summaryrefslogtreecommitdiff
path: root/utils/MTP/beastpatcher/Makefile
blob: 5f3951d8befb4369220a7c7f58df94519b2aed84 (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
CFLAGS=-Wall -W

ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN)
OUTPUT=beastpatcher.exe
CROSS=
CFLAGS+=-mno-cygwin
else
ifeq ($(findstring MINGW,$(shell uname)),MINGW)
OUTPUT=beastpatcher.exe
CROSS=
else
OUTPUT=beastpatcher
CROSS=i586-mingw32msvc-
endif
endif

ifneq ($(findstring MINGW,$(shell uname)),MINGW)
LIBS = /usr/lib/libmtp.a /usr/lib/libusb.a
CFLAGS += $(shell printf \
	'\#include <libmtp.h>\nlibmtp version: LIBMTP_VERSION\n' | \
	gcc -E -P - -o - | grep -q '^libmtp version: 0\.2' && echo '-DOLDMTP')
CFLAGS += $(shell printf \
	'\#include <libmtp.h>\nlibmtp version: LIBMTP_VERSION\n' | \
	gcc -E -P - -o - | grep -q '^libmtp version: 0\.2\.[0-5]' && echo '-DREALLYOLDMTP')
endif
WINLIBS = ../MTP_DLL.dll

NATIVECC = gcc
CC = $(CROSS)gcc

all: $(OUTPUT)

beastpatcher: beastpatcher.c bootimg.c mtp_common.h mtp_libmtp.c main.c
	gcc $(CFLAGS) -o beastpatcher beastpatcher.c bootimg.c mtp_libmtp.c main.c $(LIBS)
	strip beastpatcher

beastpatcher.exe:  beastpatcher.c bootimg.c mtp_common.h mtp_win32.c main.c $(WINLIBS)
	$(CC) $(CFLAGS) -o beastpatcher.exe beastpatcher.c bootimg.c mtp_win32.c main.c $(WINLIBS)
	$(CROSS)strip beastpatcher.exe

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

beastpatcher-i386:  beastpatcher.c  bootimg.c usb.h main.c libusb-i386.a
	$(CC) -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 -framework iokit -framework coreservices -arch i386 $(CFLAGS) -o beastpatcher-i386 beastpatcher.c bootimg.c -I. libusb-i386.a
	strip beastpatcher-i386

beastpatcher-ppc: beastpatcher.c bootimg.c usb.h main.c libusb-ppc.a
	$(CC) -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 -framework iokit -framework coreservices -arch ppc $(CFLAGS) -o beastpatcher-ppc beastpatcher.c bootimg.c -I. libusb-ppc.a
	strip beastpatcher-ppc

bin2c: ../../../rbutil/sansapatcher/bin2c.c
	$(NATIVECC) $(CFLAGS) -o bin2c ../../../rbutil/sansapatcher/bin2c.c

bootimg.c: bootloader.bin bin2c
	./bin2c bootloader.bin bootimg

clean:
	rm -f beastpatcher.exe beastpatcher-mac beastpatcher-i386 beastpatcher-ppc beastpatcher bin2c bootimg.c bootimg.h *~