-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
executable file
·105 lines (77 loc) · 2.45 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
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
105
# GNU Makefile
# Paths
SRC_ENC = lib_enc lib_com
SRC_DEC = lib_dec lib_com
BUILD = build
SRC_DIRS = $(sort -u $(SRC_ENC) $(SRC_DEC))
# Name of CLI binaries
CLI_ENC = EVS_cod
CLI_DEC = EVS_dec
# Default tool settings
CC = gcc
RM = rm -f
# Switches for cross-platform builds (i.e. build 32 bit code on 64 bit platforms)
ifneq "$(TARGET_PLATFORM)" ""
ifeq ("$(TARGET_PLATFORM)", "$(findstring $(TARGET_PLATFORM), i386 i586 i686)")
CFLAGS += -m32
LDFLAGS += -m32
endif
ifeq ("$(TARGET_PLATFORM)", "$(findstring $(TARGET_PLATFORM), x86_64)")
CFLAGS += -m64
LDFLAGS += -m64
endif
endif
ifndef VERBOSE
QUIET_CC = @echo ' ' Compiling $<;
QUIET_LINK= @echo ' ' Linking $@;
QUIET = @
endif
# C compiler flags
CFLAGS += -pedantic -Wcast-qual -Wall -W -Wextra -Wno-long-long \
-Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes \
-Werror-implicit-function-declaration
ifeq "$(RELEASE)" "1"
CFLAGS += -DRELEASE
DELIVERY = 1
OPTIM ?= 2
endif
ifneq "$(DEBUG)" "0"
CFLAGS += -g3
LDFLAGS += -g3
endif
ifeq "$(WMOPS)" "1"
CFLAGS += -DWMOPS=1
endif
OPTIM ?= 0
CFLAGS += -O$(OPTIM)
CFLAGS += $(foreach DIR,$(SRC_DIRS),-I$(DIR))
# Source file search paths
VPATH = $(SRC_DIRS)
###############################################################################
SRCS_ENC = $(foreach DIR,$(SRC_ENC),$(patsubst $(DIR)/%,%,$(wildcard $(DIR)/*.c)))
SRCS_DEC = $(foreach DIR,$(SRC_DEC),$(patsubst $(DIR)/%,%,$(wildcard $(DIR)/*.c)))
OBJS_ENC = $(addprefix $(BUILD)/,$(SRCS_ENC:.c=.o))
OBJS_DEC = $(addprefix $(BUILD)/,$(SRCS_DEC:.c=.o))
DEPS = $(addprefix $(BUILD)/,$(SRCS_ENC:.c=.P) $(SRCS_DEC:.c=.P))
###############################################################################
.PHONY: all clean clean_all
all: $(CLI_ENC) $(CLI_DEC)
$(BUILD):
$(QUIET)mkdir -p $(BUILD)
$(CLI_ENC): $(OBJS_ENC)
$(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_ENC) -lm -o $(CLI_ENC)
$(CLI_DEC): $(OBJS_DEC)
$(QUIET_LINK)$(CC) $(LDFLAGS) $(OBJS_DEC) -lm -o $(CLI_DEC)
clean:
$(QUIET)$(RM) $(OBJS_ENC) $(OBJS_DEC) $(DEPS)
$(QUIET)$(RM) $(DEPS:.P=.d)
$(QUIET)test ! -d $(BUILD) || rm -rf $(BUILD)
clean_all: clean
$(QUIET)$(RM) $(CLI_ENC) $(CLI_DEC)
$(BUILD)/%.o : %.c | $(BUILD)
$(QUIET_CC)$(CC) $(CFLAGS) -c -MD -o $@ $<
@cp $(BUILD)/$*.d $(BUILD)/$*.P; \
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
-e '/^$$/ d' -e 's/$$/ :/' < $(BUILD)/$*.d >> $(BUILD)/$*.P; \
$(RM) $(BUILD)/$*.d
-include $(DEPS)