-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
131 lines (101 loc) · 4.03 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#****************************************************************************
# Debug and Profile
#****************************************************************************
DEBUG := NO
PROFILE := NO
#****************************************************************************
CC := gcc
CXX := g++
LD := g++
AR := ar rc
RANLIB := ranlib
DEBUG_CFLAGS := -Wall -Wno-format -g -DDEBUG
RELEASE_CFLAGS := -Wall -Wno-unknown-pragmas -Wno-format -O3
LIBS := -Llib/GA/ga
DEBUG_CXXFLAGS := $(DEBUG_CFLAGS)
RELEASE_CXXFLAGS := $(RELEASE_CFLAGS)
DEBUG_LDFLAGS := -g
RELEASE_LDFLAGS :=
ifeq (YES, $(DEBUG))
CFLAGS := $(DEBUG_CFLAGS)
CXXFLAGS := $(DEBUG_CXXFLAGS)
LDFLAGS := $(DEBUG_LDFLAGS)
else
CFLAGS := $(RELEASE_CFLAGS)
CXXFLAGS := $(RELEASE_CXXFLAGS)
LDFLAGS := $(RELEASE_LDFLAGS)
endif
ifeq (YES, $(PROFILE))
CFLAGS := $(CFLAGS) -pg -O3
CXXFLAGS := $(CXXFLAGS) -pg -O3
LDFLAGS := $(LDFLAGS) -pg
endif
#****************************************************************************
# Preprocessor directives
#****************************************************************************
DEFS := -DTIXML_USE_STL
#****************************************************************************
# Include paths
#****************************************************************************
INCS := -Ilib -Ilib/GA
EXTRA_LIBS := -lga
#****************************************************************************
# Makefile code common to all platforms
#****************************************************************************
CFLAGS := $(CFLAGS) $(DEFS)
CXXFLAGS := $(CXXFLAGS) $(DEFS)
#****************************************************************************
# Source files
#****************************************************************************
SRC_DIR := src/
SRCS := $(wildcard $(SRC_DIR)*.cpp) \
$(wildcard lib/ACO/src/*.cpp) \
$(wildcard lib/ABC/src/*.cpp) \
$(wildcard lib/newton/*.cpp) \
$(filter-out %xmltest.cpp, $(wildcard lib/tinyxml/*.cpp))
OBJS := $(patsubst %.cpp, %.o, $(patsubst %.c, %.o, $(SRCS)))
#****************************************************************************
# Targets of the build
#****************************************************************************
OUTPUT := energy
all: $(OUTPUT)
GA:
$(MAKE) -C lib/GA/ga DEBUG=$(DEBUG) PROFILE=$(PROFILE)
FOR_LISTING_FILES = $(wildcard $(SRC_DIR)*.h) $(wildcard $(SRC_DIR)*.cpp)
listing.txt: $(FOR_LISTING_FILES)
echo "" > $@
for file in $(FOR_LISTING_FILES); \
do \
echo "/* File $$file */\n" >> $@; \
cat $$file >> $@ ; \
done
#****************************************************************************
# Output
#****************************************************************************
$(OUTPUT): $(OBJS) GA
$(LD) -o $@ $(LDFLAGS) $(OBJS) $(LIBS) $(EXTRA_LIBS)
#****************************************************************************
# Common rules
#****************************************************************************
# Rules for compiling source files to object files
# For C++
%.o : %.cpp
$(CXX) -c $(CXXFLAGS) $(INCS) $< -o $@
# For C
%.o : %.c
$(CC) -c $(CFLAGS) $(INCS) $< -o $@
clean:
-rm -f $(OBJS) $(OUTPUT)
#****************************************************************************
# Dependencies
#****************************************************************************
$(SRC_DIR)energy.o: $(SRC_DIR)EnergyAlgorithmBee.h
$(SRC_DIR)EnergyAlgorithmBee.h: $(SRC_DIR)EnergyAlgorithm.h
$(SRC_DIR)EnergyAlgorithm.h: $(SRC_DIR)EnergyBus.h $(SRC_DIR)EnergyBusSet.h $(SRC_DIR)EnergyLine.h $(SRC_DIR)EnergyLineSet.h
$(SRC_DIR)EnergyAlgorithm.o: $(SRC_DIR)EnergyAlgorithm.h
$(SRC_DIR)EnergyBus.o: $(SRC_DIR)EnergyBus.h
$(SRC_DIR)EnergyBusSet.o: $(SRC_DIR)EnergyBusSet.h
$(SRC_DIR)EnergyBusSet.h: $(SRC_DIR)EnergyBus.h
$(SRC_DIR)EnergyLine.o: $(SRC_DIR)EnergyLine.h
$(SRC_DIR)EnergyLineSet.o: $(SRC_DIR)EnergyLineSet.h
$(SRC_DIR)EnergyLineSet.h: $(SRC_DIR)EnergyLine.h