forked from modelica-3rdparty/ExternalMedia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile-linux
executable file
·247 lines (207 loc) · 8.61 KB
/
makefile-linux
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
# ============================================================================
# Name : Makefile
# Author : Jorrit Wronski (jowr@mek.dtu.dk)
# Version : 1.0
# Copyright : Use and modify at your own risk.
# Description : Makefile for ExternalMedia and CoolProp
# ============================================================================
# The installation procedure should be as follows:
# 1) make header library
# 2) make install
# ============================================================================
#
###########################################################
# Setting the directories for library, header and
# binary files created in this makefile, change these
# variables to install the library for Dymola or OpenModelica
###########################################################
SRCDIR :=./Sources
# For Dymola integration
# DYMDIR =/opt/dymola
# LIBINST =$(DYMDIR)/bin/lib
# HEADINST =$(DYMDIR)/source
# For OpenModelica integration
# LIBINST =/usr/lib/omc
# HEADINST =/usr/include/omc
# For system-wide installation
# LIBINST =/usr/local/lib
# HEADINST =/usr/local/include
# For relative path installation
LIBINST ="../Modelica/ExternalMedia $(FULLVERSION)/Resources/Library/linux32"
HEADINST ="../Modelica/ExternalMedia $(FULLVERSION)/Resources/Include"
#
BINDIR :=./build/LinuxGCC
# ============================================================================
# ============ No customisation is necessary beyond this point ===============
# ============================================================================
# general commands:
RM := rm -f
CP := cp
CD := cd
CH := chmod 0644
MK := mkdir -p
LD := ldconfig
LN := ln -sf
LT := libtool
AR := ar rvs
SVN := svn
# Emulate Gnu make utilities
lc = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,$(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,$(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$1))))))))))))))))))))))))))
USERNAME :=$(shell whoami)
# used for the output
MAJORVERSION :=3
MINORVERSION :=2
FULLVERSION :=$(MAJORVERSION).$(MINORVERSION).1
THENAME :=ExternalMediaLib
LIBRARYEXTENSION :=.a
THETEST :=ExternalMediaLibTest
COOLPROPDIR :=../externals/coolprop/trunk/CoolProp
LIBS =
OPTFLAGS =-O2 -funroll-loops -ffast-math #-loleaut32 #-DCOOLPROP=1 # optimisation, remove for debugging
###########################################################
# Change these lines if you are using a different C++
# compiler or if you would like to use other flags.
###########################################################
CPPC =g++
DEBUGFLAGS =-g -O3
CPPFLAGS =$(OPTFLAGS)# -Wall -pedantic -fbounds-check -ansi -Wpadded -Wpacked -malign-double -mpreferred-stack-boundary=8
.PHONY : install
LIBFILE :=$(THENAME)
LIBRARY :=lib$(THENAME)
#HEADERFILE =$(THENAME)
HEADERFILE :=$(call lc,$(THENAME))
HEADEREXTENSION :=.h
###########################################################
# Change these lines if you have other needs regarding
# the generated shared library file.
###########################################################
ifeq ($(LIBRARYEXTENSION),.so)
install : install_dynamic
LIBFLAGS =-rdynamic -fPIC -shared -Wl,-soname,$(LIBRARY)$(LIBRARYEXTENSION).$(MAJORVERSION)
endif
###########################################################
# Change these lines if you have other needs regarding
# the generated static library file.
###########################################################
ifeq ($(LIBRARYEXTENSION),.a)
install : install_static
LIBFLAGS =-fPIC -static
endif
###########################################################
# Copy files to places recognised by the system.
###########################################################
.PHONY : install_dynamic
install_dynamic : header library
$(MK) $(HEADINST) $(LIBINST)
$(CP) $(BINDIR)/$(HEADERFILE)$(HEADEREXTENSION) $(HEADINST)/$(HEADERFILE)$(HEADEREXTENSION)
$(CP) $(BINDIR)/$(LIBRARY).so $(LIBINST)/$(LIBRARY).so.$(MAJORVERSION).$(MINORVERSION)
$(CH) $(HEADINST)/$(HEADERFILE)$(HEADEREXTENSION)
$(CH) $(LIBINST)/$(LIBRARY).so.$(MAJORVERSION).$(MINORVERSION)
ifeq ($(USERNAME),root)
$(LD) -l $(LIBINST)/$(LIBRARY).so.$(MAJORVERSION).$(MINORVERSION)
endif
$(LN) $(LIBINST)/$(LIBRARY).so.$(MAJORVERSION) $(LIBINST)/$(LIBRARY).so
ifeq ($(USERNAME),root)
$(LD)
endif
.PHONY : install_static
install_static : header library
$(MK) $(HEADINST) $(LIBINST)
$(CP) $(BINDIR)/$(HEADERFILE)$(HEADEREXTENSION) $(HEADINST)/$(HEADERFILE)$(HEADEREXTENSION)
$(CP) $(BINDIR)/$(LIBRARY).a $(LIBINST)/$(LIBRARY).a
$(CH) $(HEADINST)/$(HEADERFILE)$(HEADEREXTENSION)
$(CH) $(LIBINST)/$(LIBRARY).a
ifeq ($(USERNAME),root)
$(LD)
endif
.PHONY : uninstall
uninstall :
$(RM) $(HEADINST)/$(HEADERFILE)$(HEADEREXTENSION)
$(RM) $(LIBINST)/$(LIBRARY)$(LIBRARYEXTENSION)
.PHONY : all
all : header library
############################################################
## Compile sources to static files
############################################################
EXMECPP_FILES := $(wildcard $(SRCDIR)/*.cpp)
EXMEOBJ_FILES := $(addprefix $(BINDIR)/,$(notdir $(EXMECPP_FILES:.cpp=.o)))
# Files do not change here, := assignments work.
USE_FLUIDPROP := $(shell grep FLUIDPROP $(SRCDIR)/include.h | head -n 1 | cut -d " " -f3)
USE_FLUIDPROP := 0
USE_COOLPROP := $(shell grep COOLPROP $(SRCDIR)/include.h | head -n 1 | cut -d " " -f3)
ifeq ($(USE_FLUIDPROP),1)
else
# Remove the FluidProp files, they are not available for Linux
EXMEOBJ_FILES := $(filter-out $(BINDIR)/FluidProp_IF.o, $(EXMEOBJ_FILES))
EXMEOBJ_FILES := $(filter-out $(BINDIR)/fluidpropsolver.o, $(EXMEOBJ_FILES))
endif
ifeq ($(USE_COOLPROP),1)
COOLCPP_FILES := $(wildcard $(COOLPROPDIR)/*.cpp)
COOLOBJ_FILES := $(addprefix $(BINDIR)/,$(notdir $(COOLCPP_FILES:.cpp=.o)))
else
COOLCPP_FILES :=
COOLOBJ_FILES :=
EXMEOBJ_FILES := $(filter-out $(BINDIR)/coolpropsolver.o, $(EXMEOBJ_FILES))
endif
# Define search path for prerequisite files and g++ include
# parameters to be used later.
INC_LIST:=# 0
INC_LIST+=$(COOLPROPDIR) # 1
INC_LIST+=$(COOLPROPDIR)/purefluids # 2
INC_LIST+=$(COOLPROPDIR)/pseudopurefluids # 3
INC_LIST+=$(SRCDIR) # 4
CPPINCLUDES:=$(foreach i,$(INC_LIST), -I$(i))
VPAINCLUDES:=$(foreach i,$(INC_LIST),$(i):)
vpath %.cpp $(VPAINCLUDES)
##########################################################
# Compile the C++ sources into a library file that can
# be used as shared or static object.
###########################################################
.PHONY : header
header : $(BINDIR)/$(HEADERFILE)$(HEADEREXTENSION)
$(BINDIR)/$(HEADERFILE)$(HEADEREXTENSION): $(SRCDIR)/$(HEADERFILE)$(HEADEREXTENSION)
$(MK) $(BINDIR)
$(CP) $(SRCDIR)/$(HEADERFILE)$(HEADEREXTENSION) $(BINDIR)
.PHONY : library
library : $(COOLOBJ_FILES) $(BINDIR)/$(LIBRARY)$(LIBRARYEXTENSION)
$(BINDIR)/$(LIBRARY).so: $(COOLOBJ_FILES) $(EXMEOBJ_FILES) #$(SRCDIR)/$(LIBFILE).o
$(MK) $(BINDIR)
$(CPPC) $(LIBFLAGS) $(CPPFLAGS) -o $(BINDIR)/$(LIBRARY).so $(EXMEOBJ_FILES) #$(SRCDIR)/$(LIBFILE).o
$(BINDIR)/$(LIBRARY).a: $(COOLOBJ_FILES) $(EXMEOBJ_FILES) #$(SRCDIR)/$(LIBFILE).o
$(MK) $(BINDIR)
$(AR) $(BINDIR)/$(LIBRARY).a $^
###########################################################
# General rulesets for compilation.
###########################################################
.PHONY: clean
clean:
$(RM) $(BINDIR)/*solver.o $(BINDIR)/*solver.obj $(BINDIR)/*xternal*
.PHONY: very-clean
very-clean: clean
$(RM) $(BINDIR)/* **.so **.a **.dylib **.lib **.o **.obj **.mod
$(BINDIR)/%.o : %.cpp
$(CPPC) $(CPPFLAGS) -o $(BINDIR)/$*.o $(CPPINCLUDES) -c $<
############################################################
## Create the documentation from annotations in the source
## files with DOXYGEN, a configuration file is needed.
############################################################
#.PHONY : doc
#doc : doc/Doxyfile
# doxygen doc/Doxyfile
# cd doc/latex ; \
# make all
.PHONY : print-flags
print-flags:
@printf "\nBuild settings:\n\
USERNAME :$(USERNAME)\n\
MAJORVERSION :$(MAJORVERSION)\n\
MINORVERSION :$(MINORVERSION)\n\
LIBRARY :$(LIBRARY)\n\
LIBFLAGS :$(LIBFLAGS)\n\
OPTFLAGS :$(OPTFLAGS)\n\
CPPFLAGS :$(CPPFLAGS)\n\
CPPINCLUDES :$(CPPINCLUDES)\n\
USE_FLUIDPROP:$(USE_FLUIDPROP)\n\
USE_COOLPROP :$(USE_COOLPROP)\n\n\
EXMEOBJ_FILES:\n$(EXMEOBJ_FILES)\n\
COOLOBJ_FILES:\n$(COOLOBJ_FILES)\n\n"