forked from approach0/search-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodule.mk
More file actions
36 lines (28 loc) · 954 Bytes
/
module.mk
File metadata and controls
36 lines (28 loc) · 954 Bytes
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
# source files can have mixed code of C and CPP
SRC:=$(wildcard *.c) $(wildcard *.cpp)
SRC_OBJS:=$(SRC)
SRC_OBJS:=$(SRC_OBJS:.c=.o)
SRC_OBJS:=$(SRC_OBJS:.cpp=.o)
# test files / final executable files
RUN_SRC:=$(wildcard run/*.c)
RUN_OBJS:=$(RUN_SRC:.c=.o)
RUN_BINS:=$(RUN_OBJS:.o=.out)
CFLAGS := -I .
# make an archive only if SRC_OBJS is non-empty.
ifneq ($(SRC_OBJS), )
CURDIRNAME := $(notdir $(CURDIR))
ARCHIVE := lib$(CURDIRNAME).a
$(ARCHIVE): $(SRC_OBJS)
$(AR)
endif
# use object files in this module to link RUN_BINS
LDOBJS := $(SRC_OBJS)
# include dependency .mk files, e.g. dep-LDLIB.mk.
DEP_LINKS := $(wildcard dep-*.mk)
-include $(DEP_LINKS)
# strip off suffix ".mk" from DEP_LINKS
LDLIBS := $(foreach dep_link, ${DEP_LINKS}, ${dep_link:.mk=})
# further strip off leading "dep"
LDLIBS := $(foreach dep_link, ${LDLIBS}, ${dep_link:dep%=%})
# summary what a module needs to make
module := $(SRC_OBJS) $(RUN_OBJS) $(ARCHIVE) $(RUN_BINS)