ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/JSOC/make_basic.mk
Revision: 1.76
Committed: Wed Mar 21 15:10:27 2012 UTC (11 years, 6 months ago) by arta
Branch: MAIN
CVS Tags: Ver_6-2, Ver_6-3, NetDRMS_Ver_6-2, NetDRMS_Ver_6-3
Changes since 1.75: +1 -1 lines
Log Message:
Fix broken build - I have no idea how helloworld_sock ever built before.

File Contents

# Content
1 VPATH = $(SRCDIR)
2 STATIC =
3 DBMS = 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_ARCH="\"$(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 ifeq ($(FCOMPILER), ifort)
190 F_LF_ALL = -nofor-main -openmp -static-intel -Wl,-export-dynamic
191 endif
192 #***********************************************************************************************#
193
194 #***********************************************************************************************#
195 #
196 # GLOBAL COMPILE FLAGS
197 #
198 GCC_CF_GCCCOMP = -DGCCCOMP
199 ICC_CF_ICCCOMP = -DICCCOMP -openmp
200
201 # can't figure out how to get stupid make to do if/else if/else
202 ifeq ($(DEBUG), 0)
203 GCC_CF_ALL = -I$(SRCDIR)/base/include -std=gnu99 -O2 $(GCC_WARN) $(GCC_CF_GCCCOMP) $(CUSTOMSW) $(GLOBALSW) -DNDEBUG
204 # -xW tells the icc compiler to optimize for Pentium 4
205 ICC_CF_ALL = -I$(SRCDIR)/base/include -std=c99 -D_GNU_SOURCE $(ICC_WARN) $(ICC_CF_ICCCOMP) $(CUSTOMSW) $(GLOBALSW) -DNDEBUG
206
207 ifeq ($(JSOC_MACHINE), linux_x86_64)
208 GCC_CF_ALL = -I$(SRCDIR)/base/include -std=gnu99 -O2 -march=opteron $(GCC_WARN) $(GCC_CF_GCCCOMP) $(CUSTOMSW) $(GLOBALSW) -DNDEBUG
209 endif
210
211 ifeq ($(JSOC_MACHINE), linux_ia64)
212 ICC_CF_ALL = -I$(SRCDIR)/base/include -std=c99 -D_GNU_SOURCE $(ICC_WARN) $(ICC_CF_ICCCOMP) $(CUSTOMSW) $(GLOBALSW) -DNDEBUG
213 endif
214
215 ifeq ($(JSOC_MACHINE), linux_ia32)
216 GCC_CF_ALL = -I$(SRCDIR)/base/include -std=gnu99 -O2 -march=i686 $(GCC_WARN) $(GCC_CF_GCCCOMP) $(CUSTOMSW) $(GLOBALSW) -DNDEBUG
217 endif
218
219 else
220 # -g tells the icc and gcc compilers to generate full debugging information
221 GCC_CF_ALL = -I$(SRCDIR)/base/include -std=gnu99 -g $(GCC_WARN) $(GCC_CF_GCCCOMP) $(CUSTOMSW) $(GLOBALSW)
222 ICC_CF_ALL = -I$(SRCDIR)/base/include -std=c99 -D_GNU_SOURCE -g $(ICC_WARN) $(ICC_CF_ICCCOMP) $(CUSTOMSW) $(GLOBALSW)
223 endif
224
225 # Fortran global COMPILE flags
226 ifeq ($(JSOC_MACHINE), linux_x86_64)
227 ifeq ($(FCOMPILER), ifort)
228 F_CF_ALL := -openmp
229 endif
230 endif
231
232 # Other compiler-specific Fortran COMPILE flags
233 ifeq ($(FCOMPILER), ifort)
234 FCFLAGS_INIT := -ftrapuv
235 else
236 # must be gfortran
237 FCFLAGS_INIT :=
238 endif
239
240 ifeq ($(DEBUG), 0)
241 # -xW optimizes ifort compilation for Pentium 4
242 # -ftrapuv initializes stack local variables to an unusual value to aid error detection.
243 F_CF_ALL := $(F_CF_ALL) $(FCOMPILER_WARN)
244 else
245 F_CF_ALL := $(F_CF_ALL) -g $(FCFLAGS_INIT) $(FCOMPILER_WARN)
246 endif
247 #***********************************************************************************************#
248
249
250 #***********************************************************************************************#
251 #
252 # BUILD TOOLS
253 #
254 # The C compiler named here must output full (header) dependencies in $(@).d.
255 # It may be necessary to create a script similar to ccd-gcc for your compiler.
256 #
257 GCC_CMPLR = $(SRCDIR)/build/ccd-gcc
258 ICC_CMPLR = $(SRCDIR)/build/ccd-icc
259 ARCHIVE = ar crus $@ $^
260
261 ECPG = ecpg -o $@ -c $<
262 SWIG = swig -perl5 -o $@ $<
263
264 GCC_COMP = $(GCC_CMPLR) $(GCC_CF_ALL) $(CF_TGT) -o $@ -c $<
265 ICC_COMP = $(ICC_CMPLR) $(ICC_CF_ALL) $(CF_TGT) -o $@ -c $<
266
267 GCC_LINK = $(GCC_CMPLR) $(GCC_LF_ALL) $(LF_TGT) -o $@ $^ $(LL_TGT) $(LL_ALL)
268 ICC_LINK = $(ICC_CMPLR) $(ICC_LF_ALL) $(LF_TGT) -o $@ $^ $(LL_TGT) $(LL_ALL)
269
270 GCC_COMPLINK = $(GCC_CMPLR) $(GCC_CF_ALL) $(CF_TGT) $(GCC_LF_ALL) $(LF_TGT) -o $@ $< $(LL_TGT) $(LL_ALL)
271 ICC_COMPLINK = $(ICC_CMPLR) $(GCC_CF_ALL) $(CF_TGT) $(ICC_LF_ALL) $(LF_TGT) -o $@ $< $(LL_TGT) $(LL_ALL)
272
273 ifneq ($(COMPILER), icc)
274 COMP = $(GCC_COMP)
275 LINK = $(GCC_LINK)
276 COMPLINK = $(GCC_COMPLINK)
277 else
278 COMP = $(ICC_COMP)
279 LINK = $(ICC_LINK)
280 COMPLINK = $(ICC_COMPLINK)
281 endif
282
283 FCOMP = $(FCOMPILER) $(F_CF_ALL) $(FF_TGT) -o $@ -c $<
284 FLINK = $(FCOMPILER) $(F_LF_ALL) $(LF_TGT) -o $@ $^ $(LL_TGT) $(LL_ALL)
285
286 SLBIN = ln -sf ../../_$(MACH)/$@ ../bin/$(MACH)/
287 SLLIB = ln -sf ../../_$(MACH)/$@ ../lib/$(MACH)/
288 #***********************************************************************************************#
289
290
291 #***********************************************************************************************#
292 #
293 # LIBRARY COLLECTIONS
294 #
295 ALL_LIBS_FPIC = $(LIBDRMSCLIENT_FPIC) $(LIBDBCLIENT_FPIC) $(LIBCMDPARAMS_FPIC) $(LIBTHREADUTIL_FPIC) $(LIBRICECOMP_FPIC) $(LIBDEFS_FPIC) $(LIBMISC_FPIC) $(LIBDSTRUCT_FPIC) $(LIBTIMEIO_FPIC) $(LIBFITSRW_FPIC)
296
297 ### Standard parts
298 #
299 include $(SRCDIR)/Rules.mk
300
301 # Libraries from src/util linked with all programs.
302 ifneq ($(COMPILER), icc)
303 SYSLIBS = -lz -ldl -lpthread -lm
304 else
305 SYSLIBS = -lz -ldl -lpthread
306 endif
307 SRCLIBS = $(LIBTHREADUTIL) $(LIBRICECOMP) $(LIBCMDPARAMS) $(LIBTIMEIO) $(LIBFITSRW) $(LIBERRLOG) $(LIBEXPDRMS) $(LIBEXPUTL) $(LIBMISC) $(LIBDSTRUCT)
308 FSRCLIBS = $(LIBTHREADUTIL) $(LIBRICECOMP) $(LIBCMDPARAMSF) $(LIBTIMEIO) $(LIBFITSRW) $(LIBERRLOG) $(LIBEXPDRMS) $(LIBEXPUTL) $(LIBMISC) $(LIBDSTRUCT)
309
310 ########## Libraries to link for server executables, ##############
311 ########## standalone executables and pipeline modules. ##############
312
313 # SERVERLIBS: Libraries linked with "server" programs that
314 # need direct access to the DRMS databases.
315 SERVERLIBS = $(LIBDRMS) $(LIBDEFSSERVER) $(LIBDB) $(LIBSUMSAPI) $(SRCLIBS)
316
317 # EXELIBS: Libraries linked with standalone executables.
318 EXELIBS = $(LIBDRMSCLIENT) $(LIBDEFSCLIENT) $(LIBDBCLIENT) $(SRCLIBS)
319
320 # MODLIBS: Libraries linked with DRMS modules.
321 MODLIBS = $(LIBJSOC_MAIN) $(SERVERLIBS)
322
323 # MODLIBS_SOCK: Libraries linked with DRMS modules with socket connection to a drms_server
324 MODLIBS_SOCK = $(LIBJSOC_MAIN_SOCK) $(LIBDRMSCLIENT) $(LIBDEFSCLIENT) $(LIBDBCLIENT) $(LIBSUMSAPI) $(SRCLIBS)
325
326 # FMODLIBS: Libraries linked with DRMS Fortran modules
327 FMODLIBS_SOCK = $(LIBJSOC_MAIN_SOCK_F) $(LIBINTHANDLESF) $(LIBDRMSCLIENT) $(LIBDEFSCLIENT) $(LIBDBCLIENT) $(FSRCLIBS)
328 #***********************************************************************************************#
329
330
331 #***********************************************************************************************#
332 #
333 # PROJECT MAKE RULES
334 #
335 # Make rules that apply to all projects outside of the base DRMS/SUMS system
336 -include $(SRCDIR)/$(LOCALIZATIONDIR)/make_basic.mk
337 #***********************************************************************************************#
338
339
340 #***********************************************************************************************#
341 #
342 # MODULE TYPES
343 #
344 # Make rules that apply to all projects, inside and outside of the base DRMS/SUMS system
345 $(CEXE): %: %.o $(EXELIBS)
346 $(LINK)
347 $(SLBIN)
348
349 $(FEXE): %: %.o
350 $(FLINK)
351 $(SLBIN)
352
353 $(SERVEREXE): LL_TGT := $(LL_TGT) $(PGLIBS) $(CFITSIOLIBS)
354 $(SERVEREXE): %: %.o $(SERVERLIBS)
355 $(LINK)
356 $(SLBIN)
357
358 $(MODEXE): LL_TGT := $(LL_TGT) $(PGLIBS) $(CFITSIOLIBS)
359 $(MODEXE): %: %.o $(MODLIBS)
360 $(LINK)
361 $(SLBIN)
362
363 $(MODEXE_SOCK): LL_TGT := $(LL_TGT) $(PGLIBS) $(CFITSIOLIBS)
364 $(MODEXE_SOCK): %_sock: %.o $(MODLIBS_SOCK)
365 $(LINK)
366 $(SLBIN)
367 # FMODEXE_SOCK contains all Fortran modules - the DoIt() function is defined inside a .f file.
368 # These are socket-connect modules only. Assume they use third-party Fortran libraries
369 # (although this may not be the case).
370 $(FMODEXE_SOCK): LL_TGT := $(LL_TGT) $(PGLIBS) $(CFITSIOLIBS)
371 $(FMODEXE_SOCK): %_sock: %.o $(FMODLIBS_SOCK)
372 $(FLINK)
373 $(SLBIN)
374
375 # MODEXE_USEF contains all C direct-connect modules that use third-party Fortran libraries.
376 $(MODEXE_USEF): LL_TGT := $(LL_TGT) $(PGLIBS) $(CFITSIOLIBS)
377 $(MODEXE_USEF): %: %.o $(MODLIBS)
378 $(FLINK)
379 $(SLBIN)
380 # MODEXE_USEF contains all C socket-connect modules that use third-party Fortran libraries.
381 $(MODEXE_USEF_SOCK): LL_TGT := $(LL_TGT) $(PGLIBS) $(CFITSIOLIBS)
382 $(MODEXE_USEF_SOCK): %_sock: %.o $(MODLIBS_SOCK)
383 $(FLINK)
384 $(SLBIN)
385 #***********************************************************************************************#