]> git.saurik.com Git - wxWidgets.git/blame_incremental - build/palmos/makefile-engine.mk
Minor header cleaning.
[wxWidgets.git] / build / palmos / makefile-engine.mk
... / ...
CommitLineData
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
69comma:= ,
70
71ifeq ($(TOOLS_DIR), )
72 TOOLS_DIR =
73endif
74
75# Locale (defaults to English)
76ifeq ($(LOCALE), )
77 LOCALE := enUS
78endif
79
80ifeq ($(CREATOR_ID), )
81 CREATOR_ID = STRT
82endif
83
84ifeq ($(DB_TYPE), )
85 DB_TYPE = appl
86endif
87
88ifeq ($(SLD_FILE), )
89 SLD_FILE = none
90endif
91
92ifeq ($(DEBUG_DEVICE_OUTPUT_DIR), )
93 DEBUG_DEVICE_OUTPUT_DIR = DebugDevice
94endif
95
96ifeq ($(RELEASE_DEVICE_OUTPUT_DIR), )
97 RELEASE_DEVICE_OUTPUT_DIR = ReleaseDevice
98endif
99
100ifeq ($(DEBUG_SIMULATOR_OUTPUT_DIR), )
101 DEBUG_SIMULATOR_OUTPUT_DIR = DebugSim
102endif
103
104ifeq ($(RELEASE_SIMULATOR_OUTPUT_DIR), )
105 RELEASE_SIMULATOR_OUTPUT_DIR = ReleaseSim
106endif
107
108ifeq ($(SDK_VERSION), )
109 SDK_VERSION = sdk-6
110endif
111
112ifeq ($(ENABLE_EXCEPTIONS), )
113 ENABLE_EXCEPTIONS=TRUE
114endif
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
124ifeq ($(DATABASE_NAME), )
125ifeq ($(ESCAPED_ARTIFACT_NAME), )
126 # Database name defaults if ARTIFACT_NAME is empty
127 DATABASE_NAME = StartApp
128else
129 DATABASE_NAME = $(ESCAPED_ARTIFACT_NAME)
130endif
131endif
132
133ifeq ($(PRC_NAME), )
134ifeq ($(ESCAPED_ARTIFACT_NAME), )
135 # PRC name defaults if ESCAPED_ARTIFACT_NAME is empty
136 PRC_NAME = Start.prc
137else
138 PRC_NAME = $(DATABASE_NAME).prc
139endif
140endif
141
142ifeq ($(LIB_NAME), )
143ifeq ($(ESCAPED_ARTIFACT_NAME), )
144 # LIB name defaults if ESCAPED_ARTIFACT_NAME is empty
145 LIB_NAME = Start.a
146else
147 LIB_NAME = $(DATABASE_NAME).a
148endif
149endif
150
151ifeq ($(SIM_LIB_NAME), )
152ifeq ($(ESCAPED_ARTIFACT_NAME), )
153 # SIM LIB name defaults if ESCAPED_ARTIFACT_NAME is empty
154 SIM_LIB_NAME = Start.lib
155else
156 SIM_LIB_NAME = $(DATABASE_NAME).lib
157endif
158endif
159
160###############################################################################
161# Compile and Link Settings
162
163TARGET_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
170CC = "$(TOOLS_DIR)pacc"
171SIM_CC = gcc
172
173CFLAGS += -D__PALMOS_KERNEL__=1 -D__PALMOS__=0x06000000
174SIM_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
177ifeq ($(WARNING_LEVEL), ALL)
178 CFLAGS += -W4
179else
180ifeq ($(WARNING_LEVEL), SOME)
181 CFLAGS += -W2
182else
183ifeq ($(WARNING_LEVEL), NONE)
184 CFLAGS += -W0
185endif
186endif
187endif
188
189# Warning level for simulator target
190ifeq ($(SIM_WARNING_LEVEL), ALL)
191 SIM_CFLAGS += -Wall
192else
193ifeq ($(SIM_WARNING_LEVEL), NONE)
194 SIM_CFLAGS += -w
195endif
196endif
197
198# Warnings as errors for device builds
199ifeq ($(WARNING_AS_ERROR), TRUE)
200 CFLAGS += -Werror
201endif
202
203# Warnings as errors for simulator builds
204ifeq ($(SIM_WARNING_AS_ERROR), TRUE)
205 SIM_CFLAGS += -Werror
206endif
207
208# Adding after other warnings flags so this is always in effect
209SIM_CFLAGS += -Wno-multichar
210
211# Verbose output for device build
212ifeq ($(VERBOSE), TRUE)
213 CFLAGS += -v
214endif
215
216# Verbose output for simulator build
217ifeq ($(SIM_VERBOSE), TRUE)
218 SIM_CFLAGS += -v
219endif
220
221# Dislay logo
222ifeq ($(ARM_LOGO), TRUE)
223 CFLAGS += -logo
224else
225 CFLAGS += -nologo
226endif
227
228# Exception handling support
229ifeq ($(ENABLE_EXCEPTIONS), TRUE)
230 CFLAGS += -ex
231 LDFLAGS += -ex
232endif
233
234# Assertion handling support
235ifeq ($(ENABLE_ASSERTIONS), TRUE)
236 CFLAGS += -UNDEBUG
237else
238 CFLAGS += -DNDEBUG=1
239endif
240
241# Additional linker flags
242ifdef ADDITIONAL_PALINK_FLAGS
243 LDFLAGS += $(ADDITIONAL_PALINK_FLAGS)
244endif
245
246# Optimization settings
247ifeq ($(OPTIMIZE_LEVEL), INLINING)
248 OPTIMIZER_FLAG = -O5
249 SIM_OPTIMIZER_FLAG = -O3
250else
251ifeq ($(OPTIMIZE_LEVEL), INTERPROCEDURAL)
252 OPTIMIZER_FLAG = -O4
253 SIM_OPTIMIZER_FLAG = -O3
254else
255ifeq ($(OPTIMIZE_LEVEL), FULL)
256 OPTIMIZER_FLAG = -O3
257 SIM_OPTIMIZER_FLAG = -O3
258else
259ifeq ($(OPTIMIZE_LEVEL), INTRAPROCEDURAL)
260 OPTIMIZER_FLAG = -O2
261 SIM_OPTIMIZER_FLAG = -O3
262else
263ifeq ($(OPTIMIZE_LEVEL), SOME)
264 OPTIMIZER_FLAG = -O1
265 SIM_OPTIMIZER_FLAG = -O1
266else
267ifeq ($(OPTIMIZE_LEVEL), NONE)
268 OPTIMIZER_FLAG = -O0
269 SIM_OPTIMIZER_FLAG = -O0
270else
271# Default to 0 for debug, 3 for release
272ifeq ($(DEBUG_OR_RELEASE), Debug)
273 OPTIMIZER_FLAG = -O0
274 SIM_OPTIMIZER_FLAG = -O0
275else
276 OPTIMIZER_FLAG = -O3
277 SIM_OPTIMIZER_FLAG = -O3
278endif
279endif
280endif
281endif
282endif
283endif
284endif
285
286# Debug settings (can override optimize settings)
287ifeq ($(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
291else
292 BUILD_TYPE_FLAG = -DBUILD_TYPE=BUILD_TYPE_RELEASE
293 TRACE_OUTPUT_FLAG = -DTRACE_OUTPUT=TRACE_OUTPUT_OFF
294endif
295
296ifeq ($(DEBUG_OR_RELEASE), Debug)
297 OBJ_DIR = $(DEBUG_DEVICE_OUTPUT_DIR)
298 SIM_OBJ_DIR = $(DEBUG_SIMULATOR_OUTPUT_DIR)
299else
300 OBJ_DIR = $(RELEASE_DEVICE_OUTPUT_DIR)
301 SIM_OBJ_DIR = $(RELEASE_SIMULATOR_OUTPUT_DIR)
302endif
303
304
305CFLAGS += $(OPTIMIZER_FLAG) $(DEBUG_FLAG) $(BUILD_TYPE_FLAG) $(TRACE_OUTPUT_FLAG)
306SIM_CFLAGS += $(SIM_OPTIMIZER_FLAG) $(DEBUG_FLAG) $(BUILD_TYPE_FLAG) $(TRACE_OUTPUT_FLAG)
307
308# Linker settings (must come after setting DEBUG_FLAG)
309LD = "$(TOOLS_DIR)pacc"
310SIM_LD = gcc
311
312LDFLAGS += $(DEBUG_FLAG) -nologo -Wl,-nolocals
313SIM_LDFLAGS += $(DEBUG_FLAG) -mno-cygwin -mwindows $(SIM_OBJ_DIR)/gcc_link.def -shared -nostdlib -u___divdi3 -u___moddi3 -u___udivdi3 -u___umoddi3
314SIM_LIBS = -L "$(TOOLS_DIR)misclibs" -lpxstlport -lpxsupc++ -lpxgcc -lgcc
315ifeq ($(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"
318else
319 LDFLAGS += -Wl,-libpath -Wl,"$(SDK_LOCATION)libraries/ARM_4T/Release/Default"
320 SIM_LIBS += "$(SDK_LOCATION)libraries/Simulator/Release/PalmOS.lib"
321endif
322
323LDOBJS = PalmOS.a SystemGlue.a FloatMgr.sa
324
325ifeq ($(TARGET_PLATFORM), Device)
326 NATIVE_OBJ_DIR := $(OBJ_DIR)
327 RSC_OBJ_DIR := $(OBJ_DIR)
328else
329 NATIVE_OBJ_DIR := $(SIM_OBJ_DIR)
330 RSC_OBJ_DIR := $(SIM_OBJ_DIR)
331endif
332
333# Librarian settings
334AR="$(TOOLS_DIR)palib"
335SIM_AR=ar
336
337ARFLAGS= -c -a
338SIM_ARFLAGS=-rc
339
340LINKER_OUTPUT := $(OBJ_DIR)/$(DATABASE_NAME).axf
341SIM_LINKER_OUTPUT := $(SIM_OBJ_DIR)/$(DATABASE_NAME).dll
342
343TARGET := $(OBJ_DIR)/$(PRC_NAME)
344SIM_TARGET := $(SIM_OBJ_DIR)/$(PRC_NAME)
345
346STATIC_LIB_TARGET := $(OBJ_DIR)/$(LIB_NAME)
347SIM_STATIC_LIB_TARGET := $(SIM_OBJ_DIR)/$(SIM_LIB_NAME)
348
349###############################################################################
350# Resource flags (PalmRC)
351
352RFLAGS +=
353
354# Default text encoding is Latin
355ifeq ($(PRC_TEXT_ENCODING), )
356 PRC_TEXT_ENCODING = LATIN
357endif
358
359ifeq ($(PRC_TEXT_ENCODING), LATIN)
360 RFLAGS += -target 4.0
361else
362ifeq ($(PRC_TEXT_ENCODING), JAPANESE)
363 RFLAGS += -target 4.0J
364else
365ifeq ($(PRC_TEXT_ENCODING), SIMPLIFIED_CHINESE)
366 RFLAGS += -target 4.0CS
367endif
368endif
369endif
370
371ifeq ($(PRC_NO_LOCALE_CHECK), TRUE)
372 RFLAGS += -noLocaleCheck
373endif
374
375ifeq ($(PRC_STRICT_LOCALE), TRUE)
376 RFLAGS += -strictLocale
377endif
378
379ifeq ($(PRC_STRICT_ENCODING), TRUE)
380 RFLAGS += -strictTextEncoding
381endif
382
383ifdef PRC_OVERLAY_FILTER
384 RFLAGS += -overlayFilter $(PRC_OVERLAY_FILTER)
385endif
386
387ifeq ($(PRC_NO_WARN_SIZE), TRUE)
388 RFLAGS += -noWarnSize
389endif
390
391ifeq ($(PRC_QUIET), TRUE)
392 RFLAGS += -quiet
393endif
394
395ifeq ($(PRCMERGE_QUIET), TRUE)
396 PRCFLAGS += -quiet
397endif
398
399###############################################################################
400
401# function for converting sources to object file names in one of output directories
402define SOURCE_LIST_TO_OBJS
403 $(addprefix $(OBJ_DIR)/, $(addsuffix .o, $(foreach file, $(SOURCES), \
404 $(basename $(notdir $(file))))))
405endef
406
407# function for converting sources to object file names in $(SIM_OBJ_DIR)
408define SOURCE_LIST_TO_SIM_OBJS
409 $(addprefix $(SIM_OBJ_DIR)/, $(addsuffix .o, $(foreach file, $(SOURCES), \
410 $(basename $(notdir $(file))))))
411endef
412
413# function for converting resources into resource object files
414define RESOURCE_LIST_TO_OBJS
415 $(addprefix $(RSC_OBJ_DIR)/, $(addsuffix .trc, $(foreach file, $(RESOURCES), \
416 $(basename $(file)))))
417endef
418
419OBJS = $(SOURCE_LIST_TO_OBJS)
420SIM_OBJS = $(SOURCE_LIST_TO_SIM_OBJS)
421SOURCE_PATHS += $(sort $(foreach file, $(SOURCES), $(dir $(file))))
422RESOURCE_OBJS = $(RESOURCE_LIST_TO_OBJS)
423RESOURCE_PATHS += $(sort $(foreach file, $(RESOURCES), $(dir $(file))))
424SLD_BASENAME := $(addsuffix _Startup, $(basename $(notdir $(SLD_FILE))))
425SLD_OBJ := $(addprefix $(OBJ_DIR)/, $(addsuffix .o, $(SLD_BASENAME)))
426SLD_SIM_OBJ := $(addprefix $(SIM_OBJ_DIR)/, $(addsuffix .o, $(SLD_BASENAME)))
427
428VPATH :=
429VPATH += $(addprefix :, $(subst ,:, $(filter-out $($(subst, :, ,$(VPATH))), $(SOURCE_PATHS) $(RESOURCE_PATHS) )))
430
431SYSTEM_INCLUDES = $(SYSTEM_INCLUDE_PATHS) -I "$(SDK_LOCATION)headers" -I "$(SDK_LOCATION)headers/posix"
432INCLUDES = $(LOCAL_INCLUDE_PATHS) $(foreach path, $(SOURCE_PATHS), $(addprefix -I, $(path))) $(SYSTEM_INCLUDES) $(PRE_INCLUDE_PATHS)
433CPP_INCLUDES = -I "$(TOOLS_DIR)include/stlport"
434
435SIM_SYSTEM_INCLUDES = $(SYSTEM_SIM_INCLUDE_PATHS) -I "$(SDK_LOCATION)headers" -I "$(SDK_LOCATION)headers/posix"
436SIM_INCLUDES = $(LOCAL_SIM_INCLUDE_PATHS) $(foreach path, $(SOURCE_PATHS), $(addprefix -I, $(path))) $(SIM_SYSTEM_INCLUDES) $(SIM_PRE_INCLUDE_PATHS)
437SIM_CPP_INCLUDES = -I "$(TOOLS_DIR)include/stlport"
438
439# Now add additional settings specified by user
440LDFLAGS += $(ADDITIONAL_LINK_LIBRARIES)
441LDFLAGS += $(foreach libpath, $(ADDITIONAL_LINK_LIBPATH), $(addprefix -libpath , $(libpath)))
442LDFLAGS += $(foreach option, $(ADDITIONAL_LINKER_FLAGS), $(addprefix -Wl$(comma), $(option)))
443CFLAGS += $(foreach define, $(DEFINES), $(addprefix -D, $(define)))
444CFLAGS += $(foreach define, $(UNDEFINES), $(addprefix -U, $(define)))
445CFLAGS += $(ADDITIONAL_COMPILER_FLAGS)
446
447SIM_LDFLAGS += $(ADDITIONAL_SIM_LINK_LIBRARIES)
448SIM_LDFLAGS += $(ADDITIONAL_SIM_LINKER_FLAGS)
449SIM_LDFLAGS += $(foreach libpath, $(ADDITIONAL_SIM_LINK_LIBPATH), $(addprefix -L, $(libpath)))
450SIM_CFLAGS += $(foreach define, $(SIM_DEFINES), $(addprefix -D, $(define)))
451SIM_CFLAGS += $(foreach define, $(SIM_UNDEFINES), $(addprefix -U, $(define)))
452SIM_CFLAGS += $(ADDITIONAL_SIM_COMPILER_FLAGS)
453
454# Specifyc additional archival flags (for static libraries)
455ARFLAGS += $(ADDITIONAL_AR_FLAGS)
456SIM_ARFLAGS += $(ADDITIONAL_SIM_AR_FLAGS)
457
458RFLAGS += $(ADDITIONAL_PRC_FLAGS)
459PRCFLAGS += $(ADDITIONAL_PRCMERGE_FLAGS)
460
461###############################################################################
462# Flags for PRC creation
463
464PRCFLAGS += -dbFlagExtendedDB -dbFlagExecutable
465
466PRCFLAGS += -dbVersion $(DATABASE_VERSION) $(DATABASE_PROTECT) $(DATABASE_HIDDEN) $(DATABASE_BACKUP) $(DATABASE_RESET) $(DATABASE_BUNDLE)
467
468
469###############################################################################
470# Flags for pslib
471
472PSLIB_DEV_FLAGS =
473PSLIB_SIM_FLAGS = -outSimgcc
474ifeq ($(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
477endif
478
479
480
481###############################################################################
482# Project make target determination
483
484ifeq ($(TARGET_PLATFORM), Device)
485
486ifeq ($(PROJECT_TYPE), )
487 PROJECT_TARGET = device
488endif
489
490ifeq ($(PROJECT_TYPE), appl)
491 PROJECT_TARGET = device
492endif
493ifeq ($(PROJECT_TYPE), slib)
494 PROJECT_TARGET = device_shared_lib
495endif
496ifeq ($(PROJECT_TYPE), lib)
497 PROJECT_TARGET = device_static_lib
498endif
499
500else
501
502ifeq ($(PROJECT_TYPE), )
503 PROJECT_TARGET = simulator
504endif
505
506ifeq ($(PROJECT_TYPE), appl)
507 PROJECT_TARGET = simulator
508endif
509ifeq ($(PROJECT_TYPE), slib)
510 PROJECT_TARGET = simulator_shared_lib
511endif
512ifeq ($(PROJECT_TYPE), lib)
513 PROJECT_TARGET = simulator_static_lib
514endif
515
516endif
517
518###############################################################################
519# Eclipse requires an all target to get the work done
520
521all: $(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
526device: $(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
531simulator: $(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
536device_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
541simulator_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
546device_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
551simulator_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
644FORCE:
645
646# Eclipse requires a clean command
647clean :: FORCE
648 -rm -rf $(NATIVE_OBJ_DIR)/*
649
650
651printvars :: 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
703DEPFLAG = -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#
713SOURCE_SEDSCRIPT = sed -e's%^\(.*\.o\)%$$(OBJ_DIR)/\1%'
714SOURCE_SIM_SEDSCRIPT = sed -e's%^\(.*\.o\)%$$(SIM_OBJ_DIR)/\1%'
715
716# Command adds $(RSC_OBJ_DIR) and converts .xrd to .trc
717RESOURCE_TARGET_SEDSCRIPT = sed -e';s%^\(.*\).xrd%$$(RSC_OBJ_DIR)/\1.trc%'
718
719# Command to escape spaces in a path
720ESCAPE_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
724RESOURCE_PREREQ_SEDSCRIPT = tr '\r\n' ' '
725
726depend :: 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
743cleandepend :: FORCE
744 -rm -f .dependencies
745
746-include .dependencies