[virt-tools-list] [PATCH 01/11] autoconfiscate

Jim Meyering jim at meyering.net
Fri Jan 29 14:58:42 UTC 2010


From: Jim Meyering <meyering at redhat.com>

* Makefile.am: New file.
* configure.ac: New file.
* Makefile: Remove.
* .gitignore: List ignorable files.
---
 .gitignore   |   19 +++++++++++++++++++
 Makefile     |   40 ----------------------------------------
 Makefile.am  |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
 configure.ac |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 122 insertions(+), 40 deletions(-)
 create mode 100644 .gitignore
 delete mode 100644 Makefile
 create mode 100644 Makefile.am
 create mode 100644 configure.ac

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..392e51c
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,19 @@
+*.[ao]
+*.l[ao]
+*~
+.deps
+.libs
+Makefile
+Makefile.in
+aclocal.m4
+autom4te.cache
+build-aux
+config.cache
+config.h
+config.h.in
+config.log
+config.status
+configure
+libtool
+m4
+stamp-h1
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 5ed3d88..0000000
--- a/Makefile
+++ /dev/null
@@ -1,40 +0,0 @@
-CC = gcc
-LD = ld
-SRCDIR = ./src
-BINDIR = ./bin
-INCDIR = ./inc
-TESTDIR = ./test
-DATADIR = ./data
-LD_LIBRARY_PATH = $(shell echo $LD_LIBRARY_PATH):$(shell pwd)/$(BINDIR)
-DATA_PATH = $(shell pwd)/$(DATADIR)
-
-INCLUDES = -I ./$(SRCDIR) -I ./$(INCDIR) \
-	`xml2-config --cflags --libs`
-FLAGS = -g3 -fPIC
-SONAME = libosinfo.so
-OBJS = osi_hv.o osi_common.o osi_dataread.o osi_device.o osi_filter.o \
-	osi_lib.o osi_os.o
-OUT_OBJS = $(addprefix $(BINDIR)/,$(OBJS))
-TESTS = sample test-filter test-get_devices test-get_os \
-	test-manipulate_devices test-manipulate_hypervisor \
-	test-manipulate_library test-manipulate_os test-set_hypervisor \
-	test-skeleton
-IN_TESTS = $(addsuffix .c, $(addprefix $(SRCDIR)/,$(TESTS)))
-OUT_TESTS = $(addprefix $(BINDIR)/,$(TESTS))
-
-lib: $(BINDIR)/$(SONAME)
-
-$(BINDIR)/$(SONAME) : $(OUT_OBJS)
-	mv $(OBJS) $(BINDIR)/.
-	$(CC) -shared -Wl,-soname,$(SONAME) -o $(BINDIR)/$(SONAME) $(OUT_OBJS)
-
-$(BINDIR)/%.o : $(SRCDIR)/%.c
-	$(CC) $(FLAGS) $(INCLUDES) -c $^
-
-clean:
-	rm -f $(BINDIR)/*
-
-test: lib $(OUT_TESTS)
-
-$(BINDIR)/% : $(TESTDIR)/%.c
-	$(CC) $(FLAGS) $(INCLUDES) -L $(BINDIR) -losinfo $^ -o $@
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..abfa713
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,49 @@
+
+AM_CPPFLAGS = -I$(top_srcdir)/inc $(LIBXML_CFLAGS)
+libosinfo_la_LDFLAGS = $(LIBXML_LIBS)
+
+lib_LTLIBRARIES = libosinfo.la
+
+libosinfo_la_SOURCES =		\
+  inc/libosinfo.h		\
+  inc/osi_api_methods.h		\
+  inc/osi_api_types.h		\
+  src/list.h			\
+  src/osi_common.c		\
+  src/osi_dataread.c		\
+  src/osi_device.c		\
+  src/osi_filter.c		\
+  src/osi_hv.c			\
+  src/osi_internal_types.h	\
+  src/osi_lib.c			\
+  src/osi_os.c
+
+check_PROGRAMS =			\
+  test/sample				\
+  test/test-filter			\
+  test/test-get_devices			\
+  test/test-get_os			\
+  test/test-manipulate_devices		\
+  test/test-manipulate_hypervisor	\
+  test/test-manipulate_library		\
+  test/test-manipulate_os		\
+  test/test-set_hypervisor		\
+  test/test-skeleton
+
+EXTRA_DIST =				\
+  data/libosinfo-dummy-data.xml
+
+LDADD = $(lib_LTLIBRARIES)
+
+generated_test_scripts = $(patsubst %,%.sh,$(check_PROGRAMS))
+TESTS = $(generated_test_scripts)
+
+DISTCLEANFILES = $(generated_test_scripts)
+
+test/%.sh: Makefile
+	printf '#!$(SHELL)\nexec $(*F) $(srcdir)/data\n' > $@-tmp
+	chmod a+x $@-tmp
+	mv $@-tmp $@
+
+TESTS_ENVIRONMENT = \
+  PATH='$(abs_top_builddir)/test$(PATH_SEPARATOR)'"$$PATH"
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..7ca7b6b
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,54 @@
+AC_INIT([libosinfo], [0.1], [virt-tools-list at redhat.com])
+AC_CONFIG_AUX_DIR([build-aux])
+AC_CONFIG_MACRO_DIR([m4])
+AM_INIT_AUTOMAKE([1.11.1 -Wall -Werror foreign color-tests])
+AC_PREREQ([2.61])
+AC_CONFIG_SRCDIR([src/osi_internal_types.h])
+AC_CONFIG_HEADERS([config.h])
+AC_PROG_LIBTOOL
+AC_PROG_CC
+
+LIBXML_REQUIRED=2.6.0
+
+dnl ==========================================================================
+dnl find libxml2 library, borrowed from xmlsec
+dnl ==========================================================================
+LIBXML_CONFIG="xml2-config"
+LIBXML_CFLAGS=""
+LIBXML_LIBS=""
+LIBXML_FOUND="no"
+
+AC_ARG_WITH([libxml], AC_HELP_STRING([--with-libxml=@<:@PFX@:>@],
+            [libxml2 location]))
+if test "x$with_libxml" = xno ; then
+    AC_MSG_CHECKING([for libxml2 libraries >= $LIBXML_REQUIRED])
+    AC_MSG_ERROR([libxml2 >= $LIBXML_REQUIRED is required for libvirt])
+elif test "x$with_libxml" = "x" -a "x$PKG_CONFIG" != "x" ; then
+    PKG_CHECK_MODULES([LIBXML], [libxml-2.0 >= $LIBXML_REQUIRED],
+                      [LIBXML_FOUND=yes], [LIBXML_FOUND=no])
+fi
+if test "$LIBXML_FOUND" = "no" ; then
+    if test "x$with_libxml" != "x" ; then
+	LIBXML_CONFIG=$with_libxml/bin/$LIBXML_CONFIG
+    fi
+    AC_MSG_CHECKING(libxml2 $LIBXML_CONFIG >= $LIBXML_REQUIRED )
+    if ! $LIBXML_CONFIG --version > /dev/null 2>&1 ; then
+	AC_MSG_ERROR([Could not find libxml2 (see config.log for details).])
+    fi
+    vers=`$LIBXML_CONFIG --version | awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
+    minvers=`echo $LIBXML_REQUIRED | awk -F. '{ printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
+    if test "$vers" -ge "$minvers" ; then
+        LIBXML_LIBS="`$LIBXML_CONFIG --libs`"
+        LIBXML_CFLAGS="`$LIBXML_CONFIG --cflags`"
+	LIBXML_FOUND="yes"
+        AC_MSG_RESULT([yes])
+    else
+        AC_MSG_ERROR(
+          [You need at least libxml2 $LIBXML_REQUIRED for this version of libvirt])
+    fi
+fi
+AC_SUBST([LIBXML_CFLAGS])
+AC_SUBST([LIBXML_LIBS])
+
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
-- 
1.7.0.rc0.187.g226c




More information about the virt-tools-list mailing list