Subversion Repositories freemyipod

Rev

Rev 454 | Rev 462 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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