mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-23 11:39:53 +00:00
484e2cc730
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
159 lines
5.1 KiB
Makefile
159 lines
5.1 KiB
Makefile
|
|
# These are used when we want to do substitutions without confusing Make
|
|
NULL :=
|
|
SPACE := $(NULL) #
|
|
COMMA := ,
|
|
|
|
# Don't use implicit rules or variables
|
|
# we have explicit rules for everything
|
|
MAKEFLAGS += -rR
|
|
|
|
# Files with this suffixes are final, don't try to generate them
|
|
# using implicit rules
|
|
%/trace-events:
|
|
%.hx:
|
|
%.py:
|
|
%.objs:
|
|
%.d:
|
|
%.h:
|
|
%.c:
|
|
%.cc:
|
|
%.cpp:
|
|
%.m:
|
|
%.mak:
|
|
|
|
# Flags for dependency generation
|
|
QEMU_DGFLAGS += -MMD -MP -MT $@ -MF $(@D)/$(*F).d
|
|
|
|
# Compiler searches the source file dir first, but in vpath builds
|
|
# we need to make it search the build dir too, before any other
|
|
# explicit search paths. There are two search locations in the build
|
|
# dir, one absolute and the other relative to the compiler working
|
|
# directory. These are the same for target-independent files, but
|
|
# different for target-dependent ones.
|
|
QEMU_LOCAL_INCLUDES = -iquote $(BUILD_DIR) -iquote $(BUILD_DIR)/$(@D) -iquote $(@D)
|
|
|
|
WL := -Wl,
|
|
ifdef CONFIG_DARWIN
|
|
whole-archive = $(WL)-force_load,$1
|
|
else
|
|
whole-archive = $(WL)--whole-archive $1 $(WL)--no-whole-archive
|
|
endif
|
|
|
|
extract-libs = $(strip $(foreach o,$1,$($o-libs)))
|
|
|
|
%.o: %.c
|
|
@mkdir -p $(dir $@)
|
|
$(call quiet-command,$(CC) $(QEMU_LOCAL_INCLUDES) $(QEMU_INCLUDES) \
|
|
$(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) $($@-cflags) \
|
|
-c -o $@ $<,"CC","$(TARGET_DIR)$@")
|
|
|
|
# If we have a CXX we might have some C++ objects, in which case we
|
|
# must link with the C++ compiler, not the plain C compiler.
|
|
LINKPROG = $(or $(CXX),$(CC))
|
|
|
|
LINK = $(call quiet-command, $(LINKPROG) $(CFLAGS) $(QEMU_LDFLAGS) -o $@ \
|
|
$(filter-out %.a %.fa,$1) \
|
|
$(foreach l,$(filter %.fa,$1),$(call whole-archive,$l)) \
|
|
$(filter %.a,$1) \
|
|
$(call extract-libs,$1) $(LIBS),"LINK","$(TARGET_DIR)$@")
|
|
|
|
%.o: %.S
|
|
$(call quiet-command,$(CCAS) $(QEMU_LOCAL_INCLUDES) $(QEMU_INCLUDES) \
|
|
$(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) \
|
|
-c -o $@ $<,"CCAS","$(TARGET_DIR)$@")
|
|
|
|
%.o: %.cc
|
|
$(call quiet-command,$(CXX) $(QEMU_LOCAL_INCLUDES) $(QEMU_INCLUDES) \
|
|
$(QEMU_CXXFLAGS) $(QEMU_DGFLAGS) $(CXXFLAGS) $($@-cflags) \
|
|
-c -o $@ $<,"CXX","$(TARGET_DIR)$@")
|
|
|
|
%.o: %.cpp
|
|
$(call quiet-command,$(CXX) $(QEMU_LOCAL_INCLUDES) $(QEMU_INCLUDES) \
|
|
$(QEMU_CXXFLAGS) $(QEMU_DGFLAGS) $(CXXFLAGS) $($@-cflags) \
|
|
-c -o $@ $<,"CXX","$(TARGET_DIR)$@")
|
|
|
|
%.o: %.m
|
|
$(call quiet-command,$(OBJCC) $(QEMU_LOCAL_INCLUDES) $(QEMU_INCLUDES) \
|
|
$(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) $($@-cflags) \
|
|
-c -o $@ $<,"OBJC","$(TARGET_DIR)$@")
|
|
|
|
%.o: %.dtrace
|
|
$(call quiet-command,dtrace -o $@ -G -s $<,"GEN","$(TARGET_DIR)$@")
|
|
|
|
.PHONY: modules
|
|
modules:
|
|
|
|
%$(EXESUF): %.o
|
|
$(call LINK,$(filter %.o %.a %.fa, $^))
|
|
|
|
%.a:
|
|
$(call quiet-command,rm -f $@ && $(AR) rcs $@ $^,"AR","$(TARGET_DIR)$@")
|
|
|
|
# Usage: $(call quiet-command,command and args,"NAME","args to print")
|
|
# This will run "command and args", and either:
|
|
# if V=1 just print the whole command and args
|
|
# otherwise print the 'quiet' output in the format " NAME args to print"
|
|
# NAME should be a short name of the command, 7 letters or fewer.
|
|
# If called with only a single argument, will print nothing in quiet mode.
|
|
quiet-command-run = $(if $(V),,$(if $2,printf " %-7s %s\n" $2 $3 && ))$1
|
|
quiet-@ = $(if $(V),,@)
|
|
quiet-command = $(quiet-@)$(call quiet-command-run,$1,$2,$3)
|
|
|
|
# cc-option
|
|
# Usage: CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0)
|
|
|
|
cc-option = $(if $(shell $(CC) $1 $2 -S -o /dev/null -xc /dev/null \
|
|
>/dev/null 2>&1 && echo OK), $2, $3)
|
|
cc-c-option = $(if $(shell $(CC) $1 $2 -c -o /dev/null -xc /dev/null \
|
|
>/dev/null 2>&1 && echo OK), $2, $3)
|
|
|
|
VPATH_SUFFIXES = %.c %.h %.S %.cc %.cpp %.m %.mak %.texi %.sh %.rc Kconfig% %.json.in
|
|
set-vpath = $(if $1,$(foreach PATTERN,$(VPATH_SUFFIXES),$(eval vpath $(PATTERN) $1)))
|
|
|
|
# install-prog list, dir
|
|
define install-prog
|
|
$(INSTALL_DIR) "$2"
|
|
$(INSTALL_PROG) $1 "$2"
|
|
$(if $(STRIP),$(STRIP) $(foreach T,$1,"$2/$(notdir $T)"),)
|
|
endef
|
|
|
|
# Logical functions (for operating on y/n values like CONFIG_FOO vars)
|
|
# Inputs to these must be either "y" (true) or "n" or "" (both false)
|
|
# Output is always either "y" or "n".
|
|
# Usage: $(call land,$(CONFIG_FOO),$(CONFIG_BAR))
|
|
# Logical NOT
|
|
lnot = $(if $(subst n,,$1),n,y)
|
|
# Logical AND
|
|
land = $(if $(findstring yy,$1$2),y,n)
|
|
# Logical OR
|
|
lor = $(if $(findstring y,$1$2),y,n)
|
|
# Logical XOR (note that this is the inverse of leqv)
|
|
lxor = $(if $(filter $(call lnot,$1),$(call lnot,$2)),n,y)
|
|
# Logical equivalence (note that leqv "","n" is true)
|
|
leqv = $(if $(filter $(call lnot,$1),$(call lnot,$2)),y,n)
|
|
# Logical if: like make's $(if) but with an leqv-like test
|
|
lif = $(if $(subst n,,$1),$2,$3)
|
|
|
|
# String testing functions: inputs to these can be any string;
|
|
# the output is always either "y" or "n". Leading and trailing whitespace
|
|
# is ignored when comparing strings.
|
|
# String equality
|
|
eq = $(if $(subst $2,,$1)$(subst $1,,$2),n,y)
|
|
# String inequality
|
|
ne = $(if $(subst $2,,$1)$(subst $1,,$2),y,n)
|
|
# Emptiness/non-emptiness tests:
|
|
isempty = $(if $1,n,y)
|
|
notempty = $(if $1,y,n)
|
|
|
|
.PHONY: clean-timestamp
|
|
clean-timestamp:
|
|
rm -f *.timestamp
|
|
clean: clean-timestamp
|
|
|
|
# will delete the target of a rule if commands exit with a nonzero exit status
|
|
.DELETE_ON_ERROR:
|
|
|
|
print-%:
|
|
@echo '$*=$($*)'
|