Commit Graph

91 Commits

Author SHA1 Message Date
rillig 1c89b83dd4 mkdep: avoid memory allocation in findcc
This change takes the idea of handling strings as pairs in the form
(start, len) by Robert Elz from
https://mail-index.netbsd.org/source-changes-d/2021/08/20/msg013427.html
and expands it by avoiding one more memory allocation, for iterating the
PATH environment variable.

No functional change.
2021-08-20 06:36:10 +00:00
rillig 9108d0c35f mkdep: make argument of findcc const
Previously, findcc modified its argument string, even though it had been
declared as 'const char *'.  This triggered a lint warning that "strchr
effectively discards 'const char *' from argument", in fact, this code
caused the lint check to be implemented in the first place.

The first attempt at fixing it by removing the 'const' from the
parameter type was a bad idea since it made the API of that function
more complicated.

Revert back to making the parameter a 'const char *' and duplicate that
string internally as necessary.  Add a few more tests for absolute
pathnames since these had been missing before.  There are no tests yet
for snprintf with too long strings, but the current change does not
modify that part of the code.
2021-08-20 05:45:19 +00:00
rillig bcffde7ea8 mkdep: fix string constness in call to findcc 2021-08-20 04:23:56 +00:00
rillig 7b082b39f1 mkdep: fix prototype of findcc
A function that modifies a string argument must not declare that
argument as 'const char *', even if all callers (mkdep and lint) always
pass it a modifiable string.

No functional change.
2021-08-19 21:21:04 +00:00
rillig 27aee6b2ec mkdep: document possible undefined behavior
If findcc is called with a constant string, as its prototype suggests,
the process crashes with a segmentation fault.  Luckily, neither mkdep
nor lint do that, but the function prototype is nevertheless confusing.
2021-08-11 20:48:16 +00:00
joerg cebcb94770 deconst -> __UNCONST to avoid null pointer arithmetic 2018-05-23 21:20:20 +00:00
christos ff53269704 fix some error handling. 2015-06-16 22:54:10 +00:00
christos f5b1598c2a Conditionally include the depend files. 2013-03-05 21:57:47 +00:00
christos dc18bf8e97 add -i and -v 2013-03-05 01:59:56 +00:00
jmmv cdcce7d462 Add a new "-P prefix" option to mkdep(1).
This option prepends the string given in prefix to every target
filename.  This is useful for programs that have source files in
multiple subdirectories and a single Makefile that references all of
them explicitly (without using the VPATH functionality because there
can be files with the same name in each subdirectory).
2012-08-26 22:37:19 +00:00
joerg 4e46e5935f ANSIfy + static + __dead 2011-09-04 20:29:12 +00:00
wiz 4cbd24b23f dependant -> dependent 2011-06-30 20:09:15 +00:00
enami 179c4640cc Don't touch before the mmap'ed region. 2011-05-31 02:34:32 +00:00
christos 856fae793d Handle the empty suffix properly. Convert suffix list to a list from an
array and don't have limits in the suffix length. Also don't require that
suffixes have a single dot.
2011-05-30 22:52:12 +00:00
christos 28e5fe5363 Recognize --sysroot but don't document it or do anything about it for now. 2011-04-17 22:35:22 +00:00
dholland 1657dadafa Per PR 19359 note that mkdep doesn't handle all make metacharacters
correctly; in particular, filenames containing '#' cause trouble,
although '$' seems to be ok. Bump date.
2010-10-15 05:46:48 +00:00
christos 478b26f3ff fix empty suffix case. 2010-05-26 18:07:34 +00:00
christos 07072da337 PR/43364: Nicolas Joly: mkdep(1) wrong target names when suffix list miss .o 2010-05-26 15:04:40 +00:00
lukem 63c02b1078 fix -Wcast-qual & -Wsign-compare issues 2009-04-12 14:23:30 +00:00
uebayasi a6533b8fed Comment out CFLAGS+=-g. 2009-02-13 16:02:05 +00:00
lukem 98e5374ccb Remove the \n and tabs from the __COPYRIGHT() strings.
Tweak to use a consistent format.
2008-07-21 14:19:20 +00:00
martin ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
lukem a213122ebe remove unnecessary #include 2007-09-25 04:36:30 +00:00
christos 11c53ad61c kill crypto/rmd160.h and crypto/sha2.h, and instead make symlinks to
/usr/include from /usr/include/sys. This makes all the one way hash
header handling identical.
2006-10-30 20:22:53 +00:00
christos 6cbdf318bf - make a variable volatile, that gcc warns vfork will clobber.
- don't blindly walk before the beginning of the buffer because of a
  corrupt dependency file. In this case the first character of the
  dependency file was a :
2006-10-15 18:50:47 +00:00
christos 9731df7d2d make this compile again. 2006-03-20 23:13:51 +00:00
elad cd7d931d2e plug leaks, coverity cids 92, 93. 2006-03-20 17:18:06 +00:00
wiz dbaaaf27a8 Sort options. 2005-12-12 22:49:37 +00:00
dsl 0f4ad533d7 Add a -D option that acts like -d, but reads the filenames (whitespace
separated) from stdin.
Useful (eg in Makefile.kern.inc) to avoid breaking the systems command
line limit.
2005-12-12 22:05:28 +00:00
ross 2ea481dec5 Edit -s text. 2005-10-19 18:19:41 +00:00
he f104d7d50d Initialize a couple of local variables to appease -Wuninitialized.
Marked with XXXGCC for sun2 (found while compiling for it).

Reviewed by lukem.
2005-06-07 09:33:37 +00:00
wiz 1c7022e424 Sync usage with man page. From Kouichirou Hiratsuka in PR 26224. 2004-07-13 12:00:30 +00:00
dsl 36af2f9f0c Redo code that expands the 'xxx.o' to 'xxx.o xxx.so xxx.po xxx.ln' so that
is doesn't care which of the wanted suffixes are in the input file.
Needed for my autodepend code where you don't know which compilation ran last.
2004-01-26 21:47:04 +00:00
dsl 43296f2aec Only emit each filename once in a single .OPTIONAL line when -o is given.
(Saves several MB for kernel .depend files.)
2003-12-07 20:22:49 +00:00
dsl 60dd40c33a Don't rely on mmap giving a NUL terminated buffer.
Let '--' be used to separate options to mkdep from those to cc.
2003-11-11 10:55:24 +00:00
dsl c934ce564a Fix continuation line handling. 2003-11-10 18:43:15 +00:00
dsl cffe183eef Add the following options with a view to using 'cc -MD' to automatically
create dependency files:
	-d	process xxx.d files to generate .depend (don't run ${CC})
	-o	add .OPTIONAL: <headers> to output file
	-q	don't print warnins for missing files (with -d)
	-s suf	list of suffixes to replace ".o"
The -s suf should allow all the 'afterdepend' stuff to be killed.
(christos thought this might be a good idea...)
2003-11-10 17:56:38 +00:00
lukem 171d653219 Overhaul how `build.sh tools' are used:
*	Rename "config.h" to "nbtool_config.h" and
	HAVE_CONFIG_H to HAVE_NBTOOL_CONFIG_H.
	This makes in more obvious in the source when we're using
	tools/compat/config.h versus "standard autoconf" config.h

    *	Consistently move the inclusion of nbtool_config.h to before
    	<sys/cdefs.h> so that the former can provide __RCSID() (et al),
    	and there's no need to protect those macros any more.

These changes should make it easier to "tool-ify" a program by adding:
	#if HAVE_NBTOOL_CONFIG_H
	#include "nbtool_config.h"
	#endif
to the top of the source files (for the general case).
2003-10-27 00:12:41 +00:00
agc 89aaa1bb64 Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22365, verified by myself.
2003-08-07 11:13:06 +00:00
tron e290120150 Remove old, unused and unsafe shell scripts as suggested by Jeremy C. Reed
on "current-users".
2003-06-11 16:22:10 +00:00
lukem 826a14607a Now that <bsd.prog.mk> DTRT if HOSTPROG is defined (i.e, it is a no-op),
there's no need to special-case .include-ing it.
2003-05-18 07:57:31 +00:00
msaitoh bc44d1eef4 catch SIGPIPE, too. 2003-03-28 07:38:15 +00:00
wiz 990562bfef .Nm does not need a dummy argument ("") before punctuation or
for correct formatting of the SYNOPSIS any longer.
2003-02-25 10:34:36 +00:00
elric 3799cab605 Backing this out until it works. 2003-01-19 00:42:45 +00:00
jmmv 1f46362208 When an unknown option is found, ignore it, as it may be cc related (i.e.,
-D and -I options).
2003-01-18 22:32:20 +00:00
jmmv c69d292b43 Use getopt(3) instead of specific code to parse options.
Reviewed by jdolecek.
2003-01-18 21:13:58 +00:00
msaitoh e43fc70de5 catch SIGINT, SIGHUP, SIGQUIT and SIGTERM to clear a temporary file. 2003-01-16 08:05:09 +00:00
wiz 1035faff1d writable, not writeable. 2003-01-06 20:30:28 +00:00
simonb f76ac8f4dc Split out the findcc() function that tries to determine the path to
the C compiler so other programs can use it.
2002-06-14 23:14:18 +00:00
tv 9fbd88883c Roll in fixes to permit cross-compiling from non-NetBSD hosts. This
round has been tested on Solaris/x86 and Linux hosts.

* Add host tools cap_mkdb, ctags, m4, uudecode.
* Protect __RCSID() and __COPYRIGHT() better.
* Reduce the number of places that need to include "config.h", to keep
  sources closer to their "vanilla" versions.
* Add more compat #defines and autoconf-checked functions.
2002-01-31 22:43:33 +00:00