2011-07-11 11:48:24 +04:00
|
|
|
# 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:
|
2011-07-17 21:41:45 +04:00
|
|
|
# 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
|
2011-07-11 11:48:24 +04:00
|
|
|
# Report bugs to <mecareful@gmail.com>
|
|
|
|
|
|
|
|
#_________________________________
|
|
|
|
# ENVIRONMENT |
|
|
|
|
#________________________________|
|
2011-06-14 13:35:44 +04:00
|
|
|
CC=cc
|
|
|
|
CXX=c++
|
2011-07-17 21:41:45 +04:00
|
|
|
LIBRARIES=-lstdc++
|
|
|
|
TARGET0=std_string_speed_test
|
|
|
|
TARGET1=zalloc_speed_test_c
|
|
|
|
TARGET2=zalloc_ext_test
|
|
|
|
TARGET= $(TARGET0) $(TARGET1) $(TARGET2)
|
2011-07-11 11:48:24 +04:00
|
|
|
INCLUDE1=$(HOME)/projects/include
|
|
|
|
INCLUDE2=/usr/local/include
|
|
|
|
INCLUDE=-I$(INCLUDE1) -I$(INCLUDE2)
|
2011-06-14 13:35:44 +04:00
|
|
|
|
2011-07-11 11:48:24 +04:00
|
|
|
#________________________________________
|
|
|
|
# BUILD SCRIPT (don't change) |
|
|
|
|
#_______________________________________|
|
2011-06-14 13:35:44 +04:00
|
|
|
ifeq ($(mode),)
|
|
|
|
mode = debug
|
|
|
|
endif
|
|
|
|
ifeq ($(mode),debug)
|
2011-07-17 21:41:45 +04:00
|
|
|
CFLAGS := -O0 -g -std=gnu99 -pedantic -Wextra -Wconversion $(CFLAGS)
|
|
|
|
LDFLAGS := $(LDFLAGS)
|
2011-06-14 13:35:44 +04:00
|
|
|
endif
|
|
|
|
ifeq ($(mode),profile)
|
2011-07-17 21:41:45 +04:00
|
|
|
CFLAGS := -O0 -g -p -ftest-coverage -Wcoverage-mismatch $(CFLAGS)
|
|
|
|
LDFLAGS := -g -p $(LDFLAGS)
|
2011-06-14 13:35:44 +04:00
|
|
|
endif
|
|
|
|
ifeq ($(mode),develop)
|
2011-07-17 21:41:45 +04:00
|
|
|
CFLAGS := -O2 -g $(CFLAGS)
|
|
|
|
LDFLAGS := -O1 $(LDFLAGS)
|
2011-06-14 13:35:44 +04:00
|
|
|
endif
|
|
|
|
ifeq ($(mode),release)
|
2011-07-17 21:41:45 +04:00
|
|
|
CFLAGS := -O2 $(CFLAGS)
|
|
|
|
LDFLAGS := -O1 $(LDFLAGS)
|
2011-06-14 13:35:44 +04:00
|
|
|
endif
|
|
|
|
|
|
|
|
CFLAGS += -Wall
|
2011-07-11 11:48:24 +04:00
|
|
|
LDFLAGS += -Wall $(LIBRARIES)
|
2011-06-14 13:35:44 +04:00
|
|
|
|
2011-07-11 11:48:24 +04:00
|
|
|
all: change_make_options $(TARGET)
|
2011-06-14 13:35:44 +04:00
|
|
|
|
|
|
|
ifneq ($(mode),debug)
|
|
|
|
ifneq ($(mode),profile)
|
|
|
|
ifneq ($(mode),develop)
|
|
|
|
ifneq ($(mode),release)
|
|
|
|
@echo "Invalid build mode."
|
2011-07-11 11:48:24 +04:00
|
|
|
@echo "Please use 'make mode=release', 'make mode=develop', 'make mode=profile' or 'make mode=debug'"
|
2011-06-14 13:35:44 +04:00
|
|
|
@exit 1
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
@echo ".........................."
|
|
|
|
@echo "Building on "$(mode)" mode "
|
|
|
|
@echo "CFLAGS=$(CFLAGS)"
|
|
|
|
@echo "LDFLAGS=$(LDFLAGS)"
|
|
|
|
@echo ".........................."
|
|
|
|
|
2011-07-11 11:48:24 +04:00
|
|
|
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
|
2011-07-17 21:41:45 +04:00
|
|
|
@echo "MODE=$(mode)" > make_options.out
|
|
|
|
@echo "CFLAGS=$(CFLAGS)" >> make_options.out
|
|
|
|
@echo "LDFLAGS=$(LDFLAGS)" >> make_options.out
|
2011-07-11 11:48:24 +04:00
|
|
|
endif
|
|
|
|
|
2011-06-14 13:35:44 +04:00
|
|
|
%.o :
|
2011-07-11 11:48:24 +04:00
|
|
|
$(CC) -c $(CFLAGS) $(INCLUDE) -o $@ $<
|
|
|
|
|
|
|
|
clean:
|
|
|
|
$(RM) *.o *.out callgrind.out.* *.gcno $(TARGET)
|
2011-06-14 13:35:44 +04:00
|
|
|
|
2011-07-11 11:48:24 +04:00
|
|
|
.PHONY: all change_make_options clean
|
2011-06-14 13:35:44 +04:00
|
|
|
|
2011-07-11 11:48:24 +04:00
|
|
|
#_________________________________
|
|
|
|
# R U L E S |
|
|
|
|
#________________________________|
|
|
|
|
target_objs0 = \
|
2011-07-17 21:41:45 +04:00
|
|
|
std_string_speed_test.o
|
|
|
|
|
|
|
|
$(TARGET0): $(target_objs0)
|
|
|
|
$(CC) $(LDFLAGS) -o $@ $(target_objs0)
|
|
|
|
|
|
|
|
|
|
|
|
target_objs1 = \
|
|
|
|
zalloc_speed_test_c.o \
|
|
|
|
xerror.o \
|
|
|
|
zalloc.o \
|
|
|
|
zalloc_ext.o
|
|
|
|
|
|
|
|
$(TARGET1): $(target_objs1)
|
|
|
|
$(CC) $(LDFLAGS) -o $@ $(target_objs1)
|
|
|
|
|
|
|
|
|
|
|
|
target_objs2 = \
|
2011-07-11 11:48:24 +04:00
|
|
|
zalloc_ext_test.o \
|
|
|
|
xalloc.o \
|
|
|
|
xerror.o \
|
|
|
|
zalloc.o \
|
|
|
|
zalloc_ext.o
|
2011-06-14 13:35:44 +04:00
|
|
|
|
2011-07-17 21:41:45 +04:00
|
|
|
$(TARGET2): $(target_objs2)
|
|
|
|
$(CC) $(LDFLAGS) -o $@ $(target_objs2)
|
|
|
|
|
2011-06-14 13:35:44 +04:00
|
|
|
|
2011-07-17 21:41:45 +04:00
|
|
|
std_string_speed_test.o: \
|
|
|
|
std_string_speed_test.cpp
|
|
|
|
|
|
|
|
zalloc_speed_test_c.o: \
|
|
|
|
zalloc_speed_test_c.c \
|
|
|
|
$(INCLUDE1)/zalloc.h \
|
|
|
|
$(INCLUDE1)/zalloc_ext.h
|
2011-06-14 13:35:44 +04:00
|
|
|
|
2011-07-11 11:48:24 +04:00
|
|
|
zalloc_ext_test.o: \
|
|
|
|
zalloc_ext_test.c \
|
|
|
|
$(INCLUDE1)/xalloc.h \
|
|
|
|
$(INCLUDE1)/zalloc.h \
|
|
|
|
$(INCLUDE1)/zalloc_ext.h
|
2011-06-15 20:00:24 +04:00
|
|
|
|
2011-07-11 11:48:24 +04:00
|
|
|
zalloc.o: \
|
|
|
|
$(INCLUDE1)/zalloc.c \
|
|
|
|
$(INCLUDE1)/xerror.h \
|
|
|
|
$(INCLUDE1)/zalloc.h
|
|
|
|
|
|
|
|
zalloc_ext.o: \
|
|
|
|
$(INCLUDE1)/zalloc_ext.c \
|
|
|
|
$(INCLUDE1)/zalloc.h \
|
|
|
|
$(INCLUDE1)/zalloc_ext.h
|
|
|
|
|
2011-07-17 21:41:45 +04:00
|
|
|
xalloc.o: \
|
|
|
|
$(INCLUDE1)/xalloc.c \
|
|
|
|
$(INCLUDE1)/xalloc.h \
|
|
|
|
$(INCLUDE1)/xerror.h
|
|
|
|
|
2011-07-11 11:48:24 +04:00
|
|
|
xerror.o: \
|
|
|
|
$(INCLUDE1)/xerror.c \
|
|
|
|
$(INCLUDE1)/xerror.h
|
2011-06-14 13:35:44 +04:00
|
|
|
|