-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathMakefile
50 lines (35 loc) · 1.28 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
CC=gcc
AR=ar
BIN=./bin/bitfiend
LIB=./lib/libbf.a
########## LIBBF ###############################################################
libbf: CFLAGS=-std=gnu99 -g
libbf: DEFS=-D_FILE_OFFSET_BITS=64 -D__USE_BSD -D_GNU_SOURCE
LIBBF_SRCS=$(wildcard ./src/libbf/*.c)
LIBBF_OBJS=$(LIBBF_SRCS:./src/%.c=./obj/%.o)
LIBBF_DEPS=$(LIBBF_OBJS:%.o=%.d)
./obj/libbf/%.o: ./src/libbf/%.c
@mkdir -p ./obj/libbf
$(CC) -MT $@ -MMD -MP -MF ./obj/libbf/$*.d $(CFLAGS) $(DEFS) -c $< -o $@
libbf: $(LIBBF_OBJS)
@mkdir -p ./lib
$(AR) rcs $(LIB) $(LIBBF_OBJS)
-include $(LIBBF_DEPS)
########## CLI #################################################################
bfcli: CFLAGS=-std=gnu99 -pthread -g
bfcli: LDFLAGS=-L./lib -lbf -lm -lrt
bfcli: INCLUDE=-I./src/
BFCLI_SRCS=$(wildcard ./src/ui/cli/*.c)
BFCLI_OBJS=$(BFCLI_SRCS:./src/%.c=./obj/%.o)
BFCLI_DEPS=$(BFCLI_OBJS:%.o=%.d)
./obj/ui/cli/%.o: ./src/ui/cli/%.c
@mkdir -p ./obj/ui/cli
$(CC) -MT $@ -MMD -MP -MF ./obj/ui/cli/$*.d $(INCLUDE) $(CFLAGS) -c $< -o $@
bfcli: $(BFCLI_OBJS) libbf
@mkdir -p ./bin
$(CC) $(CFLAGS) $(BFCLI_OBJS) -o $(BIN) $(LDFLAGS)
-include $(BFCLI_DEPS)
################################################################################
.PHONY: clean
clean:
@rm -f $(LIBBF_OBJS) $(LIBBF_DEPS) $(BFCLI_OBJS) $(BFCLI_DEPS) $(BIN) $(LIB)