-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.rule
67 lines (54 loc) · 1.29 KB
/
Makefile.rule
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
ifeq ($(DEBUG_SYMBOLS),TRUE)
CFLAGS +=-g -Wall -Werror -O0
else
CFLAGS +=-Wall -Werror -O2
endif
ifeq ($(MAKELEVEL), 0)
all: msg
else
all: $(SRC_BIN) $(SRC_LIB)
endif
ifneq ($(SRC_BIN),)
$(SRC_BIN): $(SRC_OBJ)
$(CC) -o $@ $^ $(LDFLAGS)
endif
ifneq ($(SRC_LIB),)
$(SRC_LIB): $(SRC_OBJ)
$(AR) rcs $@ $^
endif
ifeq ($(SRC_BASE),)
BUILDDIR = $(MOD_SRC_DIR)
OBJDIR = $(MOD_SRC_DIR)
LIBDIR = $(MOD_SRC_DIR)
BINDIR = $(MOD_SRC_DIR)
else
ifeq ($(DEBUG_SYMBOLS), TRUE)
BUILDDIR = $(SRC_BASE)/build/$(PLATFORM)_dbg
else
BUILDDIR = $(SRC_BASE)/build/$(PLATFORM)
endif
OBJDIR = $(BUILDDIR)/obj/$(MODULE)
LIBDIR = $(BUILDDIR)/lib
BINDIR = $(BUILDDIR)/bin
endif
msg:
@echo "You cannot directily execute this Makefile! This Makefile should calledby toplevel Makefile."
lib: $(OBJDIR) $(LIBDIR)/$(SRC_LIB)
bin: $(OBJDIR) $(BINDIR)/$(SRC_BIN)
$(OBJDIR):
@echo "MKDIR $(notdir $@)..."
@mkdir -p $@
ifneq ($(SRC_BIN),)
$(BINDIR)/$(SRC_BIN) : $(SRC_OBJ)
$(CC) -o $@ $^ $(LDFLAGS) $(CPPFLAGS)
endif
ifneq ($(SRC_LIB),)
$(LIBDIR)/$(SRC_LIB) : $(SRC_OBJ)
$(AR) rcs $@ $^
endif
# clean target
clean:
$(RM) $(SRC_OBJ) $(SRC_LIB) $(SRC_BIN) $(SRC_BIN).exe *.swp
distclean:
$(RM) $(SRC_OBJ) $(SRC_LIB) $(SRC_BIN) $(SRC_BIN).exe $(SRC_BASE)/libs/* $(SRC_BASE)/tags *~ *.swp
.PHONY : all clean distclean