[netcf-devel] [PATCH 2/5] Modified project build for Windows

Adam Stokes astokes at fedoraproject.org
Fri Sep 17 16:28:57 UTC 2010


---
 autogen.sh      |    1 -
 bootstrap       |   53 ++++++++++++++++++++++++++++++++---------------------
 configure.ac    |   19 +++++++++++++++++--
 src/Makefile.am |   15 ++++++++++-----
 4 files changed, 59 insertions(+), 29 deletions(-)

diff --git a/autogen.sh b/autogen.sh
index 425c7b1..b0197c3 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -84,7 +84,6 @@ fi
 
 mkdir -p $BUILD_AUX
 
-touch ChangeLog
 $LIBTOOLIZE --copy --force
 ./bootstrap ${GNULIB_SRCDIR:+--gnulib-srcdir="$GNULIB_SRCDIR"}
 aclocal -I gnulib/m4
diff --git a/bootstrap b/bootstrap
index f64713d..84d81cb 100755
--- a/bootstrap
+++ b/bootstrap
@@ -33,40 +33,52 @@ do
   esac
 done
 
-# Get gnulib files.
+cleanup_gnulib() {
+  st=$?
+  rm -fr .gnulib
+  exit $st
+}
 
 case ${GNULIB_SRCDIR--} in
 -)
-  echo "$0: getting gnulib files..."
-  git submodule init || exit $?
-  git submodule update || exit $?
-  GNULIB_SRCDIR=.gnulib
-  ;;
-*)
-  # Redirect the gnulib submodule to the directory on the command line
-  # if possible.
-  if test -d "$GNULIB_SRCDIR"/.git && \
-	git config --file .gitmodules submodule.gnulib.url >/dev/null; then
-    git submodule init
-    GNULIB_SRCDIR=`cd $GNULIB_SRCDIR && pwd`
-    git config --replace-all submodule.gnulib.url $GNULIB_SRCDIR
+  if [ ! -d .gnulib ]; then
     echo "$0: getting gnulib files..."
-    git submodule update || exit $?
-    GNULIB_SRCDIR=.gnulib
-  else
-    echo >&2 "$0: invalid gnulib srcdir: $GNULIB_SRCDIR"
-    exit 1
+
+    trap cleanup_gnulib 1 2 13 15
+
+    git clone --depth 1 git://git.sv.gnu.org/gnulib .gnulib ||
+      cleanup_gnulib
+
+    trap - 1 2 13 15
   fi
-  ;;
+  GNULIB_SRCDIR=.gnulib
 esac
 
 gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
 <$gnulib_tool || exit
 
 modules='
+arpa_inet
 c-ctype
+close
+fcntl
+getdtablesize
+getopt-posix
+inet_ntop
+inet_pton
+netinet_in
+pthread
 read-file
 safe-alloc
+sigaction
+signal
+socket
+string
+sys_ioctl
+sys_socket
+sys_wait
+unistd
+vasprintf
 warnings
 '
 
@@ -76,7 +88,6 @@ warnings
 #   put *.[ch] files in new gnulib/lib/ dir.
 
 $gnulib_tool			\
-  --lgpl=2			\
   --with-tests			\
   --m4-base=gnulib/m4		\
   --source-base=gnulib/lib	\
diff --git a/configure.ac b/configure.ac
index 25ef95f..185d3f8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -17,7 +17,22 @@ AC_PROG_LIBTOOL
 
 dnl The backend driver. Right now hardcoded to initscripts, but
 dnl eventually needs to be configurable at buildtime
-AM_CONDITIONAL([NETCF_DRIVER_INITSCRIPTS], [true])
+dnl temporary, if win32 then dont build this.
+AC_CANONICAL_HOST
+
+dnl WIN32
+AC_MSG_CHECKING([for win32 platform])
+PLATFORM_WIN32="no"
+case "$host" in
+	*-*-mingw*)
+		PLATFORM_WIN32="yes"
+	*)
+	;;
+esac
+AC_MSG_RESULT([$PLATFORM_WIN32])
+AM_CONDITIONAL(PLATFORM_WIN32, test "${PLATFORM_WIN32}" = "yes")
+AC_SUBST([PLATFORM_WIN32])
+AC_SUBST(MINGW_EXTRA_LDFLAGS)
 
 dnl Compiler flags to be used everywhere
 AC_SUBST([NETCF_CFLAGS], ['--std=gnu99 -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fasynchronous-unwind-tables'])
@@ -52,4 +67,4 @@ AC_OUTPUT(Makefile                                          \
           src/Makefile                                      \
           tests/Makefile                                    \
           doc/Makefile                                      \
-          netcf.pc netcf.spec)
+          netcf.pc netcf.spec mingw32-netcf.spec)
diff --git a/src/Makefile.am b/src/Makefile.am
index 9d8a3d7..98025cc 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -5,7 +5,7 @@ GNULIB_CFLAGS= -I $(top_srcdir)/gnulib/lib
 AM_CFLAGS = $(NETCF_CFLAGS) $(GNULIB_CFLAGS) $(WARN_CFLAGS) \
   $(LIBXML_CFLAGS) $(LIBXSLT_CFLAGS) $(LIBAUGEAS_CFLAGS)
 
-include_HEADERS = netcf.h
+include_HEADERS = netcf.h netcf_win.h
 
 lib_LTLIBRARIES = libnetcf.la
 
@@ -16,7 +16,10 @@ noinst_PROGRAMS = ncftransform
 EXTRA_DIST = netcf_public.syms \
 	netcf_private.syms
 
-if NETCF_DRIVER_INITSCRIPTS
+if PLATFORM_WIN32
+WIN32LIB= -liphlpapi -ldnsapi
+DRIVER_SOURCES = netcf_win.h netcf_win.c
+else
 DRIVER_SOURCES = drv_initscripts.c dutil.h dutil.c \
      dutil_linux.h dutil_linux.c
 endif
@@ -29,9 +32,11 @@ libnetcf_la_SOURCES = netcf.h netcf.c internal.h \
      ref.h list.h \
      xslt_ext.c $(DRIVER_SOURCES)
 libnetcf_la_LDFLAGS = -Wl,--version-script=netcf.syms \
-     -version-info $(LIBNETCF_VERSION_INFO)
+     -version-info $(LIBNETCF_VERSION_INFO) -no-undefined
 libnetcf_la_LIBADD = $(NETCF_LIBDEPS) $(GNULIB)
-libnetcf_la_DEPENDENCIES = $(libnetcf_la_LIBADD) netcf.syms
+if PLATFORM_WIN32
+libnetcf_la_LIBADD += $(WIN32LIB)
+endif
 
 ncftool_SOURCES = ncftool.c
 ncftool_LDADD = libnetcf.la $(READLINE_LIBS) $(GNULIB)
@@ -55,6 +60,6 @@ netcf.syms: netcf_public.syms netcf_private.syms
 internal.h: datadir.h
 
 datadir.h: $(top_builddir)/config.status
-	echo '#define DATADIR "$(datadir)"' > datadir.h
+	echo '#define NETCF_DATADIR "$(datadir)"' > datadir.h
 
 DISTCLEANFILES += $(BUILT_SOURCES)
-- 
1.7.2.3



More information about the netcf-devel mailing list