forked from pelrun/CHDK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_rules.inc
74 lines (60 loc) · 1.93 KB
/
build_rules.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# Build Rules for CHDK code (except tools)
# rule for building .o from .c in the same directory
%.o: %.c
@echo $< \-\> $@
$(CC) $(CFLAGS) $(ARCHFLAGS) -nostdinc -c -o $@ $<
# rule for building .o in $O sub-directory from .c in the current directory
$O%.o: %.c
mkdir -p $O
@echo $< \-\> $@
$(CC) $(CFLAGS) -nostdinc -c -o $@ $<
# rule for building .o from .c in the same directory - forces THUMB build
%.thm.o: %.c
@echo $< \-\> $@
$(CC) $(CFLAGS) -mthumb -nostdinc -c -o $@ $<
# rule for building .o from .c in the 'core' directory
$O%.o: $(core)/%.c
mkdir -p $O
@echo $< \-\> $@
$(CC) $(CFLAGS) -nostdinc -c -o $@ $<
# rule for building .o from .c in the 'core' directory - forces THUMB build
%.thm.o: $(core)/%.c
@echo $< \-\> $@
$(CC) $(CFLAGS) -mthumb -nostdinc -c -o $@ $<
# rule for building .o from .c in the 'modules' directory
$O%.o: $(modules)/%.c
mkdir -p $O
@echo $< \-\> $@
$(CC) $(CFLAGS) -nostdinc -c -o $@ $<
# rule for building .o from .S in the same directory
%.o: %.S
@echo $< \-\> $@
$(CC) $(CFLAGS) -nostdinc -c -o $@ $<
# rule for building .o in $O sub-directory from .S in the current directory
$O%.o: %.S
mkdir -p $O
@echo $< \-\> $@
$(CC) $(CFLAGS) -nostdinc -c -o $@ $<
# rule for building .a
%.a:
@echo $^ \-\> $@
$(AR) rcs $@ $^
%.bin: %.elf
@echo $< \-\> $@
$(OBJDUMP) -j .text -j .data -j .bss -z -d -r -f -h $< > $@.dump
$(OBJCOPY) -O binary $< $@
%.elf:
@echo \-\> $@
$(CC) $(CFLAGS) -o $@ $^ $(LDOPTS)
( $(NM) $@ | grep ' U ' > $@.syms ) && exit 1 || exit 0
.dep/%.d: %.c .dep
$(CC) $(CFLAGS) -M $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
.dep/%.d: %.S .dep
$(CC) $(CFLAGS) -M $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
# Define empty recipes for source files (including the makefiles)
# to prevent make from trying implicit rules to create them. Speeds up build process
$(topdir)build_rules.inc: ;