summaryrefslogtreecommitdiff
path: root/usr.bin/make/main.c
AgeCommit message (Collapse)Author
2001-11-11Fixed version... don't see how this could work on i386, since it didn'tMarc Espie
initialize create in main.c.
2001-11-11undo changes that crash on (at least) the alphaTheo de Raadt
2001-11-11Redo LstInit as a macro: smaller and faster code in all cases, zeroing twoMarc Espie
pointers is simpler than calling a function. Recognize purely static lst headers, which don't really need any initialization. ok miod@
2001-06-05Use Str_concat instead of fixed buffers and snprintf in building paths.Marc Espie
Replace MAXPATHLEN with PATH_MAX (synch with op-make). ok naddy@
2001-06-03Make sure targs get initialized.Marc Espie
Don't bother cleaning it up for speed
2001-05-31Simple guard against overflow. Better code to appear.Marc Espie
2001-05-29Protect against copying a too long PWD.Marc Espie
This is temporary, this code needs better fixes.
2001-05-29Take includes out of lst.h, re-add what's needed to separate files.Marc Espie
Removes remaining lint stuff from lst.lib.
2001-05-23Mostly clean-up:Marc Espie
- cut up those huge include files into separate interfaces for all modules. Put the interface documentation there, and not with the implementation. - light-weight includes for needed concrete types (lst_t.h, timestamp_t.h). - cut out some more logically separate parts: cmd_exec, varname, parsevar, timestamp. - put all error handling functions together, so that we will be able to clean them up. - more systematic naming: functioni to handle interval, function to handle string. - put the init/end code apart to minimize coupling. - kill weird types like ReturnStatus and Boolean. Use standard bool (with a fallback for non-iso systems) - better interface documentation for lots of subsystems. As a result, make compilation goes somewhat faster (5%, even considering the largish BSD copyrights to read). The corresponding preprocessed source goes down from 1,5M to 1M. A few minor code changes as well: Parse_DoVar is no longer destructive. Parse_IsVar functionality is folded into Parse_DoVar (as it knows what an assignment is), a few more interval handling functions. Avoid calling XXX_End when they do nothing, just #define XXX_End to nothing. Parse_DoVar is slightly more general: it will handle compound assignments as long as they make sense, e.g., VAR +!= cmd will work. As a side effect, VAR++=value now triggers an error (two + in assignment). - this stuff doesn't occur in portable Makefiles. - writing VAR++ = value or VAR+ +=value disambiguates it. - this is a good thing, it uncovered a bug in bsd.port.mk. Tested by naddy@. Okayed millert@. I'll handle the fallback if there is any. This went through a full make build anyways, including isakmpd (without mickey's custom binutils, as he didn't see fit to share it with me).
2001-05-07avoid closing the same file twice. parse module assumes ownership ofMarc Espie
file handles it's passed to. (this is apparently harmless on BSDs, but is still a bug).
2001-05-03Synch with my current work.Marc Espie
Numerous changes: - generate can build several tables - style cleanup - statistics code - use variable names throughout (struct Name) - recursive variables everywhere - faster parser (pass buffer along instead of allocating multiple copies) - correct parser. Handles comments everywhere, and ; correctly - more string intervals - simplified dir.c, less recursion. - extended for loops - sinclude() - finished removing extra junk from Lst_* - handles ${@D} and friends in a simpler way - cleaned up and modular VarModifiers handling. - recognizes some gnu Makefile usages and errors out about them. Additionally, some extra functionality is defined by FEATURES. The set of functionalities is currently hardcoded to OpenBSD defaults, but this may include support for some NetBSD extensions, like ODE modifiers. Backed by miod@ and millert@, who finally got sick of my endless patches...
2000-11-24Change the time stamp interface to use an abstract datatype.Marc Espie
Define two possible interfaces: the classic one, and the new one (used where available) that depends on timespec. Better granularity, make is now able to distinguish between files that were built during the same second.
2000-10-13esetenv: does a setenv and bails out if error.Marc Espie
2000-09-14Replace the old hash used to hold file names within a directory withMarc Espie
open hashing. An interesting optimization is that the open hashing interface is more fine-grained, hence we can compute the correct hash value at the start of Dir_FindFile, and reuse it for each hash structure into which we look (the effect is measurable on large directories along with objdir/VPATH). Remove a few unnecessary Lst_Open/Lst_Close that serve no purpose except obfuscating the code. The interface to dir.h changes slightly, hence tedious includes changes...
2000-09-14- new DirReadDir internal function, that just reads a directory fromMarc Espie
the disk or from a cache. - use it in Dir_AddDir, and directly to set up dot. - change Dir_AddDir to use string intervals, as this simplifies dependend functions. - set up an open-hashing cache for opened directory names. - add_dirpath() function in main, to simplify code. - simplify cleaning-up directories, as Dir_ClearPath is overkill.
2000-09-14Some systematic clean-up.Marc Espie
- UNUSED macro that expands to __attribute__((unused)) for gcc - move rcsid around so that they can be tagged UNUSED. - activate -Wunused. - use UNUSED instead of kludgy junk for function arguments. - add extern to all extern prototypes. - update comments in lst.h. - clean up var.c a little bit, constifying arguments, updating comments...
2000-07-31POSIX rules: pass variables set on the command line to submakes throughMarc Espie
MAKEFLAGS
2000-07-18Handle MAKEFLAGS variation mandated by POSIX.Marc Espie
Code to pass variable definitions to submakes through make flags. Not activated yet, need to fix src/ first.
2000-07-01Forgot to import one estrdup from my trunk.Marc Espie
Ensure make prints sane error messages when obj/ exists.
2000-06-23This patch is worth a lot, speed-wise.Marc Espie
This does introduce a proper stack of IFiles to handle included files: instead of having the current file be a special case, it's also an IFile. The corresponding code is slightly unobfuscated, removing the error-prone ParseEOF function, freeing the filename systematically (thus, main.c needs to strdup stdin), and merging both include functions lookup into one. The speed gain comes from changing the IFile structure to merge with fgetln seamlessly. The low-level parse code is mostly moved to a new file, lowparse.c, to make things easier to read (see next patch as well). Accordingly, util.c gains a fgetln. Note the interaction between Parse_File, Dir_FindFile, and ReadMakefile in main.c. This patch closes a subtle memory hole (only the Makefile names, so rather small). Reviewed by miod@.
2000-06-23This patch separates local contexts from global contexts for good.Marc Espie
Apart from a few casts, VAR_GLOBAL and friends are separate data structures, so we use a small array for local variables. We also junk allVars, since TargFreeGN can release local nodes, and var.c has explicit lists for its variables already. Reviewed millert@ and miod@.
2000-06-23Trivial consequences of the previous list changes:Marc Espie
- audit code for Lst_Datum, it's never applied to an empty pointer, so check can be removed -> turn into a macro, - Lst_First, Lst_Last can become macro as well - specialized version of Lst_Succ (Lst_Adv) to use in loops where it cannot fail, - Lst_Open can no longer fail. Trim down corresponding code. Reviewed millert@, miod@
2000-06-17A few assorted changes, to remove more dynamic lists.Marc Espie
- in Dir_Expand, path is a misnomer. Use a temp variable instead... Reformat code for readability. - Change Parse_MainName/Targ_FindList so that they fill arguments instead of allocating new lists. - nuke Targ_FindList(TG_NOCREATE), as this is never used. - close a small memory hole (forgot to free sysMkPath if CLEANUP). Reviewed by millert@
2000-06-17This patch introduces a distinction betweenMarc Espie
Lst_Init (constructor) and Lst_New (allocation + construction) Lst_Destroy (destructor) and Lst_Delete (deallocation + destruction), and uses that to turn most dynamic allocation of lists (Lst pointers) into static structures (LIST). Most of this is mundane, except for allGNs in targ.c, where the code must be checked to verify that Targ_Init is called soon enough. Lst_New is a temporary addition. All lists will soon be static. Reviewed by millert@, like the previous patch.
2000-06-10Clean-up patch: use `void *' instead of old-fashioned ClientData/Address.Marc Espie
2000-06-10Thus, Lst_ForEach no longer needs returning a status.Marc Espie
In fact, it can become a macro based on Lst_ForEachFrom. This also introduces Lst_Every, as a shortcut for the very common case where Lst_ForEach does not need any user data. Finally, make consistent use of a few function typedefs, instead of having explicit void (*)(Lst) arguments all over the place.
2000-04-03Junk CDPATH from the environment.Marc Espie
2000-03-26Remove idiotic, braindead casts T* -> void*Marc Espie
They serve no purpose, except hiding potential bugs. In particular, remove (ClientData) cast from macro, showing potentially troublesome use of Hashes to store time_t.
2000-02-02Bug-fix: make should behave sensibly when presented with negative times...Marc Espie
- let *_MTime return booleans, as that's what they're used for, the time_t is set as a side effect. - use OUT_OF_DATE for a date starting point, set it at the origin of time.
1999-12-19Rearrange Lst_Find interface to conform better with other functions.Marc Espie
1999-12-18Nothing ever checks ReturnStatus on Lst_Insert, Lst_Append, Lst_AtFront,Marc Espie
Lst_AtEnd, Lst_Concat, Lst_Remove, Lst_Replace. Don't bother returning one.
1999-12-18NIL, NILGNODE, etc, are only glorified NULL.Marc Espie
Get rid of them. Get rid of list.h, nothing uses it anyway.
1999-12-18make does not use circular lists, get rid of the extra weight.Marc Espie
1999-12-16Var_Subst is actually two distinct functions folded into one:Marc Espie
split the function specific to for.c out, and give them more sensible arguments at the same time. This makes .for loop handling more efficient, as we have some heuristic to evaluate the size of the buffer needed...
1999-12-16Allocate buffers as static data structures.Marc Espie
This cuts down quite a lot of malloc, since in actual use, buffer usage is mostly static.
1999-12-16Split Buf_GetAll into Buf_Retrieve/Buf_Size.Marc Espie
(idiotic to retrieve size every time when it's used half the time)
1999-12-09Split some allocation/error handling functions out of main.cMarc Espie
1999-12-06Extra parameter no longer needed, ditch.Marc Espie
1999-12-06Clean up buffers interface somewhat:Marc Espie
- buf.c deals exclusively with chars. Be explicit about it, and remove extraneous dumb casts to char (can hide real type errors). - buffer sizes are size_t. Note that bp->left can never become NULL. - Buf_GetAll is happy with a NULL pointer for the size, remove unneeded extra pointers. - Propagate size_t to all places where buffer functions are used.
1999-12-06Fix handling ofMarc Espie
VAR!= specifically, properly distinguish between bad commands and empty results.
1999-11-10Turn on strict-prototypes, add missing prototypes.Marc Espie
Move main prototype to main.c, as this is not used from any other file. Close open bug.
1999-01-09close PR 685.Marc Espie
Slightly trimmed down version of fix by assar@sics.se (strtol failure is usually simpler to test, and error messages should identify the program that produces them)
1998-12-05Modifications from netbsd:Marc Espie
- don't interfere with MACHINE/MACHINE_ARCH defines for bootstrap - type clean-up, time_t, and printing `unknown' ints - fix TARGET/MEMBER bug in archive rules - memmove... - cleaner Error handler. - reentrant brk_string - .MAKE env variable - preliminary scaffolding for .NOPATH Other improvements: - efree - shellneed streamlined - display Stop in .CURDIR after an error. - document most features and misfeatures. - add a few OpenBSD notes to the tutorial.
1998-01-28Use BSDmakefile in favour of [mM]akefile if existent. Good forNiklas Hallqvist
cases where you want BSDmake specific facilities not messing up other implementations of make
1997-04-01Sync with NetBSD (mostly by christos initial substitution/regexp from Der Mouse)Todd C. Miller
- fix the variable substitution code in make [PR/2748] 1. change s/a/b/ so that it substitutes the first occurance of the pattern on each word, not only the first word. 2. add flag '1' to the variable substitution so that the substitutions get performed only once. ***THIS IS AN INCOMPATIBLE CHANGE!*** Unfortunately there was no way to make things consistent without modifying the current behavior. Fortunately none of our Makefiles depended on this. OLD: VAR = aa1 aa2 aa3 aa4 S/a/b/ = ba1 aa2 aa3 aa4 S/a/b/g = bb1 bb2 bb3 bb4 NEW: VAR = aa1 aa2 aa3 aa4 S/a/b/ = ba1 ba2 ba3 ba4 S/a/b/1 = ba1 aa2 aa3 aa4 S/a/b/g = bb1 bb2 bb3 bb4 S/a/b/1g = bb1 aa2 aa3 aa4 - add regexp variable substitution via 'C/foo/bar/' [PR/2752] - add variable quoting via the ${VAR:Q} modifier. This is useful when running recursive invocations of make(1): make VAR=${VAR:Q} will always work... (This may prove useful in the kernel builds...) [PR/2981] - BSD did not traditionally have <sys/cdefs.h>; use BSD4_4 instead and include <sys/param.h> to grab it. - Don't compile the regex code if MAKE_BOOTSTRAP (from gwr) - Use explicit .c.o rule in Makefile.boot so that the bootstrap process works. - Use only integral types in procedure arguments. [buf.c buf.h] - Include <stdlib.h> to get getenv() prototype on SVR4 - if __STDC__ -> ifdef __STDC__ to appease SVR4 - Define const and volatile for non __STDC__ - Implement snprintf() and vsnprintf() for non BSD4_4 systems. - Make $MACHINE_ARCH settable from the environment. - Fix .USE directive problems: (reported by cgd) 1. ${.*} variables did not get expanded in dependencies. 2. expanded ${.*} variables in .USE dependencies can cause tree restructuring; handle it. 3. in compat mode, expand .USE before evaluating the list of targets, instead of doing .USE expansions on demand, because they can cause tree restructuring. - Add a .MADE directive to indicated that the children of a target are up-to-date, even when they are not. This is to simulate our current make install behavior with proper dependencies. - Fix problems in the RE substitution error handling. - Locate all the children of a node marked as MADE. - Do not compile-in ${MACHINE} (as per NetBSD PR#3386) - Disable globbing for targets/dependencies when POSIX is defined. - Fix globbing so that patterns that don't have a matching number of [] or {} don't get expanded. (before the [ case got expanded to nothing!) This is disabled. - Make sure that the children of nodes that are marked .MADE, are marked UPTODATE and their timestamps are consistent. - Don't disable wildcards completely; they are used by other Makefiles.
1997-01-27Set MACHINE_ARCH only if it's not already in the environment. Updatebriggs
comment accordingly. Patch from Dale Rahn.
1997-01-15getopt(3) returns -1 when out of args, not EOF, whee!Todd C. Miller
1996-11-30Sync with NetBSD:Todd C. Miller
- Merge in FreeBSD and Lite2 changes. - Fix bug where a non-archive target with a .a suffix would always be considered to be out of date, since it does not have a TOC. - Fix NetBSD PR #2930: declare missing variable.
1996-09-02Sync up with NetBSD:briggs
(christos) Fix bug reported by Greg Hudson where leaf (source only) nodes were referenced only by their basename and not by their full pathname. This breaks when .PATH or MAKEOBJDIR are used. There might be Makefiles around that try to work around this bug by prepending ${.CURDIR} to the sources, and they should be found and fixed. Also a lot of the gunk in suff.c that was attempting to work around the same problem could be removed. (christos) - Move -D flags from Makefile to config.h and explain what they do. Add -Wall -Wno-unused to CFLAGS. Add new define SYSVVARSUB to enable SysV style variable substitutions and enable them. - Add SunOS style command substitutions via SUNSHCMD - Fix core dump with '{variable = value' (christos) Fix bug where make will always exit with 0, even when one or more parallel jobs failed. (Only affects parallel make code) (christos) Protect __P from being multiply defined (for systems that already define it) (christos) Add strdup() since ultrix is missing it. From Larry Schwimmer <rosebud@cyclone.Stanford.EDU> (christos) Add estrdup(), a checked version of strdup and use it. (christos) Recognize SVR4 style long filename entries in archives. (thorpej) Tidy up some RCS ids a bit.
1996-04-21sync to netbsd 960418Theo de Raadt