summaryrefslogtreecommitdiffstats
path: root/rbutil/mktccboot/Makefile
blob: 61737651b7d87a24efd0c81ae51f9e4cfb143edd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#             __________               __   ___.
#   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
#   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
#   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
#   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
#                     \/            \/     \/    \/            \/
# $Id$
#

# We use the Telechips code available in the Rockbox tools/ directory
TOOLSDIR=../../tools
CFLAGS := -O -g -W -Wall -Wshadow -pedantic -I$(TOOLSDIR)

ifndef V
SILENT = @
endif

ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN)
OUTPUT=mktccboot.exe
CFLAGS+=-mno-cygwin
else
ifeq ($(findstring MINGW,$(shell uname)),MINGW)
OUTPUT=mktccboot.exe
else
ifeq ($(findstring mingw,$(CC)),mingw)
OUTPUT=mktccboot.exe
else
OUTPUT=mktccboot
endif
endif
endif

ifdef RBARCH
CFLAGS += -arch $(RBARCH)
endif

OUT = $(TARGET_DIR)build$(RBARCH)

all: $(OUTPUT)

# inputs
LIBSOURCES := mktccboot.c $(TOOLSDIR)/telechips.o
SOURCES := $(LIBSOURCES) main.c
OBJS := $(patsubst %.c,%.o,$(addprefix $(OUT)/,$(notdir $(SOURCES))))
LIBOBJS := $(patsubst %.c,%.o,$(addprefix $(OUT)/,$(notdir $(LIBSOURCES))))
EXTRADEPS :=

# rule for sources from tools dir
$(OUT)/%.o: $(TOOLSDIR)/%.c $(OUT)
	@echo CC $<
	$(SILENT)$(CC) $(CFLAGS) -c -o $@ $<

$(OUT)/%.o: %.c $(OUT)
	@echo CC $<
	$(SILENT)$(CC) $(CFLAGS) -c -o $@ $<

# building the library archive
$(OUT)/libmktccboot.o: $(OUT)/mktccboot.o
	@echo CC $<
	$(SILENT)$(CC) $(CFLAGS) -DLIB -c -o $(OUT)/libmktccboot.o -W -Wall mktccboot.c

libmktccboot$(RBARCH).a: $(LIBOBJS)
	@echo AR $@
	$(SILENT)$(AR) ruc $(TARGET_DIR)$@ $^

# building the standalone executable
$(OUTPUT): $(OBJS) $(EXTRADEPS)
	@echo LD $@
	$(SILENT)$(CC) $(CFLAGS) -o$(OUTPUT) $(OBJS) $(EXTRADEPS)

# some trickery to build ppc and i386 from a single call
ifeq ($(RBARCH),)
$(TARGET_DIR)libmktccbooti386.a:
	make RBARCH=i386 TARGET_DIR=$(TARGET_DIR) libmktccbooti386.a

$(TARGET_DIR)libmktccbootppc.a:
	make RBARCH=ppc TARGET_DIR=$(TARGET_DIR) libmktccbootppc.a
endif    
    
libmktccboot-universal: $(TARGET_DIR)libmktccbooti386.a $(TARGET_DIR)libmktccbootppc.a
	@echo lipo $(TARGET_DIR)libmktccboot.a
	$(SILENT) rm -f $(TARGET_DIR)libmktccboot.a
	lipo -create $(TARGET_DIR)libmktccbootppc.a $(TARGET_DIR)libmktccbooti386.a -output $(TARGET_DIR)libmktccboot.a
    
clean:
	rm -f $(OUTPUT) $(TARGET_DIR)libmktccboot*.a mktccboot.dmg
	rm -rf $(OUT)

mktccboot-i386:
	$(MAKE) RBARCH=i386
	mv mktccboot mktccboot-i386

mktccboot-ppc:
	make RBARCH=ppc
	mv mktccboot mktccboot-ppc

mktccboot-mac: mktccboot-i386 mktccboot-ppc
	lipo -create mktccboot-ppc mktccboot-i386 -output mktccboot-mac

mktccboot.dmg: mktccboot-mac
	mkdir -p mktccboot-dmg
	cp -p mktccboot-mac mktccboot-dmg
	hdiutil create -srcfolder mktccboot-dmg mktccboot.dmg
    
$(OUT):
	@echo MKDIR $(OUT)
	$(SILENT)mkdir $(OUT)