Prevent unnecessary rebuilding of libs.
[maemo-rb.git] / rbutil / mkamsboot / Makefile
blob052904211b877ed6aab0362831a91291ae0c9ee2
1 # __________ __ ___.
2 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
3 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6 # \/ \/ \/ \/ \/
8 #change for releases
9 ifndef APPVERSION
10 APPVERSION=$(shell ../../tools/version.sh ../../)
11 endif
12 TARGET_DIR ?= $(shell pwd)/
13 # We use the UCL code available in the Rockbox tools/ directory
14 CFLAGS=-I../../tools/ucl/include -Wall -DVERSION=\"$(APPVERSION)\"
16 ifndef V
17 SILENT = @
18 endif
20 ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN)
21 OUTPUT=mkamsboot.exe
22 CFLAGS+=-mno-cygwin
23 else
24 ifeq ($(findstring MINGW,$(shell uname)),MINGW)
25 OUTPUT=mkamsboot.exe
26 else
27 ifeq ($(findstring mingw,$(CC)),mingw)
28 OUTPUT=mkamsboot.exe
29 else
30 OUTPUT=mkamsboot
31 endif
32 endif
33 endif
35 ifdef RBARCH
36 CFLAGS += -arch $(RBARCH)
37 OBJDIR = $(TARGET_DIR)build/$(RBARCH)/
38 else
39 OBJDIR = $(TARGET_DIR)build/
40 endif
43 all: $(OUTPUT)
45 # additional link dependencies for the standalone executable
46 LIBUCL=$(OBJDIR)libucl$(RBARCH).a
48 $(LIBUCL):
49 $(SILENT)$(MAKE) -C ../../tools/ucl/src TARGET_DIR=$(OBJDIR) libucl$(RBARCH).a
51 # inputs
52 LIBSOURCES := dualboot.c md5.c mkamsboot.c
53 SOURCES := $(LIBSOURCES) main.c
54 OBJS := $(patsubst %.c,%.o,$(addprefix $(OBJDIR),$(SOURCES)))
55 LIBOBJS := $(patsubst %.c,%.o,$(addprefix $(OBJDIR),$(LIBSOURCES)))
56 EXTRADEPS := $(LIBUCL)
58 # explicit dependencies on dualboot.{c,h} and mkamsboot.h
59 $(OBJDIR)mkamsboot.o: dualboot.h dualboot.c mkamsboot.c mkamsboot.h
60 $(OBJDIR)main.o: dualboot.h dualboot.c main.c mkamsboot.h
62 $(OBJDIR)%.o: %.c
63 @echo CC $<
64 $(SILENT)mkdir -p $(dir $@)
65 $(SILENT)$(CC) $(CFLAGS) -c -o $@ $<
67 libmkamsboot$(RBARCH).a: $(TARGET_DIR)libmkamsboot$(RBARCH).a
69 $(TARGET_DIR)libmkamsboot$(RBARCH).a: $(LIBOBJS)
70 @echo AR $(notdir $@)
71 $(SILENT)$(AR) rucs $@ $^
73 # building the standalone executable
74 $(OUTPUT): $(OBJS) $(EXTRADEPS)
75 @echo LD $@
76 $(SILENT)$(CC) $(CFLAGS) -o $(OUTPUT) $(OBJS) $(EXTRADEPS)
78 # some trickery to build ppc and i386 from a single call
79 ifeq ($(RBARCH),)
80 $(TARGET_DIR)libmkamsbooti386.a:
81 make RBARCH=i386 TARGET_DIR=$(TARGET_DIR) libmkamsbooti386.a
83 $(TARGET_DIR)libmkamsbootppc.a:
84 make RBARCH=ppc TARGET_DIR=$(TARGET_DIR) libmkamsbootppc.a
85 endif
87 libmkamsboot-universal: $(TARGET_DIR)libmkamsbooti386.a $(TARGET_DIR)libmkamsbootppc.a
88 @echo lipo $(TARGET_DIR)libmkamsboot.a
89 $(SILENT) rm -f $(TARGET_DIR)libmkamsboot.a
90 $(SILENT)lipo -create $(TARGET_DIR)libmkamsbootppc.a $(TARGET_DIR)libmkamsbooti386.a -output $(TARGET_DIR)libmkamsboot.a
92 clean:
93 rm -f $(OBJS) $(OUTPUT) libmkamsboot.o $(TARGET_DIR)libmkamsboot*.a mkamsboot.dmg
94 rm -rf mkamsboot-* i386 ppc $(OBJDIR)
96 mkamsboot-i386:
97 $(MAKE) RBARCH=i386
98 mv mkamsboot mkamsboot-i386
100 mkamsboot-ppc:
101 $(MAKE) RBARCH=ppc
102 mv mkamsboot mkamsboot-ppc
104 mkamsboot-mac: mkamsboot-i386 mkamsboot-ppc
105 $(SILENT)lipo -create mkamsboot-ppc mkamsboot-i386 -output mkamsboot-mac
107 mkamsboot.dmg: mkamsboot-mac
108 mkdir -p mkamsboot-dmg
109 cp -p mkamsboot-mac mkamsboot-dmg
110 hdiutil create -srcfolder mkamsboot-dmg mkamsboot.dmg