Subversion Repositories freemyipod

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
976 user890104 1
NAME := ipodscsi
2
 
3
ifeq ($(shell uname),WindowsNT)
4
CCACHE :=
5
else
6
CCACHE := $(shell which ccache)
7
endif
8
 
9
CC      := $(CCACHE) gcc
10
LD      := $(CCACHE) gcc
11
 
12
CFLAGS  += -Os -fomit-frame-pointer "-DDFUIMAGE=\"$(DFUIMAGE)\""
13
LDFLAGS += -Wl,-s
14
 
15
preprocess = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c $(1) | grep -v "^\#")
16
preprocesspaths = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c $(1) | grep -v "^\#" | sed -e "s:^..*:$(dir $(1))&:" | sed -e "s:^\\./::")
17
 
18
REVISION := $(shell svnversion .)
19
REVISIONINT := $(shell echo $(REVISION) | sed -e "s/[^0-9].*$$//")
20
 
21
SRC := $(call preprocesspaths,SOURCES,-I. -I..)
22
OBJ := $(SRC:%.c=build/%.o)
23
OBJ := $(OBJ:%.S=build/%.o)
24
OBJ := $(OBJ:%.rc=build/%.o)
25
 
26
all: $(NAME)
27
 
28
-include $(OBJ:%=%.dep)
29
 
30
ipodscsi.rc: ipodscsi.exe.manifest
31
 
32
$(NAME): build/$(NAME).exe
33
 
34
build/$(NAME).exe: $(OBJ)
35
	@echo [LD]     $@
36
	@$(LD) -o $@ $(OBJ) $(LDFLAGS)
37
 
38
build/%.o: %.c build/version.h
39
	@echo [CC]     $<
40
ifeq ($(shell uname),WindowsNT)
41
	@-if not exist $(subst /,\,$(dir $@)) md $(subst /,\,$(dir $@))
42
else
43
	@-mkdir -p $(dir $@)
44
endif
45
	@$(CC) -c $(CFLAGS) -o $@ $<
46
	@$(CC) -MM $(CFLAGS) $< > $@.dep.tmp
47
	@sed -e "s|.*:|$@:|" < $@.dep.tmp > $@.dep
48
ifeq ($(shell uname),WindowsNT)
49
	@sed -e "s/.*://" -e "s/\\$$//" < $@.dep.tmp | fmt -1 | sed -e "s/^ *//" -e "s/$$/:/" >> $@.dep
50
else
51
	@sed -e 's/.*://' -e 's/\\$$//' < $@.dep.tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $@.dep
52
endif
53
	@rm -f $@.dep.tmp
54
 
55
build/%.o: %.S build/version.h
56
	@echo [CC]     $<
57
ifeq ($(shell uname),WindowsNT)
58
	@-if not exist $(subst /,\,$(dir $@)) md $(subst /,\,$(dir $@))
59
else
60
	@-mkdir -p $(dir $@)
61
endif
62
	@$(CC) -c $(CFLAGS) -o $@ $<
63
	@$(CC) -MM $(CFLAGS) $< > $@.dep.tmp
64
	@sed -e "s|.*:|$@:|" < $@.dep.tmp > $@.dep
65
ifeq ($(shell uname),WindowsNT)
66
	@sed -e "s/.*://" -e "s/\\$$//" < $@.dep.tmp | fmt -1 | sed -e "s/^ *//" -e "s/$$/:/" >> $@.dep
67
else
68
	@sed -e 's/.*://' -e 's/\\$$//' < $@.dep.tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $@.dep
69
endif
70
	@rm -f $@.dep.tmp
71
 
72
build/%.o: %.rc
73
	@echo [WINRES] $<
74
ifeq ($(shell uname),WindowsNT)
75
	@-if not exist $(subst /,\,$(dir $@)) md $(subst /,\,$(dir $@))
76
else
77
	@-mkdir -p $(dir $@)
78
endif
79
	@windres -i $< -o $@ 
80
 
81
build/version.h: version.h ../../.svn/entries
82
	@echo [PP]     $<
83
ifeq ($(shell uname),WindowsNT)
84
	@-if not exist build md build
85
	@sed -e "s/\$$REVISION\$$/$(REVISION)/" -e "s/\$$REVISIONINT\$$/$(REVISIONINT)/" < $< > $@
86
else
87
	@-mkdir -p build
88
	@sed -e 's/\$$REVISION\$$/$(REVISION)/' -e 's/\$$REVISIONINT\$$/$(REVISIONINT)/' < $< > $@
89
endif
90
 
91
clean:
92
	@rm -rf build
93
 
94
.PHONY: all clean $(NAME)