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