Following is a repost of the public domain 'make' that I posted
to net.sources a couple of months ago.  I have fixed a few bugs, and
added some more features, and the resulting changes amounted to
about as much text as the whole program (hence the repost).

For those that missed the net.sources posting, this is a public domain
re-implementation of the UNIX make program.  There is no manual included;
for documentation, refer to a UNIX manual, or the source.

Here is a list of the changes made:

i)      If '-' (ignore) or '@' (silent) where used at the start
        of a command, their effect was not turned off for the following
        commands.
ii)     A special target (.SUFFIXES, .PRECIOUS) or a rule (.c.o, .a.o),
        if first in the file would be taken as the default target.
        This resulted in error messages like "Don't know how to
        make .c", because things like .SUFFIXES were being made.
        This was further complicated by ---
iii)    Special target lines with no dependents (ie. .SUFFIXES:\n)
        were not clearing out the existing dependents like
        they should.
iv)     Default rules could not be redefined because of the error
        checking for commands being defined twice.  Now you are
        allowed to define a target beinging with '.', having
        no dependents with commands.
v)      The -q option didn't do the time comparison correctly,
        or clear the variable used to keep track of this.  Thus
        it didn't work very well.
vi)     The syntax ${..} for macro's supported by UNIX make was
        not supported.
vii)    There wuz a couple of spelling errors.
viii)   When make checked for implicit rules on targets without
        a suffix, there were problems.  (Note: The ~ feature of
        UNIX make wasn't and still isn't supported)
ix)     The -n option did not print @ lines like it was supposed to.
x)      :: added.  (See UNIX manual)
xi)     $? added.  (see UNIX manual)

===========================

This 'make' is based on a usenet version that was posted to mod.sources
in December of 1986.  I have added some #defines to enable compilation
with Microsoft C, version 4.0, under MS-DOS.  Within the bounds of
legality, this is as close as one can get to REAL unix make on a DOS
machine.  If anyone ever again spends money for a DOS make program they
either:  1) don't know about this version, or 2) are crazy.  Let's distribute
this widely to take care of the first case.  As to the second case, that
probably doesn't matter- most of them are using MacIntoshes!

        - Paul Homchick
          Sysop, GEnie IBM RoundTable
          January 11, 1987

(For information on how to use make, see any text on unix programming,
or, any unix documentation.  While this source code is P.D., the AT&T
documentation is not.)

These are the default rules for this implementation:

        macro "CC" =  "cc"
        macro "CFLAGS" = "-O"
        rule "c.obj"
        command "$(CC) $(CFLAGS) -c $<"

        macro "AS" = "masm"
        rule ".asm.obj"
        command "$(AS) $<;"

        suffixes:
        ".obj"
        ".asm"
        ".c"
        ".SUFFIXES"

===========================

Further changes for MS-DOS, made by Rahul Dhesi.  All changes will
compile with Microsoft C version 3.0, but are compiler-specific and
will probably not work with any other compiler (with the possible
exception of Microsoft C version 4.0).

1987/02/01
(a)  If switchchar had been set to other than "/", using Make made the 
system go haywire.  Included my own system() function that recognizes 
switchar.  File affected:  new file `msdos.c'.

(b)  System() function always invoked MS-DOS's command interpreter.
As a result, the return code from the executed command was lost, since
MS-DOS's command interpreter always returns a zero exit code.  Fixed
as follows:  My system() function first tries to execute the command 
directly by creating a process with the help of the spawn() library 
function of Microsoft C.  If this fails, only then is the command
interpreter invoked.  This means that all commands other than those
executed by the MS-DOS command interpreter will return a proper exit
code.  File affected:  `msdos.c'.

This does have the side effect that if there is a program called 
COPY.COM or COPY.EXE, that will be executed in preference to the
command interpreter's command COPY.  This is not necessarily a bad
thing.

(c)  User interrupts were being ignored.  Added some signal() calls
to trap any user interrupt and increment a flag.  Also added kbhit()
function call to check console status after each command is executed and 
(with any luck) recognize any user interrupt.  User interrupt
handling is now somewhat improved.  File affected:  `msdos.c'.

(d)  Added "$*" macro which stands for target minus suffix.  File
affected:  `make.c'.

Remaining known bug:  A command-line macro definition, as in

   make "switch = -o" xyz

should override a macro definition of `switch' in the makefile.  It
does not.  One way of fixing this would be to change the structure of
macro definitions to indicate whether or not the current macro
definition is a command-line definition.  Then a command-line
definition would never be replaced by one within the makefile.  

                                  -- R.D.  1987/02/01

--------

Ported to lcc-win32  

Included rules for lcc-win32, added some system dependent features
Had similar problems with system(), so created my own implementation
Had problems with the timing and touching, so ended up with a bunch
of Windows95 specific code

				-- paag 1996/01/09

Included a simple substitution mechanism in the macro expansion code

the syntax is 
   $(VAR;old=new) 
    where VAR is an valid macro variable
    old is a string in this variable
    new is the string it has to be changed to
e.g.
if
   SRC = alloc.c dothing.c
then
   OBJ = $(SRC;.c=.obj)
expands to
   OBJ = alloc.obj dothing.obj

WARNING: the substitution mechanism is CASE SENSITIVE

                                -- paag 1996/02/10
