Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site ucsfcgl.UUCP Path: utzoo!watmath!clyde!burl!ulysses!ucbvax!ucsfcgl!kneller From: kneller@ucsfcgl.UUCP (Don Kneller%Langridge) Newsgroups: net.micro.pc Subject: MSDOS make (repost 1 of 2) Message-ID: <771@ucsfcgl.UUCP> Date: Mon, 10-Feb-86 14:52:46 EST Article-I.D.: ucsfcgl.771 Posted: Mon Feb 10 14:52:46 1986 Date-Received: Wed, 12-Feb-86 07:37:15 EST Reply-To: kneller@ucsfcgl.UUCP (Don Kneller) Organization: UCSF Computer Graphics Lab Lines: 986 Keywords: make, program maintenance This is a reposting because we were having severe network problems for the past week and some of our news and mail was lost in transit. This is the documentation and a sample init file for NDMAKE 3.0. The uuencoded binary has been posted as a separate article. As described below, use `/bin/sh' on this file to create `READ.ME', `make.doc' and `make.ini'. Don Kneller UUCP: ...ucbvax!ucsfcgl!kneller ARPA: kneller@ucsf-cgl.ARPA BITNET: kneller@ucsfcgl.BITNET ------------------------------ CUT ---------------------------- #!/bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #!/bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # READ.ME # make.doc # make.ini # This archive created: Tue Feb 4 16:30:39 1986 export PATH; PATH=/bin:$PATH echo shar: extracting "'READ.ME'" '(391 characters)' if test -f 'READ.ME' then echo shar: over-writing existing file "'READ.ME'" fi sed 's/^X//' << \SHAR_EOF > 'READ.ME' XNDMAKE 3.0 is similar to UN*X `make'. It has the same syntax and Xmost of the capabilities as the UN*X version (VPATH and archives Xare not yet supported). X XIf you are reposting NDMAKE to a BBS or FIDO system, please put XMAKE.DOC, MAKE.INI and MAKE.EXE in an ARChive called NDMAKE30.ARC X X Don Kneller XUUCP: ...ucbvax!ucsfcgl!kneller XARPA: kneller@ucsf-cgl.ARPA XBITNET: kneller@ucsfcgl.BITNET SHAR_EOF if test 391 -ne "`wc -c 'READ.ME'`" then echo shar: error transmitting "'READ.ME'" '(should have been 391 characters)' fi echo shar: extracting "'make.doc'" '(25146 characters)' if test -f 'make.doc' then echo shar: over-writing existing file "'make.doc'" fi sed 's/^X//' << \SHAR_EOF > 'make.doc' X X X X X X X X NDMAKE version 3.0 X ------------------ X Copyright (C) 1985, 1986 D. G. Kneller X All rights reserved. X X X Program Description X ------------------- X X NDMAKE is an implementation of the UN*X program maintenance utility X called `make'. It has the same syntax and most of the capability. If X you are familiar with UN*X `make' you should have no difficulties with X NDMAKE. In the rest of this documentation, NDMAKE will be referred to X simply as `MAKE'. X X MAKE is a utility that helps you maintain programs, particularly X programs that are composed of several modules (files). Once you X describe the relationships between these modules, MAKE will keep track X of the modules and only `make' those that are out of date with respect X to their sources. MAKE can also be used as a general compile and link X tool for handling single files, much like a batch file. X X MAKE requires at least DOS 2.0 and uses a minimum of about 30000 bytes X of memory. Since MAKE executes other programs from within itself, X this memory will be unavailable to them while MAKE is running. Also, X since MAKE uses the file time to determine which files are newer, it X is imperative that you either have a real-time clock or are diligent X about setting the time and date when you boot up. X X X Synopsis X -------- X X make [-f makefile] [options] [macros] [targets] X X The [] signify optional parameters. [options] and [macros] will be X discussed later. X X X Description X ----------- X X MAKE executes commands in a MAKE description file to update one or X more targets. The targets are typically the names of programs. If no X -f option is present, the MAKE description file called `makefile' is X tried. If makefile is `-', the keyboard (standard input) is used as X the makefile. More than one -f option may appear. X X Make updates a target if it is older than the files it depends on, or X if the target does not exist. If no targets are given on the command X line, the first target in the makefile is `made'. X X X X X X X X X NDMAKE v3.0 page 2 X X X X X X The MAKE description files X -------------------------- X X MAKE uses 2 description files: `makefile' and `make.ini'. The X description files consists of several kinds of entries: X X 1) dependency and command lines X 2) macro definitions X 3) default rules X 4) "dot commands" X X When MAKE starts up, it looks for an initialization file called X `make.ini'. This file usually contains only default rules and macro X definitions that you don't want to put in every makefile. The current X directory is searched first, followed by directories along the PATH. X You customize your copy of MAKE by changing `make.ini'. X X X 1) Dependency and command lines X ------------------------------- X X These are lines that specify the relationship between targets and X dependents, and how to update the targets. The general form is: X X targets : [dependents] X [command] X .... X X where is the tab character. X X The first line of an entry is a blank-separated list of targets, then X a colon, then a list of prerequisite files. All following lines that X begin with a tab are commands to be executed to update the target. X For example, assume you have a program `test.exe' that is composed of X modules `main.obj' and `sub.obj'. Each of these depend on a common X include file, `incl.h', and on their respective `.c' files. The X makefile might look like: X X test.exe : main.obj sub.obj X link main.obj sub.obj, test; X X main.obj : main.c incl.h X msc -AL main.c; X X sub.obj : sub.c incl.h X msc -AL sub.c; X X If a target appears on the left of more than one `colon' line, then it X depends on all of the names on the right of the colon on those lines, X but only one command sequence may be specified for it. The previous X example could have been written as: X X test.exe : main.obj sub.obj X link main.obj sub.obj, test; X X X X X X X NDMAKE v3.0 page 3 X X X X X X X main.obj : main.c X msc -AL main.c; X X sub.obj : sub.c X msc -AL sub.c; X X main.obj sub.obj : incl.h X X A target that has no dependents is considered always out of date and X is always made. On the command line, wildcard characters can be given X in target names provided there are files to match the wildcards. X X X 2) Macro definitions X -------------------- X X Makefile entries of the form: X X name = [value] X X are macro definitions. Macros allow the association of a name and a X value. Subsequent appearances of $(name) or ${name} are replaced by X value. If name is a single character, the parentheses or braces are X optional. Spaces between name and =, and between = and value are X ignored. If value is not given, the macro value is a null string. X X The previous example could have had: X X OBJS = main.obj sub.obj X X test.exe : $(OBJS) X link $(OBJS), test; X X main.obj : main.c X msc -AL main.c; X X sub.obj : sub.c X msc -AL sub.c; X X $(OBJS) : incl.h X X Macros can be entered as command line parameters. For example: X X A> make CFLAGS=-AL test.exe X X MAKE evaluates macros only when needed, and the order in which macros X appear in a description file is insignificant. Conventionally, all X definitions appear at the top of the description file. If the same X name is defined more than once, the most recent definition is used. X The precedence of definitions is: X X X X X X X X X X NDMAKE v3.0 page 4 X X X X X X X 1. command line definition (highest) X 2. `makefile' definition X 3. `make.ini' definition X 4. environment definition (lowest) X X X Predefined macros: X X There are 4 "run-time" macros. These are: X X $* - stands for the target name with suffix deleted X $@ - stands for the full target name X $< - stands for the complete list of prerequisites X $? - stands for the list of prerequisites that are out X of date with respect to the target. X X These are usually used when defining default rules (to be discussed X next). Unlike UN*X make, you can use these run-time macros anywhere X they make sense. Thus, a dependency line for OBJS could be: X X $(OBJS) : $*.c X X The macro `MFLAGS' gets filled in with the initial command line X options supplied to MAKE. This can be used to invoke MAKE on X makefiles in subdirectories and pass along the options. The macro X `CWD' gets filled in with the current directory. X X The macro `$$' evaluates to the dollar sign `$'. X X X 3) Default rules X ---------------- X X MAKE can use default rules to specify commands for files for which the X makefile gives no explicit commands. A default rule tells MAKE how to X create a file with a particular extension from a file with the same X base name but another extension. Default rules take the following X form: X X .from_extension.to_extension : X command X [command] X ... X X For example, to produce a `.obj' file from a `.c' file, the default X rule could be: X X .c.obj : X msc -AL $*.c; X X When MAKE finds a dependency with no commands, it looks for the first X possible name for which both a rule and a file exist. Since there may X be several ways to produce a `.obj' file (eg from a C, FORTRAN, or X X X X X X X NDMAKE v3.0 page 5 X X X X X X PASCAL compiler, or from MASM), the order in which rules are attempted X is specified by the `.SUFFIXES' list. This is a special target with a X list of extensions. For example: X X .SUFFIXES: .exe .obj .c .asm .for X X If MAKE was trying to make a `test.obj' file using a default rule, it X would first look for a `.c.obj' rule. If it found a `.c.obj' rule, it X would check if the file `test.c' existed. If it didn't, MAKE would X look for a `.asm.obj' rule (and `test.asm' file), and finally a X `.for.obj' rule (and `test.for' file). X X Assuming `make.ini' contained the .c.obj rule and the .SUFFIXES as X defined above, our previous example could be written more succinctly: X X OBJS = main.obj sub.obj X X test.exe : $(OBJS) X link $(OBJS), test; X X $(OBJS) : incl.h X X Because of the default rules, `main.obj' and `sub.obj' implicitly X depend on files `main.c' and `sub.c', respectively, as well as X explicitly depending on `incl.h'. X X Suffixes accumulate, so if the makefile had the line: X X .SUFFIXES : .obj .pas X X the suffix list would look like: .obj .pas .exe .obj .c .asm .for X A .SUFFIXES line with nothing on it clears the list of suffixes. X X X 4) "dot commands" X ----------------- X X Besides the special target `.SUFFIXES' mentioned above, there are a X few other special targets and dependents that can be put in MAKE X description files. X X .HELP - prints a reminder that `make -h' gives help. X X .IGNORE - Commands returning nonzero status (ie. the exit code or X errorlevel) cause MAKE to terminate unless the special target X `.IGNORE' is in makefile or the command begins with `-' (hyphen). X X .SILENT - Commands to be executed are printed when executed unless the X special target `.SILENT' is in makefile, or the first character of the X command is `@'. For example: X X X X X X X X X X X NDMAKE v3.0 page 6 X X X X X X X all.exe : 1.obj 2.obj 3.obj X link 1 2 3, tmp.exe; # this line will be printed X - exepack tmp.exe all.exe # ignore any errors X @erase tmp.exe # this line will not be printed X X .PRECIOUS - Break (control-C) and command errors cause the target to X be deleted unless the target has no dependents (explicit or implicit), X or depends on the special name `.PRECIOUS'. For example: X X nerase.exe : nerase.obj .PRECIOUS # nerase.exe won't be deleted if X link nerase; # link returns an error. X X X Additional notes and technical information X ------------------------------------------ X X If you type in a `makefile' from the keyboard (by using the command X `make -f -'), to signal you are done put a ^Z (control-Z) followed by X a as the last two characters. X X Lines in a MAKE description file that are too long to fit on one line X can be extended to the next line by putting a backslash, `\', as the X last character of the line. X X Everything on a line after the comment character, `#', is ignored. X Blank lines and lines that start with `#' are completely ignored. X X Case is not important, so `test.obj' and `TEST.OBJ' are the same. X X The separation character between targets and dependents, `:' is also X the character used for the drive separator in MSDOS. For MAKE to know X this colon is *not* the drive separator, it must be followed by a X space, semicolon or colon (see below), or nothing. X X MAKE is stupid in that after the commands to update a target have been X executed without error, MAKE assumes the target is up to date. If you X give commands that don't really update a target, MAKE doesn't know. X X When MAKE executes commands, such as `link', it first tries to find a X file called `link.exe' (or `link.com'). If the file is not found, X MAKE loads a second copy of COMMAND.COM and passes it the command X line, in the hope that the command is an internal DOS command. This X is backwards to how COMMAND.COM normally works (first checking X internally, then checking externally). It is done this way because I X could not get the second copy of COMMAND.COM to return the exit code X of the passed command. I'm using Microsoft C v3.0 and PCDOS 2.0, so X if anyone knows how to get the exit code back, please let me know. X X You can force MAKE to load a second copy of COMMAND.COM by putting a X `+' as the first letter in the command. You can put more than one of X `-', `@', and `+' for each command. Ex: X X X X X X X X X NDMAKE v3.0 page 7 X X X X X X @- exepack tmp.exe all.exe X X MAKE always uses a second copy of COMMAND.COM if the command involves X redirection of IO (with `>', `>>', `<', or `|'). X X Most commands must be shorter than the DOS command line limit of 128 X characters. Since `link' is used so often, MAKE knows about it X specially and will automatically use a response file if the `link' X command is longer than the limit. X X Macro definitions can refer to other macros. You could have: X X CFLAGS = -A$(MODEL) -Od # remember, order is not important X MODEL = L X X When it comes time to use CFLAGS, MAKE will expand CFLAGS as X `-AL -Od'. Command line macros have the highest precedence, so: X X A> make MODEL=S test.exe X X results in CFLAGS having the value `-AS -Od'. For command line macros X that contain spaces, enclose entirely the macro in double quotes, " ": X X A> make "CFLAGS=-A$(MODEL) -Zd" MODEL=M test.exe X X MAKE will let you define a recursive macro: X X macro1 = $(macro2) # macro1 = the value of macro2 X macro2 = $(macro1) # macro2 = the value of macro1 X X but generate an error if it tries to use it. X X X UN*X features X ------------- X X As with UN*X, dependency lines and default rules can have a command on X the same line as the `colon' line, if the command follows a semicolon: X X .c.obj:; msc $*.c; X test.exe: $(OBJS); link $(OBJS), test; X @echo done X X # are equivalent to X X .c.obj: X msc $*.c; X test.exe: $(OBJS) X link $(OBJS), test; X @echo done X X If a name appears on a line with a double colon :: then the command X sequence following that line is performed only if the name is out of X date with respect to the names to the right of the double colon, and X X X X X X X NDMAKE v3.0 page 8 X X X X X X is not affected by other double colon lines on which that name may X appear. Consider the following makefile: X X 1:: 2 X @echo 2 X 1:: 3 X @echo 3 X X If 2 and 3 are more recent than 1 and you type: X X A> make 1 X X The response will be: X 2 X 3 X X If 1 is more recent than 3, but 2 is newer than 1 the response is: X 2 X X If 1 is more recent than both 2 and 3, the response will be: X Make: `1' is up to date. X X X OPTIONS X ------- X X Options are entered on the command line with a `-' preceding them. X You cannot use `/' instead of `-'. -nd is equivalent to -n -d. X X -d Debug mode. Prints information on macros, dependencies, X SUFFIXES, default rules. Also traces MAKE as it excutes. X X -h Print a help screen. Also, -? will do the same. X X -i Equivalent to the special entry `.IGNORE'. Causes commands X that return errors to be ignored. Doing `make -i > errs' X collects all error messages into 1 `errs' file. To stop X running `make -i' you may have to push ^C several times. X X -k When a command returns nonzero status, abandon work on the X current target, but continue on branches that do not depend X on the current target. X X -n Display but do not execute the commands needed to update the X targets. Doing `make -n > todo.bat' produces the batch file X `todo.bat' containing the commands to be executed. X X -r Clears the .SUFFIXES list after `make.ini' is read. X X -s Equivalent to the special entry `.SILENT'. Commands are not X echoed to the screen before they are executed. X X -t Touch, i.e. set the file time of the out of date targets to X the current time without executing any commands. X X X X X X X NDMAKE v3.0 page 9 X X X X X X Sample session X -------------- X X A sample `make.ini' file X ------------------------ X .SUFFIXES : .exe .obj .c .for .asm X X M = S X CFLAGS = -A$M X X .c.obj:; cl $(CFLAGS) -c $*.c X X .obj.exe:; link $*.obj, $@; X X .c.exe: X cl $(CFLAGS) -c $*.c X link $*.obj, $@; X erase $*.obj X X A sample makefile X ----------------- X OBJS = main.obj sub.obj X X test.exe: $(OBJS) X link $<, $@; X X $(OBJS): incl.h X X sub.obj: sub.c X cl $(CFLAGS) -Od -c sub.c X X install: test.exe X copy test.exe $(BIN) # BIN comes from the environment X X ---------- X X Assume the following files are in your directory: `main.c', `sub.c', X `incl.h'. When you type: X X A> make X X MAKE first reads `make.ini' then `makefile'. It sees the first target X `test.exe' and tries to make it. But first, MAKE must know if the X files that `test.exe' depends on are up to date. As `test.exe' X depends on several `.obj' files, and these `.obj' files also have X dependents, the (very) detailed procedure that MAKE undergoes looks X like this: X X -Make `test.exe' X `test.exe' depends on `main.obj' and `sub.obj'. Make each of these X -Make `main.obj' X `main.obj' depends on `incl.h'. X -Make `incl.h' X `incl.h' depends on nothing explicitly. X X X X X X X NDMAKE v3.0 page 10 X X X X X X -Since there are no explicit commands to make `incl.h', X check for implicit dependencies. X -Since there is no `.h' suffix in .SUFFIXES, there are X no implicit dependencies. X -Assume `incl.h' is up to date. X -Since there are no explicit commands for `main.obj', check for X implicit dependencies based on default rules. X -Find the rule `.c.obj' and the file `main.c'. X -Make `main.c' X `main.c' depends on nothing explicitly. X -Since there are no explicit commands to make `main.c', X check for implicit dependencies. X -Since there are no `.from_extension.c' rules, `main.c' X depends on nothing implicitly. X -Assume `main.c' is up to date. X -Compare `main.obj' with `incl.h' and `main.c'. Since `main.obj' X doesn't exist, it is out of date with respect to its dependents, X so execute the (implicit) command: X X cl -AL -c main.c X X -Assume `main.obj' is up to date. X -Make `sub.obj' X `sub.obj' depends on `incl.h' and `sub.c' X -Make `incl.h' X MAKE already knows that `incl.h' is up to date. X -Make `sub.c' X `sub.c' depends on nothing explicitly X -Since there are no explicit commands to make `sub.c', X check for implicit dependencies. X -Since there are no `.from_extension.c' rules, `sub.c' X depends on nothing implicitly. X -Assume `sub.c' is up to date. X -Compare `sub.obj' with `incl.h' and `sub.c'. Since `sub.obj' X doesn't exist, it is out of date with respect to its dependents, X so execute the (explicit) command: X X cl -AL -Od -c sub.c X X -Assume `sub.obj' is up to date. X -Compare `test.exe' with `main.obj' and `sub.obj'. Since `test.exe' X doesn't exist, execute the command: X X link main.obj sub.obj, test.exe; X X -Assume `test.exe' is up to date. X X Note the way $< gets replaced with the files `test.exe' depends on, X and $@ gets replaced with `test.exe'. X X Assuming no errors occurred, when you now type `make' you will get the X message that `test.exe' is up to date. If you edit `sub.c' and make X some changes, when you next type `make', MAKE will see that `sub.c' is X X X X X X X X NDMAKE v3.0 page 11 X X X X X X more recent than `sub.obj' and recompile `sub.c'. MAKE will then see X that `sub.obj' is more recent than `test.exe' and relink the files. X X If you type `make install', MAKE will ensure `test.exe' is up to date, X then copy it to your BIN directory. BIN was assumed to be defined in X your environment. X X X Using MAKE without a makefile X ----------------------------- X X It is possible to use MAKE without having a makefile. Assume you have X a file called `xyzzy.c' and using the same `make.ini' file described X above, you type: X X A> make xyzzy.exe X X MAKE uses its default rules to compile `xyzzy.c', link `xyzzy.obj' to X form `xyzzy.exe', then erases `xyzzy.obj'. If several `.exe' files X exist in a directory and you have just finished editing some of their X `.c' files, you could type: X X A> make *.exe X X and update only the `.exe' files that are out of date. By adding more X default rules to `make.ini', MAKE could invoke the FORTRAN compiler X for `.for' files or MASM for `.asm' files. In this way, MAKE can do X the right thing for each type of file. You can do `make *.exe' and X have MAKE figure out what to do. X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X NDMAKE v3.0 page 12 X X X X X X USER-SUPPORTED SOFTWARE NOTIFICATION X ------------------------------------ X X If you like and use this program, I ask you to consider registering X it. The benefits of registration include the first bugfix/enhanced X version free. Registered owners will get a response to any questions X they may have. I anticipate adding VPATH (a way to look for dependent X files in other than the current directory) and ARC and LIB support for X the next version. Also, I am certain there will be some reported bugs X or incompatibilities with UN*X MAKE which will be fixed in the first X update. X X The suggested registration fee is $20. Regardless of whether you X register or not, you may freely copy and distribute this program for X noncommercial purposes. The program, MAKE.EXE, the documentation, X MAKE.DOC, and the initialization file, MAKE.INI must all be X distributed together. X X Commercial use of this program requires my prior written consent. X X I hope you enjoy NDMAKE and find it to be a useful addition to your X programming tools. X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X NDMAKE v3.0 page 13 X X X X X X --------------------------------------------------------------------- X Registration form for NDMAKE v3.0 X X X X Name: _________________________________________________ X X Address: _________________________________________________ X X City, State, Zip: _________________________________________________ X X Country: _________________________________________________ X X X OPTIONAL: System description (computer, memory, DOS version) X X _____________________________________________________________________ X X _____________________________________________________________________ X X X COMMENTS: Please feel free to add your thoughts or suggestions! X X _____________________________________________________________________ X X _____________________________________________________________________ X X _____________________________________________________________________ X X _____________________________________________________________________ X X X Mail to: X D. G. Kneller X 2 Panoramic Way #204 X Berkeley CA, 94704 X U.S.A X X X X X X X X X X X X X X X X X X X X X X X SHAR_EOF if test 25146 -ne "`wc -c 'make.doc'`" then echo shar: error transmitting "'make.doc'" '(should have been 25146 characters)' fi echo shar: extracting "'make.ini'" '(1401 characters)' if test -f 'make.ini' then echo shar: over-writing existing file "'make.ini'" fi sed 's/^X//' << \SHAR_EOF > 'make.ini' X# This is a sample `make.ini' file for NDMAKE v3.0. You will probably want X# to customize it for your system. X X# Print the `make -h' message X.HELP X X# The order to search for rules and files is specified by .SUFFIXES X.SUFFIXES : .exe .obj .c .for .asm X X# A few macros. XCFLAGS = -A$(MODEL) XMODEL = S XLIBS = # none yet X X# DEFAULT RULES X# To produce a `.obj' file from a `.asm' file. X.asm.obj:; masm $*.asm; X X# To produce a `.obj' file from a `.c' file. X.c.obj:; cl $(CFLAGS) -c $*.c X X# To produce a `.obj' file from a `.for' file. X.for.obj: X for1 $*.for; X pas2 X X# To produce a `.exe' file from an `.obj' file. Note that there is a X# problem because LIBS may be different for linking `.obj' files X# produced by different compilers (C, FORTRAN, PASCAL, etc). To avoid X# this problem you may want to have the C compiler produce `.cbj' files, X# the FORTRAN compiler produce `.fbj' files, etc. Then you could write X# specific rules for `.cbj.exe' and `.fbj.exe' which would use the correct X# libraries. X.obj.exe:; link $*.obj, $@, nul, $(LIBS) X X# To produce a `.exe' file from a `.asm' file. X.asm.exe: X masm $*.asm; X link $*.obj, $@, nul, $(LIBS) X erase $*.obj X X# To produce a `.exe' file from a `.c' file. X.c.exe: X cl $(CFLAGS) -c $*.c X link $*.obj, $@; X erase $*.obj X X# To produce a `.exe' file from a `.for' file. X.for.exe: X for1 $*.for; X pas2 X link $*.obj, $@, nul, $(LIB)\FORTRAN.LIB X erase $*.obj SHAR_EOF if test 1401 -ne "`wc -c 'make.ini'`" then echo shar: error transmitting "'make.ini'" '(should have been 1401 characters)' fi # End of shell archive exit 0 -- Don Kneller UUCP: ...ucbvax!ucsfcgl!kneller ARPA: kneller@ucsf-cgl.ARPA BITNET: kneller@ucsfcgl.BITNET