Subversion Repositories freemyipod

Rev

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
 
12
CFLAGS  += -Os -fno-pie -fno-stack-protector -fomit-frame-pointer -I. -I$(EMBIOSDIR)/export -ffunction-sections -fdata-sections
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
 
21
SRC := $(call preprocesspaths,SOURCES,-I. -I..)
22
OBJ := $(SRC:%.c=build/%.o)
23
OBJ := $(OBJ:%.S=build/%.o)
24
 
25
all: $(NAME)
26
 
27
-include $(OBJ:%=%.dep)
28
 
29
$(NAME): build/$(NAME).embiosapp.ucl
30
 
31
build/$(NAME).embiosapp.ucl: build/$(NAME).embiosapp
32
	@echo [UCL]    $<
33
	@$(UCLPACK) $^ $@
34
 
35
build/$(NAME).embiosapp: build/$(NAME).elf
36
	@echo [OC]     $<
37
	@$(OBJCOPY) -O binary $^ $@
38
 
39
build/$(NAME).elf: ls.x $(OBJ)
40
	@echo [LD]     $@
41
	@$(LD) $(LDFLAGS) -o $@ -T ls.x $(OBJ)
42
 
43
build/%.o: %.c build/version.h
44
	@echo [CC]     $<
45
ifeq ($(shell uname),WindowsNT)
46
	@-if not exist $(subst /,\,$(dir $@)) md $(subst /,\,$(dir $@))
47
else
48
	@-mkdir -p $(dir $@)
49
endif
50
	@$(CC) -c $(CFLAGS) -o $@ $<
51
	@$(CC) -MM $(CFLAGS) $< > $@.dep.tmp
52
	@sed -e "s|.*:|$@:|" < $@.dep.tmp > $@.dep
53
ifeq ($(shell uname),WindowsNT)
54
	@sed -e "s/.*://" -e "s/\\$$//" < $@.dep.tmp | fmt -1 | sed -e "s/^ *//" -e "s/$$/:/" >> $@.dep
55
else
56
	@sed -e 's/.*://' -e 's/\\$$//' < $@.dep.tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $@.dep
57
endif
58
	@rm -f $@.dep.tmp
59
 
60
build/%.o: %.S build/version.h
61
	@echo [CC]     $<
62
ifeq ($(shell uname),WindowsNT)
63
	@-if not exist $(subst /,\,$(dir $@)) md $(subst /,\,$(dir $@))
64
else
65
	@-mkdir -p $(dir $@)
66
endif
67
	@$(CC) -c $(CFLAGS) -o $@ $<
68
	@$(CC) -MM $(CFLAGS) $< > $@.dep.tmp
69
	@sed -e "s|.*:|$@:|" < $@.dep.tmp > $@.dep
70
ifeq ($(shell uname),WindowsNT)
71
	@sed -e "s/.*://" -e "s/\\$$//" < $@.dep.tmp | fmt -1 | sed -e "s/^ *//" -e "s/$$/:/" >> $@.dep
72
else
73
	@sed -e 's/.*://' -e 's/\\$$//' < $@.dep.tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $@.dep
74
endif
75
	@rm -f $@.dep.tmp
76
 
77
build/version.h: version.h .svn/entries
78
	@echo [PP]     $<
79
ifeq ($(shell uname),WindowsNT)
80
	@-if not exist build md build
81
	@sed -e "s/\$$REVISION\$$/$(REVISION)/" -e "s/\$$REVISIONINT\$$/$(REVISIONINT)/" < $< > $@
82
else
83
	@-mkdir -p build
84
	@sed -e 's/\$$REVISION\$$/$(REVISION)/' -e 's/\$$REVISIONINT\$$/$(REVISIONINT)/' < $< > $@
85
endif
86
 
87
clean:
88
	@rm -rf build
89
 
90
.PHONY: all clean $(NAME)