Subversion Repositories freemyipod

Rev

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

Rev 4 Rev 5
Line 12... Line 12...
12
LDFLAGS ?= "$(shell $(CC) -print-libgcc-file-name)" --gc-sections
12
LDFLAGS ?= "$(shell $(CC) -print-libgcc-file-name)" --gc-sections
13
 
13
 
14
preprocess = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c $(1) | grep -v "^\#" | sed -e "s:^..*:$(dir $(1))&:")
14
preprocess = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c $(1) | grep -v "^\#" | sed -e "s:^..*:$(dir $(1))&:")
15
 
15
 
16
define TARGET_template
16
define TARGET_template
17
SRC_$(1) := $$(call preprocess,SOURCES,-D TARGET=$(1))
17
SRC_$(1) := $$(call preprocess,SOURCES,-DTARGET_$(1))
18
OBJ_$(1) := $$(SRC_$(1):%.c=build/$(1)/%.o)
18
OBJ_$(1) := $$(SRC_$(1):%.c=build/$(1)/%.o)
19
OBJ_$(1) := $$(OBJ_$(1):%.S=build/$(1)/%.o)
19
OBJ_$(1) := $$(OBJ_$(1):%.S=build/$(1)/%.o)
20
 
20
 
21
-include $$(OBJ_$(1):%=%.dep)
21
-include $$(OBJ_$(1):%=%.dep)
22
 
22
 
Line 35... Line 35...
35
ifeq ($(shell uname),WindowsNT)
35
ifeq ($(shell uname),WindowsNT)
36
	@-if not exist $$(subst /,\,$$(dir $$@)) md $$(subst /,\,$$(dir $$@))
36
	@-if not exist $$(subst /,\,$$(dir $$@)) md $$(subst /,\,$$(dir $$@))
37
else
37
else
38
	@-mkdir -p $$(dir $$@)
38
	@-mkdir -p $$(dir $$@)
39
endif
39
endif
40
	$(CC) -c $(CFLAGS) -Itarget/$(1) -D TARGET=$(1) -o $$@ $$<
40
	$(CC) -c $(CFLAGS) -Itarget/$(1) -DTARGET_$(1) -o $$@ $$<
41
	@$(CC) -MM $(CFLAGS) -Itarget/$(1) -D TARGET=$(1) $$< > $$@.dep
41
	@$(CC) -MM $(CFLAGS) -Itarget/$(1) -DTARGET_$(1) $$< > $$@.dep
42
	@mv -f $$@.dep $$@.dep.tmp
42
	@mv -f $$@.dep $$@.dep.tmp
43
	@sed -e "s|.*:|$$@:|" < $$@.dep.tmp > $$@.dep
43
	@sed -e "s|.*:|$$@:|" < $$@.dep.tmp > $$@.dep
44
	@# Those many backslashes are necessary as make escapes them itself, then the shell
-
 
45
	@# So make makes 4 out of 8, then the shell makes 2 out of 4 which is what we want
-
 
46
	@sed -e "s/.*://" -e "s/\\\\\\\\$$$$//" < $$@.dep.tmp | fmt -1 | sed -e "s/^ *//" -e "s/$$$$/:/" >> $$@.dep
44
	@sed -e "s/.*://" -e "s/\\\\\\\\$$$$//" < $$@.dep.tmp | fmt -1 | sed -e "s/^ *//" -e "s/$$$$/:/" >> $$@.dep
47
	@rm -f $$@.dep.tmp
45
	@rm -f $$@.dep.tmp
48
 
46
 
49
build/$(1)/%.o: %.S
47
build/$(1)/%.o: %.S
50
ifeq ($(shell uname),WindowsNT)
48
ifeq ($(shell uname),WindowsNT)
51
	@-if not exist $$(subst /,\,$$(dir $$@)) md $$(subst /,\,$$(dir $$@))
49
	@-if not exist $$(subst /,\,$$(dir $$@)) md $$(subst /,\,$$(dir $$@))
52
else
50
else
53
	@-mkdir -p $$(dir $$@)
51
	@-mkdir -p $$(dir $$@)
54
endif
52
endif
55
	$(CC) -c $(CFLAGS) -Itarget/$(1) -D TARGET=$(1) -o $$@ $$<
53
	$(CC) -c $(CFLAGS) -Itarget/$(1) -DTARGET_$(1) -o $$@ $$<
56
	@$(CC) -MM $(CFLAGS) -Itarget/$(1) -D TARGET=$(1) $$< > $$@.dep
54
	@$(CC) -MM $(CFLAGS) -Itarget/$(1) -DTARGET_$(1) $$< > $$@.dep
57
	@mv -f $$@.dep $$@.dep.tmp
55
	@mv -f $$@.dep $$@.dep.tmp
58
	@sed -e "s|.*:|$$@:|" < $$@.dep.tmp > $$@.dep
56
	@sed -e "s|.*:|$$@:|" < $$@.dep.tmp > $$@.dep
59
	@# Those many backslashes are necessary as make escapes them itself, then the shell
-
 
60
	@# So make makes 4 out of 8, then the shell makes 2 out of 4 which is what we want
-
 
61
	@sed -e "s/.*://" -e "s/\\\\\\\\$$$$//" < $$@.dep.tmp | fmt -1 | sed -e "s/^ *//" -e "s/$$$$/:/" >> $$@.dep
57
	@sed -e "s/.*://" -e "s/\\\\\\\\$$$$//" < $$@.dep.tmp | fmt -1 | sed -e "s/^ *//" -e "s/$$$$/:/" >> $$@.dep
62
	@rm -f $$@.dep.tmp
58
	@rm -f $$@.dep.tmp
63
endef
59
endef
64
 
60
 
65
all: $(TARGETS)
61
all: $(TARGETS)