dev/c/tex_parser/Makefile

116 lines
3.5 KiB
Makefile

#_________________________________
# ENVIRONMENT |
#________________________________|
CC=cc
CXX=c++
INCLUDE=-I$(HOME)/projects/include
LIBRARIES=
#-lexpat $(shell pkg-config --cflags liblist)
TARGET=tex_parser_test
#________________________________________
# BUILD SCRIPT (don't change) |
#_______________________________________|
# Compiler flags
# if mode variable is empty, setting debug build mode
ifeq ($(mode),)
mode = debug
endif
ifeq ($(mode),debug)
CFLAGS = -O0 -g -std=gnu99 -pedantic -Wextra -Wconversion
LDFLAGS =
endif
ifeq ($(mode),profile)
CFLAGS = -O0 -g -p -ftest-coverage -Wcoverage-mismatch
LDFLAGS = -g -p
endif
ifeq ($(mode),develop)
CFLAGS += -O2 -g
LDFLAGS += -O1
endif
ifeq ($(mode),release)
CFLAGS += -O2
LDFLAGS += -O1
endif
CFLAGS += -Wall
LDFLAGS += -Wall $(LIBRARIES)
all: change_build_mode $(TARGET)
ifneq ($(mode),debug)
ifneq ($(mode),profile)
ifneq ($(mode),develop)
ifneq ($(mode),release)
@echo "Invalid build mode."
@echo "Please use 'make mode=release', 'make mode=develop' or 'make mode=debug'"
@exit 1
endif
endif
endif
endif
@echo ".........................."
@echo "Building on "$(mode)" mode "
@echo "CFLAGS=$(CFLAGS)"
@echo "LDFLAGS=$(LDFLAGS)"
@echo ".........................."
OLD_BUILD_MODE=$(shell cat build_mode.out 2>/dev/null)
change_build_mode:
ifneq ($(mode), $(OLD_BUILD_MODE))
@echo CLEANING...
@make clean &>/dev/null
@echo $(mode) > build_mode.out
endif
%.o :
$(CC) -c $(CFLAGS) $(INCLUDE) -o $@ $<
clean:
$(RM) *.o *.out callgrind.out.* *.gcno $(TARGET)
.PHONY: all change_build_mode clean
#_________________________________
# R U L E S |
#________________________________|
KOLAN_PROJECTS=$(HOME)/projects
KOLAN_INCLUDE=$(KOLAN_PROJECTS)/include
target_objs = tex_parser_test.o tex_parser.o tex_parser_table.o tex_parser_graphics.o \
zalloc_ext.o zalloc.o xalloc.o zerror.o xerror.o
$(TARGET): $(target_objs)
$(CC) $(LDFLAGS) -o $@ $(target_objs)
tex_parser_test.o: tex_parser_test.c tex_parser.c tex_parser.h tex_parser_const.h \
tex_parser_table.h tex_parser_graphics.h \
$(KOLAN_INCLUDE)/xerror.h $(KOLAN_INCLUDE)/zerror.h \
$(KOLAN_INCLUDE)/xalloc.h $(KOLAN_INCLUDE)/zalloc.h $(KOLAN_INCLUDE)/zalloc_ext.h
tex_parser.o: tex_parser.c tex_parser.h tex_parser_const.h \
tex_parser_table.h tex_parser_graphics.h \
$(KOLAN_INCLUDE)/xerror.h $(KOLAN_INCLUDE)/zerror.h \
$(KOLAN_INCLUDE)/xalloc.h $(KOLAN_INCLUDE)/zalloc.h $(KOLAN_INCLUDE)/zalloc_ext.h
tex_parser_table.o: tex_parser_table.c tex_parser_table.h tex_parser_const.h \
$(KOLAN_INCLUDE)/xerror.h $(KOLAN_INCLUDE)/zerror.h \
$(KOLAN_INCLUDE)/xalloc.h $(KOLAN_INCLUDE)/zalloc.h \
$(KOLAN_INCLUDE)/zalloc_ext.h
tex_parser_graphics.o: tex_parser_graphics.c tex_parser_graphics.h tex_parser_const.h \
$(KOLAN_INCLUDE)/xerror.h $(KOLAN_INCLUDE)/zerror.h \
$(KOLAN_INCLUDE)/xalloc.h $(KOLAN_INCLUDE)/zalloc.h \
$(KOLAN_INCLUDE)/zalloc_ext.h
zalloc_ext.o: $(KOLAN_INCLUDE)/zalloc_ext.c $(KOLAN_INCLUDE)/zalloc_ext.h \
$(KOLAN_INCLUDE)/zalloc.h $(KOLAN_INCLUDE)/xerror.h
zalloc.o: $(KOLAN_INCLUDE)/zalloc.c $(KOLAN_INCLUDE)/zalloc.h $(KOLAN_INCLUDE)/xerror.h
xalloc.o: $(KOLAN_INCLUDE)/xalloc.c $(KOLAN_INCLUDE)/xalloc.h $(KOLAN_INCLUDE)/xerror.h
zerror.o: $(KOLAN_INCLUDE)/zerror.c $(KOLAN_INCLUDE)/zerror.h $(KOLAN_INCLUDE)/xerror.h
xerror.o: $(KOLAN_INCLUDE)/xerror.c $(KOLAN_INCLUDE)/xerror.h