#************************************************************************* # MP1 Makefile #************************************************************************* #************************************************************************* # To begin our Makefile, we want to create various helpful macros. # # First of all, we need to name our program. The "executable file" is the # actual program -- all the individual compiled files linked together. NAME_OF_EXECUTABLE_FILE = mp1 # Next, we want to define which C++ compiler we are using and what options # we are using for that compiler. COMPILER = g++ COMPILER_OPTS = -c -g # Next, we want to define which program we are using to link all our # files together (often, we are using the compiler we used to compile them # in the first place) and what options we are using for that linker. LINKER = g++ LINKER_OPTS = -o $(NAME_OF_EXECUTABLE_FILE) # Finally, we want a list of all the .o files (object files) that # NAME_OF_EXECUTABLE_FILE depends on. That is, we want a list of all # the object files that make up the program. OBJS = asserts.o string.o office.o building.o main.o # And that is it for the macros; we now are ready to compile and link # the program. #************************************************************************** #************************************************************************ # Rule for linking the program. $(NAME_OF_EXECUTABLE_FILE) : $(OBJS) $(LINKER) $(LINKER_OPTS) $(OBJS) # And that is it for the linking step! However, the assorted .o files # must be created before the above line can finish, so the compilation # rules below get run before the above rule can finish. #************************************************************************ #************************************************************************** # Rules for performing the compilation of each individual object file. asserts.o : asserts.h asserts.cpp $(COMPILER) $(COMPILER_OPTS) asserts.cpp string.o : string.h string.cpp asserts.h $(COMPILER) $(COMPILER_OPTS) string.cpp office.o : office.h office.cpp string.h $(COMPILER) $(COMPILER_OPTS) office.cpp building.o : building.h building.cpp string.h office.h $(COMPILER) $(COMPILER_OPTS) building.cpp main.o : main.cpp asserts.h string.h office.h building.h $(COMPILER) $(COMPILER_OPTS) main.cpp # And now we have created all the individual object files specified with # the macro "OBJS". #************************************************************************ #*********************************************************************** # The "clean" rule -- triggered with the command "make clean" -- will # erase any files created by the compilation. That is, it cleans up # the directory you are in, so that the next compilation must proceed # completely from scratch. This is sometimes very helpful. clean: -rm *.o $(NAME_OF_EXECUTABLE_FILE) -rm -rf SunWS_cache # #***********************************************************************