more recent changes than were available on zooty at the time of initial checkin.
[feisty_meow.git] / scripts / clam / cpp / rules.def
1 ###############################################################################
2
3 # CLAM System default rules and targets for C++ compilation.
4
5 # This file composite macros and rules for creating compilation objects
6 # (such as library archives, object files, executable programs, and others).
7
8 # This file should be included in the user's Makefile after the variables
9 # have been initialized appropriately for the particular project being
10 # compiled.  The user's own targets should be placed after the include
11 # directive that specifies this file.
12
13 ###############################################################################
14
15 # This section manipulates variable values to prepare them for their use
16 # in the standard CLAM support.
17
18 # Modify the output directory for executable files if we're building a
19 # test project.
20 ifneq "$(findstring test, $(TYPE))" ""
21 ###  EXECUTABLE_DIR = $(TARGETS_DIR)/tests/$(PROJECT)
22 endif
23
24 # see if they have got the clean flag set.  if so, we will not build anything.
25 ifneq "$(CLEAN)" ""
26   NO_COMPILE = t
27 endif
28 # also omit version compilation and some logging when not compiling.
29 ifneq "$(NO_COMPILE)" ""
30   QUIET = t
31 endif
32
33 # implement special bits for gnu on unix.
34 ifeq "$(COMPILER)" "GNU_LINUX"
35   ifneq "$(USE_XWIN)" ""
36     ifneq "$(OP_SYSTEM)" "WIN32"
37       DEFINITIONS += __XWINDOWS__ __X__
38       LIBS_USED += Xm Xt X11 Xft Xp 
39 #need to separate out with a USE_MOTIF kind of thing.
40 LIBS_USED += Xmu
41       HEADER_SEARCH_PATH += /usr/include/X11 /usr/X11R6/include /usr/include/g++
42       LIBRARY_SEARCH_PATH += /usr/X11R6/lib 
43     endif
44   endif
45
46   ifneq "$(USE_SSL)" ""
47     LIBS_USED += ssl crypto
48   endif
49   
50   ifneq "$(USE_WXWIDGETS)" ""
51     DEFINITIONS += __WXWIDGETS__ 
52     use_unicode =
53     ifneq "$(findstring UNICODE, $(DEFINITIONS))" ""
54 #      ifeq "$(OP_SYSTEM)" "WIN32"
55         use_unicode = true
56 #      endif
57     endif
58
59     # decide whether to turn on the unicode flag or not.
60     ifneq "$(use_unicode)" ""
61       DEFINITIONS += wxUSE_UNICODE
62       UNICODE_FLAG_ADD = --unicode=yes
63     else
64       UNICODE_FLAG_ADD = --unicode=no
65     endif
66     # could add for debugging: --debug=yes 
67     COMPILER_FLAGS += $(shell wx-config --cxxflags $(UNICODE_FLAG_ADD) )
68
69     LOAD_FLAG_PREFIX += $(shell wx-config --libs $(UNICODE_FLAG_ADD) )
70   endif
71
72   ifneq "$(USE_CURL)" ""
73     COMPILER_FLAGS += `curl-config --cflags`
74     LOAD_FLAG_SUFFIX += `curl-config --static-libs`
75   endif
76
77 endif
78
79 ###############################################################################
80
81 ifeq "$(COMPILER)" "GNU_DARWIN"
82   ifneq "$(USE_XWIN)" ""
83     DEFINITIONS += __XWINDOWS__ __X__
84     LIBS_USED += 
85 #Xm Xt X11 Xft Xp 
86 #need to separate out with a USE_MOTIF kind of thing.
87 #LIBS_USED += Xmu
88     HEADER_SEARCH_PATH += /usr/include/X11 /usr/X11R6/include /usr/include/g++
89     LIBRARY_SEARCH_PATH += /usr/X11R6/lib 
90   endif
91
92   ifneq "$(USE_SSL)" ""
93     LIBS_USED += crypto
94   endif
95   
96   ifneq "$(USE_WXWIDGETS)" ""
97     DEFINITIONS += __WXWIDGETS__ 
98     use_unicode =
99     ifneq "$(findstring UNICODE, $(DEFINITIONS))" ""
100 #      ifeq "$(OP_SYSTEM)" "WIN32"
101         use_unicode = true
102 #      endif
103     endif
104
105     # decide whether to turn on the unicode flag or not.
106 ###    ifneq "$(findstring UNICODE, $(DEFINITIONS))" ""
107     ifneq "$(use_unicode)" ""
108       UNICODE_FLAG_ADD = --unicode=yes
109       DEFINITIONS += wxUSE_UNICODE
110     else
111       UNICODE_FLAG_ADD = --unicode=no
112     endif
113
114     COMPILER_FLAGS += $(shell wx-config --cxxflags $(UNICODE_FLAG_ADD) )
115     LOAD_FLAG_PREFIX += $(shell wx-config --libs $(UNICODE_FLAG_ADD) )
116   endif
117
118   ifneq "$(USE_CURL)" ""
119     COMPILER_FLAGS += `curl-config --cflags`
120     LOAD_FLAG_SUFFIX += `curl-config --libs`
121   endif
122
123 endif
124
125 ###############################################################################
126
127
128 # additions for gnu x86 and arm compilers.
129 ifneq "$(OP_SYSTEM)" "WIN32"
130   # is the freetds library support available on this host.
131   ifneq "$(ENABLE_FREETDS)" ""
132     # establish the headers if freetds is enabled.  that just means things
133     # can be compiled against it.  to link in the db-lib, the makefile should
134     # have a 'USE_FREETDS = true' statement.
135
136     # is this particular library or app using freetds?
137     ifneq "$(USE_FREETDS)" ""
138       DEFINITIONS += ENABLE_FREETDS _FREETDS_LIBRARY_SOURCE
139       LIBS_USED += rt sybdb 
140     endif
141   endif
142 endif
143
144 # win32 compiler additions.
145 ifeq "$(OP_SYSTEM)" "WIN32"
146   # processes the def file for linkage, if one has been specified.
147   ifneq "$(DEF_FILE)" ""
148     LOAD_FLAG_PREFIX += -def:$(DEF_FILE)
149   endif
150
151   ifneq "$(TYPE)" "library"
152     ifneq "$(USE_MFC)" ""
153       ifneq "$(findstring UNICODE, $(DEFINITIONS))" "" 
154         # specify the winmain type for unicode explicitly.
155         LOAD_FLAG_PREFIX += -entry:wWinMainCRTStartup
156       endif
157     endif
158   endif
159
160   # these are loaded after any special debugging libs.
161   ifneq "$(VCPP_USE_BASE)" ""
162     # the first set will be included in almost any old program.  we include
163     # winmm for multimedia in the base support since we make heavy use of the
164     # more accurate uptime function.
165     LOAD_FLAG_PREFIX += kernel32.lib user32.lib advapi32.lib shell32.lib \
166       version.lib winmm.lib shlwapi.lib 
167   endif
168
169   ifneq "$(USE_WXWIDGETS)" ""
170     DEFINITIONS += __WXWIDGETS__ __WXMSW__ 
171     LOCAL_HEADERS += $(THIRD_PARTY_DIR)/wxwidgets/include 
172     LIBRARY_SEARCH_PATH += $(THIRD_PARTY_DIR)/wxwidgets/lib
173 #    ifeq "$(findstring UNICODE, $(DEFINITIONS))" ""
174       LIBS_USED += wxmsw28_core.lib
175       LOCAL_HEADERS += $(THIRD_PARTY_DIR)/wxwidgets/lib/msw
176 #    else
177 #      DEFINITIONS += wxUSE_UNICODE
178 #      LIBS_USED += wxmsw28u_core.lib
179 #      LOCAL_HEADERS += $(THIRD_PARTY_DIR)/wxwidgets/lib/mswu
180 #    endif
181
182 ##    LOAD_FLAG_PREFIX += comctl32.lib shell32.lib
183     VCPP_USE_GUI = t
184     VCPP_USE_OLE = t
185   endif
186
187   ifneq "$(USE_CURL)" ""
188     DEFINITIONS += _WIN32
189     LOCAL_HEADERS += $(THIRD_PARTY_DIR)/curl/include
190     LIBRARY_SEARCH_PATH += $(THIRD_PARTY_DIR)/curl/lib
191 #    ifeq "$(findstring libcurl, $(LIBS_USED))" ""
192       LIBS_USED += libcurl.dll.a
193 #    endif
194   endif
195
196   ifneq "$(VCPP_USE_GUI)" ""
197     LOAD_FLAG_PREFIX += comctl32.lib comdlg32.lib gdi32.lib winspool.lib
198   endif
199
200   ifneq "$(VCPP_USE_OLE)" ""
201     LOAD_FLAG_PREFIX += ole32.lib oleaut32.lib uuid.lib
202     VCPP_USE_RPC = t
203   endif
204   ifneq "$(VCPP_USE_RPC)" ""
205     ifeq "$(COMPILER_VERSION)" "8"
206       LOAD_FLAG_PREFIX += rpcndr.lib rpcns4.lib rpcrt4.lib
207     endif
208     ifeq "$(COMPILER_VERSION)" "10"
209       LOAD_FLAG_PREFIX += rpcrt4.lib
210     endif
211     VCPP_USE_SOCK = t
212   endif
213   ifneq "$(VCPP_USE_SOCK)" ""
214     LOAD_FLAG_PREFIX += netapi32.lib ws2_32.lib
215   endif
216   ifneq "$(VCPP_USE_CLR)" ""
217     LOAD_FLAG_PREFIX += -noentry -include:"__DllMainCRTStartup@12"
218     COMPILER_FLAGS += -EHa -clr -AI "$(FRAMEWORK_DIR)" -AI "$(DYNAMIC_LIBRARY_DIR)" -FU "mscorlib.dll" -FU "System.dll" -FU "System.Data.dll" -FU "System.Windows.Forms.dll" -FU "System.Drawing.dll"
219   endif
220
221   ifneq "$(USE_SSL)" ""
222     LOCAL_HEADERS += $(THIRD_PARTY_DIR)/openssl/include
223     LIBRARY_SEARCH_PATH += $(THIRD_PARTY_DIR)/openssl/lib
224     LIBS_USED += libeay32.lib
225     $(shell cp $(THIRD_PARTY_DIR)/openssl/lib/*dll $(EXECUTABLE_DIR) )
226   endif
227   
228 endif
229
230 ifeq "$(OP_SYSTEM)" "WIN32"
231   # prep the actual source variable so that certain file names are translated.
232   ACTUAL_RESX = $(RESX:%.resx=$(OBJECT_DIR)/%.resources)
233   ACTUAL_RESX_FLAGS = $(ACTUAL_RESX:%=-ASSEMBLYLINKRESOURCE:%) 
234 else
235   ACTUAL_RESX = 
236   ACTUAL_RESX_FLAGS = 
237 endif
238
239 # Create the real list of local libraries needed.
240 TEMP_LOC1 = $(LOCAL_LIBS_USED:%=%$(TRIPART_VERSION))
241 ACTUAL_LOCAL_LIBS = $(TEMP_LOC1)
242
243 # Create the list of objects from the list of source files.
244 TEMP_OBJ1 = $(SOURCE:%.cpp=%.obj)
245 TEMP_OBJ2 = $(TEMP_OBJ1:%.c=%.obj)
246 ifeq "$(OP_SYSTEM)" "WIN32"
247   ifneq "$(OMIT_VERSIONS)" ""
248     # remove version rc files if we're not dealing with versions.
249     TEMP_OBJ3a = $(TEMP_OBJ2:%_version.rc=)
250   else
251     TEMP_OBJ3a = $(TEMP_OBJ2)
252   endif
253   TEMP_OBJ3 = $(TEMP_OBJ3a:%.rc=%.res)
254 else
255   # replace this when supporting resource files on unix.
256   TEMP_OBJ3 = $(TEMP_OBJ2:%.rc=)
257 endif
258 TEMP_OBJ4 = $(TEMP_OBJ3:%.h=%.bad)
259 OBJECTS = $(TEMP_OBJ4)
260
261 # special case for multi-build and res files that need to be rebuilt.
262 #RES_OBJECTS_0 = $(SOURCE:%.cpp=)
263 #RES_OBJECTS_1 = $(RES_OBJECTS_0:%.c=)
264 #RES_OBJECTS = $(RES_OBJECTS_1:%.rc=$(OBJECT_DIR)/%.res)
265
266 # not much conversion anymore...
267 ACTUAL_OBJECTS = $(OBJECTS) $(EXTRA_OBJECTS)
268
269 # Updates the search path for the compiler and local libraries.
270 BASE_HEADER_PATH = $(CODEBASE_HEADERS) $(LOCAL_HEADERS) $(HOOPLE_HEADERS) $(SEARCH_DIRS)
271 HEADER_SEARCH_PATH += $(BASE_HEADER_PATH) $(COMPILER_HEADER_DIR)
272
273 LIBRARY_SEARCH_PATH += $(LOCAL_LIBRARIES) $(HOOPLE_LIBRARIES) \
274   $(STATIC_LIBRARY_DIR) $(COMPILER_LIBRARY_DIR) $(SEARCH_DIRS)
275
276 # Adds some directories that must be searched onto the search path for
277 # header files, such as the header file directory for the compiler.
278 COMPILER_FLAGS += $(HEADER_SEARCH_PATH:%=-I%) $(DEFINITIONS:%=-D%) $(UNDEFINITIONS:%=-U%) -DGLOBAL_PRODUCT_NAME="$(GLOBAL_PRODUCT_NAME)"
279
280 # The load flags are updated by looking for code libraries in the directories
281 # to search and by adding all of the code libraries that are used.
282 LOAD_FLAG_PREFIX += $(LIBRARY_SEARCH_PATH:%=$(LIBRARY_PATH_FLAG)%)
283 ifeq "$(OP_SYSTEM)" "UNIX"
284 #mac no like these flags?
285 #  LOAD_FLAG_PREFIX += -Xlinker --start-group
286 #  LOAD_FLAG_SUFFIX += -Xlinker --end-group
287 endif
288 # had to switch from prefix to suffix recently.  oddity.
289 #LOAD_FLAG_PREFIX += $(LIBS_USED:%=$(LIBRARY_NAME_FLAG)%)
290 LOAD_FLAG_SUFFIX += $(LIBS_USED:%=$(LIBRARY_NAME_FLAG)%)
291
292 # we steal the exe targets and represent their dependency from the hidden
293 # cpp for the exe.
294 EXE_TEMP_0 = $(TARGETS:%.dll=)
295 EXE_TEMP_1 = $(EXE_TEMP_0:%.so=)
296 EXE_TEMP_2 = $(EXE_TEMP_1:%.lib=)
297 EXE_TEMP_3 = $(EXE_TEMP_2:%.elf=%.cpp)
298 EXE_CPPS   = $(EXE_TEMP_3:%.exe=%.cpp)
299
300 # used for compiling multiple source files at the same time with visual cpp.
301 MULTI_BUILD_CMD = $(CC) $(COMPILER_FLAGS) -c `cat $(BUILD_LIST_FILE)` $(OBJECT_NAME_FLAG)$(OBJECT_DIR)/
302
303 # prepare for mfc style DLLs.  currently we plan on all dlls we create being
304 # based on MFC.  this is an unfortunate requirement for using the mfc debug
305 # support for allocations; if regular new and DEBUG_NEW get mixed together,
306 # crashes used to result.  supposedly these are gone now at least.
307 ifneq "$(USE_MFC)" ""
308   ifeq "$(OP_SYSTEM)" "WIN32"
309     # set the flag that says we are doing mfc extension dlls.
310     DEFINITIONS += _AFXDLL
311     DEPENDENCY_DEFINITIONS += _MT _DLL
312     DEPENDENCY_DEFINITIONS += __AFXWIN_H__  # add this flag to shut stdafx up.
313   endif
314 endif
315
316 ifeq "$(OMIT_VERSIONS)" ""
317   ifneq "$(VERSION_RC_ROOT)" ""
318     VERSION_TARGET = $(VERSION_RC_ROOT)_version.rc
319   endif
320 endif
321
322 ifneq "$(GENDEPS)" ""
323   EXTRA_FIRST_TARGETS += gendeps
324 endif
325
326 # only do the deps generation for makefiles that are properly marked.
327 ifneq "$(findstring __BUILD_STATIC_APPLICATION__, $(DEFINITIONS))" ""
328   # generate static build dependencies for all targets in the makefile.
329   GENERATED_DEPS_LIST = $(TARGETS:%.exe=%.gendeps)
330 endif
331
332 # Make sure that the directory for objects exists.
333 ACTUAL_FIRST_TARGETS = check_requirements $(EXTRA_FIRST_TARGETS) $(VERSION_TARGET) $(FIRST_TARGETS) pre_compilation
334
335 # Adds the primary targets to the list of products to create.
336 ifeq "$(NO_COMPILE)" ""
337   ifeq "$(OP_SYSTEM)" "UNIX"
338     ACTUAL_TARGETS1 = $(TARGETS:%.exe=$(EXECUTABLE_DIR)/%)
339   else
340     ACTUAL_TARGETS1 = $(TARGETS:%.exe=$(EXECUTABLE_DIR)/%.exe)
341   endif
342   ifeq "$(OP_SYSTEM)" "UNIX"
343     ACTUAL_TARGETS2 = $(ACTUAL_TARGETS1:%.dll=%.so)
344     ACTUAL_TARGETS3 = $(ACTUAL_TARGETS2:%.so=$(DYNAMIC_LIBRARY_DIR)/%$(TRIPART_VERSION).so)
345   else
346     ACTUAL_TARGETS2 = $(ACTUAL_TARGETS1:%.so=%.dll)
347     ACTUAL_TARGETS3 = $(ACTUAL_TARGETS2:%.dll=$(DYNAMIC_LIBRARY_DIR)/%$(TRIPART_VERSION).dll)
348   endif
349   ACTUAL_TARGETS4 = $(ACTUAL_TARGETS3:%.lib=$(STATIC_LIBRARY_DIR)/%$(TRIPART_VERSION).library)
350   ACTUAL_TARGETS = $(ACTUAL_TARGETS4:%.elf=$(EXECUTABLE_DIR)/%.elf)
351 else #is no_compile
352   ACTUAL_TARGETS1 = $(TARGETS:%.exe=)
353   ACTUAL_TARGETS2 = $(ACTUAL_TARGETS1:%.dll=)
354   ACTUAL_TARGETS3 = $(ACTUAL_TARGETS2:%.so=)
355   ACTUAL_TARGETS4 = $(ACTUAL_TARGETS3:%.lib=)
356   ACTUAL_TARGETS = $(ACTUAL_TARGETS4:%.elf=)
357 endif
358
359 # Adds the last few targets for CLAM to do.
360 ACTUAL_LAST_TARGETS = post_compilation $(LAST_TARGETS)
361
362 ############################################################################
363
364 # This section defines the rules used to generate various objects from their
365 # source files.
366
367 ############################################################################
368
369 # The first section provides simplistic pseudo-targets for testing compilation
370 # rather than generating built products.
371
372 # the blank target is used to (somewhat) safely remove items from the SOURCE
373 # list.  it is an empty file that should be able to go in a library archive
374 # without hosing it up.
375 %.nil:
376 ifeq "$(NO_COMPILE)" ""
377         $(CATCHER)$(CC) -c $(CLAM_DIR)/cpp/blank_target.c -o $@
378 endif
379
380 %.bad:
381         @echo There is a problem with the makefile in the SOURCE variable.
382         @echo The offending item is $@.
383         $(HIDESH)$(CLAM_DIR)/exit_make.sh
384
385 ## faked debug object.
386 #%.obj: %.cpp
387 #ifeq "$(NO_COMPILE)" ""
388 #       @echo Bogus [$@].
389 #       $(CATCHER)$(CC) $(COMPILER_FLAGS) -c $< $(OBJECT_NAME_FLAG)$(TEMP)/$@
390 #endif
391
392 # recreate dependencies for static applications.
393 %.gendeps: %.cpp
394         @echo "Generating Static Deps: $*.cpp"
395         $(HIDESH)$(CLAM_DIR)/cpp/buildor_gen_deps.sh "$*.cpp"
396
397 ############################################################################
398
399 # C++ source to object file translation.
400 # if there is a special set of flags for this source file, we use them
401 # instead of the default compiler flags.
402
403 $(OBJECT_DIR)/%.obj: $(CURRENT_DIR)/%.cpp
404 ifeq "$(NO_COMPILE)" ""
405   ifneq "$(COMPILER)" "VISUAL_CPP"
406         @echo Compiling [$(shell basename $@)].
407         $(HIDESH)-c 'if [ ! -d $(@D) ]; then mkdir $(@D); fi'
408         $(CATCHER)$(CC) $(COMPILER_FLAGS) -c $< $(OBJECT_NAME_FLAG)$@
409   else
410         @echo $< >>$(BUILD_LIST_FILE)
411         @echo $@ >>$(BUILD_WHACK_FILE)
412         @echo >$@
413   endif
414 endif
415
416 ############################################################################
417
418 # C source to object file translation.
419
420 $(OBJECT_DIR)/%.obj: $(CURRENT_DIR)/%.c
421 ifeq "$(NO_COMPILE)" ""
422   ifneq "$(COMPILER)" "VISUAL_CPP"
423         @echo Compiling [$@].
424         $(HIDESH)-c 'if [ ! -d $(@D) ]; then mkdir $(@D); fi'
425         $(CATCHER)$(CC) $(COMPILER_FLAGS) -c $< $(OBJECT_NAME_FLAG)$@
426   else
427         @echo $< >>$(BUILD_LIST_FILE)
428         @echo $@ >>$(BUILD_WHACK_FILE)
429         @echo >$@
430   endif
431 endif
432
433 ############################################################################
434
435 # resource compiler for win32.
436
437 ifeq "$(OP_SYSTEM)" "WIN32"
438 $(OBJECT_DIR)/%.res: %.rc $(PARAMETER_FILE)
439   ifeq "$(NO_COMPILE)" ""
440         @echo Resource [$@].
441         $(HIDESH)-c 'if [ ! -d $(@D) ]; then mkdir $(@D); fi'
442         $(CATCHER)$(RC) -r $(DEFINITIONS:%=-D%) $(HEADER_SEARCH_PATH:%=-i%) -fo $@ $<
443   endif
444
445 $(OBJECT_DIR)/%.resources: %.resx $(PARAMETER_FILE)
446   ifeq "$(NO_COMPILE)" ""
447         @echo Resource [$@].
448         $(HIDESH)-c 'if [ ! -d $(@D) ]; then mkdir $(@D); fi'
449         $(VCS_ROOT)/../SDK/v1.1/bin/resgen $< $@
450   endif
451 else #non-win32
452   # this platform probably does not use rc files.
453 $(OBJECT_DIR)/%.res: %.rc
454   ifeq "$(NO_COMPILE)" ""
455         @echo Bogus resource [$@].
456         @echo >$@
457   endif
458 endif #win32
459
460 ############################################################################
461
462 # creates static libraries.
463 ifneq "$(NO_COMPILE)" ""
464 $(STATIC_LIBRARY_DIR)/%.library:
465 endif
466
467 ifeq "$(NO_COMPILE)" ""
468 $(STATIC_LIBRARY_DIR)/%.library: $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)%$(LIB_ENDING)) $(PARAMETER_FILE)
469         $(HIDER)echo Static [$@].
470         @echo $@ >$(DIRTY_FILE)
471   ifeq "$(COMPILER)" "VISUAL_CPP"
472         $(HIDESH)-c 'if [ -f $(BUILD_LIST_FILE) ]; then $(SHELL) $(CLAM_DIR)/cpp/rebuild_oldies.sh $(MULTI_BUILD_CMD); fi'
473   endif
474         $(CATCHER)$(LIBRARY_TOOL) $(LIBRARIAN_FLAGS) $(CREATE_LIBRARY_FLAG)$@ $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%)
475   ifneq "$(OP_SYSTEM)" "UNIX"
476         $(HIDER)mv $@ $(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)$*$(LIB_ENDING)
477         $(HIDER)echo nil >$@
478   else
479         $(HIDER)ranlib $@ 
480         $(HIDER)rm -f $(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)$*$(LIB_ENDING)
481         $(HIDER)ln -s $@ $(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)$*$(LIB_ENDING)
482   endif
483 endif #no_compile
484
485 ############################################################################
486
487 # creates dynamic libraries.
488
489 # we whack any existing LIB file, since we want to use changes in that file
490 # as a clue for when we should rescan the dependencies.  we'd be fine if
491 # visual c++ didn't keep an existing LIB if it doesn't change (even when the
492 # DLL does).
493
494 ifneq "$(NO_COMPILE)" ""
495 $(DYNAMIC_LIBRARY_DIR)/%.dll:
496 endif
497
498 ifeq "$(NO_COMPILE)" ""
499 $(DYNAMIC_LIBRARY_DIR)/%.dll: $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)%$(LIB_ENDING)) $(ACTUAL_RESX) $(PARAMETER_FILE) 
500 #hmmm: use the res objects variable to rebuild res files as needed.
501 ###$(RES_OBJECTS) 
502         $(HIDER)echo Dynamic [$@].
503         @echo $@ >$(DIRTY_FILE)
504   ifeq "$(COMPILER)" "VISUAL_CPP"
505         $(HIDESH)-c 'if [ -f $(BUILD_LIST_FILE) ]; then $(SHELL) $(CLAM_DIR)/cpp/rebuild_oldies.sh $(MULTI_BUILD_CMD); fi'
506   endif
507         $(HIDER)rm -f $(@:%.dll=%.lib)
508         $(CATCHER)$(LINK_TOOL) $(LINKER_OUTPUT_FLAG)$@ -dll $(LOAD_FLAG_PREFIX) $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_RESX_FLAGS) $(ACTUAL_LOCAL_LIBS:%=$(LIBRARY_NAME_FLAG)$(LIB_PREFIX)%$(LIB_ENDING)) $(LOAD_FLAG_SUFFIX)
509   ifeq "$(COMPILER_VERSION)" "8"
510         $(HIDESH)$(CLAM_DIR)/cpp/ms_manifest.sh "$@" "2"
511   endif
512   ifeq "$(COMPILER_VERSION)" "10"
513         $(HIDESH)$(CLAM_DIR)/cpp/ms_manifest.sh "$@" "2"
514   endif
515   ifneq "$(VCPP_VISTA_ICON)" ""
516         $(HIDER)ReplaceVistaIcon "$@" "$(VCPP_VISTA_ICON)"
517   endif
518 endif #no_compile
519
520 ifneq "$(NO_COMPILE)" ""
521 $(DYNAMIC_LIBRARY_DIR)/%.so:
522 endif
523
524 ifeq "$(NO_COMPILE)" ""
525 $(DYNAMIC_LIBRARY_DIR)/%.so: $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)%$(LIB_ENDING)) $(PARAMETER_FILE)
526   ifeq "$(COMPILER:%_LINUX=LINUX)" "LINUX"
527         $(HIDER)echo Shared [$@].
528         @echo $@ >$(DIRTY_FILE)
529         $(CATCHER)$(LINK_TOOL) $(LINKER_OUTPUT_FLAG)$@ $(LOAD_FLAG_PREFIX) -shared -Wl,-soname,$*.so $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(LIBRARY_NAME_FLAG)%) $(LOAD_FLAG_SUFFIX) 
530         $(HIDER)rm -f $(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)$*$(LIB_ENDING)
531         $(HIDER)ln -s $@ $(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)$*$(LIB_ENDING)
532   endif
533 endif #no_compile
534
535 ############################################################################
536
537 # creates "exe" executables using all of the appropriate objects.
538
539 ifeq "$(OP_SYSTEM)" "WIN32"
540   ifneq "$(NO_COMPILE)" ""
541 $(EXECUTABLE_DIR)/%.exe:
542   endif
543
544   ifeq "$(NO_COMPILE)" ""
545 $(EXECUTABLE_DIR)/%.exe: $(OBJECT_DIR)/%.obj $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)%$(LIB_ENDING)) $(ACTUAL_RESX) $(PARAMETER_FILE)
546         $(HIDER)echo Application [$@].
547         @echo $@ >$(DIRTY_FILE)
548     ifeq "$(COMPILER)" "VISUAL_CPP"
549         $(HIDESH)-c 'if [ -f $(BUILD_LIST_FILE) ]; then $(SHELL) $(CLAM_DIR)/cpp/rebuild_oldies.sh $(MULTI_BUILD_CMD); fi'
550     endif
551         $(CATCHER)$(LINK_TOOL) $(EXE_FLAGS) $(LOAD_FLAG_PREFIX) $< $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_RESX_FLAGS) $(ACTUAL_LOCAL_LIBS:%=$(LIBRARY_NAME_FLAG)$(LIB_PREFIX)%$(LIB_ENDING)) $(LOAD_FLAG_SUFFIX) $(LINKER_OUTPUT_FLAG)$@
552 #$(^:force_rebuild=) 
553     ifeq "$(COMPILER_VERSION)" "8"
554         $(HIDESH)$(CLAM_DIR)/cpp/ms_manifest.sh "$@" "1"
555     endif
556     ifeq "$(COMPILER_VERSION)" "10"
557         $(HIDESH)$(CLAM_DIR)/cpp/ms_manifest.sh "$@" "1"
558     endif
559     ifneq "$(VCPP_VISTA_ICON)" ""
560         $(HIDER)ReplaceVistaIcon "$@" "$(VCPP_VISTA_ICON)"
561     endif
562   endif #no_compile
563 endif #win32
564
565 ifeq "$(OP_SYSTEM)" "UNIX"
566   ifneq "$(NO_COMPILE)" ""
567 $(EXECUTABLE_DIR)/%:
568   endif
569
570   ifeq "$(NO_COMPILE)" ""
571 $(EXECUTABLE_DIR)/%: $(OBJECT_DIR)/%.obj $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)%$(LIB_ENDING)) $(PARAMETER_FILE)
572         $(HIDER)echo Application [$@].
573         @echo $@ >$(DIRTY_FILE)
574         $(CATCHER)$(LINK_TOOL) $(EXE_FLAGS) $(LOAD_FLAG_PREFIX) $< $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(LIBRARY_NAME_FLAG)%) $(LOAD_FLAG_SUFFIX) $(LINKER_OUTPUT_FLAG)$@
575 #hmmm: experimental item below.
576 #$(^:force_rebuild=) 
577   endif #no_compile
578 endif #unix
579
580 ############################################################################
581
582 # creates firmware "elf" executables with the proper objects.
583
584 ifneq "$(NO_COMPILE)" ""
585 $(EXECUTABLE_DIR)/%.elf:
586 endif
587
588 ifeq "$(NO_COMPILE)" ""
589 $(EXECUTABLE_DIR)/%.elf: $(OBJECT_DIR)/%.obj $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)%$(LIB_ENDING)) $(PARAMETER_FILE)
590         $(HIDER)echo Application [$@].
591         @echo $@ >$(DIRTY_FILE)
592         $(CATCHER)$(LINK_TOOL) $(MAP) $(LOAD_FLAG_PREFIX) $< $(LINKER_COMMAND_FILE) $(STARTUP_OBJECT_FILE) $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(LIBRARY_NAME_FLAG)%) $(LOAD_FLAG_SUFFIX) $(LINKER_OUTPUT_FLAG)$@
593 #$(^:force_rebuild=) 
594         @echo Hex [$(EXECUTABLE_DIR)/$*.out].
595         $(CATCHER)$(DDUMP_TOOL) $(DDUMP_OPTIONS) $@ -o$(EXECUTABLE_DIR)/$*.out
596         @echo Binary [$(EXECUTABLE_DIR)/$*.bin].
597         $(CATCHER)$(DDUMP_TOOL) $(DDUMP_BIN_OPTIONS) $@ -o$(EXECUTABLE_DIR)/$*.bin
598 endif #no_compile
599
600 ############################################################################
601
602 # handles creating version resource files if this project has a version.ini.
603
604 ifeq "$(OMIT_VERSIONS)" ""
605   ifneq "$(VERSION_RC_ROOT)" ""
606 # only redo the version resource if it or version.ini is out of date.
607 %_version.rc: version.ini $(PARAMETER_FILE)
608         $(CATCHER)$(CLAM_BIN)/version_stamper$(EXE_END) . $(PARAMETER_FILE)
609   endif
610 endif
611
612 ############################################################################
613
614 # Now the active part of the make process...
615
616 # Adds the main CLAM system in to get some work done.  This should be placed
617 # after the module's rules are defined and before the module's targets are
618 # defined.
619 include rules.def
620
621 # make sure we really want to include the dependencies file.
622 ifeq "$(TYPE)" "hierarchy"
623   # no dependencies for a simple hierarchy builder.
624   NO_DEPS = t
625 endif
626 ifneq "$(CLEAN)" ""
627   NO_DEPS = t
628   # no dependencies get left when we are cleaning up.
629   $(shell rm -f $(DEPS_FILE))
630 endif
631 ifneq "$(NO_COMPILE)" ""
632   # non compiling projects do not need dependencies.
633   NO_DEPS = t
634 endif
635 ifneq "$(REBUILD)" ""
636   NO_DEPS = t
637   # if we are rebuilding everything, we zap the deps file.
638   $(shell rm -f $(DEPS_FILE))
639 endif
640
641 # includes the auto-dependency information.  the dependency file is checked
642 # for being up-to-date.  if not, it gets rebuilt and the make is restarted.
643 ifeq "$(NO_DEPS)" ""
644   include $(DEPS_FILE)
645 endif
646
647 # preserves intermediate files from being deleted.
648 ifeq "$(CLEAN)" ""
649 .PRECIOUS: $(OBJECT_DIR)/%.obj $(OBJECT_DIR)/%.res $(OBJECT_DIR)/%.resources
650 endif
651
652 # zaps things when they could not be created correctly.
653 ####.DELETE_ON_ERROR:
654
655 ############################################################################
656
657 # autodependency file creator.  See the make_dep man page for more info.
658
659 # we do the auto-dependencies unless the disabling flag is set.
660 ifneq "$(NO_DEPS)" ""
661     # makes the dependencies a no-op.
662     deps: $(PARAMETER_FILE)
663
664     $(DEPS_FILE): $(PARAMETER_FILE)
665
666 else
667   deps: $(DEPS_FILE)
668
669   # this causes the dependency file to be regenerated if the sources or libs
670   # have changed.  we have to touch the deps file in case it's missing;
671   # makedep doesn't deal well with that.  also, we touch the dirty flag file
672   # to ensure that the fact we redid dependencies for some reason causes us
673   # to re-promote.  we only bother with any of this if we know we're going
674   # to really do some compilation; if in non-compile mode, we'll skip it.
675   ifneq "$(NO_COMPILE)" ""
676     # no dependencies in non-compile mode.
677     $(DEPS_FILE):
678
679   else
680     ifeq "$(LAX_DEPENDENCIES)" ""
681       $(DEPS_FILE): $(SOURCE) $(ACTUAL_LOCAL_LIBS:%=$(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)%$(LIB_ENDING)) $(wildcard *.h) $(EXE_CPPS)
682     else  # lax dependencies means create if missing or if parm file changed.
683       $(DEPS_FILE): $(PARAMETER_FILE)
684     endif # !lax dependencies.
685     ifneq "$(VERSION_RC_ROOT)" ""
686       ifeq "$(OMIT_VERSIONS)" ""
687         $(DEPS_FILE): $(VERSION_RC_ROOT)_version.rc
688       endif
689     endif
690         @echo Dependencies [$(shell basename $@)].
691         -$(HIDESH)$(CLAM_DIR)/cpp/preconditions.sh
692         @touch $@
693 #       @echo dep adds: $(DEPENDENCY_ADDITIONS)
694         @echo clam bin here is $(CLAM_BIN)
695         @$(CLAM_BIN)/makedep$(EXE_END) $(DEPENDENCY_DEFINITIONS:%=-D%) $(DEPENDENCY_ADDITIONS) -f$@ -o.obj -p$(OBJECT_DIR)/ -w 420 $(COMPILER_HEADER_DIR:%=-X%) $(THIRD_PARTY_DIR:%=-X%) -- $(COMPILER_FLAGS) $(SOURCE) $(EXE_CPPS)
696 #       $(CATCHER)$(CLAM_BIN)/makedep$(EXE_END) $(DEPENDENCY_DEFINITIONS:%=-D%) $(DEPENDENCY_ADDITIONS) -f$@ -o.obj -p$(OBJECT_DIR)/ -w 420 $(COMPILER_HEADER_DIR:%=-X%) $(THIRD_PARTY_DIR:%=-X%) -- $(COMPILER_FLAGS) $(SOURCE) $(EXE_CPPS)
697         @echo $@ >$(SUBMAKE_FLAG)
698   endif # non-compile.
699 endif # no-deps.
700
701 ############################################################################
702
703 # examines the required variables and complains if they're missing.
704 check_requirements:
705         $(HIDESH) -c 'if [ -z "$(PROJECT)" ]; then echo the PROJECT variable is not defined!; . $(CLAM_DIR)/exit_make.sh; fi'
706         $(HIDESH) -c 'if [ -z "$(TYPE)" ]; then echo the TYPE variable is not defined!; . $(CLAM_DIR)/exit_make.sh; fi'
707  
708 ############################################################################
709
710 # calls the script for preparing output directories and such.
711 pre_compilation:
712         $(HIDESH)$(CLAM_DIR)/cpp/preconditions.sh
713
714 ############################################################################
715
716 # calls the script for copying the final products to the library directory.
717 # we don't bother reporting errors from touch since there will sometimes
718 # not be any objects in the final directory.
719 post_compilation:
720         $(HIDESH)$(CLAM_DIR)/cpp/postconditions.sh
721
722 ############################################################################
723
724 # if REBUILD is defined, then we cause all objects to be recompiled.
725 .PHONY: force_rebuild
726 force_rebuild:
727
728 ifneq "$(REBUILD)" ""
729   # the target below needs the blank rule that it has for this to work.
730   $(FIRST_TARGETS) $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_TARGETS) $(EXE_CPPS:%.cpp=$(OBJECT_DIR)/%.obj) $(LAST_TARGETS): force_rebuild
731 endif
732
733 ############################################################################
734
735 # generate dependencies for any static targets if requested.
736 gendeps: $(GENERATED_DEPS_LIST)
737
738 ############################################################################
739