-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.old
94 lines (75 loc) · 2.36 KB
/
Makefile.old
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
# list of modules to be compiled
CLIENT_MODULES := client
SERVER_MODULES := server keyregistry
# future extension: modules that are used by server and client (for example protocol definitions)
COMMON_MODULES :=
# predefined macros
PREDEFS :=
# handle make params
# app (mandatory)
# server - compiles the Key-Value Server application
# client - compiles the Key-Value Client application
#
# strict (optional)
# yes - server won't allow to update already existing keys
# anything else - update of keys are possible (default behavior)
# defines a feature switch FS_ALLOW_UPDATE
ifdef app
ifeq ($(app),server)
APPLICATION := kvp_server
ALL_MODULES := $(SERVER_MODULES) $(COMMON_MODULES)
ifneq ($(strict),yes)
PREDEFS := $(PREDEFS) -DFS_ALLOW_UPDATE
endif
else
ifeq ($(app),client)
APPLICATION := kvp_client
ALL_MODULES := $(CLIENT_MODULES) $(COMMON_MODULES)
else
$(info Invalid application ...)
$(info - app=server)
$(info - app=client)
$(error Please provide one of the make-variables on your command line.)
endif
endif
else
$(info Application has not been selected ...)
$(info - app=server)
$(info - app=client)
$(error Please provide one of the make-variables on your command line.)
endif
SRC_PATH := src
OBJ_PATH := obj
INC_PATH := inc
BUILD_PATH := .
CC := gcc
CFLAGS = -Wall \
-c \
-o $(OBJ_PATH)/$*.o \
-I$(INC_PATH) \
$(PREDEFS)
LINK_OPTS = -o $(BUILD_PATH)/$(APPLICATION)
$(OBJ_PATH)/%.o : $(SRC_PATH)/%.c
@if ! [ -d $(OBJ_PATH) ]; then mkdir $(OBJ_PATH); fi
@echo " Compiling $< ..."
@$(CC) $< $(CFLAGS)
OBJS := $(addprefix $(OBJ_PATH)/, $(addsuffix .o, $(ALL_MODULES)))
$(BUILD_PATH)/$(APPLICATION) : $(OBJS)
@echo Linking application ...
@$(CC) $(LINK_OPTS) $(OBJS)
@echo DONE
.PHONY: build
build : $(BUILD_PATH)/$(APPLICATION)
@echo Application build complete!
.PHONY: clean
clean :
@echo Cleaning application ...
@rm -f $(OBJS)
@rm -f $(BUILD_PATH)/$(APPLICATION)
.PHONY: all
all :
@$(MAKE) --no-print-directory build
.PHONY: rebuild
rebuild :
@$(MAKE) --no-print-directory clean
@$(MAKE) --no-print-directory build