root / rules.mak @ f141ccfa
History | View | Annotate | Download (3.8 kB)
1 | 17759187 | aliguori | |
---|---|---|---|
2 | 5ab28867 | Juan Quintela | # Don't use implicit rules or variables |
3 | 5ab28867 | Juan Quintela | # we have explicit rules for everything |
4 | 5ab28867 | Juan Quintela | MAKEFLAGS += -rR |
5 | 5ab28867 | Juan Quintela | |
6 | 5ab28867 | Juan Quintela | # Files with this suffixes are final, don't try to generate them |
7 | 5ab28867 | Juan Quintela | # using implicit rules |
8 | 5ab28867 | Juan Quintela | %.d: |
9 | 5ab28867 | Juan Quintela | %.h: |
10 | 5ab28867 | Juan Quintela | %.c: |
11 | 5ab28867 | Juan Quintela | %.m: |
12 | 5ab28867 | Juan Quintela | %.mak: |
13 | 5ab28867 | Juan Quintela | |
14 | 7ebf54bc | Stefan Weil | # Flags for dependency generation |
15 | a71cd2a5 | Jan Kiszka | QEMU_DGFLAGS += -MMD -MP -MT $@ -MF $(*D)/$(*F).d |
16 | 02d5467e | malc | |
17 | 9d9199a0 | Paolo Bonzini | # Same as -I$(SRC_PATH) -I., but for the nested source/object directories |
18 | 9d9199a0 | Paolo Bonzini | QEMU_CFLAGS += -I$(<D) -I$(@D) |
19 | 9d9199a0 | Paolo Bonzini | |
20 | 0e8c9214 | Andreas Färber | %.o: %.c |
21 | 76dc3cf8 | Jiri Denemark | $(call quiet-command,$(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," CC $(TARGET_DIR)$@") |
22 | 17759187 | aliguori | |
23 | 44dc0ca3 | Alon Levy | ifeq ($(LIBTOOL),) |
24 | 44dc0ca3 | Alon Levy | %.lo: %.c |
25 | 44dc0ca3 | Alon Levy | @echo "missing libtool. please install and rerun configure"; exit 1 |
26 | 44dc0ca3 | Alon Levy | else |
27 | f141ccfa | Paolo Bonzini | LIBTOOL += $(if $(V),,--quiet) |
28 | 44dc0ca3 | Alon Levy | %.lo: %.c |
29 | f141ccfa | Paolo Bonzini | $(call quiet-command,$(LIBTOOL) --mode=compile --tag=CC $(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," lt CC $@") |
30 | 44dc0ca3 | Alon Levy | endif |
31 | 44dc0ca3 | Alon Levy | |
32 | 3dd46c78 | Blue Swirl | %.asm: %.S |
33 | 3dd46c78 | Blue Swirl | $(call quiet-command,$(CPP) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -o $@ $<," CPP $(TARGET_DIR)$@") |
34 | 3dd46c78 | Blue Swirl | |
35 | 3dd46c78 | Blue Swirl | %.o: %.asm |
36 | 3dd46c78 | Blue Swirl | $(call quiet-command,$(AS) $(ASFLAGS) -o $@ $<," AS $(TARGET_DIR)$@") |
37 | 17759187 | aliguori | |
38 | 17759187 | aliguori | %.o: %.m |
39 | 3c4a4d0d | Peter Maydell | $(call quiet-command,$(OBJCC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," OBJC $(TARGET_DIR)$@") |
40 | 17759187 | aliguori | |
41 | 3bc2f570 | Paolo Bonzini | LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(sort $(filter %.o, $1)) $(filter-out %.o, $1) $(LIBS)," LINK $(TARGET_DIR)$@") |
42 | 3aa892d7 | aliguori | |
43 | 3aa892d7 | aliguori | %$(EXESUF): %.o |
44 | 0bfe3ca5 | Anthony Liguori | $(call LINK,$^) |
45 | 4f188f88 | aliguori | |
46 | 93a0dba7 | aliguori | %.a: |
47 | 28c699a2 | aliguori | $(call quiet-command,rm -f $@ && $(AR) rcs $@ $^," AR $(TARGET_DIR)$@") |
48 | 93a0dba7 | aliguori | |
49 | 28c699a2 | aliguori | quiet-command = $(if $(V),$1,$(if $(2),@echo $2 && $1, @$1)) |
50 | 70071e17 | Juan Quintela | |
51 | 70071e17 | Juan Quintela | # cc-option |
52 | 8a2e6ab5 | Juan Quintela | # Usage: CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0) |
53 | 70071e17 | Juan Quintela | |
54 | fc3baad7 | Thomas Monjalon | cc-option = $(if $(shell $(CC) $1 $2 -S -o /dev/null -xc /dev/null \ |
55 | fc3baad7 | Thomas Monjalon | >/dev/null 2>&1 && echo OK), $2, $3) |
56 | 1215c6e7 | Juan Quintela | |
57 | b93b63f5 | Paolo Bonzini | VPATH_SUFFIXES = %.c %.h %.S %.m %.mak %.texi %.sh |
58 | 288e7bcc | Nathan Froyd | set-vpath = $(if $1,$(foreach PATTERN,$(VPATH_SUFFIXES),$(eval vpath $(PATTERN) $1))) |
59 | 076d2471 | Paolo Bonzini | |
60 | 2b2e59e6 | Paolo Bonzini | # find-in-path |
61 | 2b2e59e6 | Paolo Bonzini | # Usage: $(call find-in-path, prog) |
62 | 2b2e59e6 | Paolo Bonzini | # Looks in the PATH if the argument contains no slash, else only considers one |
63 | 2b2e59e6 | Paolo Bonzini | # specific directory. Returns an # empty string if the program doesn't exist |
64 | 2b2e59e6 | Paolo Bonzini | # there. |
65 | 2b2e59e6 | Paolo Bonzini | find-in-path = $(if $(find-string /, $1), \ |
66 | 2b2e59e6 | Paolo Bonzini | $(wildcard $1), \ |
67 | 2b2e59e6 | Paolo Bonzini | $(wildcard $(patsubst %, %/$1, $(subst :, ,$(PATH))))) |
68 | 2b2e59e6 | Paolo Bonzini | |
69 | c0424934 | Lluís Vilanova | # Generate files with tracetool |
70 | c0424934 | Lluís Vilanova | TRACETOOL=$(PYTHON) $(SRC_PATH)/scripts/tracetool.py |
71 | c0424934 | Lluís Vilanova | |
72 | 1215c6e7 | Juan Quintela | # Generate timestamp files for .h include files |
73 | 1215c6e7 | Juan Quintela | |
74 | 1215c6e7 | Juan Quintela | %.h: %.h-timestamp |
75 | 1215c6e7 | Juan Quintela | @test -f $@ || cp $< $@ |
76 | 1215c6e7 | Juan Quintela | |
77 | 1215c6e7 | Juan Quintela | %.h-timestamp: %.mak |
78 | 4e8cb28c | Paolo Bonzini | $(call quiet-command, sh $(SRC_PATH)/scripts/create_config < $< > $@, " GEN $(TARGET_DIR)$*.h") |
79 | 1215c6e7 | Juan Quintela | @cmp $@ $*.h >/dev/null 2>&1 || cp $@ $*.h |
80 | 7dbbbb0c | Michael S. Tsirkin | |
81 | 7dbbbb0c | Michael S. Tsirkin | # will delete the target of a rule if commands exit with a nonzero exit status |
82 | 7dbbbb0c | Michael S. Tsirkin | .DELETE_ON_ERROR: |
83 | e05804ee | Paolo Bonzini | |
84 | e05804ee | Paolo Bonzini | # magic to descend into other directories |
85 | e05804ee | Paolo Bonzini | |
86 | e05804ee | Paolo Bonzini | obj := . |
87 | e05804ee | Paolo Bonzini | old-nested-dirs := |
88 | e05804ee | Paolo Bonzini | |
89 | e05804ee | Paolo Bonzini | define push-var |
90 | e05804ee | Paolo Bonzini | $(eval save-$2-$1 = $(value $1)) |
91 | e05804ee | Paolo Bonzini | $(eval $1 :=) |
92 | e05804ee | Paolo Bonzini | endef |
93 | e05804ee | Paolo Bonzini | |
94 | e05804ee | Paolo Bonzini | define pop-var |
95 | e05804ee | Paolo Bonzini | $(eval subdir-$2-$1 := $(if $(filter $2,$(save-$2-$1)),$(addprefix $2,$($1)))) |
96 | e05804ee | Paolo Bonzini | $(eval $1 = $(value save-$2-$1) $$(subdir-$2-$1)) |
97 | e05804ee | Paolo Bonzini | $(eval save-$2-$1 :=) |
98 | e05804ee | Paolo Bonzini | endef |
99 | e05804ee | Paolo Bonzini | |
100 | e05804ee | Paolo Bonzini | define unnest-dir |
101 | e05804ee | Paolo Bonzini | $(foreach var,$(nested-vars),$(call push-var,$(var),$1/)) |
102 | e05804ee | Paolo Bonzini | $(eval obj := $(obj)/$1) |
103 | e05804ee | Paolo Bonzini | $(eval include $(SRC_PATH)/$1/Makefile.objs) |
104 | e05804ee | Paolo Bonzini | $(eval obj := $(patsubst %/$1,%,$(obj))) |
105 | e05804ee | Paolo Bonzini | $(foreach var,$(nested-vars),$(call pop-var,$(var),$1/)) |
106 | e05804ee | Paolo Bonzini | endef |
107 | e05804ee | Paolo Bonzini | |
108 | e05804ee | Paolo Bonzini | define unnest-vars-1 |
109 | e05804ee | Paolo Bonzini | $(eval nested-dirs := $(filter-out \ |
110 | e05804ee | Paolo Bonzini | $(old-nested-dirs), \ |
111 | e05804ee | Paolo Bonzini | $(sort $(foreach var,$(nested-vars), $(filter %/, $($(var))))))) |
112 | e05804ee | Paolo Bonzini | $(if $(nested-dirs), |
113 | e05804ee | Paolo Bonzini | $(foreach dir,$(nested-dirs),$(call unnest-dir,$(patsubst %/,%,$(dir)))) |
114 | e05804ee | Paolo Bonzini | $(eval old-nested-dirs := $(old-nested-dirs) $(nested-dirs)) |
115 | e05804ee | Paolo Bonzini | $(call unnest-vars-1)) |
116 | e05804ee | Paolo Bonzini | endef |
117 | e05804ee | Paolo Bonzini | |
118 | e05804ee | Paolo Bonzini | define unnest-vars |
119 | e05804ee | Paolo Bonzini | $(call unnest-vars-1) |
120 | e05804ee | Paolo Bonzini | $(foreach var,$(nested-vars),$(eval $(var) := $(filter-out %/, $($(var))))) |
121 | 2dee8d54 | Paolo Bonzini | $(shell mkdir -p $(sort $(foreach var,$(nested-vars),$(dir $($(var)))))) |
122 | 1435ddb8 | Paolo Bonzini | $(foreach var,$(nested-vars), $(eval \ |
123 | 1435ddb8 | Paolo Bonzini | -include $(addsuffix *.d, $(sort $(dir $($(var))))))) |
124 | e05804ee | Paolo Bonzini | endef |