Preventing the make command from stopping on errors
The make command normally stops if any program returns a nonzero error code. Some programs return status that has no meaning.
To prevent the make command from stopping on errors, do any of the following:
- Use the -i flag with the make command on the command line.
- Put the fake target name .IGNORE on a dependency line by itself in the description file. Because .IGNORE is not a real target file, it is called a fake target. If .IGNORE has prerequisites, the make command ignores errors associated with them.
- Put a - (minus sign) in the first character position of each line in the description file where themake command should not stop on errors.
Example of a description file
For example, a program named prog is made by compiling and linking three C language files x.c, y.c, and z.c. The x.c and y.c files share some declarations in a file named defs. The z.c file does not share those declarations. The following is an example of a description file, which creates the prog program:
# Make prog from 3 object files
prog: x.o y.o z.o
# Use the cc program to make prog
cc x.o y.o z.o -o prog
# Make x.o from 2 other files
x.o: x.c defs
# Use the cc program to make x.o
cc -c x.c
# Make y.o from 2 other files
y.o: y.c defs
# Use the cc program to make y.o
cc -c y.c
# Make z.o from z.c
z.o: z.c
# Use the cc program to make z.o
cc -c z.c
If this file is called makefile, enter the make command to update the prog program after making changes to any of the source files: x.c, y.c, z.c, or defs.