dev/c/realloc_speed_test/Makefile

80 lines
2.1 KiB
Makefile

CC=cc
CXX=c++
INCLUDE=-I$(HOME)/projects/include
KOLAN_PROJECTS=$(HOME)/projects
KOLAN_INCLUDE=$(KOLAN_PROJECTS)/include
# 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
CXXFLAGS = -O0 -g -std=c++0x -pedantic -Wextra -Wconversion
LDFLAGS =
endif
ifeq ($(mode),profile)
CFLAGS = -O0 -g -p -ftest-coverage -Wcoverage-mismatch
CXXFLAGS =$(CFLAGS)
LDFLAGS = -g -p
endif
ifeq ($(mode),develop)
CFLAGS += -O2 -g
CXXFLAGS = $(CFLAGS)
LDFLAGS += -O1
endif
ifeq ($(mode),release)
CFLAGS += -O2
CXXFLAGS = $(CFLAGS)
LDFLAGS += -O1
endif
CFLAGS += -Wall $(shell pkg-config --cflags liblist)
CXXFLAGS += -Wall $(shell pkg-config --cflags liblist)
LDFLAGS += -Wall $(shell pkg-config --libs liblist) -lpthread -lexpat
all: realloc_speed_test_c realloc_speed_test_cpp
ifneq ($(mode),debug)
ifneq ($(mode),profile)
ifneq ($(mode),develop)
ifneq ($(mode),release)
@echo "Invalid build mode."
@echo "Please use 'make mode=release' or 'make mode=develop' or 'make mode=debug'"
@exit 1
endif
endif
endif
endif
@echo ".........................."
@echo "Building on "$(mode)" mode "
@echo "CFLAGS=$(CFLAGS)"
@echo "CXXFLAGS=$(CXXFLAGS)"
@echo "LDLAGS=$(LDFLAGS)"
@echo ".........................."
realloc_speed_test_cpp: realloc_speed_test_cpp.o
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(INCLUDE) -o $@ realloc_speed_test_cpp.o
realloc_speed_test_cpp.o: realloc_speed_test_cpp.[c,h]pp
$(CXX) -c $(CXXFLAGS) $(LDFLAGS) $(INCLUDE) -o $@ realloc_speed_test_cpp.cpp
%.o :
$(CC) -c $(CFLAGS) $(LDFLAGS) $(INCLUDE) -o $@ $<
realloc_speed_test_c_obj = realloc_speed_test_c.o xalloc.o xerror.o
realloc_speed_test_c: $(realloc_speed_test_c_obj)
$(CC) $(CFLAGS) $(LDFLAGS) $(INCLUDE) -o $@ $(realloc_speed_test_c_obj)
realloc_speed_test_c.o: realloc_speed_test_c.[c,h] xalloc.o
xalloc.o: $(KOLAN_INCLUDE)/xalloc.c $(KOLAN_INCLUDE)/xalloc.h xerror.o
xerror.o: $(KOLAN_INCLUDE)/xerror.[c,h]
clean:
$(RM) *.o *.out callgrind.out.* *.gcno realloc_speed_test_cpp realloc_speed_test_c
.PHONY: all clean