-
Notifications
You must be signed in to change notification settings - Fork 49
/
Makefile
181 lines (158 loc) · 5.02 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
CC ?= gcc
CXX ?= g++
LINK ?= $(CXX)
RM=rm -rf
CP=cp -rf
MKDIR=mkdir -p
ROOT_DIR=$(shell pwd)
# Option to enable AddressSanitizer
ASAN ?= OFF
# Statically link dependencies as much as possible
STATIC ?= OFF
# Option to switch between Debug and Release builds
BUILD_TYPE ?= Release
detected_OS ?= $(shell uname -s)
ifeq ($(detected_OS),Darwin)
BUILD_DIR := build/mac
INSTALL_DIR := install/mac
CMAKE_TARGET=-DCMAKE_SYSTEM_NAME=$(detected_OS)
FEXT=.dylib
CMAKE_FPIC=-DCMAKE_C_FLAGS="-fPIC"
else ifeq (MINGW32,$(findstring MINGW32,$(detected_OS)))
BUILD_DIR := build/mingw
INSTALL_DIR := install/mingw
CMAKE_TARGET=-G "MSYS Makefiles"
FEXT=.dll
EEXT=.exe
ifeq (clang,$(findstring clang,$(CC)))
DISABLE_SHARED = --disable-shared
endif
else ifeq (MINGW,$(findstring MINGW,$(detected_OS)))
BUILD_DIR := build/mingw
INSTALL_DIR := install/mingw
CMAKE_TARGET=-G "MSYS Makefiles"
FEXT=.dll
EEXT=.exe
ifeq (clang,$(findstring clang,$(CC)))
DISABLE_SHARED = --disable-shared
endif
else
BUILD_DIR := build/linux
INSTALL_DIR := install/linux
CMAKE_TARGET=-DCMAKE_SYSTEM_NAME=$(detected_OS)
FEXT=.so
CMAKE_FPIC=-DCMAKE_C_FLAGS="-fPIC"
endif
ifeq ($(STATIC),ON)
# Do not use -DBoost_USE_STATIC_LIBS=ON; it messes up -static in alpine/musl
CMAKE_STATIC=-DBUILD_SHARED=OFF
endif
# use cmake from above if is set, otherwise cmake
ifeq ($(CMAKE),)
CMAKE=cmake
endif
# Should we install everything into the OMBUILDDIR?
ifeq ($(OMBUILDDIR),)
TOP_INSTALL_DIR=$(INSTALL_DIR)
CMAKE_INSTALL_PREFIX=-DCMAKE_INSTALL_PREFIX=$(TOP_INSTALL_DIR)
HOST_SHORT=
else
TOP_INSTALL_DIR=$(OMBUILDDIR)
CMAKE_INSTALL_PREFIX=-DCMAKE_INSTALL_PREFIX=$(OMBUILDDIR)
ifeq ($(host_short),)
HOST_SHORT=-DHOST_SHORT=
else
HOST_SHORT_OMC=$(host_short)/omc
HOST_SHORT=-DHOST_SHORT=$(HOST_SHORT_OMC)
endif
endif
ifeq ($(detected_OS),Darwin)
EXTRA_CMAKE=-DCMAKE_MACOSX_RPATH=ON -DCMAKE_INSTALL_RPATH="`pwd`/$(TOP_INSTALL_DIR)/lib/$(HOST_SHORT_OMC)"
endif
ifneq ($(CROSS_TRIPLE),)
CROSS_TRIPLE_DASH = $(CROSS_TRIPLE)-
HOST_CROSS_TRIPLE = "--host=$(CROSS_TRIPLE)"
AR ?= $(CROSS_TRIPLE)-ar
RANLIB ?= $(CROSS_TRIPLE)-ranlib
ifeq (MINGW,$(findstring MINGW,$(detected_OS)))
CMAKE_TARGET=-G "Unix Makefiles" -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_RC_COMPILER=$(CROSS_TRIPLE)-windres
endif
ifeq ($(detected_OS),Darwin)
EXTRA_CMAKE+=-DCMAKE_INSTALL_NAME_TOOL=$(CROSS_TRIPLE)-install_name_tool
endif
DISABLE_RUN_OMSIMULATOR_VERSION ?= 1
endif
.PHONY: OMSimulator OMSimulatorCore config-OMSimulator config-xerces config-3rdParty distclean testsuite doc doc-html doc-doxygen pip
OMSimulator:
@echo OS: $(detected_OS)
@echo "# make OMSimulator"
@echo
@$(MAKE) OMSimulatorCore
test ! -z "$(DISABLE_RUN_OMSIMULATOR_VERSION)" || $(TOP_INSTALL_DIR)/bin/OMSimulator --version
OMSimulatorCore:
@echo
@echo "# make OMSimulatorCore"
@echo
@$(MAKE) -C $(BUILD_DIR) install
pip:
@echo
@echo "# make pip"
@echo
cd src/pip/install/ && python3 setup.py sdist
@echo
@echo "# All local packages:"
@ls src/pip/install/dist/ -Art
@echo
@echo "# Run the following command to upload the package"
@echo "> twine upload src/pip/install/dist/$(shell ls src/pip/install/dist/ -Art | tail -n 1)"
3rdParty/README.md:
@echo "Please checkout the 3rdParty submodule, e.g. using \"git submodule update --init 3rdParty\", and try again."
@false
config-3rdParty: 3rdParty/README.md
config-OMSimulator: $(BUILD_DIR)/Makefile
$(BUILD_DIR)/Makefile: CMakeLists.txt
@echo
@echo "# config OMSimulator"
@echo
$(MKDIR) $(BUILD_DIR)
$(CMAKE) -S . -B $(BUILD_DIR) $(CMAKE_TARGET) -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DASAN:BOOL=$(ASAN) -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) $(CMAKE_INSTALL_PREFIX) $(HOST_SHORT) $(EXTRA_CMAKE) $(CMAKE_STATIC)
config-xerces: 3rdParty/xerces/$(INSTALL_DIR)/lib/libxerces-c.a
3rdParty/xerces/$(INSTALL_DIR)/lib/libxerces-c.a: 3rdParty/xerces/$(BUILD_DIR)/Makefile
$(MAKE) -C 3rdParty/xerces/$(BUILD_DIR)/ install
3rdParty/xerces/$(BUILD_DIR)/Makefile: 3rdParty/xerces/CMakeLists.txt
@echo
@echo "# config xerces"
@echo
$(MKDIR) 3rdParty/xerces/$(BUILD_DIR)
cd 3rdParty/xerces/$(BUILD_DIR) && $(CMAKE) $(CMAKE_TARGET) ../.. -DCMAKE_INSTALL_PREFIX=../../$(INSTALL_DIR) -DBUILD_SHARED_LIBS:BOOL=OFF
distclean:
@echo
@echo "# make distclean"
@echo
$(RM) $(BUILD_DIR)
$(RM) $(INSTALL_DIR)
$(RM) 3rdParty/xerces/$(BUILD_DIR)
$(RM) 3rdParty/xerces/$(INSTALL_DIR)
testsuite:
@echo
@echo "# run testsuite"
@echo
@$(MAKE) -C testsuite all
doc:
@$(MAKE) -C doc/UsersGuide latexpdf
@$(MKDIR) $(INSTALL_DIR)/doc
@cp doc/UsersGuide/build/latex/OMSimulator.pdf $(INSTALL_DIR)/doc
doc-html:
@$(MAKE) -C doc/UsersGuide html
@$(MKDIR) $(INSTALL_DIR)/doc
@$(RM) $(INSTALL_DIR)/doc/html
@$(CP) doc/UsersGuide/build/html/ $(INSTALL_DIR)/doc/html
doc-doxygen:
@$(RM) $(INSTALL_DIR)/doc/OMSimulatorLib
@$(MKDIR) $(INSTALL_DIR)/doc/OMSimulatorLib
@$(MAKE) -C doc/dev/OMSimulatorLib doc-doxygen
@$(CP) doc/dev/OMSimulatorLib/html/* $(INSTALL_DIR)/doc/OMSimulatorLib/
@$(MAKE) -C doc/dev/OMSimulatorLib clean
gitclean:
git submodule foreach --recursive 'git clean -fdx'
git clean -fdx -e .project