-
Notifications
You must be signed in to change notification settings - Fork 41
/
Makefile
75 lines (61 loc) · 1.43 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
CC?=gcc
CXX?=g
STDC=-std=gnu11
OPTS?=-g
LEVEL?=$(OPTS)
ifeq ($(OS),Windows_NT)
CFLAGS = -DWIN32
else
OSDEF := $(shell uname -s)
ifeq ($(OSDEF),Linux)
LDFLAGS = -pthread -ldl -lm
endif
ifeq ($(OSDEF),OpenBSD)
STDC=-std=c11
CC=clang
CXX=clang
LDFLAGS = -pthread -lm
endif
ifeq ($(OSDEF),FreeBSD)
STDC=-std=c11
CC=clang
CXX=clang
LDFLAGS =-pthread -lm
endif
ifneq ($(OSDEF),Darwin)
ifneq ($(CC),tcc)
LDFLAGS = -latomic
endif
endif
endif
WARNS = -Wall -Wextra -Werror -Wno-missing-field-initializers -Wno-unused-value -Wno-unused-function -Wno-missing-braces -Wno-ignored-qualifiers
CFLAGS = $(LEVEL) $(STDC) -Icode $(WARNS)
CXXFLAGS = $(LEVEL) -std=c 11 -Icode $(WARNS)
EXAMPLES = $(patsubst %.c,%,$(wildcard code/apps/examples/*.c))
EXAMPLES = $(patsubst %.cc,%,$(wildcard code/apps/examples/*.cc))
BUILD_FILES = $(wildcard build/*)
.PHONY: all clean examples test app embed
all: examples test
test: code/tests/tester
@echo '> Building unit tests'
build/tester
examples: $(EXAMPLES)
@echo '> Building examples'
app: code/apps/examples/$(NAME)
@echo '=> Building $(NAME)'
clean:
ifneq ($(BUILD_FILES),)
@echo '> Cleaning up files'
@rm -r $(BUILD_FILES)
endif
% : %.c
@mkdir -p build
@echo '=> Building $(@F)'
$(CC) -g $(CFLAGS) $^ $(LDFLAGS) -o build/$(@F)
% : %.cc
@mkdir -p build
@echo '=> Building $(@F)'
$(CXX) -g $(CXXFLAGS) $^ $(LDFLAGS) -o build/$(@F)
.SILENT:
embed:
./misc/embed.sh