Dave Chapman | c06071e | 2009-02-22 13:54:46 +0000 | [diff] [blame] | 1 | CFLAGS=-Wall -W |
| 2 | |
| 3 | ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN) |
| 4 | OUTPUT=beastpatcher.exe |
| 5 | CROSS= |
Dave Chapman | 93f4bd3 | 2009-02-22 23:35:29 +0000 | [diff] [blame] | 6 | CFLAGS+=-mno-cygwin |
Dave Chapman | c06071e | 2009-02-22 13:54:46 +0000 | [diff] [blame] | 7 | else |
| 8 | OUTPUT=beastpatcher |
| 9 | CROSS=i586-mingw32msvc- |
| 10 | endif |
| 11 | |
Dave Chapman | c06071e | 2009-02-22 13:54:46 +0000 | [diff] [blame] | 12 | LIBS = /usr/lib/libmtp.a /usr/lib/libusb.a |
| 13 | CFLAGS += $(shell printf \ |
| 14 | '\#include <libmtp.h>\nlibmtp version: LIBMTP_VERSION\n' | \ |
| 15 | gcc -E -P - -o - | grep -q '^libmtp version: 0\.2' && echo '-DOLDMTP') |
Dave Chapman | 93f4bd3 | 2009-02-22 23:35:29 +0000 | [diff] [blame] | 16 | WINLIBS = ../MTP_DLL.dll |
Dave Chapman | c06071e | 2009-02-22 13:54:46 +0000 | [diff] [blame] | 17 | |
| 18 | NATIVECC = gcc |
| 19 | CC = $(CROSS)gcc |
| 20 | |
| 21 | all: $(OUTPUT) |
| 22 | |
| 23 | beastpatcher: beastpatcher.c bootimg.c mtp_common.h mtp_libmtp.c |
| 24 | gcc $(CFLAGS) -o beastpatcher beastpatcher.c bootimg.c mtp_libmtp.c $(LIBS) |
| 25 | strip beastpatcher |
| 26 | |
Dave Chapman | 93f4bd3 | 2009-02-22 23:35:29 +0000 | [diff] [blame] | 27 | beastpatcher.exe: beastpatcher.c bootimg.c mtp_common.h mtp_win32.c $(WINLIBS) |
| 28 | $(CC) $(CFLAGS) -o beastpatcher.exe beastpatcher.c bootimg.c mtp_win32.c $(WINLIBS) |
Dave Chapman | c06071e | 2009-02-22 13:54:46 +0000 | [diff] [blame] | 29 | $(CROSS)strip beastpatcher.exe |
| 30 | |
| 31 | beastpatcher-mac: beastpatcher-i386 beastpatcher-ppc |
| 32 | lipo -create beastpatcher-ppc beastpatcher-i386 -output beastpatcher-mac |
| 33 | |
| 34 | beastpatcher-i386: beastpatcher.c bootimg.c usb.h libusb-i386.a |
| 35 | $(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 |
| 36 | strip beastpatcher-i386 |
| 37 | |
| 38 | beastpatcher-ppc: beastpatcher.c bootimg.c usb.h libusb-ppc.a |
| 39 | $(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 |
| 40 | strip beastpatcher-ppc |
| 41 | |
| 42 | bin2c: ../../../rbutil/sansapatcher/bin2c.c |
| 43 | $(NATIVECC) $(CFLAGS) -o bin2c ../../../rbutil/sansapatcher/bin2c.c |
| 44 | |
| 45 | bootimg.c: bootloader.bin bin2c |
| 46 | ./bin2c bootloader.bin bootimg |
| 47 | |
| 48 | clean: |
| 49 | rm -f beastpatcher.exe beastpatcher-mac beastpatcher-i386 beastpatcher-ppc beastpatcher bin2c bootimg.c bootimg.h *~ |