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