Subversion Repositories freemyipod

Rev

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