# This is an example of a basic makefile # Rules are always of the form: # # target: dependencies # (Rules to generate the target) # # Note that (Rules to generate the target) must ALWAYS be preceded by a # tab character. Don't even try to fake the funk with spaces! I'll # explain the rules below to give you an idea of how these work: # "all" is the first rule that make will execute. In order to satify this # rule, all of its dependencies must be satisfied. In other words, this # target states, "To satisfy the target 'all', I need to complete the # target 'duplex'". Once 'duplex' has been completed, it will print # a message stating that the project has finished building all: duplex @echo @echo @echo "Finished building the project" # Prints a line of text # 'duplex' states that is depends upon the targets 'pipes.c' and 'blError.o'. # Since 'pipe.c' is a file in the project, the dependency is already # satisfied (ie, nothing needs to be done to build this file or dependency # because it already exists). However, blError.o has not been built yet, # so it will need to jump to the 'blError.o' target below. Once both # dependencies have been satisfied, the makefile will print a message # and then compile the program 'duplex' duplex: pipes.c blError.o @echo @echo @echo "Generating target 'duplex'" ${CC} pipes.c blError.o -o duplex # 'blError.o' depends on blError.c and blError.h . However, both of these # files already exist on the harddrive, so their dependencies have already # been taken care of. This target will then print a message and compile # (but not link) the file 'blError.c' . blError.o: blError.c blError.h @echo @echo @echo "Generating target 'blError.o'" ${CC} -c blError.c -o blError.o # This is an extra target that is not used unless it is called explicitly # from the commandline. If the user types: # # make clean # # then the makefile will jump immediately to this target. This target # is used to clean up object files, backup files, and remove the program. # (Note: the - in front of each command tells make to continue to the # keep going even if one of the commands fail. For instance, if there # are no *.o files, it will stil try to remove duplex and all of the # backup files) clean: - rm *.o - rm duplex - rm *~