diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2011-12-14 21:59:37 +0000 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2011-12-14 21:59:37 +0000 |
commit | b24e562061213cae3a40625e3423572fb58a2d83 (patch) | |
tree | 12eaa443f88d03795b1e021c360d86c57e6efd31 /rbutil/libtools.make | |
parent | 8e6030c8223bfb3102048b2daccbf6a6f4e97ba2 (diff) | |
download | rockbox-b24e562061213cae3a40625e3423572fb58a2d83.tar.gz rockbox-b24e562061213cae3a40625e3423572fb58a2d83.zip |
Initial common Makefile for Rockbox Utility tools / libs.
Introduce a new Makefile holding the common functionality for building tools
used by Rockbox Utility (*patcher / mk*boot). This converts mktccboot to use
the common Makefile.
Also introduces BUILD_DIR variable to control the path used for placing
intermediate objects into. This should avoid filename clashes between different
tools. Filenames are (still) assumed to be unique withing a single tool.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31257 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil/libtools.make')
-rw-r--r-- | rbutil/libtools.make | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/rbutil/libtools.make b/rbutil/libtools.make new file mode 100644 index 0000000000..1e5a297f79 --- /dev/null +++ b/rbutil/libtools.make @@ -0,0 +1,117 @@ +# __________ __ ___. +# Open \______ \ ____ ____ | | _\_ |__ _______ ___ +# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +# \/ \/ \/ \/ \/ + +# libtools.make +# +# Common Makefile for tools used by Rockbox Utility. +# Provides rules for building as library, universal library (OS X) and +# standalone binary. +# +# LIBSOURCES is a list of files to build the lib +# SOURCES is a list of files to build for the main binary +# EXTRADEPS is a list of make targets dependencies +# +ifndef V +SILENT = @ +endif + +# Get directory this Makefile is in for relative paths. +TOP := $(dir $(lastword $(MAKEFILE_LIST))) + +# overwrite for releases +ifndef APPVERSION +APPVERSION=$(shell $(TOP)/../tools/version.sh ../) +endif +CFLAGS += -DVERSION=\"$(APPVERSION)\" +TARGET_DIR ?= $(shell pwd)/ + +BINARY = $(OUTPUT) +# when building a Windows binary add the correct file suffix +ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN) +BINARY = $(OUTPUT).exe +CFLAGS+=-mno-cygwin +else +ifeq ($(findstring MINGW,$(shell uname)),MINGW) +BINARY = $(OUTPUT).exe +else +ifeq ($(findstring mingw,$(CROSS)$(CC)),mingw) +BINARY = $(OUTPUT).exe +endif +endif +endif + +ifndef BUILD_DIR +BUILD_DIR = $(TARGET_DIR)build +endif +OBJDIR = $(abspath $(BUILD_DIR)/$(RBARCH))/ + +ifdef RBARCH +CFLAGS += -arch $(RBARCH) +endif + +all: $(BINARY) + +OBJS := $(patsubst %.c,%.o,$(addprefix $(OBJDIR),$(notdir $(SOURCES)))) +LIBOBJS := $(patsubst %.c,%.o,$(addprefix $(OBJDIR),$(notdir $(LIBSOURCES)))) + +$(OBJDIR)%.o: %.c + @echo CC $< + $(SILENT)mkdir -p $(dir $@) + $(SILENT)$(CROSS)$(CC) $(CFLAGS) -c -o $@ $< + +lib$(OUTPUT)$(RBARCH).a: $(TARGET_DIR)lib$(OUTPUT)$(RBARCH).a +lib$(OUTPUT)$(RBARCH): $(TARGET_DIR)lib$(OUTPUT)$(RBARCH).a + +$(TARGET_DIR)lib$(OUTPUT)$(RBARCH).a: $(LIBOBJS) $(addprefix $(OBJDIR),$(EXTRALIBOBJS)) + @echo AR $(notdir $@) + $(SILENT)mkdir -p $(dir $@) + $(SILENT)$(AR) rucs $@ $^ + + +# building the standalone executable +$(BINARY): $(OBJS) $(EXTRADEPS) $(addprefix $(OBJDIR),$(EXTRALIBOBJS)) + @echo LD $@ +# $(SILENT)mkdir -p $(dir $@) +# EXTRADEPS need to be built into OBJDIR. + $(SILENT)$(CROSS)$(CC) $(CFLAGS) -o $(BINARY) $(OBJS) $(addprefix $(OBJDIR),$(EXTRADEPS)) $(addprefix $(OBJDIR),$(EXTRALIBOBJS)) + +# some trickery to build ppc and i386 from a single call +ifeq ($(RBARCH),) +$(TARGET_DIR)lib$(OUTPUT)i386.a: + make RBARCH=i386 TARGET_DIR=$(TARGET_DIR) lib$(OUTPUT)i386.a + +$(TARGET_DIR)lib$(OUTPUT)ppc.a: + make RBARCH=ppc TARGET_DIR=$(TARGET_DIR) lib$(OUTPUT)ppc.a +endif + +lib$(OUTPUT)-universal: $(TARGET_DIR)lib$(OUTPUT)i386.a $(TARGET_DIR)lib$(OUTPUT)ppc.a + @echo lipo $(TARGET_DIR)libmkamsboot.a + $(SILENT) rm -f $(TARGET_DIR)libmkamsboot.a + $(SILENT)lipo -create $(TARGET_DIR)lib$(OUTPUT)i386.a $(TARGET_DIR)lib$(OUTPUT)ppc.a -output $(TARGET_DIR)lib$(OUTPUT).a + +clean: + rm -f $(OBJS) $(OUTPUT) $(TARGET_DIR)lib$(OUTPUT)*.a $(OUTPUT).dmg + rm -rf $(OUTPUT)-* i386 ppc $(OBJDIR) + +# OS X specifics +$(OUTPUT)-i386: + $(MAKE) RBARCH=i386 + mv $(OUTPUT) $@ + +$(OUTPUT)-ppc: + $(MAKE) RBARCH=ppc + mv $(OUTPUT) $@ + +$(OUTPUT)-mac: $(OUTPUT)-i386 $(OUTPUT)-ppc + @echo LIPO $@ + $(SILENT)lipo -create $(OUTPUT)-ppc $(OUTPUT)-i386 -output $@ + +$(OUTPUT).dmg: $(OUTPUT)-mac + @echo DMG $@ + $(SILENT)mkdir -p $(OUTPUT)-dmg + $(SILENT)cp -p $(OUTPUT)-mac $(OUTPUT)-dmg + $(SILENT)hdiutil create -srcfolder $(OUTPUT)-dmg $@ |