]> git.proxmox.com Git - qemu.git/blame - rules.mak
S390: ccw firmware: Add main program
[qemu.git] / rules.mak
CommitLineData
17759187 1
5ab28867
JQ
2# Don't use implicit rules or variables
3# we have explicit rules for everything
4MAKEFLAGS += -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 15QEMU_DGFLAGS += -MMD -MP -MT $@ -MF $(*D)/$(*F).d
02d5467e 16
9d9199a0
PB
17# Same as -I$(SRC_PATH) -I., but for the nested source/object directories
18QEMU_CFLAGS += -I$(<D) -I$(@D)
19
0e8c9214 20%.o: %.c
76dc3cf8 21 $(call quiet-command,$(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," CC $(TARGET_DIR)$@")
17759187 22
44dc0ca3 23ifeq ($(LIBTOOL),)
b6fc675b 24LIBTOOL = /bin/false
21655882 25LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ \
bf0842b7 26 $(sort $(filter %.o, $1)) $(filter-out %.o, $1) $(version-obj-y) \
21655882 27 $(LIBS)," LINK $(TARGET_DIR)$@")
44dc0ca3 28else
f141ccfa 29LIBTOOL += $(if $(V),,--quiet)
44dc0ca3 30%.lo: %.c
f141ccfa 31 $(call quiet-command,$(LIBTOOL) --mode=compile --tag=CC $(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," lt CC $@")
2c13ec50
PB
32%.lo: %.dtrace
33 $(call quiet-command,$(LIBTOOL) --mode=compile --tag=CC dtrace -o $@ -G -s $<, " lt GEN $(TARGET_DIR)$@")
34
21655882
PB
35LINK = $(call quiet-command,\
36 $(if $(filter %.lo %.la,$^),$(LIBTOOL) --mode=link --tag=CC \
37 )$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ \
5354e4d2
MAL
38 $(sort $(filter %.o, $1)) $(filter-out %.o, $1) \
39 $(if $(filter %.lo %.la,$^),$(version-lobj-y),$(version-obj-y)) \
37746c5e 40 $(if $(filter %.lo %.la,$^),$(LIBTOOLFLAGS)) \
21655882 41 $(LIBS),$(if $(filter %.lo %.la,$^),"lt LINK ", " LINK ")"$(TARGET_DIR)$@")
44dc0ca3
AL
42endif
43
3dd46c78
BS
44%.asm: %.S
45 $(call quiet-command,$(CPP) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -o $@ $<," CPP $(TARGET_DIR)$@")
46
47%.o: %.asm
48 $(call quiet-command,$(AS) $(ASFLAGS) -o $@ $<," AS $(TARGET_DIR)$@")
17759187
AL
49
50%.o: %.m
3c4a4d0d 51 $(call quiet-command,$(OBJCC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<," OBJC $(TARGET_DIR)$@")
17759187 52
2c13ec50
PB
53%.o: %.dtrace
54 $(call quiet-command,dtrace -o $@ -G -s $<, " GEN $(TARGET_DIR)$@")
55
3aa892d7 56%$(EXESUF): %.o
0bfe3ca5 57 $(call LINK,$^)
4f188f88 58
93a0dba7 59%.a:
28c699a2 60 $(call quiet-command,rm -f $@ && $(AR) rcs $@ $^," AR $(TARGET_DIR)$@")
93a0dba7 61
28c699a2 62quiet-command = $(if $(V),$1,$(if $(2),@echo $2 && $1, @$1))
70071e17
JQ
63
64# cc-option
8a2e6ab5 65# Usage: CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0)
70071e17 66
fc3baad7
TM
67cc-option = $(if $(shell $(CC) $1 $2 -S -o /dev/null -xc /dev/null \
68 >/dev/null 2>&1 && echo OK), $2, $3)
1215c6e7 69
b93b63f5 70VPATH_SUFFIXES = %.c %.h %.S %.m %.mak %.texi %.sh
288e7bcc 71set-vpath = $(if $1,$(foreach PATTERN,$(VPATH_SUFFIXES),$(eval vpath $(PATTERN) $1)))
076d2471 72
2b2e59e6
PB
73# find-in-path
74# Usage: $(call find-in-path, prog)
75# Looks in the PATH if the argument contains no slash, else only considers one
76# specific directory. Returns an # empty string if the program doesn't exist
77# there.
78find-in-path = $(if $(find-string /, $1), \
79 $(wildcard $1), \
80 $(wildcard $(patsubst %, %/$1, $(subst :, ,$(PATH)))))
81
c0424934
LV
82# Generate files with tracetool
83TRACETOOL=$(PYTHON) $(SRC_PATH)/scripts/tracetool.py
84
1215c6e7
JQ
85# Generate timestamp files for .h include files
86
4b25966a
MT
87config-%.h: config-%.h-timestamp
88 @cmp $< $@ >/dev/null 2>&1 || cp $< $@
1215c6e7 89
4b25966a
MT
90config-%.h-timestamp: config-%.mak
91 $(call quiet-command, sh $(SRC_PATH)/scripts/create_config < $< > $@, " GEN $(TARGET_DIR)config-$*.h")
7dbbbb0c 92
7586317b
MT
93.PHONY: clean-timestamp
94clean-timestamp:
95 rm -f *.timestamp
96clean: clean-timestamp
97
7dbbbb0c
MT
98# will delete the target of a rule if commands exit with a nonzero exit status
99.DELETE_ON_ERROR:
e05804ee
PB
100
101# magic to descend into other directories
102
103obj := .
104old-nested-dirs :=
105
106define push-var
107$(eval save-$2-$1 = $(value $1))
108$(eval $1 :=)
109endef
110
111define pop-var
112$(eval subdir-$2-$1 := $(if $(filter $2,$(save-$2-$1)),$(addprefix $2,$($1))))
113$(eval $1 = $(value save-$2-$1) $$(subdir-$2-$1))
114$(eval save-$2-$1 :=)
115endef
116
117define unnest-dir
118$(foreach var,$(nested-vars),$(call push-var,$(var),$1/))
119$(eval obj := $(obj)/$1)
120$(eval include $(SRC_PATH)/$1/Makefile.objs)
121$(eval obj := $(patsubst %/$1,%,$(obj)))
122$(foreach var,$(nested-vars),$(call pop-var,$(var),$1/))
123endef
124
125define unnest-vars-1
126$(eval nested-dirs := $(filter-out \
127 $(old-nested-dirs), \
128 $(sort $(foreach var,$(nested-vars), $(filter %/, $($(var)))))))
129$(if $(nested-dirs),
130 $(foreach dir,$(nested-dirs),$(call unnest-dir,$(patsubst %/,%,$(dir))))
131 $(eval old-nested-dirs := $(old-nested-dirs) $(nested-dirs))
132 $(call unnest-vars-1))
133endef
134
135define unnest-vars
136$(call unnest-vars-1)
137$(foreach var,$(nested-vars),$(eval $(var) := $(filter-out %/, $($(var)))))
2dee8d54 138$(shell mkdir -p $(sort $(foreach var,$(nested-vars),$(dir $($(var))))))
1435ddb8
PB
139$(foreach var,$(nested-vars), $(eval \
140 -include $(addsuffix *.d, $(sort $(dir $($(var)))))))
e05804ee 141endef