Subversion Repositories freemyipod

Rev

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

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