slightly closer but cleanups are still wrong.
[feisty_meow.git] / scripts / clam / cpp / variables.def
1 ###############################################################################
2
3 # CLAM System default variable definitions for C++ compilation.
4
5 ###############################################################################
6
7 ifneq "$(BUILD_PARAMETER_FILE)" ""
8   # define our version of the build parameter file.  this should be set
9   # beforehand so we override the default parameter file for clam.
10   export PARAMETER_FILE = $(BUILD_PARAMETER_FILE)
11 endif
12 ifeq "$(PARAMETER_FILE)" ""
13   # last ditch attempt to get one that will work.
14   export PARAMETER_FILE = $(PRODUCTION_DIR)/feisty_meow_config.ini
15 endif
16
17 ###############################################################################
18
19 # Pull in the base support for CLAM.
20 include variables.def
21
22 ###############################################################################
23
24 #no # set the repository directory if it is still set to the base version.
25 #ifeq "$(FEISTY_MEOW_APEX)" ""
26 #  ifeq "$(OP_SYSTEM)" "UNIX"
27 #    export FEISTY_MEOW_APEX = $(HOME)/hoople
28 #  endif
29 #  ifeq "$(OP_SYSTEM)" "WIN32"
30 #    export FEISTY_MEOW_APEX = l:
31 #  endif
32 #endif
33
34 #export CLAM_BINARY_DIR = $(CLAM_DIR)/../bin
35
36 ###############################################################################
37
38 # BASE_CPU is a flag that distinguishes the type of processor, if necessary.
39 export BASE_CPU
40 #BASE_CPU := m68k = motorola 68000 series | m68340 = motorola 68340
41 #    | x86 = intel x86 | ppc = power pc | arm = ARM core
42
43 # set the CPU to a default if it has not been set previously.
44 ifeq "$(BASE_CPU)" ""
45 #  ifneq "$(OP_SYSTEM)" "WIN32"
46     BASE_CPU := $(shell machine 2>/dev/null || arch 2>/dev/null || uname -m 2>/dev/null || echo i686)
47 #  endif
48
49 #  ifeq "$(BASE_CPU)" ""
50 #    BASE_CPU := $(shell uname -m)
51 #    BASE_CPU := $(shell arch)
52 #    ifeq "$(BASE_CPU)" ""
53 #      # failed to get the cpu type.
54 #      BASE_CPU := x86
55 #    endif
56 #  endif
57 endif
58
59 # COMPILER is a flag that specifies the compiler that will be used to build
60 # code.  It is mainly used within CLAM itself for determining the proper
61 # compiler flags.
62 export COMPILER
63 #COMPILER := GNU_LINUX | GNU_ARM_LINUX | GNU_DARWIN | GNU_WINDOWS | VISUAL_CPP
64
65 # choose a default compiler if none was specified.
66 ifeq "$(COMPILER)" ""
67   ifeq "$(OP_SYSTEM)" "UNIX"
68     ifeq "$(OS_SUBCLASS)" "darwin"
69       COMPILER := GNU_DARWIN
70     else
71       COMPILER := GNU_LINUX
72     endif
73   endif
74   ifeq "$(OP_SYSTEM)" "WIN32"
75 #    COMPILER := GNU_WINDOWS
76     COMPILER := VISUAL_CPP
77   endif
78   ifeq "$(COMPILER)" ""
79     # if we get into this case, we have no idea how to set the default
80     # compiler.  you may need to change the above logic for guessing it
81     # anyhow.  but we will go with our favorite default.
82     COMPILER := GNU_LINUX
83   endif
84 endif
85
86 # COMPILER_VERSION specifies the version of a particular compiler, if this is
87 # needed to distinguish how the code is built.
88 export COMPILER_VERSION
89
90 ###############################################################################
91
92 # "TYPE" is the kind of product being generated by this project.  this is
93 # used to decide where to put the final products of compilation.  this is a
94 # variable in the user makefile.
95 # Valid Types:
96 #     TYPE = library        (outputs are static or dynamic libraries)
97 #     TYPE = application    (outputs are main-line executables)
98 #     TYPE = test           (outputs are test programs)
99 #     TYPE = hierarchy      (there are no outputs; just invokes other makes)
100 export TYPE
101
102 ###############################################################################
103
104 # "DEFINITIONS" is a list of compiler flags that define the value of c macros.
105 # These usually have the format of -D<flag>, but in this variable, only the
106 # <flag> itself should be listed because the compiler option -D is added
107 # automatically.
108 DEFINITIONS += CLAM_BUILT
109   # simple definition that tells the code that clam is building it.
110
111 ifneq "$(BOOT_STRAPPING)" ""
112   # the software is being built from the ground up, including the binaries
113   # we use for building (like value_tagger and others).
114   DEFINITIONS += BOOT_STRAPPING
115 endif
116
117 # "UNDEFINITIONS" is a list of macros to undefine.
118 #UNDEFINITIONS =
119
120 # GLOBAL_PRODUCT_NAME is an important variable for tagging the entire code base
121 # with some branding.  It is provided as a macro definition to all source
122 # files.  The initial value for the macro should come from the build init
123 # file, but if it does not, we pick a default.
124 ifeq "$(product_name)" ""
125   GLOBAL_PRODUCT_NAME := \\\"HOOPLE\\\"
126 else
127   GLOBAL_PRODUCT_NAME := \\\"$(product_name)\\\"
128 endif
129
130 # *_PRODUCT_VERSION records parts of our version numbers for the code to see.
131 DEFINITIONS += MAJOR_PRODUCT_VERSION=$(major) MINOR_PRODUCT_VERSION=$(minor)
132
133 # TEST_MAKEFILE tells the preconditions to check that the files specified
134 # in the makefile are actually present.
135 export TEST_MAKEFILE =
136
137 ###############################################################################
138
139 # pseudo-boolean variable section.  if these have any value at all, then they
140 # are treated as being true.  note that these are flags that should generally
141 # be passed on the command line to a make.  if they are intended to be used
142 # from inside a makefile, then they must appear before this file is included.
143
144 # "REBUILD" causes a rebuild of all source files if it is true.
145 export REBUILD
146
147 # "DEBUG" is used to specify a debugging build.  the default is for this to
148 # be false, which causes a release build.
149 export DEBUG
150
151 # Add in a macro definition if debugging is turned on.  This allows us to
152 # easily eliminate code from release builds.
153 ifneq "$(DEBUG)" ""
154   DEFINITIONS += __DEBUGGING__
155 endif
156
157 # "CONSOLE_MODE" causes the program to be generated as a console application.
158 # this is relevant in systems where programs are otherwise built with graphical
159 # user interfaces.  these are always built statically.
160 #CONSOLE_MODE =
161
162 # "OPTIMIZE" creates optimized code.
163 export OPTIMIZE
164
165 # "NO_COMPILE" just runs through the targets without compiling.
166 export NO_COMPILE
167
168 # "BUILD_LIST_FILE" is the set of files that need to be recompiled for
169 # visual c++.
170 export BUILD_LIST_FILE = $(CLAM_TMP)/clam_rebuild.$(PROJECT)
171
172 # "BUILD_WHACK_FILE" is the set of object files that should be removed if
173 # a build failure occurs.
174 export BUILD_WHACK_FILE = $(CLAM_TMP)/clam_whack.$(PROJECT)
175
176 # we are adding the build list to the flag files so we know it gets cleaned up.
177 FLAG_FILES += $(BUILD_LIST_FILE) $(BUILD_WHACK_FILE)
178
179 ###############################################################################
180
181 # This section implements the HOOPLE directory scheme.  If your scheme differs,
182 # then you will want to modify these appropriately.
183
184 # "THIRD_PARTY_DIR" is the root of our support libraries.
185 export THIRD_PARTY_DIR
186 ifeq "$(THIRD_PARTY_DIR)" ""
187   export THIRD_PARTY_DIR := "$(PRODUCTION_DIR)/3rdparty"
188 endif
189
190 # "OUTPUT_ROOT" is the root of all output directories for objects and other
191 # products being built.
192 export OUTPUT_ROOT = $(CLAM_TMP)/objects
193
194 # "PLATFORM_ADD_IN" is an option discriminator for the intended execution
195 # platform.  it should end in an underscore if it is provided.
196 #PLATFORM_ADD_IN = linux_ | w32_
197
198 # "CPU_BUILD_DIR" distinguishes object directories by including the CPU
199 # name and the type of build.
200 ifneq "$(DEBUG)" ""
201   CPU_BUILD_DIR = $(BASE_CPU)_$(PLATFORM_ADD_IN)dbg
202 else
203   CPU_BUILD_DIR = $(BASE_CPU)_$(PLATFORM_ADD_IN)rel
204 endif
205
206 # "BASE_OUTPUT_PATH" is the parent directory of objects for this type of
207 # CPU and this type of build.
208 export BASE_OUTPUT_PATH = $(OUTPUT_ROOT)/$(CPU_BUILD_DIR)
209
210 # special case when doing arm-linux builds
211 ifeq "$(COMPILER)" "GNU_ARM_LINUX"
212   export TARGETS_DIR = $(FEISTY_MEOW_APEX)/$(CPU_BUILD_DIR)
213   # special output directory for firmware does not include CPU name because
214   #  the repository already include the CPU name
215   BASE_OUTPUT_PATH = $(OUTPUT_ROOT)
216 endif
217
218 # "OUTPUT_PATH" is the directory to generate all compiled products into.
219 export OUTPUT_PATH = $(BASE_OUTPUT_PATH)/$(PROJECT)
220
221 # "OBJECT_DIR" is where object files will be stored during compilation for the
222 # target type being produced.
223 export OBJECT_DIR = $(OUTPUT_PATH)
224
225 # These specify where files are to be created or located for our local build.
226 export EXECUTABLE_DIR = $(TARGETS_DIR)
227 export DYNAMIC_LIBRARY_DIR = $(TARGETS_DIR)
228 export STATIC_LIBRARY_DIR = $(TARGETS_DIR)
229
230 # "HEADER_SEARCH_PATH" is where the class interface files are to be found.
231 #HEADER_SEARCH_PATH =
232
233 # "HOOPLE_HEADERS" are locations where the HOOPLE headers can be found.
234 ifeq "$(HOOPLE_HEADERS)" ""
235 #seems like some of this is redundant with earlier 3rdparty exploring.
236   LOCUS_LIBRARY_HEADERS = $(shell bash -c '\
237     if [ -d "$(FEISTY_MEOW_APEX)/nucleus" ]; then \
238       echo "$(FEISTY_MEOW_APEX)/nucleus" "$(FEISTY_MEOW_APEX)/octopi" "$(FEISTY_MEOW_APEX)/graphiq" ; \
239     else \
240       echo ""; \
241     fi | tr "\\\\" / | sed -e "s/\([a-zA-Z]\):\/\([^ ]*\)/\/cygdrive\/\1\/\2/g" ')
242     # above assumes cygwin support for windows!  was assuming msys support.
243   HOOPLE_HEADERS := $(shell $(FIND) $(LOCUS_LIBRARY_HEADERS) -mindepth 1 -maxdepth 1 -type d )
244 endif
245
246 # "LOCAL_HEADERS" are overrides that go first in the header search path.
247 LOCAL_HEADERS = $(THIRD_PARTY_DIR)
248
249 # "CODEBASE_HEADERS" is a list that can be changed for a particular codebase.
250 # it is guaranteed that clam will not interfere with this list, whereas
251 # the LOCAL_HEADERS can be modified by clam.
252 #CODEBASE_HEADERS =
253
254 # "LOCAL_LIBRARIES" are overrides that go first in the library search path.
255 #LOCAL_LIBRARIES =
256
257 # "LIBRARY_SEARCH_PATH" is where the library files are to be found.
258 #LIBRARY_SEARCH_PATH =
259
260 # "HOOPLE_LIBRARIES" is where our local libraries are located.
261 HOOPLE_LIBRARIES =
262
263 # "EXTRA_COPIES" is a list of files that need to be among the files copied
264 # to a project output folder.
265 export EXTRA_COPIES
266
267 # "EXTRA_VERSIONS" is a list of version files to synchronize with the main
268 # library version for this build.  if a file called "version.ini" exists in
269 # the project directory, then it will automatically be upgraded, so the
270 # extra version files are mainly useful when you have a project with multiple
271 # programs in it and you want them to have independent version files (as you
272 # should perhaps want).
273 export EXTRA_VERSIONS
274
275 # "DEPS_FILE" is where the auto-dependency information is stored.
276 export DEPS_FILE = $(OUTPUT_PATH)/$(PROJECT).deps
277
278 # "NO_DEPS" is an exclusion flag.  if it is defined, then no auto-dependency
279 # files will be generated.  this is useful if you are missing makedep or trying
280 # to compile it...
281 #NO_DEPS = t
282
283 # "OMIT_VERSIONS" is another exclusion flag.  this one turns off the creation
284 # of version resource files and eliminates any references that would include
285 # such files.  this is needed when rebuilding version_stamper.
286 #OMIT_VERSIONS = t
287
288 # add the cleanup values we already know.
289 CLEANUPS += $(OUTPUT_PATH) $(DEPS_FILE)
290
291 # "GENDEPS" is a flag that causes dependencies to be generated into
292 # statically built applications.
293 export GENDEPS
294
295 ###############################################################################
296
297 # "SEARCH_DIRS" is a list of directories that should be searched for both C++
298 # header files and for C++ code libraries.  The items placed in SEARCH_DIRS
299 # are fed into both the LIBRARY_SEARCH_PATH and the HEADER_SEARCH_PATH.
300 #SEARCH_DIRS =
301
302 # "DEPENDENCY_DEFINITIONS" is a list of extra definitions that only get passed
303 # to the makedep tool.  this can vary for each compiler.
304 #DEPENDENCY_DEFINITIONS =
305
306 # "DEPENDENCY_ADDITIONS" is a set of parameters passed directly to makedep.
307 #DEPENDENCY_ADDITIONS =
308
309 # "DEBUG_FLAGS" these flags are used for generating specialized versions of
310 # object files, such as ones that include debugging code or that add code for
311 # profiling.
312 # Possible values are -g for adding GDB debugging code and -pg for adding
313 # gprof profiling code.
314 #DEBUG_FLAGS = -g
315 #DEBUG_FLAGS = -pg
316 #DEBUG_FLAGS =
317
318 # "COMPILER_FLAGS" are the flags for the pre-processor and compiler.
319 #COMPILER_FLAGS =
320
321 # "STRICT_WARNINGS" turns on all warnings and forces them to be considered
322 # as errors when encountered.
323 #STRICT_WARNINGS = 
324
325 # "LIBRARIAN_FLAGS" are flags that need to be passed to the library tool
326 # that creates static code libraries.
327 #LIBRARIAN_FLAGS =
328
329 # "SOURCE" is the list of files that are turned into objects.
330 #SOURCE=
331
332 # "OBJECTS" are the files to be created by compilation and added to any
333 # libraries or executables that are made.
334 #OBJECTS =
335
336 # "EXTRA_OBJECTS" are files that are created elsewhere but need to be bound
337 # into the target.
338 #EXTRA_OBJECTS =
339
340 # "LIBS_USED" are system or compiler code libraries that the targets to be
341 # created depend upon.
342 LIBS_USED =
343
344 # "LOCAL_LIBS_USED" is very similar to the LIBS_USED, but these libraries
345 # actually cause executables and object files to be recompiled when the
346 # libraries specified have changed.  To accomplish this, these libraries MUST
347 # be located in the STATIC_LIBRARY_DIR rather than at some arbitrary place
348 # on the LIBRARY_SEARCH_PATH.
349 #LOCAL_LIBS_USED=
350
351 # Load flags tell the linker and loader how to deal with the files and where
352 # to locate library components.  The prefix goes before object files are
353 # listed, and the suffix after.  The prefix should have things like the
354 # directories to be searched for code libraries (although they should be added
355 # to LIBRARY_SEARCH_PATH) and the loading mode for functions (static/dynamic).
356 # In the suffix, actual library loading statements (like -lmath) can be
357 # included (although they should be listed in a different form in LIBS_USED).
358 # Remember that the unix loader looks for functions in libraries in a bizarre
359 # way: ld searches for a function only when it has already been asked for it.
360 # This means that it does not remember what functions it has already been
361 # provided with in the libraries and object files, and it will fail if those
362 # functions are only asked for after they have already been encountered.
363 #LOAD_FLAG_PREFIX =
364 #LOAD_FLAG_SUFFIX =
365
366 # The prefix used on library names, mostly for unix.
367 export LIB_PREFIX
368 # The standard suffix for static or import libraries on this operating system.
369 export LIB_ENDING
370
371 # The dynamic library ending differs between platforms.
372 export DYNLIB_ENDING
373
374 # Flag for specifying the library name to create.
375 #CREATE_LIBRARY_FLAG =
376
377 # Flag for specifying a library to include in linking.
378 LIBRARY_NAME_FLAG = -l
379
380 # Flag for specifying the name of an object file to include in a library or exe.
381 OBJECT_NAME_FLAG = -o
382
383 # Flag for specifying a directory to add to the search path for libs.
384 LIBRARY_PATH_FLAG = -L
385
386 # Flag for specifying the name of an output from the linker.
387 #LINKER_OUTPUT_FLAG =
388
389 # Flag for separating linker options from compilation options for a combined
390 # compiler / linker.
391 #LINKER_OPTION_SEPARATOR =
392
393 # Flag that passes special options when building executable programs.  It is
394 # passed just before the LOAD_FLAG_PREFIX.
395 #EXE_FLAGS = 
396
397 # The name of the compiler tool.
398 #CC =
399
400 # The name of the library creator tool.
401 #LIBRARY_TOOL =
402
403 # the root name of the version file.  This is currently irrelevant on
404 # non-win32 platforms.
405 VERSION_RC_ROOT = $(shell $(SHELL) $(CLAM_DIR)/cpp/rc_name.sh)
406
407 ifneq "$(CONSOLE_MODE)" ""
408   # this definition can be used to signal different behavior when the app is
409   # being built for console mode.  that generally implies that it should send
410   # debugging info to standard out and avoid doing much with graphics.
411   DEFINITIONS += CONSOLE_MODE
412 endif
413
414 ###############################################################################
415
416 # Operating system dependent flags.
417
418 ifeq "$(OP_SYSTEM)" "UNIX"
419   LIB_ENDING = .a
420   DYNLIB_ENDING = .so
421 endif
422 ifeq "$(OP_SYSTEM)" "WIN32"
423   ifeq "$(COMPILER)" "VISUAL_CPP"
424     LIB_ENDING = .lib
425     DYNLIB_ENDING = .dll
426   else
427     LIB_ENDING = .a
428     DYNLIB_ENDING = .so
429   endif
430 endif
431
432 ###############################################################################
433
434 # Compiler Dependent Flags
435 #
436 # "COMPILER_ROOT_DIR" is the top-level for the C++ compiler location.
437 export COMPILER_ROOT_DIR
438 # "COMPILER_HEADER_DIR" is where the compiler headers are.
439 export COMPILER_HEADER_DIR
440 # "COMPILER_LIBRARY_DIR" is where archived libraries are.
441 # "CC" is the name of the C++ compiler to be used.
442
443 # These flags may be useful across multiple compilers.
444 #
445 # SSL brings in the OpenSSL libraries.
446 USE_SSL=
447
448 # CURL provides access to the curl library.
449 USE_CURL=
450
451 # Enables wxwidget library support.
452 USE_WXWIDGETS=
453
454 ifneq "$(OMIT_VERSIONS)" ""
455   DEFINITIONS += NO_VERSION
456 endif
457
458 ############################################################################
459 # compiler specific section below.
460 ############################################################################
461
462 ifeq "$(COMPILER)" "GNU_LINUX"
463   # Unix GNU compiler...
464   CC = g++
465   COMPILER_ROOT_DIR = /
466   PLATFORM_ADD_IN = linux_
467   ARCHITECTURE = $(shell machine 2>/dev/null || arch 2>/dev/null || echo i686)
468
469   export COMPILER_VERSION = $(shell $(SHELL) $(CLAM_DIR)/cpp/get_version.sh $(COMPILER) $(COMPILER_ROOT_DIR) )
470
471   DEFINITIONS += _FILE_OFFSET_BITS=64 
472
473   DEPENDENCY_DEFINITIONS += NO_VERSION
474   DEPENDENCY_ADDITIONS = -X/usr/include -X/usr/include/c++/$(COMPILER_VERSION) -X/usr/include/c++/$(COMPILER_VERSION)/tr1 -X/usr/local/include -X/usr/include/linux -X/usr/include/wx-2.8 -X/usr/lib/gcc/i586-suse-linux/$(COMPILER_VERSION)/include -X/usr/lib/gcc/i486-linux-gnu/$(COMPILER_VERSION)/include -X/usr/lib/gcc/i686-linux-gnu/$(COMPILER_VERSION)/include -X/usr/lib/gcc/x86_64-linux-gnu/$(COMPILER_VERION)/include -X/usr/include/x86_64-linux-gnu -X/usr/include/i386-linux-gnu
475
476   # "USE_XWIN" specifies that this project needs X window system support.
477   #USE_XWIN =
478
479   ifeq "x86_64" "$(ARCHITECTURE)"
480     COMPILER_LIBRARY_DIR = /lib64 /usr/lib64 /usr/local/lib64
481   else
482     COMPILER_LIBRARY_DIR = /lib /usr/lib /usr/local/lib
483   endif
484   DEFINITIONS += __LINUX__ linux __linux__ UNIX unix __UNIX__ __USE_GNU 
485   # X Window System not enabled by default.
486   #DEFINITIONS += __XWINDOWS__ 
487
488   LIBRARY_TOOL = ar
489   LIB_PREFIX = lib
490   LOAD_FLAG_PREFIX += -Xlinker -O3 
491     # -Xlinker --print-map : shows what went in and why.
492     # -Xlinker -O3 : linker optimization
493
494   CREATE_LIBRARY_FLAG += -r 
495     # space on end is significant.
496   LINKER_OUTPUT_FLAG = -o 
497   LINK_TOOL = g++
498   # compiler flags for gcc:
499   # -finline-functions: inline functions as needed.
500   # -fPIC: generate position independent code.
501   # -fpic: generate position independent code, but less portable.
502   # -frepo: automatic template instantiation at link time, no implicit ones.
503   # -ffunction-sections: put each function in own section, improving linking.
504   # -fdata-sections: put data in own section, improving linking.
505   # -shared-libgcc: use the shared library version of compiler libraries.
506   # -fno-exceptions: do not support exception handling and stack unwinding.
507
508   COMPILER_FLAGS += -shared-libgcc -fPIC  
509
510   ifeq "$(DEBUG)" ""
511 #    COMPILER_FLAGS += -finline-functions 
512   endif
513   ifneq "$(STRICT_WARNINGS)" ""
514     COMPILER_FLAGS += -Wall -Werror -Wextra -Wno-long-long
515   endif
516
517   ifeq "$(CONSOLE_MODE)" ""
518     LIBS_USED += dl 
519      # dl=dynamic library.
520   endif
521
522   LIBS_USED += pthread rt 
523      # pthread=thread libraries.
524      # rt=real time libraries for shared memory.
525
526   ifneq "$(DEBUG)" ""
527     # add in debugging flags.
528     COMPILER_FLAGS += -g3 -O0
529
530 ##LOAD_FLAG_PREFIX += -lefence
531 #electric fence
532
533 ###COMPILER_FLAGS += -pg
534 ###LOAD_FLAG_PREFIX += -pg
535 ####trying out profiling: does not work so well yet.  generates gmon.out files
536 ####  in pretty random places.  the parameters to the linker do not even
537 ####  mention this flag, and the compiler flags do not seem to provide an
538 ####  option for where the file goes.  so, it is on hold.
539
540   endif
541
542 endif
543
544 ############################################################################
545
546 ifeq "$(COMPILER)" "GNU_ARM_LINUX"
547   # ARM-linux GNU compiler...
548   COMPILER_ROOT_DIR = /usr/local/arm-linux
549   CC = $(COMPILER_ROOT_DIR)/bin/g++
550   PLATFORM_ADD_IN = linux_
551
552   export COMPILER_VERSION = $(shell $(SHELL) $(CLAM_DIR)/cpp/get_version.sh $(COMPILER) $(COMPILER_ROOT_DIR) )
553
554   SNAPGEAR_ROOT_DIR = $(HOME)/snapgear
555
556   DEPENDENCY_DEFINITIONS += NO_VERSION
557
558   COMPILER_HEADER_DIR = $(SNAPGEAR_ROOT_DIR)/linux-2.4.x/include
559 #  COMPILER_HEADER_DIR += $(SNAPGEAR_ROOT_DIR)/include 
560   COMPILER_HEADER_DIR += $(COMPILER_ROOT_DIR)/include $(COMPILER_ROOT_DIR)/lib 
561   COMPILER_HEADER_DIR += /usr/local/lib/gcc-lib/arm-linux/3.3.2/include
562   
563   COMPILER_LIBRARY_DIR = $(SNAPGEAR_ROOT_DIR)/lib $(COMPILER_ROOT_DIR)/lib/be
564
565   DEFINITIONS += linux __linux__ unix UNIX __UNIX__ __LINUX__ 
566
567   COMPILER_FLAGS += -mbig-endian -finline-functions -ffunction-sections -fPIC -nostdinc -nostdinc++ 
568   ifneq "$(STRICT_WARNINGS)" ""
569     COMPILER_FLAGS += -Wall -Werror
570   endif
571
572   LIBRARY_TOOL = $(COMPILER_ROOT_DIR)/bin/ar
573   LIB_PREFIX = lib
574   CREATE_LIBRARY_FLAG += -r 
575     # space on end is significant.
576   
577   LINK_TOOL = $(COMPILER_ROOT_DIR)/bin/g++
578   LINKER_OUTPUT_FLAG = -o
579   EXE_FLAGS = -mbig-endian
580   LOAD_FLAG_PREFIX += -v -mbig-endian
581
582   LIBS_USED += pthread dl
583
584   ifneq "$(DEBUG)" ""
585     COMPILER_FLAGS += -g3 -O0
586   endif
587
588 endif
589
590 ############################################################################
591
592 ifeq "$(COMPILER)" "GNU_WINDOWS"
593   # GNU compiler for MS Windoze...
594   CC = g++
595   ifeq "$(COMPILER_ROOT_DIR)" ""
596     COMPILER_ROOT_DIR = $(CYGROOT)
597   endif
598
599   export COMPILER_VERSION = $(shell $(SHELL) $(CLAM_DIR)/cpp/get_version.sh $(COMPILER) $(COMPILER_ROOT_DIR) )
600
601   RC := $(COMPILER_ROOT_DIR)/bin/windres
602   PLATFORM_ADD_IN = w32_
603
604   COMPILER_HEADER_DIR = $(COMPILER_ROOT_DIR)/include $(COMPILER_ROOT_DIR)/include/c++/3.4.2 
605 #$(COMPILER_ROOT_DIR)/lib/gcc/mingw32/3.4.2/include 
606 ###$(COMPILER_ROOT_DIR)/usr/include/mingw $(COMPILER_ROOT_DIR)/usr/include $(COMPILER_ROOT_DIR)/usr/include/w32api $(COMPILER_ROOT_DIR)/usr/include/extras
607
608   COMPILER_LIBRARY_DIR = $(COMPILER_ROOT_DIR)/lib
609   DEFINITIONS += __GNU_WINDOWS__ _Windows _WINDOWS WIN32 __WIN32__ __FLAT__ VC_EXTRALEAN WIN32_LEAN_AND_MEAN ATL_NO_LEAN_AND_MEAN _WIN32 __USE_W32_SOCKETS
610 #__cplusplus 
611 #__USE_GNU 
612
613   LIBRARY_TOOL = ar
614   LIBRARY_PATH_FLAG = -L 
615   LIB_PREFIX = lib
616   LIB_ENDING = .a
617 #  LOAD_FLAG_PREFIX += -lpthread
618   LOAD_FLAG_PREFIX += -mwindows
619   CREATE_LIBRARY_FLAG += -r 
620     # space on end is significant.
621   LINKER_OUTPUT_FLAG = -o
622   LINK_TOOL = g++
623   MIDL = midl -Oicf $(MIDL_DEFS) $(HEADER_SEARCH_PATH:%=-I% ) $(DEFINITIONS:%=-D% )
624   MIDL_DEFS = -no_robust
625   # some lovely definitions used by some of the mfc and other ms code.
626   DEPENDENCY_DEFINITIONS += __cplusplus __MINGW32__ _WIN32 _CHAR_UNSIGNED M_I86 _M_I86 _M_IX86=500 _WIN32_WINNT=0x501 __RPC_WIN32__ __RPCNDR_H_VERSION__ __RPCPROXY_H_VERSION__ TARGET_IS_NT40_OR_LATER PGM_SETCHILD _MFC_VER=0x0600
627
628 endif
629
630 ############################################################################
631
632 ifeq "$(COMPILER)" "VISUAL_CPP"
633   # microsoft visual c++ 4.x, 5.x or 6.x.
634
635   PLATFORM_ADD_IN = w32_
636
637   TRIPART_VERSION =
638
639   CLEANUPS += $(PDB_DIR)/$(PROJECT)_bookkeeping.pdb 
640 #hmmm: import libs for dynamic libraries on ms-win32 do not currently get
641 #      cleaned up nicely.
642
643   # ensure that any setting for this is seen by sub-shells.
644   export WIN32_MANIFEST_FILE
645
646   # these define special characteristics for a program being built.
647   #   BASE is almost always defined and pulls in fundamental w32 support.
648   #   RPC supplies the remote procedure call libraries.
649   #   SECURITY links with the w32 security APIs.
650   #   CLR sets options that are appropriate for managed code.
651   VCPP_USE_BASE=true
652   VCPP_USE_RPC=
653   VCPP_USE_OLE=
654   VCPP_USE_SECURITY=
655   VCPP_USE_CLR=
656   VCPP_VISTA_ICON=
657
658   # the framework dir points at the .net framework to be used for compilation.
659   ifeq "$(FRAMEWORK_VERSION)" ""
660
661     # older .net 1.1.
662 #    SHORT_FRAMEWORK_VERSION = 1.1
663 #    FRAMEWORK_VERSION = $(SHORT_FRAMEWORK_VERSION).4322
664
665     # current .net 2.0.
666     SHORT_FRAMEWORK_VERSION = 2.0
667     FRAMEWORK_VERSION = $(SHORT_FRAMEWORK_VERSION).50727
668   endif
669   ifeq "$(FRAMEWORK_DIR)" ""
670     FRAMEWORK_DIR = $(subst \,/,$(WINDIR))/Microsoft.NET/Framework/v$(FRAMEWORK_VERSION)
671   endif
672
673   # calculate the visual studio root directory.
674   ifeq "$(VIS_STU_ROOT)" ""
675     export VIS_STU_ROOT := $(shell $(SHELL) $(CLAM_DIR)/cpp/ms_root_dir.sh )
676   endif
677   ifneq "$(VIS_STU_ROOT)" ""
678     export COMPILER_ROOT_DIR = $(VIS_STU_ROOT)/VC
679   endif
680   ifeq "$(COMPILER_ROOT_DIR)" ""
681     HOSEUP = $(shell echo The compiler directory is not set.  Please define the environment variable)
682     HOSEUP = $(shell echo VSxCOMNTOOLS (x=80, 90 or 100) to point at the folder where visual )
683     HOSEUP = $(shell echo Studio is installed.)
684     HOSEUP =
685   endif
686
687   # redo the compiler version with our new info.
688   export COMPILER_VERSION := $(shell $(SHELL) $(CLAM_DIR)/cpp/get_version.sh $(COMPILER) $(COMPILER_ROOT_DIR) )
689
690   # set up a directory for debugging files to be stored.  these are not
691   # moved with the postconditions--they are generated in place.
692   export PDB_DIR = $(TARGETS_DIR)
693
694   # set these way up here so we can override them later.
695   CC = $(BUILD_SCRIPTS_DIR)/wrapdoze.sh $(COMPILER_ROOT_DIR)/bin/cl.exe
696   LINK_TOOL = $(BUILD_SCRIPTS_DIR)/wrapdoze.sh $(COMPILER_ROOT_DIR)/bin/link.exe
697   LIBRARY_TOOL = $(BUILD_SCRIPTS_DIR)/wrapdoze.sh $(COMPILER_ROOT_DIR)/bin/lib
698
699   # This is needed to protect against the use of 64-bit time_t structure
700   # on windows.  We are casting to time_t from a 32-bit structure.
701   DEFINITIONS += _USE_32BIT_TIME_T
702
703   # vary the locations for compiler files based on the version.
704   ifeq "$(COMPILER_VERSION)" "6"
705     COMPILER_HEADER_DIR = $(COMPILER_ROOT_DIR)/include $(COMPILER_ROOT_DIR)/atl/include
706     COMPILER_LIBRARY_DIR = $(COMPILER_ROOT_DIR)/lib $(COMPILER_ROOT_DIR)/atl/lib
707     RC = $(BUILD_SCRIPTS_DIR)/wrapdoze.sh $(COMPILER_ROOT_DIR)/../common/msdev98/bin/rc
708   endif
709   ifeq "$(COMPILER_VERSION)" "7"
710     COMPILER_HEADER_DIR = $(COMPILER_ROOT_DIR)/include $(COMPILER_ROOT_DIR)/atlmfc/include $(COMPILER_ROOT_DIR)/platformsdk/include $(FRAMEWORK_DIR)
711     COMPILER_LIBRARY_DIR = $(COMPILER_ROOT_DIR)/lib $(COMPILER_ROOT_DIR)/atlmfc/lib $(COMPILER_ROOT_DIR)/platformsdk/lib
712     RC = $(BUILD_SCRIPTS_DIR)/wrapdoze.sh $(COMPILER_ROOT_DIR)/bin/rc
713     COMPILER_FLAGS += -Zc:forScope
714       # turn on proper loop scoping.
715   endif
716   ifeq "$(COMPILER_VERSION)" "8"
717     COMPILER_HEADER_DIR = $(COMPILER_ROOT_DIR)/include $(COMPILER_ROOT_DIR)/atlmfc/include $(COMPILER_ROOT_DIR)/platformsdk/include $(FRAMEWORK_DIR)
718     COMPILER_LIBRARY_DIR = $(COMPILER_ROOT_DIR)/lib $(COMPILER_ROOT_DIR)/atlmfc/lib $(COMPILER_ROOT_DIR)/platformsdk/lib
719     RC = $(BUILD_SCRIPTS_DIR)/wrapdoze.sh $(COMPILER_ROOT_DIR)/bin/rc
720     COMPILER_FLAGS += -Zc:forScope
721       # turn on proper loop scoping.
722     DEFINITIONS += _WIN32_WINNT=0x501 
723     DEPENDENCY_DEFINITIONS += _WIN32_WINNT=0x501 
724   endif
725 #
726 # ver 9 (vis stu 2008) is not in here but is probably similar to 8 or 10.
727 #
728   ifeq "$(COMPILER_VERSION)" "10"
729     export PLATYPUS = $(WindowsSdkDir)
730     COMPILER_HEADER_DIR = $(COMPILER_ROOT_DIR)/include $(COMPILER_ROOT_DIR)/atlmfc/include $(PLATYPUS)/include
731 ## $(FRAMEWORK_DIR)
732     COMPILER_LIBRARY_DIR = $(COMPILER_ROOT_DIR)/lib $(COMPILER_ROOT_DIR)/atlmfc/lib $(PLATYPUS)/lib
733     DEFINITIONS += _WIN32_WINNT=0x501 
734     DEPENDENCY_DEFINITIONS += _WIN32_WINNT=0x501 
735     RC = $(BUILD_SCRIPTS_DIR)/wrapdoze.sh $(PLATYPUS)/bin/rc
736     COMPILER_FLAGS += -Zc:forScope
737       # turn on proper loop scoping.
738   endif
739   ifeq "$(COMPILER_HEADER_DIR)" ""
740     HOSEUP = $(shell echo The compiler version is not set.  Please define COMPILER_VERSION.)
741   endif
742   ifeq "$(COMPILER_HEADER_DIR)" ""
743     HOSEUP = $(shell echo The compiler version is not set.  Please define COMPILER_VERSION.)
744   endif
745   ifeq "$(COMPILER_HEADER_DIR)" "0"
746     HOSEUP = $(shell echo The compiler version is not set.  Please define COMPILER_VERSION.)
747   endif
748
749   # add in the mfc directories.
750   COMPILER_HEADER_DIR += $(COMPILER_ROOT_DIR)/mfc/include
751   COMPILER_LIBRARY_DIR += $(COMPILER_ROOT_DIR)/mfc/lib
752
753   DEFINITIONS += _Windows _WINDOWS WIN32 __WIN32__ __FLAT__ VC_EXTRALEAN WIN32_LEAN_AND_MEAN ATL_NO_LEAN_AND_MEAN 
754   DEF_FILE =
755   LOAD_FLAG_PREFIX = -subsystem:windows -machine:X86 -nologo
756   LOAD_FLAG_SUFFIX =
757
758   MIDL = "$(COMPILER_ROOT_DIR)/../Common7/Tools/Bin"/midl.exe -Oicf $(MIDL_DEFS) $(HEADER_SEARCH_PATH:%=-I% ) $(DEFINITIONS:%=-D% )
759   MIDL_DEFS = -no_robust
760
761   # additional definitions that get put on the command line for makedep.  these
762   # are needed since visual c++ defines them automatically.
763   DEPENDENCY_DEFINITIONS += __cplusplus _WIN32 _CHAR_UNSIGNED M_I86 _M_I86 _MSC_VER=1200 _M_IX86=500 __RPC_WIN32__ __RPCNDR_H_VERSION__ __RPCPROXY_H_VERSION__ TARGET_IS_NT40_OR_LATER PGM_SETCHILD _MFC_VER=0x0600
764
765   # set the flags used by visual c++.
766   CREATE_LIBRARY_FLAG = -out:
767   LIBRARY_NAME_FLAG =
768   LIBRARY_PATH_FLAG = -libpath:
769   LINKER_OPTION_SEPARATOR = -link
770   LINKER_OUTPUT_FLAG = -out:
771   OBJECT_NAME_FLAG = -Fo
772
773   # Add the extra files created by visual c++.
774 #is this needed now that we whack whole output path?  CLEANUPS += $(OUTPUT_PATH)/*.*db
775
776   # compilation parameters for microsoft.
777   #   -c specifies compilation without linking.
778   #   -EHsc is the flag for turning on exception handling.
779   #   -FD is for getting the best dependency checking in visual studio.
780   #   -Fd[filename] names the program database (PDB) file used for debugging.
781   #   -Fp[filename] names the precompiled header file name.
782   #   -FR[filename] names the browser output path used for source analysis.
783   #   -Gd calling convention is cdecl.
784   #   -Gm enables minimal rebuild (only if source files changed).
785   #       Note!  as of Visual Studio 6 SP 3, minimal rebuild does not work
786   #       properly.  Do not use it unless you want inconsistent builds!
787   #   -GR enables run-time type identification (RTTI).
788   #   -GS enables buffer checking.
789   #   -GX turns on synchronous exception handling. (deprecated)
790   #   -Gz uses __stdcall calling convention.
791   #   -MD specifies multi-threaded DLL (MDd means debug).
792   #   -ML signifies uni-threaded executable (MLd means debug).
793   #   -MT indicates multi-threaded executable (MTd means debug)
794   #   -O is for optimization (1 small code, 2 fast code, d disabled).
795   #     do not use 1 or 2 though; they both include "global optimization",
796   #     which seems plagued with problems.  the specific optimizations are:
797   #       -Oa  assume no aliasing
798   #       -Obn  inline function expansion, where n is 1 (enable) or 0 (disable)
799   #       -Od  disable (for debug)
800   #       -Oi  generate intrinsic functions
801   #       -Og  global optimizations (flawed)
802   #       -Op  improve float consistency
803   #       -Os  favor small code
804   #       -Ot  favor fast code
805   #       -Ow  assume aliasing across function calls
806   #       -Ox  full optimization
807   #       -Oy  frame pointer optimization
808   #     -O1 has g s y b1 Gs Gf Gy
809   #     -O2 has g i t y b1 Gs Gf Gy
810   #   -TP C++ compilation.
811   #   -W sets the warning level (from 0 (least warnings) through 4 (loudest)).
812   #       -WX turns all warnings into errors.
813   #   -Yu[filename] uses a precompiled header file.
814   #   -YX turns on precompiled headers.  not used due to poor implementation.
815   #   -Zi generates debugging information into the PDB file.
816
817   # put the common flags into the compiler flags.
818   COMPILER_FLAGS += -nologo -Fd$(PDB_DIR)/$(PROJECT)_bookkeeping.pdb -GR -W3 -Zi -EHsc -GS -Gd 
819 #-Wp64 
820
821   ifneq "$(DEBUG)" ""
822     # disable function inlining and optimizations for debug.
823     COMPILER_FLAGS += -Ob0 -Od
824   else
825     # enable function inlining for release only.
826     COMPILER_FLAGS += -Ob1
827
828     ifneq "$(OPTIMIZE)" ""
829       # add in fast code optimization.
830       COMPILER_FLAGS += -O2
831     else
832       # no optimizations.
833     endif
834
835   endif
836
837   # linking parameters for microsoft.
838   #   -dll specifies that a dynamic library is to be created.
839   #   -debug specifies that debugging information is to be included.
840   #   -map turns on the map file.
841   #   -warn sets the warning level, from 0 to 3, where 3 is the most verbose.
842   #   kernel32.lib is the kernel support.
843   #   user32.lib is the user level support.
844   #   gdi32.lib is the graphical device interface? support.
845   #   winspool.lib contains printer support.
846   #   comdlg32.lib provides the common dialogs.
847   #   advapi32.lib provides deeper win32 features, like registry, services, etc.
848   #   shell32.lib is ?
849   #   ole32.lib supplies OLE support.
850   #   oleaut32.lib is the OLE automation library.
851   #   uuid.lib has unique id management?
852   #   odbc32.lib provides ODBC data source functionality.
853   #   odbccp32.lib is something?
854   #   winmm.lib has the win32 multimedia support.
855   #   version.lib offers up splendid version services.
856
857   # check if profiling is to be enabled.
858   PROFILER_FLAG =
859   ifneq "$(PROFILE)" ""
860     PROFILER_FLAG = -profile
861   endif
862
863   LIBS_USED += htmlhelp.lib
864
865   # add the common linker flags.  the debugging flag is added because we
866   # want to be able to debug into release code, but since the pdb files
867   # are separate, we are not exposing ourselves when we do not include them.
868   LOAD_FLAG_PREFIX += $(PROFILER_FLAG) -debug -opt:ref -opt:icf 
869 #-warn:3
870
871   # "USE_MFC" dictates whether mfc should be allowed in the application.
872   # the default is not to use MFC extension style dlls.  this can be turned
873   # on in the individual makefiles that require MFC.
874   #USE_MFC =
875
876   # the library creator gets a couple of flags.
877   LIBRARIAN_FLAGS += -nologo -machine:X86 -subsystem:windows
878
879   # now, vary the flag configuration based on the flags that have been set.
880
881 ####override for windows since things are broken with WinMain
882 ###export CONSOLE_MODE = true
883
884   ifneq "$(CONSOLE_MODE)" ""
885     # console type of applications are built using the static flag so that
886     # they are more redistributable.
887     DEFINITIONS += _CONSOLE
888     LOAD_FLAG_SUFFIX += -subsystem:console
889     LIBRARIAN_FLAGS += -subsystem:console
890   endif
891
892   # dynamically linked library or application flags.
893   ifneq "$(DEBUG)" ""
894     # debug.
895     DEFINITIONS += _DEBUG
896     COMPILER_FLAGS += -MDd
897   else
898     # release.
899     DEFINITIONS += NDEBUG
900     COMPILER_FLAGS += -MD
901     LOAD_FLAG_PREFIX += -map
902   endif
903
904   ifneq "$(STRICT_WARNINGS)" ""
905     COMPILER_FLAGS += -WX
906 #would like to add W4 but that triggers warnings in microsoft headers.
907   endif
908
909 endif
910
911 ############################################################################
912
913 ifeq "$(COMPILER)" "GNU_DARWIN"
914   # Darwin kernel GNU compiler...
915   CC = g++
916   COMPILER_ROOT_DIR = /
917   PLATFORM_ADD_IN = darwin
918   ARCHITECTURE = $(shell machine 2>/dev/null || arch 2>/dev/null || echo i686)
919 #  COMPILER_FLAGS += -fgnu-runtime
920
921   export COMPILER_VERSION = $(shell $(SHELL) $(CLAM_DIR)/cpp/get_version.sh $(COMPILER) $(COMPILER_ROOT_DIR) )
922
923   DEFINITIONS += _FILE_OFFSET_BITS=64 
924
925   DEPENDENCY_DEFINITIONS += NO_VERSION
926   DEPENDENCY_ADDITIONS = -X/usr/include -X/usr/include/c++/$(COMPILER_VERSION) -X/usr/include/c++/$(COMPILER_VERSION)/tr1 -X/usr/local/include -X/usr/include/linux -X/usr/include/wx-2.8 -X/usr/lib/gcc/i586-suse-linux/$(COMPILER_VERSION)/include -X/usr/lib/gcc/i486-linux-gnu/$(COMPILER_VERSION)/include
927
928 #protect other additions to make them only for debian?
929 #  COMPILER_HEADER_DIR := /usr/include /usr/local/include 
930   COMPILER_HEADER_DIR := /System/Library/Frameworks/Foundation.framework/Versions/C/Headers
931
932   # "USE_XWIN" specifies that this project needs X window system support.
933   #USE_XWIN =
934
935 #  ifeq "x86_64" "$(ARCHITECTURE)"
936 #    COMPILER_LIBRARY_DIR = /lib64 /usr/lib64 /usr/local/lib64
937 #  else
938
939     COMPILER_LIBRARY_DIR = /usr/lib 
940 ###/usr/local/lib
941 #/lib 
942
943 #  endif
944   DEFINITIONS += __LINUX__ linux __linux__ UNIX unix __UNIX__ __USE_GNU 
945   # X Window System not enabled by default.
946   #DEFINITIONS += __XWINDOWS__ 
947
948   LIBRARY_TOOL = ar
949   LIB_PREFIX = lib
950 #  LOAD_FLAG_PREFIX += -Xlinker 
951 #mac has no o3???
952 #-O3 
953
954 # -Xlinker --print-map : shows what went in and why.
955 # -Xlinker -O3 : linker optimization
956   CREATE_LIBRARY_FLAG += -r 
957     # space on end is significant.
958   LINKER_OUTPUT_FLAG = -o 
959   LINK_TOOL = g++
960 #  COMPILER_FLAGS += -shared-libgcc -fPIC  
961 #old: -Wl,-export-dynamic
962 #  ifeq "$(DEBUG)" ""
963 #    COMPILER_FLAGS += -finline-functions 
964 #  endif
965 #  ifneq "$(STRICT_WARNINGS)" ""
966 #    COMPILER_FLAGS += -Wall -Werror -Wextra -pedantic-errors -Wno-long-long
967 #  endif
968 #  LIBS_USED += dl pthread rt 
969 #mac no like these libs
970      # dl=dynamic library.
971      # pthread=thread libraries.
972      # rt=real time libraries for shared memory.
973
974   ifneq "$(DEBUG)" ""
975     # add in debugging flags.
976 #    COMPILER_FLAGS += -g3 -O0
977   endif
978 endif
979
980 ############################################################################
981
982 # these activities are done after the compiler specific stuff.
983
984 # add a definition for programs to be able to differentiate the versions.
985 DEFINITIONS += COMPILER_VERSION=$(COMPILER_VERSION)
986
987 # set a variable that scripts can use to get most of the definitions.
988 export VARIABLE_DEFINITION_SET := $(DEFINITIONS)
989
990 ###############################################################################
991