Subversion Repositories freemyipod

Rev

Rev 147 | Rev 458 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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