From b0ce609eca32ec033b026ebab6d6f578366e20cc Mon Sep 17 00:00:00 2001 From: Cesar Souza Date: Tue, 27 Sep 2016 18:40:37 +0200 Subject: [PATCH] - Updating the linux build scripts to use autogen/autoconf/make - Reorganizing the the build scripts to make their intent more clear --- .gitignore | 66 +++++---- .travis.yml | 9 +- Build.sh | 26 ---- Makefile.am | 104 ++++++++++++++ .../Archiver/{Build.cmd => package-framework.cmd} | 0 .../Archiver/{Samples.cmd => package-samples.cmd} | 0 Setup/NuGet/{Build.cmd => package-nuget.cmd} | 0 Setup/NuGet/{Push.cmd => push-packages.cmd} | 0 Setup/NuGet/{Update.cmd => update-nuget.cmd} | 0 Setup/{CreateRelease.cmd => create-release.cmd} | 8 +- Setup/{PublishNuGet.cmd => publish-nuget.cmd} | 0 Tests.sh | 21 --- accord.pc.in | 10 ++ autogen.sh | 153 +++++++++++++++++++++ Build.cmd => build-all.cmd | 0 configure.ac | 46 +++++++ Tests.cmd => run-tests.cmd | 0 17 files changed, 359 insertions(+), 84 deletions(-) delete mode 100755 Build.sh create mode 100644 Makefile.am rename Setup/Archiver/{Build.cmd => package-framework.cmd} (100%) rename Setup/Archiver/{Samples.cmd => package-samples.cmd} (100%) rename Setup/NuGet/{Build.cmd => package-nuget.cmd} (100%) rename Setup/NuGet/{Push.cmd => push-packages.cmd} (100%) rename Setup/NuGet/{Update.cmd => update-nuget.cmd} (100%) rename Setup/{CreateRelease.cmd => create-release.cmd} (76%) rename Setup/{PublishNuGet.cmd => publish-nuget.cmd} (100%) delete mode 100755 Tests.sh create mode 100644 accord.pc.in create mode 100644 autogen.sh rename Build.cmd => build-all.cmd (100%) create mode 100644 configure.ac rename Tests.cmd => run-tests.cmd (100%) diff --git a/.gitignore b/.gitignore index 525c048bd..22e23daf9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,29 +1,37 @@ -bin -obj - -*.user -*.pidb -*.suo -*.vsp -*.ipch - -/Setup/Accord.Setup.dll -/Setup/Accord.Setup.pdb - -/Sources/Accord.Music -/Sources/TestResults -*.sdf -*.shfbproj_* - -/Release -/Debug - -/Docs -/Unit Tests/Accord.Tests.Math.Cpp/Debug -/Unit Tests/Accord.Tests.Math.Cpp/Release -/Unit Tests/packages - -/Sources/Debug -/Sources/Release - -/Sources/*.opensdf +bin +obj + +*.user +*.pidb +*.suo +*.vsp +*.ipch + +/Setup/Accord.Setup.dll +/Setup/Accord.Setup.pdb + +/Sources/Accord.Music +/Sources/TestResults +*.sdf +*.shfbproj_* + +/Release +/Debug + +/Docs +/Unit Tests/Accord.Tests.Math.Cpp/Debug +/Unit Tests/Accord.Tests.Math.Cpp/Release +/Unit Tests/packages + +/Sources/Debug +/Sources/Release + +/Sources/*.opensdf +/autom4te.cache/ +/Makefile.in +/Makefile +/configure +/config.status +/config.log +*.m4 +/accord.pc diff --git a/.travis.yml b/.travis.yml index a9d8a07f6..6f352cb7b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,9 @@ language: csharp -solution: Sources/Accord.NET.sln install: - nuget restore Sources/Accord.NET.sln script: - - ./Build.sh framework - - ./Build.sh samples - - ./Tests.sh \ No newline at end of file + - ./autogen.sh + - make + - make samples + - make test + - make check \ No newline at end of file diff --git a/Build.sh b/Build.sh deleted file mode 100755 index 58efa70b9..000000000 --- a/Build.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -########### - -echo " " -echo "Accord.NET Framework all projects configurations builder " -echo "=========================================================" -echo " " -echo "This Linux bash script will use Mono's xbuild tool to " -echo "compile the Debug and Release versions of the framework. " -echo " " - - - -if [ $# -eq 0 ] || [ "$1" == "framework" ]; then - echo "" - echo " - Building Mono configuration..." - echo "" - xbuild /p:Configuration=Mono Sources/Accord.NET.sln -fi - -if [ $# -eq 0 ] || [ "$1" == "samples" ]; then - echo "" - echo " - Building samples..." - echo "" - xbuild /p:Configuration=Mono /p:Platform=x86 Samples/Samples.sln -fi diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 000000000..e6490b2fd --- /dev/null +++ b/Makefile.am @@ -0,0 +1,104 @@ +SUBDIRS = +DIST_SUBDIRS = + +DIR_DEBUG = $(srcdir)/Debug +DIR_RELEASE = $(srcdir)/Release +LIBDIR = $(srcdir)/Release/mono + +ACCORD_ASSEMBLY_PC = $(srcdir)/$(PACKAGE_NAME).pc + +DIR_TEST = "$(srcdir)/Unit Tests/bin/Release/mono" +NUNIT = "$(srcdir)/Externals/NUnit/nunit-console-x86.exe" + +LIBFILES = \ + $(LIBDIR)/Accord.Vision.dll \ + $(LIBDIR)/Accord.Video.Ximea.dll \ + $(LIBDIR)/Accord.Video.VFW.dll \ + $(LIBDIR)/Accord.Video.Kinect.dll \ + $(LIBDIR)/Accord.Video.dll \ + $(LIBDIR)/Accord.Video.DirectShow.dll \ + $(LIBDIR)/Accord.Neuro.dll \ + $(LIBDIR)/Accord.Math.dll \ + $(LIBDIR)/Accord.Math.Core.dll \ + $(LIBDIR)/Accord.MachineLearning.dll \ + $(LIBDIR)/Accord.IO.dll \ + $(LIBDIR)/Accord.Imaging.dll \ + $(LIBDIR)/Accord.Genetic.dll \ + $(LIBDIR)/Accord.Fuzzy.dll \ + $(LIBDIR)/Accord.dll \ + $(LIBDIR)/Accord.Controls.Vision.dll \ + $(LIBDIR)/Accord.Controls.Imaging.dll \ + $(LIBDIR)/Accord.Controls.Audio.dll \ + $(LIBDIR)/Accord.Audition.dll \ + $(LIBDIR)/Accord.Audio.dll + +TESTFILES = \ + ${DIR_TEST}/Accord.Tests.Controls.dll \ + ${DIR_TEST}/Accord.Tests.Core.dll \ + ${DIR_TEST}/Accord.Tests.Imaging.dll \ + ${DIR_TEST}/Accord.Tests.IO.dll \ + ${DIR_TEST}/Accord.Tests.MachineLearning.dll \ + ${DIR_TEST}/Accord.Tests.Math.dll \ + ${DIR_TEST}/Accord.Tests.Neuro.dll \ + ${DIR_TEST}/Accord.Tests.Vision.dll \ + ${DIR_TEST}/Accord.Tests.Statistics.dll +# ${DIR_TEST}/Accord.Tests.Audio.dll + + +DEBUG_FILES = $(addsuffix .mdb, $(LIBFILES)) +RELEASE_FILE = $(PACKAGE)-$(VERSION) + + +#magic automake variables +pkgconfigdir = $(LIBDIR)/pkgconfig +pkgconfig_DATA = $(ACCORD_ASSEMBLY_PC) +#end + + + +# target: all - Default target: build +all: build + +# target: help - Display callable targets. +help: + egrep "^# target:" Makefile | sed 's/^# target:/make/' + +# target: build - Build Accord.NET Framework +build: Sources/Accord.NET.sln + $(XBUILD) /p:Configuration=Mono Sources/Accord.NET.sln + +# target: build - Build sample applications +samples: Samples/Samples.sln + $(XBUILD) /p:Configuration=Mono /p:Platform=x86 Samples/Samples.sln + +# target: build - Build documentation +docs: + mdoc update --lib=Release/mono/ --out=Docs/monodoc Release/mono/*.dll + mdoc export-html -o htmldocs docfiles + +# target: test - Run unit tests +test: build + $(MONO) --runtime=v4.0 ${NUNIT} -noxml -nodots -labels -process=single \ + -exclude:Serialization,Intensive,WinForms,Office,MonoNotSupported,Random \ + ${TESTFILES} + +# target: clean obj and bin directories +clean-local: + rm -rvf $(LIBDIR)/* + rm -rvf $(DIR_RELEASE)/* + rm -rvf $(DIR_DEBUG)/* + find $(srcdir)/ -type d -name obj | xargs rm -rvf + +maintainer-clean-local: + rm -rf autom4te.cache + + + +MAINTAINERCLEANFILES = Makefile.in \ + install-sh \ + configure \ + aclocal.m4 \ + missing \ + compile + +.PHONY: install uninstall cleanbin cleanobj \ No newline at end of file diff --git a/Setup/Archiver/Build.cmd b/Setup/Archiver/package-framework.cmd similarity index 100% rename from Setup/Archiver/Build.cmd rename to Setup/Archiver/package-framework.cmd diff --git a/Setup/Archiver/Samples.cmd b/Setup/Archiver/package-samples.cmd similarity index 100% rename from Setup/Archiver/Samples.cmd rename to Setup/Archiver/package-samples.cmd diff --git a/Setup/NuGet/Build.cmd b/Setup/NuGet/package-nuget.cmd similarity index 100% rename from Setup/NuGet/Build.cmd rename to Setup/NuGet/package-nuget.cmd diff --git a/Setup/NuGet/Push.cmd b/Setup/NuGet/push-packages.cmd similarity index 100% rename from Setup/NuGet/Push.cmd rename to Setup/NuGet/push-packages.cmd diff --git a/Setup/NuGet/Update.cmd b/Setup/NuGet/update-nuget.cmd similarity index 100% rename from Setup/NuGet/Update.cmd rename to Setup/NuGet/update-nuget.cmd diff --git a/Setup/CreateRelease.cmd b/Setup/create-release.cmd similarity index 76% rename from Setup/CreateRelease.cmd rename to Setup/create-release.cmd index d65512b46..d88a3e432 100644 --- a/Setup/CreateRelease.cmd +++ b/Setup/create-release.cmd @@ -7,13 +7,13 @@ :: Compile sources cd .. -cmd /c "Build.cmd" +cmd /c "build-all.cmd" cd Setup :: Build compressed archive cd Archiver -cmd /c "Build.cmd" -cmd /c "Samples.cmd" +cmd /c "package-framework.cmd" +cmd /c "package-samples.cmd" cd .. echo. @@ -29,7 +29,7 @@ echo. :: Build NuGet packages cd NuGet -cmd /c Build.cmd +cmd /c "package-nuget.cmd" cd .. echo. diff --git a/Setup/PublishNuGet.cmd b/Setup/publish-nuget.cmd similarity index 100% rename from Setup/PublishNuGet.cmd rename to Setup/publish-nuget.cmd diff --git a/Tests.sh b/Tests.sh deleted file mode 100755 index 4c3fef37d..000000000 --- a/Tests.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -########### - -TESTS="Unit Tests/bin/Release/mono/" -NUNIT="Externals/NUnit/nunit-console-x86.exe" -LIST=() - -# Run unit tests in the Mono solution -#LIST+=("${TESTS}Accord.Tests.Audio.dll") -LIST+=("${TESTS}Accord.Tests.Controls.dll") -LIST+=("${TESTS}Accord.Tests.Core.dll") -LIST+=("${TESTS}Accord.Tests.Imaging.dll") -LIST+=("${TESTS}Accord.Tests.IO.dll") -LIST+=("${TESTS}Accord.Tests.MachineLearning.dll") -LIST+=("${TESTS}Accord.Tests.Math.dll") -LIST+=("${TESTS}Accord.Tests.Neuro.dll") -LIST+=("${TESTS}Accord.Tests.Vision.dll") -LIST+=("${TESTS}Accord.Tests.Statistics.dll") - - -mono --runtime=v4.0 ${NUNIT} -noxml -nodots -labels -exclude:Serialization,Intensive,WinForms,Office,MonoNotSupported,Random -process=single "${LIST[@]/#/}" diff --git a/accord.pc.in b/accord.pc.in new file mode 100644 index 000000000..a3925feb7 --- /dev/null +++ b/accord.pc.in @@ -0,0 +1,10 @@ +Name: Accord.NET +Description: The Accord.NET Framework for Machine Learning, Image Processing, Mathematics and Statistics +Version: @VERSION@ +URL: http://accord-framework.net + +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ + +Libs: -r:@libdir@/Accord.Vision.dll -r:@libdir@/Accord.Video.Ximea.dll -r:@libdir@/Accord.Video.VFW.dll -r:@libdir@/Accord.Video.Kinect.dll -r:@libdir@/Accord.Video.dll -r:@libdir@/Accord.Video.DirectShow.dll -r:@libdir@/Accord.Neuro.dll -r:@libdir@/Accord.Math.dll -r:@libdir@/Accord.Math.Core.dll -r:@libdir@/Accord.MachineLearning.dll -r:@libdir@/Accord.IO.dll -r:@libdir@/Accord.Imaging.dll -r:@libdir@/Accord.Genetic.dll -r:@libdir@/Accord.Fuzzy.dll -r:@libdir@/Accord.dll -r:@libdir@/Accord.Controls.Vision.dll -r:@libdir@/Accord.Controls.Imaging.dll -r:@libdir@/Accord.Controls.Audio.dll -r:@libdir@/Accord.Audition.dll -r:@libdir@/Accord.Audio.dll \ No newline at end of file diff --git a/autogen.sh b/autogen.sh new file mode 100644 index 000000000..96406769e --- /dev/null +++ b/autogen.sh @@ -0,0 +1,153 @@ +#! /bin/sh + +# Compares software version numbers +# 10 means EQUAL +# 11 means GREATER THAN +# 9 means LESS THAN +check_version() { + test -z "$1" && return 1 + local ver1=$1 + while test `echo $ver1 | egrep -c [^0123456789.]` -gt 0 ; do + char=`echo $ver1 | sed 's/.*\([^0123456789.]\).*/\1/'` + char_dec=`echo -n "$char" | od -b | head -1 | awk {'print $2'}` + ver1=`echo $ver1 | sed "s/$char/.$char_dec/g"` + done + test -z "$2" && return 1 + local ver2=$2 + while test `echo $ver2 | egrep -c [^0123456789.]` -gt 0 ; do + char=`echo $ver2 | sed 's/.*\([^0123456789.]\).*/\1/'` + char_dec=`echo -n "$char" | od -b | head -1 | awk {'print $2'}` + ver2=`echo $ver2 | sed "s/$char/.$char_dec/g"` + done + + ver1=`echo $ver1 | sed 's/\.\./.0/g'` + ver2=`echo $ver2 | sed 's/\.\./.0/g'` + + do_version_check "$ver1" "$ver2" +} + +do_version_check() { + + test "$1" -eq "$2" && return 10 + + ver1front=`echo $1 | cut -d "." -f -1` + ver1back=`echo $1 | cut -d "." -f 2-` + ver2front=`echo $2 | cut -d "." -f -1` + ver2back=`echo $2 | cut -d "." -f 2-` + + if test "$ver1front" != "$1" || test "$ver2front" != "$2" ; then + test "$ver1front" -gt "$ver2front" && return 11 + test "$ver1front" -lt "$ver2front" && return 9 + + test "$ver1front" -eq "$1" || test -z "$ver1back" && ver1back=0 + test "$ver2front" -eq "$2" || test -z "$ver2back" && ver2back=0 + do_version_check "$ver1back" "$ver2back" + return $? + else + test "$1" -gt "$2" && return 11 || return 9 + fi +} + +PROJECT=Accord.NET +FILE= +CONFIGURE=configure.ac + +: ${AUTOCONF=autoconf} +: ${AUTOHEADER=autoheader} +: ${AUTOMAKE=automake} +: ${ACLOCAL=aclocal} +: ${MONO=mono} +: ${XBUILD=xbuild} + +DIE=0 + +($AUTOCONF --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "You must have autoconf installed to compile $PROJECT." + echo "Download the appropriate package for your distribution," + echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" + echo + echo "On apt-get systems, you might want to run 'sudo apt-get install autoconf'" + DIE=1 +} + +($AUTOMAKE --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "You must have automake installed to compile $PROJECT." + echo "Get ftp://sourceware.cygnus.com/pub/automake/automake-1.4.tar.gz" + echo "(or a newer version if it is available)" + echo + echo "On apt-get systems, you might want to run 'sudo apt-get install automake'" + DIE=1 +} + +($MONO --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "You must have mono runtime installed to compile $PROJECT." + echo + echo "On apt-get systems, you might want to run 'sudo apt-get install mono-complete'" + DIE=1 +} + +($XBUILD /version) < /dev/null > /dev/null 2>&1 || { + echo + echo "You must have mono-xbuild installed to compile $PROJECT." + echo + echo "On apt-get systems, you might want to run 'sudo apt-get install mono-xbuild'" + DIE=1 +} + +if test "$DIE" -eq 1; then + exit 1 +fi + +unset GREP_OPTIONS + +xbuild_version=`xbuild /version | grep '^XBuild' | egrep -o '([0-9]+\.?){2,}'` +check_version "$xbuild_version" "2.4" 2> /dev/null +if test $? -eq 9; then + echo + echo "A newer version of XBuild is required to build $PROJECT ( >= 2.4 )" + exit 1 +fi + +mono_version=`xbuild /version | grep '^Mono' | egrep -o '([0-9]+\.?){2,}'` +check_version "$xbuild_version" "2.4" 2> /dev/null +if test $? -eq 9; then + echo + echo "A newer version of Mono is required to run $PROJECT ( >= 2.4 )" + exit 1 +fi + + +#Check directoy +srcdir=`dirname $0` +test -z "$srcdir" && srcdir=. + +ORIGDIR=`pwd` +cd $srcdir +TEST_TYPE=-f +aclocalinclude="-I . $ACLOCAL_FLAGS" + + +test $TEST_TYPE $FILE || { + echo "You must run this script in the top-level $PROJECT directory" + exit 1 +} + +if test -z "$*"; then + echo "I am going to run ./configure with no arguments - if you wish " + echo "to pass any to it, please specify them on the $0 command line." +fi + +echo "Running $ACLOCAL $aclocalinclude ..." +$ACLOCAL $aclocalinclude + +echo "Running $AUTOMAKE --gnu $am_opt ..." +$AUTOMAKE --add-missing --gnu $am_opt + +echo "Running $AUTOCONF ..." +$AUTOCONF + +echo Running $srcdir/configure $conf_flags "$@" ... +$srcdir/configure $conf_flags "$@" \ No newline at end of file diff --git a/Build.cmd b/build-all.cmd similarity index 100% rename from Build.cmd rename to build-all.cmd diff --git a/configure.ac b/configure.ac new file mode 100644 index 000000000..8d8fd0c48 --- /dev/null +++ b/configure.ac @@ -0,0 +1,46 @@ +dnl Process this file with autoconf to produce a configure script. +AC_INIT([accord], [3.3]) +AM_INIT_AUTOMAKE([tar-ustar foreign]) + +AC_PROG_INSTALL + +dnl pkg-config +PKG_PROG_PKG_CONFIG([0.20]) + +AC_PATH_PROG(XBUILD, xbuild, no) +AC_PATH_PROG(MONO, mono, no) + +if test "x$XBUILD" = "xno"; then + AC_MSG_ERROR([XBuild not found]) +fi + +if test "x$MONO" = "xno"; then + AC_MSG_ERROR([No mono runtime found]) +fi + +# Check Mono version +MONO_MINIMUM_VERSION=2.8 +PKG_CHECK_MODULES(MONO, mono >= $MONO_MINIMUM_VERSION) + +AC_SUBST(XBUILD) +AC_SUBST(MONO) + + +AC_CONFIG_FILES([ +Makefile +accord.pc +]) + +AC_OUTPUT + +cat <