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