#CPPFLAGS Extra flags to give to the C preprocessor and programs that use it (the C and Fortran compilers). #CFLAGS Extra flags to give to the C compiler. #CXXFLAGS Extra flags to give to the C++ compiler. #LDFLAGS Extra flags to give to compilers when they are supposed to invoke the linker, 'ld'. #Standard variables: CC = gcc CXX = g++ LEX = lex YACC= yacc CFLAGS = -Wall $(DEBUGFLAGS) $(SDL_CFLAGS) CXXFLAGS = -Wall $(DEBUGFLAGS) $(SDL_CFLAGS) LFLAGS = YFLAGS = -d LDFLAGS = $(SDL_LDFLAGS) #My variables: #DEBUGFLAGS = -g -ggdb SDL_CFLAGS := $(shell sdl-config --cflags) SDL_LDFLAGS := $(shell sdl-config --libs) -lSDL_image #List of files PROG = tile #Name of executable file #=====================================# # No need to change below this line # #=====================================# OBJECTS = main.o tileset.o #Basic rules .PHONY: all clean all: $(PROG) clean: for a in $(OBJECTS) $(PROG); do \ rm -f $$a ; \ done $(PROG): $(OBJECTS) $(CC) $(LDFLAGS) -o $@ $^ #Some implicit rules main.o: main.c tileset.o: tileset.c #Some header dependency main.o: common.h tileset.h tileset.o: tileset.h #The variables: # $@ - The name of the target of the rule. # $? - The names of all the prerequisites that are newer than the target. # $< - The name of the first prerequisite. # $^ - The names of all the prerequisites. #Pattern-rules %.o: %.c $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $< %.o: %.cpp $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) -o $@ $< %.o: %.h %.c: %.l lex $(LFLAGS) -t $< > $@ %.cpp: %.l lex $(LFLAGS) -t $< > $@ %.c: %.y yacc $< mv -f y.tab.c $@ %.cpp: %.y yacc $(YFLAGS) $< mv -f y.tab.c $@