]> git.saurik.com Git - wxWidgets.git/blob - build/palmos/makefile-engine.mk
PalmOS 6 compilation fixes (patch 1849757)
[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 ifeq ($(TARGET_FORMAT), )
164 TARGET_FORMAT=PalmOS6
165 endif
166
167 # Compiler settings... compiler + optimizations + debug
168 # This is a makefile for Palm OS 6 so the compilers used are as follows:
169 # Device target compiler is pacc
170 # Simulator target compiler is gcc
171
172 CC = "$(TOOLS_DIR)pacc"
173 SIM_CC = gcc
174
175 CFLAGS += -D__PALMOS_KERNEL__=1 -D__PALMOS__=0x06000000
176 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
177
178 # Warning level for device target
179 ifeq ($(WARNING_LEVEL), ALL)
180 CFLAGS += -W4
181 else
182 ifeq ($(WARNING_LEVEL), SOME)
183 CFLAGS += -W2
184 else
185 ifeq ($(WARNING_LEVEL), NONE)
186 CFLAGS += -W0
187 endif
188 endif
189 endif
190
191 # Warning level for simulator target
192 ifeq ($(SIM_WARNING_LEVEL), ALL)
193 SIM_CFLAGS += -Wall
194 else
195 ifeq ($(SIM_WARNING_LEVEL), NONE)
196 SIM_CFLAGS += -w
197 endif
198 endif
199
200 # Warnings as errors for device builds
201 ifeq ($(WARNING_AS_ERROR), TRUE)
202 CFLAGS += -Werror
203 endif
204
205 # Warnings as errors for simulator builds
206 ifeq ($(SIM_WARNING_AS_ERROR), TRUE)
207 SIM_CFLAGS += -Werror
208 endif
209
210 # Adding after other warnings flags so this is always in effect
211 SIM_CFLAGS += -Wno-multichar
212
213 # Verbose output for device build
214 ifeq ($(VERBOSE), TRUE)
215 CFLAGS += -v
216 endif
217
218 # Verbose output for simulator build
219 ifeq ($(SIM_VERBOSE), TRUE)
220 SIM_CFLAGS += -v
221 endif
222
223 # Dislay logo
224 ifeq ($(ARM_LOGO), TRUE)
225 CFLAGS += -logo
226 else
227 CFLAGS += -nologo
228 endif
229
230 # Exception handling support
231 ifeq ($(ENABLE_EXCEPTIONS), TRUE)
232 CFLAGS += -ex
233 LDFLAGS += -ex
234 endif
235
236 # Assertion handling support
237 ifeq ($(ENABLE_ASSERTIONS), TRUE)
238 CFLAGS += -UNDEBUG
239 else
240 CFLAGS += -DNDEBUG=1
241 endif
242
243 # Additional linker flags
244 ifdef ADDITIONAL_PALINK_FLAGS
245 LDFLAGS += $(ADDITIONAL_PALINK_FLAGS)
246 endif
247
248 # Optimization settings
249 ifeq ($(OPTIMIZE_LEVEL), INLINING)
250 OPTIMIZER_FLAG = -O5
251 SIM_OPTIMIZER_FLAG = -O3
252 else
253 ifeq ($(OPTIMIZE_LEVEL), INTERPROCEDURAL)
254 OPTIMIZER_FLAG = -O4
255 SIM_OPTIMIZER_FLAG = -O3
256 else
257 ifeq ($(OPTIMIZE_LEVEL), FULL)
258 OPTIMIZER_FLAG = -O3
259 SIM_OPTIMIZER_FLAG = -O3
260 else
261 ifeq ($(OPTIMIZE_LEVEL), INTRAPROCEDURAL)
262 OPTIMIZER_FLAG = -O2
263 SIM_OPTIMIZER_FLAG = -O3
264 else
265 ifeq ($(OPTIMIZE_LEVEL), SOME)
266 OPTIMIZER_FLAG = -O1
267 SIM_OPTIMIZER_FLAG = -O1
268 else
269 ifeq ($(OPTIMIZE_LEVEL), NONE)
270 OPTIMIZER_FLAG = -O0
271 SIM_OPTIMIZER_FLAG = -O0
272 else
273 # Default to 0 for debug, 3 for release
274 ifeq ($(DEBUG_OR_RELEASE), Debug)
275 OPTIMIZER_FLAG = -O0
276 SIM_OPTIMIZER_FLAG = -O0
277 else
278 OPTIMIZER_FLAG = -O3
279 SIM_OPTIMIZER_FLAG = -O3
280 endif
281 endif
282 endif
283 endif
284 endif
285 endif
286 endif
287
288 # Debug settings (can override optimize settings)
289 ifeq ($(DEBUG_OR_RELEASE), Debug)
290 DEBUG_FLAG += -g
291 BUILD_TYPE_FLAG = -DBUILD_TYPE=BUILD_TYPE_DEBUG
292 TRACE_OUTPUT_FLAG = -DTRACE_OUTPUT=TRACE_OUTPUT_ON
293 else
294 BUILD_TYPE_FLAG = -DBUILD_TYPE=BUILD_TYPE_RELEASE
295 TRACE_OUTPUT_FLAG = -DTRACE_OUTPUT=TRACE_OUTPUT_OFF
296 endif
297
298 ifeq ($(DEBUG_OR_RELEASE), Debug)
299 OBJ_DIR = $(DEBUG_DEVICE_OUTPUT_DIR)
300 SIM_OBJ_DIR = $(DEBUG_SIMULATOR_OUTPUT_DIR)
301 else
302 OBJ_DIR = $(RELEASE_DEVICE_OUTPUT_DIR)
303 SIM_OBJ_DIR = $(RELEASE_SIMULATOR_OUTPUT_DIR)
304 endif
305
306
307 CFLAGS += $(OPTIMIZER_FLAG) $(DEBUG_FLAG) $(BUILD_TYPE_FLAG) $(TRACE_OUTPUT_FLAG)
308 SIM_CFLAGS += $(SIM_OPTIMIZER_FLAG) $(DEBUG_FLAG) $(BUILD_TYPE_FLAG) $(TRACE_OUTPUT_FLAG)
309
310 # Linker settings (must come after setting DEBUG_FLAG)
311 LD = "$(TOOLS_DIR)pacc"
312 SIM_LD = gcc
313
314 LDFLAGS += $(DEBUG_FLAG) -nologo -Wl,-nolocals
315 SIM_LDFLAGS += $(DEBUG_FLAG) -mno-cygwin -mwindows $(SIM_OBJ_DIR)/gcc_link.def -shared -nostdlib -u___divdi3 -u___moddi3 -u___udivdi3 -u___umoddi3
316 SIM_LIBS = -L "$(TOOLS_DIR)misclibs" -lpxstlport -lpxsupc++ -lpxgcc -lgcc
317 ifeq ($(DEBUG_OR_RELEASE), Debug)
318 LDFLAGS += -Wl,-debug -Wl,-libpath -Wl,"$(SDK_LOCATION)libraries/ARM_4T/Debug/Default"
319 SIM_LIBS += "$(SDK_LOCATION)libraries/Simulator/Debug/PalmOS.lib"
320 else
321 LDFLAGS += -Wl,-libpath -Wl,"$(SDK_LOCATION)libraries/ARM_4T/Release/Default"
322 SIM_LIBS += "$(SDK_LOCATION)libraries/Simulator/Release/PalmOS.lib"
323 endif
324
325 LDOBJS = PalmOS.a SystemGlue.a FloatMgr.sa
326
327 ifeq ($(TARGET_PLATFORM), Device)
328 NATIVE_OBJ_DIR := $(OBJ_DIR)
329 RSC_OBJ_DIR := $(OBJ_DIR)
330 else
331 NATIVE_OBJ_DIR := $(SIM_OBJ_DIR)
332 RSC_OBJ_DIR := $(SIM_OBJ_DIR)
333 endif
334
335 # Librarian settings
336 AR="$(TOOLS_DIR)palib"
337 SIM_AR=ar
338
339 ARFLAGS= -c -a
340 SIM_ARFLAGS=-rc
341
342 LINKER_OUTPUT := $(OBJ_DIR)/$(DATABASE_NAME).axf
343 SIM_LINKER_OUTPUT := $(SIM_OBJ_DIR)/$(DATABASE_NAME).dll
344
345 TARGET := $(OBJ_DIR)/$(PRC_NAME)
346 SIM_TARGET := $(SIM_OBJ_DIR)/$(PRC_NAME)
347
348 STATIC_LIB_TARGET := $(OBJ_DIR)/$(LIB_NAME)
349 SIM_STATIC_LIB_TARGET := $(SIM_OBJ_DIR)/$(SIM_LIB_NAME)
350
351 ###############################################################################
352 # Resource flags (PalmRC)
353
354 RFLAGS +=
355
356 # Default text encoding is Latin
357 ifeq ($(PRC_TEXT_ENCODING), )
358 PRC_TEXT_ENCODING = LATIN
359 endif
360
361 ifeq ($(PRC_TEXT_ENCODING), LATIN)
362 RFLAGS += -target 4.0
363 else
364 ifeq ($(PRC_TEXT_ENCODING), JAPANESE)
365 RFLAGS += -target 4.0J
366 else
367 ifeq ($(PRC_TEXT_ENCODING), SIMPLIFIED_CHINESE)
368 RFLAGS += -target 4.0CS
369 endif
370 endif
371 endif
372
373 ifeq ($(PRC_NO_LOCALE_CHECK), TRUE)
374 RFLAGS += -noLocaleCheck
375 endif
376
377 ifeq ($(PRC_STRICT_LOCALE), TRUE)
378 RFLAGS += -strictLocale
379 endif
380
381 ifeq ($(PRC_STRICT_ENCODING), TRUE)
382 RFLAGS += -strictTextEncoding
383 endif
384
385 ifdef PRC_OVERLAY_FILTER
386 RFLAGS += -overlayFilter $(PRC_OVERLAY_FILTER)
387 endif
388
389 ifeq ($(PRC_NO_WARN_SIZE), TRUE)
390 RFLAGS += -noWarnSize
391 endif
392
393 ifeq ($(PRC_QUIET), TRUE)
394 RFLAGS += -quiet
395 endif
396
397 ifeq ($(PRCMERGE_QUIET), TRUE)
398 PRCFLAGS += -quiet
399 endif
400
401 ###############################################################################
402
403 # function for converting sources to object file names in one of output directories
404 define SOURCE_LIST_TO_OBJS
405 $(addprefix $(OBJ_DIR)/, $(addsuffix .o, $(foreach file, $(SOURCES), \
406 $(basename $(notdir $(file))))))
407 endef
408
409 # function for converting sources to object file names in $(SIM_OBJ_DIR)
410 define SOURCE_LIST_TO_SIM_OBJS
411 $(addprefix $(SIM_OBJ_DIR)/, $(addsuffix .o, $(foreach file, $(SOURCES), \
412 $(basename $(notdir $(file))))))
413 endef
414
415 # function for converting resources into resource object files
416 define RESOURCE_LIST_TO_OBJS
417 $(addprefix $(RSC_OBJ_DIR)/, $(addsuffix .trc, $(foreach file, $(RESOURCES), \
418 $(basename $(file)))))
419 endef
420
421 OBJS = $(SOURCE_LIST_TO_OBJS)
422 SIM_OBJS = $(SOURCE_LIST_TO_SIM_OBJS)
423 SOURCE_PATHS += $(sort $(foreach file, $(SOURCES), $(dir $(file))))
424 RESOURCE_OBJS = $(RESOURCE_LIST_TO_OBJS)
425 RESOURCE_PATHS += $(sort $(foreach file, $(RESOURCES), $(dir $(file))))
426 SLD_BASENAME := $(addsuffix _Startup, $(basename $(notdir $(SLD_FILE))))
427 SLD_OBJ := $(addprefix $(OBJ_DIR)/, $(addsuffix .o, $(SLD_BASENAME)))
428 SLD_SIM_OBJ := $(addprefix $(SIM_OBJ_DIR)/, $(addsuffix .o, $(SLD_BASENAME)))
429
430 VPATH :=
431 VPATH += $(addprefix :, $(subst ,:, $(filter-out $($(subst, :, ,$(VPATH))), $(SOURCE_PATHS) $(RESOURCE_PATHS) )))
432
433 # -I "$(SDK_LOCATION)include" -I "$(SDK_LOCATION)include/Core/System" #
434 SYSTEM_INCLUDES = $(SYSTEM_INCLUDE_PATHS) -I "$(SDK_LOCATION)headers" -I "$(SDK_LOCATION)headers/posix"
435 INCLUDES = $(LOCAL_INCLUDE_PATHS) $(foreach path, $(SOURCE_PATHS), $(addprefix -I, $(path))) $(SYSTEM_INCLUDES) $(PRE_INCLUDE_PATHS)
436 CPP_INCLUDES = -I "$(TOOLS_DIR)include/stlport"
437
438 SIM_SYSTEM_INCLUDES = $(SYSTEM_SIM_INCLUDE_PATHS) -I "$(SDK_LOCATION)headers" -I "$(SDK_LOCATION)headers/posix"
439 SIM_INCLUDES = $(LOCAL_SIM_INCLUDE_PATHS) $(foreach path, $(SOURCE_PATHS), $(addprefix -I, $(path))) $(SIM_SYSTEM_INCLUDES) $(SIM_PRE_INCLUDE_PATHS)
440 SIM_CPP_INCLUDES = -I "$(TOOLS_DIR)include/stlport"
441
442 # Now add additional settings specified by user
443 LDFLAGS += $(ADDITIONAL_LINK_LIBRARIES)
444 LDFLAGS += $(foreach libpath, $(ADDITIONAL_LINK_LIBPATH), $(addprefix -libpath , $(libpath)))
445 LDFLAGS += $(foreach option, $(ADDITIONAL_LINKER_FLAGS), $(addprefix -Wl$(comma), $(option)))
446 CFLAGS += $(foreach define, $(DEFINES), $(addprefix -D, $(define)))
447 CFLAGS += $(foreach define, $(UNDEFINES), $(addprefix -U, $(define)))
448 CFLAGS += $(ADDITIONAL_COMPILER_FLAGS)
449
450 SIM_LDFLAGS += $(ADDITIONAL_SIM_LINK_LIBRARIES)
451 SIM_LDFLAGS += $(ADDITIONAL_SIM_LINKER_FLAGS)
452 SIM_LDFLAGS += $(foreach libpath, $(ADDITIONAL_SIM_LINK_LIBPATH), $(addprefix -L, $(libpath)))
453 SIM_CFLAGS += $(foreach define, $(SIM_DEFINES), $(addprefix -D, $(define)))
454 SIM_CFLAGS += $(foreach define, $(SIM_UNDEFINES), $(addprefix -U, $(define)))
455 SIM_CFLAGS += $(ADDITIONAL_SIM_COMPILER_FLAGS)
456
457 # Specifyc additional archival flags (for static libraries)
458 ARFLAGS += $(ADDITIONAL_AR_FLAGS)
459 SIM_ARFLAGS += $(ADDITIONAL_SIM_AR_FLAGS)
460
461 RFLAGS += $(ADDITIONAL_PRC_FLAGS)
462 PRCFLAGS += $(ADDITIONAL_PRCMERGE_FLAGS)
463
464 ###############################################################################
465 # Flags for PRC creation
466
467 PRCFLAGS += -dbFlagExtendedDB -dbFlagExecutable
468
469 PRCFLAGS += -dbVersion $(DATABASE_VERSION) $(DATABASE_PROTECT) $(DATABASE_HIDDEN) $(DATABASE_BACKUP) $(DATABASE_RESET) $(DATABASE_BUNDLE)
470
471
472 ###############################################################################
473 # Flags for pslib
474
475 PSLIB_DEV_FLAGS =
476 PSLIB_SIM_FLAGS = -outSimgcc
477 ifeq ($(PROJECT_TYPE), slib)
478 PSLIB_DEV_FLAGS += -outEntryNums $(OBJ_DIR)/$(DATABASE_NAME)_Client.h -outObjStubs $(OBJ_DIR)/$(DATABASE_NAME)_Client.sa
479 PSLIB_SIM_FLAGS += -outEntryNums $(SIM_OBJ_DIR)/$(DATABASE_NAME)_Client.h -outSimStubs $(SIM_OBJ_DIR)/$(DATABASE_NAME)_Client.slib
480 endif
481
482
483
484 ###############################################################################
485 # Project make target determination
486
487 ifeq ($(TARGET_PLATFORM), Device)
488
489 ifeq ($(PROJECT_TYPE), )
490 PROJECT_TARGET = device
491 endif
492
493 ifeq ($(PROJECT_TYPE), appl)
494 PROJECT_TARGET = device
495 endif
496 ifeq ($(PROJECT_TYPE), slib)
497 PROJECT_TARGET = device_shared_lib
498 endif
499 ifeq ($(PROJECT_TYPE), lib)
500 PROJECT_TARGET = device_static_lib
501 endif
502
503 else
504
505 ifeq ($(PROJECT_TYPE), )
506 PROJECT_TARGET = simulator
507 endif
508
509 ifeq ($(PROJECT_TYPE), appl)
510 PROJECT_TARGET = simulator
511 endif
512 ifeq ($(PROJECT_TYPE), slib)
513 PROJECT_TARGET = simulator_shared_lib
514 endif
515 ifeq ($(PROJECT_TYPE), lib)
516 PROJECT_TARGET = simulator_static_lib
517 endif
518
519 endif
520
521 ###############################################################################
522 # Eclipse requires an all target to get the work done
523
524 all: $(PROJECT_TARGET)
525
526 # This rule is only valid for projects created as application projects.
527 # Don't invoke this make target directly; instead change the value of
528 # TARGET_PLATFORM to Device in the main makefile
529 device: $(OBJ_DIR) $(TARGET)
530
531 # This rule is only valid for projects created as application projects.
532 # Don't invoke this make target directly; instead change the value of
533 # TARGET_PLATFORM to Simulator in the main makefile
534 simulator: $(SIM_OBJ_DIR) $(SIM_TARGET)
535
536 # This rule is only valid for projects created as shared library projects.
537 # Don't invoke this make target directly; instead change the value of
538 # TARGET_PLATFORM to Device in the main makefile
539 device_shared_lib: $(OBJ_DIR) $(TARGET)
540
541 # This rule is only valid for projects created as shared library projects.
542 # Don't invoke this make target directly; instead change the value of
543 # TARGET_PLATFORM to Simulator in the main makefile
544 simulator_shared_lib: $(SIM_OBJ_DIR) $(SIM_TARGET)
545
546 # This rule is only valid for projects created as static library projects.
547 # Don't invoke this make target directly; instead change the value of
548 # TARGET_PLATFORM to Device in the main makefile
549 device_static_lib: $(OBJ_DIR) $(STATIC_LIB_TARGET)
550
551 # This rule is only valid for projects created as static library projects.
552 # Don't invoke this make target directly; instead change the value of
553 # TARGET_PLATFORM to Simulator in the main makefile
554 simulator_static_lib: $(SIM_OBJ_DIR) $(SIM_STATIC_LIB_TARGET)
555
556
557 # rule to create the object file directories if needed
558 $(OBJ_DIR):
559 @[ -d $(OBJ_DIR) ] || mkdir $(OBJ_DIR) > /dev/null 2>&1
560
561 $(SIM_OBJ_DIR):
562 @[ -d $(SIM_OBJ_DIR) ] || mkdir $(SIM_OBJ_DIR) > /dev/null 2>&1
563
564 # main C/C++ sources
565 $(OBJ_DIR)/%.o : %.c makefile
566 $(CC) -c $< $(INCLUDES) $(CFLAGS) -o $@
567 $(OBJ_DIR)/%.o : %.cpp makefile
568 $(CC) -c $< $(INCLUDES) $(CPP_INCLUDES) $(CFLAGS) -o $@
569 $(OBJ_DIR)/%.o : %.cp makefile
570 $(CC) -c $< $(INCLUDES) $(CPP_INCLUDES) $(CFLAGS) -o $@
571 $(OBJ_DIR)/%.o : %.cc makefile
572 $(CC) -c $< $(INCLUDES) $(CPP_INCLUDES) $(CFLAGS) -o $@
573 $(OBJ_DIR)/%.o : %.C makefile
574 $(CC) -c $< $(INCLUDES) $(CFLAGS) -o $@
575 $(OBJ_DIR)/%.o : %.CC makefile
576 $(CC) -c $< $(INCLUDES) $(CPP_INCLUDES) $(CFLAGS) -o $@
577 $(OBJ_DIR)/%.o : %.CPP makefile
578 $(CC) -c $< $(INCLUDES) $(CPP_INCLUDES) $(CFLAGS) -o $@
579
580 # Simulator C/C++ sources
581 $(SIM_OBJ_DIR)/%.o : %.c makefile
582 $(SIM_CC) -c $< $(SIM_INCLUDES) -std=c99 $(SIM_CFLAGS) -o $@
583 $(SIM_OBJ_DIR)/%.o : %.cpp makefile
584 $(SIM_CC) -c $< $(SIM_INCLUDES) $(SIM_CPP_INCLUDES) -frtti $(SIM_CFLAGS) -o $@
585 $(SIM_OBJ_DIR)/%.o : %.cp makefile
586 $(SIM_CC) -c $< $(SIM_INCLUDES) $(SIM_CPP_INCLUDES) -frtti $(SIM_CFLAGS) -o $@
587 $(SIM_OBJ_DIR)/%.o : %.cc makefile
588 $(SIM_CC) -c $< $(SIM_INCLUDES) $(SIM_CPP_INCLUDES) -frtti $(SIM_CFLAGS) -o $@
589 $(SIM_OBJ_DIR)/%.o : %.C makefile
590 $(SIM_CC) -c $< $(SIM_INCLUDES) -std=c99 $(SIM_CFLAGS) -o $@
591 $(SIM_OBJ_DIR)/%.o : %.CC makefile
592 $(SIM_CC) -c $< $(SIM_INCLUDES) $(SIM_CPP_INCLUDES) -frtti $(SIM_CFLAGS) -o $@
593 $(SIM_OBJ_DIR)/%.o : %.CPP makefile
594 $(SIM_CC) -c $< $(SIM_INCLUDES) $(SIM_CPP_INCLUDES) -frtti $(SIM_CFLAGS) -o $@
595
596
597 # XRD source processing
598 $(RSC_OBJ_DIR)/%.trc : %.xrd makefile
599 "$(TOOLS_DIR)PalmRC" -p $(TARGET_FORMAT) -makeDeps $(@D)/$(*F).deps $(RFLAGS) -locale $(LOCALE) "`cygpath -w -a ./$<`" -o $@
600 $(RSC_OBJ_DIR)/%.trc : %.XRD makefile
601 "$(TOOLS_DIR)PalmRC" -p $(TARGET_FORMAT) -makeDeps $(@D)/$(*F).deps $(RFLAGS) -locale $(LOCALE) "`cygpath -w -a ./$<`" -o $@
602
603
604 # Definition file source processing
605 $(SLD_OBJ) : makefile
606 @echo "...Processing definition file for Device..."
607 "$(TOOLS_DIR)pslib" -inDef "$(SLD_FILE)" $(PSLIB_DEV_FLAGS) -outObjStartup $@ -type '$(DB_TYPE)' -creator '$(CREATOR_ID)' -execName $(DATABASE_NAME)
608 $(INSTALL_DIR) $(incdir)/wx/
609 $(INSTALL_DATA) ../../include/wx/palmos/setup0.h $(incdir)/wx/setup.h
610
611
612 $(SLD_SIM_OBJ) : makefile
613 @echo "...Processing definition file for Simulator..."
614 "$(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)
615 $(INSTALL_DIR) $(incdir)/wx/
616 $(INSTALL_DATA) ../../include/wx/palmos/setup0.h $(incdir)/wx/setup.h
617
618 # Linking step
619 $(LINKER_OUTPUT) : $(OBJS)
620 @echo "...Linking for Device Target..."
621 $(LD) -o $(LINKER_OUTPUT) $(OBJS) $(SLD_OBJ) $(LDOBJS) $(LDFLAGS)
622
623 $(SIM_LINKER_OUTPUT) : $(SIM_OBJS)
624 @echo "...Linking for Simulator Target..."
625 $(SIM_LD) --entry 0 -o $(SIM_LINKER_OUTPUT) $(SIM_OBJS) $(SLD_SIM_OBJ) $(SIM_LDFLAGS) $(SIM_LIBS)
626
627
628 # Final target creation
629 $(TARGET): $(SLD_OBJ) $(LINKER_OUTPUT) $(RESOURCE_OBJS)
630 @echo "...Creating PRC for Device: $(TARGET)"
631 "$(TOOLS_DIR)pelf2bin" -format 6 -directory $(OBJ_DIR) -code acod -data adat -rsrc 0x0000 $(LINKER_OUTPUT)
632 "$(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
633 @echo ...Done with Device build...
634 @echo
635
636 $(SIM_TARGET): $(SLD_SIM_OBJ) $(SIM_LINKER_OUTPUT) $(RESOURCE_OBJS)
637 @echo "...Creating PRC for Simulator: $(SIM_TARGET)"
638 cp -f "$(SDK_LOCATION)misctools/Resources/amdd_fake" $(SIM_OBJ_DIR)/adat0000.bin
639 "$(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
640 @echo ...Done with Simulator build...
641 @echo
642
643 $(STATIC_LIB_TARGET) : $(OBJS)
644 @echo "...Linking Static Library for Device Target..."
645 $(AR) $(ARFLAGS) $(STATIC_LIB_TARGET) $(OBJS)
646
647 $(SIM_STATIC_LIB_TARGET) : $(SIM_OBJS)
648 @echo "...Linking Static Library for Simulator Target..."
649 $(SIM_AR) $(SIM_ARFLAGS) $(SIM_STATIC_LIB_TARGET) $(SIM_OBJS)
650
651
652 FORCE:
653
654 # Eclipse requires a clean command
655 clean :: FORCE
656 -rm -rf $(NATIVE_OBJ_DIR)/*
657
658
659 printvars :: FORCE
660 @echo "SDK_LOCATION"
661 @echo $(SDK_LOCATION)
662 @echo "CFLAGS"
663 @echo $(CFLAGS)
664 @echo "SIM_CFLAGS"
665 @echo $(SIM_CFLAGS)
666 @echo "LDFLAGS"
667 @echo $(LDFLAGS)
668 @echo "SIM_LDFLAGS"
669 @echo $(SIM_LDFLAGS)
670 @echo "OBJS"
671 @echo $(OBJS)
672 @echo "SIM_OBJS"
673 @echo $(SIM_OBJS)
674 @echo "SLD_OBJ"
675 @echo $(SLD_OBJ)
676 @echo "SLD_SIM_OBJ"
677 @echo $(SLD_SIM_OBJ)
678 @echo "TARGET"
679 @echo $(TARGET)
680 @echo "SIM_TARGET"
681 @echo $(SIM_TARGET)
682 @echo "SOURCE_PATHS"
683 @echo $(SOURCE_PATHS)
684 @echo "RESOURCE_OBJS"
685 @echo $(RESOURCE_OBJS)
686 @echo "RESOURCE_PATHS"
687 @echo $(RESOURCE_PATHS)
688 @echo "OBJ_DIR"
689 @echo $(OBJ_DIR)
690 @echo "SIM_OBJ_DIR"
691 @echo $(SIM_OBJ_DIR)
692 @echo "RSC_OBJ_DIR"
693 @echo $(RSC_OBJ_DIR)
694 @echo "LINKER_OUTPUT"
695 @echo $(LINKER_OUTPUT)
696 @echo "SIM_LINKER_OUTPUT"
697 @echo $(SIM_LINKER_OUTPUT)
698 @echo "SIM_GCC_SLIBS"
699 @echo $(SIM_GCC_SLIBS)
700 @echo "SIM_GCC_SLIB_PATHS"
701 @echo $(SIM_GCC_SLIB_PATHS)
702 @echo "VPATH"
703 @echo $(VPATH)
704
705
706 #
707 # dependency generation
708 # Generate dependencies with depend target "make depend"
709 #
710
711 DEPFLAG = -MM
712
713 #
714 # Adds $(SIM_OBJ_DIR) to target .o file
715 # ...Search for string starting at the beginning of the line [^]
716 # ...that contain anything followed by .o [.*\.o]
717 # ...and remember that string [\(...\)]
718 # ...replace that string with $(SIM_OBJ_DIR)/<tagged string> [$$(SIM_OBJ_DIR)/\1]
719 # ($ is doubled so that make doesn't interpret the variable syntax)
720 #
721 SOURCE_SEDSCRIPT = sed -e's%^\(.*\.o\)%$$(OBJ_DIR)/\1%'
722 SOURCE_SIM_SEDSCRIPT = sed -e's%^\(.*\.o\)%$$(SIM_OBJ_DIR)/\1%'
723
724 # Command adds $(RSC_OBJ_DIR) and converts .xrd to .trc
725 RESOURCE_TARGET_SEDSCRIPT = sed -e';s%^\(.*\).xrd%$$(RSC_OBJ_DIR)/\1.trc%'
726
727 # Command to escape spaces in a path
728 ESCAPE_SPACES_SEDSCRIPT = sed 's/ /\\\ /g'
729
730 # Take out all newlines (and/or returns) and replace with spaces
731 # ...putting all dependencies on the same line
732 RESOURCE_PREREQ_SEDSCRIPT = tr '\r\n' ' '
733
734 depend :: FORCE
735 @echo "" > .dependencies
736 @$(SIM_CC) $(SIM_INCLUDES) $(SIM_CFLAGS) $(DEPFLAG) $(SOURCES) | $(SOURCE_SIM_SEDSCRIPT) >> .dependencies
737 @$(SIM_CC) $(SIM_INCLUDES) $(SIM_CFLAGS) $(DEPFLAG) $(SOURCES) | $(SOURCE_SEDSCRIPT) >> .dependencies
738 @for i in $(RESOURCES); do \
739 echo "$$i: \\" | $(RESOURCE_TARGET_SEDSCRIPT) >> .resdependencies; \
740 "$(TOOLS_DIR)PalmRC" -p $(TARGET_FORMAT) $(RFLAGS) -locale $(LOCALE) -makedeps $$i.tmp "`cygpath -w -a ./$$i`"; \
741 cygpath -m -f $$i.tmp | $(ESCAPE_SPACES_SEDSCRIPT) >> $$i.deps; \
742 rm -rf $$i.tmp; \
743 cat $$i.deps | $(RESOURCE_PREREQ_SEDSCRIPT) >> .resdependencies; \
744 echo "" >> .resdependencies; \
745 rm -rf $$i.deps; \
746 cat .resdependencies >> .dependencies; \
747 rm -rf .resdependencies; \
748 done
749
750
751 cleandepend :: FORCE
752 -rm -f .dependencies
753
754 -include .dependencies