-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
42 lines (31 loc) · 872 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
CFLAGS = -Wextra -Wall -D_GNU_SOURCE -g -MMD -Iinclude -Ilinenoise \
-Ielfutils/libdw -Ielfutils/libelf
LDFLAGS = -Wl,-rpath="$(CURDIR)" -L. -ldw
CURDIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
OUT ?= build
LIBDW = libdw.so
BINARY = $(OUT)/raid
SHELL_HACK := $(shell mkdir -p $(OUT))
GIT_HOOKS := .git/hooks/applied
CSRCS = $(shell find ./src -name '*.c')
CSRCS += $(shell find ./linenoise -name 'linenoise.c')
_COBJ = $(notdir $(CSRCS))
COBJ = $(_COBJ:%.c=$(OUT)/%.o)
vpath %.c $(sort $(dir $(CSRCS)))
all: $(GIT_HOOKS) $(BINARY) $(LIBDW)
$(GIT_HOOKS):
@scripts/install-git-hooks
@echo
$(LIBDW):
@scripts/install-libdw.sh
$(OUT)/%.o: %.c
$(CC) -c $(CFLAGS) $< -o $@
$(BINARY): $(COBJ) $(LIBDW)
$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS)
run: $(BINARY)
$(BINARY) bin/hello
clean:
$(RM) $(COBJ)
$(RM) $(BINARY)
$(RM) $(OUT)/*.d
-include $(OUT)/*.d