Make me wonder

This is how I changed the make file to get what I want. I want the objects that are linked to the main program to be recompiled when a change is made in the headers. I also wanted to have a quick command to allow the use of gdb or kdb. For the sake of some education, the names with = are substituted when the name is encountered preceded by $ and enclosed in () like $(NAME). It substitutes all of the text, except the line continuation mark '\' , before it executes the make action. In this case 'DEBUGIT = -g' and '$(DEBUGIT)' would be replaced with just the two characters '-g' . One odd thing about make files, is that there MUST be a tab on the line after a line using ':' Obviously or not, the lines with # are comment lines and are ignored by make.

LIBS  = -lGL -lglut -lSDL_mixer
PROJECT = puzzler
CC = gcc -Wall -W -ansi -pedantic 

# This is the flag to add to get debug symbols for GDB
# See man gcc with search '/-g ' with the space!
# That is vi command '/' = search
# This will make the code slow usually and -O can be used
DEBUGIT = -g


OBJECTS =  $(PROJECT)_gl.o $(PROJECT)_game.o $(PROJECT)_sdl.o $(PROJECT)_textures.o \
  $(PROJECT)_save.o $(PROJECT)_matrix.o $(PROJECT)_menu.o

SOURCES =  $(PROJECT)_gl.c $(PROJECT)_game.c $(PROJECT)_sdl.c $(PROJECT)_textures.c \
  $(PROJECT)_save.c $(PROJECT)_matrix.c $(PROJECT)_menu.c

#Build is dependent on changes to makefile also
DEPENDS = makefile $(PROJECT).h $(PROJECT).c $(PROJECT)_game.c \
  $(PROJECT)_sdl.c $(PROJECT)_save.c $(PROJECT)_gl.c $(PROJECT)_textures.c \
  $(PROJECT)_matrix.c $(PROJECT)_menu.c $(PROJECT)_game.h $(OBJECTS)

puzzler:  $(DEPENDS)
  $(CC) -c  $(SOURCES)
  $(CC) $(PROJECT).c -o $(PROJECT) $(OBJECTS) $(LIBS)
#  strip $(PROJECT)
#  ls -la $(PROJECT)

#Create the debug version, if needed
puzzlerD:
  $(CC) $(DEBUGIT) -c $(SOURCES)
  $(CC) $(DEBUGIT)    $(PROJECT).c -o $(PROJECT) $(OBJECTS) $(LIBS)

0 comments:

Contributors

Automated Intelligence

Automated Intelligence
Auftrag der unendlichen LOL katzen