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

Eric Blake eblake at redhat.com
Wed Sep 22 19:59:17 UTC 2010


On 09/17/2010 10:28 AM, Adam Stokes wrote:
> ---
>   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

Why this change?  I think it's spurious.

> 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=$?

$? on entrance to a function is not portable across all shells.

> +  rm -fr .gnulib

Huh?  Why are you deleting the just-imported submodule?  Oh - this 
function is designed only for exit traps.

> +  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

This could be made _much_ faster by using --reference, if you already 
have another gnulib.git clone on a local disk; in fact, that's what 
gnulib's bootstrap script does.  Maybe it makes more sense to work on 
getting netcf to use gnulib's bootstrap instead of rolling our own, in 
which case, we can benefit from upstream maintenance.  And at the same 
time, maybe this patch for cleaning up .gnulib on a failed submodule 
clone should be ported over to gnulib's bootstrap script.

> +
> +    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
>   '

This commit (or at least this hunk) should be reordered to come before 
1/5.  You want every commit to independently compile, but it is quite 
likely that mingw won't compile without these modules in place.

>
> @@ -76,7 +88,6 @@ warnings
>   #   put *.[ch] files in new gnulib/lib/ dir.
>
>   $gnulib_tool			\
> -  --lgpl=2			\

Which modules were problematic for you?  Either netcf cannot use those 
modules, or we have to figure out if those modules can be relaxed 
upstream in gnulib.

>     --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.

Is this "temporary" comment going to end up as a permanent fixture?  If 
so, then reword it; if not, then delete it.

> +AC_CANONICAL_HOST
> +
> +dnl WIN32
> +AC_MSG_CHECKING([for win32 platform])
> +PLATFORM_WIN32="no"
> +case "$host" in
> +	*-*-mingw*)
> +		PLATFORM_WIN32="yes"

Missing ;;.

> +	*)
> +	;;

You don't need a *) branch if it is a no-op.

> +esac
> +AC_MSG_RESULT([$PLATFORM_WIN32])
> +AM_CONDITIONAL(PLATFORM_WIN32, test "${PLATFORM_WIN32}" = "yes")
> +AC_SUBST([PLATFORM_WIN32])
> +AC_SUBST(MINGW_EXTRA_LDFLAGS)

Where are these defined?

>
>   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)

This hunk belongs with 1/5, when you introduced ming32-netcf.spec.in

> 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

Are we guaranteed that these libraries will always exist in a mingw 
build, or do we need to add come configure.ac checks for whether they 
are present.

> +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

Why the rename?  None of the rest of this patch uses this rename.

>
>   DISTCLEANFILES += $(BUILT_SOURCES)

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org


More information about the netcf-devel mailing list