# Makefile for K&R rpn calculator # # A Makefile comment starts with a # and extends to the end of the # line. # Rule to make the executable from the compiled modules rpn: rpn.o stack.o getop.o getch.o clang -o rpn rpn.o stack.o getop.o getch.o # Rule to build the rpn module rpn.o: rpn.c stack.h getop.h clang -c -Wall -pedantic-errors rpn.c # Rule to build the stack module stack.o: stack.c stack.h clang -c -Wall -pedantic-errors stack.c getop.o: getop.c getop.h getch.h clang -c -Wall -pedantic-errors getop.c getch.o: getch.c getch.h clang -c -Wall -pedantic-errors getch.c # This is a commandless rule. Its purpose is to force make to test # the rpn rule. This causes make to evaluate the rpn rules # dependencies. This is the same as typing "make rpn". all: rpn # This is a rule with no dependencies. When you make a such a target, # the command is always executed. Normally, the "rm" command will # complain if you ask it to remove a file that doesn't exist. The # "-f" option tells rm to be silent about these errors. clean: rm -f rpn.o stack.o getop.o getch.o rpn rpn.tar # Make the tarball. # # Normally, each part of a rule must be on a single line. However, # you can use the continuation character '\' to break part of a rule # across multiple lines, to make it easier to read. tarball: rpn tar -c -f rpn.tar rpn.c stack.c stack.h getop.c getop.h \ getch.c getch.h Makefile