forked from buschko/imca
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
276 lines (238 loc) · 8.1 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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
#-----------------------------------------------------------------------------
#
# IMCA is a analyzing tool for unbounded reachability probabilities, expected-
# time, and long-run averages for Interactive Markov Chains and Markov Automata.
# Copyright (C) RWTH Aachen, 2012
# Author: Dennis Guck
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
# Source description:
# Makefile for the Interactive Markov Chain Analyzer (IMCA)
#
# Created by Dennis Guck
#
#-----------------------------------------------------------------------------
VERSION := 1.6.beta
#-----------------------------------------------------------------------------
# Architecture
#-----------------------------------------------------------------------------
ARCH := $(shell uname -m | \
sed \
-e 's/sun../sparc/' \
-e 's/i.86/x86/' \
-e 's/i86pc/x86/' \
-e 's/[0-9]86/x86/' \
-e 's/amd64/x86_64/' \
-e 's/IP../mips/' \
-e 's/9000..../hppa/' \
-e 's/Power\ Macintosh/ppc/' \
-e 's/00........../pwr4/' )
OSTYPE := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \
sed \
-e 's/cygwin.*/cygwin/' \
-e 's/irix../irix/' \
-e 's/windows.*/windows/' \
-e 's/mingw.*/mingw/')
HOSTNAME := $(shell uname -n | tr '[:upper:]' '[:lower:]')
UNAME := $(shell uname)
#-----------------------------------------------------------------------------
# Soplex Libaries -- path to Soplex library has to be adjusted (only if option
# SOPLEX=true is active ) --
#-----------------------------------------------------------------------------
SOPLEXSRC = ~/lib/soplex-1.7.0#/Users/guckd/lib/soplex-1.7.2
SOPLEXLIB = $(SOPLEXSRC)/lib/libsoplex.a
SOPLEXINCLUDE = $(SOPLEXSRC)/src
SOPLEXLINK = $(SOPLEXSRC)/lib/libsoplex.a
SOPLEX = true
SOPLEXVAR = __SOPLEX__
#-----------------------------------------------------------------------------
# lp_solve Libaries -- path to lp_solve library has to be adjusted --
#-----------------------------------------------------------------------------
LPSOLVEINCLUDE = /opt/local/include/lpsolve
#-----------------------------------------------------------------------------
# Options
#-----------------------------------------------------------------------------
DEBUG = true
VERBOSE = false
SHARED = false
OPT = opt
STATICLIBEXT = a
SHAREDLIBEXT = so
LIBEXT = $(STATICLIBEXT)
EXEEXTENSION = #
REPOSIT = #
COMP = gnu
CXX = g++
CXX_c = -c #
CXX_o = -o #
LINKCXX = g++
LINKCXX_L = -L
LINKCXX_l = -l
LINKCXX_o = -o #
AR = ar
AR_o = #
ZLIB = -lz
GMPLIB = -lgmpxx -lgmp -lstdc++
ifeq ($(UNAME), Linux)
TIMELIB = -lrt
else
TIMELIB =
endif
SRCDIR = src
BINDIR = bin
LIBDIR = lib
INCLUDEDIR = include
LIBOBJ = read_file.o read_file_imc.o sparse.o unbounded.o expected_time.o expected_reward.o bounded_reward.o sccs.o sccs2.o long_run_average.o debug.o bounded.o long_run_reward.o
BINOBJ = main.o
NAME = imca
BASE = $(OSTYPE).$(ARCH).$(COMP).$(OPT)
BINNAME = $(NAME)-$(VERSION).$(BASE)
BINSHORTLINK = $(BINDIR)/$(NAME)$(EXEEXTENSION)
BINFILE = $(BINDIR)/$(BINNAME)
LIBNAME = $(NAME)-$(VERSION).$(BASE)
LIBFILE = $(LIBDIR)/lib$(LIBNAME).$(LIBEXT)
LIBSHORTLINK = $(LIBDIR)/lib$(NAME).$(LIBEXT)
LIBLINK = $(LIBDIR)/lib$(NAME).$(BASE).$(LIBEXT)
OBJDIR = obj/O.$(BASE)
BINOBJDIR = $(OBJDIR)/bin
LIBOBJDIR = $(OBJDIR)/lib
BINOBJFILES = $(addprefix $(BINOBJDIR)/,$(BINOBJ))
LIBOBJFILES = $(addprefix $(LIBOBJDIR)/,$(LIBOBJ))
TMPDIR = tmp
LIBBUILD = $(AR)
LIBBUILD_o = $(AR_o)
LIBBUILDFLAGS = $(ARFLAGS)
ifeq ($(DEBUG),true)
FLAGS = -g -Wall -D NDEBUG
else
FLAGS = -O2
endif
ifeq ($(SOPLEX),true)
CPPFLAGS = -I $(INCLUDEDIR) -I $(SOPLEXINCLUDE) $(ZLIB) $(GMPLIB) $(TIMELIB)
else
CPPFLAGS = -I $(INCLUDEDIR) $(ZLIB) $(GMPLIB) $(TIMELIB) -I $(LPSOLVEINCLUDE) /opt/local/lib/liblpsolve55.dylib /opt/local/lib/liblpsolve55.a
endif
CXXFLAGS =
BINOFLAGS =
LIBOFLAGS =
ifeq ($(SOPLEX),true)
LDFLAGS += -I $(INCLUDEDIR) -I $(SOPLEXINCLUDE) $(SOPLEXLIB) $(ZLIB) $(GMPLIB) $(TIMELIB)
else
LDFLAGS += -I $(INCLUDEDIR) $(ZLIB) $(GMPLIB) $(TIMELIB) -I $(LPSOLVEINCLUDE) /opt/local/lib/liblpsolve55.dylib /opt/local/lib/liblpsolve55.a
endif
ARFLAGS = cr
DFLAGS = -MM
VFLAGS = --tool=memcheck --leak-check=yes --show-reachable=yes #--gen-suppressions=yes
ifeq ($(SOPLEX),true)
INCLUDES = -I $(INCLUDEDIR) -I $(SOPLEXINCLUDE)
else
INCLUDES = -I $(INCLUDEDIR) -I $(LPSOLVEINCLUDE)
endif
LN_s = ln -s
ifeq ($(SOPLEX),true)
FLAGS += -D$(SOPLEXVAR)
endif
ifeq ($(VERBOSE),false)
.SILENT: $(LIBLINK) $(LIBSHORTLINK) $(BINLINK) $(BINSHORTLINK) $(BINFILE) $(LIBFILE) $(BINOBJFILES) $(LIBOBJFILES)
endif
all: $(TMPDIR) $(LIBFILE) $(BINFILE) $(LIBLINK) $(LIBSHORTLINK) $(BINLINK) $(BINSHORTLINK) $(SOPLEXLINK)
#-----------------------------------------------------------------------------
# SHARED Libaries
#-----------------------------------------------------------------------------
ifeq ($(SHARED),true)
CPPFLAGS += -fPIC
LIBEXT = $(SHAREDLIBEXT)
LIBBUILD = $(LINKCXX)
LIBBUILDFLAGS += -shared
LIBBUILD_o = -o # the trailing space is important
ARFLAGS =
RANLIB =
endif
CXXFLAGS += $(USRCXXFLAGS)
LDFLAGS += $(USRLDFLAGS)
ARFLAGS += $(USRARFLAGS)
DFLAGS += $(USRDFLAGS)
#-----------------------------------------------------------------------------
# Create directories
#-----------------------------------------------------------------------------
$(OBJDIR):
@-mkdir -p $(OBJDIR)
$(BINOBJDIR): $(OBJDIR)
@-mkdir -p $(BINOBJDIR)
$(LIBOBJDIR): $(OBJDIR)
@-mkdir -p $(LIBOBJDIR)
$(BINDIR):
@-mkdir -p $(BINDIR)
$(LIBDIR):
@-mkdir -p $(LIBDIR)
$(TMPDIR):
@-mkdir -p $(TMPDIR)
#-----------------------------------------------------------------------------
# making library
#-----------------------------------------------------------------------------
$(LIBLINK) $(LIBSHORTLINK): $(LIBFILE)
@rm -f $@
cd $(dir $@) && $(LN_s) $(notdir $(LIBFILE)) $(notdir $@)
$(BINLINK) $(BINSHORTLINK): $(BINFILE)
@rm -f $@
cd $(dir $@) && $(LN_s) $(notdir $(BINFILE)) $(notdir $@)
$(BINFILE): $(BINDIR) $(BINOBJDIR) $(LIBOBJFILES) $(BINOBJFILES)
@echo "-> linking $@"
$(LINKCXX) $(BINOBJFILES) $(LIBOBJFILES) \
$(LDFLAGS) $(LINKCXX_o)$@
$(LIBFILE): $(LIBDIR) $(LIBOBJDIR) $(LIBOBJFILES)
@echo "-> generating library $@"
-rm -f $(LIBFILE)
$(LIBBUILD) $(LIBBUILDFLAGS) $(LIBBUILD_o)$@ $(LIBOBJFILES) $(REPOSIT)
ifneq ($(RANLIB),)
$(RANLIB) $@
endif
#-----------------------------------------------------------------------------
# object compiling and linking
#-----------------------------------------------------------------------------
$(BINOBJDIR)/%.o: $(SRCDIR)/%.cpp
@-mkdir -p $(BINOBJDIR)
@echo "-> compiling $@"
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(BINOFLAGS) $(FLAGS) $(CXX_c)$< $(CXX_o)$@
$(LIBOBJDIR)/%.o: $(SRCDIR)/%.cpp $(INCLUDEDIR)/%.h
@-mkdir -p $(LIBOBJDIR)
@echo "-> compiling $@"
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LIBOFLAGS) $(FLAGS) $(CXX_c)$< $(CXX_o)$@
#-----------------------------------------------------------------------------
# cleaning
#-----------------------------------------------------------------------------
.PHONY: cleanbin
cleanbin: $(BINDIR)
@echo "remove binary $(BINFILE)"
@-rm -f $(BINFILE) $(BINLINK) $(BINSHORTLINK)
.PHONY: cleanlib
cleanlib: $(LIBDIR)
@echo "remove library $(LIBFILE)"
@-rm -f $(LIBFILE) $(LIBLINK) $(LIBSHORTLINK)
.PHONY: clean
clean: cleanlib cleanbin $(LIBOBJDIR) $(BINOBJDIR) $(OBJDIR)
@echo "remove objective files"
ifneq ($(LIBOBJDIR),)
@-rm -f $(LIBOBJDIR)/*.o && rmdir $(LIBOBJDIR)
endif
ifneq ($(BINOBJDIR),)
@-rm -f $(BINOBJDIR)/*.o && rmdir $(BINOBJDIR)
endif
ifneq ($(OBJDIR),)
@-rm -f $(LASTSETTINGS)
@-rmdir $(OBJDIR)
endif