From ffed8fd7b719388c75b7b4a8a642609fed38d6a0 Mon Sep 17 00:00:00 2001 From: HolyWu Date: Fri, 26 Aug 2016 15:53:30 +0800 Subject: [PATCH] Replace custom configure script with Autoconf --- GNUmakefile | 46 ---------- Makefile.am | 42 +++++++++ README.md | 10 +++ autogen.sh | 3 + configure | 248 --------------------------------------------------- configure.ac | 56 ++++++++++++ 6 files changed, 111 insertions(+), 294 deletions(-) delete mode 100644 GNUmakefile create mode 100644 Makefile.am create mode 100644 autogen.sh delete mode 100755 configure create mode 100644 configure.ac diff --git a/GNUmakefile b/GNUmakefile deleted file mode 100644 index b7e3df3..0000000 --- a/GNUmakefile +++ /dev/null @@ -1,46 +0,0 @@ -#---------------------------------------------------------------------------- -# Makefile for VapourSynth-TCanny -#---------------------------------------------------------------------------- - -include config.mak - -vpath %.cpp $(SRCDIR) -vpath %.h $(SRCDIR) - -SRCS = TCanny/TCanny.cpp - -OBJS = $(SRCS:%.cpp=%.o) - -.PHONY: all install clean distclean dep - -all: $(LIBNAME) - -$(LIBNAME): $(OBJS) - $(LD) -o $@ $(LDFLAGS) $^ $(LIBS) - -@ $(if $(STRIP), $(STRIP) -x $@) - -%.o: %.cpp .depend - $(CXX) $(CXXFLAGS) -c $< -o $@ - -install: all - install -d $(libdir) - install -m 755 $(LIBNAME) $(libdir) - -clean: - $(RM) *.dll *.so *.dylib $(OBJS) .depend - -distclean: clean - $(RM) config.* - -dep: .depend - -ifneq ($(wildcard .depend),) -include .depend -endif - -.depend: config.mak - @$(RM) .depend - @$(foreach SRC, $(SRCS:%=$(SRCDIR)/%), $(CXX) $(SRC) $(CXXFLAGS) -MT $(SRC:$(SRCDIR)/%.cpp=%.o) -MM >> .depend;) - -config.mak: - ./configure diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..4d4ac63 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,42 @@ +warning_flags = -Wall -Wextra -Wno-unused-parameter -Wshadow +common_cflags = -O3 -ffast-math $(MFLAGS) $(warning_flags) +AM_CXXFLAGS = -std=c++14 $(common_cflags) + +AM_CPPFLAGS = $(VapourSynth_CFLAGS) + +lib_LTLIBRARIES = libtcanny.la + +libtcanny_la_SOURCES = TCanny/TCanny.cpp \ + TCanny/vectorclass/instrset.h \ + TCanny/vectorclass/instrset_detect.cpp + +if VS_TARGET_CPU_X86 +libtcanny_la_SOURCES += TCanny/TCanny_SSE2.cpp \ + TCanny/vectorclass/vectorclass.h \ + TCanny/vectorclass/vectorf128.h \ + TCanny/vectorclass/vectorf256.h \ + TCanny/vectorclass/vectorf256e.h \ + TCanny/vectorclass/vectori128.h \ + TCanny/vectorclass/vectori256.h \ + TCanny/vectorclass/vectori256e.h \ + TCanny/vectorclass/vectormath_common.h \ + TCanny/vectorclass/vectormath_trig.h + + +noinst_LTLIBRARIES = libavx.la libavx2.la + + +libavx_la_SOURCES = TCanny/TCanny_AVX.cpp + +libavx_la_CXXFLAGS = $(AM_CXXFLAGS) -mavx + + +libavx2_la_SOURCES = TCanny/TCanny_AVX2.cpp + +libavx2_la_CXXFLAGS = $(AM_CXXFLAGS) -mfma -mavx2 + + +libtcanny_la_LIBADD = libavx.la libavx2.la +endif + +libtcanny_la_LDFLAGS = -no-undefined -avoid-version $(PLUGINLDFLAGS) diff --git a/README.md b/README.md index fb84297..c72acad 100644 --- a/README.md +++ b/README.md @@ -42,3 +42,13 @@ Usage * 4 = use avx2 * planes: A list of the planes to process. By default all planes are processed. + + +Compilation +=========== + +``` +./autogen.sh +./configure +make +``` diff --git a/autogen.sh b/autogen.sh new file mode 100644 index 0000000..a8fd885 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +autoreconf --verbose --install --force diff --git a/configure b/configure deleted file mode 100755 index 5b09ce3..0000000 --- a/configure +++ /dev/null @@ -1,248 +0,0 @@ -#!/bin/sh - -#---------------------------------------------------------------------------- -# configure script for VapourSynth-TCanny -#---------------------------------------------------------------------------- - -# -- help ------------------------------------------------------------------- -if test x"$1" = x"-h" -o x"$1" = x"--help" ; then -cat << EOF -Usage: [PKG_CONFIG_PATH=/foo/bar/lib/pkgconfig] ./configure [options] -options: - -h, --help print help (this) - - --install=PATH set dir for install library - [/usr/local/lib/vapoursynth] - - --cxx=CXX use a defined compiler for compilation and linking - [g++] - --target-os=OS build programs to run on OS [auto] - --cross-prefix=PREFIX use PREFIX for compilation tools - --sysroot=SYSROOT root of cross-build tree - --enable-debug compile with debug symbols and never strip - - --extra-cxxflags=XCXXFLAGS add XCXXFLAGS to CXXFLAGS - --extra-ldflags=XLDFLAGS add XLDFLAGS to LDFLAGS - --extra-libs=XLIBS add XLIBS to LIBS - - --target=TARGET set target instruction set [sse2] - --disable-simd disable all x86 SIMD code - -EOF -exit 1 -fi - -#-- func -------------------------------------------------------------------- -error_exit() -{ - echo error: $1 - exit 1 -} - -log_echo() -{ - echo $1 - echo >> config.log - echo --------------------------------- >> config.log - echo $1 >> config.log -} - -cc_check() -{ - rm -f conftest.c - if [ -n "$3" ]; then - echo "#include <$3>" >> config.log - echo 'extern "C" {' > conftest.cpp - echo "#include <$3>" >> conftest.cpp - echo } >> conftest.cpp - fi - echo "int main(void){$4 return 0;}" >> config.log - echo "int main(void){$4 return 0;}" >> conftest.cpp - echo $CXX conftest.cpp -o conftest $1 $2 >> config.log - $CXX conftest.cpp -o conftest $1 $2 2>> config.log - ret=$? - echo $ret >> config.log - rm -f conftest* - return $ret -} -#---------------------------------------------------------------------------- -rm -f config.* .depend - -SRCDIR="$(cd $(dirname $0); pwd)" -test "$SRCDIR" = "$(pwd)" && SRCDIR=. -test -n "$(echo $SRCDIR | grep ' ')" && \ - error_exit "out-of-tree builds are impossible with whitespace in source path" - -# -- init ------------------------------------------------------------------- -libdir="/usr/local/lib/vapoursynth" - -TARGET_OS="" -CROSS="" - -SYSROOT="" -CXX="g++" -LD="g++" -STRIP="strip" - -DEBUG="" - -LIBNAME="" - -CXXFLAGS="-std=c++11 -Wall -I. -I$SRCDIR/include" -LDFLAGS="" -SOFLAGS="-shared" - -TARGET="-msse2" -SIMD="-DVS_TARGET_CPU_X86" - -# -- options ---------------------------------------------------------------- -echo all command lines: > config.log -echo "$*" >> config.log - -for opt; do - optarg="${opt#*=}" - case "$opt" in - --install=*) - libdir="$optarg" - ;; - --enable-debug) - DEBUG="enabled" - CXXFLAGS="$CXXFLAGS -g" - ;; - --cxx=*) - CXX="$optarg" - LD="$optarg" - ;; - --extra-cxxflags=*) - XCXXFLAGS="$optarg" - ;; - --extra-ldflags=*) - XLDFLAGS="$optarg" - ;; - --extra-libs=*) - XLIBS="$optarg" - ;; - --target-os=*) - TARGET_OS="$optarg" - ;; - --cross-prefix=*) - CROSS="$optarg" - ;; - --sysroot=*) - CXXFLAGS="$CXXFLAGS --sysroot=$optarg" - LDFLAGS="$LDFLAGS --sysroot=$optarg" - ;; - --target=*) - TARGET="-m$optarg" - ;; - --disable-simd) - SIMD="" - ;; - *) - error_exit "unknown option $opt" - ;; - esac -done - -CXXFLAGS="$CXXFLAGS $XCXXFLAGS $TARGET $SIMD" -LDFLAGS="$LDFLAGS $XLDFLAGS" - -CXX="${CROSS}${CXX}" -LD="${CROSS}${LD}" -STRIP="${CROSS}${STRIP}" -for f in "$CXX" "$LD" "$STRIP"; do - test -n "$(which $f 2> /dev/null)" || error_exit "$f is not executable" -done - -if test -n "$TARGET_OS"; then - TARGET_OS=$(echo $TARGET_OS | tr '[A-Z]' '[a-z]') -else - TARGET_OS=$($CXX -dumpmachine | tr '[A-Z]' '[a-z]') -fi -case "$TARGET_OS" in - *mingw*) - LIBNAME="TCanny.dll" - SOFLAGS="$SOFLAGS -Wl,--dll,--add-stdcall-alias" - ;; - *darwin*) - LIBNAME="libtcanny.dylib" - SOFLAGS="$SOFLAGS -dynamiclib -Wl,-undefined,suppress -Wl,-read_only_relocs,suppress -Wl,-flat_namespace" - ;; - *linux*) - LIBNAME="libtcanny.so" - CXXFLAGS="$CXXFLAGS -fabi-version=6 -fPIC" - SOFLAGS="$SOFLAGS -fPIC" - ;; - *) - error_exit "target is unsupported system" -esac - - -log_echo "CXXFLAGS/LDFLAGS checking..." -if ! cc_check "$CXXFLAGS" "$LDFLAGS"; then - error_exit "invalid CXXFLAGS/LDFLAGS" -fi -if cc_check "-O3 -ffast-math $CXXFLAGS" "$LDFLAGS"; then - CXXFLAGS="-O3 -ffast-math $CXXFLAGS" -fi -if cc_check "$CXXFLAGS -mfpmath=sse" "$LDFLAGS"; then - CXXFLAGS="$CXXFLAGS -mfpmath=sse" -fi - -PKGCONFIGBIN="pkg-config" -test -n "$(which ${CROSS}${PKGCONFIGBIN} 2> /dev/null)" && \ - PKGCONFIGBIN=${CROSS}${PKGCONFIGBIN} - - -log_echo "checking for vapoursynth headers..." -if $PKGCONFIGBIN --exists vapoursynth 2> /dev/null; then - CXXFLAGS="$CXXFLAGS $($PKGCONFIGBIN --cflags vapoursynth)" -else - log_echo "warning: pkg-config or pc files not found, header detection may be inaccurate." -fi -if ! cc_check "$CXXFLAGS" "$LDFLAGS $LIBS $XLIBS" "VapourSynth.h" "getVapourSynthAPI;" ; then - log_echo "error: vapoursynth checking failed." - error_exit "VapourSynth.h might not be installed." -fi - -LDFLAGS="$SOFLAGS $LDFLAGS" -LIBS="$LIBS $XLIBS" - - -cat >> config.mak << EOF -CXX = $CXX -LD = $LD -STRIP = $STRIP -CXXFLAGS = $CXXFLAGS -LDFLAGS = $LDFLAGS -LIBS = $LIBS -SRCDIR = $SRCDIR -LIBNAME = $LIBNAME -libdir = $libdir -EOF - -cat >> config.log << EOF ---------------------------------- - setting ---------------------------------- -EOF -cat config.mak >> config.log - -cat << EOF - -settings... -CXX = $CXX -LD = $LD -STRIP = $STRIP -CXXFLAGS = $CXXFLAGS -LDFLAGS = $LDFLAGS -LIBS = $LIBS -LIBNAME = $LIBNAME -install path = $libdir -EOF - -test "$SRCDIR" = "." || ln -sf $SRCDIR/GNUmakefile . - -echo configure finished. - -exit 0 diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..b3bcb98 --- /dev/null +++ b/configure.ac @@ -0,0 +1,56 @@ +AC_INIT([TCanny], [7], [https://github.com/HomeOfVapourSynthEvolution/VapourSynth-TCanny/issues], [TCanny], [https://github.com/HomeOfVapourSynthEvolution/VapourSynth-TCanny/]) + +: ${CXXFLAGS=""} + +AM_INIT_AUTOMAKE([foreign no-dist-gzip dist-xz subdir-objects no-define]) +AM_SILENT_RULES([yes]) + +LT_INIT([disable-static win32-dll]) + +AC_PROG_CXX + +AC_CANONICAL_HOST + + +X86="false" +PPC="false" +ARM="false" + +AS_CASE( + [$host_cpu], + [i?86], [BITS="32" X86="true"], + [x86_64], [BITS="64" X86="true"], + [powerpc*], [PPC="true"], + [arm*], [ARM="true"] +) + +AS_CASE( + [$host_os], + [cygwin*|mingw*], + [ + AS_IF( + [test "x$BITS" = "x32"], + [ + AC_SUBST([PLUGINLDFLAGS], ["-Wl,--kill-at"]) + ] + ) + ] +) + +AS_IF( + [test "x$X86" = "xtrue"], + [ + AC_DEFINE([VS_TARGET_CPU_X86]) + + AC_SUBST([MFLAGS], ["-mfpmath=sse -msse2"]) + ] +) + + +AM_CONDITIONAL([VS_TARGET_CPU_X86], [test "x$X86" = "xtrue"]) + + +PKG_CHECK_MODULES([VapourSynth], [vapoursynth]) + +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT