summaryrefslogtreecommitdiffstats
path: root/rbutil/mkamsboot/Makefile
blob: 219fb43d03aa1eb23265d81984fed2c0dd64f289 (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

#change for releases
ifndef APPVERSION
APPVERSION=`../../tools/version.sh`
endif

# We use the UCL code available in the Rockbox tools/ directory
CFLAGS=-I../../tools/ucl/include -Wall -DVERSION=\"$(APPVERSION)\"

ifndef V
SILENT = @
endif

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

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

OUT = $(TARGET_DIR)build$(RBARCH)

all: $(OUTPUT)

# additional link dependencies for the standalone executable
LIBUCL=../../tools/ucl/src/libucl$(RBARCH).a

$(LIBUCL):
	make -C ../../tools/ucl/src $(TARGET_DIR)libucl$(RBARCH).a

# inputs
LIBSOURCES := dualboot.c md5.c mkamsboot.c
SOURCES := $(LIBSOURCES) main.c
OBJS := $(patsubst %.c,%.o,$(addprefix $(OUT)/,$(SOURCES)))
LIBOBJS := $(patsubst %.c,%.o,$(addprefix $(OUT)/,$(LIBSOURCES)))
EXTRADEPS := $(LIBUCL)

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

libmkamsboot$(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)libmkamsbooti386.a:
	make RBARCH=i386 TARGET_DIR=$(TARGET_DIR) libmkamsbooti386.a

$(TARGET_DIR)libmkamsbootppc.a:
	make RBARCH=ppc TARGET_DIR=$(TARGET_DIR) libmkamsbootppc.a
endif    
    
libmkamsboot-universal: $(TARGET_DIR)libmkamsbooti386.a $(TARGET_DIR)libmkamsbootppc.a
	@echo lipo $(TARGET_DIR)libmkamsboot.a
	$(SILENT) rm -f $(TARGET_DIR)libmkamsboot.a
	lipo -create $(TARGET_DIR)libmkamsbootppc.a $(TARGET_DIR)libmkamsbooti386.a -output $(TARGET_DIR)libmkamsboot.a
    
clean:
	rm -f $(OUTPUT) libmkamsboot.o $(TARGET_DIR)libmkamsboot*.a mkamsboot.dmg
	rm -rf build* mkamsboot-*

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

mkamsboot-ppc:
	make RBARCH=ppc
	mv mkamsboot mkamsboot-ppc

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

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