[Spice-commits] autogen.sh configure.ac Makefile Makefile.am slirp_common.h slirp_config.h slirp.pc slirp.pc.in

Alexander Larsson alexl at kemper.freedesktop.org
Fri Mar 26 01:43:50 PDT 2010


 Makefile       |   91 ------------------------------
 Makefile.am    |   49 ++++++++++++++++
 autogen.sh     |  170 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 configure.ac   |  117 +++++++++++++++++++++++++++++++++++++++
 slirp.pc       |   11 ---
 slirp.pc.in    |   11 +++
 slirp_common.h |    1 
 slirp_config.h |    9 ---
 8 files changed, 348 insertions(+), 111 deletions(-)

New commits:
commit 24f4767e1e10fbdc9bf569e4ac88b8acf08c6d51
Author: Alexander Larsson <alexl at redhat.com>
Date:   Fri Mar 26 09:30:54 2010 +0100

    Convert slirp to use autoconf
    
    Based on patch from Dave Airlie <airlied at gmail.com>

diff --git a/Makefile b/Makefile
deleted file mode 100644
index 929af78..0000000
--- a/Makefile
+++ /dev/null
@@ -1,91 +0,0 @@
-CC = gcc
-
-CFLAGS = -fvisibility=hidden -fPIC -DPIC -Wall -Wno-sign-compare -Werror -fno-strict-overflow
-LDFLAGS = -fPIC
-TARGET = RELEASE
-
-ifeq ($(TARGET),DEBUG)
-	CFLAGS += -g -O0
-	TARGETNAME = debug
-else ifeq ($(TARGET),RELEASE)
-	CFLAGS += -g -O3
-	TARGETNAME = release
-else
-	TARGETNAME = $(error Invalid TARGET. Use DEBUG or RELEASE)
-endif
-
-HEADERNAME = net_slirp.h
-LIBNAME = libslirp.so
-PCNAME = slirp.pc
-
-BIN = $(addprefix $(TARGETNAME)/, libslirp.so)
-
-INCLUDEDIR = /usr/include/libslirp
-LIBDIR = /usr/lib64
-PKGCONFIGDIR = /usr/lib64/pkgconfig
-
-SRCS =\
-	bootp.c\
-	cksum.c\
-	debug.c\
-	if.c\
-	ip_icmp.c\
-	ip_input.c\
-	ip_output.c\
-	mbuf.c\
-	misc.c\
-	sbuf.c\
-	net_slirp.c\
-	tcp_input.c\
-	tcp_output.c\
-	tcp_subr.c\
-	tcp_timer.c\
-	udp.c\
-    socket.c\
-    $(NULL)
-
-TMP = $(SRCS:.c=.o)
-OBJ = $(addprefix $(TARGETNAME)/, $(TMP))
-
-STATIC_LIBS = 
-DYNAMIC_LIBS =
-
-LIBS = -Wl,-Bstatic $(addprefix -l, $(STATIC_LIBS)) -Wl,-Bdynamic $(addprefix -l, $(DYNAMIC_LIBS))
-
-all : $(BIN) link
-
-$(BIN) : $(TARGETNAME) $(OBJ)
-	$(CC) -shared $(LDFLAGS) -o $(BIN) $(OBJ) $(LIBS)
-
-link : $(BIN)
-	rm -f $(LIBNAME)
-	ln -s $(BIN)
-
-MAKEDEPEND = $(CC) -M $(CFLAGS) -o $(addprefix $(TARGETNAME)/,.$*.dep.tmp) $<
-
-$(addprefix $(TARGETNAME)/, %.o) : %.c Makefile
-	@$(MAKEDEPEND) && \
-	cp $(addprefix $(TARGETNAME)/, .$*.dep.tmp) $(addprefix $(TARGETNAME)/, .$*.dep) && \
-	sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
-	    -e '/^$$/ d' -e 's/$$/ :/' < $(addprefix $(TARGETNAME)/,.$*.dep.tmp) >> $(addprefix $(TARGETNAME)/,.$*.dep) && \
-	sed -i '1 s/^\(.\)/$(TARGETNAME)\/\1/' $(addprefix $(TARGETNAME)/, .$*.dep) && \
-	rm -f $(addprefix $(TARGETNAME)/,.$*.dep.tmp)
-	$(CC) $(CFLAGS) -c -o $@ $<
-
-clean:
-	@rm -f $(TARGETNAME)/*.o $(TARGETNAME)/.*.dep $(TARGETNAME)/.*.dep.tmp $(BIN)
-
-$(TARGETNAME):
-	@mkdir -p $(TARGETNAME)
-
--include $(patsubst %.c, $(TARGETNAME)/.%.dep, $(SRCS))
-
-install:
-	mkdir -p $(DESTDIR)/$(INCLUDEDIR)
-	cp $(LIBNAME) $(DESTDIR)/$(LIBDIR)
-	cp $(HEADERNAME) $(DESTDIR)/$(INCLUDEDIR)
-	cp $(PCNAME) $(DESTDIR)/$(PKGCONFIGDIR)
-uninstall:
-	rm -f $(DESTDIR)/$(LIBDIR)/$(LIBNAME)
-	rm -f $(DESTDIR)/$(INCLUDEDIR)/$(HEADERNAME)
-	rm -f $(DESTDIR)/$(PKGCONFIGDIR)/$(PCNAME)
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..416268e
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,49 @@
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = slirp.pc
+
+lib_LTLIBRARIES = libslirp.la
+
+libslirpinclude_HEADERS = net_slirp.h
+libslirpincludedir = $(includedir)/libslirp
+
+NULL=
+
+libslirp_la_SOURCES=		\
+	bootp.c			\
+	bootp.h			\
+	cksum.h			\
+	ctl.h			\
+	debug.h			\
+	icmp_var.h		\
+	if.h			\
+	ip.h			\
+	ip_icmp.h		\
+	mbuf.h			\
+	misc.h			\
+	sbuf.h			\
+	slirp_common.h		\
+	slirp_config.h		\
+	socket.c		\
+	socket.h		\
+	tcp.h			\
+	tcp_timer.h		\
+	tcp_var.h		\
+	tcpip.h			\
+	tftp.h			\
+	udp.h			\
+	cksum.c			\
+	debug.c			\
+	if.c			\
+	ip_icmp.c		\
+	ip_input.c		\
+	ip_output.c		\
+	mbuf.c			\
+	misc.c			\
+	net_slirp.c		\
+	sbuf.c			\
+	tcp_input.c		\
+	tcp_output.c		\
+	tcp_subr.c		\
+	tcp_timer.c		\
+	udp.c			\
+	$(NULL)
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..9f9b0c5
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,170 @@
+#! /bin/sh
+
+srcdir=`dirname $0`
+test -z "$srcdir" && srcdir=.
+
+ORIGDIR=`pwd`
+cd $srcdir
+
+# FIXME: can replace this entire script with
+# the following line if we can require autoconf 2.60:
+# autoreconf -v --force --install || exit 1
+
+PACKAGE=libslirp
+
+ACLOCAL_FLAGS=""
+LIBTOOLIZE=${LIBTOOLIZE-libtoolize}
+LIBTOOLIZE_FLAGS="--copy --force"
+AUTOHEADER=${AUTOHEADER-autoheader}
+AUTOMAKE_FLAGS="--add-missing --gnu"
+AUTOCONF=${AUTOCONF-autoconf}
+
+# automake 1.8 requires autoconf 2.58
+# automake 1.7 requires autoconf 2.54
+automake_min_vers=1.7
+aclocal_min_vers=$automake_min_vers
+autoconf_min_vers=2.54
+libtoolize_min_vers=1.4
+
+# The awk-based string->number conversion we use needs a C locale to work
+# as expected. Setting LC_ALL overrides whether the user set LC_ALL,
+# LC_NUMERIC, or LANG.
+LC_ALL=C
+
+ARGV0=$0
+
+# Allow invocation from a separate build directory; in that case, we change
+# to the source directory to run the auto*, then change back before running configure
+srcdir=`dirname $ARGV0`
+test -z "$srcdir" && srcdir=.
+
+ORIGDIR=`pwd`
+
+# Not all echo versions allow -n, so we check what is possible. This test is
+# based on the one in autoconf.
+case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
+  *c*,-n*) ECHO_N= ;;
+  *c*,*  ) ECHO_N=-n ;;
+  *)       ECHO_N= ;;
+esac
+
+
+# some terminal codes ...
+boldface="`tput bold 2>/dev/null || true`"
+normal="`tput sgr0 2>/dev/null || true`"
+printbold() {
+    echo $ECHO_N "$boldface"
+    echo "$@"
+    echo $ECHO_N "$normal"
+}
+printerr() {
+    echo "$@" >&2
+}
+
+
+# Usage:
+#     compare_versions MIN_VERSION ACTUAL_VERSION
+# returns true if ACTUAL_VERSION >= MIN_VERSION
+compare_versions() {
+    ch_min_version=$1
+    ch_actual_version=$2
+    ch_status=0
+    IFS="${IFS=         }"; ch_save_IFS="$IFS"; IFS="."
+    set $ch_actual_version
+    for ch_min in $ch_min_version; do
+        ch_cur=`echo $1 | sed 's/[^0-9].*$//'`; shift # remove letter suffixes
+        if [ -z "$ch_min" ]; then break; fi
+        if [ -z "$ch_cur" ]; then ch_status=1; break; fi
+        if [ $ch_cur -gt $ch_min ]; then break; fi
+        if [ $ch_cur -lt $ch_min ]; then ch_status=1; break; fi
+    done
+    IFS="$ch_save_IFS"
+    return $ch_status
+}
+
+# Usage:
+#     version_check PACKAGE VARIABLE CHECKPROGS MIN_VERSION SOURCE
+# checks to see if the package is available
+version_check() {
+    vc_package=$1
+    vc_variable=$2
+    vc_checkprogs=$3
+    vc_min_version=$4
+    vc_source=$5
+    vc_status=1
+
+    vc_checkprog=`eval echo "\\$$vc_variable"`
+    if [ -n "$vc_checkprog" ]; then
+	printbold "using $vc_checkprog for $vc_package"
+	return 0
+    fi
+
+    printbold "checking for $vc_package >= $vc_min_version..."
+    for vc_checkprog in $vc_checkprogs; do
+	echo $ECHO_N "  testing $vc_checkprog... "
+	if $vc_checkprog --version < /dev/null > /dev/null 2>&1; then
+	    vc_actual_version=`$vc_checkprog --version | head -n 1 | \
+                               sed 's/^.*[ 	]\([0-9.]*[a-z]*\).*$/\1/'`
+	    if compare_versions $vc_min_version $vc_actual_version; then
+		echo "found $vc_actual_version"
+		# set variable
+		eval "$vc_variable=$vc_checkprog"
+		vc_status=0
+		break
+	    else
+		echo "too old (found version $vc_actual_version)"
+	    fi
+	else
+	    echo "not found."
+	fi
+    done
+    if [ "$vc_status" != 0 ]; then
+	printerr "***Error***: You must have $vc_package >= $vc_min_version installed"
+	printerr "  to build $PROJECT.  Download the appropriate package for"
+	printerr "  from your distribution or get the source tarball at"
+        printerr "    $vc_source"
+	printerr
+    fi
+    return $vc_status
+}
+
+version_check autoconf AUTOCONF $AUTOCONF $autoconf_min_vers \
+    "http://ftp.gnu.org/pub/gnu/autoconf/autoconf-${autoconf_min_vers}.tar.gz" || DIE=1
+version_check automake AUTOMAKE "$AUTOMAKE automake automake-1.10 automake-1.9 automake-1.8 automake-1.7" $automake_min_vers \
+    "http://ftp.gnu.org/pub/gnu/automake/automake-${automake_min_vers}.tar.gz" || DIE=1
+ACLOCAL=`echo $AUTOMAKE | sed s/automake/aclocal/`
+version_check libtool LIBTOOLIZE "$LIBTOOLIZE glibtoolize libtoolize" $libtoolize_min_vers \
+    "http://ftp.gnu.org/pub/gnu/libtool/libtool-${libtool_min_vers}.tar.gz" || DIE=1
+
+if test -n "$DIE"; then
+  exit 1
+fi
+
+
+if test -z "$*"; then
+  echo "$ARGV0:	Note: \`./configure' will be run with no arguments."
+  echo "		If you wish to pass any to it, please specify them on the"
+  echo "		\`$0' command line."
+  echo
+fi
+
+do_cmd() {
+    echo "$ARGV0: running \`$@'"
+    $@
+}
+
+# Run for top level directory
+
+printbold "Setting up $PACKAGE toplevel"
+cd $srcdir
+do_cmd $LIBTOOLIZE $LIBTOOLIZE_FLAGS
+do_cmd $ACLOCAL $ACLOCAL_FLAGS
+do_cmd $AUTOHEADER
+do_cmd $AUTOMAKE $AUTOMAKE_FLAGS
+do_cmd $AUTOCONF
+
+cd $ORIGDIR || exit $?
+rm -f config.cache
+
+do_cmd $srcdir/configure --enable-maintainer-mode ${1+"$@"} || exit 1
+
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..e3f33e7
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,117 @@
+AC_PREREQ([2.57])
+
+AC_INIT([libslirp],
+	0.0.1,
+	[],
+	libslirp)
+
+AM_INIT_AUTOMAKE([foreign dist-bzip2])
+AM_MAINTAINER_MODE
+AM_CONFIG_HEADER(config.h)
+
+# Check for progs
+AC_PROG_CC
+AC_PROG_LIBTOOL
+dnl If the first PKG_CHECK_MODULES appears inside a conditional, pkg-config
+dnl must first be located explicitly.
+PKG_PROG_PKG_CONFIG
+
+dnl ===========================================================================
+dnl check compiler flags
+
+AC_DEFUN([SLIRP_CC_TRY_FLAG], [
+  AC_MSG_CHECKING([whether $CC supports $1])
+
+  slirp_save_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS $1"
+
+  AC_COMPILE_IFELSE([ ], [slirp_cc_flag=yes], [slirp_cc_flag=no])
+  CFLAGS="$slirp_save_CFLAGS"
+
+  if test "x$slirp_cc_flag" = "xyes"; then
+    ifelse([$2], , :, [$2])
+  else
+    ifelse([$3], , :, [$3])
+  fi
+  AC_MSG_RESULT([$slirp_cc_flag])
+])
+
+dnl Use lots of warning flags with with gcc and compatible compilers
+
+dnl Note: if you change the following variable, the cache is automatically
+dnl skipped and all flags rechecked.  So there's no need to do anything
+dnl else.  If for any reason you need to force a recheck, just change
+dnl MAYBE_WARN in an ignorable way (like adding whitespace)
+
+dnl MAYBE_WARN="-Wall -Wno-sign-compare -Werror -Wno-deprecated-declarations"
+
+MAYBE_WARN="-Wall -Wno-sign-compare -Werror -Wno-deprecated-declarations"
+
+# invalidate cached value if MAYBE_WARN has changed
+if test "x$slirp_cv_warn_maybe" != "x$MAYBE_WARN"; then
+	unset slirp_cv_warn_cflags
+fi
+AC_CACHE_CHECK([for supported warning flags], slirp_cv_warn_cflags, [
+	echo
+	WARN_CFLAGS=""
+
+	# Some warning options are not supported by all versions of
+	# gcc, so test all desired options against the current
+	# compiler.
+	#
+	# Note that there are some order dependencies
+	# here. Specifically, an option that disables a warning will
+	# have no net effect if a later option then enables that
+	# warnings, (perhaps implicitly). So we put some grouped
+	# options (-Wall and -Wextra) up front and the -Wno options
+	# last.
+
+	for W in $MAYBE_WARN; do
+		SLIRP_CC_TRY_FLAG([$W], [WARN_CFLAGS="$WARN_CFLAGS $W"])
+	done
+
+	slirp_cv_warn_cflags=$WARN_CFLAGS
+	slirp_cv_warn_maybe=$MAYBE_WARN
+
+	AC_MSG_CHECKING([which warning flags were supported])])
+WARN_CFLAGS="$slirp_cv_warn_cflags"
+SLIRP_CFLAGS="$SLIRP_CFLAGS $WARN_CFLAGS"
+
+# We only wish to enable attribute(warn_unused_result) if we can prevent
+# gcc from generating thousands of warnings about the misapplication of the
+# attribute to void functions and variables.
+AC_MSG_CHECKING([how to enable unused result warnings])
+warn_unused_result=""
+if echo $WARN_CFLAGS | grep -e '-Wno-attributes' >/dev/null; then
+    AC_TRY_COMPILE([__attribute__((__warn_unused_result__))
+	int f (int i) { return i; }], [],
+	[warn_unused_result="__attribute__((__warn_unused_result__))"])
+fi
+AC_DEFINE_UNQUOTED([WARN_UNUSED_RESULT], [$warn_unused_result],
+	  [Define to the value your compiler uses to support the warn-unused-result attribute])
+AC_MSG_RESULT([$warn_unused_result])
+
+AC_SUBST(WARN_CFLAGS)
+AC_SUBST(CFLAGS_CFLAGS)
+
+dnl =========================================================================
+dnl -fvisibility stuff
+
+have_gcc4=no
+AC_MSG_CHECKING(for -fvisibility)
+AC_COMPILE_IFELSE([
+#if defined(__GNUC__) && (__GNUC__ >= 4)
+#else
+error Need GCC 4.0 for visibility
+#endif
+int main () { return 0; }
+], have_gcc4=yes)
+
+if test "x$have_gcc4" = "xyes"; then
+   VISIBILITY_HIDDEN_CFLAGS="-fvisibility=hidden"
+fi
+AC_MSG_RESULT($have_gcc4)
+AC_SUBST(VISIBILITY_HIDDEN_CFLAGS)
+
+AC_OUTPUT([Makefile
+	   slirp.pc])
diff --git a/slirp.pc b/slirp.pc
deleted file mode 100644
index d463103..0000000
--- a/slirp.pc
+++ /dev/null
@@ -1,11 +0,0 @@
-prefix=/usr/local
-exec_prefix=${prefix}
-libdir=/usr/lib64
-includedir=/usr/include
-
-Name: slirp
-Description: user network stack
-Version: 0.1.0
-Requires: 
-Libs: -L${libdir} -lslirp  
-Cflags: -I${includedir}/libslirp
diff --git a/slirp.pc.in b/slirp.pc.in
new file mode 100644
index 0000000..a7983c3
--- /dev/null
+++ b/slirp.pc.in
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: slirp
+Description: user network stack
+Version: @PACKAGE_VERSION@
+Requires:
+Cflags: -I${includedir}/libslirp
+Libs: -L${libdir} -lslirp
diff --git a/slirp_common.h b/slirp_common.h
index 97e9852..65e859f 100644
--- a/slirp_common.h
+++ b/slirp_common.h
@@ -13,6 +13,7 @@
 #define STAT(expr) do { } while(0)
 #endif
 
+#include "config.h"
 #include "slirp_config.h"
 
 #ifdef _WIN32
diff --git a/slirp_config.h b/slirp_config.h
index dbc8dfd..afb9ff4 100644
--- a/slirp_config.h
+++ b/slirp_config.h
@@ -54,12 +54,6 @@
 /* Ignore this */
 #undef DUMMY_PPP
 
-/* Define if you have unistd.h */
-#define HAVE_UNISTD_H
-
-/* Define if you have stdlib.h */
-#define HAVE_STDLIB_H
-
 /* Define if you have sys/ioctl.h */
 #undef HAVE_SYS_IOCTL_H
 #ifndef _WIN32
@@ -112,9 +106,6 @@
 #define HAVE_SYS_SELECT_H
 #endif
 
-/* Define if you have strings.h */
-#define HAVE_STRING_H
-
 /* Define if you have arpa/inet.h */
 #undef HAVE_ARPA_INET_H
 #ifndef _WIN32


More information about the Spice-commits mailing list