# This is a sample makefile. It's name should usually be "makefile" or # "Makefile". You can see that lines that begin with the pound character, '#', # (like this one) are comments. You should type "man make" to learn more # about the make program and the makefile syntax. Another useful reference # is Andrew Oram and Steve Talbott, "Managing Projects with make," O'Reilly, # Sebastopol, California, 1991. # Equals signs are used for assignments: the symbol appears on the left # the new value, on the right. The next line defines the symbol source # to contain the name of a particular source file. More than one filename # (separated by white space) can appear on the right hand side. SOURCE = sierpinski.c # The next line defines the symbol OBJS to be the source files, after # replacing the .c extension by a .o. Thus OBJS will have the value # sierpinski.o. Note that a dollar sign is used to dereference a symbol, # but brackets or parentheses are necessary. OBJS = sierpinski.o # Here is another assignment. The symbol LIBS was chosen to contain the # library flags for the linker. Type "man gcc" for a description of the # function of the "-l" compiler flag. For OpenGL will often need # /usr/local/lib/libglut.a, /usr/lib/libGL.so, and sometimes, # /usr/lib/libGLU.so. Unix window managers are usually based on X Windows. # Thus, the glut toolkit will make calls to /usr/lib/libX11.so, # /usr/lib/libXmu.so, and /usr/lib/libXext. Finally, /usr/lib/libm.so # contains the object code for the mathematical subroutines. LIBS = -lglut -lGLU -lGL -lXmu -lXext -lX11 -lm # # IF YOU ARE USING A MACINTOSH, PLEASE UNCOMMENT THE NEXT LINE. #LIBS = -framework GLUT -framework OpenGL -framework Foundation -framework vecLib # The library path /usr/lib should be examined by default; but we usually # need to explicitly list other directory paths. The following may be needed # for libglut.a. LIBPATHS = -L/usr/local/lib # Here, CFLAGS is used to contain compiler options. The "-I" flag precedes # a path that should be examined for headers. The path /usr/include is # usually examined by default. However, on my machine, , is # contained under /usr/local/include. The "-g" flag tells the compiler # to create a symbol table for running a debugger. You may wish to remove # this, once you are certain that your code is bug free. You may wish to # replace it with -O1, -O2, or -O3 to optimize the object code. # CFLAGS = -I/usr/local/include -g # # IF YOU ARE USING A MACINTOSH, PLEASE UNCOMMENT THE NEXT LINE. #CFLAGS = -I/usr/local/include -g -Dmac_osx # I prefer the GNU C compiler, don't you? CC = gcc # The next two lines tell the make program how to create a object file # (one with a .o extensions) from a C source file (one with a .c extension). # the second line must begin with a TAB character. Any needed object file # that is older than its source will be recompiled. .c.o : ${CC} ${CFLAGS} -c $< # The next two lines tell the make program how to link the executable. The # execuatble, will be called sierpinski. If any of the object files defined # by OBJS are younger than sierpinski, then the executable will be relinked. sierpinski : $(OBJS) ${CC} -o $@ ${OBJS} ${LIBPATHS} ${LIBS} # For ease of use, we make "all" depend on sierpinski. Typing "make all" will # ensure that all executables to the right of the colon are up to date. all: sierpinski # Make does more that compile. Typing "make clean" will remove the executable # and all objects. You should do this before you submit your assignments, # as it will reduce the size of your submission. clean: rm sierpinski ${OBJS}