dev/c/tex_parser/Makefile

104 lines
2.8 KiB
Makefile
Raw Normal View History

2011-07-01 15:16:59 +04:00
#_________________________________
# ENVIRONMENT |
#________________________________|
CC=cc
CXX=c++
INCLUDE=-I$(HOME)/projects/include
2011-07-01 15:16:59 +04:00
LIBRARIES=
#-lexpat $(shell pkg-config --cflags liblist)
TARGET=tex_parser_test
#________________________________________
2011-07-01 15:16:59 +04:00
# 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
2011-07-01 15:16:59 +04:00
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 :
2011-07-01 15:16:59 +04:00
$(CC) -c $(CFLAGS) $(INCLUDE) -o $@ $<
2011-07-01 15:16:59 +04:00
clean:
$(RM) *.o *.out callgrind.out.* *.gcno $(TARGET)
.PHONY: all change_build_mode clean
2011-07-01 15:16:59 +04:00
#_________________________________
# R U L E S |
#________________________________|
KOLAN_PROJECTS=$(HOME)/projects
KOLAN_INCLUDE=$(KOLAN_PROJECTS)/include
2011-06-20 17:24:43 +04:00
target_objs = tex_parser_test.o tex_parser.o \
2011-07-01 15:16:59 +04:00
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 \
2011-07-01 15:16:59 +04:00
$(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 \
2011-07-01 15:16:59 +04:00
$(KOLAN_INCLUDE)/xerror.h $(KOLAN_INCLUDE)/zerror.h \
$(KOLAN_INCLUDE)/xalloc.h $(KOLAN_INCLUDE)/zalloc.h $(KOLAN_INCLUDE)/zalloc_ext.h
2011-07-01 15:16:59 +04:00
zalloc_ext.o: $(KOLAN_INCLUDE)/zalloc_ext.c $(KOLAN_INCLUDE)/zalloc_ext.h \
$(KOLAN_INCLUDE)/zalloc.h $(KOLAN_INCLUDE)/xerror.h
2011-07-01 15:16:59 +04:00
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