Subversion Repositories freemyipod

Rev

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

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