[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 6/7] build-sys: link with slirp as an external proje
From: |
Marc-André Lureau |
Subject: |
[Qemu-devel] [PATCH 6/7] build-sys: link with slirp as an external project |
Date: |
Tue, 12 Feb 2019 17:25:23 +0100 |
Use the "system" libslirp if its present or requested.
Else build with a static libslirp.a if slirp/ is checked
out ("internal") or a submodule ("git").
Signed-off-by: Marc-André Lureau <address@hidden>
---
net/slirp.c | 2 +-
Makefile | 8 +++---
Makefile.objs | 1 -
Makefile.target | 5 +---
configure | 65 +++++++++++++++++++++++++++++++++++++++++++---
net/Makefile.objs | 2 ++
util/Makefile.objs | 1 +
7 files changed, 72 insertions(+), 12 deletions(-)
diff --git a/net/slirp.c b/net/slirp.c
index b3bb1880c7..9c69500a36 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -37,7 +37,7 @@
#include "monitor/monitor.h"
#include "qemu/error-report.h"
#include "qemu/sockets.h"
-#include "slirp/src/libslirp.h"
+#include <libslirp.h>
#include "chardev/char-fe.h"
#include "sysemu/sysemu.h"
#include "qemu/cutils.h"
diff --git a/Makefile b/Makefile
index 3658310b95..55188d9e0a 100644
--- a/Makefile
+++ b/Makefile
@@ -382,8 +382,7 @@ dummy := $(call unnest-vars,, \
ui-obj-m \
audio-obj-y \
audio-obj-m \
- trace-obj-y \
- slirp-obj-y)
+ trace-obj-y)
include $(SRC_PATH)/tests/Makefile.include
@@ -456,7 +455,10 @@ CAP_CFLAGS += -DCAPSTONE_HAS_X86
subdir-capstone: .git-submodule-status
$(call quiet-command,$(MAKE) -C $(SRC_PATH)/capstone CAPSTONE_SHARED=no
BUILDDIR="$(BUILD_DIR)/capstone" CC="$(CC)" AR="$(AR)" LD="$(LD)"
RANLIB="$(RANLIB)" CFLAGS="$(CAP_CFLAGS)" $(SUBDIR_MAKEFLAGS)
$(BUILD_DIR)/capstone/$(LIBCAPSTONE))
-$(SUBDIR_RULES): libqemuutil.a $(common-obj-y) $(chardev-obj-y) $(slirp-obj-y)
\
+subdir-slirp: .git-submodule-status
+ $(call quiet-command,$(MAKE) -C $(SRC_PATH)/slirp
BUILD_DIR="$(BUILD_DIR)/slirp" CC="$(CC)" AR="$(AR)" LD="$(LD)"
RANLIB="$(RANLIB)" CFLAGS="$(QEMU_CFLAGS)")
+
+$(SUBDIR_RULES): libqemuutil.a $(common-obj-y) $(chardev-obj-y) \
$(qom-obj-y) $(crypto-aes-obj-$(CONFIG_USER_ONLY))
ROMSUBDIR_RULES=$(patsubst %,romsubdir-%, $(ROMS))
diff --git a/Makefile.objs b/Makefile.objs
index b7aae33367..90a7edeb4b 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -17,7 +17,6 @@ util-obj-y += $(QAPI_MODULES:%=qapi/qapi-events-%.o)
util-obj-y += qapi/qapi-introspect.o
chardev-obj-y = chardev/
-slirp-obj-$(CONFIG_SLIRP) = slirp/
#######################################################################
# block-obj-y is code used by both qemu system emulation and qemu-img
diff --git a/Makefile.target b/Makefile.target
index 401dc1ea6f..cb85eb450c 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -173,7 +173,6 @@ target-obj-y :=
block-obj-y :=
common-obj-y :=
chardev-obj-y :=
-slirp-obj-y :=
include $(SRC_PATH)/Makefile.objs
dummy := $(call unnest-vars,,target-obj-y)
target-obj-y-save := $(target-obj-y)
@@ -186,8 +185,7 @@ dummy := $(call unnest-vars,.., \
qom-obj-y \
io-obj-y \
common-obj-y \
- common-obj-m \
- slirp-obj-y)
+ common-obj-m)
target-obj-y := $(target-obj-y-save)
all-obj-y += $(common-obj-y)
all-obj-y += $(target-obj-y)
@@ -196,7 +194,6 @@ all-obj-$(CONFIG_SOFTMMU) += $(block-obj-y) $(chardev-obj-y)
all-obj-$(CONFIG_USER_ONLY) += $(crypto-aes-obj-y)
all-obj-$(CONFIG_SOFTMMU) += $(crypto-obj-y)
all-obj-$(CONFIG_SOFTMMU) += $(io-obj-y)
-all-obj-$(CONFIG_SOFTMMU) += $(slirp-obj-y)
$(QEMU_PROG_BUILD): config-devices.mak
diff --git a/configure b/configure
index fbd0825488..3664911a14 100755
--- a/configure
+++ b/configure
@@ -406,7 +406,7 @@ includedir="\${prefix}/include"
sysconfdir="\${prefix}/etc"
local_statedir="\${prefix}/var"
confsuffix="/qemu"
-slirp="yes"
+slirp=""
oss_lib=""
bsd="no"
linux="no"
@@ -1106,6 +1106,10 @@ for opt do
;;
--disable-slirp) slirp="no"
;;
+ --enable-slirp=git) slirp="git"
+ ;;
+ --enable-slirp=system) slirp="system"
+ ;;
--disable-vde) vde="no"
;;
--enable-vde) vde="yes"
@@ -5690,6 +5694,55 @@ if test "$libpmem" != "no"; then
fi
fi
+##########################################
+# check for slirp
+
+case "$slirp" in
+ "" | yes)
+ if $pkg_config slirp; then
+ slirp=system
+ elif test -e "${source_path}/.git" && test $git_update = 'yes' ; then
+ slirp=git
+ elif test -e "${source_path}/slirp/Makefile" ; then
+ slirp=internal
+ elif test -z "$slirp" ; then
+ slirp=no
+ else
+ feature_not_found "slirp" "Install slirp devel or git submodule"
+ fi
+ ;;
+
+ system)
+ if ! $pkg_config slirp; then
+ feature_not_found "slirp" "Install slirp devel"
+ fi
+ ;;
+esac
+
+case "$slirp" in
+ git | internal)
+ if test "$slirp" = git; then
+ git_submodules="${git_submodules} slirp"
+ fi
+ mkdir -p slirp
+ slirp_cflags="-I\$(SRC_PATH)/slirp/src -I\$(BUILD_DIR)/slirp/src"
+ slirp_libs="-L\$(BUILD_DIR)/slirp -lslirp"
+ ;;
+
+ system)
+ slirp_version=$($pkg_config --modversion slirp 2>/dev/null)
+ slirp_cflags=$($pkg_config --cflags slirp 2>/dev/null)
+ slirp_libs=$($pkg_config --libs slirp 2>/dev/null)
+ ;;
+
+ no)
+ ;;
+ *)
+ error_exit "Unknown state for slirp: $slirp"
+ ;;
+esac
+
+
##########################################
# End of CC checks
# After here, no more $cc or $ld runs
@@ -6047,7 +6100,8 @@ echo "QEMU_LDFLAGS $QEMU_LDFLAGS"
echo "make $make"
echo "install $install"
echo "python $python ($python_version)"
-if test "$slirp" = "yes" ; then
+echo "slirp support $slirp $(echo_version $slirp $slirp_version)"
+if test "$slirp" != "no" ; then
echo "smbd $smbd"
fi
echo "module support $modules"
@@ -6307,9 +6361,14 @@ fi
if test "$profiler" = "yes" ; then
echo "CONFIG_PROFILER=y" >> $config_host_mak
fi
-if test "$slirp" = "yes" ; then
+if test "$slirp" != "no"; then
echo "CONFIG_SLIRP=y" >> $config_host_mak
echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
+ echo "SLIRP_CFLAGS=$slirp_cflags" >> $config_host_mak
+ echo "SLIRP_LIBS=$slirp_libs" >> $config_host_mak
+fi
+if [ "$slirp" = "git" -o "$slirp" = "internal" ]; then
+ echo "config-host.h: subdir-slirp" >> $config_host_mak
fi
if test "$vde" = "yes" ; then
echo "CONFIG_VDE=y" >> $config_host_mak
diff --git a/net/Makefile.objs b/net/Makefile.objs
index b2bf88a0ef..7282c57c94 100644
--- a/net/Makefile.objs
+++ b/net/Makefile.objs
@@ -5,6 +5,8 @@ common-obj-y += eth.o
common-obj-$(CONFIG_L2TPV3) += l2tpv3.o
common-obj-$(CONFIG_POSIX) += vhost-user.o
common-obj-$(CONFIG_SLIRP) += slirp.o
+slirp.o-cflags := $(SLIRP_CFLAGS)
+slirp.o-libs := $(SLIRP_LIBS)
common-obj-$(CONFIG_VDE) += vde.o
common-obj-$(CONFIG_NETMAP) += netmap.o
common-obj-y += filter.o
diff --git a/util/Makefile.objs b/util/Makefile.objs
index 0820923c18..d67a31452f 100644
--- a/util/Makefile.objs
+++ b/util/Makefile.objs
@@ -3,6 +3,7 @@ util-obj-y += bufferiszero.o
util-obj-y += lockcnt.o
util-obj-y += aiocb.o async.o aio-wait.o thread-pool.o qemu-timer.o
util-obj-y += main-loop.o iohandler.o
+main-loop.o-cflags := $(SLIRP_CFLAGS)
util-obj-$(call lnot,$(CONFIG_ATOMIC64)) += atomic64.o
util-obj-$(CONFIG_POSIX) += aio-posix.o
util-obj-$(CONFIG_POSIX) += compatfd.o
--
2.21.0.rc0.1.g036caf7885
- [Qemu-devel] [PATCH 0/7] slirp: make it a standalone project, Marc-André Lureau, 2019/02/12
- [Qemu-devel] [PATCH 4/7] slirp: move sources to src/ subdirectory, Marc-André Lureau, 2019/02/12
- [Qemu-devel] [PATCH 1/7] slirp: adapt a subset of QEMU vmstate code, Marc-André Lureau, 2019/02/12
- [Qemu-devel] [PATCH 7/7] slirp: remove QEMU Makefile.objs, Marc-André Lureau, 2019/02/12
- [Qemu-devel] [PATCH 2/7] slirp: use libslirp migration code, Marc-André Lureau, 2019/02/12
- [Qemu-devel] [PATCH 3/7] slirp: use "slirp_" prefix for inet_aton() win32 implementation, Marc-André Lureau, 2019/02/12
- [Qemu-devel] [PATCH 6/7] build-sys: link with slirp as an external project,
Marc-André Lureau <=
- [Qemu-devel] [PATCH 5/7] slirp: add a standalone Makefile, Marc-André Lureau, 2019/02/12