# PonyProg serial programmer
#DPROG = -c dasa2
+# Set to 1 to build for embedded devices.
+# e.g. produce target.elf instead of target and target_nostrip
+EMBEDDED_TARGET = 1
+#EMBEDDED_TARGET = 0
+
OPTCFLAGS = -ffunction-sections -fdata-sections
#OPTCFLAGS = -funsafe-loop-optimizations
LIST_FLAGS = -Wa,-anhlmsd=$(@:.o=.lst)
# Linker flags for generating map files
-#bernie: bogus binutils from Fedora 6 can't cope with this
-#MAP_FLAGS = -Wl,-Map=$(@:%.elf=%.map),--cref
+ifeq ($(EMBEDDED_TARGET), 1)
+MAP_FLAGS = -Wl,-Map=$(@:%.elf=%.map),--cref
+else
+MAP_FLAGS =
+endif
# Compiler warning flags for both C and C++
WARNFLAGS = \
# The default target
.PHONY: all
-all:: all-recursive $(TRG_S19) $(TRG_HEX)
+ifeq ($(EMBEDDED_TARGET),1)
+all:: all-recursive $(TRG_S19) $(TRG_HEX) $(TRG_BIN)
+else
+all:: all-recursive $(TRG_ELF)
+endif
# Generate project documentation
.PHONY: docs
$L "$(1): Assembling with CPP $$<"
@$$(MKDIR_P) $$(dir $$@)
$Q $$(CC) -c $$(CPPAFLAGS) $$($(1)_CPPAFLAGS) $$($(1)_CPPFLAGS) $$(CPPFLAGS) $$< -o $$@
+
# Link: instructions to create elf output file from object files
$$(OUTDIR)/$(1).elf: bumprev $$($(1)_OBJ) $$($(1)_LDSCRIPT)
$L "$(1): Linking $$(OUTDIR)/$(1)"
@$$(MKDIR_P) $$(dir $$@)
+ifeq ($(EMBEDDED_TARGET), 1)
+ $Q $$(LD) $$($(1)_OBJ) $$(LIB) $$(LDFLAGS) $$($(1)_LDFLAGS) -o $$@
+else
$Q $$(LD) $$($(1)_OBJ) $$(LIB) $$(LDFLAGS) $$($(1)_LDFLAGS) -o $$(OUTDIR)/$(1)_nostrip
$Q $$(STRIP) -o $$(OUTDIR)/$(1) $$(OUTDIR)/$(1)_nostrip
-
+endif
+
# Compile and link (program-at-a-time)
$$(OUTDIR)/$(1)_whole.elf: bumprev $$($(1)_SRC) $$($(1)_LDSCRIPT)
$L "$(1): Compiling and Linking whole program $$@"