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