diff options
-rw-r--r-- | rbutil/libtools.make | 117 | ||||
-rw-r--r-- | rbutil/mktccboot/Makefile | 92 |
2 files changed, 127 insertions, 82 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 @@ | |||
1 | # __________ __ ___. | ||
2 | # Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
3 | # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
4 | # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
5 | # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
6 | # \/ \/ \/ \/ \/ | ||
7 | |||
8 | # libtools.make | ||
9 | # | ||
10 | # Common Makefile for tools used by Rockbox Utility. | ||
11 | # Provides rules for building as library, universal library (OS X) and | ||
12 | # standalone binary. | ||
13 | # | ||
14 | # LIBSOURCES is a list of files to build the lib | ||
15 | # SOURCES is a list of files to build for the main binary | ||
16 | # EXTRADEPS is a list of make targets dependencies | ||
17 | # | ||
18 | ifndef V | ||
19 | SILENT = @ | ||
20 | endif | ||
21 | |||
22 | # Get directory this Makefile is in for relative paths. | ||
23 | TOP := $(dir $(lastword $(MAKEFILE_LIST))) | ||
24 | |||
25 | # overwrite for releases | ||
26 | ifndef APPVERSION | ||
27 | APPVERSION=$(shell $(TOP)/../tools/version.sh ../) | ||
28 | endif | ||
29 | CFLAGS += -DVERSION=\"$(APPVERSION)\" | ||
30 | TARGET_DIR ?= $(shell pwd)/ | ||
31 | |||
32 | BINARY = $(OUTPUT) | ||
33 | # when building a Windows binary add the correct file suffix | ||
34 | ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN) | ||
35 | BINARY = $(OUTPUT).exe | ||
36 | CFLAGS+=-mno-cygwin | ||
37 | else | ||
38 | ifeq ($(findstring MINGW,$(shell uname)),MINGW) | ||
39 | BINARY = $(OUTPUT).exe | ||
40 | else | ||
41 | ifeq ($(findstring mingw,$(CROSS)$(CC)),mingw) | ||
42 | BINARY = $(OUTPUT).exe | ||
43 | endif | ||
44 | endif | ||
45 | endif | ||
46 | |||
47 | ifndef BUILD_DIR | ||
48 | BUILD_DIR = $(TARGET_DIR)build | ||
49 | endif | ||
50 | OBJDIR = $(abspath $(BUILD_DIR)/$(RBARCH))/ | ||
51 | |||
52 | ifdef RBARCH | ||
53 | CFLAGS += -arch $(RBARCH) | ||
54 | endif | ||
55 | |||
56 | all: $(BINARY) | ||
57 | |||
58 | OBJS := $(patsubst %.c,%.o,$(addprefix $(OBJDIR),$(notdir $(SOURCES)))) | ||
59 | LIBOBJS := $(patsubst %.c,%.o,$(addprefix $(OBJDIR),$(notdir $(LIBSOURCES)))) | ||
60 | |||
61 | $(OBJDIR)%.o: %.c | ||
62 | @echo CC $< | ||
63 | $(SILENT)mkdir -p $(dir $@) | ||
64 | $(SILENT)$(CROSS)$(CC) $(CFLAGS) -c -o $@ $< | ||
65 | |||
66 | lib$(OUTPUT)$(RBARCH).a: $(TARGET_DIR)lib$(OUTPUT)$(RBARCH).a | ||
67 | lib$(OUTPUT)$(RBARCH): $(TARGET_DIR)lib$(OUTPUT)$(RBARCH).a | ||
68 | |||
69 | $(TARGET_DIR)lib$(OUTPUT)$(RBARCH).a: $(LIBOBJS) $(addprefix $(OBJDIR),$(EXTRALIBOBJS)) | ||
70 | @echo AR $(notdir $@) | ||
71 | $(SILENT)mkdir -p $(dir $@) | ||
72 | $(SILENT)$(AR) rucs $@ $^ | ||
73 | |||
74 | |||
75 | # building the standalone executable | ||
76 | $(BINARY): $(OBJS) $(EXTRADEPS) $(addprefix $(OBJDIR),$(EXTRALIBOBJS)) | ||
77 | @echo LD $@ | ||
78 | # $(SILENT)mkdir -p $(dir $@) | ||
79 | # EXTRADEPS need to be built into OBJDIR. | ||
80 | $(SILENT)$(CROSS)$(CC) $(CFLAGS) -o $(BINARY) $(OBJS) $(addprefix $(OBJDIR),$(EXTRADEPS)) $(addprefix $(OBJDIR),$(EXTRALIBOBJS)) | ||
81 | |||
82 | # some trickery to build ppc and i386 from a single call | ||
83 | ifeq ($(RBARCH),) | ||
84 | $(TARGET_DIR)lib$(OUTPUT)i386.a: | ||
85 | make RBARCH=i386 TARGET_DIR=$(TARGET_DIR) lib$(OUTPUT)i386.a | ||
86 | |||
87 | $(TARGET_DIR)lib$(OUTPUT)ppc.a: | ||
88 | make RBARCH=ppc TARGET_DIR=$(TARGET_DIR) lib$(OUTPUT)ppc.a | ||
89 | endif | ||
90 | |||
91 | lib$(OUTPUT)-universal: $(TARGET_DIR)lib$(OUTPUT)i386.a $(TARGET_DIR)lib$(OUTPUT)ppc.a | ||
92 | @echo lipo $(TARGET_DIR)libmkamsboot.a | ||
93 | $(SILENT) rm -f $(TARGET_DIR)libmkamsboot.a | ||
94 | $(SILENT)lipo -create $(TARGET_DIR)lib$(OUTPUT)i386.a $(TARGET_DIR)lib$(OUTPUT)ppc.a -output $(TARGET_DIR)lib$(OUTPUT).a | ||
95 | |||
96 | clean: | ||
97 | rm -f $(OBJS) $(OUTPUT) $(TARGET_DIR)lib$(OUTPUT)*.a $(OUTPUT).dmg | ||
98 | rm -rf $(OUTPUT)-* i386 ppc $(OBJDIR) | ||
99 | |||
100 | # OS X specifics | ||
101 | $(OUTPUT)-i386: | ||
102 | $(MAKE) RBARCH=i386 | ||
103 | mv $(OUTPUT) $@ | ||
104 | |||
105 | $(OUTPUT)-ppc: | ||
106 | $(MAKE) RBARCH=ppc | ||
107 | mv $(OUTPUT) $@ | ||
108 | |||
109 | $(OUTPUT)-mac: $(OUTPUT)-i386 $(OUTPUT)-ppc | ||
110 | @echo LIPO $@ | ||
111 | $(SILENT)lipo -create $(OUTPUT)-ppc $(OUTPUT)-i386 -output $@ | ||
112 | |||
113 | $(OUTPUT).dmg: $(OUTPUT)-mac | ||
114 | @echo DMG $@ | ||
115 | $(SILENT)mkdir -p $(OUTPUT)-dmg | ||
116 | $(SILENT)cp -p $(OUTPUT)-mac $(OUTPUT)-dmg | ||
117 | $(SILENT)hdiutil create -srcfolder $(OUTPUT)-dmg $@ | ||
diff --git a/rbutil/mktccboot/Makefile b/rbutil/mktccboot/Makefile index b01f25dc3d..3bca0ba05e 100644 --- a/rbutil/mktccboot/Makefile +++ b/rbutil/mktccboot/Makefile | |||
@@ -8,98 +8,26 @@ | |||
8 | # | 8 | # |
9 | 9 | ||
10 | # We use the Telechips code available in the Rockbox tools/ directory | 10 | # We use the Telechips code available in the Rockbox tools/ directory |
11 | TOOLSDIR=../../tools | 11 | TOOLSDIR = ../../tools/ |
12 | CFLAGS := -O -g -W -Wall -Wshadow -pedantic -I$(TOOLSDIR) | 12 | CFLAGS := -O -g -W -Wall -Wshadow -pedantic -I$(TOOLSDIR) |
13 | 13 | ||
14 | ifndef V | 14 | OUTPUT = mktccboot |
15 | SILENT = @ | ||
16 | endif | ||
17 | 15 | ||
18 | ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN) | ||
19 | OUTPUT=mktccboot.exe | ||
20 | CFLAGS+=-mno-cygwin | ||
21 | else | ||
22 | ifeq ($(findstring MINGW,$(shell uname)),MINGW) | ||
23 | OUTPUT=mktccboot.exe | ||
24 | else | ||
25 | ifeq ($(findstring mingw,$(CC)),mingw) | ||
26 | OUTPUT=mktccboot.exe | ||
27 | else | ||
28 | OUTPUT=mktccboot | ||
29 | endif | ||
30 | endif | ||
31 | endif | ||
32 | |||
33 | ifdef RBARCH | ||
34 | CFLAGS += -arch $(RBARCH) | ||
35 | endif | ||
36 | |||
37 | TARGET_DIR ?= $(shell pwd)/ | ||
38 | OBJDIR = $(TARGET_DIR)build$(RBARCH) | ||
39 | |||
40 | all: $(OUTPUT) | ||
41 | 16 | ||
42 | # inputs | 17 | # inputs |
43 | LIBSOURCES := mktccboot.c $(TOOLSDIR)/telechips.o | 18 | LIBSOURCES := mktccboot.c $(TOOLSDIR)telechips.c |
44 | SOURCES := $(LIBSOURCES) main.c | 19 | SOURCES := $(LIBSOURCES) main.c |
45 | OBJS := $(patsubst %.c,%.o,$(addprefix $(OBJDIR)/,$(notdir $(SOURCES)))) | ||
46 | LIBOBJS := $(patsubst %.c,%.o,$(addprefix $(OBJDIR)/,$(notdir $(LIBSOURCES)))) | ||
47 | EXTRADEPS := | 20 | EXTRADEPS := |
48 | 21 | ||
49 | # rule for sources from tools dir | 22 | include ../libtools.make |
50 | $(OBJDIR)/%.o: $(TOOLSDIR)/%.c | ||
51 | @echo CC $< | ||
52 | $(SILENT)mkdir -p $(dir $@) | ||
53 | $(SILENT)$(CC) $(CFLAGS) -c -o $@ $< | ||
54 | 23 | ||
55 | $(OBJDIR)/%.o: %.c | 24 | # rule for sources from tools dir |
25 | # Rules go _after_ including mkboot.make to have OBJDIR set up correctly. | ||
26 | # Paths are assumed to end with a / | ||
27 | telechips.o: $(OBJDIR)telechips.o | ||
28 | $(OBJDIR)%.o: $(TOOLSDIR)%.c | ||
56 | @echo CC $< | 29 | @echo CC $< |
57 | $(SILENT)mkdir -p $(dir $@) | 30 | $(SILENT)mkdir -p $(dir $@) |
58 | $(SILENT)$(CC) $(CFLAGS) -c -o $@ $< | 31 | $(SILENT)$(CROSS)$(CC) $(CFLAGS) -c -o $@ $< |
59 | |||
60 | libmktccboot$(RBARCH).a: $(TARGET_DIR)libmktccboot$(RBARCH).a | ||
61 | |||
62 | $(TARGET_DIR)libmktccboot$(RBARCH).a: $(LIBOBJS) | ||
63 | @echo AR $(notdir $@) | ||
64 | $(SILENT)$(AR) rucs $@ $^ | ||
65 | |||
66 | # building the standalone executable | ||
67 | $(OUTPUT): $(OBJS) $(EXTRADEPS) | ||
68 | @echo LD $@ | ||
69 | $(SILENT)$(CC) $(CFLAGS) -o$(OUTPUT) $(OBJS) $(EXTRADEPS) | ||
70 | |||
71 | # some trickery to build ppc and i386 from a single call | ||
72 | ifeq ($(RBARCH),) | ||
73 | $(TARGET_DIR)libmktccbooti386.a: | ||
74 | make RBARCH=i386 TARGET_DIR=$(TARGET_DIR) libmktccbooti386.a | ||
75 | |||
76 | $(TARGET_DIR)libmktccbootppc.a: | ||
77 | make RBARCH=ppc TARGET_DIR=$(TARGET_DIR) libmktccbootppc.a | ||
78 | endif | ||
79 | |||
80 | libmktccboot-universal: $(TARGET_DIR)libmktccbooti386.a $(TARGET_DIR)libmktccbootppc.a | ||
81 | @echo lipo $(TARGET_DIR)libmktccboot.a | ||
82 | $(SILENT) rm -f $(TARGET_DIR)libmktccboot.a | ||
83 | $(SILENT)lipo -create $(TARGET_DIR)libmktccbootppc.a $(TARGET_DIR)libmktccbooti386.a -output $(TARGET_DIR)libmktccboot.a | ||
84 | |||
85 | clean: | ||
86 | rm -f $(OUTPUT) $(TARGET_DIR)libmktccboot*.a mktccboot.dmg | ||
87 | rm -rf $(OBJDIR) | ||
88 | |||
89 | mktccboot-i386: | ||
90 | $(MAKE) RBARCH=i386 | ||
91 | mv mktccboot mktccboot-i386 | ||
92 | |||
93 | mktccboot-ppc: | ||
94 | make RBARCH=ppc | ||
95 | mv mktccboot mktccboot-ppc | ||
96 | |||
97 | mktccboot-mac: mktccboot-i386 mktccboot-ppc | ||
98 | $(SILENT)lipo -create mktccboot-ppc mktccboot-i386 -output mktccboot-mac | ||
99 | |||
100 | mktccboot.dmg: mktccboot-mac | ||
101 | mkdir -p mktccboot-dmg | ||
102 | cp -p mktccboot-mac mktccboot-dmg | ||
103 | hdiutil create -srcfolder mktccboot-dmg mktccboot.dmg | ||
104 | 32 | ||
105 | 33 | ||