Commit Graph

96 Commits

Author SHA1 Message Date
Warner Losh
fbbd9655e5 Renumber copyright clause 4
Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by:	Jan Schaumann <jschauma@stevens.edu>
Pull Request:	https://github.com/freebsd/freebsd/pull/96
2017-02-28 23:42:47 +00:00
Warner Losh
b14fc856d7 Make it clear that we're ignoring the return value fread(3). All
errors that might happen here will be reported a few lines down.

CID: 1295248
2015-08-24 00:34:09 +00:00
Eitan Adler
68c45bf852 config: remove set but unchecked variable
reported by: gcc5.1
2015-04-19 08:30:13 +00:00
Craig Rodrigues
69627a0de1 Add -s option to config.
This option allows for specifying the directory to use as the location for
kernel source files. This option was ported from NetBSD.

GitHub Pull Request:   https://github.com/freebsd/freebsd/pull/18
Submitted by:          Steve Kiernan <stevek@juniper.net>, Simon Gerraty <sjg@juniper.net>
Obtained from:         Juniper Networks, Inc.
Reviewed by:           imp
Differential Revision: https://reviews.freebsd.org/D1722
Relnotes:              yes
2015-01-29 22:49:30 +00:00
Ian Lepore
c72731180a Consider the negation operator (!) to be a word even if it is not followed
by whitespace.  This allows "optional !foo" which is what most programmers
are naturally going to tend to do as opposed to "optional ! foo".
2014-11-23 19:13:17 +00:00
Alan Somers
ae0944614d Fix kern/187712: config(8) does not respect KERNCONFDIR.
The impact of this bug is that you cannot build a kernel if both of the
following are true:
1) The kernel config file is in a non-default location
2) The kernel config file uses the "include" statement from config(5).

usr.sbin/config/main.c
usr.sbin/config/config.8
usr.sbin/config/config.h
usr.sbin/config/lang.l
	Added a "-I path" option to config(8).  By analogy to cc(1), it adds
	an extra path in which the "include" statement will search for
	files.

Makefile.inc1
	Pass "-I ${KERNCONFDIR}" to config(8).

PR:		kern/187712
Reviewed by:	will, imp (previous version)
MFC after:	3 weeks
Sponsored by:	Spectra Logic Corporation
2014-03-20 17:30:09 +00:00
Wojciech A. Koszek
7002629c49 Make the internal assertion correct--only fail when '\0' is found in
places other than the end of the test section. Otherwise, with kernel
compiled with Clang which happens to be setting ELF section alignment
differently config(8) was throwing assert() failure unnecessarily

Reported by:	Kimmo Paasiala <kpaasial (at) gmail.com>
Tested by:	Kimmo Paasiala <kpaasial (at) gmail.com>
MFC after:	10 days
2013-05-01 05:14:59 +00:00
Jung-uk Kim
52569792bd Loosen restrictions for quoted strings. Now we can use more complex strings
and "escaped" quote characters.

MFC after:	1 month
2013-03-26 23:58:13 +00:00
Baptiste Daroussin
5e2a209a27 Fix world after byacc import:
- old yacc(1) use to magicially append stdlib.h, while new one don't
- new yacc(1) do declare yyparse by itself, fix redundant declaration of
  'yyparse'

Approved by:	des (mentor)
2012-05-22 16:33:10 +00:00
Ed Schouten
b3608ae18f Replace index() and rindex() calls with strchr() and strrchr().
The index() and rindex() functions were marked LEGACY in the 2001
revision of POSIX and were subsequently removed from the 2008 revision.
The strchr() and strrchr() functions are part of the C standard.

This makes the source code a lot more consistent, as most of these C
files also call into other str*() routines. In fact, about a dozen
already perform strchr() calls.
2012-01-03 18:51:58 +00:00
Ed Schouten
0732dbfff5 Improve portability of config(8).
- Use strlen(dp->d_name) instead of the unportable dp->d_namlen. Rename
  i to len to make it slightly more descriptive and prevent negative
  indexing of the array.
- Replace index() by strchr().

This supposedly fixes compilation on GNU systems.

Submitted by:	Robert Millan <rmh debian org> (original patch)
MFC after:	3 weeks
2011-07-03 20:59:57 +00:00
John Baldwin
67fb1bc8ed Remove support for creating the 'machine' symlink as well as creating the
extra MACHINE_ARCH symlink for certain platforms (such as pc98).  The
support for creating these symlinks was added to sys/conf/kern.post.mk in
changeset 152964.  The intention of that commit was to remove this code
from config(8), but config(8) was never updated.

Approved by:	imp
2010-10-29 19:17:07 +00:00
Nathan Whitehorn
9b047d4a9a Enhance config to handle MACHINEs with multiple architectures:
- Passing -m to config will now print the MACHINE and MACHINE_ARCH
  given in the passed kernel configuration file and then exit.
- If an option is defined in options.MACHINE with the same name as the
  architecture of the kernel being configured, that option will be
  considered set. This allows conditional compilation based on CPU
  architecture.

Config version is now 600010.

Reviewed by:	imp
2010-07-13 04:08:08 +00:00
Warner Losh
02b9c3f52f sparc64, and possibly other architectures, pads the length of the
section holding the config file to sh_addralign bytes using NULs.
This bogusly triggers an assert.  Break out of the loop when we hit an
NUL within that many bytes of the end.

MFC after:	3 days
2010-05-01 07:25:28 +00:00
Warner Losh
90aa4f9e8c Move checking the version up from Makefile generation to just after
we've parsed the config file.  Makefile generation is too late if
we've introduce changes to the syntax of the metafiles to warn about
version skew, since we have to try to parse them and we get an parse
error that's rather baffling to the user rather than a 'your config is
too old, upgrade' which we should get.

We have to defer doing it until after we've read the user's config
file because we define machinename there.  The version required to
compile the kernel is encoded in Makefile.machinename.  There's no
real reason for this to be the case, but changing it now would
introduce some logistical issues that I'd rather avoid for the moment.
I intend to revisit this if we're still using config in FreeBSD 10.

This also means that we cannot introduce any config metafile changes
that result in a syntax error or other error for the user until 9.0 is
released.  Otherwise, we break the upgrade path, or at least reduce
the usefulness of the error messages we generate.

# This implies that the config file option mapping will need to be redone.

MFC after:	3 days
2010-04-27 05:04:32 +00:00
Ruslan Ermilov
53d55e9756 - Handle calloc() allocation failures.
- Fixed a comment.
- 2 -> EXIT_FAILURE in some places.
- errx() -> err() where appropriate.

PR:		144644
Submitted by:	Garrett Cooper
2010-03-30 13:46:40 +00:00
Wojciech A. Koszek
4ac2fcaa45 Move the comment to it's correct place. 2009-02-07 11:40:47 +00:00
Wojciech A. Koszek
fcba95d49e Remove leftover of alpha support for config(8)--we have MAP_FAILED
globally defined.
2009-02-07 11:12:30 +00:00
Wojciech A. Koszek
d030e65009 Make config -x <kernel> only return non-zero characters,
so that:

	config -x <kernel> | grep <something>

just works.

Reported by:	Danny Braniss <danny@cs.huji.ac.il>
2009-02-06 00:50:21 +00:00
Warner Losh
30f94bb497 Fix a bug introduced by DEFAULTS feature. When the config file
doesn't exist, we make a directory and then say "oops, that file isn't
there" leaving the directory behind.  Add a stat for the config file
so that we detect this before making the directory.  This is
semi-lame, but less lame than having this bug.
2008-04-10 22:57:54 +00:00
Ed Maste
3b2262e488 Honour the logical current working directory ($PWD) when using config's
-d destdir option.  For an automounted src tree using the logical cwd
in the Makefile keeps amd(8)'s mount timeout refreshed.  Code to check
$PWD's validity cribbed from pwd(1).

Discussed on hackers@.
2008-01-08 21:10:13 +00:00
Warner Losh
c1f4dd9355 Fix some problems that affect multiple file inclusion. Bruce found
this bug and submitted these patches to dunstan@.  He sent them to me
to test, and I discovered they were needed for the atmel kernel config
files.  Since we were playing with them in the terminal room after the
developer's summit today, I thought I'd go ahead and commit them to
allow those folks that now have atmel hardware (thanks Andre) a chance
to try it out w/o my help.  Since dunstan@ is asleep right now, risk
stepping on his toes a little by going ahead and committing this
change.

Submitted by: dunstan@, bde@
Tested by: bde@
2007-05-17 04:53:52 +00:00
Wojciech A. Koszek
ae7a150a68 This is loser's commit message:
Remember about tricky cases, where options contain unfriendly characters,
from the ANSI-C string point of view ('"' in this case). The x09 build
breakage was caused by SC_CUT_SEPCHARS options.

I did test this patch number of times; each time unprofessionally and
inappropriately.

OKed by:	cognet (mentor)
2007-05-12 22:37:52 +00:00
Wojciech A. Koszek
744b947ef8 Improve INCLUDE_CONFIG_FILE support.
This change will let us to have full configuration of a running kernel
available in sysctl:

	sysctl -b kern.conftxt

The same configuration is also contained within the kernel image. It can be
obtained with:

	config -x <kernelfile>

Current functionality lets you to quickly recover kernel configuration, by
simply redirecting output from commands presented above and starting kernel
build procedure. "include" statements are also honored, which means options
and devices from included files are also included.

Please note that comments from configuration files are not preserved by
default. In order to preserve them, you can use -C flag for config(8). This
will bring configuration file and included files literally; however,
redirection to a file no longer works directly.

This commit was followed by discussion, that took place on freebsd-current@.
For more details, look here:

	http://lists.freebsd.org/pipermail/freebsd-current/2007-March/069994.html
	http://lists.freebsd.org/pipermail/freebsd-current/2007-May/071844.html

Development of this patch took place in Perforce, hierarchy:

	//depot/user/wkoszek/wkoszek_kconftxt/

Support from:	freebsd-current@ (links above)
Reviewed by:	imp@
Approved by:	imp@
2007-05-12 19:38:18 +00:00
Warner Losh
86418d0cef End my resistance to jmg's multiple hints files and bring in support
for having multiple hints files generate a correct hints.c (eg, with
all the specified ones catenated together).
2006-10-24 00:31:59 +00:00
Xin LI
5f17c1e2b2 Use calloc() instead of zeroing the memory our own. 2006-06-07 01:43:26 +00:00
Florent Thoumie
34e703473c - Change the exit message from "make cleandepend; make depend" to
"make cleandepend && make depend".

PR:		bin/91765
Submitted by:	Soeren Straarup <xride@x12.dk>
Approved by:	cpercival
MFC after:	3 days
2006-01-14 08:12:25 +00:00
Ruslan Ermilov
22025511b4 Clean up most of the "XXX"-tagged items:
- The code that creates hints.c and env.c from the skeleton files
  moved into separate functions.

- Sanity checks for missing "ident" and "cputype" directives moved
  into main(), alongside the existing check for "machine".

PR:		bin/90310
Submitted by:	Matt Emmerton <matt@gsicomp.on.ca>
2005-12-30 15:29:50 +00:00
Ruslan Ermilov
f0caeb4419 Style: use S_ISDIR() (submitted by bde@) and eq() where appropriate. 2005-11-30 17:55:49 +00:00
Peter Wemm
03349079fe The DEFAULTS changes caused the user specified config file to be opened
much later than before, and it is now after we do a mkdir ../compile/FILE.
As a result, if you do 'config DOESNOTEXIST', it now creates the directory
../config/DOESNOTEXIST.  It did not do that before.  If DEFAULTS does not
exist, it still fails early before any permanent changes.

This shameless hack restores the old behavior of ensuring the config file
actually exists before mkdiring its counterpart directory.

Now I can rmdir ../compile/D and it will stay dead, after my fingers keep
sabotaging me with 'config D<tab><enter>'.  (Some of my kernel names
started with D, which used to be 1-character unique and my fingers knew
this very well...)
2005-11-29 22:54:49 +00:00
John Baldwin
dfdbf9be00 Optionally include a DEFAULTS config file if it is present in the current
directory before the specified config file.  This is implemented by
opening DEFAULTS as stdin if it exists, and if so resetting stdin to the
actual config file when DEFAULTS is fully parsed via yywrap().  In short,
this lets us create DEFAULTS kernel configs in /sys/<arch>/conf that can
enable certain options or devices by default and allow users to disable
them via 'nooptions' or 'nodevice' rather than having to create kludge
NO_FOO options.

Requested by:	scottl
Reviewed by:	scottl
2005-10-27 17:13:23 +00:00
David E. O'Brien
216a5fbf37 Put rev. 1.65 into usage(). 2005-08-11 15:23:23 +00:00
David E. O'Brien
71d8a448ac Add an option to tell what version of config(8) this is. 2005-08-10 06:36:44 +00:00
Ruslan Ermilov
de12942735 Ask that "make cleandepend" be run before "make depend", now that
we don't do this automatically.

Suggested by:	bde
2005-04-22 17:42:50 +00:00
Warner Losh
51c1297a48 Allow one to specify a second parameter to the machine line. This
allows us to specify the machine_arch as well as machine.  If
specified then a second link will be made, similar to machine, from
$MACHINE_ARCH to $S/$MACHINE_ARCH/include.

This is for ports where MACHINE != MACHINE_ARCH (pc98 today, others in
the future?).

Reviewed by: arch@, nyan@
2005-04-01 22:54:22 +00:00
Warner Losh
a2920586a8 style(9) nits 2005-03-30 21:45:08 +00:00
Dag-Erling Smørgrav
8acd37ef20 Unstaticize config. It was being optimized away.
MFC after:	3 days
2005-03-27 13:44:00 +00:00
Warner Losh
23717fc46a Per letter dated July 22, 1999, delete clause 3 from code directly
from Berkeley.
2004-08-07 04:19:37 +00:00
Olivier Houchard
43a903c091 Add a new "files" directive, which allows to include a files.foo file directly
from a kernel config file.
Bump config version to reflect this change.
2004-05-09 22:29:00 +00:00
Thomas Moestl
74155a4873 Check the return values of opendir() and unlink() in cleanheaders().
If unlink() fails, just print a warning for now.
2003-06-12 11:36:54 +00:00
Ruslan Ermilov
292dd8a87f Convert to using <sys/queue.h> macros. 2003-02-15 02:26:13 +00:00
David E. O'Brien
4ffcd14286 We don't need to hit the user over the head so strong now that we've
fixed all the known warnings suffiently to not require NO_WERROR.

Ok'ed by:	peter
2002-07-06 01:07:48 +00:00
Peter Wemm
916cd514f2 Add a hint about -DNO_WERROR 2002-02-25 21:59:57 +00:00
Peter Wemm
ef1cb1959c Remove the old machine symlink first. 2001-07-14 00:03:05 +00:00
Dima Dorfman
5e06480c9f Introduce an "include" directive. It takes one argument, a filename
to be included into this one.  This works the same way as #include
does in C; as far as the user is concerned, the included file is
inlined into the current one.

Since config(8) is no longer limited to working on one user-supplied
file, printing just a line number in an error message is not
sufficient.  The new global variable yyfile represents the file
currently being parsed, and must be printed as well.

Reviewed by:	imp
Obtained from:	OpenBSD
2001-07-12 02:08:51 +00:00
Warner Losh
971470c36c Move kernel compile directory from sys/compile/FOO to
sys/compile/${MACHINE}/FOO.

Reviewed by: obrien, peter and the USENIX terminal room secret kernel cabal
2001-06-30 06:28:12 +00:00
Peter Wemm
ed53c6c5c0 Move the 'dont forget "make depend"' to be the last thing that people see,
after the warnings.
2001-02-23 00:22:04 +00:00
Peter Wemm
68f4fced95 ${BDECFLAGS} work. And fix a real error in the process. A "MAXUSERS"
string could have been passed to free();  There are some warnings here
I am not sure how to fix as they are in the lex scanner code, etc.
2001-02-19 04:43:21 +00:00
Peter Wemm
3b10a240e5 Remove the need to list each and every cpu platform. Config will now
take your word for the 'machine' switch.
2001-02-04 13:17:38 +00:00
Peter Wemm
ace858085f Redo the stray header file cleanup code to not depend on timestamps
or access times or anything.  Just bite the bullet and keep a list of
header files that we know about.
2001-01-31 08:42:35 +00:00