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-ipodclassic
273 theseven 2
 
427 farthen 3
EMCOREDIR ?= ../../
273 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
273 theseven 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=arm926ej-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 "^\#")
666 theseven 22
preprocesspaths = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c $(1) | grep -v "^\#" | sed -e "s:^..*:$(dir $(1))&:" | sed -e "s:^\\./::")
273 theseven 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
 
520 theseven 35
$(NAME): build/$(NAME).bin
273 theseven 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
 
427 farthen 79
build/__emcore_%.o: $(EMCOREDIR)/export/%.S
273 theseven 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
 
664 theseven 88
build/version.h: version.h .svn/entries
273 theseven 89
	@echo [PP]     $<
90
ifeq ($(shell uname),WindowsNT)
664 theseven 91
	@-if not exist build md build
273 theseven 92
	@sed -e "s/\$$REVISION\$$/$(REVISION)/" -e "s/\$$REVISIONINT\$$/$(REVISIONINT)/" < $< > $@
93
else
664 theseven 94
	@-mkdir -p build
273 theseven 95
	@sed -e 's/\$$REVISION\$$/$(REVISION)/' -e 's/\$$REVISIONINT\$$/$(REVISIONINT)/' < $< > $@
96
endif
97
 
98
clean:
663 theseven 99
	@rm -rf build
273 theseven 100
 
101
.PHONY: all clean $(NAME)