]>
git.proxmox.com Git - qemu.git/blob - rules.mak
2 # Don't use implicit rules or variables
3 # we have explicit rules for everything
6 # Files with this suffixes are final, don't try to generate them
14 # Flags for dependency generation
15 QEMU_DGFLAGS
+= -MMD
-MP
-MT
$@
-MF
$(*D
)/$(*F
).d
17 # Same as -I$(SRC_PATH) -I., but for the nested source/object directories
18 QEMU_CFLAGS
+= -I
$(<D
) -I
$(@D
)
21 $(call quiet-command
,$(CC
) $(QEMU_INCLUDES
) $(QEMU_CFLAGS
) $(QEMU_DGFLAGS
) $(CFLAGS
) -c
-o
$@
$<," CC $(TARGET_DIR)$@")
25 @echo
"missing libtool. please install and rerun configure"; exit
1
27 LIBTOOL
+= $(if
$(V
),,--quiet
)
29 $(call quiet-command
,$(LIBTOOL
) --mode
=compile
--tag
=CC
$(CC
) $(QEMU_INCLUDES
) $(QEMU_CFLAGS
) $(QEMU_DGFLAGS
) $(CFLAGS
) -c
-o
$@
$<," lt CC $@")
33 $(call quiet-command
,$(CPP
) $(QEMU_INCLUDES
) $(QEMU_CFLAGS
) $(QEMU_DGFLAGS
) $(CFLAGS
) -o
$@
$<," CPP $(TARGET_DIR)$@")
36 $(call quiet-command
,$(AS
) $(ASFLAGS
) -o
$@
$<," AS $(TARGET_DIR)$@")
39 $(call quiet-command
,$(OBJCC
) $(QEMU_INCLUDES
) $(QEMU_CFLAGS
) $(QEMU_DGFLAGS
) $(CFLAGS
) -c
-o
$@
$<," OBJC $(TARGET_DIR)$@")
41 LINK
= $(call quiet-command
,$(CC
) $(QEMU_CFLAGS
) $(CFLAGS
) $(LDFLAGS
) -o
$@
$(sort $(filter %.o
, $1)) $(filter-out %.o
, $1) $(LIBS
)," LINK $(TARGET_DIR)$@")
47 $(call quiet-command
,rm -f
$@
&& $(AR
) rcs
$@
$^
," AR $(TARGET_DIR)$@")
49 quiet-command
= $(if
$(V
),$1,$(if
$(2),@echo
$2 && $1, @
$1))
52 # Usage: CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0)
54 cc-option
= $(if
$(shell $(CC
) $1 $2 -S
-o
/dev
/null
-xc
/dev
/null \
55 >/dev
/null
2>&1 && echo OK
), $2, $3)
57 VPATH_SUFFIXES
= %.c
%.h
%.S
%.m
%.mak
%.texi
%.sh
58 set-vpath
= $(if
$1,$(foreach PATTERN
,$(VPATH_SUFFIXES
),$(eval vpath
$(PATTERN
) $1)))
61 # Usage: $(call find-in-path, prog)
62 # Looks in the PATH if the argument contains no slash, else only considers one
63 # specific directory. Returns an # empty string if the program doesn't exist
65 find-in-path
= $(if
$(find-string
/, $1), \
67 $(wildcard $(patsubst %, %/$1, $(subst :, ,$(PATH
)))))
69 # Generate files with tracetool
70 TRACETOOL
=$(PYTHON
) $(SRC_PATH
)/scripts
/tracetool.py
72 # Generate timestamp files for .h include files
75 @
test -f
$@ || cp
$< $@
78 $(call quiet-command
, sh
$(SRC_PATH
)/scripts
/create_config
< $< > $@
, " GEN $(TARGET_DIR)$*.h")
79 @cmp
$@
$*.h
>/dev
/null
2>&1 || cp
$@
$*.h
81 # will delete the target of a rule if commands exit with a nonzero exit status
84 # magic to descend into other directories
90 $(eval save-
$2-$1 = $(value
$1))
95 $(eval subdir-
$2-$1 := $(if
$(filter $2,$(save-
$2-$1)),$(addprefix $2,$($1))))
96 $(eval
$1 = $(value save-
$2-$1) $$(subdir-
$2-$1))
101 $(foreach var
,$(nested-vars
),$(call push-var
,$(var
),$1/))
102 $(eval obj
:= $(obj
)/$1)
103 $(eval
include $(SRC_PATH
)/$1/Makefile.objs
)
104 $(eval obj
:= $(patsubst %/$1,%,$(obj
)))
105 $(foreach var
,$(nested-vars
),$(call pop-var
,$(var
),$1/))
109 $(eval nested-dirs
:= $(filter-out \
110 $(old-nested-dirs
), \
111 $(sort $(foreach var
,$(nested-vars
), $(filter %/, $($(var
)))))))
113 $(foreach dir,$(nested-dirs
),$(call unnest-dir
,$(patsubst %/,%,$(dir))))
114 $(eval old-nested-dirs
:= $(old-nested-dirs
) $(nested-dirs
))
115 $(call unnest-vars-1
))
119 $(call unnest-vars-1
)
120 $(foreach var
,$(nested-vars
),$(eval
$(var
) := $(filter-out %/, $($(var
)))))
121 $(shell mkdir
-p
$(sort $(foreach var
,$(nested-vars
),$(dir $($(var
))))))
122 $(foreach var
,$(nested-vars
), $(eval \
123 -include $(addsuffix *.d
, $(sort $(dir $($(var
)))))))