]> git.saurik.com Git - wxWidgets.git/blob - build/palmos/makefile-engine.mk
fixed condition for using #pragmas
[wxWidgets.git] / build / palmos / makefile-engine.mk
1 ## Palm OS Protein Generic Makefile Engine for Eclipse v1.0.0
2 #
3 # Last edit: 7/22/04
4 #
5 # This makefile engine is capable of compiling Protein
6 # applications for Palm OS.
7 #
8 # This makefile engine assumes that the following variables are
9 # set outside of this makefile by a referencing master makefile
10 # (see a master makefile generated by a Palm OS Developer
11 # Suite wizard for detailed explanation of each variable):
12 #
13 # SOURCES
14 # RESOURCES
15 # DATABASE_RESET
16 # DATABASE_BACKUP
17 # DATABASE_HIDDEN
18 # DATABASE_PROTECT
19 # DATABASE_BUNDLE
20 # DATABASE_VERSION
21 # DATABASE_NAME
22 # PROJECT_TYPE
23 # DEBUG_OR_RELEASE
24 # OPTIMIZE_LEVEL
25 # WARNING_LEVEL
26 # ENABLE_EXCEPTIONS
27 # ENABLE_ASSERTIONS
28 # ADDITIONAL_LINK_LIBRARIES
29 # ADDITIONAL_SIM_LINK_LIBRARIES
30 # LOCAL_INCLUDE_PATHS
31 # LOCAL_SIM_INCLUDE_PATHS
32 # SYSTEM_INCLUDE_PATHS
33 # SYSTEM_SIM_INCLUDE_PATHS
34 # DEFINES
35 # SIM_DEFINES
36 # ADDITIONAL_COMPILER_FLAGS
37 # ADDITIONAL_SIM_COMPILER_FLAGS
38 # ADDITIONAL_LINKER_FLAGS
39 # ADDITIONAL_SIM_LINKER_FLAGS
40 # ADDITIONAL_AR_FLAGS
41 # ADDITIONAL_SIM_AR_FLAGS
42 # TEXTENCODING
43 # LOCALE_CHECKING
44 # STRICT_ENCODING
45 # SDK_LOCATION
46 # TARGET_PLATFORM
47 #
48 # Additionally, the user of this makefile engine may obtain the
49 # dynamic values for:
50 # SDK_LOCATION
51 # SDK_VERSION
52 # TOOLS_DIR
53 # by doing an optional include of a makefile segment that is
54 # generated during the Palm OS Developer Suite standard make build.
55 # The makefile line to accomplish this is:
56 # -include auto-generated.mk
57 # All master makefiles generated by Palm OS Developer Suite
58 # wizards include this line already to pick up and use these
59 # dynamic definitions.
60 #
61 # All variable values may be overridden by editing the make command
62 # for the project (Project->Properties->C/C++ Make Project->Make Builder,
63 # Build Command field).
64 #
65
66 ###############################################################################
67 # Defaults
68
69 comma:= ,
70
71 ifeq ($(TOOLS_DIR), )
72 TOOLS_DIR =
73 endif
74
75 # Locale (defaults to English)
76 ifeq ($(LOCALE), )
77 LOCALE := enUS
78 endif
79
80 ifeq ($(CREATOR_ID), )
81 CREATOR_ID = STRT
82 endif
83
84 ifeq ($(DB_TYPE), )
85 DB_TYPE = appl
86 endif
87
88 ifeq ($(SLD_FILE), )
89 SLD_FILE = none
90 endif
91
92 ifeq ($(DEBUG_DEVICE_OUTPUT_DIR), )
93 DEBUG_DEVICE_OUTPUT_DIR = DebugDevice
94 endif
95
96 ifeq ($(RELEASE_DEVICE_OUTPUT_DIR), )
97 RELEASE_DEVICE_OUTPUT_DIR = ReleaseDevice
98 endif
99
100 ifeq ($(DEBUG_SIMULATOR_OUTPUT_DIR), )
101 DEBUG_SIMULATOR_OUTPUT_DIR = DebugSim
102 endif
103
104 ifeq ($(RELEASE_SIMULATOR_OUTPUT_DIR), )
105 RELEASE_SIMULATOR_OUTPUT_DIR = ReleaseSim
106 endif
107
108 ifeq ($(SDK_VERSION), )
109 SDK_VERSION = sdk-6
110 endif
111
112 ifeq ($(ENABLE_EXCEPTIONS), )
113 ENABLE_EXCEPTIONS=TRUE
114 endif
115
116 ###############################################################################
117 # App/PRC/Database Names
118 #
119 # The difference between App Name and Database name is that App Name may
120 # contain spaces while the database name is the App name with spaces removed.
121 # (Coded in such a way that if the user already explicitly defined these
122 # variables previously, we'll go with those).
123
124 ifeq ($(DATABASE_NAME), )
125 ifeq ($(ESCAPED_ARTIFACT_NAME), )
126 # Database name defaults if ARTIFACT_NAME is empty
127 DATABASE_NAME = StartApp
128 else
129 DATABASE_NAME = $(ESCAPED_ARTIFACT_NAME)
130 endif
131 endif
132
133 ifeq ($(PRC_NAME), )
134 ifeq ($(ESCAPED_ARTIFACT_NAME), )
135 # PRC name defaults if ESCAPED_ARTIFACT_NAME is empty
136 PRC_NAME = Start.prc
137 else
138 PRC_NAME = $(DATABASE_NAME).prc
139 endif
140 endif
141
142 ifeq ($(LIB_NAME), )
143 ifeq ($(ESCAPED_ARTIFACT_NAME), )
144 # LIB name defaults if ESCAPED_ARTIFACT_NAME is empty
145 LIB_NAME = Start.a
146 else
147 LIB_NAME = $(DATABASE_NAME).a
148 endif
149 endif
150
151 ifeq ($(SIM_LIB_NAME), )
152 ifeq ($(ESCAPED_ARTIFACT_NAME), )
153 # SIM LIB name defaults if ESCAPED_ARTIFACT_NAME is empty
154 SIM_LIB_NAME = Start.lib
155 else
156 SIM_LIB_NAME = $(DATABASE_NAME).lib
157 endif
158 endif
159
160 ###############################################################################
161 # Compile and Link Settings
162
163 TARGET_FORMAT=PalmOS6
164
165 # Compiler settings... compiler + optimizations + debug
166 # This is a makefile for Palm OS 6 so the compilers used are as follows:
167 # Device target compiler is pacc
168 # Simulator target compiler is gcc
169
170 CC = "$(TOOLS_DIR)pacc"
171 SIM_CC = gcc
172
173 CFLAGS += -D__PALMOS_KERNEL__=1 -D__PALMOS__=0x06000000
174 SIM_CFLAGS += -fexceptions -mno-cygwin -mwindows -D__PALMOS_KERNEL__=1 -D__PALMOS__=0x06000000 -D_SUPPORTS_NAMESPACE=0 -D_SUPPORTS_RTTI=1 -DTARGET_PLATFORM=TARGET_PLATFORM_PALMSIM_WIN32 -DTARGET_HOST=TARGET_HOST_PALMOS
175
176 # Warning level for device target
177 ifeq ($(WARNING_LEVEL), ALL)
178 CFLAGS += -W4
179 else
180 ifeq ($(WARNING_LEVEL), SOME)
181 CFLAGS += -W2
182 else
183 ifeq ($(WARNING_LEVEL), NONE)
184 CFLAGS += -W0
185 endif
186 endif
187 endif
188
189 # Warning level for simulator target
190 ifeq ($(SIM_WARNING_LEVEL), ALL)
191 SIM_CFLAGS += -Wall
192 else
193 ifeq ($(SIM_WARNING_LEVEL), NONE)
194 SIM_CFLAGS += -w
195 endif
196 endif
197
198 # Warnings as errors for device builds
199 ifeq ($(WARNING_AS_ERROR), TRUE)
200 CFLAGS += -Werror
201 endif
202
203 # Warnings as errors for simulator builds
204 ifeq ($(SIM_WARNING_AS_ERROR), TRUE)
205 SIM_CFLAGS += -Werror
206 endif
207
208 # Adding after other warnings flags so this is always in effect
209 SIM_CFLAGS += -Wno-multichar
210
211 # Verbose output for device build
212 ifeq ($(VERBOSE), TRUE)
213 CFLAGS += -v
214 endif
215
216 # Verbose output for simulator build
217 ifeq ($(SIM_VERBOSE), TRUE)
218 SIM_CFLAGS += -v
219 endif
220
221 # Dislay logo
222 ifeq ($(ARM_LOGO), TRUE)
223 CFLAGS += -logo
224 else
225 CFLAGS += -nologo
226 endif
227
228 # Exception handling support
229 ifeq ($(ENABLE_EXCEPTIONS), TRUE)
230 CFLAGS += -ex
231 LDFLAGS += -ex
232 endif
233
234 # Assertion handling support
235 ifeq ($(ENABLE_ASSERTIONS), TRUE)
236 CFLAGS += -UNDEBUG
237 else
238 CFLAGS += -DNDEBUG=1
239 endif
240
241 # Additional linker flags
242 ifdef ADDITIONAL_PALINK_FLAGS
243 LDFLAGS += $(ADDITIONAL_PALINK_FLAGS)
244 endif
245
246 # Optimization settings
247 ifeq ($(OPTIMIZE_LEVEL), INLINING)
248 OPTIMIZER_FLAG = -O5
249 SIM_OPTIMIZER_FLAG = -O3
250 else
251 ifeq ($(OPTIMIZE_LEVEL), INTERPROCEDURAL)
252 OPTIMIZER_FLAG = -O4
253 SIM_OPTIMIZER_FLAG = -O3
254 else
255 ifeq ($(OPTIMIZE_LEVEL), FULL)
256 OPTIMIZER_FLAG = -O3
257 SIM_OPTIMIZER_FLAG = -O3
258 else
259 ifeq ($(OPTIMIZE_LEVEL), INTRAPROCEDURAL)
260 OPTIMIZER_FLAG = -O2
261 SIM_OPTIMIZER_FLAG = -O3
262 else
263 ifeq ($(OPTIMIZE_LEVEL), SOME)
264 OPTIMIZER_FLAG = -O1
265 SIM_OPTIMIZER_FLAG = -O1
266 else
267 ifeq ($(OPTIMIZE_LEVEL), NONE)
268 OPTIMIZER_FLAG = -O0
269 SIM_OPTIMIZER_FLAG = -O0
270 else
271 # Default to 0 for debug, 3 for release
272 ifeq ($(DEBUG_OR_RELEASE), Debug)
273 OPTIMIZER_FLAG = -O0
274 SIM_OPTIMIZER_FLAG = -O0
275 else
276 OPTIMIZER_FLAG = -O3
277 SIM_OPTIMIZER_FLAG = -O3
278 endif
279 endif
280 endif
281 endif
282 endif
283 endif
284 endif
285
286 # Debug settings (can override optimize settings)
287 ifeq ($(DEBUG_OR_RELEASE), Debug)
288 DEBUG_FLAG += -g
289 BUILD_TYPE_FLAG = -DBUILD_TYPE=BUILD_TYPE_DEBUG
290 TRACE_OUTPUT_FLAG = -DTRACE_OUTPUT=TRACE_OUTPUT_ON
291 else
292 BUILD_TYPE_FLAG = -DBUILD_TYPE=BUILD_TYPE_RELEASE
293 TRACE_OUTPUT_FLAG = -DTRACE_OUTPUT=TRACE_OUTPUT_OFF
294 endif
295
296 ifeq ($(DEBUG_OR_RELEASE), Debug)
297 OBJ_DIR = $(DEBUG_DEVICE_OUTPUT_DIR)
298 SIM_OBJ_DIR = $(DEBUG_SIMULATOR_OUTPUT_DIR)
299 else
300 OBJ_DIR = $(RELEASE_DEVICE_OUTPUT_DIR)
301 SIM_OBJ_DIR = $(RELEASE_SIMULATOR_OUTPUT_DIR)
302 endif
303
304
305 CFLAGS += $(OPTIMIZER_FLAG) $(DEBUG_FLAG) $(BUILD_TYPE_FLAG) $(TRACE_OUTPUT_FLAG)
306 SIM_CFLAGS += $(SIM_OPTIMIZER_FLAG) $(DEBUG_FLAG) $(BUILD_TYPE_FLAG) $(TRACE_OUTPUT_FLAG)
307
308 # Linker settings (must come after setting DEBUG_FLAG)
309 LD = "$(TOOLS_DIR)pacc"
310 SIM_LD = gcc
311
312 LDFLAGS += $(DEBUG_FLAG) -nologo -Wl,-nolocals
313 SIM_LDFLAGS += $(DEBUG_FLAG) -mno-cygwin -mwindows $(SIM_OBJ_DIR)/gcc_link.def -shared -nostdlib -u___divdi3 -u___moddi3 -u___udivdi3 -u___umoddi3
314 SIM_LIBS = -L "$(TOOLS_DIR)misclibs" -lpxstlport -lpxsupc++ -lpxgcc -lgcc
315 ifeq ($(DEBUG_OR_RELEASE), Debug)
316 LDFLAGS += -Wl,-debug -Wl,-libpath -Wl,"$(SDK_LOCATION)libraries/ARM_4T/Debug/Default"
317 SIM_LIBS += "$(SDK_LOCATION)libraries/Simulator/Debug/PalmOS.lib"
318 else
319 LDFLAGS += -Wl,-libpath -Wl,"$(SDK_LOCATION)libraries/ARM_4T/Release/Default"
320 SIM_LIBS += "$(SDK_LOCATION)libraries/Simulator/Release/PalmOS.lib"
321 endif
322
323 LDOBJS = PalmOS.a SystemGlue.a FloatMgr.sa
324
325 ifeq ($(TARGET_PLATFORM), Device)
326 NATIVE_OBJ_DIR := $(OBJ_DIR)
327 RSC_OBJ_DIR := $(OBJ_DIR)
328 else
329 NATIVE_OBJ_DIR := $(SIM_OBJ_DIR)
330 RSC_OBJ_DIR := $(SIM_OBJ_DIR)
331 endif
332
333 # Librarian settings
334 AR="$(TOOLS_DIR)palib"
335 SIM_AR=ar
336
337 ARFLAGS= -c -a
338 SIM_ARFLAGS=-rc
339
340 LINKER_OUTPUT := $(OBJ_DIR)/$(DATABASE_NAME).axf
341 SIM_LINKER_OUTPUT := $(SIM_OBJ_DIR)/$(DATABASE_NAME).dll
342
343 TARGET := $(OBJ_DIR)/$(PRC_NAME)
344 SIM_TARGET := $(SIM_OBJ_DIR)/$(PRC_NAME)
345
346 STATIC_LIB_TARGET := $(OBJ_DIR)/$(LIB_NAME)
347 SIM_STATIC_LIB_TARGET := $(SIM_OBJ_DIR)/$(SIM_LIB_NAME)
348
349 ###############################################################################
350 # Resource flags (PalmRC)
351
352 RFLAGS +=
353
354 # Default text encoding is Latin
355 ifeq ($(PRC_TEXT_ENCODING), )
356 PRC_TEXT_ENCODING = LATIN
357 endif
358
359 ifeq ($(PRC_TEXT_ENCODING), LATIN)
360 RFLAGS += -target 4.0
361 else
362 ifeq ($(PRC_TEXT_ENCODING), JAPANESE)
363 RFLAGS += -target 4.0J
364 else
365 ifeq ($(PRC_TEXT_ENCODING), SIMPLIFIED_CHINESE)
366 RFLAGS += -target 4.0CS
367 endif
368 endif
369 endif
370
371 ifeq ($(PRC_NO_LOCALE_CHECK), TRUE)
372 RFLAGS += -noLocaleCheck
373 endif
374
375 ifeq ($(PRC_STRICT_LOCALE), TRUE)
376 RFLAGS += -strictLocale
377 endif
378
379 ifeq ($(PRC_STRICT_ENCODING), TRUE)
380 RFLAGS += -strictTextEncoding
381 endif
382
383 ifdef PRC_OVERLAY_FILTER
384 RFLAGS += -overlayFilter $(PRC_OVERLAY_FILTER)
385 endif
386
387 ifeq ($(PRC_NO_WARN_SIZE), TRUE)
388 RFLAGS += -noWarnSize
389 endif
390
391 ifeq ($(PRC_QUIET), TRUE)
392 RFLAGS += -quiet
393 endif
394
395 ifeq ($(PRCMERGE_QUIET), TRUE)
396 PRCFLAGS += -quiet
397 endif
398
399 ###############################################################################
400
401 # function for converting sources to object file names in one of output directories
402 define SOURCE_LIST_TO_OBJS
403 $(addprefix $(OBJ_DIR)/, $(addsuffix .o, $(foreach file, $(SOURCES), \
404 $(basename $(notdir $(file))))))
405 endef
406
407 # function for converting sources to object file names in $(SIM_OBJ_DIR)
408 define SOURCE_LIST_TO_SIM_OBJS
409 $(addprefix $(SIM_OBJ_DIR)/, $(addsuffix .o, $(foreach file, $(SOURCES), \
410 $(basename $(notdir $(file))))))
411 endef
412
413 # function for converting resources into resource object files
414 define RESOURCE_LIST_TO_OBJS
415 $(addprefix $(RSC_OBJ_DIR)/, $(addsuffix .trc, $(foreach file, $(RESOURCES), \
416 $(basename $(file)))))
417 endef
418
419 OBJS = $(SOURCE_LIST_TO_OBJS)
420 SIM_OBJS = $(SOURCE_LIST_TO_SIM_OBJS)
421 SOURCE_PATHS += $(sort $(foreach file, $(SOURCES), $(dir $(file))))
422 RESOURCE_OBJS = $(RESOURCE_LIST_TO_OBJS)
423 RESOURCE_PATHS += $(sort $(foreach file, $(RESOURCES), $(dir $(file))))
424 SLD_BASENAME := $(addsuffix _Startup, $(basename $(notdir $(SLD_FILE))))
425 SLD_OBJ := $(addprefix $(OBJ_DIR)/, $(addsuffix .o, $(SLD_BASENAME)))
426 SLD_SIM_OBJ := $(addprefix $(SIM_OBJ_DIR)/, $(addsuffix .o, $(SLD_BASENAME)))
427
428 VPATH :=
429 VPATH += $(addprefix :, $(subst ,:, $(filter-out $($(subst, :, ,$(VPATH))), $(SOURCE_PATHS) $(RESOURCE_PATHS) )))
430
431 SYSTEM_INCLUDES = $(SYSTEM_INCLUDE_PATHS) -I "$(SDK_LOCATION)headers" -I "$(SDK_LOCATION)headers/posix"
432 INCLUDES = $(LOCAL_INCLUDE_PATHS) $(foreach path, $(SOURCE_PATHS), $(addprefix -I, $(path))) $(SYSTEM_INCLUDES) $(PRE_INCLUDE_PATHS)
433 CPP_INCLUDES = -I "$(TOOLS_DIR)include/stlport"
434
435 SIM_SYSTEM_INCLUDES = $(SYSTEM_SIM_INCLUDE_PATHS) -I "$(SDK_LOCATION)headers" -I "$(SDK_LOCATION)headers/posix"
436 SIM_INCLUDES = $(LOCAL_SIM_INCLUDE_PATHS) $(foreach path, $(SOURCE_PATHS), $(addprefix -I, $(path))) $(SIM_SYSTEM_INCLUDES) $(SIM_PRE_INCLUDE_PATHS)
437 SIM_CPP_INCLUDES = -I "$(TOOLS_DIR)include/stlport"
438
439 # Now add additional settings specified by user
440 LDFLAGS += $(ADDITIONAL_LINK_LIBRARIES)
441 LDFLAGS += $(foreach libpath, $(ADDITIONAL_LINK_LIBPATH), $(addprefix -libpath , $(libpath)))
442 LDFLAGS += $(foreach option, $(ADDITIONAL_LINKER_FLAGS), $(addprefix -Wl$(comma), $(option)))
443 CFLAGS += $(foreach define, $(DEFINES), $(addprefix -D, $(define)))
444 CFLAGS += $(foreach define, $(UNDEFINES), $(addprefix -U, $(define)))
445 CFLAGS += $(ADDITIONAL_COMPILER_FLAGS)
446
447 SIM_LDFLAGS += $(ADDITIONAL_SIM_LINK_LIBRARIES)
448 SIM_LDFLAGS += $(ADDITIONAL_SIM_LINKER_FLAGS)
449 SIM_LDFLAGS += $(foreach libpath, $(ADDITIONAL_SIM_LINK_LIBPATH), $(addprefix -L, $(libpath)))
450 SIM_CFLAGS += $(foreach define, $(SIM_DEFINES), $(addprefix -D, $(define)))
451 SIM_CFLAGS += $(foreach define, $(SIM_UNDEFINES), $(addprefix -U, $(define)))
452 SIM_CFLAGS += $(ADDITIONAL_SIM_COMPILER_FLAGS)
453
454 # Specifyc additional archival flags (for static libraries)
455 ARFLAGS += $(ADDITIONAL_AR_FLAGS)
456 SIM_ARFLAGS += $(ADDITIONAL_SIM_AR_FLAGS)
457
458 RFLAGS += $(ADDITIONAL_PRC_FLAGS)
459 PRCFLAGS += $(ADDITIONAL_PRCMERGE_FLAGS)
460
461 ###############################################################################
462 # Flags for PRC creation
463
464 PRCFLAGS += -dbFlagExtendedDB -dbFlagExecutable
465
466 PRCFLAGS += -dbVersion $(DATABASE_VERSION) $(DATABASE_PROTECT) $(DATABASE_HIDDEN) $(DATABASE_BACKUP) $(DATABASE_RESET) $(DATABASE_BUNDLE)
467
468
469 ###############################################################################
470 # Flags for pslib
471
472 PSLIB_DEV_FLAGS =
473 PSLIB_SIM_FLAGS = -outSimgcc
474 ifeq ($(PROJECT_TYPE), slib)
475 PSLIB_DEV_FLAGS += -outEntryNums $(OBJ_DIR)/$(DATABASE_NAME)_Client.h -outObjStubs $(OBJ_DIR)/$(DATABASE_NAME)_Client.sa
476 PSLIB_SIM_FLAGS += -outEntryNums $(SIM_OBJ_DIR)/$(DATABASE_NAME)_Client.h -outSimStubs $(SIM_OBJ_DIR)/$(DATABASE_NAME)_Client.slib
477 endif
478
479
480
481 ###############################################################################
482 # Project make target determination
483
484 ifeq ($(TARGET_PLATFORM), Device)
485
486 ifeq ($(PROJECT_TYPE), )
487 PROJECT_TARGET = device
488 endif
489
490 ifeq ($(PROJECT_TYPE), appl)
491 PROJECT_TARGET = device
492 endif
493 ifeq ($(PROJECT_TYPE), slib)
494 PROJECT_TARGET = device_shared_lib
495 endif
496 ifeq ($(PROJECT_TYPE), lib)
497 PROJECT_TARGET = device_static_lib
498 endif
499
500 else
501
502 ifeq ($(PROJECT_TYPE), )
503 PROJECT_TARGET = simulator
504 endif
505
506 ifeq ($(PROJECT_TYPE), appl)
507 PROJECT_TARGET = simulator
508 endif
509 ifeq ($(PROJECT_TYPE), slib)
510 PROJECT_TARGET = simulator_shared_lib
511 endif
512 ifeq ($(PROJECT_TYPE), lib)
513 PROJECT_TARGET = simulator_static_lib
514 endif
515
516 endif
517
518 ###############################################################################
519 # Eclipse requires an all target to get the work done
520
521 all: $(PROJECT_TARGET)
522
523 # This rule is only valid for projects created as application projects.
524 # Don't invoke this make target directly; instead change the value of
525 # TARGET_PLATFORM to Device in the main makefile
526 device: $(OBJ_DIR) $(TARGET)
527
528 # This rule is only valid for projects created as application projects.
529 # Don't invoke this make target directly; instead change the value of
530 # TARGET_PLATFORM to Simulator in the main makefile
531 simulator: $(SIM_OBJ_DIR) $(SIM_TARGET)
532
533 # This rule is only valid for projects created as shared library projects.
534 # Don't invoke this make target directly; instead change the value of
535 # TARGET_PLATFORM to Device in the main makefile
536 device_shared_lib: $(OBJ_DIR) $(TARGET)
537
538 # This rule is only valid for projects created as shared library projects.
539 # Don't invoke this make target directly; instead change the value of
540 # TARGET_PLATFORM to Simulator in the main makefile
541 simulator_shared_lib: $(SIM_OBJ_DIR) $(SIM_TARGET)
542
543 # This rule is only valid for projects created as static library projects.
544 # Don't invoke this make target directly; instead change the value of
545 # TARGET_PLATFORM to Device in the main makefile
546 device_static_lib: $(OBJ_DIR) $(STATIC_LIB_TARGET)
547
548 # This rule is only valid for projects created as static library projects.
549 # Don't invoke this make target directly; instead change the value of
550 # TARGET_PLATFORM to Simulator in the main makefile
551 simulator_static_lib: $(SIM_OBJ_DIR) $(SIM_STATIC_LIB_TARGET)
552
553
554 # rule to create the object file directories if needed
555 $(OBJ_DIR):
556 @[ -d $(OBJ_DIR) ] || mkdir $(OBJ_DIR) > /dev/null 2>&1
557
558 $(SIM_OBJ_DIR):
559 @[ -d $(SIM_OBJ_DIR) ] || mkdir $(SIM_OBJ_DIR) > /dev/null 2>&1
560
561 # main C/C++ sources
562 $(OBJ_DIR)/%.o : %.c makefile
563 $(CC) -c $< $(INCLUDES) $(CFLAGS) -o $@
564 $(OBJ_DIR)/%.o : %.cpp makefile
565 $(CC) -c $< $(INCLUDES) $(CPP_INCLUDES) $(CFLAGS) -o $@
566 $(OBJ_DIR)/%.o : %.cp makefile
567 $(CC) -c $< $(INCLUDES) $(CPP_INCLUDES) $(CFLAGS) -o $@
568 $(OBJ_DIR)/%.o : %.cc makefile
569 $(CC) -c $< $(INCLUDES) $(CPP_INCLUDES) $(CFLAGS) -o $@
570 $(OBJ_DIR)/%.o : %.C makefile
571 $(CC) -c $< $(INCLUDES) $(CFLAGS) -o $@
572 $(OBJ_DIR)/%.o : %.CC makefile
573 $(CC) -c $< $(INCLUDES) $(CPP_INCLUDES) $(CFLAGS) -o $@
574 $(OBJ_DIR)/%.o : %.CPP makefile
575 $(CC) -c $< $(INCLUDES) $(CPP_INCLUDES) $(CFLAGS) -o $@
576
577 # Simulator C/C++ sources
578 $(SIM_OBJ_DIR)/%.o : %.c makefile
579 $(SIM_CC) -c $< $(SIM_INCLUDES) -std=c99 $(SIM_CFLAGS) -o $@
580 $(SIM_OBJ_DIR)/%.o : %.cpp makefile
581 $(SIM_CC) -c $< $(SIM_INCLUDES) $(SIM_CPP_INCLUDES) -frtti $(SIM_CFLAGS) -o $@
582 $(SIM_OBJ_DIR)/%.o : %.cp makefile
583 $(SIM_CC) -c $< $(SIM_INCLUDES) $(SIM_CPP_INCLUDES) -frtti $(SIM_CFLAGS) -o $@
584 $(SIM_OBJ_DIR)/%.o : %.cc makefile
585 $(SIM_CC) -c $< $(SIM_INCLUDES) $(SIM_CPP_INCLUDES) -frtti $(SIM_CFLAGS) -o $@
586 $(SIM_OBJ_DIR)/%.o : %.C makefile
587 $(SIM_CC) -c $< $(SIM_INCLUDES) -std=c99 $(SIM_CFLAGS) -o $@
588 $(SIM_OBJ_DIR)/%.o : %.CC makefile
589 $(SIM_CC) -c $< $(SIM_INCLUDES) $(SIM_CPP_INCLUDES) -frtti $(SIM_CFLAGS) -o $@
590 $(SIM_OBJ_DIR)/%.o : %.CPP makefile
591 $(SIM_CC) -c $< $(SIM_INCLUDES) $(SIM_CPP_INCLUDES) -frtti $(SIM_CFLAGS) -o $@
592
593
594 # XRD source processing
595 $(RSC_OBJ_DIR)/%.trc : %.xrd makefile
596 "$(TOOLS_DIR)PalmRC" -p $(TARGET_FORMAT) -makeDeps $(@D)/$(*F).deps $(RFLAGS) -locale $(LOCALE) "`cygpath -w -a ./$<`" -o $@
597 $(RSC_OBJ_DIR)/%.trc : %.XRD makefile
598 "$(TOOLS_DIR)PalmRC" -p $(TARGET_FORMAT) -makeDeps $(@D)/$(*F).deps $(RFLAGS) -locale $(LOCALE) "`cygpath -w -a ./$<`" -o $@
599
600
601 # Definition file source processing
602 $(SLD_OBJ) : makefile
603 @echo "...Processing definition file for Device..."
604 "$(TOOLS_DIR)pslib" -inDef "$(SLD_FILE)" $(PSLIB_DEV_FLAGS) -outObjStartup $@ -type '$(DB_TYPE)' -creator '$(CREATOR_ID)' -execName $(DATABASE_NAME)
605
606 $(SLD_SIM_OBJ) : makefile
607 @echo "...Processing definition file for Simulator..."
608 "$(TOOLS_DIR)pslib" -inDef "$(SLD_FILE)" $(PSLIB_SIM_FLAGS) -outSimStartup $@ -outSimRsrc $(SIM_OBJ_DIR)/acod0000.bin -outSimDefs $(SIM_OBJ_DIR)/gcc_link.def -type '$(DB_TYPE)' -creator '$(CREATOR_ID)' -execName $(DATABASE_NAME)
609
610 # Linking step
611 $(LINKER_OUTPUT) : $(OBJS)
612 @echo "...Linking for Device Target..."
613 $(LD) -o $(LINKER_OUTPUT) $(OBJS) $(SLD_OBJ) $(LDOBJS) $(LDFLAGS)
614
615 $(SIM_LINKER_OUTPUT) : $(SIM_OBJS)
616 @echo "...Linking for Simulator Target..."
617 $(SIM_LD) --entry 0 -o $(SIM_LINKER_OUTPUT) $(SIM_OBJS) $(SLD_SIM_OBJ) $(SIM_LDFLAGS) $(SIM_LIBS)
618
619
620 # Final target creation
621 $(TARGET): $(SLD_OBJ) $(LINKER_OUTPUT) $(RESOURCE_OBJS)
622 @echo "...Creating PRC for Device: $(TARGET)"
623 "$(TOOLS_DIR)pelf2bin" -format 6 -directory $(OBJ_DIR) -code acod -data adat -rsrc 0x0000 $(LINKER_OUTPUT)
624 "$(TOOLS_DIR)PRCMerge" -dbType '$(DB_TYPE)' -dbCreator '$(CREATOR_ID)' -dbName $(DATABASE_NAME) $(PRCFLAGS) -o $(TARGET) $(RESOURCE_OBJS) $(OBJ_DIR)/adat0000.bin $(OBJ_DIR)/acod0000.bin
625 @echo ...Done with Device build...
626 @echo
627
628 $(SIM_TARGET): $(SLD_SIM_OBJ) $(SIM_LINKER_OUTPUT) $(RESOURCE_OBJS)
629 @echo "...Creating PRC for Simulator: $(SIM_TARGET)"
630 cp -f "$(SDK_LOCATION)misctools/Resources/amdd_fake" $(SIM_OBJ_DIR)/adat0000.bin
631 "$(TOOLS_DIR)PRCMerge" -dbType '$(DB_TYPE)' -dbCreator '$(CREATOR_ID)' -dbName $(DATABASE_NAME) $(PRCFLAGS) -o $(SIM_TARGET) $(RESOURCE_OBJS) $(SIM_OBJ_DIR)/adat0000.bin $(SIM_OBJ_DIR)/acod0000.bin
632 @echo ...Done with Simulator build...
633 @echo
634
635 $(STATIC_LIB_TARGET) : $(OBJS)
636 @echo "...Linking Static Library for Device Target..."
637 $(AR) $(ARFLAGS) $(STATIC_LIB_TARGET) $(OBJS)
638
639 $(SIM_STATIC_LIB_TARGET) : $(SIM_OBJS)
640 @echo "...Linking Static Library for Simulator Target..."
641 $(SIM_AR) $(SIM_ARFLAGS) $(SIM_STATIC_LIB_TARGET) $(SIM_OBJS)
642
643
644 FORCE:
645
646 # Eclipse requires a clean command
647 clean :: FORCE
648 -rm -rf $(NATIVE_OBJ_DIR)/*
649
650
651 printvars :: FORCE
652 @echo "SDK_LOCATION"
653 @echo $(SDK_LOCATION)
654 @echo "CFLAGS"
655 @echo $(CFLAGS)
656 @echo "SIM_CFLAGS"
657 @echo $(SIM_CFLAGS)
658 @echo "LDFLAGS"
659 @echo $(LDFLAGS)
660 @echo "SIM_LDFLAGS"
661 @echo $(SIM_LDFLAGS)
662 @echo "OBJS"
663 @echo $(OBJS)
664 @echo "SIM_OBJS"
665 @echo $(SIM_OBJS)
666 @echo "SLD_OBJ"
667 @echo $(SLD_OBJ)
668 @echo "SLD_SIM_OBJ"
669 @echo $(SLD_SIM_OBJ)
670 @echo "TARGET"
671 @echo $(TARGET)
672 @echo "SIM_TARGET"
673 @echo $(SIM_TARGET)
674 @echo "SOURCE_PATHS"
675 @echo $(SOURCE_PATHS)
676 @echo "RESOURCE_OBJS"
677 @echo $(RESOURCE_OBJS)
678 @echo "RESOURCE_PATHS"
679 @echo $(RESOURCE_PATHS)
680 @echo "OBJ_DIR"
681 @echo $(OBJ_DIR)
682 @echo "SIM_OBJ_DIR"
683 @echo $(SIM_OBJ_DIR)
684 @echo "RSC_OBJ_DIR"
685 @echo $(RSC_OBJ_DIR)
686 @echo "LINKER_OUTPUT"
687 @echo $(LINKER_OUTPUT)
688 @echo "SIM_LINKER_OUTPUT"
689 @echo $(SIM_LINKER_OUTPUT)
690 @echo "SIM_GCC_SLIBS"
691 @echo $(SIM_GCC_SLIBS)
692 @echo "SIM_GCC_SLIB_PATHS"
693 @echo $(SIM_GCC_SLIB_PATHS)
694 @echo "VPATH"
695 @echo $(VPATH)
696
697
698 #
699 # dependency generation
700 # Generate dependencies with depend target "make depend"
701 #
702
703 DEPFLAG = -MM
704
705 #
706 # Adds $(SIM_OBJ_DIR) to target .o file
707 # ...Search for string starting at the beginning of the line [^]
708 # ...that contain anything followed by .o [.*\.o]
709 # ...and remember that string [\(...\)]
710 # ...replace that string with $(SIM_OBJ_DIR)/<tagged string> [$$(SIM_OBJ_DIR)/\1]
711 # ($ is doubled so that make doesn't interpret the variable syntax)
712 #
713 SOURCE_SEDSCRIPT = sed -e's%^\(.*\.o\)%$$(OBJ_DIR)/\1%'
714 SOURCE_SIM_SEDSCRIPT = sed -e's%^\(.*\.o\)%$$(SIM_OBJ_DIR)/\1%'
715
716 # Command adds $(RSC_OBJ_DIR) and converts .xrd to .trc
717 RESOURCE_TARGET_SEDSCRIPT = sed -e';s%^\(.*\).xrd%$$(RSC_OBJ_DIR)/\1.trc%'
718
719 # Command to escape spaces in a path
720 ESCAPE_SPACES_SEDSCRIPT = sed 's/ /\\\ /g'
721
722 # Take out all newlines (and/or returns) and replace with spaces
723 # ...putting all dependencies on the same line
724 RESOURCE_PREREQ_SEDSCRIPT = tr '\r\n' ' '
725
726 depend :: FORCE
727 @echo "" > .dependencies
728 @$(SIM_CC) $(SIM_INCLUDES) $(SIM_CFLAGS) $(DEPFLAG) $(SOURCES) | $(SOURCE_SIM_SEDSCRIPT) >> .dependencies
729 @$(SIM_CC) $(SIM_INCLUDES) $(SIM_CFLAGS) $(DEPFLAG) $(SOURCES) | $(SOURCE_SEDSCRIPT) >> .dependencies
730 @for i in $(RESOURCES); do \
731 echo "$$i: \\" | $(RESOURCE_TARGET_SEDSCRIPT) >> .resdependencies; \
732 "$(TOOLS_DIR)PalmRC" -p $(TARGET_FORMAT) $(RFLAGS) -locale $(LOCALE) -makedeps $$i.tmp "`cygpath -w -a ./$$i`"; \
733 cygpath -m -f $$i.tmp | $(ESCAPE_SPACES_SEDSCRIPT) >> $$i.deps; \
734 rm -rf $$i.tmp; \
735 cat $$i.deps | $(RESOURCE_PREREQ_SEDSCRIPT) >> .resdependencies; \
736 echo "" >> .resdependencies; \
737 rm -rf $$i.deps; \
738 cat .resdependencies >> .dependencies; \
739 rm -rf .resdependencies; \
740 done
741
742
743 cleandepend :: FORCE
744 -rm -f .dependencies
745
746 -include .dependencies