[libvirt] [libvirt-php][PATCH 00/10] Couple of PHP fixes

Even though this project is not actively developed, it does not mean we can't make some things better in it. After this patchset, distcheck works, targets are not built everytime, only when necessary, and so on. Michal Privoznik (10): Update .gitignore Update autotools generated files get_next_free_numeric_value: Use correct format for sscanf() tools: Cleanup Makefile configure.ac: Check for libtool src: Clean up Makefile tests: Clean up Makefile.am tests: Update qemu path tests: run under distcheck Install libvirt-php.ini more wisely .gitignore | 28 ++ INSTALL | 8 +- Makefile.am | 4 +- configure.ac | 8 +- install-sh | 14 +- missing | 412 ++++++++++----------------- src/Makefile.am | 64 +++-- src/libvirt-php.c | 2 +- tests/Makefile.am | 37 ++- tests/data/example-qcow2-disk.xml | 2 +- tests/{functions.phpt => functions.phpt.in} | 4 +- tests/php.ini | 2 +- tests/runtests.sh | 4 +- tests/test-domain-create-and-coredump.phpt | 3 +- tests/test-domain-create-and-get-xpath.phpt | 3 +- tests/test-domain-create-get-metadata.phpt | 3 +- tests/test-domain-create.phpt | 3 +- tests/test-domain-define-create-destroy.phpt | 3 +- tests/test-domain-define-undefine.phpt | 3 +- tests/test-domain-snapshot.phpt | 3 +- tools/Makefile.am | 29 +- 21 files changed, 309 insertions(+), 330 deletions(-) rename tests/{functions.phpt => functions.phpt.in} (91%) -- 2.3.6

There are plenty of built files that we don't want git to track. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- .gitignore | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.gitignore b/.gitignore index 691b998..2a6915a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,28 @@ +*.o +.deps +.stamp +/aclocal.m4 +/config.guess +/config.h +/config.h.in +/config.sub +/install-sh +/libtool +/libvirt-php.spec +/libvirt-php-[0-9]*/ +/ltmain.sh +/missing +/INSTALL Makefile +Makefile.in config.log config.status configure docs/*.html +docs/*.html.in autom4te.cache/ src/*.so +stamp-h1 +tools/generate-api-docs libvirt-php-*.tar.gz *~ -- 2.3.6

Some files, that we track in git, are unfortunately generated by autotools. Running autogen.sh with recent tools regenerated those files, so let's push the change into the repo too. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- INSTALL | 8 +- install-sh | 14 +-- missing | 412 ++++++++++++++++++++++--------------------------------------- 3 files changed, 159 insertions(+), 275 deletions(-) diff --git a/INSTALL b/INSTALL index a1e89e1..007e939 100644 --- a/INSTALL +++ b/INSTALL @@ -1,7 +1,7 @@ Installation Instructions ************************* -Copyright (C) 1994-1996, 1999-2002, 2004-2011 Free Software Foundation, +Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, @@ -309,9 +309,10 @@ causes the specified `gcc' to be used as the C compiler (unless it is overridden in the site shell script). Unfortunately, this technique does not work for `CONFIG_SHELL' due to -an Autoconf bug. Until the bug is fixed you can use this workaround: +an Autoconf limitation. Until the limitation is lifted, you can use +this workaround: - CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash + CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash `configure' Invocation ====================== @@ -367,4 +368,3 @@ operates. `configure' also accepts some other, not widely useful, options. Run `configure --help' for more details. - diff --git a/install-sh b/install-sh index a9244eb..377bb86 100755 --- a/install-sh +++ b/install-sh @@ -1,7 +1,7 @@ #!/bin/sh # install - install a program, script, or datafile -scriptversion=2011-01-19.21; # UTC +scriptversion=2011-11-20.07; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the @@ -35,7 +35,7 @@ scriptversion=2011-01-19.21; # UTC # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it +# 'make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written @@ -156,7 +156,7 @@ while test $# -ne 0; do -s) stripcmd=$stripprog;; -t) dst_arg=$2 - # Protect names problematic for `test' and other utilities. + # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac @@ -190,7 +190,7 @@ if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then fi shift # arg dst_arg=$arg - # Protect names problematic for `test' and other utilities. + # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac @@ -202,7 +202,7 @@ if test $# -eq 0; then echo "$0: no input file specified." >&2 exit 1 fi - # It's OK to call `install-sh -d' without argument. + # It's OK to call 'install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi @@ -240,7 +240,7 @@ fi for src do - # Protect names problematic for `test' and other utilities. + # Protect names problematic for 'test' and other utilities. case $src in -* | [=\(\)!]) src=./$src;; esac @@ -354,7 +354,7 @@ do if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or - # other-writeable bit of parent directory when it shouldn't. + # other-writable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. ls_ld_tmpdir=`ls -ld "$tmpdir"` case $ls_ld_tmpdir in diff --git a/missing b/missing index 86a8fc3..cdea514 100755 --- a/missing +++ b/missing @@ -1,11 +1,10 @@ #! /bin/sh -# Common stub for a few missing GNU programs while installing. +# Common wrapper for a few potentially missing GNU programs. -scriptversion=2012-01-06.13; # UTC +scriptversion=2012-06-26.16; # UTC -# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006, -# 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. -# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. +# Copyright (C) 1996-2013 Free Software Foundation, Inc. +# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -26,68 +25,40 @@ scriptversion=2012-01-06.13; # UTC # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then - echo 1>&2 "Try \`$0 --help' for more information" + echo 1>&2 "Try '$0 --help' for more information" exit 1 fi -run=: -sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' -sed_minuso='s/.* -o \([^ ]*\).*/\1/p' - -# In the cases where this matters, `missing' is being run in the -# srcdir already. -if test -f configure.ac; then - configure_ac=configure.ac -else - configure_ac=configure.in -fi - -msg="missing on your system" - case $1 in ---run) - # Try to run requested program, and just exit if it succeeds. - run= - shift - "$@" && exit 0 - # Exit code 63 means version mismatch. This often happens - # when the user try to use an ancient version of a tool on - # a file that requires a minimum version. In this case we - # we should proceed has if the program had been absent, or - # if --run hadn't been passed. - if test $? = 63; then - run=: - msg="probably too old" - fi - ;; + + --is-lightweight) + # Used by our autoconf macros to check whether the available missing + # script is modern enough. + exit 0 + ;; + + --run) + # Back-compat with the calling convention used by older automake. + shift + ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... -Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an -error status if there is no known handling for PROGRAM. +Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due +to PROGRAM being missing or too old. Options: -h, --help display this help and exit -v, --version output version information and exit - --run try to run the given command, and emulate it if it fails Supported PROGRAM values: - aclocal touch file \`aclocal.m4' - autoconf touch file \`configure' - autoheader touch file \`config.h.in' - autom4te touch the output file, or create a stub one - automake touch all \`Makefile.in' files - bison create \`y.tab.[ch]', if possible, from existing .[ch] - flex create \`lex.yy.c', if possible, from existing .c - help2man touch the output file - lex create \`lex.yy.c', if possible, from existing .c - makeinfo touch the output file - yacc create \`y.tab.[ch]', if possible, from existing .[ch] + aclocal autoconf autoheader autom4te automake makeinfo + bison yacc flex lex help2man -Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and -\`g' are ignored when checking the name. +Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and +'g' are ignored when checking the name. Send bug reports to <bug-automake@gnu.org>." exit $? @@ -99,228 +70,141 @@ Send bug reports to <bug-automake@gnu.org>." ;; -*) - echo 1>&2 "$0: Unknown \`$1' option" - echo 1>&2 "Try \`$0 --help' for more information" + echo 1>&2 "$0: unknown '$1' option" + echo 1>&2 "Try '$0 --help' for more information" exit 1 ;; esac -# normalize program name to check for. -program=`echo "$1" | sed ' - s/^gnu-//; t - s/^gnu//; t - s/^g//; t'` +# Run the given program, remember its exit status. +"$@"; st=$? -# Now exit if we have it, but it failed. Also exit now if we -# don't have it and --version was passed (most likely to detect -# the program). This is about non-GNU programs, so use $1 not -# $program. -case $1 in - lex*|yacc*) - # Not GNU programs, they don't have --version. +# If it succeeded, we are done. +test $st -eq 0 && exit 0 + +# Also exit now if we it failed (or wasn't found), and '--version' was +# passed; such an option is passed most likely to detect whether the +# program is present and works. +case $2 in --version|--help) exit $st;; esac + +# Exit code 63 means version mismatch. This often happens when the user +# tries to use an ancient version of a tool on a file that requires a +# minimum version. +if test $st -eq 63; then + msg="probably too old" +elif test $st -eq 127; then + # Program was missing. + msg="missing on your system" +else + # Program was found and executed, but failed. Give up. + exit $st +fi + +perl_URL=http://www.perl.org/ +flex_URL=http://flex.sourceforge.net/ +gnu_software_URL=http://www.gnu.org/software + +program_details () +{ + case $1 in + aclocal|automake) + echo "The '$1' program is part of the GNU Automake package:" + echo "<$gnu_software_URL/automake>" + echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" + echo "<$gnu_software_URL/autoconf>" + echo "<$gnu_software_URL/m4/>" + echo "<$perl_URL>" + ;; + autoconf|autom4te|autoheader) + echo "The '$1' program is part of the GNU Autoconf package:" + echo "<$gnu_software_URL/autoconf/>" + echo "It also requires GNU m4 and Perl in order to run:" + echo "<$gnu_software_URL/m4/>" + echo "<$perl_URL>" + ;; + esac +} + +give_advice () +{ + # Normalize program name to check for. + normalized_program=`echo "$1" | sed ' + s/^gnu-//; t + s/^gnu//; t + s/^g//; t'` + + printf '%s\n' "'$1' is $msg." + + configure_deps="'configure.ac' or m4 files included by 'configure.ac'" + case $normalized_program in + autoconf*) + echo "You should only need it if you modified 'configure.ac'," + echo "or m4 files included by it." + program_details 'autoconf' + ;; + autoheader*) + echo "You should only need it if you modified 'acconfig.h' or" + echo "$configure_deps." + program_details 'autoheader' + ;; + automake*) + echo "You should only need it if you modified 'Makefile.am' or" + echo "$configure_deps." + program_details 'automake' + ;; + aclocal*) + echo "You should only need it if you modified 'acinclude.m4' or" + echo "$configure_deps." + program_details 'aclocal' + ;; + autom4te*) + echo "You might have modified some maintainer files that require" + echo "the 'automa4te' program to be rebuilt." + program_details 'autom4te' + ;; + bison*|yacc*) + echo "You should only need it if you modified a '.y' file." + echo "You may want to install the GNU Bison package:" + echo "<$gnu_software_URL/bison/>" + ;; + lex*|flex*) + echo "You should only need it if you modified a '.l' file." + echo "You may want to install the Fast Lexical Analyzer package:" + echo "<$flex_URL>" + ;; + help2man*) + echo "You should only need it if you modified a dependency" \ + "of a man page." + echo "You may want to install the GNU Help2man package:" + echo "<$gnu_software_URL/help2man/>" ;; + makeinfo*) + echo "You should only need it if you modified a '.texi' file, or" + echo "any other file indirectly affecting the aspect of the manual." + echo "You might want to install the Texinfo package:" + echo "<$gnu_software_URL/texinfo/>" + echo "The spurious makeinfo call might also be the consequence of" + echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" + echo "want to install GNU make:" + echo "<$gnu_software_URL/make/>" + ;; + *) + echo "You might have modified some files without having the proper" + echo "tools for further handling them. Check the 'README' file, it" + echo "often tells you about the needed prerequisites for installing" + echo "this package. You may also peek at any GNU archive site, in" + echo "case some other package contains this missing '$1' program." + ;; + esac +} - *) - if test -z "$run" && ($1 --version) > /dev/null 2>&1; then - # We have it, but it failed. - exit 1 - elif test "x$2" = "x--version" || test "x$2" = "x--help"; then - # Could not run --version or --help. This is probably someone - # running `$TOOL --version' or `$TOOL --help' to check whether - # $TOOL exists and not knowing $TOOL uses missing. - exit 1 - fi - ;; -esac +give_advice "$1" | sed -e '1s/^/WARNING: /' \ + -e '2,$s/^/ /' >&2 -# If it does not exist, or fails to run (possibly an outdated version), -# try to emulate it. -case $program in - aclocal*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`acinclude.m4' or \`${configure_ac}'. You might want - to install the \`Automake' and \`Perl' packages. Grab them from - any GNU archive site." - touch aclocal.m4 - ;; - - autoconf*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`${configure_ac}'. You might want to install the - \`Autoconf' and \`GNU m4' packages. Grab them from any GNU - archive site." - touch configure - ;; - - autoheader*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`acconfig.h' or \`${configure_ac}'. You might want - to install the \`Autoconf' and \`GNU m4' packages. Grab them - from any GNU archive site." - files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` - test -z "$files" && files="config.h" - touch_files= - for f in $files; do - case $f in - *:*) touch_files="$touch_files "`echo "$f" | - sed -e 's/^[^:]*://' -e 's/:.*//'`;; - *) touch_files="$touch_files $f.in";; - esac - done - touch $touch_files - ;; - - automake*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. - You might want to install the \`Automake' and \`Perl' packages. - Grab them from any GNU archive site." - find . -type f -name Makefile.am -print | - sed 's/\.am$/.in/' | - while read f; do touch "$f"; done - ;; - - autom4te*) - echo 1>&2 "\ -WARNING: \`$1' is needed, but is $msg. - You might have modified some files without having the - proper tools for further handling them. - You can get \`$1' as part of \`Autoconf' from any GNU - archive site." - - file=`echo "$*" | sed -n "$sed_output"` - test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` - if test -f "$file"; then - touch $file - else - test -z "$file" || exec >$file - echo "#! /bin/sh" - echo "# Created by GNU Automake missing as a replacement of" - echo "# $ $@" - echo "exit 0" - chmod +x $file - exit 1 - fi - ;; - - bison*|yacc*) - echo 1>&2 "\ -WARNING: \`$1' $msg. You should only need it if - you modified a \`.y' file. You may need the \`Bison' package - in order for those modifications to take effect. You can get - \`Bison' from any GNU archive site." - rm -f y.tab.c y.tab.h - if test $# -ne 1; then - eval LASTARG=\${$#} - case $LASTARG in - *.y) - SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` - if test -f "$SRCFILE"; then - cp "$SRCFILE" y.tab.c - fi - SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` - if test -f "$SRCFILE"; then - cp "$SRCFILE" y.tab.h - fi - ;; - esac - fi - if test ! -f y.tab.h; then - echo >y.tab.h - fi - if test ! -f y.tab.c; then - echo 'main() { return 0; }' >y.tab.c - fi - ;; - - lex*|flex*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified a \`.l' file. You may need the \`Flex' package - in order for those modifications to take effect. You can get - \`Flex' from any GNU archive site." - rm -f lex.yy.c - if test $# -ne 1; then - eval LASTARG=\${$#} - case $LASTARG in - *.l) - SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` - if test -f "$SRCFILE"; then - cp "$SRCFILE" lex.yy.c - fi - ;; - esac - fi - if test ! -f lex.yy.c; then - echo 'main() { return 0; }' >lex.yy.c - fi - ;; - - help2man*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified a dependency of a manual page. You may need the - \`Help2man' package in order for those modifications to take - effect. You can get \`Help2man' from any GNU archive site." - - file=`echo "$*" | sed -n "$sed_output"` - test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` - if test -f "$file"; then - touch $file - else - test -z "$file" || exec >$file - echo ".ab help2man is required to generate this page" - exit $? - fi - ;; - - makeinfo*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified a \`.texi' or \`.texinfo' file, or any other file - indirectly affecting the aspect of the manual. The spurious - call might also be the consequence of using a buggy \`make' (AIX, - DU, IRIX). You might want to install the \`Texinfo' package or - the \`GNU make' package. Grab either from any GNU archive site." - # The file to touch is that specified with -o ... - file=`echo "$*" | sed -n "$sed_output"` - test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` - if test -z "$file"; then - # ... or it is the one specified with @setfilename ... - infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` - file=`sed -n ' - /^@setfilename/{ - s/.* \([^ ]*\) *$/\1/ - p - q - }' $infile` - # ... or it is derived from the source name (dir/f.texi becomes f.info) - test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info - fi - # If the file does not exist, the user really needs makeinfo; - # let's fail without touching anything. - test -f $file || exit 1 - touch $file - ;; - - *) - echo 1>&2 "\ -WARNING: \`$1' is needed, and is $msg. - You might have modified some files without having the - proper tools for further handling them. Check the \`README' file, - it often tells you about the needed prerequisites for installing - this package. You may also peek at any GNU archive site, in case - some other package would contain this missing \`$1' program." - exit 1 - ;; -esac - -exit 0 +# Propagate the correct exit status (expected to be 127 for a program +# not found, 63 for a program that failed due to version mismatch). +exit $st # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) -- 2.3.6

To parse a string, sscanf() is used. However, with wrong format: libvirt-php.c: In function ‘get_next_free_numeric_value’: libvirt-php.c:2719:6: warning: format ‘%x’ expects argument of type ‘unsigned int *’, but argument 3 has type ‘long int *’ [-Wformat=] sscanf(Z_STRVAL_PP(data), "%x", &num); ^ Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/libvirt-php.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index 0adc4be..c35fa5b 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -2777,7 +2777,7 @@ long get_next_free_numeric_value(virDomainPtr domain, char *xpath) if (zend_hash_get_current_key_ex(arr_hash, &key, &key_len, &index, 0, &pointer) != HASH_KEY_IS_STRING) { long num = -1; - sscanf(Z_STRVAL_PP(data), "%x", &num); + sscanf(Z_STRVAL_PP(data), "%lx", &num); if (num > max_slot) max_slot = num; } -- 2.3.6

Lets use more of libtoolisms to make sure we don't build files everytime, only when needed. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- .gitignore | 1 + tools/Makefile.am | 29 ++++++++++++++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 2a6915a..95c45bb 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ Makefile.in config.log config.status configure +depcomp docs/*.html docs/*.html.in autom4te.cache/ diff --git a/tools/Makefile.am b/tools/Makefile.am index 27254ae..6d3f6bc 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -1,6 +1,25 @@ -EXTRA_DIST = generate-api-docs.c +noinst_PROGRAMS=generate-api-docs -all-am: - $(CC) -Wall -o generate-api-docs generate-api-docs.c - ./generate-api-docs ../src/libvirt-php.c ../docs/api-reference.html.in - ./generate-api-docs --private ../src/libvirt-php.c ../docs/dev-api-reference.html.in +generate_api_docs_SOURCES=generate-api-docs.c + +APIBUILD_STAMP=$(srcdir)/.stamp +EXTRA_DIST = $(APIBUILD_STAMP) + +doc_generated_files = \ + $(top_builddir)/docs/api-reference.html.in \ + $(top_builddir)/docs/dev-api-reference.html.in + $(NULL) + +$(doc_generated_files): $(APIBUILD_STAMP) + +$(APIBUILD_STAMP): $(srcdir)/generate-api-docs + ./generate-api-docs $(top_srcdir)/src/libvirt-php.c ../docs/api-reference.html.in + ./generate-api-docs --private $(top_srcdir)/src/libvirt-php.c ../docs/dev-api-reference.html.in + touch $@ + +CLEANFILES = $(doc_generated_files) + +maintainer-clean-local: + rm -rf $(APIBUILD_STAMP) + +all-am: $(APIBUILD_STAMP) -- 2.3.6

Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- .gitignore | 1 + Makefile.am | 2 ++ configure.ac | 6 ++++++ 3 files changed, 9 insertions(+) diff --git a/.gitignore b/.gitignore index 95c45bb..698e97d 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,7 @@ depcomp docs/*.html docs/*.html.in autom4te.cache/ +m4/ src/*.so stamp-h1 tools/generate-api-docs diff --git a/Makefile.am b/Makefile.am index c4cc7a1..bab66e4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,3 +1,5 @@ SUBDIRS = tools src docs tests +ACLOCAL_AMFLAGS = -I m4 + EXTRA_DIST = libvirt-php.spec.in diff --git a/configure.ac b/configure.ac index 7099f9d..4584385 100644 --- a/configure.ac +++ b/configure.ac @@ -3,6 +3,12 @@ AM_INIT_AUTOMAKE([-Wall -Werror -Wno-portability]) AC_CONFIG_FILES([Makefile tools/Makefile src/Makefile tests/Makefile docs/Makefile]) AM_MAINTAINER_MODE([enable]) +m4_ifndef([LT_INIT], [ + AM_PROG_LIBTOOL +], [ + LT_INIT([shared disable-static]) +]) + dnl Checks for programs. AC_PROG_CC AC_LANG([C]) -- 2.3.6

Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- .gitignore | 3 +++ Makefile.am | 2 +- src/Makefile.am | 33 +++++++++++++++++++-------------- tests/php.ini | 2 +- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 698e97d..121adbd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ +*.la +*.lo *.o .deps +.libs .stamp /aclocal.m4 /config.guess diff --git a/Makefile.am b/Makefile.am index bab66e4..3b33a99 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,4 +2,4 @@ SUBDIRS = tools src docs tests ACLOCAL_AMFLAGS = -I m4 -EXTRA_DIST = libvirt-php.spec.in +EXTRA_DIST = libvirt-php.spec.in winsrc diff --git a/src/Makefile.am b/src/Makefile.am index 3f2de38..867f5df 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -5,18 +5,6 @@ DEFINES=-DHAVE_CONFIG_H WL=@WL@ SHLIB_FLAGS=@SHLIB_FLAGS@ -EXTRA_DIST = libvirt-php.c sockets.c vncfunc.c libvirt-php.h - - -all-am: build - -build: - $(CC) $(CFLAGS) -Wall -fpic -DCOMPILE_DL_LIBVIRT=1 $(PHPINC) -c -o libvirt-php.o libvirt-php.c $(LIBXML_CFLAGS) $(LIBVIRT_CFLAGS) $(DEFINES) - $(CC) $(CFLAGS) -Wall -fpic -DCOMPILE_DL_LIBVIRT=1 -c -o vncfunc.o vncfunc.c $(PHPINC) $(LIBXML_CFLAGS) $(LIBVIRT_CFLAGS) $(DEFINES) - $(CC) $(CFLAGS) -Wall -fpic -DCOMPILE_DL_LIBVIRT=1 -c -o sockets.o sockets.c $(PHPINC) $(LIBXML_CFLAGS) $(LIBVIRT_CFLAGS) $(DEFINES) - $(CC) $(CFLAGS) $(LDFLAGS) -Wall $(SHLIB_FLAGS) -o $(PACKAGE).so vncfunc.o sockets.o libvirt-php.o -ldl -lvirt $(LIBXML_LIBS) $(LIBVIRT_LIBS) $(LIBS) - $(ECHO) "Extension compiled as $(PACKAGE).so" - install-exec-local: $(INSTALL) -m 644 -D $(PACKAGE).so $(DESTDIR)$(PHPEDIR)/$(PACKAGE).so $(INSTALL) -m 755 -d $(DESTDIR)$(PHPCDIR) @@ -34,5 +22,22 @@ uninstall-local: $(RM) -f $(DESTDIR)$(PHPCDIR)/$(PACKAGE).ini $(RM) -f $(DESTDIR)$(PHPEDIR)/$(PACKAGE).so -clean-local: - $(RM) -f *.o +AM_CFLAGS = \ + $(PHPINC) $(LIBXML_CFLAGS) \ + $(LIBVIRT_CFLAGS) $(DEFINES) \ + -I$(top_srcdir)/winsrc + +AM_LDFLAGS = \ + $(SHLIB_LDFLAGS) \ + $(LIBXML_LIBS) \ + $(LIBVIRT_LIBS) + +lib_LTLIBRARIES = libvirt-php.la + +libvirt_php_la_SOURCES = \ + vncfunc.c \ + sockets.c \ + libvirt-php.c libvirt-php.h +libvirt_php_la_CFLAGS = \ + $(AM_CFLAGS) \ + -DCOMPILE_DL_LIBVIRT=1 diff --git a/tests/php.ini b/tests/php.ini index a00a0ee..128286e 100644 --- a/tests/php.ini +++ b/tests/php.ini @@ -1,2 +1,2 @@ -extension_dir=../src/ +extension_dir=../src/.libs/ extension=libvirt-php.so -- 2.3.6

Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- .gitignore | 4 ++++ tests/Makefile.am | 23 +++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 121adbd..1066cf5 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,10 @@ /libvirt-php-[0-9]*/ /ltmain.sh /missing +/tests/*.log +/tests/*.trs +/tests/functions.phpt +/test-driver /INSTALL Makefile Makefile.in diff --git a/tests/Makefile.am b/tests/Makefile.am index 416910a..aeb184e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,2 +1,21 @@ -check: - ./runtests-report.sh +test_scripts = runtests.sh + +TESTS = $(test_scripts) +EXTRA_DIST = $(test_scripts) \ + runtests-report.sh \ + test-connect.phpt \ + test-conn-limit.phpt \ + test-domain-create-and-coredump.phpt \ + test-domain-create-and-get-xpath.phpt \ + test-domain-create-get-metadata.phpt \ + test-domain-create.phpt \ + test-domain-define-create-destroy.phpt \ + test-domain-define-undefine.phpt \ + test-domain-snapshot.phpt \ + test-get-emulator.phpt \ + test-get-models.phpt \ + test-get-models-unsupported-hw.phpt \ + test-install.phpt \ + test-logging.phpt \ + test-version-get.phpt \ + test-version-check.phpt -- 2.3.6

Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- tests/data/example-qcow2-disk.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/data/example-qcow2-disk.xml b/tests/data/example-qcow2-disk.xml index f015965..1e46566 100644 --- a/tests/data/example-qcow2-disk.xml +++ b/tests/data/example-qcow2-disk.xml @@ -18,7 +18,7 @@ <on_reboot>restart</on_reboot> <on_crash>restart</on_crash> <devices> - <emulator>/usr/bin/qemu-kvm</emulator> + <emulator>/usr/bin/qemu-system-x86_64</emulator> <disk type='block' device='cdrom'> <driver name='qemu' type='raw'/> <target dev='hdc' bus='ide'/> -- 2.3.6

Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/Makefile.am | 4 +++- tests/Makefile.am | 14 ++++++++++++++ tests/{functions.phpt => functions.phpt.in} | 4 +++- tests/runtests.sh | 4 +++- tests/test-domain-create-and-coredump.phpt | 3 +-- tests/test-domain-create-and-get-xpath.phpt | 3 +-- tests/test-domain-create-get-metadata.phpt | 3 +-- tests/test-domain-create.phpt | 3 +-- tests/test-domain-define-create-destroy.phpt | 3 +-- tests/test-domain-define-undefine.phpt | 3 +-- tests/test-domain-snapshot.phpt | 3 +-- 11 files changed, 30 insertions(+), 17 deletions(-) rename tests/{functions.phpt => functions.phpt.in} (91%) diff --git a/src/Makefile.am b/src/Makefile.am index 867f5df..a601ebe 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -6,7 +6,9 @@ WL=@WL@ SHLIB_FLAGS=@SHLIB_FLAGS@ install-exec-local: - $(INSTALL) -m 644 -D $(PACKAGE).so $(DESTDIR)$(PHPEDIR)/$(PACKAGE).so + $(MKDIR_P) $(DESTDIR)$(PHPEDIR) + $(MKDIR_P) $(DESTDIR)$(PHPCDIR) + $(INSTALL) -m 644 -D .libs/$(PACKAGE).so $(DESTDIR)$(PHPEDIR)/$(PACKAGE).so $(INSTALL) -m 755 -d $(DESTDIR)$(PHPCDIR) $(ECHO) "extension=$(PACKAGE).so" > $(DESTDIR)$(PHPCDIR)/libvirt-php.ini $(ECHO) >> $(DESTDIR)$(PHPCDIR)/libvirt-php.ini diff --git a/tests/Makefile.am b/tests/Makefile.am index aeb184e..3531369 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -3,6 +3,9 @@ test_scripts = runtests.sh TESTS = $(test_scripts) EXTRA_DIST = $(test_scripts) \ runtests-report.sh \ + data \ + functions.phpt.in \ + php.ini \ test-connect.phpt \ test-conn-limit.phpt \ test-domain-create-and-coredump.phpt \ @@ -19,3 +22,14 @@ EXTRA_DIST = $(test_scripts) \ test-logging.phpt \ test-version-get.phpt \ test-version-check.phpt + +runtests.sh: functions.phpt + +functions.phpt: functions.phpt.in + $(AM_V_GEN)sed \ + -e 's|[@]abs_srcdir[@]|$(abs_srcdir)|g' \ + < $< > $@-t && \ + chmod a+x $@-t && \ + mv $@-t $@ + +CLEANFILES = functions.phpt diff --git a/tests/functions.phpt b/tests/functions.phpt.in similarity index 91% rename from tests/functions.phpt rename to tests/functions.phpt.in index 5f95188..47dba2d 100644 --- a/tests/functions.phpt +++ b/tests/functions.phpt.in @@ -29,8 +29,10 @@ exit(1); } + $abs_srcdir = '@abs_srcdir@' ?: getcwd(); + if (!extension_loaded('libvirt')) { - if (!dl('../src/libvirt-php.so')) + if (!dl('libvirt-php.so')) bail('Cannot load libvirt-php extension. Please install libvirt-php first (using `make install`)'); } ?> diff --git a/tests/runtests.sh b/tests/runtests.sh index 24cbcf2..8280be7 100755 --- a/tests/runtests.sh +++ b/tests/runtests.sh @@ -1,5 +1,7 @@ #!/bin/bash +: ${srcdir=.} + nf=$1 tests=( "test-version-check" "test-version-get" "test-get-emulator" "test-logging" "test-connect" "test-conn-limit" @@ -15,7 +17,7 @@ run_test() local nf=$2 ret=0 - php -n -c "./php.ini" $name.phpt + php -n -c "${srcdir}/php.ini" "${srcdir}/${name}.phpt" if [ "x$?" != "x0" ]; then if [ "x$nf" == 'x1' ]; then ret=1 diff --git a/tests/test-domain-create-and-coredump.phpt b/tests/test-domain-create-and-coredump.phpt index abfd520..840bab9 100644 --- a/tests/test-domain-create-and-coredump.phpt +++ b/tests/test-domain-create-and-coredump.phpt @@ -5,8 +5,7 @@ if (!is_resource($conn)) bail('Connection to default hypervisor failed'); - $curdir = getcwd(); - $xml = file_get_contents($curdir.'/data/example-no-disk-and-media.xml'); + $xml = file_get_contents($abs_srcdir.'/data/example-no-disk-and-media.xml'); $res = libvirt_domain_create_xml($conn, $xml); if (!is_resource($res)) diff --git a/tests/test-domain-create-and-get-xpath.phpt b/tests/test-domain-create-and-get-xpath.phpt index d370216..26176f8 100644 --- a/tests/test-domain-create-and-get-xpath.phpt +++ b/tests/test-domain-create-and-get-xpath.phpt @@ -5,8 +5,7 @@ if (!is_resource($conn)) bail('Connection to default hypervisor failed'); - $curdir = getcwd(); - $xml = file_get_contents($curdir.'/data/example-no-disk-and-media.xml'); + $xml = file_get_contents($abs_srcdir.'/data/example-no-disk-and-media.xml'); $res = libvirt_domain_create_xml($conn, $xml); if (!is_resource($res)) diff --git a/tests/test-domain-create-get-metadata.phpt b/tests/test-domain-create-get-metadata.phpt index 8c22c34..72cd0c8 100644 --- a/tests/test-domain-create-get-metadata.phpt +++ b/tests/test-domain-create-get-metadata.phpt @@ -5,8 +5,7 @@ if (!is_resource($conn)) bail('Connection to default hypervisor failed'); - $curdir = getcwd(); - $xml = file_get_contents($curdir.'/data/example-no-disk-and-media.xml'); + $xml = file_get_contents($abs_srcdir.'/data/example-no-disk-and-media.xml'); $res = libvirt_domain_create_xml($conn, $xml); if (!is_resource($res)) diff --git a/tests/test-domain-create.phpt b/tests/test-domain-create.phpt index 1bcccb8..5a69db7 100644 --- a/tests/test-domain-create.phpt +++ b/tests/test-domain-create.phpt @@ -5,8 +5,7 @@ if (!is_resource($conn)) bail('Connection to default hypervisor failed'); - $curdir = getcwd(); - $xml = file_get_contents($curdir.'/data/example-no-disk-and-media.xml'); + $xml = file_get_contents($abs_srcdir.'/data/example-no-disk-and-media.xml'); $res = libvirt_domain_create_xml($conn, $xml); if (!is_resource($res)) diff --git a/tests/test-domain-define-create-destroy.phpt b/tests/test-domain-define-create-destroy.phpt index 0c41c2d..77fafda 100644 --- a/tests/test-domain-define-create-destroy.phpt +++ b/tests/test-domain-define-create-destroy.phpt @@ -5,8 +5,7 @@ if (!is_resource($conn)) bail('Connection to default hypervisor failed'); - $curdir = getcwd(); - $xml = file_get_contents($curdir.'/data/example-no-disk-and-media.xml'); + $xml = file_get_contents($abs_srcdir.'/data/example-no-disk-and-media.xml'); $res = libvirt_domain_define_xml($conn, $xml); if (!is_resource($res)) diff --git a/tests/test-domain-define-undefine.phpt b/tests/test-domain-define-undefine.phpt index 61ff3a7..2627272 100644 --- a/tests/test-domain-define-undefine.phpt +++ b/tests/test-domain-define-undefine.phpt @@ -5,8 +5,7 @@ if (!is_resource($conn)) bail('Connection to default hypervisor failed'); - $curdir = getcwd(); - $xml = file_get_contents($curdir.'/data/example-no-disk-and-media.xml'); + $xml = file_get_contents($abs_srcdir.'/data/example-no-disk-and-media.xml'); $res = libvirt_domain_define_xml($conn, $xml); if (!is_resource($res)) diff --git a/tests/test-domain-snapshot.phpt b/tests/test-domain-snapshot.phpt index c30a458..2c43085 100644 --- a/tests/test-domain-snapshot.phpt +++ b/tests/test-domain-snapshot.phpt @@ -11,8 +11,7 @@ @libvirt_domain_undefine($res); } - $curdir = getcwd(); - $xml = file_get_contents($curdir.'/data/example-qcow2-disk.xml'); + $xml = file_get_contents($abs_srcdir.'/data/example-qcow2-disk.xml'); /* This is applicable only for QEMU/KVM so check whether we're on QEMU/KVM */ $e = @libvirt_connect_get_emulator($conn); -- 2.3.6

Instead of creating the file directly under the installation directory, lets just create it locally and copy afterwards. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- configure.ac | 2 +- src/Makefile.am | 33 ++++++++++++++++++--------------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/configure.ac b/configure.ac index 4584385..9e9fee0 100644 --- a/configure.ac +++ b/configure.ac @@ -148,5 +148,5 @@ AC_SUBST([SHLIB_FLAGS]) AC_SUBST([PHPIZE]) AC_SUBST([PHPCONFIG]) AC_CONFIG_HEADERS([config.h]) -AC_CONFIG_FILES([$PACKAGE.spec]) +AC_CONFIG_FILES([libvirt-php.spec]) AC_OUTPUT diff --git a/src/Makefile.am b/src/Makefile.am index a601ebe..cab0456 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -6,23 +6,24 @@ WL=@WL@ SHLIB_FLAGS=@SHLIB_FLAGS@ install-exec-local: - $(MKDIR_P) $(DESTDIR)$(PHPEDIR) - $(MKDIR_P) $(DESTDIR)$(PHPCDIR) - $(INSTALL) -m 644 -D .libs/$(PACKAGE).so $(DESTDIR)$(PHPEDIR)/$(PACKAGE).so - $(INSTALL) -m 755 -d $(DESTDIR)$(PHPCDIR) - $(ECHO) "extension=$(PACKAGE).so" > $(DESTDIR)$(PHPCDIR)/libvirt-php.ini - $(ECHO) >> $(DESTDIR)$(PHPCDIR)/libvirt-php.ini - $(ECHO) "[libvirt]" >> $(DESTDIR)$(PHPCDIR)/libvirt-php.ini - $(ECHO) "; Path to ISO images for VM installations" >> $(DESTDIR)$(PHPCDIR)/libvirt-php.ini - $(ECHO) "libvirt.iso_path=/var/lib/libvirt/images" >> $(DESTDIR)$(PHPCDIR)/libvirt-php.ini - $(ECHO) "; Path where disk images for new VMs should be created" >> $(DESTDIR)$(PHPCDIR)/libvirt-php.ini - $(ECHO) "libvirt.image_path=/var/lib/libvirt/images" >> $(DESTDIR)$(PHPCDIR)/libvirt-php.ini - $(ECHO) "; Limit maximum number of libvirt connections" >> $(DESTDIR)$(PHPCDIR)/libvirt-php.ini - $(ECHO) "libvirt.max_connections=5" >> $(DESTDIR)$(PHPCDIR)/libvirt-php.ini + $(MKDIR_P) $(DESTDIR)$(prefix)$(PHPEDIR) + $(MKDIR_P) $(DESTDIR)$(prefix)$(PHPCDIR) + $(INSTALL) -m 644 -D .libs/$(PACKAGE).so $(DESTDIR)$(prefix)$(PHPEDIR)/$(PACKAGE).so + $(INSTALL) -m 755 -d $(DESTDIR)$(prefix)$(PHPCDIR) + $(ECHO) "extension=$(PACKAGE).so" > libvirt-php.ini + $(ECHO) >> libvirt-php.ini + $(ECHO) "[libvirt]" >> libvirt-php.ini + $(ECHO) "; Path to ISO images for VM installations" >> libvirt-php.ini + $(ECHO) "libvirt.iso_path=/var/lib/libvirt/images" >> libvirt-php.ini + $(ECHO) "; Path where disk images for new VMs should be created" >> libvirt-php.ini + $(ECHO) "libvirt.image_path=/var/lib/libvirt/images" >> libvirt-php.ini + $(ECHO) "; Limit maximum number of libvirt connections" >> libvirt-php.ini + $(ECHO) "libvirt.max_connections=5" >> libvirt-php.ini + $(INSTALL) -m 644 -D libvirt-php.ini $(DESTDIR)$(prefix)$(PHPCDIR)/$(PACKAGE).ini uninstall-local: - $(RM) -f $(DESTDIR)$(PHPCDIR)/$(PACKAGE).ini - $(RM) -f $(DESTDIR)$(PHPEDIR)/$(PACKAGE).so + $(RM) -f $(DESTDIR)$(prefix)$(PHPCDIR)/$(PACKAGE).ini + $(RM) -f $(DESTDIR)$(prefix)$(PHPEDIR)/$(PACKAGE).so AM_CFLAGS = \ $(PHPINC) $(LIBXML_CFLAGS) \ @@ -43,3 +44,5 @@ libvirt_php_la_SOURCES = \ libvirt_php_la_CFLAGS = \ $(AM_CFLAGS) \ -DCOMPILE_DL_LIBVIRT=1 + +CLEANFILES = libvirt-php.ini -- 2.3.6

On 05.05.2015 11:59, Michal Privoznik wrote:
Even though this project is not actively developed, it does not mean we can't make some things better in it. After this patchset, distcheck works, targets are not built everytime, only when necessary, and so on.
Michal Privoznik (10): Update .gitignore Update autotools generated files get_next_free_numeric_value: Use correct format for sscanf() tools: Cleanup Makefile configure.ac: Check for libtool src: Clean up Makefile tests: Clean up Makefile.am tests: Update qemu path tests: run under distcheck Install libvirt-php.ini more wisely
.gitignore | 28 ++ INSTALL | 8 +- Makefile.am | 4 +- configure.ac | 8 +- install-sh | 14 +- missing | 412 ++++++++++----------------- src/Makefile.am | 64 +++-- src/libvirt-php.c | 2 +- tests/Makefile.am | 37 ++- tests/data/example-qcow2-disk.xml | 2 +- tests/{functions.phpt => functions.phpt.in} | 4 +- tests/php.ini | 2 +- tests/runtests.sh | 4 +- tests/test-domain-create-and-coredump.phpt | 3 +- tests/test-domain-create-and-get-xpath.phpt | 3 +- tests/test-domain-create-get-metadata.phpt | 3 +- tests/test-domain-create.phpt | 3 +- tests/test-domain-define-create-destroy.phpt | 3 +- tests/test-domain-define-undefine.phpt | 3 +- tests/test-domain-snapshot.phpt | 3 +- tools/Makefile.am | 29 +- 21 files changed, 309 insertions(+), 330 deletions(-) rename tests/{functions.phpt => functions.phpt.in} (91%)
Ping? No php knowledge is required to review these patches. They are merely Makefile and configure.ac cleanups. Michal

2015-06-10 12:23 GMT+03:00 Michal Privoznik <mprivozn@redhat.com>:
Ping? No php knowledge is required to review these patches. They are merely Makefile and configure.ac cleanups.
Michal
Michal Novotny says that he busy now and you can accept/review my patches.. i think in this case - you can ACK ? =) -- Vasiliy Tolstov, e-mail: v.tolstov@selfip.ru

On 10.06.2015 11:29, Vasiliy Tolstov wrote:
2015-06-10 12:23 GMT+03:00 Michal Privoznik <mprivozn@redhat.com>:
Ping? No php knowledge is required to review these patches. They are merely Makefile and configure.ac cleanups.
Michal
Michal Novotny says that he busy now and you can accept/review my patches.. i think in this case - you can ACK ? =)
I went ahead and pushed this. Hopefully I did not break anything. Michal
participants (2)
-
Michal Privoznik
-
Vasiliy Tolstov