-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
48 lines (32 loc) · 786 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
40
41
42
43
44
45
46
47
48
NAME = sha256
# Release products.
DST_BIN = dist/$(NAME)
DST_LICENSE = dist/LICENSE
DST_README = dist/README.md
DST = $(DST_BIN) $(DST_LICENSE) $(DST_README)
SOURCES = $(wildcard src/**/*.c) $(wildcard src/*.c)
OBJECTS = $(patsubst src/%.c,build/%.o,$(SOURCES))
LIBS = $(wildcard lib/*)
LIB_LINK = $(wildcard lib/*.a) $(wildcard lib/**/*.a)
INCLUDE = $(patsubst %,-I%,$(LIBS))
all: $(DST)
run: $(DST_BIN)
$^
.SECONDEXPANSION:
$(DST_LICENSE): LICENSE
cp $< $@
$(DST_README): README.md
cp $< $@
$(DST_BIN): $(OBJECTS) $(LIB_LINK)
clang -std=c11 -o $@ $^
build/%.o: src/%.c | $$(@D)/.keep
clang -std=c11 -O2 $(INCLUDE) -MD -o $@ -c $<
.PRECIOUS: %/.keep
dist:
mkdir -p $@
%/.keep:
mkdir -p $(dir $@)
@touch $@
clean:
rm -rf $(DST) build
-include $(OBJECTS:.o=.d)