1 ###############################################################################
3 # CLAM System default rules and targets for C++ compilation.
5 # This file composite macros and rules for creating compilation objects
6 # (such as library archives, object files, executable programs, and others).
8 # This file should be included in the user's Makefile after the variables
9 # have been initialized appropriately for the particular project being
10 # compiled. The user's own targets should be placed after the include
11 # directive that specifies this file.
13 ###############################################################################
15 # This section manipulates variable values to prepare them for their use
16 # in the standard CLAM support.
18 # Modify the output directory for executable files if we're building a
21 EXECUTABLE_DIR = $(TARGETS_STORE)/tests/$(PROJECT)
22 ifneq "$(CONSOLE_MODE)" ""
23 COMPILER_FLAGS += -target:exe
25 COMPILER_FLAGS += -target:winexe
28 ifeq "$(TYPE)" "application"
29 ifneq "$(CONSOLE_MODE)" ""
30 COMPILER_FLAGS += -target:exe
32 COMPILER_FLAGS += -target:winexe
35 ifeq "$(TYPE)" "library"
36 COMPILER_FLAGS += -target:library
39 # prep the actual source variable so that certain file names are translated.
40 ACTUAL_RESX = $(RESX:%.resx=%.resources)
42 ifeq "$(OP_SYSTEM)" "WIN32"
43 ifneq "$(OMIT_VERSIONS)" ""
44 # remove version rc files if we're not dealing with versions.
45 ACTUAL_RESOURCE = $(RESOURCE:%.rc=)
47 ACTUAL_RESOURCE = $(RESOURCE:%.rc=%.res)
50 # replace this when supporting resource files on unix.
51 ACTUAL_RESOURCE = $(RESOURCE:%.rc=)
54 # patch the sources so that subdirs work.
55 ACTUAL_SOURCE = $(SOURCE:%.cs=$(CURRENT_DIR)/%.cs)
57 # visual studio settings.
58 ifeq "$(COMPILER)" "VISUAL_CPP"
59 # processes the def file for linkage, if one has been specified.
60 ifneq "$(DEF_FILE)" ""
61 LOAD_FLAG_PREFIX += -def:$(DEF_FILE)
64 # these are loaded after any special debugging libs.
65 ifneq "$(VCPP_USE_BASE)" ""
66 # the first set will be included in almost any old program. we include
67 # winmm for multimedia in the base support since we make heavy use of the
68 # more accurate uptime function.
69 # LOAD_FLAG_PREFIX += advapi32.lib kernel32.lib version.lib winmm.lib
71 #is advapi32 really part of the base required stuff? will it work on
72 #win98? how about win95?
74 ifneq "$(VCPP_USE_GUI)" ""
75 LOAD_FLAG_PREFIX += comdlg32.lib gdi32.lib user32.lib winspool.lib
78 ifneq "$(VCPP_USE_OLE)" ""
79 LOAD_FLAG_PREFIX += ole32.lib oleaut32.lib uuid.lib
82 ifneq "$(VCPP_USE_RPC)" ""
83 LOAD_FLAG_PREFIX += rpcndr.lib rpcns4.lib rpcrt4.lib
86 ifneq "$(VCPP_USE_SOCK)" ""
87 LOAD_FLAG_PREFIX += netapi32.lib ws2_32.lib
91 # Updates the search path for the compiler and local libraries.
92 BASE_HEADER_PATH = $(CODEBASE_HEADERS) $(LOCAL_HEADERS) $(HOOPLE_HEADERS) $(SEARCH_DIRS)
93 HEADER_SEARCH_PATH += $(BASE_HEADER_PATH) $(COMPILER_HEADER_DIR)
95 LIBRARY_SEARCH_PATH += $(LOCAL_LIBRARIES) $(HOOPLE_LIBRARIES) \
96 $(STATIC_LIBRARY_DIR) $(COMPILER_LIBRARY_DIR) $(SEARCH_DIRS)
98 # Adds some directories that must be searched onto the search path for
99 # header files, such as the compiler's own special header file directory.
100 COMPILER_FLAGS += $(DEFINITIONS:%=-D:%) $(UNDEFINITIONS:%=-U%)
101 #$(HEADER_SEARCH_PATH:%=-I%)
103 # The load flags are updated by looking for code libraries in the directories
104 # to search and by adding all of the code libraries that are used.
105 LOAD_FLAG_PREFIX += $(LIBRARY_SEARCH_PATH:%=$(LIBRARY_PATH_FLAG)%)
106 LOAD_FLAG_PREFIX += $(LIBS_USED:%=$(LIBRARY_NAME_FLAG)%)
108 # prepare for mfc style DLLs. currently we plan on all dlls we create being
109 # based on MFC. this is an unfortunate requirement for using the mfc debug
110 # support for allocations; if regular new and DEBUG_NEW get mixed together,
111 # crashes used to result. supposedly these are gone now at least.
112 ifneq "$(USE_MFC)" ""
113 # set the flag that says we are doing mfc extension dlls.
114 DEFINITIONS += _AFXDLL
116 # add in the mfc directories.
117 COMPILER_HEADER_DIR += $(COMPILER_ROOT_DIR)/mfc/include
118 COMPILER_LIBRARY_DIR += $(COMPILER_ROOT_DIR)/mfc/lib
121 ifeq "$(OMIT_VERSIONS)" ""
122 ifneq "$(VERSION_RC_ROOT)" ""
123 VERSION_TARGET = $(VERSION_RC_ROOT)_version.rc
127 # Make sure that the directory for objects exists.
128 ACTUAL_FIRST_TARGETS = check_requirements $(VERSION_TARGET) $(FIRST_TARGETS) pre_compilation
130 # Adds the primary targets to the list of products to create.
131 ACTUAL_TARGETS1 = $(TARGETS:%.exe=$(EXECUTABLE_DIR)/%.exe)
132 ACTUAL_TARGETS2 = $(ACTUAL_TARGETS1:%.dll=$(DYNAMIC_LIBRARY_DIR)/%.dynlibrary)
133 ACTUAL_TARGETS3 = $(ACTUAL_TARGETS2:%.so=$(DYNAMIC_LIBRARY_DIR)/%.so)
134 ACTUAL_TARGETS4 = $(ACTUAL_TARGETS3:%.lib=$(STATIC_LIBRARY_DIR)/%.library)
135 ACTUAL_TARGETS = $(ACTUAL_TARGETS4:%.elf=$(EXECUTABLE_DIR)/%.elf)
137 # Adds the last few targets for CLAM to do.
138 ACTUAL_LAST_TARGETS = post_compilation $(LAST_TARGETS)
140 ############################################################################
142 # This section defines the rules used to generate various objects from their
145 ############################################################################
147 # resource compiler for c#.
150 @echo Creating resource file [$@].
152 # $(CATCHER)$(RC) $< $@
154 ############################################################################
156 # resource compiler for standard resource files.
158 ifeq "$(OP_SYSTEM)" "WIN32"
160 @echo Creating resource file [$@].
161 ifeq "$(NO_COMPILE)" ""
162 $(CATCHER)$(STANDARD_RC) -r $(DEFINITIONS:%=-D%) $(HEADER_SEARCH_PATH:%=-i%) -fo $@ $<
166 ############################################################################
168 # creates dynamic libraries.
170 # we whack any existing LIB file, since we want to use changes in that file
171 # as a clue for when we should rescan the dependencies. we'd be fine if
172 # visual c++ didn't keep an existing LIB if it doesn't change (even when the
175 $(DYNAMIC_LIBRARY_DIR)/%.dynlibrary: $(LOCAL_LIBS_USED:%=$(DYNAMIC_LIBRARY_DIR)/$(LIB_PREFIX)%$(LIB_ENDING)) $(ACTUAL_RESX) $(ACTUAL_SOURCE) $(ACTUAL_RESOURCE)
176 $(HIDER)echo Creating dynamic library [$@].
177 @echo $@ >$(DIRTY_FILE)
178 $(HIDER)rm -f $(@:%.dll=%.lib)
179 $(CATCHER)$(CC) $(COMPILER_FLAGS) $(EXE_FLAGS) $(LOAD_FLAG_PREFIX) $(LOCAL_LIBS_USED:%=$(LIBRARY_NAME_FLAG)$(DYNAMIC_LIBRARY_DIR)/$(LIB_PREFIX)%$(LIB_ENDING)) $(LOAD_FLAG_SUFFIX) $(LINKER_OUTPUT_FLAG)$@ $(ACTUAL_SOURCE) $(ACTUAL_RESX:%=-res:%) $(ACTUAL_RESOURCE:%=-win32res:%)
180 ifneq "$(VCPP_VISTA_ICON)" ""
181 $(HIDER)ReplaceVistaIcon "$@" "$(VCPP_VISTA_ICON)"
183 $(HIDER)mv $@ $(DYNAMIC_LIBRARY_DIR)/$(LIB_PREFIX)$*$(LIB_ENDING)
184 ifneq "$(CREATE_TLB)" ""
185 $(CATCHER)$(TLBEXPORT) $(DYNAMIC_LIBRARY_DIR)/$(LIB_PREFIX)$*$(LIB_ENDING) -out:$(DYNAMIC_LIBRARY_DIR)/$(LIB_PREFIX)$*.tlb
189 #$(LINKER_OUTPUT_FLAG)$@ -dll $(LOAD_FLAG_PREFIX) $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(LOCAL_LIBS_USED:%=$(LIBRARY_NAME_FLAG)$(LIB_PREFIX)%$(LIB_ENDING)) $(LOAD_FLAG_SUFFIX)
191 ############################################################################
193 # creates "exe" executables using all of the appropriate objects.
194 $(EXECUTABLE_DIR)/%.exe: $(LOCAL_LIBS_USED:%=$(DYNAMIC_LIBRARY_DIR)/$(LIB_PREFIX)%$(LIB_ENDING)) $(ACTUAL_RESX) $(ACTUAL_SOURCE) $(ACTUAL_RESOURCE)
195 $(HIDER)echo Building program [$@].
196 @echo $@ >$(DIRTY_FILE)
197 $(CATCHER)$(CC) $(COMPILER_FLAGS) $(EXE_FLAGS) $(LOAD_FLAG_PREFIX) $(LOCAL_LIBS_USED:%=$(LIBRARY_NAME_FLAG)$(DYNAMIC_LIBRARY_DIR)/$(LIB_PREFIX)%$(LIB_ENDING)) $(LOAD_FLAG_SUFFIX) $(LINKER_OUTPUT_FLAG)$@ $(ACTUAL_SOURCE) $(ACTUAL_RESX:%=-res:%) $(ACTUAL_RESOURCE:%=-win32res:%)
198 ifneq "$(VCPP_VISTA_ICON)" ""
199 $(HIDER)ReplaceVistaIcon "$@" "$(VCPP_VISTA_ICON)"
202 ############################################################################
204 # handles creating version resource files if this project has a version.ini.
206 ifeq "$(OMIT_VERSIONS)" ""
207 ifneq "$(VERSION_RC_ROOT)" ""
208 # only redo the version resource if it or version.ini is out of date.
209 %_version.rc: version.ini $(PARAMETER_FILE)
210 $(CATCHER)$(CLAM_BINARIES)/version_stamper$(EXE_END) . $(PARAMETER_FILE)
214 ############################################################################
216 # Now the active part of the make process...
218 # Adds the main CLAM system in to get some work done. This should be placed
219 # after the module's rules are defined and before the module's targets are
223 # preserves intermediate files from being deleted.
224 ##.PRECIOUS: %.resources
226 # zaps things when they could not be created correctly.
229 ############################################################################
231 # examines the required variables and complains if they're missing.
233 $(HIDESH) -c 'if [ -z "$(PROJECT)" ]; then echo the PROJECT variable is not defined!; . $(CLAM_SCRIPTS)/exit_make.sh; fi'
234 $(HIDESH) -c 'if [ -z "$(TYPE)" ]; then echo the TYPE variable is not defined!; . $(CLAM_SCRIPTS)/exit_make.sh; fi'
236 ############################################################################
238 # calls the script for preparing output directories and such.
240 $(HIDESH)$(CLAM_SCRIPTS)/csharp/preconditions.sh
242 ############################################################################
244 # calls the script for copying the final products to the library directory.
245 # we don't bother reporting errors from touch since there will sometimes
246 # not be any objects in the final directory.
248 $(HIDESH)$(CLAM_SCRIPTS)/csharp/postconditions.sh
250 ############################################################################
252 # if REBUILD is defined, then we cause all objects to be recompiled.
253 .PHONY: force_rebuild
256 ifneq "$(REBUILD)" ""
257 # the target below needs the blank rule that it has for this to work.
258 $(FIRST_TARGETS) $(ACTUAL_OBJECTS:%=$(OBJECT_DIR)/%) $(ACTUAL_TARGETS) $(LAST_TARGETS): force_rebuild
261 ############################################################################