Subversion Repositories freemyipod

Rev

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

Rev Author Line No. Line
427 farthen 1
NAME := emcoreldr-ipodnano2g
159 theseven 2
 
427 farthen 3
EMCOREDIR ?= ../../
159 theseven 4
 
462 theseven 5
ifeq ($(shell uname),WindowsNT)
6
CCACHE :=
7
else
8
CCACHE := $(shell which ccache)
9
endif
10
 
455 theseven 11
CROSS   ?= arm-elf-eabi-
462 theseven 12
CC      := $(CCACHE) $(CROSS)gcc
159 theseven 13
AS      := $(CROSS)as
14
LD      := $(CROSS)ld
15
OBJCOPY := $(CROSS)objcopy
16
UCLPACK := ucl2e10singleblk
427 farthen 17
CRYPTDFU := python $(EMCOREDIR)/tools/ipodcrypt.py s5l8701-cryptdfu
159 theseven 18
 
19
CFLAGS  += -Os -fno-pie -fno-stack-protector -fomit-frame-pointer -I. -ffunction-sections -fdata-sections -mcpu=arm940t
20
LDFLAGS += "$(shell $(CC) -print-libgcc-file-name)" --gc-sections
21
 
22
preprocess = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c $(1) | grep -v "^\#")
23
preprocesspaths = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c $(1) | grep -v "^\#" | sed -e "s:^..*:$(dir $(1))&:")
24
 
25
REVISION := $(shell svnversion .)
26
REVISIONINT := $(shell echo $(REVISION) | sed -e "s/[^0-9].*$$//")
27
 
28
SRC := $(call preprocesspaths,SOURCES,-I. -I..)
29
OBJ := $(SRC:%.c=build/%.o)
30
OBJ := $(OBJ:%.S=build/%.o) $(HELPERS)
31
 
32
all: $(NAME)
33
 
34
-include $(OBJ:%=%.dep)
35
 
36
$(NAME): build/$(NAME).dfu
37
 
38
build/$(NAME).dfu: build/$(NAME).bin
39
	@echo [CDFU]   $<
40
	@$(CRYPTDFU) $^ $@
41
 
42
build/$(NAME).bin: build/$(NAME).elf
43
	@echo [OC]     $<
44
	@$(OBJCOPY) -O binary $^ $@
45
 
46
build/$(NAME).elf: ls.x $(OBJ)
47
	@echo [LD]     $@
48
	@$(LD) $(LDFLAGS) -o $@ -T ls.x $(OBJ)
49
 
50
build/%.o: %.c build/version.h
51
	@echo [CC]     $<
52
ifeq ($(shell uname),WindowsNT)
53
	@-if not exist $(subst /,\,$(dir $@)) md $(subst /,\,$(dir $@))
54
else
55
	@-mkdir -p $(dir $@)
56
endif
57
	@$(CC) -c $(CFLAGS) -o $@ $<
58
	@$(CC) -MM $(CFLAGS) $< > $@.dep.tmp
59
	@sed -e "s|.*:|$@:|" < $@.dep.tmp > $@.dep
60
ifeq ($(shell uname),WindowsNT)
61
	@sed -e "s/.*://" -e "s/\\$$//" < $@.dep.tmp | fmt -1 | sed -e "s/^ *//" -e "s/$$/:/" >> $@.dep
62
else
63
	@sed -e 's/.*://' -e 's/\\$$//' < $@.dep.tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $@.dep
64
endif
65
	@rm -f $@.dep.tmp
66
 
67
build/%.o: %.S build/version.h
68
	@echo [CC]     $<
69
ifeq ($(shell uname),WindowsNT)
70
	@-if not exist $(subst /,\,$(dir $@)) md $(subst /,\,$(dir $@))
71
else
72
	@-mkdir -p $(dir $@)
73
endif
74
	@$(CC) -c $(CFLAGS) -o $@ $<
75
	@$(CC) -MM $(CFLAGS) $< > $@.dep.tmp
76
	@sed -e "s|.*:|$@:|" < $@.dep.tmp > $@.dep
77
ifeq ($(shell uname),WindowsNT)
78
	@sed -e "s/.*://" -e "s/\\$$//" < $@.dep.tmp | fmt -1 | sed -e "s/^ *//" -e "s/$$/:/" >> $@.dep
79
else
80
	@sed -e 's/.*://' -e 's/\\$$//' < $@.dep.tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $@.dep
81
endif
82
	@rm -f $@.dep.tmp
83
 
427 farthen 84
build/__emcore_%.o: $(EMCOREDIR)/export/%.S
159 theseven 85
	@echo [CC]     $<
86
ifeq ($(shell uname),WindowsNT)
87
	@-if not exist $(subst /,\,$(dir $@)) md $(subst /,\,$(dir $@))
88
else
89
	@-mkdir -p $(dir $@)
90
endif
91
	@$(CC) -c $(CFLAGS) -o $@ $<
92
 
664 theseven 93
build/version.h: version.h .svn/entries
159 theseven 94
	@echo [PP]     $<
95
ifeq ($(shell uname),WindowsNT)
664 theseven 96
	@-if not exist build md build
159 theseven 97
	@sed -e "s/\$$REVISION\$$/$(REVISION)/" -e "s/\$$REVISIONINT\$$/$(REVISIONINT)/" < $< > $@
98
else
664 theseven 99
	@-mkdir -p build
159 theseven 100
	@sed -e 's/\$$REVISION\$$/$(REVISION)/' -e 's/\$$REVISIONINT\$$/$(REVISIONINT)/' < $< > $@
101
endif
102
 
103
clean:
663 theseven 104
	@rm -rf build
159 theseven 105
 
106
.PHONY: all clean $(NAME)