From: "Daniel P. Berrange" <berrange(a)redhat.com>
Instead of hardcoding the choice of driver, add a --with-driver=XXX
option accepting 'redhat' as the only choice for now. If the files
/etc/fedora-release or /etc/redhat-release are present, the 'redhat'
driver will be activated automatically. Otherwise configure will
exit with an error. The use of 'redhat' can be forced by specifiying
--with-driver=redhat, causing the /etc checks to be skipped
The existing --with-init-script=XXX option is now removed
The main library and test makefiles are re-organized so that
future addition of new drivers minimises the diff
---
configure.ac | 39 ++++++++++++++++++++++-----------------
src/Makefile.am | 13 ++++++++++---
tests/Makefile.am | 26 +++++++++++++++++++-------
3 files changed, 51 insertions(+), 27 deletions(-)
diff --git a/configure.ac b/configure.ac
index 58df429..f2a9869 100644
--- a/configure.ac
+++ b/configure.ac
@@ -15,10 +15,6 @@ gl_EARLY
AC_PROG_LIBTOOL
-dnl The backend driver. Right now hardcoded to redhat, but
-dnl eventually needs to be configurable at buildtime
-AM_CONDITIONAL([NETCF_DRIVER_REDHAT], [true])
-
dnl Compiler flags to be used everywhere
AC_SUBST([NETCF_CFLAGS], ['--std=gnu99 -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fasynchronous-unwind-tables'])
@@ -60,25 +56,34 @@ fi
dnl
dnl init script flavor
dnl
-AC_MSG_CHECKING([for init script flavor])
-AC_ARG_WITH([init-script],
- [AC_HELP_STRING([--with-init-script=@<:@redhat|auto|none@:>@],
- [Style of init script to install @<:@default=auto@:>@])])
-if test "x$with_init_script" = "x" || test
"x$with_init_script" = "xauto"; then
- if test "$prefix" = "$HOME" || test "$cross_compiling"
= yes || test ! -f /etc/redhat-release; then
- with_init_script=none
- else
- with_init_script=redhat
- fi
+AC_ARG_WITH([driver],
+ [AS_HELP_STRING([--with-driver],
+ [Network driver name])],
+ [],[with_driver=check])
+
+AC_MSG_CHECKING([Network driver name])
+if test "x$with_driver" = "xcheck" && test -f
/etc/redhat-release ; then
+ with_driver=redhat
+fi
+if test "x$with_driver" = "xcheck" && test -f
/etc/fedora-release ; then
+ with_driver=redhat
fi
-if test "x$with_init_script" = "xredhat"; then
+if test "x$with_driver" = "xcheck" ; then
+ AC_MSG_ERROR([Cannot detect network driver, use --with-driver=NAME to select
implementation])
+fi
+AC_MSG_RESULT([$with_driver])
+NETCF_DRIVER=$with_driver
+AC_SUBST([NETCF_DRIVER])
+AC_DEFINE_UNQUOTED([NETCF_DRIVER], $NETCF_DRIVER, [The network driver])
+AM_CONDITIONAL([NETCF_DRIVER_REDHAT], test "x$with_driver" =
"xredhat")
+
+if test "x$with_driver" = "xredhat"; then
AC_DEFINE_UNQUOTED([NETCF_TRANSACTION],
["$sysconfdir/rc.d/init.d/netcf-transaction"],
[Location of the netcf-transaction shell script])
fi
AM_CONDITIONAL([NETCF_INIT_SCRIPT_RED_HAT],
- [test x$with_init_script = xredhat])
-AC_MSG_RESULT([$with_init_script])
+ [test x$with_driver = xredhat])
AC_OUTPUT(Makefile \
gnulib/lib/Makefile \
diff --git a/src/Makefile.am b/src/Makefile.am
index c652fad..9d4869d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -13,13 +13,20 @@ bin_PROGRAMS = ncftool
noinst_PROGRAMS = ncftransform
+DRIVER_SOURCES_LINUX = dutil.h dutil.c \
+ dutil_linux.h dutil_linux.c
+DRIVER_SOURCES_REDHAT = drv_redhat.c
+
EXTRA_DIST = netcf_public.syms \
netcf_private.syms \
- netcf-transaction.init.sh
+ netcf-transaction.init.sh \
+ $(DRIVER_SOURCES_LINUX) \
+ $(DRIVER_SOURCES_REDHAT)
if NETCF_DRIVER_REDHAT
-DRIVER_SOURCES = drv_redhat.c dutil.h dutil.c \
- dutil_linux.h dutil_linux.c
+DRIVER_SOURCES = \
+ $(DRIVER_SOURCES_LINUX) \
+ $(DRIVER_SOURCES_REDHAT)
endif
BUILT_SOURCES = datadir.h netcf.syms
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 701aba0..3ed4f43 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -14,20 +14,32 @@ TESTS_ENVIRONMENT = \
abs_top_builddir='$(abs_top_builddir)' \
abs_top_srcdir='$(abs_top_srcdir)'
-TESTS=test-redhat
-
INCLUDES = -I$(top_srcdir)/src
-# FIXME: Needs to be conditionalized
-check_PROGRAMS=test-redhat
+TESTS=
+check_PROGRAMS=
+
+DRIVER_SOURCES_SHARED = cutest.c cutest.h tutil.c tutil.h
+DRIVER_SOURCES_REDHAT = test-redhat.c
+EXTRA_DIST += \
+ $(DRIVER_SOURCES_SHARED) \
+ $(DRIVER_SOURCES_REDHAT)
-test_redhat_SOURCES = test-redhat.c cutest.c cutest.h tutil.c tutil.h
+if NETCF_DRIVER_REDHAT
+TESTS += test-redhat
+check_PROGRAMS += test-redhat
+
+test_redhat_SOURCES = $(DRIVER_SOURCES_REDHAT) $(DRIVER_SOURCES_SHARED)
test_redhat_LDADD = $(top_builddir)/src/libnetcf.la $(GNULIB)
+endif
+
-# Clean up files generated by test-redhat
+# Clean up files generated by test programs
distclean-local:
- @chmod -R u+w $(top_builddir)/build/test_redhat
+if NETCF_DRIVER_REDHAT
+ @chmod -R u+w $(top_builddir)/build/test_redhat || :
@rm -rf $(top_builddir)/build/test_redhat
+endif
xmllint:
@(for f in interface/*.xml; do \
--
1.7.6.2