fix-obj-vars has the undesired side effect of breaking -cflags
-objs and -libs variables in the toplevel Makefile.objs. The
variables in the toplevel Makefile.objs do not need any fix,
so fix-obj-vars need not do anything.
Since we are touching it, remove the now unnecessary $(if)
in the callers.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This is needed in order to use per-object flags variables.
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
The compiling is done in a subdir, so the extraction of per-object libs
and cflags are referencing objects with ../ prefixed. So prefix the
per-object variables "foo.o-cflags" and "foo.o-libs" to
"../foo.o-cflags" and "../foo.o-libs".
Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Don't sort the extracted options, sort the objects.
Reported-by: Christian Mahnke <cmahnke@googlemail.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This patch adds loading, stamp checking and initialization of modules.
The init function of dynamic module is no longer directly called as
__attribute__((constructor)) in static linked version, it is called
only after passed the checking of presense of stamp symbol:
qemu_stamp_$RELEASEHASH
where $RELEASEHASH is generated by hashing version strings and content
of configure script.
With this, modules built from a different tree/version/configure will
not be loaded.
The module loading code requires gmodule-2.0.
Modules are searched under
- CONFIG_MODDIR
- executable folder (to allow running qemu-{img,io} in the build
directory)
- ../ of executable folder (to allow running system emulator in the
build directory)
Modules are linked under their subdir respectively, then copied to top
level of build directory for above convinience, e.g.:
$(BUILD_DIR)/block/curl.so -> $(BUILD_DIR)/block-curl.so
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Add necessary rules and flags for shared object generation.
The new rules introduced here are:
1) %.o in $(common-obj-m) is compiled to %.o, then linked to %.so.
2) %.mo in $(common-obj-m) is the placeholder for %.so for pattern
matching in Makefile. It's linked to "-shared" with all its dependencies
(multiple *.o) as input. Which means the list of depended objects must
be specified in each sub-Makefile.objs:
foo.mo-objs := bar.o baz.o qux.o
in the same style with foo.o-cflags and foo.o-libs. The objects here
will be prefixed with "$(obj)/" if it's a subdirectory Makefile.objs.
3) For all files ending up in %.so, the following is added automatically:
foo.o-cflags += -fPIC -DBUILD_DSO
Also introduce --enable-modules in configure, the option will enable
support of shared object build. Otherwise objects are static linked to
executables.
Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Adds extract-libs in LINK to expand any "per object libs", the syntax to define
such a libs options is like:
foo.o-libs := $(CURL_LIBS)
in block/Makefile.objs.
Similarly,
foo.o-cflags := $(FOO_CFLAGS)
is also supported.
"foo.o" must be listed in a nested var (e.g. common-obj-y) to make the
option variables effective.
Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Makefile.target includes rule.mak and unnested common-obj-y, then prefix
them with '../', this will ignore object specific QEMU_CFLAGS in subdir
Makefile.objs:
$(obj)/curl.o: QEMU_CFLAGS += $(CURL_CFLAGS)
Because $(obj) here is './block', instead of '../block'. This doesn't
hurt compiling because we basically build all .o from top Makefile,
before entering Makefile.target, but it will affact arriving per-object
libs support.
The starting point of $(obj) is passed in as argument of unnest-vars, as
well as nested variables, so that different Makefiles can pass in a
right value.
Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
If we have a C++ compiler available, link with it, because we might be
linking some C++ files in. This allows us to include C++ object files
in the QEMU binary proper.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
The A64 disassembler libvixl uses .cc as its suffix for
C++ source files, so add support for it (we already support
.cpp).
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Add new string testing functions which return a y/n result:
eq : are two strings equal (ignoring leading/trailing space)?
ne : are two strings unequal?
isempty : is a string empty?
notempty : is a string non-empty?
Based on an idea by Ákos Kovács <akoskovacs@gmx.com>.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Add new logical functions for handling y/n values like those we
use in CONFIG_FOO variables:
lnot : logical NOT
land : logical AND
lor : logical OR
lxor : logical XOR
leqv : logical equality, inverse of lxor
lif : like Make's $(if) but with an eq-like test
Based on an idea by Ákos Kovács <akoskovacs@gmx.com>.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Add configuration for C++ compiler in configure and Makefiles.
The C++ compiler is choosed as following:
- ${CXX}, if it is specified.
- ${cross_prefix}g++, if ${cross_prefix} is specified.
- Otherwise, c++ is used.
Currently, usage of C++ language is only for access to Windows VSS
using COM+ services in qemu-guest-agent for Windows.
Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Micael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
While commit c02817e5bf fixed compilation
without an installed libtool, moving the dependencies to rules.mak does
not work because the version-*-y variables are not defined yet. Building
in a clean tree thus fails.
Revert the commit and remove the dummy /bin/false assignment to LIBTOOL.
This makes the build work, at the price of slightly worse errors when
there are Makefile bugs.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1367425815-15083-1-git-send-email-pbonzini@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
The following error occurs when building dtc module:
CHK version_gen.h
CC libfdt/fdt.o
cc1: error: dtc: No such file or directory [-Werror]
cc1: all warnings being treated as errors
make[1]: *** [libfdt/fdt.o] Error 1
make: *** [subdir-dtc] Error 2
In rules.mak, "-I$(<D) -I$(@D)" was expanded to "-Idtc -I." when
building submodule dct. Due to the using of "-Wmissing-include-dirs,
a warning would be rarsed. To avoid it, add "-I$(<D) -I$(@D)" to
QEMU_INCLUDES instead of QEMU_CFLAGS so that QEMU_CFLAGS does not
contain the "-Idtc".
Cc: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Cc: Blue Swirl <blauwirbel@gmail.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Dunrong Huang <riegamaths@gmail.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1367247132-19622-1-git-send-email-riegamaths@gmail.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This makes the test on $(LIBTOOL) work. Otherwise, LIBTOOL
is /bin/false by the time the test is done.
Fixes Win32 compilation without a working cross-libtool.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
It is needed to give that flag to the linker as well, but latest
libtool 2.4.2 still swallows that argument, so let's pass it with
libtool -Wc argument.
qemu-1.4.0/stubs/arch-query-cpu-def.c:6: undefined reference to `__stack_chk_guard'
Signed-off-by: Marc-André Lureau <mlureau@redhat.com>
Reviewed-by: Alon Levy <alevy@redhat.com>
This addresses two issues with config generation
1. rule generating timestamp has side effect.
Thus cleanup on error does not work.
2. rule for handling timestamp is too generic.
It can create any missing .h file.
As a result when .h file is removed, build
might try to create it using this rule which
results in build errors.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Build option ROM .S files with separate preprocessor and
assembler steps because the C compiler could be unsuitable.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Weak symbols were a nice idea, but they turned out not to be a good one.
Toolchain support is just too sparse, in particular llvm-gcc is totally
broken.
This patch uses a surprisingly low-tech approach: a static library.
Symbols in a static library are always overridden by symbols in an
object file. Furthermore, if you place each function in a separate
source file, object files for unused functions will not be taken in.
This means that each function can use all the dependencies that it needs
(especially QAPI stuff such as error_setg).
Thus, all stubs are placed in separate object files and put together in
a static library. The library then is linked to all programs.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Tested-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Tested-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
MacOSX 10.8 ("Mountain Lion") requires us to compile our one
Objective-C source file with clang even if the rest of QEMU
requires a real gcc, because the system headers we use make
use of Apple's "Blocks" extension to C/ObjC, and mainline
gcc doesn't support that. Since we only need to use a true
gcc for the parts of QEMU that use the fixed-register
env variable, we can simply use clang to build the ObjC
file: it will link to the gcc-built objects with no problems.
Add the necessary support for an OBJCC variable in the
makefile and configure machinery; we default to clang
if we have it, otherwise whatever CC is (since gcc
might be the Apple gcc which does support Blocks).
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
After commit dcff25f2cd, Dependency file
are taken from the directories that have a Makefile.objs file. This is
not enough, since files can be included from other directories.
So, pick them from directories that have an object file in them.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
I think I understand enough of what's going on in these rules to ensure this is
right. But I could certainly use a second or third opinion...
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This adds the 'magic' rules that take care of subdirectories.
The subdirectory makefiles in the source tree are not complete; they
only define some variables (listed in nested-vars) according to the
configuration.
The magic rules descend into subdirectory makefiles and gather the
evaluated values of those variables. The values from all subdirectories
are joined together, each prefixed with the subdirectory name, and used
by the "real" makefiles.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This introduces new test reporting infrastructure based on
gtester and gtester-report.
Also, all existing tests are moved to tests/, and tests/Makefile
is reorganized to factor out the commonalities in the rules.
Signed-off-by: Anthony Liguori <aliguori@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Avoid duplicate object files during the link. There are legitimate
cases where a link command-line would include duplicate object files
because two independent subsystems both depend on common infrastructure.
Use GNU make's $(sort) function to remove duplicate object files from
the link command-line.
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Improvements to the libtool support in QEMU. Replace hard coded
libtool in the infrastructure with $(LIBTOOL) and allow
overriding the libtool binary used via the configure
script.
Reviewed-by: Andreas F=E4rber <andreas.faerber@web.de>
Signed-off-by: Brad Smith <brad@comstyle.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This patch fixes build when any of the include paths from QEMU_CFLAGS
contains a header file with similar name to a header file in qemu
sources. I hit it with error.h included by qapi/qapi-types-core.h. GCC
decided to use /usr/include/alsa/error.h instead of qemu's error.h.
Tested-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
No flag to configure is required. Instead, added a libcacard.la target that
is not built by default, only when requested explicitly via:
mkdir build
cd build
../configure
make libcacard.la
make install-libcacard
Uses libtool to do actual linking of object files and shared library, and
installing. Tested only under linux, but supposed to work on other systems as
well.
If libtool isn't found you get a message complaining about that, only at build
time (since it is not a default target I did not add a message at configure
time).
New build artifacts:
.libs subdirectories (at <buildroot> and <buildroot>/libcacard)
*.lo files (at same locations as the respective o files)
Added %.lo : %.c rule that uses libtool.
Updated clean rule to clean up those artifacts.
Added specific rule to call dtrace with libtool wrapper (note that because of
a current upstream dtrace bug fixed by systemtap b1568fd85 commit the -fPIC flag
isn't actually passed on. still current dtrace+libtool produced object links fine).
If libtool is missing any of the following targets will complain and exit 1:
any subdir: *.lo
root and libcacard: libcacard.la, libcacard-instsall
Tested to link and load with all tracing backends.
Non-existent -I paths are dropped silently by the compiler, but still
it is not polite to pass bogus options. Configure-time tests do not
need any include files from the source path, so only include -I flags
at make time (when they're properly expanded).
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
1) compute path to i386 compiler from configure. If it is found, run
the i386 tests. I use macros so that this approach could be applied
for other arches as well.
2) provide an easily extensible way to add tests
Most tests fail, but at least "make test" does something meaningful.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This seems to resolve subtle breakages of our build system:
Dependency files generated for targets like 'dir/foo.o' were saved as
'foo.d'. Now, if there was also a target 'foo.o', one of the dependency
file was overwritten. Concrete example: libhw*/macio.o vs.
libhw*/ide/macio.o. And this often left a segfaulting build result
behind when changing the "wrong" data structures".
Fix it by generating proper 'dir/foo.d'.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Acked-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
With three different make binaries I have available, configuring a
pristine QEMU tree and attempting to make gives the cryptic:
Makefile:27: *** missing separator. Stop.
This patch fixes it (presumably because it makes the output of
`set-vpath' be an empty string, rather than a bit of whitespace), but I
don't understand why this hasn't been a problem for other folks before.
Signed-off-by: Nathan Froyd <froydnj@codesourcery.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This adds a few more vpath suffixes and points the remaining two paths
explicitly to $(SRC_PATH) in order to eliminate the VPATH assignment
from config-host.mak.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Cc: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
The vpath directive has two advantages over the VPATH variable:
1) it allows to skip searching of .o files; 2) the default semantics
are to append to the vpath, so there is no confusion between "VPATH=xyz"
and "VPATH+=xyz".
Since "vpath %.c %.h PATH" is not valid, I'm introducing a wrapper
macro to append one or more directories to the vpath.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Juan has contributed a cool Makefile infrastructure that enables us to drop
static libraries completely:
Move shared obj-y definitions to Makefile.objs, prefixed {common-,hw-,user-},
and link those object files directly into the executables.
Replace HWLIB by HWDIR, specifying only the directory.
Drop --whole-archive and ARLIBS in Makefiles and configure.
Drop GENERATED_HEADERS dependency in rules.mak, since this rebuilds all
common objects after generating a target-specific header; add dependency
rules to Makefile and Makefile.target instead.
v2:
- Don't try to include /config.mak for user emulators
- Changes to user object paths ("Quickfix for libuser.a drop") were obsoleted
by "user_only: compile everything with -fpie" (Kirill A. Shutemov)
v3:
- Fix dependency modelling for tools
- Remove comment on GENERATED_HEADERS obsoleted by this patch
Signed-off-by: Andreas Färber <afaerber@opensolaris.org>
Cc: Blue Swirl <blauwirbel@gmail.com>
Cc: Palle Lyckegaard <palle@lyckegaard.dk>
Cc: Ben Taylor <bentaylor.solx86@gmail.com>
Cc: Juan Quintela <quintela@trasno.org>
Cc: Kirill A. Shutemov <kirill@shutemov.name>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Instruct make to remove any rule target on error. This prevetns
situation where there was an error during build but generated file still
stays behind.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>