-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
58 lines (51 loc) · 1.26 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
.PHONY: daala_tools clean
.DEFAULT_GOAL := all
STATIC ?= 0
DEBUG ?= 0
QUIET ?= 1
CFLAGS=-m64 -pedantic -pedantic-errors -std=gnu99 -Werror -Wall -Wextra -Wshadow -Wpointer-arith -Wcast-qual -Wformat=2 -Wstrict-prototypes -Wmissing-prototypes
CC=gcc
TARGETS := psha256
psha256_SOURCES := src/psha256.c
psha256_LDLIBS := -lcrypto
ifeq ($(STATIC),1)
LDFLAGS += -static
endif
## debugging
ifeq ($(DEBUG),1)
CFLAGS += -Og -g
STRIP := echo -n ". Debug mode; not stripping"
else
CFLAGS += -O2
STRIP := strip
endif
## quiet build
ifeq ($(QUIET),1)
QPFX := @
else
QPFX :=
endif
export STATIC DEBUG QUIET
define GEN_TARGET_RULE
$(1): $$($(1)_SOURCES:c=o)
@echo -n "Building $$@.."
$(QPFX)$$(CC) $$(CPPFLAGS) $$(CFLAGS) $$($(1)_LDFLAGS) $$(LDFLAGS) -o $$@ $$^ $$($(1)_LDLIBS) $$(LDLIBS)
$(QPFX)$$(STRIP) $$@
@echo ". done."
endef
$(foreach targ,$(TARGETS),$(eval $(call GEN_TARGET_RULE,$(targ))))
define GEN_CLEAN_RULE
.PHONY: $(1)_clean
$(1)_clean:
$(QPFX)echo " [clean] $(1)"
$(QPFX)rm -f $$($(1)_SOURCES:c=o) $(1)
endef
$(foreach targ,$(TARGETS),$(eval $(call GEN_CLEAN_RULE,$(targ))))
%.o: %.c
$(QPFX)echo " [cc] $@"
$(QPFX)$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
all: daala_tools $(TARGETS)
daala_tools:
+make -C daala_tools
clean: $(TARGETS:=_clean)
+make -C daala_tools clean