Subversion Repositories freemyipod

Rev

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

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