castlevur.blogg.se

Writing makefile for c program
Writing makefile for c program











writing makefile for c program

This must be done if the file edit does not exist, or if any of the object files are newer than it. The recompilation must be done if the source file, or any of the header files named as prerequisites, is more recent than the object file, or if the object file does not exist.Īfter recompiling whichever object files need it, make decides whether to relink edit. These rules say to update each ‘.o’ file by compiling its source file. Each of these files is processed according to its own rule. In the example, this rule is for relinking edit but before make can fully process this rule, it must process the rules for the files that edit depends on, which in this case are the object files. Make reads the makefile in the current directory and begins by processing the first rule. In the simple example of the previous section, the default goal is to update the executable program edit therefore, we put that rule first. DEFAULT_GOAL special variable ( see Other Special Variables). You can override this behavior using the command line ( see Arguments to Specify the Goals) or with the. (Goals are the targets that make strives ultimately to update. How make Processes a Makefileīy default, make starts with the first target (not targets whose names start with ‘.’). If some other rule is not depended on by the goal (or anything it depends on, etc.), that rule is not processed, unless you tell make to do so (with a command such as make clean). The other rules are processed because their targets appear as prerequisites of the goal. Rm edit main.o kbd.o command.o display.o \ Edit : main.o kbd.o command.o display.o \Ĭc -o edit main.o kbd.o command.o display.o \įiles.o : files.c defs.h buffer.h command.h













Writing makefile for c program