dev/c/realloc_speed_test/Makefile

140 lines
3.8 KiB
Makefile

# This file is generated with smake.sh.
# You can use this make file with instruction make to
# use one of build mode: debug, profile, develop, release.
# No need to call make clean if You make with other mode,
# because the Makefile containes rules for automatically clean.
# Some usage examples:
# make # default mode is debug
# CFLAGS="-O2 -march=core2 -mtune=core2 --msse4.1 mfpmath=sse -fomit-frame-pointer -pipe" LDFLAGS="-Wl,-O1 -Wl,-ass-needed" make mode=develop
# CFLAGS="-O2 -march=amdfam10 -mtune=amdfam10 -msse4a --mfpmath=sse -fomit-frame-pointer -pipe" LDFLAGS="-Wl,-O1 -Wl,--as-needed" make mode=profile
# CFLAGS="-O2 -march=k6-2 -mtune=k6-2 -m3dnow --mfpmath=387 -fomit-frame-pointer -pipe" LDFLAGS="-Wl,-O1 -Wl,--as-needed" make mode=release
# Report bugs to <mecareful@gmail.com>
#_________________________________
# ENVIRONMENT |
#________________________________|
TARGET0=realloc_speed_test_c
TARGET1=realloc_speed_test_cpp
TARGET2=realloc_speed_test_glib
TARGETS= $(TARGET0) $(TARGET1) $(TARGET2)
CC=cc
CXX=c++
LIBS=-lglib-2.0 -lstdc++
SRC1=$(HOME)/projects/texreport/mod-alloc
SRC2=$(HOME)/projects/texreport/mod-err
SRC=-I$(SRC1) -I$(SRC2)
INCLUDES=-I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include
#________________________________________
# BUILD SCRIPT (don't change) |
#_______________________________________|
ifeq ($(mode),)
mode = debug
endif
ifeq ($(mode),debug)
CFLAGS := -O0 -g -std=gnu99 -pedantic -Wextra -Wconversion $(CFLAGS)
LDFLAGS := $(LDFLAGS)
endif
ifeq ($(mode),profile)
CFLAGS := -O0 -g -p -ftest-coverage -Wcoverage-mismatch $(CFLAGS)
LDFLAGS := -g -p $(LDFLAGS)
endif
ifeq ($(mode),develop)
CFLAGS := -O2 -g $(CFLAGS)
LDFLAGS := -O1 $(LDFLAGS)
endif
ifeq ($(mode),release)
CFLAGS := -O2 $(CFLAGS)
LDFLAGS := -O1 $(LDFLAGS)
endif
CFLAGS += -Wall $(INCLUDES)
LDFLAGS += -Wall $(LIBS)
all: change_make_options $(TARGETS)
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', 'make mode=profile' 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 grep ^MODE make_options.out 2>/dev/null | sed 's~^MODE=~~')
OLD_BUILD_CFLAGS=$(shell grep ^CFLAGS make_options.out 2>/dev/null | sed 's~^CFLAGS=~~')
OLD_BUILD_LDFLAGS=$(shell grep ^LDFLAGS make_options.out 2>/dev/null | sed 's~^LDFLAGS=~~')
change_make_options:
ifneq ($(mode)|$(CFLAGS)|$(LDFLAGS), $(OLD_BUILD_MODE)|$(OLD_BUILD_CFLAGS)|$(OLD_BUILD_LDFLAGS))
@echo CLEANING...
@make clean &>/dev/null
@echo "MODE=$(mode)" > make_options.out
@echo "CFLAGS=$(CFLAGS)" >> make_options.out
@echo "LDFLAGS=$(LDFLAGS)" >> make_options.out
endif
%.o :
$(CC) -c $(CFLAGS) $(SRC) -o $@ $<
clean:
$(RM) *.o *.out callgrind.out.* *.gcno $(TARGETS)
.PHONY: all change_make_options clean
#_________________________________
# R U L E S |
#________________________________|
target_objs0 = \
realloc_speed_test_c.o \
xalloc.o \
xerror.o
$(TARGET0): $(target_objs0)
$(CC) $(LDFLAGS) -o $@ $(target_objs0)
target_objs1 = \
realloc_speed_test_cpp.o
$(TARGET1): $(target_objs1)
$(CC) $(LDFLAGS) -o $@ $(target_objs1)
target_objs2 = \
realloc_speed_test_glib.o \
xalloc.o \
xerror.o
$(TARGET2): $(target_objs2)
$(CC) $(LDFLAGS) -o $@ $(target_objs2)
realloc_speed_test_c.o: \
realloc_speed_test_c.c \
$(SRC1)/xalloc.h
realloc_speed_test_cpp.o: \
realloc_speed_test_cpp.cpp
realloc_speed_test_glib.o: \
realloc_speed_test_glib.c \
$(SRC1)/xalloc.h
xalloc.o: \
$(SRC1)/xalloc.c \
$(SRC1)/xalloc.h \
$(SRC2)/xerror.h
xerror.o: \
$(SRC2)/xerror.c \
$(SRC2)/xerror.h