Files
exercism/c/phone-number/makefile

52 lines
1.2 KiB
Makefile

### If you wish to use extra libraries (math.h for instance),
### add their flags here (-lm in our case) in the "LIBS" variable.
LIBS = -lm
###
CFLAGS = -std=c99
CFLAGS += -g
CFLAGS += -Wall
CFLAGS += -Wextra
CFLAGS += -pedantic
CFLAGS += -Werror
CFLAGS += -Wmissing-declarations
CFLAGS += -DUNITY_SUPPORT_64
# detect compiler.
REALCC=$(realpath $(shell which $(CC)))
CC_VERSION_TEXT=$(shell $(REALCC) --version 2>/dev/null | head -n 1)
# fix discrepancies in compilers warnings. Only gcc and clang for now.
ifneq ($(findstring clang,$(CC_VERSION_TEXT)),)
CFLAGS += -Wimplicit-fallthrough
else
ifneq ($(findstring gcc,$(CC_VERSION_TEXT)),)
CFLAGS := $(filter-out -Wimplicit-fallthrough%,$(CFLAGS))
CFLAGS += -Wimplicit-fallthrough=5
endif
endif
ASANFLAGS = -fsanitize=address
ASANFLAGS += -fno-common
ASANFLAGS += -fno-omit-frame-pointer
.PHONY: test
test: tests.out
@./tests.out
.PHONY: memcheck
memcheck: ./*.c ./*.h
@echo Compiling $@
$(CC) $(ASANFLAGS) $(CFLAGS) test-framework/unity.c ./*.c -o memcheck.out $(LIBS)
@./memcheck.out
@echo "Memory check passed"
.PHONY: clean
clean:
rm -rf *.o *.out *.out.dSYM
tests.out: ./*.c ./*.h
@echo Compiling $@
$(CC) $(CFLAGS) test-framework/unity.c ./*.c -o tests.out $(LIBS)