# project name and version PROJECT = accounting # header files HEADERS += u.h HEADERS += util.h HEADERS += parse.h # source files SOURCES += util.c SOURCES += parse.c SOURCES += main.c # object files OBJECTS = $(SOURCES:.c=.o) # tarball content TARBALL += Makefile TARBALL += $(HEADERS) TARBALL += $(SOURCES) # programs CC = cc CCFLAGS = -pedantic -pedantic-errors -ansi -Wall -Werror -O2 CCDEBUGFLAGS = -pedantic -pedantic-errors -ansi -Wall -Werror -O0 -ggdb3 LD = ld LDFLAGS = LDDEBUGFLAGS = # -t STRIP = strip STRIPFLAGS = -s RM = rm RMFLAGS = -f CP = cp CPFLAGS = -i TAR = tar TARFLAGS = -v COMPRESS = gzip COMPRESSFLAGS = -9 -f # debugging ifeq ($(debug), 1) CCFLAGS = $(CCDEBUGFLAGS) LDFLAGS = $(LDDEBUGFLAGS) else CCFLAGS += -DNDEBUG endif # compilation targets all: $(SOURCES) $(PROJECT) $(PROJECT): $(OBJECTS) $(CC) $(CCFLAGS) $(LDFLAGS) $(OBJECTS) -o $@ remake: clean $(PROJECT) # file targets %.o: %.c $(HEADERS) $(CC) $(CCFLAGS) -c -o $@ $< # stripping strip: strip $(STRIPFLAGS) $(OBJECTS) strip $(STRIPFLAGS) $(PROJECT) # cleaning targets clean-all: clean $(RM) $(RMFLAGS) $(PROJECT) $(RM) $(RMFLAGS) $(PROJECT).tar.* clean: $(RM) $(RMFLAGS) $(OBJECTS) $(RM) $(RMFLAGS) $(SOURCES:.c=.c.[0-9]*) # create compressed tarball tarball: $(TAR) -c $(TARFLAGS) -f $(PROJECT).tar $(TARBALL) $(COMPRESS) $(COMPRESSFLAGS) $(PROJECT).tar # usage information help: @echo 'make [debug=1] [all] [remake] [clean(-all)] [tarball]'