-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile.modular
127 lines (106 loc) · 3.85 KB
/
Makefile.modular
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# ### ### ### ### ### ### ###
# DO NOT EDIT THIS FILE!!!
# DO NOT EDIT THIS FILE!!!
# DO NOT EDIT THIS FILE!!!
#
# The proper way is to use the makefile-manager script to generate a Makefile, using Makefile.modular as a template
# If you want to add a new project: use ./makefile-manager -h
# If you want to change the compiler (e.g. gcc, clang, ...): modify Makefile.modular
# ### ### ### ### ### ### ###
CC = g++
CCFLAGS = -Wall -O3 -std=c++11
LDFLAGS = `sdl2-config --cflags --libs`
LIBS = -lboost_serialization
RM = rm -f
MAKE = make
BUILD_PATH_DIR = "build"
BUILD_PATH = ${shell if [ -d $(BUILD_PATH_DIR) ]; then echo "$(BUILD_PATH_DIR)/"; fi;}
INCLUDE = -Iinclude/ext -Iinclude/contrib -Iinclude/core -Iprj/
SRC_C = $(wildcard src/core/*.c src/contrib/*.c src/contrib/**/*.c src/ext/*.c)
SRC_CC = $(wildcard src/core/*.cpp src/contrib/*.cpp src/contrib/**/*.cpp src/ext/*.cpp)
DIR_NAME = $(shell basename `pwd`)
DATE_TIME = `date +'%Y.%m.%d_%Hh%M'`
# if DEBUG is enabled, add -g option to CCFLAGS
ifneq ($(strip $(DEBUG)),)
CCFLAGS += -g
endif
# if MODULES is empty, compile everything
ifeq ($(strip $(MODULES)),)
MODULES := ${shell ls -1 prj | grep '/' | cut -d'/' -f 1}
endif
# Preprocessor variables associated with the modules to be compiled
MOD_VARS := -DMODULAR $(foreach m, $(MODULES), -DPRJ_${shell echo $(m) | tr [a-z] [A-Z] | sed 's/\-/\_/g'})
CCFLAGS += $(MOD_VARS)
# Update SRC_C And SRC_CC with modules files
SRC_C += $(foreach m, $(MODULES), $(wildcard prj/$(m)/src/*.c) $(wildcard prj/$(m)/src/**/*.c))
SRC_CC += $(foreach m, $(MODULES), $(wildcard prj/$(m)/src/*.cpp) $(wildcard prj/$(m)/src/**/*.cpp))
OBJ_o = $(SRC_C:.c=.o) $(SRC_CC:.cpp=.o)
# if BUILD_PATH is enabled, add <BUILD_PATH> to object files
ifneq ($(strip $(BUILD_PATH)),)
OBJ += $(foreach o, $(OBJ_o), $(BUILD_PATH)$(o))
else
OBJ = $(OBJ_o)
endif
TARGET := roborobo
.PHONY: snapshot
.IGNORE:
all: verifyMods $(TARGET)
verifyMods:
@echo "Building in: ."$(BUILD_PATH_DIR)"/"
@if [ -d $(BUILD_PATH_DIR) ]; then find -L src/ prj/ -type d -exec mkdir -p "$(BUILD_PATH){}" \; ; fi;
@for i in $(MODULES); do \
if [ ! -d prj/$$i ]; then \
echo "WARNING : Project $$i does not exist !"; \
fi; \
done
@if [ ! -d "logs" ]; then mkdir logs ; fi;
$(TARGET): $(OBJ)
ifeq ($(strip $(VERBOSE)),)
@echo "[LD] " $@
@$(CC) $(LDFLAGS) -o $@ $^ -lSDL2 -lSDL2_image $(LIBS)
else
$(CC) $(LDFLAGS) -o $@ $^ -lSDL2 -lSDL2_image $(LIBS)
endif
$(BUILD_PATH)%.o: %.cpp
ifeq ($(strip $(VERBOSE)),)
@echo "[CPP] " $<
@$(CC) -o $@ -c $< $(CCFLAGS) $(INCLUDE)
else
$(CC) -o $@ -c $< $(CCFLAGS) $(INCLUDE)
endif
$(BUILD_PATH)%.o: %.c
ifeq ($(strip $(VERBOSE)),)
@echo "[C] " $<
@$(CC) -o $@ -c $< $(CCFLAGS) $(INCLUDE)
else
$(CC) -o $@ -c $< $(CCFLAGS) $(INCLUDE)
endif
clean:
ifeq ($(strip $(VERBOSE)),)
@$(RM) $(OBJ)
else
$(RM) $(OBJ)
endif
distclean:
@$(MAKE) clean
$(RM) $(TARGET)
snapshot:
clear
@echo "Creating snapshot in current directory."
echo Now: $(DATE_TIME)
make distclean
rm -f roborobo3-snapshot*.tar
cd .. ; export COPYFILE_DISABLE=TRUE ; tar --exclude='._*' --exclude='Makefile' --exclude='perso' --exclude='.DS_Store' --exclude='datalog_*' --exclude='properties_*' --exclude='roborobo-snapshot*' --exclude='.svn' --exclude='logs/*' -cvf $(DIR_NAME)/roborobo3-snapshot-$(DATE_TIME).tar $(DIR_NAME)
@echo =-=-=-=
@echo =-=-=-=
@echo =-=-=-=
@echo Snapshot is created as roborobo-snapshot-$(DATE_TIME).tar
@echo .
@echo ALL files have been archived except:
@echo - datalog_* and properties_* files are NOT in the archive, wherever they were.
@echo - perso directory and content is NOT in the archive
@echo - .svn directories and content are NOT in the archive
@echo - note: dont forget to re-compile as a make distclean was performed prior to building the archive
@echo =-=-=-=
@echo =-=-=-=
@echo =-=-=-=