Subversion Repositories freemyipod

Rev

Rev 973 | Details | Compare with Previous | Last modification | View Log | RSS feed

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