-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
39 lines (30 loc) · 836 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
.PHONY : none clean cxxcheck entities
.DEFAULT_GOAL := none
SOURCES := entities.c
OBJECTS := $(SOURCES:%.c=%.o)
TESTS := $(SOURCES:%.c=t-%)
GARBAGE := $(OBJECTS) $(TESTS)
CLANG := clang -std=c99 -Werror -Weverything
CLANGXX := clang++ -std=c++98 -Werror -Weverything -xc++
GCC := gcc -std=c99 -pedantic -Werror -Wall -Wextra
CFLAGS := -O3 -ggdb3
NOWARN :=
CHECK_SYNTAX = $(CLANG) -fsyntax-only $(NOWARN:%=-Wno-%) $<
COMPILE = $(GCC) -c $(CFLAGS) -o $@ $<
BUILD = $(GCC) $(CFLAGS) -o $@ $^
CLEAN = rm -f $(GARBAGE)
CXXCHECK = $(CLANGXX) -fsyntax-only $(NOWARN:%=-Wno-%) $(SOURCES)
RUN = @set -e; for BIN in $^; do echo ./$$BIN; ./$$BIN; done
none :
clean :
$(CLEAN)
cxxcheck :
$(CXXCHECK)
entities : % : t-%
$(RUN)
$(TESTS) : t-% : t-%.c %.o
$(CHECK_SYNTAX)
$(BUILD)
$(OBJECTS) : %.o : %.c %.h
$(CHECK_SYNTAX)
$(COMPILE)