ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/JSOC/make_basic.mk
Revision: 1.71
Committed: Mon Aug 29 15:12:28 2011 UTC (12 years ago) by arta
Branch: MAIN
Changes since 1.70: +1 -1 lines
Log Message:
Add flag to load binaries' symbols into dynamic symbol table - necessary so that libdsds.so shared library can call functions in the binaries loading the DL.

File Contents

# Content
1 VPATH = $(SRCDIR)
2 STATIC =
3 DBNAME = POSTGRESQL
4
5 # Run a script to determine the machine on which make is being run. This
6 # MAY return a machine type, if the host found falls into one of several
7 # categories (like dbserver).
8 MACHTYPE = $(shell $(SRCDIR)/getmachtype.pl)
9
10 # If MACH was set when the make command was issued (eg., make MACH='N02'), then
11 # use its value for the output/obj directory and use the custom.mk variables
12 # relevant to its value. Otherwise, use $(JSOC_MACHINE).
13 ifeq ($(MACH),)
14 MACH = $(JSOC_MACHINE)
15 endif
16
17 #***********************************************************************************************#
18 #
19 # COMPILER SELECTION
20 #
21 COMPILER = icc
22 FCOMPILER = ifort
23
24 # can set through custom.mk or through environment
25 ifneq ($(JSOC_COMPILER),)
26 COMPILER = $(JSOC_COMPILER)
27 endif
28
29 ifneq ($(JSOC_FCOMPILER),)
30 FCOMPILER = $(JSOC_FCOMPILER)
31 endif
32 #***********************************************************************************************#
33
34 #***********************************************************************************************#
35 # This optional file has custom definitions created by the configure script.
36 # Do this after compiler selection since custom.mk might use $COMPILER or $FCOMPILER.
37 # custom.mk might also set compiler (through moreconfigure.pl)
38 -include $(SRCDIR)/$(LOCALIZATIONDIR)/custom.mk
39 #***********************************************************************************************#
40
41 #***********************************************************************************************#
42 #
43 # DEBUGGING
44 #
45 # Check for debug vs. release build - release is default.
46 # To do a debug build, either set the environment variable JSOC_DEBUG to 1, OR
47 # modify the following line so that DEBUG = 1. The environment variable takes precedence.
48 #
49 DEBUG = 0
50
51 ifdef JSOC_DEBUG
52 ifeq ($(JSOC_DEBUG), 1)
53 DEBUG = 1
54 else
55 DEBUG = 0
56 endif
57 endif
58 #***********************************************************************************************#
59
60
61 #***********************************************************************************************#
62 #
63 # WARNINGS
64 #
65 # Warnings ARE displayed, by default, for a release build.
66 #
67 WARN = 1
68
69 # Builder can request warnings via environment variable (setenv JSOC_WARN 1).
70 # The environment variable takes precedence.
71 ifdef JSOC_WARN
72 ifeq ($(JSOC_WARN), 1)
73 WARN = 1
74 else
75 WARN = 0
76 endif
77 endif
78
79 ICC_WARNMORE =
80 ifdef JSOC_WARNICC
81 ifeq ($(COMPILER), icc)
82 ICC_WARNMORE = $(JSOC_WARNICC)
83 endif
84 endif
85
86 #***********************************************************************************************#
87
88
89 #***********************************************************************************************#
90 #
91 # THIRD-PARTY LIBRARIES
92 #
93 # This section contains make variables that hold the paths to and names of third-party libraries.
94 # Variables that end in 'H' contain the -I link flags that contain the include paths
95 # for the library headers, variables that end in 'L' contain the -L link flags that
96 # contain the paths to the library binaries, and variables
97 # that end in "LIBS" contain the full link cmd (the -L flag plus the -l flag)
98 #
99
100 # PostgreSQL
101 PGH = -I$(POSTGRES_INCS)
102 PGL = -L$(POSTGRES_LIBS)
103 PGLIBNAME = $(POSTGRES_LIB)
104 PGLIBS = $(PGL) -l$(PGLIBNAME)
105
106 # CFITSIO
107 CFITSIOH = -I$(CFITSIO_INCS)
108 CFITSIOL = -L$(CFITSIO_LIBS)
109 CFITSIOLIBNAME = $(CFITSIO_LIB)
110 CFITSIOLIBS = $(CFITSIOL) -l$(CFITSIOLIBNAME)
111
112 #***********************************************************************************************#
113
114
115 #***********************************************************************************************#
116 #
117 # CUSTOM BUILDS
118 #
119 # Compilation define customizations (eg., for remote DRMS builds)
120 CUSTOMSW =
121 ifneq ($(DRMS_DEFAULT_RETENTION),)
122 # CUSTOMSW = $(CUSTOMSW) -DDRMS_DEFAULT_RETENTION="\"$(DRMS_DEFAULT_RETENTION)\""
123 CUSTOMSW := $(CUSTOMSW) -DDRMS_DEFAULT_RETENTION=$(DRMS_DEFAULT_RETENTION)
124 endif
125
126 ifneq ($(CUSTOM_DEFINES),)
127 CUSTOMSW := $(CUSTOMSW) -D$(CUSTOM_DEFINES)
128 endif
129
130 #
131 #***********************************************************************************************#
132
133 #***********************************************************************************************#
134 #
135 # Global flags
136 #
137 # All modules must be able to find libdsds.so. The define DRMS_LIBDIR specifies the path to
138 # all libraries.
139
140 GLOBALSW = -DDRMS_LIBDIR="\"$(WORKINGDIR)/lib/$(MACH)\""
141 #
142 #***********************************************************************************************#
143
144 #***********************************************************************************************#
145 #
146 # WARNINGS
147 #
148 # NO LONGER USED - Disable several warnings/remarks when compiling with icc - icc's Wall is a bit picky, it
149 # complains about extern declarations in .c files.
150 # 1418 (remark) - external function definition with no prior declaration
151 # 1419 (warning) - external declaration in primary source file
152 # 310 (remark) - old style function declaration (pre-ANSI)
153 # 279 ?
154 # 981 (remark) - operands are evaluted in unspecified order
155
156 # list of warnings to turn into errors
157 ICC_WARNTOERR = -we266
158
159 ifeq ($(WARN), 1)
160 # Show warnings (always true for a debug build).
161 ICC_WARN = $(ICC_WARNMORE)
162 GCC_WARN = -Wno-comment
163 FCOMPILER_WARN =
164 else
165 # Don't show warnings.
166 ICC_WARN = -w0 -vec-report0 -Wno-comment $(ICC_WARNTOERR)
167 GCC_WARN = -Wno-comment
168 ifeq ($(FCOMPILER), ifort)
169 FCOMPILER_WARN = -vec-report0
170 else
171 FCOMPILER_WARN =
172 endif
173 endif
174
175 #***********************************************************************************************#
176
177
178 #***********************************************************************************************#
179 #
180 # GLOBAL LINK FLAGS
181 #
182 # Link flags for all targets
183 #
184 LL_ALL = $(SYSLIBS)
185 GCC_LF_ALL = $(STATIC)
186 ICC_LF_ALL = $(STATIC) -openmp -static-intel -Wl,-export-dynamic
187
188 # Fortran global LINK flags
189 F_LF_ALL = -nofor-main -openmp -static-intel -Wl,-export-dynamic
190 #***********************************************************************************************#
191
192 #***********************************************************************************************#
193 #
194 # GLOBAL COMPILE FLAGS
195 #
196 GCC_CF_GCCCOMP = -DGCCCOMP
197 ICC_CF_ICCCOMP = -DICCCOMP -openmp
198
199 # can't figure out how to get stupid make to do if/else if/else
200 ifeq ($(DEBUG), 0)
201 GCC_CF_ALL = -I$(SRCDIR)/base/include -std=gnu99 -O2 $(GCC_WARN) $(GCC_CF_GCCCOMP) $(CUSTOMSW) $(GLOBALSW) -DNDEBUG
202 # -xW tells the icc compiler to optimize for Pentium 4
203 ICC_CF_ALL = -I$(SRCDIR)/base/include -std=c99 -D_GNU_SOURCE $(ICC_WARN) $(ICC_CF_ICCCOMP) $(CUSTOMSW) $(GLOBALSW) -DNDEBUG
204
205 ifeq ($(JSOC_MACHINE), linux_x86_64)
206 GCC_CF_ALL = -I$(SRCDIR)/base/include -std=gnu99 -O2 -march=opteron $(GCC_WARN) $(GCC_CF_GCCCOMP) $(CUSTOMSW) $(GLOBALSW) -DNDEBUG
207 endif
208
209 ifeq ($(JSOC_MACHINE), linux_ia64)
210 ICC_CF_ALL = -I$(SRCDIR)/base/include -std=c99 -D_GNU_SOURCE $(ICC_WARN) $(ICC_CF_ICCCOMP) $(CUSTOMSW) $(GLOBALSW) -DNDEBUG
211 endif
212
213 ifeq ($(JSOC_MACHINE), linux_ia32)
214 GCC_CF_ALL = -I$(SRCDIR)/base/include -std=gnu99 -O2 -march=i686 $(GCC_WARN) $(GCC_CF_GCCCOMP) $(CUSTOMSW) $(GLOBALSW) -DNDEBUG
215 endif
216
217 else
218 # -g tells the icc and gcc compilers to generate full debugging information
219 GCC_CF_ALL = -I$(SRCDIR)/base/include -std=gnu99 -g $(GCC_WARN) $(GCC_CF_GCCCOMP) $(CUSTOMSW) $(GLOBALSW)
220 ICC_CF_ALL = -I$(SRCDIR)/base/include -std=c99 -D_GNU_SOURCE -g $(ICC_WARN) $(ICC_CF_ICCCOMP) $(CUSTOMSW) $(GLOBALSW)
221 endif
222
223 # Fortran global COMPILE flags
224 ifeq ($(JSOC_MACHINE), linux_x86_64)
225 ifeq ($(FCOMPILER), ifort)
226 F_CF_ALL := -openmp
227 endif
228 endif
229
230 # Other compiler-specific Fortran COMPILE flags
231 ifeq ($(FCOMPILER), ifort)
232 FCFLAGS_INIT := -ftrapuv
233 else
234 # must be gfortran
235 FCFLAGS_INIT :=
236 endif
237
238 ifeq ($(DEBUG), 0)
239 # -xW optimizes ifort compilation for Pentium 4
240 # -ftrapuv initializes stack local variables to an unusual value to aid error detection.
241 F_CF_ALL := $(F_CF_ALL) $(FCOMPILER_WARN)
242 else
243 F_CF_ALL := $(F_CF_ALL) -g $(FCFLAGS_INIT) $(FCOMPILER_WARN)
244 endif
245 #***********************************************************************************************#
246
247
248 #***********************************************************************************************#
249 #
250 # BUILD TOOLS
251 #
252 # The C compiler named here must output full (header) dependencies in $(@).d.
253 # It may be necessary to create a script similar to ccd-gcc for your compiler.
254 #
255 GCC_CMPLR = $(SRCDIR)/build/ccd-gcc
256 ICC_CMPLR = $(SRCDIR)/build/ccd-icc
257 ARCHIVE = ar crus $@ $^
258
259 ECPG = ecpg -o $@ -c $<
260 SWIG = swig -perl5 -o $@ $<
261
262 GCC_COMP = $(GCC_CMPLR) $(GCC_CF_ALL) $(CF_TGT) -o $@ -c $<
263 ICC_COMP = $(ICC_CMPLR) $(ICC_CF_ALL) $(CF_TGT) -o $@ -c $<
264
265 GCC_LINK = $(GCC_CMPLR) $(GCC_LF_ALL) $(LF_TGT) -o $@ $^ $(LL_TGT) $(LL_ALL)
266 ICC_LINK = $(ICC_CMPLR) $(ICC_LF_ALL) $(LF_TGT) -o $@ $^ $(LL_TGT) $(LL_ALL)
267
268 GCC_COMPLINK = $(GCC_CMPLR) $(GCC_CF_ALL) $(CF_TGT) $(GCC_LF_ALL) $(LF_TGT) -o $@ $< $(LL_TGT) $(LL_ALL)
269 ICC_COMPLINK = $(ICC_CMPLR) $(GCC_CF_ALL) $(CF_TGT) $(ICC_LF_ALL) $(LF_TGT) -o $@ $< $(LL_TGT) $(LL_ALL)
270
271 ifneq ($(COMPILER), icc)
272 COMP = $(GCC_COMP)
273 LINK = $(GCC_LINK)
274 COMPLINK = $(GCC_COMPLINK)
275 else
276 COMP = $(ICC_COMP)
277 LINK = $(ICC_LINK)
278 COMPLINK = $(ICC_COMPLINK)
279 endif
280
281 FCOMP = $(FCOMPILER) $(F_CF_ALL) $(FF_TGT) -o $@ -c $<
282 FLINK = $(FCOMPILER) $(F_LF_ALL) $(LF_TGT) -o $@ $^ $(LL_TGT) $(LL_ALL)
283
284 SLBIN = ln -sf ../../_$(MACH)/$@ ../bin/$(MACH)/
285 SLLIB = ln -sf ../../_$(MACH)/$@ ../lib/$(MACH)/
286 #***********************************************************************************************#
287
288
289 #***********************************************************************************************#
290 #
291 # LIBRARY COLLECTIONS
292 #
293 ALL_LIBS_FPIC = $(LIBDRMSCLIENT_FPIC) $(LIBDBCLIENT_FPIC) $(LIBCMDPARAMS_FPIC) $(LIBTHREADUTIL_FPIC) $(LIBRICECOMP_FPIC) $(LIBDEFS_FPIC) $(LIBMISC_FPIC) $(LIBDSTRUCT_FPIC) $(LIBTIMEIO_FPIC) $(LIBFITSRW_FPIC)
294
295 ### Standard parts
296 #
297 include $(SRCDIR)/Rules.mk
298
299 # Libraries from src/util linked with all programs.
300 ifneq ($(COMPILER), icc)
301 SYSLIBS = -lz -ldl -lpthread -lm
302 else
303 SYSLIBS = -lz -ldl -lpthread
304 endif
305 SRCLIBS = $(LIBTHREADUTIL) $(LIBRICECOMP) $(LIBCMDPARAMS) $(LIBTIMEIO) $(LIBFITSRW) $(LIBERRLOG) $(LIBEXPDRMS) $(LIBEXPUTL) $(LIBMISC) $(LIBDSTRUCT)
306 FSRCLIBS = $(LIBTHREADUTIL) $(LIBRICECOMP) $(LIBCMDPARAMSF) $(LIBTIMEIO) $(LIBFITSRW) $(LIBERRLOG) $(LIBEXPDRMS) $(LIBEXPUTL) $(LIBMISC) $(LIBDSTRUCT)
307
308 ########## Libraries to link for server executables, ##############
309 ########## standalone executables and pipeline modules. ##############
310
311 # SERVERLIBS: Libraries linked with "server" programs that
312 # need direct access to the DRMS databases.
313 SERVERLIBS = $(LIBDRMS) $(LIBDEFSSERVER) $(LIBDB) $(LIBSUMSAPI) $(SRCLIBS)
314
315 # EXELIBS: Libraries linked with standalone executables.
316 EXELIBS = $(LIBDRMSCLIENT) $(LIBDEFSCLIENT) $(LIBDBCLIENT) $(SRCLIBS)
317
318 # MODLIBS: Libraries linked with DRMS modules.
319 MODLIBS = $(LIBJSOC_MAIN) $(SERVERLIBS)
320
321 # MODLIBS_SOCK: Libraries linked with DRMS modules with socket connection to a drms_server
322 MODLIBS_SOCK = $(LIBJSOC_MAIN_SOCK) $(LIBDRMSCLIENT) $(LIBDEFSCLIENT) $(LIBDBCLIENT) $(LIBSUMSAPI) $(SRCLIBS)
323
324 # FMODLIBS: Libraries linked with DRMS Fortran modules
325 FMODLIBS_SOCK = $(LIBJSOC_MAIN_SOCK_F) $(LIBINTHANDLESF) $(LIBDRMSCLIENT) $(LIBDEFSCLIENT) $(LIBDBCLIENT) $(FSRCLIBS)
326 #***********************************************************************************************#
327
328
329 #***********************************************************************************************#
330 #
331 # PROJECT MAKE RULES
332 #
333 # Make rules that apply to all projects outside of the base DRMS/SUMS system
334 -include $(SRCDIR)/$(LOCALIZATIONDIR)/make_basic.mk
335 #***********************************************************************************************#
336
337
338 #***********************************************************************************************#
339 #
340 # MODULE TYPES
341 #
342 # Make rules that apply to all projects, inside and outside of the base DRMS/SUMS system
343 $(CEXE): %: %.o $(EXELIBS)
344 $(LINK)
345 $(SLBIN)
346
347 $(FEXE): %: %.o
348 $(FLINK)
349 $(SLBIN)
350
351 $(SERVEREXE): LL_TGT := $(LL_TGT) $(PGLIBS) $(CFITSIOLIBS)
352 $(SERVEREXE): %: %.o $(SERVERLIBS)
353 $(LINK)
354 $(SLBIN)
355
356 $(MODEXE): LL_TGT := $(LL_TGT) $(PGLIBS) $(CFITSIOLIBS)
357 $(MODEXE): %: %.o $(MODLIBS)
358 $(LINK)
359 $(SLBIN)
360
361 $(MODEXE_SOCK): LL_TGT := $(LL_TGT) $(CFITSIOLIBS)
362 $(MODEXE_SOCK): %_sock: %.o $(MODLIBS_SOCK)
363 $(LINK)
364 $(SLBIN)
365 # FMODEXE_SOCK contains all Fortran modules - the DoIt() function is defined inside a .f file.
366 # These are socket-connect modules only. Assume they use third-party Fortran libraries
367 # (although this may not be the case).
368 $(FMODEXE_SOCK): LL_TGT := $(LL_TGT) $(CFITSIOLIBS)
369 $(FMODEXE_SOCK): %_sock: %.o $(FMODLIBS_SOCK)
370 $(FLINK)
371 $(SLBIN)
372
373 # MODEXE_USEF contains all C direct-connect modules that use third-party Fortran libraries.
374 $(MODEXE_USEF): LL_TGT := $(LL_TGT) $(PGLIBS) $(CFITSIOLIBS)
375 $(MODEXE_USEF): %: %.o $(MODLIBS)
376 $(FLINK)
377 $(SLBIN)
378 # MODEXE_USEF contains all C socket-connect modules that use third-party Fortran libraries.
379 $(MODEXE_USEF_SOCK): LL_TGT := $(LL_TGT) $(CFITSIOLIBS)
380 $(MODEXE_USEF_SOCK): %_sock: %.o $(MODLIBS_SOCK)
381 $(FLINK)
382 $(SLBIN)
383 #***********************************************************************************************#