-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
104 lines (90 loc) · 2.09 KB
/
Makefile
File metadata and controls
104 lines (90 loc) · 2.09 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
##############
# parameters #
##############
# should we show commands executed ?
DO_MKDBG:=0
# folder where the sources are...
SRCDIR:=src
# name of the library to create
LIBNAME:=fastlog
# compiler to use...
CC:=gcc
# basic flags to use
BASE_FLAGS:=-O2 -fpic -Wall -Werror -std=gnu99 -Wno-dangling-pointer
# do you want debugging enabled?
DO_DEBUG:=0
# do you want dependency on the Makefile itself ?
DO_ALLDEP:=1
########
# code #
########
# where is the output folder ?
OUT:=out
LIB:=$(OUT)/lib/lib$(LIBNAME).so
SRC:=$(shell find $(SRCDIR) -type f -and -name "*.c")
OBJ:=$(addprefix $(OUT)/obj/, $(addsuffix .o,$(basename $(SRC))))
CFLAGS:=$(BASE_FLAGS) -I$(SRCDIR) -Itest
LDFLAGS:=-shared -fpic
BIN:=$(OUT)/bin/fastlog_test_speed $(OUT)/bin/fastlog_test_basic $(OUT)/bin/fastlog_test_crash
BINLD:=-L$(OUT)/lib -l$(LIBNAME) -lpthread
# what is the stamp file for the tools?
ALL:=
ifeq ($(DO_MKDBG),1)
Q=
# we are not silent in this branch
else # DO_MKDBG
Q=@
#.SILENT:
endif # DO_MKDBG
ifeq ($(DO_DEBUG),1)
BASE_FLAGS:=$(BASE_FLAGS) -g2
endif # DO_DEBUG
ALL+=$(LIB) $(BIN)
#########
# rules #
#########
.PHONY: all
all: $(ALL)
@true
# binaries and libraries
$(LIB): $(OBJ)
$(info doing [$@])
$(Q)mkdir -p $(dir $@)
$(Q)$(CC) $(LDFLAGS) -o $@ $(OBJ)
.PHONY: debug
debug:
$(info SRC is $(SRC))
$(info OBJ is $(OBJ))
.PHONY: clean
clean:
$(info doing [$@])
$(Q)rm -f $(OBJ) $(LIB) $(BIN)
.PHONY: clean_hard
clean_hard:
$(info doing [$@])
$(Q)git clean -qffxd
.PHONY: run
run: $(BIN)
$(info doing [$@])
$(Q)export LD_LIBRARY_PATH=$(OUT)/lib ; ./$(OUT)/bin/fastlog_test_speed
.PHONY: run_debug
run_debug: $(BIN)
$(info doing [$@])
$(Q)export LD_LIBRARY_PATH=$(OUT)/lib ; gdb ./$(OUT)/bin/fastlog_test_speed
############
# patterns #
############
$(OBJ): $(OUT)/obj/%.o: %.c
$(info doing [$@])
$(Q)mkdir -p $(dir $@)
$(Q)$(CC) -c $(CFLAGS) -o $@ $<
$(BIN): $(OUT)/bin/%: test/%.c $(LIB)
$(info doing [$@])
$(Q)mkdir -p $(dir $@)
$(Q)$(CC) $(CFLAGS) -o $@ $< $(BINLD)
##########
# alldep #
##########
ifeq ($(DO_ALLDEP),1)
.EXTRA_PREREQS+=$(foreach mk, ${MAKEFILE_LIST},$(abspath ${mk}))
endif # DO_ALLDEP