#Example of most capabilities of Solucorp Make

#Solve DOS command line limitation for command.
#    It tells make how to create a command file, how to insert
#    continuation character, and how to call the utility.
#    for now on cc and lib may accept command line of any length.
.indir.cc  = c:\cc.$$$    @c:\cc.$$$
.indir.lib = c:\lib.$$$,& @c:\cc.$$$

#Solve DOS 640k limit selectivly.
#    It tells make that it must swap itself only when executing command
#    cc make and proto
.huge   = cc make proto naperm

#Macro definition.
#    macro SOURCE will hold a list of all C file in the current directory
#    except main.c
SOURCE  ? *.c -main.c

# Compiler flags for all .c file
CFLAGS = -O
# Compiler flags for some .c file
# See the comments in the .c.$(OBJEXT) rule
source2.CFLAGS = -n

#    macro DIROBJ will hold a path. This path will be any of three possible.
#    The first one that exist will be used.
DIROBJ  | c:\obj d:\obj .

#access control.
#    This tells where the object (.obj) files should be placed
#    and look for.
.path.obj = $(DIROBJ)

#    This tells where the header must be looked for, for depandency check.
.path.h   = . ..\include \compiler\include

#These are the general rules for rebuilding a librairy.
#    The preprocessor is used to create portable makefiles.
!if $d(MSDOS)
OBJEXT  = obj   # Extension of object files on MSDOS
LIBEXT  = lib   # Extension of library files on MSDOS
!else
OBJEXT  = o     # Extension of object files on UNIX
LIBEXT  = a     # Extension of library files on UNIX
!endif

#implicit rules for source translation into object file
.c.$(EXTOBJ):
    # Generalisition of macro usage: Object oriented macro facility
    # $& expands to the name of the current module
    # $($&.CFLAGS) expand to whatever options appropriate for
    # the current module being compiled.
    cc -c $($&.CFLAGS) $(CFLAGS) $&.c

#General rules
#    lib.lib is builted from .obj file, not .c. Macro SOURCE holds a list
#    of .c. This syntax allows editing of the list.
#    The builtin macro $? let you update the librairie
#    with only .obj (.o) files which outdated lib.lib (lib.a).
lib.$(LIBEXT): $(SOURCE:%b.$(OBJEXT))
    # True subroutine capacity, see !define lib below
    !use lib $< "$?"


#Documentation preparation.
#    Here is the sequence that has been used to create the files
#    that are documented in document.exm.
doc:
    proto -cod -fxsys.nap *.c           # Produce xsys.nap file
    naperm xsys.nap xsys.nai xsys.nas xsys.nah
    nadoc xsys.doc xsys.nap xsys.ref    # Produce the reference manual

#Automatic dependancies creation.
#    The file makefile.dep is created by scanning all the sources in
#    the current directory. This file is silently processed by
#    Make to establish the dependancies between source files and headers.
dep:
    makedep makefile *.c

# Subroutine capacity. This is the key to makefile portability
!define lib libname objects
    !if $d(MSDOS)
        # A "-+" is added before each obj file.
        lib $(libname) $(objects:-+%s)
    !else
        # Update lib.a on UNIX
        ar $(libname) $(objects)
        ranlib $(libname)
    !endif
!enddef

