Subversion Repositories freemyipod

Rev

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

Rev Author Line No. Line
145 theseven 1
NAME := uninstaller-nano2g
2
 
3
EMBIOSDIR ?= ../../embios/trunk/
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
11
 
147 theseven 12
CFLAGS  += -Os -fno-pie -fno-stack-protector -fomit-frame-pointer -I. -I$(EMBIOSDIR)/export -ffunction-sections -fdata-sections -mcpu=arm940t
145 theseven 13
LDFLAGS += "$(shell $(CC) -print-libgcc-file-name)" --gc-sections
14
 
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))&:")
17
 
18
REVISION := $(shell svnversion .)
19
REVISIONINT := $(shell echo $(REVISION) | sed -e "s/[^0-9].*$$//")
20
 
147 theseven 21
HELPERS := build/__embios_armhelpers.o
22
 
145 theseven 23
SRC := $(call preprocesspaths,SOURCES,-I. -I..)
24
OBJ := $(SRC:%.c=build/%.o)
147 theseven 25
OBJ := $(OBJ:%.S=build/%.o) $(HELPERS)
145 theseven 26
 
27
all: $(NAME)
28
 
29
-include $(OBJ:%=%.dep)
30
 
31
$(NAME): build/$(NAME).embiosapp.ucl
32
 
33
build/$(NAME).embiosapp.ucl: build/$(NAME).embiosapp
34
	@echo [UCL]    $<
35
	@$(UCLPACK) $^ $@
36
 
37
build/$(NAME).embiosapp: 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
 
147 theseven 79
build/__embios_%.o: $(EMBIOSDIR)/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
 
145 theseven 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)