-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
154 lines (117 loc) · 4.08 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
COMPILER=g++
COMPILER_FLAGS=-Wall -fPIC -pedantic -g
ARCHIVER=ar
ARCHIVER_FLAGS=rcs
LINKER=ld
NAME=libcity
MAJOR_VERSION=0
MINOR_VERSION=1
RELEASE=1
LINKER_NAME=$(NAME).so
SONAME=$(LINKER_NAME).$(MAJOR_VERSION)
REAL_NAME=$(SONAME).$(MINOR_VERSION).$(RELEASE)
STATIC_NAME=$(NAME).a
DESTDIR=
INCLUDEDIR=/usr/local/include
LIBDIR=/usr/local/lib
HEADERS_INSTALL_PATH=$(DESTDIR)$(INCLUDEDIR)
LIB_INSTALL_PATH=$(DESTDIR)$(LIBDIR)
HEADERS_DIR=include/
DOCUMENTATION_DIR=doc/
TESTS_EXECUTABLE=unit_tests
UNITTESTCPP_LIB=../UnitTest++/libUnitTest++.a
UNITTESTCPP_INCLUDE_DIR=../UnitTest++/src/
.PHONY: install uninstall static dynamic clean doc headers test
all: static dynamic headers
# LIB Object files and sources ##########################
# Geometry package
GEOMETRY_PACKAGE=src/geometry/line.o \
src/geometry/linesegment.o \
src/geometry/point.o \
src/geometry/vector.o \
src/geometry/polygon.o \
src/geometry/ray.o \
src/geometry/shape.o
# Streetgraph package
STREETGRAPH_PACKAGE=src/streetgraph/intersection.o \
src/streetgraph/road.o \
src/streetgraph/streetgraph.o \
src/streetgraph/path.o \
src/streetgraph/rasterroadpattern.o \
src/streetgraph/organicroadpattern.o \
src/streetgraph/areaextractor.o
# LSystem package
LSYSTEM_PACKAGE=src/lsystem/lsystem.o \
src/lsystem/graphiclsystem.o \
src/lsystem/roadlsystem.o
# Regions package
REGIONS_PACKAGE=src/area/block.o \
src/area/area.o \
src/area/zone.o \
src/area/lot.o \
src/area/subregion.o
# Entities package
ENTITIES_PACKAGE=src/entities/urbanentity.o \
src/entities/building.o
# No package
MISC=src/random.o \
src/city.o
LIB_OBJECTS=$(GEOMETRY_PACKAGE) $(STREETGRAPH_PACKAGE) $(LSYSTEM_PACKAGE) $(REGIONS_PACKAGE) $(ENTITIES_PACKAGE) $(MISC)
$(LIB_OBJECTS): %.o: %.cpp %.h
$(COMPILER) $(COMPILER_FLAGS) -c $< -o $@
# TEST Object files and sources ##########################
# Unit tests
TEST_UNITS=test/testPoint.o \
test/testVector.o \
test/testPolygon.o \
test/testLSystem.o \
test/testGraphicLSystem.o \
test/testStreetGraph.o \
test/testLine.o \
test/testLineSegment.o \
test/testRasterRoadPattern.o \
test/testRandom.o \
test/testAreaExtractor.o \
test/testPath.o \
test/testRay.o \
test/testBlock.o \
test/testLot.o \
test/testZone.o \
test/testSubRegion.o \
test/testShape.o
TEST_MAIN=test/main.o
TEST_OBJECTS=$(TEST_UNITS) $(TEST_MAIN)
$(TEST_OBJECTS): %.o: %.cpp
$(COMPILER) $(COMPILER_FLAGS) -I$(UNITTESTCPP_INCLUDE_DIR) -c $< -o $@
static: $(LIB_OBJECTS)
$(ARCHIVER) $(ARCHIVER_FLAGS) $(STATIC_NAME) $(LIB_OBJECTS)
dynamic: $(LIB_OBJECTS)
$(LINKER) -shared -soname $(SONAME) -o $(REAL_NAME) $(LIB_OBJECTS)
headers:
mkdir -p $(HEADERS_DIR)
cd src/ && find . -name "*.h" -exec rsync -R {} ../$(HEADERS_DIR) \; >/dev/null
install: dynamic headers
install -p -d $(HEADERS_INSTALL_PATH)/libcity/
cp -rp include/* $(HEADERS_INSTALL_PATH)/libcity
install -p libcity.h -D $(HEADERS_INSTALL_PATH)/libcity.h
install -m644 -p -s $(REAL_NAME) -D $(LIB_INSTALL_PATH)/$(REAL_NAME)
ln -sf $(REAL_NAME) $(LIB_INSTALL_PATH)/$(LINKER_NAME)
ln -sf $(REAL_NAME) $(LIB_INSTALL_PATH)/$(SONAME)
uninstall:
rm -rf $(HEADERS_INSTALL_PATH)/libcity
rm -f $(HEADERS_INSTALL_PATH)/libcity.h
rm -f $(LIB_INSTALL_PATH)/$(REAL_NAME)
rm -f $(LIB_INSTALL_PATH)/$(LINKER_NAME)
rm -f $(LIB_INSTALL_PATH)/$(SONAME)
test: $(TEST_OBJECTS) static
$(COMPILER) $(COMPILER_FLAGS) -I$(UNITTESTCPP_INCLUDE_DIR) -o $(TESTS_EXECUTABLE) $(TEST_OBJECTS) $(UNITTESTCPP_LIB) libcity.a
./$(TESTS_EXECUTABLE)
doc:
rm -rf doc/
doxygen Doxyfile
clean:
rm -rf *.o *.so* *.a *~
rm -rf $(DOCUMENTATION_DIR)
rm -rf $(HEADERS_DIR)
rm -f $(LIB_OBJECTS)
rm -f $(TEST_OBJECTS)