Subversion Repositories freemyipod

Rev

Rev 666 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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