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