diff --git a/ax_check_qt.m4 b/ax_check_qt.m4 index 91c0072..1a5dafb 100644 --- a/ax_check_qt.m4 +++ b/ax_check_qt.m4 @@ -38,6 +38,7 @@ AC_DEFUN([AX_CXX_QT_TOOL], [ + PKG_PROG_PKG_CONFIG if test -z "$HAVE_$1"; then HAVE_$1=1 AC_MSG_CHECKING([for $2]) @@ -61,7 +62,7 @@ AC_DEFUN([AX_CXX_QT_TOOL], [ fi fi AC_SUBST($1) - AM_CONDITIONAL(HAVE_$1, test $HAVE_$1 -eq 1) + AM_CONDITIONAL(HAVE_$1, test $HAVE_[$1] -eq 1) if test $HAVE_$1 -eq 1; then AC_MSG_RESULT([$$1]) else @@ -79,24 +80,6 @@ AC_DEFUN([AX_CXX_QT_TOOLS], [ AX_CXX_QT_TOOL(LRELEASE, lrelease) ]) -AC_DEFUN([AX_CHECK_VALID_FLAG], [ - AC_MSG_CHECKING([m4_default([$2], [for valid flag in "$1"])]) - save_cppflags="$CPPFLAGS" - newflag="no" - for test_flag in $1; do - CPPFLAGS+=" ${test_flag}" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [ - newflag="$test_flag" - CPPFLAGS="$save_cppflags" - CPPFLAGS+=" ${test_flag}" - break; - ]) - CPPFLAGS="$save_cppflags" - done - AC_SUBST(CPPFLAGS) - AC_MSG_RESULT([$newflag]) -]) - AC_DEFUN([AX_CHECK_QT], [ qt_modules="$2" qt_modules_optional="$3" @@ -148,8 +131,11 @@ AC_DEFUN([AX_CHECK_QT], [ fi ], [HAVE_$1=0]) ]) - AM_CONDITIONAL(HAVE_$1, test $HAVE_$1 -eq 1) - AX_CHECK_VALID_FLAG([-fPIC -fPIE], [position independent code flag]) + AM_CONDITIONAL(HAVE_$1, test $HAVE_[$1] -eq 1) + AX_CHECK_VALID_CXX_FLAG([-fPIC -fPIE], [position independent code flag]) + if test "${MINGW}" != "no"; then + AX_CHECK_VALID_CXX_FLAG([-Wl,-subsystem,windows], [windows console flag]) + fi AC_SUBST(QTDIR) AC_SUBST(QT_PLUGIN_PATH) AC_SUBST(CPPFLAGS) @@ -176,7 +162,7 @@ qrc_%.cxx: %.qrc %.qm: %.ts ${LRELEASE} $< -qm [$][@] -#%.ts: ${LANGUAGE_FILES} +#%.ts: ${LANGUAGE_FILES:%=%} # ${LUPDATE} -no-obsolete \ # -target-language ${@:${LANGUAGE_FILE_BASE}_%.ts=%} \ # -ts [$][@] $< diff --git a/ax_init_standard_project.m4 b/ax_init_standard_project.m4 index 0db6a35..2ad3639 100644 --- a/ax_init_standard_project.m4 +++ b/ax_init_standard_project.m4 @@ -160,9 +160,10 @@ AC_DEFUN([AX_INIT_STANDARD_PROJECT], [ AX_ADD_MAKEFILE_TARGET_DEP([clean-am], [clean-standard-project-targets], [makefile.in]) AX_ADD_MAKEFILE_TARGET_DEP([distclean-am], [distclean-standard-project-targets], [makefile.in]) AX_ADD_MAKEFILE_TARGET_DEP([maintainer-clean-am], [maintainer-clean-standard-project-targets], [makefile.in]) + test -f makefile.in && sed -i '1iEXTRA_DIST = ' makefile.in test -f makefile.in && cat >> makefile.in <> examples/html.in <> html/makefile.in < /dev/null); do if test -f "$f"; then $1_found=${tmp_package} $1_CFLAGS+=" -I${f%/*}" @@ -446,7 +447,7 @@ AC_DEFUN([AX_PKG_REQUIRE], [ tmp_includedir=$(${PKG_CONFIG} --variable=includedir $tmp_package) for x in ${tmp_includedir}; do AC_MSG_NOTICE([search for $3 in $x]) - for f in $(find ${x} -name "$3"); do + for f in $(find ${x} -name "$3" 2> /dev/null); do if test -f "$f"; then $1_found=${tmp_package} $1_CFLAGS+=" -I${f%/*}" @@ -501,7 +502,7 @@ AC_DEFUN([AX_PKG_CHECK], [ ], [ HAVE_$1=0 ]) - AM_CONDITIONAL(HAVE_$1, test $HAVE_$1 -eq 1) + AM_CONDITIONAL(HAVE_$1, test $HAVE_[$1] -eq 1) AC_SUBST(HAVE_$1) AC_SUBST(CPPFLAGS) AC_SUBST(CXXFLAGS) @@ -532,3 +533,95 @@ AC_DEFUN([AX_REQUIRE_HEADER], [ ], []) ], []) ]) + +# Check within a list of CPP-Flags for the first that is usable and +# configure it +# - parameter: +# $1 = white-space separated list of alternative flags +# $2 = module name (optional, if different from id) +AC_DEFUN([AX_CHECK_VALID_CPP_FLAG], [ + AC_MSG_CHECKING([m4_default([$2], [for valid flag in "$1"])]) + save_cppflags="$CPPFLAGS" + newflag="no" + for test_flag in $1; do + CPPFLAGS+=" ${test_flag}" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [ + newflag="$test_flag" + CPPFLAGS="$save_cppflags" + CPPFLAGS+=" ${test_flag}" + break; + ]) + CPPFLAGS="$save_cppflags" + done + AC_SUBST(CPPFLAGS) + AC_MSG_RESULT([$newflag in $CPPFLAGS]) +]) + +# Check within a list of CXX-Flags for the first that is usable and +# configure it +# - parameter: +# $1 = white-space separated list of alternative flags +# $2 = module name (optional, if different from id) +AC_DEFUN([AX_CHECK_VALID_CXX_FLAG], [ + AC_MSG_CHECKING([m4_default([$2], [for valid flag in "$1"])]) + save_cxxflags="$CXXFLAGS" + newflag="no" + for test_flag in $1; do + CXXFLAGS+=" ${test_flag}" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [ + newflag="$test_flag" + CXXFLAGS="$save_cxxflags" + CXXFLAGS+=" ${test_flag}" + break; + ]) + CXXFLAGS="$save_cxxflags" + done + AC_SUBST(CXXFLAGS) + AC_MSG_RESULT([$newflag in $CXXFLAGS]) +]) + +# Check within a list of C-Flags for the first that is usable and +# configure it +# - parameter: +# $1 = white-space separated list of alternative flags +# $2 = module name (optional, if different from id) +AC_DEFUN([AX_CHECK_VALID_C_FLAG], [ + AC_MSG_CHECKING([m4_default([$2], [for valid flag in "$1"])]) + save_cflags="$CFLAGS" + newflag="no" + for test_flag in $1; do + CFLAGS+=" ${test_flag}" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [ + newflag="$test_flag" + CFLAGS="$save_cflags" + CFLAGS+=" ${test_flag}" + break; + ]) + CFLAGS="$save_cflags" + done + AC_SUBST(CFLAGS) + AC_MSG_RESULT([$newflag in $CFLAGS]) +]) + +# Check within a list of LD-Flags for the first that is usable and +# configure it +# - parameter: +# $1 = white-space separated list of alternative flags +# $2 = module name (optional, if different from id) +AC_DEFUN([AX_CHECK_VALID_LD_FLAG], [ + AC_MSG_CHECKING([m4_default([$2], [for valid flag in "$1"])]) + save_ldflags="$LDFLAGS" + newflag="no" + for test_flag in $1; do + LDFLAGS+=" ${test_flag}" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [ + newflag="$test_flag" + LDFLAGS="$save_ldflags" + LDFLAGS+=" ${test_flag}" + break; + ]) + LDFLAGS="$save_ldflags" + done + AC_SUBST(LDFLAGS) + AC_MSG_RESULT([$newflag in $LDFLAGS]) +]) diff --git a/bootstrap.sh b/bootstrap.sh index f17b6ed..e5336c6 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -43,7 +43,7 @@ OPTIONS --configure, -c call ./configure after initialization --build, -b build, also call ./configure && make distcheck - --target, -t target build target , also call ./configure && make target + --target, -t same as -b, but specify target instead of distcheck --overwrite, -o overwrite all basic files (bootstrap.sh, m4-macros) --rebuild, -r force rebuild of generated files, even if modified --rebuild-file, -f rebild specific file (can be added multiple times) @@ -103,8 +103,13 @@ GENERATED FILES * ax_init_standard_project.m4 - auxiliary macro definition file * ax_cxx_compile_stdcxx_11.m4 - auxiliary macro definition file * ax_check_qt.m4 - auxiliary macro definition file + * resolve-debbuilddeps.sh - script to install debian package dependencies + * resolve-rpmbuilddeps.sh - script to install RPM package dependencies + * build-resource-file.sh - build resource.qrc file from a resource directory * mac-create-app-bundle.sh - script to create apple mac os-x app-bundle * AUTHORS - replace your name in AUTHORS before first run + * NEWS - empty file add your project's news + * README - add project description (first line is header, followed by an empty line) * configure.ac - global configuration file template * makefile.am - global makefile template * src/makefile.am - if you enabled AX_USE_CXX @@ -149,6 +154,7 @@ FILES TO EDIT The following files normally require editing: * AUTHORS + * NEWS * README * configure.ac * src/makefile.am @@ -165,19 +171,20 @@ FILE DEPENDENCIES * html/makefile.am depends on AX_BUILD_HTML * doc/doxyfile.in depends on AX_BUILD_EXAMPLES * debian/control.in depends on AX_USE_DOXYGEN, AX_USE_CPPUNIT, - AX_CXX_QT, AX_CXX_CHECK_QT, AX_USE_LIBTOOL + AX_CXX_QT, AX_CHECK_QT, AX_REQUIRE_QT, AX_USE_LIBTOOL * debian/${DEFAULT_PROJECT_NAME}.install depends on AX_USE_LIBTOOL * debian/${DEFAULT_PROJECT_NAME}.dirs depends on AX_USE_LIBTOOL * debian/${DEFAULT_PROJECT_NAME}-dev.install depends on AX_USE_LIBTOOL * debian/${DEFAULT_PROJECT_NAME}-dev.dirs depends on AX_USE_LIBTOOL - * ${DEFAULT_PROJECT_NAME}.spec.in dependson AX_USE_RPM_PACKAGING, - AX_USE_LIBTOOL, AX_CXX_CHECK_QT, AX_CXX_QT, AX_USE_CPPUNIT + * ${DEFAULT_PROJECT_NAME}.spec.in depends on AX_USE_RPM_PACKAGING, + AX_USE_LIBTOOL, AX_CHECK_QT, AX_REQUIRE_QT, AX_CXX_QT, AX_USE_CPPUNIT FILES * AUTHORS: First line is the main author and used in Debian and RPM packaging, so there must be a GPG key that matches to this line. + * NEWS: File to add project news. * README: First line is a short description of your project, then an empty line must follow. All remaining lines are a long description of your project. this information @@ -203,7 +210,7 @@ FILES * Enable C++ examples, i.e. for libraries: AX_BUILD_EXAMPLES * Check for C++11 support: AX_CXX_COMPILE_STDCXX_11 (see ax_cxx_compile_stdcxx_11.m4) * Require a QT module: AX_REQUIRE_QT (see ax_check_qt.m4) - * Optionally use a QT module: AX_CHECK_QT (see ax_check_qt.m4) + * Optionally use a QT module: AX_CHECK_QT (see ax_check_qt.m4) * Require a module: AX_PKG_REQUIRE (see ax_init_standard_project.m4) * Check for an optional module: AX_PKG_CHECK (see ax_init_standard_project.m4) @@ -275,7 +282,8 @@ run() { } testtag() { - egrep -q '^ *'"$1" configure.ac + local IFS="|" + egrep -q '^ *'"($*)" configure.ac } contains() { @@ -380,6 +388,9 @@ copy ${MY_NAME} copy ax_init_standard_project.m4 copy ax_cxx_compile_stdcxx_11.m4 copy ax_check_qt.m4 +copy resolve-debbuilddeps.sh +copy resolve-rpmbuilddeps.sh +copy build-resource-file.sh copy mac-create-app-bundle.sh AUTHOR=$(gpg -K | sed -n 's,uid *,,p' | sort | head -1) if test -z "${AUTHOR}"; then @@ -388,6 +399,14 @@ fi to AUTHORS <.qrc (default: resources.qrc) +## +## Call: +## +## cd src +## ../build-resource-file.sh + +## 1 2 3 4 5 6 7 8 +## 45678901234567890123456789012345678901234567890123456789012345678901234567890 + +RESOURCES=${1:-resources} +TARGET=${RESOURCES}.qrc + +test -d ${RESOURCES} + +echo "" > ${TARGET} +for d in $(find resources -mindepth 1 -type d); do + echo " " >> ${TARGET} + for f in $(find $d -mindepth 1 -maxdepth 1 -type f); do + echo " $f" >> ${TARGET} + done + echo " " >> ${TARGET} +done +echo "" >> ${TARGET} diff --git a/resolve-debbuilddeps.sh b/resolve-debbuilddeps.sh new file mode 100755 index 0000000..9da3c80 --- /dev/null +++ b/resolve-debbuilddeps.sh @@ -0,0 +1,44 @@ +#! /bin/bash -ex + +## @id $Id$ + +## Resolve Debian Build Dependencies +## Installs all the required packages +## Call: ./resolve-debbuilddeps 'name of build schroot' +## e.g. call: ./resolve-debbuilddeps trusty_amd64 + +## 1 2 3 4 5 6 7 8 +## 45678901234567890123456789012345678901234567890123456789012345678901234567890 + +SCHROOTNAME="$1" + +sed 's,@[^@]*@, dummytext,g' debian/control.in > debian/control + +if test -n "${SCHROOTNAME}"; then + DEPS=$(schroot -c "${SCHROOTNAME}" -- dpkg-checkbuilddeps 2>&1 || true) +else + DEPS=$(dpkg-checkbuilddeps 2>&1 || true) +fi +DEPS=$(echo "$DEPS" | sed -n '/Unmet build dependencies/ { s,.*Unmet build dependencies: ,,g; s, ([^)]*),,g; s, *| *,|,g; p}') + +for pa in ${DEPS}; do + success=0 + for p in $(echo "${pa}" | sed 's,|, ,g'); do + if test -n "${SCHROOTNAME}"; then + if schroot -c "${SCHROOTNAME}" -u root -d / -- apt-get -y install ${p}; then + success=1 + break; + fi + else + if sudo apt-get -y install ${p}; then + success=1 + break; + fi + fi + done + if test ${success} -eq 0; then + echo "**** Error: Installation Failed: ${pa}" + fi +done + +echo "**** Success: All Dependencies Resolved" diff --git a/resolve-rpmbuilddeps.sh b/resolve-rpmbuilddeps.sh new file mode 100755 index 0000000..efa546f --- /dev/null +++ b/resolve-rpmbuilddeps.sh @@ -0,0 +1,34 @@ +#! /bin/bash -ex + +## @id $Id$ + +## Resolve RPM Build Dependencies +## Installs all the required packages +## Call: ./resolve-rpmbuilddeps 'name of build schroot' +## e.g. call: ./resolve-rpmbuilddeps opensuse-13.2_x86_64 + +## 1 2 3 4 5 6 7 8 +## 45678901234567890123456789012345678901234567890123456789012345678901234567890 + +SCHROOTNAME="$1" +PACKAGE_NAME=$(sed -n 's/^ *m4_define(x_package_name, \(.*\)).*/\1/p' configure.ac) + +sed 's,@[^@]*@,dummytext,g' ${PACKAGE_NAME}.spec.in > ${PACKAGE_NAME}.spec + +if test -n "${SCHROOTNAME}"; then + FILES=$(LANG= schroot -c ${SCHROOTNAME} -- rpmbuild -bb --define "_topdir ." --define "_sourcedir ." ${PACKAGE_NAME}.spec 2>&1 | sed -n 's, is needed by.*,,p') + if test -n "${FILES}"; then + schroot -c ${SCHROOTNAME} -u root -- yum install -y ${FILES} || \ + schroot -c ${SCHROOTNAME} -u root -- zypper install -y ${FILES} || \ + schroot -c ${SCHROOTNAME} -u root -- dnf install -y ${FILES} + fi +else + FILES=$(LANG= rpmbuild -bb --define "_topdir ." --define "_sourcedir ." ${PACKAGE_NAME}.spec 2>&1 | sed -n 's, is needed by.*,,p') + if test -n "${FILES}"; then + yum install -y ${FILES} || \ + zypper install -y ${FILES} || \ + dnf install -y ${FILES} + fi +fi + +echo "**** Success: All Dependencies Resolved"