Subversion Repositories freemyipod

Rev

Rev 803 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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