clam changes tossing out old visual studio schlubs
[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 Makefile after the variables
9 # have been initialized appropriately for the particular project being
10 # compiled.  The user 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 LOAD_FLAG_PREFIX += -lwsock32 -lmswsock -shared
96
97   ifneq "$(USE_CURL)" ""
98     COMPILER_FLAGS += `curl-config --cflags`
99     LOAD_FLAG_SUFFIX += `curl-config --libs`
100   endif
101
102 endif
103
104 ###############################################################################
105
106 ifeq "$(COMPILER)" "GNU_DARWIN"
107   # finds the crypto code on macos.
108   HEADER_SEARCH_PATH += /usr/local/opt/openssl/include
109   LIBRARY_SEARCH_PATH += /usr/local/opt/openssl/lib/
110
111   ifneq "$(USE_XWIN)" ""
112     DEFINITIONS += __XWINDOWS__ __X__
113     LIBS_USED += 
114 #Xm Xt X11 Xft Xp 
115 #need to separate out with a USE_MOTIF kind of thing.
116 #LIBS_USED += Xmu
117     HEADER_SEARCH_PATH += /usr/include/X11 /usr/X11R6/include /usr/include/g++
118     LIBRARY_SEARCH_PATH += /usr/X11R6/lib
119   endif
120
121   ifneq "$(USE_SSL)" ""
122     LIBS_USED += crypto ssl
123   endif
124   
125   ifneq "$(USE_WXWIDGETS)" ""
126     DEFINITIONS += __WXWIDGETS__ 
127     use_unicode =
128     ifneq "$(findstring UNICODE, $(DEFINITIONS))" ""
129         use_unicode = true
130     endif
131
132     # decide whether to turn on the unicode flag or not.
133 ###    ifneq "$(findstring UNICODE, $(DEFINITIONS))" ""
134     ifneq "$(use_unicode)" ""
135       UNICODE_FLAG_ADD = --unicode=yes
136       DEFINITIONS += wxUSE_UNICODE
137     else
138       UNICODE_FLAG_ADD = --unicode=no
139     endif
140
141     COMPILER_FLAGS += $(shell wx-config --cxxflags $(UNICODE_FLAG_ADD) )
142     LOAD_FLAG_PREFIX += $(shell wx-config --libs $(UNICODE_FLAG_ADD) )
143   endif
144
145   ifneq "$(USE_CURL)" ""
146     COMPILER_FLAGS += `curl-config --cflags`
147     LOAD_FLAG_SUFFIX += `curl-config --libs`
148   endif
149
150 endif
151
152 ###############################################################################
153
154 # Create the real list of local libraries needed.
155 TEMP_LOC1 = $(LOCAL_LIBS_USED:%=%$(TRIPART_VERSION))
156 ACTUAL_LOCAL_LIBS = $(TEMP_LOC1)
157
158 # Create the list of objects from the list of source files.
159 TEMP_OBJ1 = $(SOURCE:%.cpp=%.obj)
160 TEMP_OBJ2 = $(TEMP_OBJ1:%.c=%.obj)
161
162 # replace this when supporting resource files on unix.
163 TEMP_OBJ3 = $(TEMP_OBJ2:%.rc=)
164
165 TEMP_OBJ4 = $(TEMP_OBJ3:%.h=%.bad)
166 OBJECTS = $(TEMP_OBJ4)
167
168 # special case for multi-build and res files that need to be rebuilt.
169 #RES_OBJECTS_0 = $(SOURCE:%.cpp=)
170 #RES_OBJECTS_1 = $(RES_OBJECTS_0:%.c=)
171 #RES_OBJECTS = $(RES_OBJECTS_1:%.rc=$(OBJECT_DIR)/%.res)
172
173 # not much conversion anymore...
174 ACTUAL_OBJECTS = $(OBJECTS) $(EXTRA_OBJECTS)
175
176 # Updates the search path for the compiler and local libraries.
177 BASE_HEADER_PATH = $(CODEBASE_HEADERS) $(LOCAL_HEADERS) $(HOOPLE_HEADERS) $(SEARCH_DIRS)
178 HEADER_SEARCH_PATH += $(BASE_HEADER_PATH) $(COMPILER_HEADER_DIR)
179
180 LIBRARY_SEARCH_PATH += $(LOCAL_LIBRARIES) $(HOOPLE_LIBRARIES) \
181   $(STATIC_LIBRARY_DIR) $(COMPILER_LIBRARY_DIR) $(SEARCH_DIRS)
182
183 # Adds some directories that must be searched onto the search path for
184 # header files, such as the header file directory for the compiler.
185 COMPILER_FLAGS += $(HEADER_SEARCH_PATH:%=-I%) $(DEFINITIONS:%=-D%) $(UNDEFINITIONS:%=-U%) -DGLOBAL_PRODUCT_NAME="$(GLOBAL_PRODUCT_NAME)"
186
187 # The load flags are updated by looking for code libraries in the directories
188 # to search and by adding all of the code libraries that are used.
189 LOAD_FLAG_PREFIX += $(LIBRARY_SEARCH_PATH:%=$(LIBRARY_PATH_FLAG)%)
190 ifeq "$(OP_SYSTEM)" "UNIX"
191   ifneq "$(COMPILER)" "GNU_DARWIN"
192     LOAD_FLAG_PREFIX += -Xlinker --start-group
193     LOAD_FLAG_SUFFIX += -Xlinker --end-group
194   endif
195 endif
196 # had to switch from prefix to suffix recently.  oddity.
197 #LOAD_FLAG_PREFIX += $(LIBS_USED:%=$(LIBRARY_NAME_FLAG)%)
198 LOAD_FLAG_SUFFIX += $(LIBS_USED:%=$(LIBRARY_NAME_FLAG)%)
199
200 # we steal the exe targets and represent their dependency from the hidden
201 # cpp for the exe.
202 EXE_TEMP_0 = $(TARGETS:%.dll=)
203 EXE_TEMP_1 = $(EXE_TEMP_0:%.so=)
204 EXE_TEMP_2 = $(EXE_TEMP_1:%.lib=)
205 EXE_TEMP_3 = $(EXE_TEMP_2:%.elf=%.cpp)
206 EXE_CPPS   = $(EXE_TEMP_3:%.exe=%.cpp)
207
208 # used for compiling multiple source files at the same time with visual cpp.
209 MULTI_BUILD_CMD = $(CC) $(COMPILER_FLAGS) -c `cat $(BUILD_LIST_FILE)` $(OBJECT_NAME_FLAG)$(OBJECT_DIR)/
210
211 ifeq "$(OMIT_VERSIONS)" ""
212   ifneq "$(VERSION_RC_ROOT)" ""
213     VERSION_TARGET = $(VERSION_RC_ROOT)_version.rc
214   endif
215 endif
216
217 # if we are cleaning up, then do not generate dependency file.
218 ifeq "$(CLEAN)" ""
219   ifneq "$(GENDEPS)" ""
220     EXTRA_FIRST_TARGETS += gendeps
221   endif
222
223 # only do the deps generation for makefiles that are properly marked.
224 ifneq "$(findstring __BUILD_STATIC_APPLICATION__, $(DEFINITIONS))" ""
225   # generate static build dependencies for all targets in the makefile.
226   GENERATED_DEPS_LIST = $(TARGETS:%.exe=%.gendeps)
227 else
228   GENERATED_DEPS_LIST =
229 endif
230
231 endif
232
233 # Make sure that the directory for objects exists.
234 ACTUAL_FIRST_TARGETS = check_requirements $(EXTRA_FIRST_TARGETS) $(VERSION_TARGET) $(FIRST_TARGETS) pre_compilation
235
236 # Adds the primary targets to the list of products to create.
237 #ifeq "$(NO_COMPILE)" ""
238
239   ifneq "$(OP_SYSTEM)" "WIN32"
240     ACTUAL_TARGETS1 = $(TARGETS:%.exe=$(EXECUTABLE_DIR)/%)
241   else
242     ACTUAL_TARGETS1 = $(TARGETS:%.exe=$(EXECUTABLE_DIR)/%.exe)
243   endif
244
245   ifneq "$(OP_SYSTEM)" "WIN32"
246     ACTUAL_TARGETS2 = $(ACTUAL_TARGETS1:%.dll=%.so)
247     ACTUAL_TARGETS3 = $(ACTUAL_TARGETS2:%.so=$(DYNAMIC_LIBRARY_DIR)/%$(TRIPART_VERSION).so)
248   else
249     ACTUAL_TARGETS2 = $(ACTUAL_TARGETS1:%.so=%.dll)
250     ACTUAL_TARGETS3 = $(ACTUAL_TARGETS2:%.dll=$(DYNAMIC_LIBRARY_DIR)/%$(TRIPART_VERSION).dll)
251   endif
252
253   ACTUAL_TARGETS4 = $(ACTUAL_TARGETS3:%.lib=$(STATIC_LIBRARY_DIR)/%$(TRIPART_VERSION).library)
254   ACTUAL_TARGETS = $(ACTUAL_TARGETS4:%.elf=$(EXECUTABLE_DIR)/%.elf)
255
256 #else #is no_compile
257 #  ACTUAL_TARGETS1 = $(TARGETS:%.exe=)
258 #  ACTUAL_TARGETS2 = $(ACTUAL_TARGETS1:%.dll=)
259 #  ACTUAL_TARGETS3 = $(ACTUAL_TARGETS2:%.so=)
260 #  ACTUAL_TARGETS4 = $(ACTUAL_TARGETS3:%.lib=)
261 #  ACTUAL_TARGETS = $(ACTUAL_TARGETS4:%.elf=)
262 #endif
263
264 # Adds the last few targets for CLAM to do.
265 ACTUAL_LAST_TARGETS = post_compilation $(LAST_TARGETS)
266
267 ############################################################################
268
269 # This section defines the rules used to generate various objects from their
270 # source files.
271
272 ############################################################################
273
274 # The first section provides simplistic pseudo-targets for testing compilation
275 # rather than generating built products.
276
277 # the blank target is used to (somewhat) safely remove items from the SOURCE
278 # list.  it is an empty file that should be able to go in a library archive
279 # without hosing it up.
280 %.nil:
281 ifeq "$(NO_COMPILE)" ""
282         $(CATCHER)$(CC) -c $(CLAM_SCRIPTS)/cpp/blank_target.c -o $@
283 endif
284
285 %.bad:
286         @echo There is a problem with the makefile in the SOURCE variable.
287         @echo The offending item is: $@
288         $(HIDESH)$(CLAM_SCRIPTS)/exit_make.sh
289
290 ## faked debug object.
291 #%.obj: %.cpp
292 #ifeq "$(NO_COMPILE)" ""
293 #       @echo Bogus [$@].
294 #       $(CATCHER)$(CC) $(COMPILER_FLAGS) -c $< $(OBJECT_NAME_FLAG)$(TEMP)/$@
295 #endif
296
297 ifeq "$(CLEAN)" ""
298 # recreate dependencies for static applications.
299 %.gendeps: %.cpp
300         @echo "Generating Static Deps: $*.cpp"
301         $(CATCHER)$(CLAM_SCRIPTS)/cpp/buildor_gen_deps.sh "$*.cpp"
302 endif
303
304 ############################################################################
305
306 # trying to delay loading this as long as possible so the built in rule system for CLEANUPS can run with the right values.
307 # so far not working right!
308 #hmmm: fix this.
309
310 # Adds the main CLAM system in to get some work done.  This should be placed
311 # after the module rules are defined and before the module targets are
312 # defined.
313 include rules.def
314
315 ############################################################################
316
317 # this adds in a customization for the cleanup variables, since the base
318 # clam code has no idea about a dynamic library directory.
319
320 cpp_add_to_cleanups_variable:
321 #       echo here is actual targets before hand $(ACTUAL_TARGETS)
322         $(eval CLEANUPS = $(ACTUAL_TARGETS:%.exe=%) $(ACTUAL_TARGETS:$(STATIC_LIBRARY_DIR)/%.library=$(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)%.a) $(CLEANUPS) )
323 #       echo "IN CPP, new CLEANUPS variable: $(CLEANUPS)"
324 #fodder for anything missing a cleanup.
325 #       $(eval CLEANUPS = $(ACTUAL_TARGETS) $(ACTUAL_TARGETS:%.dll=%.so) $(ACTUAL_TARGETS:%.so=%.dll) $(CLEANUPS) )
326
327 #dynamic is taken care of in clam base still?
328 #DYNAMIC_LIBRARY_DIR
329 #hmmm: still should change there in the base and do it
330 # here instead.
331
332 ############################################################################
333
334 # C++ source to object file translation.
335 # if there is a special set of flags for this source file, we use them
336 # instead of the default compiler flags.
337
338 $(OBJECT_DIR)/%.obj: $(CURRENT_DIR)/%.cpp
339 ifeq "$(NO_COMPILE)" ""
340         @echo Compiling Object [$(notdir $@)]
341         $(HIDESH)-c 'if [ ! -d $(@D) ]; then mkdir $(@D); fi'
342         $(CATCHER)$(CC) $(COMPILER_FLAGS) -c $< $(OBJECT_NAME_FLAG)$@
343 endif
344
345 ############################################################################
346
347 # C source to object file translation.
348
349 $(OBJECT_DIR)/%.obj: $(CURRENT_DIR)/%.c
350 ifeq "$(NO_COMPILE)" ""
351         @echo Compiling Object [$(notdir $@)]
352         $(HIDESH)-c 'if [ ! -d $(@D) ]; then mkdir $(@D); fi'
353         $(CATCHER)$(CC) $(COMPILER_FLAGS) -c $< $(OBJECT_NAME_FLAG)$@
354 endif
355
356 ############################################################################
357
358 # resource compiler for win32.
359
360 # we currently do not use rc files.
361 $(OBJECT_DIR)/%.res: %.rc
362   ifeq "$(NO_COMPILE)" ""
363         @echo Bogus resource [$@]
364         @echo >$@
365   endif
366
367 ############################################################################
368
369 # creates static libraries.
370 ifneq "$(NO_COMPILE)" ""
371 $(STATIC_LIBRARY_DIR)/%.library:
372 endif
373
374 ifeq "$(NO_COMPILE)" ""
375 $(STATIC_LIBRARY_DIR)/%.library: $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)%$(LIB_ENDING)) $(PARAMETER_FILE)
376         $(HIDER)echo Building Static Library [$(notdir $@)]
377         @echo $@ >$(DIRTY_FILE)
378         $(CATCHER)$(LIBRARY_TOOL) $(LIBRARIAN_FLAGS) $(CREATE_LIBRARY_FLAG)$@ $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%)
379   ifneq "$(OP_SYSTEM)" "UNIX"
380         $(HIDER)mv $@ $(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)$*$(LIB_ENDING)
381         $(HIDER)echo nil >$@
382   else
383         $(HIDER)ranlib $@ 
384         $(HIDER)rm -f $(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)$*$(LIB_ENDING)
385         $(HIDER)ln -s $@ $(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)$*$(LIB_ENDING)
386   endif
387 endif #no_compile
388
389 ############################################################################
390
391 # creates dynamic libraries.
392
393 # we whack any existing LIB file, since we want to use changes in that file
394 # as a clue for when we should rescan the dependencies.  we'd be fine if
395 # visual c++ didn't keep an existing LIB if it does not change (even when the
396 # DLL does).
397
398 ifneq "$(NO_COMPILE)" ""
399 $(DYNAMIC_LIBRARY_DIR)/%.dll:
400 endif
401
402 ifeq "$(NO_COMPILE)" ""
403 $(DYNAMIC_LIBRARY_DIR)/%.dll: $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)%$(LIB_ENDING)) $(ACTUAL_RESX) $(PARAMETER_FILE) 
404         $(HIDER)echo Building Dynamic Library [$(notdir $@)]
405         @echo $@ >$(DIRTY_FILE)
406         $(HIDER)rm -f $(@:%.dll=%.lib)
407         echo about to run link tool.
408         $(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)
409         echo ran link tool.
410   ifeq "$(COMPILER_VERSION)" "8"
411         $(HIDESH)$(CLAM_SCRIPTS)/cpp/ms_manifest.sh "$@" "2"
412   endif
413   ifeq "$(COMPILER_VERSION)" "10"
414         $(HIDESH)$(CLAM_SCRIPTS)/cpp/ms_manifest.sh "$@" "2"
415   endif
416   ifneq "$(VCPP_VISTA_ICON)" ""
417         $(HIDER)ReplaceVistaIcon "$@" "$(VCPP_VISTA_ICON)"
418   endif
419 endif #no_compile
420
421 ifneq "$(NO_COMPILE)" ""
422 $(DYNAMIC_LIBRARY_DIR)/%.so:
423 endif
424
425 ifeq "$(NO_COMPILE)" ""
426 $(DYNAMIC_LIBRARY_DIR)/%.so: $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)%$(LIB_ENDING)) $(PARAMETER_FILE)
427   ifeq "$(COMPILER:%_LINUX=LINUX)" "LINUX"
428         $(HIDER)echo Shared [$@]
429         @echo $@ >$(DIRTY_FILE)
430         $(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) 
431         $(HIDER)rm -f $(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)$*$(LIB_ENDING)
432         $(HIDER)ln -s $@ $(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)$*$(LIB_ENDING)
433   endif
434 endif #no_compile
435
436 ############################################################################
437
438 # creates "exe" executables using all of the appropriate objects.
439
440 ifneq "$(NO_COMPILE)" ""
441 $(EXECUTABLE_DIR)/%:
442 endif
443
444 ifeq "$(NO_COMPILE)" ""
445 $(EXECUTABLE_DIR)/%: $(OBJECT_DIR)/%.obj $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)%$(LIB_ENDING)) $(PARAMETER_FILE)
446         $(HIDER)echo Building Application [$(notdir $@)]
447         @echo $@ >$(DIRTY_FILE)
448         $(CATCHER)$(LINK_TOOL) $(EXE_FLAGS) $(LOAD_FLAG_PREFIX) $< $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(LIBRARY_NAME_FLAG)%) $(LOAD_FLAG_SUFFIX) $(LINKER_OUTPUT_FLAG)$@
449 #hmmm: experimental item below.
450 #$(^:force_rebuild=) 
451 endif #no_compile
452
453 ############################################################################
454
455 # creates firmware "elf" executables with the proper objects.
456
457 ifneq "$(NO_COMPILE)" ""
458 $(EXECUTABLE_DIR)/%.elf:
459 endif
460
461 ifeq "$(NO_COMPILE)" ""
462 $(EXECUTABLE_DIR)/%.elf: $(OBJECT_DIR)/%.obj $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_LOCAL_LIBS:%=$(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)%$(LIB_ENDING)) $(PARAMETER_FILE)
463         $(HIDER)echo Building Application [$(notdir $@)]
464         @echo $@ >$(DIRTY_FILE)
465         $(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)$@
466 #$(^:force_rebuild=) 
467         @echo Hex [$(EXECUTABLE_DIR)/$*.out]
468         $(CATCHER)$(DDUMP_TOOL) $(DDUMP_OPTIONS) $@ -o$(EXECUTABLE_DIR)/$*.out
469         @echo Binary [$(EXECUTABLE_DIR)/$*.bin]
470         $(CATCHER)$(DDUMP_TOOL) $(DDUMP_BIN_OPTIONS) $@ -o$(EXECUTABLE_DIR)/$*.bin
471 endif #no_compile
472
473 ############################################################################
474
475 # handles creating version resource files if this project has a version.ini.
476
477 ifeq "$(OMIT_VERSIONS)" ""
478   ifneq "$(VERSION_RC_ROOT)" ""
479 # only redo the version resource if it or version.ini is out of date.
480 %_version.rc: version.ini $(PARAMETER_FILE)
481         $(CATCHER)$(CLAM_BINARIES)/version_stamper$(EXE_END) . $(FEISTY_MEOW_GENERATED_STORE)/versions $(PARAMETER_FILE)
482   endif
483 endif
484
485 ############################################################################
486
487 # Now the active part of the make process...
488
489 # make sure we really want to include the dependencies file.
490 ifeq "$(TYPE)" "hierarchy"
491   # no dependencies for a simple hierarchy builder.
492   NO_DEPS = t
493 endif
494 ifneq "$(CLEAN)" ""
495   NO_DEPS = t
496   # no dependencies get left when we are cleaning up.
497 #  $(shell rm -f $(DEPS_FILE))
498 endif
499 ifneq "$(NO_COMPILE)" ""
500   # non compiling projects do not need dependencies.
501   NO_DEPS = t
502 endif
503 ifneq "$(REBUILD)" ""
504   NO_DEPS = t
505   # if we are rebuilding everything, we zap the deps file.
506   $(shell rm -f $(DEPS_FILE))
507 endif
508
509 # preserves intermediate files from being deleted.
510 ifeq "$(CLEAN)" ""
511 .PRECIOUS: $(OBJECT_DIR)/%.obj $(OBJECT_DIR)/%.res $(OBJECT_DIR)/%.resources $(OBJECT_DIR)/%.deps
512 #hmmm: added above deps.  maybe not right.
513 endif
514
515 # zaps things when they could not be created correctly.
516 ####.DELETE_ON_ERROR:
517
518 ############################################################################
519
520 # autodependency file creator.  See the make_dep man page for more info.
521
522 # we do the auto-dependencies unless the disabling flag is set.
523 ifneq "$(NO_DEPS)" ""
524     # makes the dependencies a no-op.
525     deps: $(PARAMETER_FILE)
526
527     $(DEPS_FILE): $(PARAMETER_FILE)
528
529 else
530   ifeq "$(CLEAN)" ""
531   deps: $(DEPS_FILE)
532
533   # this causes the dependency file to be regenerated if the sources or libs
534   # have changed.  we have to touch the deps file in case it is missing;
535   # makedep does not deal well with that.  also, we touch the dirty flag file
536   # to ensure that the fact we redid dependencies for some reason causes us
537   # to re-promote.  we only bother with any of this if we know we are going
538   # to really do some compilation; if in non-compile mode, we'll skip it.
539   ifneq "$(NO_COMPILE)" ""
540     # no dependencies in non-compile mode.
541     $(DEPS_FILE):
542
543   else
544     ifeq "$(LAX_DEPENDENCIES)" ""
545       $(DEPS_FILE): $(SOURCE) $(ACTUAL_LOCAL_LIBS:%=$(STATIC_LIBRARY_DIR)/$(LIB_PREFIX)%$(LIB_ENDING)) $(wildcard *.h) $(EXE_CPPS)
546     else  # lax dependencies means create if missing or if parm file changed.
547       $(DEPS_FILE): $(PARAMETER_FILE)
548     endif # !lax dependencies.
549     ifneq "$(VERSION_RC_ROOT)" ""
550       ifeq "$(OMIT_VERSIONS)" ""
551         $(DEPS_FILE): $(VERSION_RC_ROOT)_version.rc
552       endif
553     endif
554         @echo Dependencies [$(notdir $@)]
555         -$(HIDESH)$(CLAM_SCRIPTS)/cpp/preconditions.sh
556         @touch $@
557 #       @echo dep adds: $(DEPENDENCY_ADDITIONS)
558         @$(CLAM_BINARIES)/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)
559 #       $(CATCHER)$(CLAM_BINARIES)/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)
560         @echo $@ >$(SUBMAKE_FLAG)
561   endif # non-compile.
562  else # cleaning.
563     # makes the dependencies a no-op for cleaning.
564     deps: $(PARAMETER_FILE)
565
566     $(DEPS_FILE): $(PARAMETER_FILE)
567  endif
568 endif # no-deps.
569
570 ############################################################################
571
572 # examines the required variables and complains if they are missing.
573 check_requirements:
574         $(HIDESH) -c 'if [ -z "$(PROJECT)" ]; then echo the PROJECT variable is not defined!; . $(CLAM_SCRIPTS)/exit_make.sh; fi'
575         $(HIDESH) -c 'if [ -z "$(TYPE)" ]; then echo the TYPE variable is not defined!; . $(CLAM_SCRIPTS)/exit_make.sh; fi'
576         $(HIDESH) -c 'if [ ! -d $(FEISTY_MEOW_GENERATED_STORE)/versions ]; then mkdir $(FEISTY_MEOW_GENERATED_STORE)/versions; fi'
577  
578 ############################################################################
579
580 # includes the auto-dependency information.  the dependency file is checked
581 # for being up-to-date.  if not, it gets rebuilt and the make is restarted.
582 ifeq "$(CLEAN)" ""
583   ifeq "$(NO_DEPS)" ""
584
585     # thank the buddha for this bit of code, or at least thank this page:
586     # http://stackoverflow.com/questions/5553352/how-do-i-check-if-file-exists-in-makefile
587     ifneq ("$(wildcard $(DEPS_FILE))","")
588       include $(DEPS_FILE)
589     endif
590
591   endif
592 endif
593
594 ############################################################################
595
596 # calls the script for preparing output directories and such.
597 pre_compilation:
598         $(HIDESH)$(CLAM_SCRIPTS)/cpp/preconditions.sh
599
600 ############################################################################
601
602 # calls the script for copying the final products to the library directory.
603 # we don't bother reporting errors from touch since there will sometimes
604 # not be any objects in the final directory.
605 post_compilation:
606         $(HIDESH)$(CLAM_SCRIPTS)/cpp/postconditions.sh
607
608 ############################################################################
609
610 # if REBUILD is defined, then we cause all objects to be recompiled.
611 .PHONY: force_rebuild
612 force_rebuild:
613
614 ifneq "$(REBUILD)" ""
615   # the target below needs the blank rule that it has for this to work.
616   $(FIRST_TARGETS) $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_TARGETS) $(EXE_CPPS:%.cpp=$(OBJECT_DIR)/%.obj) $(LAST_TARGETS): force_rebuild
617 endif
618
619 ############################################################################
620
621 # generate dependencies for any static targets if requested.
622 gendeps: $(GENERATED_DEPS_LIST)
623
624 ############################################################################
625