#!/home/nahaj/bin/rebuild # Obviously, the line above is wrong anywhere but here. :) # This is an example build file for the "rebuild" program. # Note that we have no default rules... so some things have # to be done explicitly. # There are a number of predefined macros: # SHELL = shell to execute # THISDIRECTORY = name of this directory. # There are a number of macros that exist only while processing # patterns, such as in macro defines or dependency lists. # {target} = The file name we are processing. (Complete) # {ext} = Just the extension (if any) # {file} = Target with extension removed. # There are also macros that exist only in code definitions. # {parents} Those files that this target directly depends on. # {newparents} Only those parents that are newer than the target. # Programs to build, as an example. define PROGRAMS as testa testb all <= {PROGRAMS | minus (*.c *.h)} # the testa program needs the testlib.o library linked in. testa <= testlib.o # The bozofier.h file depends on the environment.h file. bozofier.h <= environment.h # obvious way to build programs. {PROGRAMS} <= {file}.c => gcc -o {file} {parents} # and libraries. *.o <= {file}.c => gcc {parents} # In addition, We can claim, for example, that any time a .h and a .c file # both exist for the same name, the .c file depends on the .h # file. define CULL as { dir(.) | -f | *.h => *.c | -e} # The above applies the pattern *.h on all files, keeping only those that # exist. It then rewrites those as *.c (using the {file} macro) files, # keeping only those that exist. So {CULL} is now only those .c files # that have matching .h files # and now we can say that those depend on the matching .h files in # the obvious manner. {CULL} <= {file}.h ################################### # Note that the file above would generate (assuming existance of appropriate # files) # gcc testlib.c # gcc -o testa testa.c testlib.o # gcc -o testb testb.c # # and would update testb any time testb.c or testb.h changed. # and would update testa any time testa.c or testa.h or testlib.c or testlib.h changed.