File: rules-gnu.mak

package info (click to toggle)
objcryst-fox 2022.1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 7,040 kB
  • sloc: cpp: 70,656; xml: 43,909; ansic: 467; python: 170; makefile: 21; sh: 12
file content (292 lines) | stat: -rw-r--r-- 10,187 bytes parent folder | download | duplicates (2)
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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
# Base building directory - This must be defined in the Makefile including this one
#ROOT_DIR = ${CURDIR}
# Base ObjCryst directory
DIR_CRYST = $(BUILD_DIR)/ObjCryst

#Libraries to be statically linked are installed in $(DIR_STATIC_LIBS)/lib,
#with their headers in DIR_STATIC_LIBS)/include
DIR_STATIC_LIBS = $(BUILD_DIR)/static-libs

#Internal directories
DIR_CRYSTVECTOR = ${DIR_CRYST}/CrystVector
DIR_EXAMPLE = ${DIR_CRYST}/example
DIR_LIBCRYST = ${DIR_CRYST}/ObjCryst
DIR_REFOBJ = ${DIR_CRYST}/RefinableObj
DIR_VFNQUIRKS = ${DIR_CRYST}/Quirks
DIR_WXWCRYST = ${DIR_CRYST}/wxCryst
DIR_DOC := ${DIR_CRYST}/doc

# DO we want to use shared libraries for wxGTK, freeglut, fftw & newmat ?
# User can also use shared libraries only for some libraries, by using
# "make shared-wxgtk=1" instead of "make shared=1"
ifeq ($(shared),1)
shared-newmat=1
shared-wxgtk=1
shared-fftw=1
shared-glut=1
shared-cctbx=1
endif
### Rules for Linux & GCC
# C compiler
#CC     := gcc
CFLAGS  = ${DEPENDFLAGS}
# C++ compiler
#CXX      := g++
CXXFLAGS  = ${DEPENDFLAGS} ${PROFILEFLAGS}
# FORTRAN compiler
FC     := f77
FFLAGS  =
# linker
LINKER    := ${CXX}
CRYST_LDFLAGS   = ${LDFLAGS} -L/usr/lib -L/usr/local/lib -L$(DIR_CRYSTVECTOR) -L$(DIR_LIBCRYST) -L$(DIR_REFOBJ) -L$(DIR_STATIC_LIBS)/lib -L$(DIR_VFNQUIRKS) -L$(DIR_WXWCRYST) -L$(DIR_TAU)/x86_64/lib

#to automatically generate dependencies
MAKEDEPEND = gcc -MM ${CPPFLAGS} ${CXXFLAGS} ${C_BLITZFLAG} $< > $*.dep

# header files
SEARCHDIRS = -I$(DIR_TAU)/include -I${DIR_CRYST}/.. -I$(DIR_STATIC_LIBS)/include

#wxWindows flags
ifeq ($(wxcryst),1)
   WXCRYSTFLAGS = -D__WX__CRYST__ `$(WXCONFIG) --cxxflags`
   WX_LDFLAGS = -L/usr/X11R6/lib -lwxcryst `$(WXCONFIG) --libs adv,core,base,net` $(GL_WX_LIB)
else
   WXCRYSTFLAGS :=
   WX_LDFLAGS :=
endif

#Profiling
ifeq ($(profile),1) #activate profiling using TAU package
   DIR_TAU=$(BUILD_DIR)/../../utils/tau
   PROFILEFLAGS := -DPROFILING_ON -DTAU_GNU -DTAU_DOT_H_LESS_HEADERS -DTAU_LINUX_TIMERS -DTAU_LARGEFILE -D_LARGEFILE64_SOURCE -DHAVE_TR1_HASH_MAP -UTAU_MPI -I$(DIR_TAU)/include
   PROFILELIB := -ltau
else
   ifeq ($(profile),2) # *generate* profiling using gcc
      PROFILEFLAGS := -fprofile-generate
      PROFILELIB := -fprofile-generate
   else
      ifeq ($(profile),3) # *use* profiling using gcc
         PROFILEFLAGS := -fprofile-use
         PROFILELIB := -fprofile-use
      else
         PROFILEFLAGS :=
         PROFILELIB :=
      endif
   endif
endif

#Use static linking to wx and freeglut libraries ? Unicode
ifneq ($(shared-wxgtk),1)
WXCONFIG= $(DIR_CRYST)/../static-libs/bin/wx-config --unicode=yes
else
WXCONFIG= wx-config --unicode=yes
endif

# Which command to use for download ?
WGET=$(shell which wget 2>/dev/null)
ifneq ($(WGET),)
DOWNLOAD_COMMAND=wget
else
DOWNLOAD_COMMAND=curl -L -O
endif

# If using glut (freeglut)
GLUT_FLAGS= -DHAVE_GLUT
GLUT_LIB= -lglut

#Specifiy REAL= float or double
ifeq ($(real_double),1)
REAL_FLAG= -DREAL=double
else
REAL_FLAG= -DREAL=float
endif
#Using OpenGL ?
ifeq ($(opengl),1)
GL_WX_LIB = `$(WXCONFIG) --gl-libs` -lGL -lGLU $(GLUT_LIB)
GL_FLAGS = -DOBJCRYST_GL -I/usr/X11R6/include -IGL $(GLUT_FLAGS)
else
GL_WX_LIB :=
GL_FLAGS :=
endif

#Using fftw
ifneq ($(fftw),0)
FFTW_LIB = -lfftw3f
FFTW_FLAGS = -DHAVE_FFTW
else
FFTW_LIB :=
FFTW_FLAGS :=
endif

ifneq ($(sse),0)
SSE_FLAGS = -DHAVE_SSE_MATHFUN -DUSE_SSE2 -march=native
else
SSE_FLAGS =
endif

ifneq ($(shared-newmat),1)
LDNEWMAT := $(DIR_STATIC_LIBS)/lib/libnewmat.a
else
LDNEWMAT := -lnewmat
endif

#Using COD, with MySQL
ifneq ($(cod),0)
 COD_FLAGS = -D__FOX_COD__
else
 COD_FLAGS :=
endif

ifeq ($(shared_libcryst),1)
 CPPFLAGS = -O3 -w -fPIC -g -ffast-math -fstrict-aliasing -pipe -funroll-loops ${SSE_FLAGS}
 DEPENDFLAGS = ${SEARCHDIRS} ${GL_FLAGS} ${WXCRYSTFLAGS} ${FFTW_FLAGS} ${REAL_FLAG}
else
 ifeq ($(debug),1)
 #Set DEBUG options
   ifdef RPM_OPT_FLAGS
      # we are building a RPM !
      CPPFLAGS = ${RPM_OPT_FLAGS}
   else
      CPPFLAGS = -g -Wall -D__DEBUG__ ${SSE_FLAGS} ${COD_FLAGS}
   endif
   DEPENDFLAGS = ${SEARCHDIRS} ${GL_FLAGS} ${WXCRYSTFLAGS} ${FFTW_FLAGS} ${REAL_FLAG}
   LOADLIBES = -lm -lcryst -lCrystVector -lQuirks -lRefinableObj -lcctbx ${LDNEWMAT} ${PROFILELIB} ${GL_LIB} ${WX_LDFLAGS} ${FFTW_LIB}
 else
   ifdef RPM_OPT_FLAGS
      # we are building a RPM !
      CPPFLAGS = ${RPM_OPT_FLAGS}
   else
      #default flags - use "sse=1" to enable SSE optimizations
      CPPFLAGS = -O3 -w -ffast-math -fstrict-aliasing -pipe -fomit-frame-pointer -funroll-loops -ftree-vectorize ${SSE_FLAGS} ${COD_FLAGS}
   endif
   DEPENDFLAGS = ${SEARCHDIRS} ${GL_FLAGS} ${WXCRYSTFLAGS} ${FFTW_FLAGS} ${REAL_FLAG}
   LOADLIBES = -lm -lcryst -lCrystVector -lQuirks -lRefinableObj -lcctbx ${LDNEWMAT} ${PROFILELIB} ${GL_LIB} ${WX_LDFLAGS} ${FFTW_LIB}
 endif
endif
# Add to statically link: -nodefaultlibs -lgcc /usr/lib/libstdc++.a

######################################################################
#####################      LIBRAIRIES         ########################
######################################################################
#Newmat Matrix Algebra library (used for SVD)

$(BUILD_DIR)/newmat.tar.bz2:
	cd $(BUILD_DIR) && $(DOWNLOAD_COMMAND) https://github.com/vincefn/objcryst/releases/download/v2021-3rdPartyLibs/newmat.tar.bz2

$(DIR_STATIC_LIBS)/lib/libnewmat.a: $(BUILD_DIR)/newmat.tar.bz2
	cd $(BUILD_DIR) && tar -xjf newmat.tar.bz2
	$(MAKE) -f nm_gnu.mak -C $(BUILD_DIR)/newmat libnewmat.a
	mkdir -p $(DIR_STATIC_LIBS)/lib/
	cp $(BUILD_DIR)/newmat/libnewmat.a $(DIR_STATIC_LIBS)/lib/
	mkdir -p $(DIR_STATIC_LIBS)/include/newmat
	cp $(BUILD_DIR)/newmat/*.h $(DIR_STATIC_LIBS)/include/newmat/
	#rm -Rf $(BUILD_DIR)/newmat

ifneq ($(shared-newmat),1)
libnewmat= $(DIR_STATIC_LIBS)/lib/libnewmat.a
else
libnewmat=
endif

$(BUILD_DIR)/freeglut.tar.bz2:
	cd $(BUILD_DIR) && $(DOWNLOAD_COMMAND) https://github.com/vincefn/objcryst/releases/download/v2021-3rdPartyLibs/freeglut.tar.bz2

$(BUILD_DIR)/static-libs/lib/libglut.a: $(BUILD_DIR)/freeglut.tar.bz2
	cd $(BUILD_DIR) && tar -xjf freeglut.tar.bz2
	cd $(BUILD_DIR)/freeglut && ./configure --prefix=$(BUILD_DIR)/static-libs --disable-shared --disable-warnings --x-includes=/usr/X11R6/include/ && $(MAKE) install
	rm -Rf freeglut

ifeq ($(opengl),1)
ifneq ($(shared-glut),1)
libfreeglut= $(DIR_STATIC_LIBS)/lib/libglut.a
else
libfreeglut=
endif
else
libfreeglut=
endif

$(BUILD_DIR)/wxWidgets-3.1.6.tar.bz2:
	cd $(BUILD_DIR) && $(DOWNLOAD_COMMAND) https://github.com/wxWidgets/wxWidgets/releases/download/v3.1.6/wxWidgets-3.1.6.tar.bz2

$(BUILD_DIR)/static-libs/include/wx-3.1/wx/wx.h: $(BUILD_DIR)/wxWidgets-3.1.6.tar.bz2
	cd $(BUILD_DIR) && rm -Rf wxWidgets-3.1.6 && tar -xjf wxWidgets-3.1.6.tar.bz2
	cd $(BUILD_DIR)/wxWidgets-3.1.6 && ./configure --with-gtk --with-opengl --disable-glcanvasegl --prefix=$(BUILD_DIR)/static-libs --enable-unicode  --enable-optimise --disable-shared --x-includes=/usr/X11R6/include/ && $(MAKE) install
	rm -Rf $(BUILD_DIR)/wxWidgets-3.1.6

ifneq ($(wxcryst),0)
ifneq ($(shared-wxgtk),1)
libwx = $(BUILD_DIR)/static-libs/include/wx-3.1/wx/wx.h
else
libwx=
endif
else
libwx=
endif

#cctbx
$(BUILD_DIR)/cctbx.tar.bz2:
	cd $(BUILD_DIR) && $(DOWNLOAD_COMMAND) https://github.com/vincefn/objcryst/releases/download/v2021-3rdPartyLibs/cctbx.tar.bz2

$(DIR_STATIC_LIBS)/lib/libcctbx.a: $(BUILD_DIR)/cctbx.tar.bz2
	mkdir -p $(DIR_STATIC_LIBS)/lib/ $(DIR_STATIC_LIBS)/include/
	cd $(BUILD_DIR) && tar -xjf cctbx.tar.bz2
	$(MAKE) -f gnu.mak -C $(BUILD_DIR)/cctbx install
	#ln -sf $(BUILD_DIR)/boost $(DIR_STATIC_LIBS)/include/
	#rm -Rf $(BUILD_DIR)/cctbx

ifneq ($(shared-cctbx),1)
libcctbx= $(DIR_STATIC_LIBS)/lib/libcctbx.a
else
libcctbx=
endif

$(BUILD_DIR)/fftw-3.3.9.tar.gz:
	cd $(BUILD_DIR) && $(DOWNLOAD_COMMAND) http://fftw.org/fftw-3.3.9.tar.gz

$(DIR_STATIC_LIBS)/lib/libfftw3f.a: $(BUILD_DIR)/fftw-3.3.9.tar.gz
	cd $(BUILD_DIR) && tar -xzf fftw-3.3.9.tar.gz
	cd $(BUILD_DIR)/fftw-3.3.9 && ./configure --enable-single --prefix $(DIR_STATIC_LIBS) && $(MAKE) install
	rm -Rf $(BUILD_DIR)/fftw-3.3.9

ifneq ($(fftw),0)
ifneq ($(shared-fftw),1)
libfftw = $(DIR_STATIC_LIBS)/lib/libfftw3f.a
else
libfftw=
endif
else
libfftw=
endif

# Boost library - used for cctbx and Fox. 
# TODO: clarify install to see if we use boost from cctbx or independently installed...
$(BUILD_DIR)/boost_1_68_0.tar.bz2:
	cd $(BUILD_DIR) && $(DOWNLOAD_COMMAND) https://dl.bintray.com/boostorg/release/1.68.0/source/boost_1_68_0.tar.bz2

libboost:$(BUILD_DIR)/boost_1_68_0.tar.bz2
	cd $(BUILD_DIR) && tar -xjf boost_1_68_0.tar.bz2
	cd $(BUILD_DIR)/boost_1_68_0 && rsync -ar boost --exclude="accumulators/" --exclude="asio/" --exclude="asign/" --exclude="bimap/" --exclude="circular_buffer/" --exclude="concept_check/" --exclude="dynamic_bitset/" --exclude="filesystem/" --exclude="flyweight/" --exclude="function_types/" --exclude="gil/" --exclude="graph/" --exclude="interprocess/" --exclude="intrusive/" --exclude="iostreams/" --exclude="lambda/" --exclude="logic/" --exclude="mpi/" --exclude="parameter/" --exclude="pending/" --exclude="pool/" --exclude="program_options/" --exclude="proto/" --exclude="ptr_container/" --exclude="python/" --exclude="random/" --exclude="regex/" --exclude="signals/" --exclude="spirit/" --exclude="statechart/" --exclude="system/" --exclude="test/" --exclude="thread/" --exclude="units/" --exclude="unordered/" --exclude="wave/" --exclude="xpressive/" --filter="+ */" --filter="+ *.hpp"  --filter="+ *.ipp" $(DIR_STATIC_LIBS)/include/
	rm -Rf $(BUILD_DIR)/boost_1_68_0

#ObjCryst++
libCryst: $(libwx) $(libcctbx)
	$(MAKE) -f gnu.mak -C ${DIR_LIBCRYST} lib

libcryst: libCryst

#wxCryst++
libwxCryst: $(libwx) $(libfreeglut) $(libfftw) $(libcctbx)
	$(MAKE) -f gnu.mak -C ${DIR_WXWCRYST} lib

#Vector computation library
libCrystVector: $(libwx)
	$(MAKE) -f gnu.mak -C ${DIR_CRYSTVECTOR} lib

#Quirks, including a (crude) library to display float, vectors, matrices, strings with some formatting..
libQuirks: $(libwx)
	$(MAKE) -f gnu.mak -C ${DIR_VFNQUIRKS} lib

#Library to take care of refinable parameters, plus Global optimization and Least Squares refinements
libRefinableObj:$(libnewmat) $(libwx) $(libcctbx)
	$(MAKE) -f gnu.mak -C ${DIR_REFOBJ}/ lib