# Generic Makefile -- it should appear in the same directory as the source files # and we do not generate object files in a separate directory -- it's too much effort # If you have a /src directory, put this file in there, and in the directory above, put something like # # SUBDIRS = src # # .PHONY : $(SUBDIRS) # # $(SUBDIRS) : # make -j2 -C $@ BINDIR := ../bin/ #List all your binaries here -- CHANGE THIS BIN := tester handletester cgiconv #Binaries with directory prepended (ignore this) DBIN := $(patsubst %, $(BINDIR)%, $(BIN)) #The first (and therefore default) rule -- compile all binaries listed above (can usually ignore this) all : $(DBIN) #List here each of the binaries we make, and on what object files they depend -- CHANGE THESE # if there is just one binary, you can delete/comment out the other rules. # Note that if a binary depends on X.c or X.cc or X.cpp, etc., list X.o $(BINDIR)tester : context.o tester.o $(BINDIR)handletester : handletester.o $(BINDIR)cgiconv : bluecondb-msqlpp.o context.o cgiconv.o #cgicontext.o #The libraries we want to link against (the linker is pretty good at figuring out what we actually need of these) # (i.e. it will cut out the crud if we over-specify) LIBS := -lm # -lSDLmain -lSDL -liberty -lGL -lGLU -lglut -lpng -lz #-lpthread -ldl -lccgnu2 #optimisations to use (you can tweak these, but probably don't need to) OPTIM0 := -ggdb #debugging OPTIM1 := -O2 #'safe' optimisations OPTIM2 := -O3 -march=pentium4 -fomit-frame-pointer #keen optimisations, prolly safe on P4 #If you want to profile your code (with or without optimisations), you can ignore this PROFILE := -fno-omit-frame-pointer -pg #What compilation flags to use (note we separate from warnings for a cleaner compile command line) # Pick your optimisations level here and optionally include $(PROFILE) FLAGS := -ansi -pedantic -pipe $(OPTIM1) #Use same flags at this point for C/C++ (warnings will be different though) CFLAGS := $(FLAGS) CXXFLAGS := $(FLAGS) #Any non-standard includes go here INCLUDES := #-I../include # -I/usr/include/mysql #Pick our compilers CC = gcc CXX = g++ #If you are compiling C++ source, you will need to change this to g++ LN = gcc #Include some non-default warnings, note that some only apply to C source WARNINGS := -Wall -W -Wcast-qual -Wwrite-strings -Wno-long-long -Wshadow CWARNINGS := $(WARNINGS) -Wmissing-declarations -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes CXXWARNINGS := $(WARNINGS) -Woverloaded-virtual -D_GLIBCXX_CONCEPT_CHECKS -D_GLIBCPP_CONCEPT_CHECKS #(-D_GLIBCPP_CONCEPT_CHECKS is < gcc-3.4, -D_GLIBCXX_CONCEPT_CHECKS is >= gcc-3.4) #Rule for linking executables $(DBIN) : $(LN) $(CFLAGS) $^ -o $@ $(LIBS) #Phony rules -- these are always run (even if a file of the same name exists and is "up to date") .PHONY : clean veryclean all depend #Rule for cleaning -- remove object files and editor temporaries (recursive search) clean : rm -f $(shell find . -name '*.o' -or -name '*~') #veryclean will remove binaries too veryclean : clean rm -f $(DBIN) #rule for compiling C++ files (note this overrides the implicit rule for all the warnings stuff) %.o:%.cc $(CXX) -c -o $@ $< $(CXXFLAGS) $(INCLUDES) $(CXXWARNINGS) #override implicit rule for C files %.o:%.c $(CC) -c -o $@ $< $(CFLAGS) $(INCLUDES) $(CWARNINGS) #Catch other C++ extensions %.o:%.cpp $(CXX) -c -o $@ $< $(CXXFLAGS) $(INCLUDES) $(CXXWARNINGS) # Header dependencies... # do `make depend` to append header dependencies to this file # only go two directories down depend : makedepend -Y *.c */*.c */*.cpp *.cpp *.cc */*.cc 2>/dev/null # DO NOT DELETE