-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
61 lines (40 loc) · 1.06 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
CFLAGS += -Wall -Werror -fPIC -D_GNU_SOURCE -L. -Iinclude -g -Wsparse-all \
-Wsparse-error -Wno-sizeof-bool -Wno-transparent-union -D_Float128="double"
ifndef LD_LIBRARY_PATH
include env.sh
endif
CLEAN = @find . -name "$(1)" -exec rm -f {} \;
CC = cgcc
LIB := libcryptopals.so
$(LIB)_LIBS := crypto
cflags = $(CFLAGS) $($(1)_CFLAGS) $($(1)_LIBS:%=-l%)
default: all
OBJ := $(foreach o, $(wildcard set*/ch*.c),$(subst .c,.out,$(o)))
LIB_OBJS :=
define get-set-lib
lib =
include $(1)/Makefile
endef # get-set-lib
define add-set-lib
$(eval $(call get-set-lib,$(1)))
LIB_OBJS += $(foreach o,$(lib),$(1)/$(o))
endef # add-set-lib
$(eval $(foreach s,$(wildcard set*),$(call add-set-lib,$(s))))
%.o: %.c
$(CC) -c $< -o $@ $(call cflags,$@)
%.out: %.o
$(CC) $< -o $@ $(call cflags,$@) -lcryptopals
ifeq ($(wildcard $(LIB)),)
$(OBJ): $(LIB)
endif
$(LIB): $(LIB_OBJS)
$(CC) $^ -o $@ -shared $(call cflags,$@)
lib: $(LIB)
all: lib $(OBJ)
clean: clean-obj clean-backup
clean-obj:
$(call CLEAN,*.o)
$(call CLEAN,*.out)
$(call CLEAN,*.so)
clean-backup:
$(call CLEAN,*~)