Commit 7ca2ed1a authored by Davide Galassi's avatar Davide Galassi

Build system update

parent 08dde722
......@@ -10,16 +10,11 @@ AWK := awk
CP := cp
RM := rm -rf
#
# Get build name
#
# $(call normalstr,str)
build_name = $(shell $(CC) -dumpmachine)
# convert to lowercase
binary_dir = build/$(build_name)
# call $(src_to_bin_dir,list)
src_to_bin_dir = $(patsubst $(source_dir)%,$(binary_dir)%,$1)
......@@ -27,31 +22,28 @@ target = $(binary_dir)/libcry.a
.SUFFIXES:
#warnings := -Wall -Wextra -Wpedantic -Wconversion -Wshadow \
-Wstrict-prototypes -Wmissing-prototypes
includes-y := -Iinclude -Isrc
cflags-y := -Wall -MMD -MP
cflags-y := -MMD -MP $(warnings)
cflags-$(CRY_COVERAGE) += --coverage
cflags-$(CRY_SHORT_ENUMS) += -fshort-enums
cflags-$(CRY_OMIT_FRAME_POINTER) += -fomit-frame-pointer
ifeq ($(CRY_STACK_PROTECTOR),y)
cflags-y += -fstack-protector
else
cflags-y += -fno-stack-protector
endif
cflags-$(CRY_NO_STACK_PROTECTOR) += -fno-stack-protector
ifeq ($(CRY_DEBUG),y)
cflags-y += -O0 -g3 -fno-inline
cflags-y += -O0 -g3
else
cflags-y += -DNDEBUG
ifeq ($(CRY_SMALL_SIZE),y)
cflags-y += -Os
else
cflags-y += -O3 -funroll-loops
cflags-y += -O3
endif
endif
objects-y :=
paths-y :=
objects_list :=
......@@ -81,7 +73,10 @@ LDFLAGS := $(lflags-y)
.PHONY: all cry clean config test testclean doc
all: cry
# Force serial run
all:
$(MAKE) config
$(MAKE) cry
cry: $(target)
......@@ -91,10 +86,12 @@ clean:
@$(RM) `find . -type f \( -name \*.gcda -o -name \*.gcno \)`
config: $(config_mk)
@echo "Building config ..."
@printf "/*\n * Automatically generated. Do not edit.\n */\n\n" > $(config_h)
@$(AWK) -F= 'NF > 1 && $$1 !~ /^[# ]/ { print "#define", $$1; }' $< >> $(config_h)
@printf "/*\n * Automatically generated from \"$^\".\n */\n\n" > tmp
@$(AWK) -F= 'NF > 1 && $$1 !~ /^[# ]/ { print "#define", $$1; }' < $^ >> tmp
@cmp -s tmp $(config_h) || (echo "Configuration update"; cp tmp $(config_h))
@$(RM) tmp
@echo ">>> Config:"
@cat $(config_h) | grep CRY_ | $(AWK) '{ printf(" * %s\n", $$2); }'
$(target): $(objects)
$(AR) rcs $@ $^
......@@ -108,7 +105,7 @@ $(config_h): $(config_mk)
$(binary_dir)/%.o: $(source_dir)/%.c
$(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
test: $(target)
test: all
$(MAKE) -C test
testclean:
......
......@@ -9,9 +9,9 @@
################################################################################
CRY_DEBUG=y
#CRY_OMIT_FRAME_POINTER=y
#CRY_SMALL_SIZE=y
#CRY_STACK_PROTECTOR=y
#CRY_OMIT_FRAME_POINTER=y
#CRY_NO_STACK_PROTECTOR=y
#CRY_COVERAGE=y
################################################################################
......
......@@ -9,9 +9,9 @@
################################################################################
CRY_DEBUG=y
#CRY_OMIT_FRAME_POINTER=y
#CRY_SMALL_SIZE=y
#CRY_STACK_PROTECTOR=y
#CRY_OMIT_FRAME_POINTER=y
#CRY_NO_STACK_PROTECTOR=y
CRY_COVERAGE=y
################################################################################
......
/*
* Automatically generated. Do not edit.
* Automatically generated from "config/config.mk".
*/
#define CRY_DEBUG
......
......@@ -6,8 +6,7 @@ CFLAGS := -O0 -g3 -Wall
CPPFLAGS = -I. -I../include -I../src
LDFLAGS := --coverage -Wl,--wrap=malloc,--wrap=realloc,--wrap=calloc,--wrap=free
objs := \
objects := \
test.o \
malloc_mock.o \
version_test.o \
......@@ -35,13 +34,15 @@ objs := \
.PHONY: all clean
all: $(objs) $(libcry)
all: $(objects) $(libcry)
$(CC) $(LDFLAGS) -o test $^
clean:
$(RM) $(objs) test
$(RM) $(objects) test
$(RM) `find . -type f \( -name \*.gcda -o -name \*.gcno -o -name \*.gcov \)`
$(objects): ../include/cry/config.h
coverage: test
@mkdir -p out/coverage
@lcov -q -z -d ../build
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment