summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 941dfdd05cd91808050ac6326dd5139e61597f3a (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
AR := ar
CP := cp
CC := gcc

UNAME := $(shell uname -s)

ifeq ($(UNAME),Darwin)
		CFLAGS = -I./include -I/usr/local/include -I/opt/local/include
		LDFLAGS = -L/usr/lib -L/opt/local/lib 
		LIBS = -lreadline -lusb-1.0 -framework CoreFoundation -framework IOKit
	
		IRECOVERY_TARGET = irecovery
		IRECOVERY_OBJECTS = irecovery.o libirecovery.a
		IRECOVERY_CFLAGS = $(CFLAGS)
		IRECOVERY_LDFLAGS =  $(LDFLAGS)
		IRECOVERY_LIBS = $(LIBS)
	
		LIBIRECOVERY_STATIC_TARGET = libirecovery.a
		LIBIRECOVERY_STATIC_OBJECTS = libirecovery.o
		LIBIRECOVERY_STATIC_CFLAGS = $(CFLAGS)
		LIBIRECOVERY_STATIC_LDFLAGS = $(LDFLAGS)
		LIBIRECOVERY_STATIC_LIBS = $(LIBS)
	
		LIBIRECOVERY_SHARED_TARGET = libirecovery.dylib
		LIBIRECOVERY_SHARED_OBJECTS = libirecovery.o
		LIBIRECOVERY_SHARED_CFLAGS = $(CFLAGS)
		LIBIRECOVERY_SHARED_LDFLAGS = $(LDFLAGS)
		LIBIRECOVERY_SHARED_LIBS = $(LIBS)
else
	ifeq ($(UNAME),MINGW32_NT-5.1)
		CFLAGS = -O3 -I include -I c:\mingw\include
		LDFLAGS = -L c:\mingw\lib -lreadline
		LIBS = -lreadline -lusb-1.0 -framework CoreFoundation -framework IOKit
	
		IRECOVERY_TARGET = irecovery.exe
		IRECOVERY_OBJECTS = irecovery.o
		IRECOVERY_CFLAGS = $(CFLAGS)
		IRECOVERY_LDFLAGS = $(LDFLAGS)
		IRECOVERY_LIBS = $(LIBS) libirecovery.a
	
		LIBIRECOVERY_STATIC_TARGET = libirecovery.a
		LIBIRECOVERY_STATIC_OBJECTS = libirecovery.o
		LIBIRECOVERY_STATIC_CFLAGS = $(CFLAGS)
		LIBIRECOVERY_STATIC_LDFLAGS = $(LDFLAGS)
		LIBIRECOVERY_STATIC_LIBS = $(LIBS)
	
		LIBIRECOVERY_SHARED_TARGET = libirecovery.dll
		LIBIRECOVERY_SHARED_OBJECTS = libirecovery.o
		LIBIRECOVERY_SHARED_CFLAGS = $(CFLAGS)
		LIBIRECOVERY_SHARED_LDFLAGS = $(LDFLAGS)
		LIBIRECOVERY_SHARED_LIBS = $(LIBS)
	else
		CFLAGS = -O3 -I./include -I/usr/include -I/usr/local/include
		LDFLAGS = -L/usr/lib -L/usr/local/lib
		LIBS = -lusb-1.0 -lreadline
		
		IRECOVERY_TARGET = irecovery
		IRECOVERY_OBJECTS = irecovery.o
		IRECOVERY_CFLAGS = $(CFLAGS)
		IRECOVERY_LDFLAGS = $(LDFLAGS)
		IRECOVERY_LIBS = $(LIBS)
	
		LIBIRECOVERY_STATIC_TARGET = libirecovery.a
		LIBIRECOVERY_STATIC_OBJECTS = libirecovery.o
		LIBIRECOVERY_STATIC_CFLAGS = $(CLFAGS)
		LIBIRECOVERY_STATIC_LDFLAGS = $(LDFLAGS)
		LIBIRECOVERY_STATIC_LIBS = $(LIBS)
	
		LIBIRECOVERY_SHARED_TARGET = libirecovery.so
		LIBIRECOVERY_SHARED_OBJECTS = libirecovery.o
		LIBIRECOVERY_SHARED_CFLAGS = $(CFLAGS)
		LIBIRECOVERY_SHARED_LDFLAGS = $(LDFLAGS)
		LIBIRECOVERY_SHARED_LIBS = $(LIBS)
	endif
endif

LIBIRECOVERY_OBJECTS = libirecovery.o
IRECOVERY_OBJECTS = irecovery.o libirecovery.a

TARGETS = $(LIBIRECOVERY_STATIC_TARGET) $(IRECOVERY_TARGET)
OBJECTS = libirecovery.o irecovery.o

%.o: %.S
	$(CC) -c $(<) -o $(@) $(CFLAGS)

%.o: %.c
	$(CC) -c $(<) -o $(@) $(CFLAGS) 

$(LIBIRECOVERY_STATIC_TARGET): $(LIBIRECOVERY_STATIC_OBJECTS)
	$(AR) rs $(LIBIRECOVERY_STATIC_TARGET) $(LIBIRECOVERY_STATIC_OBJECTS)
	
$(LIBIRECOVERY_SHARED_TARGET): $(LIBIRECOVERY_SHARED_OBJECTS)

$(IRECOVERY_TARGET): $(IRECOVERY_OBJECTS)
	$(CC) -o $(IRECOVERY_TARGET) $(IRECOVERY_OBJECTS) $(IRECOVERY_CFLAGS) $(IRECOVERY_LDFLAGS) $(IRECOVERY_LIBS)

all: $(TARGETS)
	
		
clean:
	$(RM) $(LIBIRECOVERY_STATIC_TARGET) $(IRECOVERY_TARGET) *.o