Subversion Repositories freemyipod

Rev

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

Rev 21 Rev 28
Line 11... Line 11...
11
LDFLAGS ?= "$(shell $(CC) -print-libgcc-file-name)" --gc-sections
11
LDFLAGS ?= "$(shell $(CC) -print-libgcc-file-name)" --gc-sections
12
 
12
 
13
preprocess = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c $(1) | grep -v "^\#")
13
preprocess = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c $(1) | grep -v "^\#")
14
preprocesspaths = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c $(1) | grep -v "^\#" | sed -e "s:^..*:$(dir $(1))&:")
14
preprocesspaths = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c $(1) | grep -v "^\#" | sed -e "s:^..*:$(dir $(1))&:")
15
 
15
 
-
 
16
REVISION := $(shell svnversion .)
-
 
17
REVISIONINT := $(shell echo $(REVISION) | sed -e "s/[^0-9].*$$//")
-
 
18
 
16
TARGETS := $(call preprocess,TARGETS,-I.)
19
TARGETS := $(call preprocess,TARGETS,-I.)
17
 
20
 
18
define TARGET_template
21
define TARGET_template
19
SRC_$(1) := $$(call preprocesspaths,SOURCES,-DTARGET_$(1) -Itarget/$(1) -I.)
22
SRC_$(1) := $$(call preprocesspaths,SOURCES,-DTARGET_$(1) -Itarget/$(1) -I.)
20
OBJ_$(1) := $$(SRC_$(1):%.c=build/$(1)/%.o)
23
OBJ_$(1) := $$(SRC_$(1):%.c=build/$(1)/%.o)
Line 31... Line 34...
31
	$(OBJCOPY) -O binary $$^ $$@
34
	$(OBJCOPY) -O binary $$^ $$@
32
 
35
 
33
build/$(1)/$(NAME).elf: target/$(1)/ls.x build/$(1)/target/$(1)/crt0.o $$(OBJ_$(1))
36
build/$(1)/$(NAME).elf: target/$(1)/ls.x build/$(1)/target/$(1)/crt0.o $$(OBJ_$(1))
34
	$(LD) $(LDFLAGS) -o $$@ -T target/$(1)/ls.x $$(OBJ_$(1))
37
	$(LD) $(LDFLAGS) -o $$@ -T target/$(1)/ls.x $$(OBJ_$(1))
35
 
38
 
36
build/$(1)/%.o: %.c
39
build/$(1)/%.o: %.c build/version.h
37
ifeq ($(shell uname),WindowsNT)
40
ifeq ($(shell uname),WindowsNT)
38
	@-if not exist $$(subst /,\,$$(dir $$@)) md $$(subst /,\,$$(dir $$@))
41
	@-if not exist $$(subst /,\,$$(dir $$@)) md $$(subst /,\,$$(dir $$@))
39
else
42
else
40
	@-mkdir -p $$(dir $$@)
43
	@-mkdir -p $$(dir $$@)
41
endif
44
endif
Line 43... Line 46...
43
	@$(CC) -MM $(CFLAGS) -Itarget/$(1) -DTARGET_$(1) $$< > $$@.dep.tmp
46
	@$(CC) -MM $(CFLAGS) -Itarget/$(1) -DTARGET_$(1) $$< > $$@.dep.tmp
44
	@sed -e "s|.*:|$$@:|" < $$@.dep.tmp > $$@.dep
47
	@sed -e "s|.*:|$$@:|" < $$@.dep.tmp > $$@.dep
45
	@sed -e "s/.*://" -e "s/\\$$$$//" < $$@.dep.tmp | fmt -1 | sed -e "s/^ *//" -e "s/$$$$/:/" >> $$@.dep
48
	@sed -e "s/.*://" -e "s/\\$$$$//" < $$@.dep.tmp | fmt -1 | sed -e "s/^ *//" -e "s/$$$$/:/" >> $$@.dep
46
	@rm -f $$@.dep.tmp
49
	@rm -f $$@.dep.tmp
47
 
50
 
48
build/$(1)/%.o: %.S
51
build/$(1)/%.o: %.S build/version.h
49
ifeq ($(shell uname),WindowsNT)
52
ifeq ($(shell uname),WindowsNT)
50
	@-if not exist $$(subst /,\,$$(dir $$@)) md $$(subst /,\,$$(dir $$@))
53
	@-if not exist $$(subst /,\,$$(dir $$@)) md $$(subst /,\,$$(dir $$@))
51
else
54
else
52
	@-mkdir -p $$(dir $$@)
55
	@-mkdir -p $$(dir $$@)
53
endif
56
endif
Line 60... Line 63...
60
 
63
 
61
all: $(TARGETS)
64
all: $(TARGETS)
62
 
65
 
63
$(foreach target,$(TARGETS),$(eval $(call TARGET_template,$(target))))
66
$(foreach target,$(TARGETS),$(eval $(call TARGET_template,$(target))))
64
 
67
 
-
 
68
build/version.h: version.h .svn/entries build
-
 
69
	@sed -e "s/\$$REVISION\$$/$(REVISION)/" -e "s/\$$REVISIONINT\$$/$(REVISIONINT)/" < $< > $@
-
 
70
 
-
 
71
build:
-
 
72
	@mkdir build
-
 
73
 
65
clean:
74
clean:
66
	rm -rf build
75
	rm -rf build
67
 
76
 
68
.PHONY: all clean $(TARGETS)
77
.PHONY: all clean $(TARGETS)