From 4f1a3b95db520593615f970e70ca52fd7a4fd1aa Mon Sep 17 00:00:00 2001 From: Nedko Arnaudov Date: Sat, 14 Apr 2007 14:29:07 +0000 Subject: [PATCH] switch to autotools and prepare for midi git-svn-id: svn://svn.gna.org/svn/jackmixer/code@34 330dde89-2920-0410-a79a-889b863ea5ce --- GNUmakefile | 62 -------------------------- Makefile.am | 63 +++++++++++++++++++++++++++ acinclude.m4 | 138 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ bootstrap | 37 ++++++++++++++++ configure.ac | 89 +++++++++++++++++++++++++++++++++++++ jack_compat.h | 64 +++++++++++++++++++++++++++ 6 files changed, 391 insertions(+), 62 deletions(-) delete mode 100644 GNUmakefile create mode 100644 Makefile.am create mode 100644 acinclude.m4 create mode 100755 bootstrap create mode 100644 configure.ac create mode 100644 jack_compat.h diff --git a/GNUmakefile b/GNUmakefile deleted file mode 100644 index 2b1ac1b..0000000 --- a/GNUmakefile +++ /dev/null @@ -1,62 +0,0 @@ -# This file is part of jack_mixer -# -# Copyright (C) 2006 Nedko Arnaudov -# -# 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 -# the Free Software Foundation; version 2 of the License -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - -# Install prefix -INSTALL_PREFIX=/usr - -# Where to install GConf schema, this must match the way GConf is configured -INSTALL_GCONF_SCHEMAS_DIR=/etc/gconf/schemas - -CC = gcc -c -I/usr/include/python2.4 -Wall -Werror -D_GNU_SOURCE -fPIC - -.PHONY: run test install uninstall - -_jack_mixer_c.so: jack_mixer.o jack_mixer_wrap.o - ld -shared jack_mixer.o jack_mixer_wrap.o -o _jack_mixer_c.so -ljack -lm - -jack_mixer_wrap.c: jack_mixer.h - swig -python jack_mixer.h - -jack_mixer.o: jack_mixer.c jack_mixer.h - $(CC) jack_mixer.c - -jack_mixer_wrap.o: jack_mixer_wrap.c - $(CC) jack_mixer_wrap.c - -clean: - -@rm jack_mixer_wrap.o jack_mixer.o jack_mixer_wrap.c jack_mixer_c.py jack_mixer_c.pyc _jack_mixer_c.so - -run: _jack_mixer_c.so - ./jack_mixer.py - -test: _jack_mixer_c.so - @./test.py - -FILES = _jack_mixer_c.so jack_mixer_c.py abspeak.py channel.py gui.py jack_mixer.py meter.py scale.py serialization.py serialization_xml.py slider.py jack_mixer.glade - -install: _jack_mixer_c.so - mkdir -p $(INSTALL_PREFIX)/share/jack_mixer/ - cp $(FILES) $(INSTALL_PREFIX)/share/jack_mixer/ - ln -nfs $(INSTALL_PREFIX)/share/jack_mixer/jack_mixer.py $(INSTALL_PREFIX)/bin/jack_mixer - cp jack_mixer.schemas $(INSTALL_GCONF_SCHEMAS_DIR) - GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source` gconftool-2 --makefile-install-rule $(INSTALL_GCONF_SCHEMAS_DIR)/jack_mixer.schemas - -uninstall: - GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source` gconftool-2 --makefile-uninstall-rule $(INSTALL_GCONF_SCHEMAS_DIR)/jack_mixer.schemas - rm $(INSTALL_GCONF_SCHEMAS_DIR)/jack_mixer.schemas - rm -r $(INSTALL_PREFIX)/share/jack_mixer/ - rm $(INSTALL_PREFIX)/bin/jack_mixer diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..7cabf67 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,63 @@ +# +# This file is part of zynjacku +# +# Copyright (C) 2007 Nedko Arnaudov +# +# 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 +# the Free Software Foundation; version 2 of the License +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# + +AM_CFLAGS = @JACK_CFLAGS@ -D_GNU_SOURCE -Wall -Werror +INCLUDES = $(PYTHON_INCLUDES) + +jack_mixerdir = $(pkgdatadir) +pkgpyexecdir = $(pythondir) +pkgpyexec_LTLIBRARIES = _jack_mixer_c.la + +_jack_mixer_c_la_LDFLAGS = -module -avoid-version + +_jack_mixer_c_la_LIBADD = @JACK_LIBS@ + +dist_jack_mixer_DATA = abspeak.py channel.py gui.py meter.py scale.py serialization.py serialization_xml.py slider.py jack_mixer.glade + +jack_mixer_c.py jack_mixer_wrap.c: $(top_srcdir)/jack_mixer.h + $(SWIG) -o jack_mixer_wrap.c -I$(top_srcdir) -python $(top_srcdir)/jack_mixer.h + +pkgpyexec_SCRIPTS = jack_mixer_c.py + +CLEANFILES = jack_mixer_c.py jack_mixer_wrap.c *.pyc +EXTRA_DIST = test.py gpl.txt jack_mixer.schemas + +_jack_mixer_c_la_SOURCES = jack_mixer.c jack_mixer.h list.h +nodist__jack_mixer_c_la_SOURCES = jack_mixer_wrap.c + +bin_SCRIPTS = $(srcdir)/jack_mixer.py + +_jack_mixer_c.so: _jack_mixer_c.la + ln -nfs .libs/_jack_mixer_c.so + +test: _jack_mixer_c.so + @./test.py + +schemadir = @GCONF_SCHEMA_FILE_DIR@ +schema_DATA = jack_mixer.schemas + +install-data-hook: + GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) gconftool-2 --makefile-install-rule $(srcdir)/$(schema_DATA) + +install-exec-hook: + ln -vfs $(DESTDIR)$(pkgdatadir)/jack_mixer.py $(DESTDIR)$(bindir)/jack_mixer + +uninstall-hook: + GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) gconftool-2 --makefile-uninstall-rule $(srcdir)/$(schema_DATA) + rm -vf $(DESTDIR)$(bindir)/jack_mixer diff --git a/acinclude.m4 b/acinclude.m4 new file mode 100644 index 0000000..de78eb1 --- /dev/null +++ b/acinclude.m4 @@ -0,0 +1,138 @@ +# Copyright (C) 2007 Nedko Arnaudov +# This file is distributed under the same terms as the Autoconf macro files. + +## this one is commonly used with AM_PATH_PYTHONDIR ... +dnl AM_CHECK_PYMOD(MODNAME [,SYMBOL [,ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]]]) +dnl Check if a module containing a given symbol is visible to python. +AC_DEFUN([AM_CHECK_PYMOD], +[AC_REQUIRE([AM_PATH_PYTHON]) +py_mod_var=`echo $1['_']$2 | sed 'y%./+-%__p_%'` +AC_MSG_CHECKING(for ifelse([$2],[],,[$2 in ])python module $1) +AC_CACHE_VAL(py_cv_mod_$py_mod_var, [ +ifelse([$2],[], [prog=" +import sys +try: + import $1 +except ImportError: + sys.exit(1) +except: + sys.exit(0) +sys.exit(0)"], [prog=" +import $1 +$1.$2"]) +if $PYTHON -c "$prog" 1>&AC_FD_CC 2>&AC_FD_CC + then + eval "py_cv_mod_$py_mod_var=yes" + else + eval "py_cv_mod_$py_mod_var=no" + fi +]) +py_val=`eval "echo \`echo '$py_cv_mod_'$py_mod_var\`"` +if test "x$py_val" != xno; then + AC_MSG_RESULT(yes) + ifelse([$3], [],, [$3 +])dnl +else + AC_MSG_RESULT(no) + ifelse([$4], [],, [$4 +])dnl +fi +]) + +dnl a macro to check for ability to create python extensions +dnl AM_CHECK_PYTHON_HEADERS([ACTION-IF-POSSIBLE], [ACTION-IF-NOT-POSSIBLE]) +dnl function also defines PYTHON_INCLUDES +AC_DEFUN([AM_CHECK_PYTHON_HEADERS], +[AC_REQUIRE([AM_PATH_PYTHON]) +AC_MSG_CHECKING(for headers required to compile python extensions) +dnl deduce PYTHON_INCLUDES +py_prefix=`$PYTHON -c "import sys; print sys.prefix"` +py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"` +PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}" +if test "$py_prefix" != "$py_exec_prefix"; then + PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}" +fi +AC_SUBST(PYTHON_INCLUDES) +dnl check if the headers exist: +save_CPPFLAGS="$CPPFLAGS" +CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES" +AC_TRY_CPP([#include ],dnl +[AC_MSG_RESULT(found) +$1],dnl +[AC_MSG_RESULT(not found) +$2]) +CPPFLAGS="$save_CPPFLAGS" +]) + +AC_DEFUN([AC_JACK_MIDI_NFRAMES_CHECK], [ +AC_MSG_CHECKING([whether JACK MIDI functions need nframes parameter]) +AC_LANG_PUSH(C) +AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[ +#include +#include +]], [[ +jack_midi_event_get(0, 0, 0, 0); +]]), [jackmidi_nframes='yes'], [jackmidi_nframes='no']) +AC_MSG_RESULT([$jackmidi_nframes]) +AC_LANG_POP() +]) + +AC_DEFUN([AC_PROG_SWIG],[ + AC_PATH_PROG([SWIG],[swig]) + if test -z "$SWIG" ; then + AC_MSG_WARN([cannot find 'swig' program. You should look at http://www.swig.org]) + SWIG='echo "Error: SWIG is not installed. You should look at http://www.swig.org" ; false' + elif test -n "$1" ; then + AC_MSG_CHECKING([for SWIG version]) + [swig_version=`$SWIG -version 2>&1 | grep 'SWIG Version' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'`] + AC_MSG_RESULT([$swig_version]) + if test -n "$swig_version" ; then + # Calculate the required version number components + [required=$1] + [required_major=`echo $required | sed 's/[^0-9].*//'`] + if test -z "$required_major" ; then + [required_major=0] + fi + [required=`echo $required | sed 's/[0-9]*[^0-9]//'`] + [required_minor=`echo $required | sed 's/[^0-9].*//'`] + if test -z "$required_minor" ; then + [required_minor=0] + fi + [required=`echo $required | sed 's/[0-9]*[^0-9]//'`] + [required_patch=`echo $required | sed 's/[^0-9].*//'`] + if test -z "$required_patch" ; then + [required_patch=0] + fi + # Calculate the available version number components + [available=$swig_version] + [available_major=`echo $available | sed 's/[^0-9].*//'`] + if test -z "$available_major" ; then + [available_major=0] + fi + [available=`echo $available | sed 's/[0-9]*[^0-9]//'`] + [available_minor=`echo $available | sed 's/[^0-9].*//'`] + if test -z "$available_minor" ; then + [available_minor=0] + fi + [available=`echo $available | sed 's/[0-9]*[^0-9]//'`] + [available_patch=`echo $available | sed 's/[^0-9].*//'`] + if test -z "$available_patch" ; then + [available_patch=0] + fi + if test $available_major -ne $required_major \ + -o $available_minor -ne $required_minor \ + -o $available_patch -lt $required_patch ; then + AC_MSG_WARN([SWIG version >= $1 is required. You have $swig_version. You should look at http://www.swig.org]) + SWIG='echo "Error: SWIG version >= $1 is required. You have '"$swig_version"'. You should look at http://www.swig.org" ; false' + else + AC_MSG_NOTICE([SWIG executable is '$SWIG']) + SWIG_LIB=`$SWIG -swiglib` + AC_MSG_NOTICE([SWIG library directory is '$SWIG_LIB']) + fi + else + AC_MSG_WARN([cannot determine SWIG version]) + SWIG='echo "Error: Cannot determine SWIG version. You should look at http://www.swig.org" ; false' + fi + fi + AC_SUBST([SWIG_LIB]) +]) diff --git a/bootstrap b/bootstrap new file mode 100755 index 0000000..f2e96d8 --- /dev/null +++ b/bootstrap @@ -0,0 +1,37 @@ +#!/bin/sh +# +# autotools bootstrap script for zynjacku +# +# This file is part of zynjacku +# +# Copyright (C) 2007 Nedko Arnaudov +# +# 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 +# the Free Software Foundation; version 2 of the License +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# + +if test x$1 = xclean +then + GENERATED="aclocal.m4 autom4te.cache config.h.in configure config Makefile.in" + set -x + if test -f Makefile; then make distclean; fi + rm -rf ${GENERATED} +else + set -x + mkdir -p config + aclocal -I config + libtoolize --copy --force + autoheader + automake --foreign --add-missing --copy + autoconf +fi diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..6aa2ada --- /dev/null +++ b/configure.ac @@ -0,0 +1,89 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. +# +# This file is part of zynjacku +# +# Copyright (C) 2007 Nedko Arnaudov +# +# 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 +# the Free Software Foundation; version 2 of the License +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# + +AC_PREREQ(2.61) +AC_INIT(jack_mixer, dev) +AC_CONFIG_AUX_DIR(config) +AM_INIT_AUTOMAKE +AC_CONFIG_HEADER([config.h]) + +AC_SUBST(DATADIR) + +# Checks for programs. +AC_PROG_CC +AC_DISABLE_STATIC +AC_PROG_LIBTOOL + +# Checks for libraries. + +PKG_CHECK_MODULES(GTK, gtk+-2.0) +PKG_CHECK_MODULES(PYGTK, pygtk-2.0) +PKG_CHECK_MODULES(JACK, jack) + +AC_PROG_SWIG(1.3.31) + +# JACK MIDI +have_jackmidi="unknown" +AC_ARG_ENABLE(jackmidi, [AS_HELP_STRING(--disable-jackmidi, [Force disable JACK MIDI support [default=no]])], [ have_jackmidi="no" ]) +if test "$have_jackmidi" = "unknown" +then + PKG_CHECK_MODULES(JACK_MIDI, jack >= 0.102.0, AC_DEFINE([HAVE_JACK_MIDI], [], [Defined if we have JACK MIDI support.]) have_jackmidi="yes") + if test "$have_jackmidi" = "yes" + then + PKG_CHECK_MODULES(OLD_JACK_MIDI, jack < 0.102.27, have_jackmidi="yes (old one)" AC_DEFINE(HAVE_OLD_JACK_MIDI, 1, [whether or not we building against old JACK MIDI (0.102.20)]), echo no) + fi +fi + +AM_CONDITIONAL(HAVE_JACK_MIDI, test "$have_jackmidi" = "yes" -o "$have_jackmidi" = "yes (old one)") + +if test "$have_jackmidi" != "yes" +then + AC_MSG_ERROR([You need JACK version with MIDI support.]) +else + AC_JACK_MIDI_NFRAMES_CHECK() + if test "$jackmidi_nframes" = "yes" + then + AC_DEFINE([JACK_MIDI_NEEDS_NFRAMES], 1, [Defined if we JACK MIDI functions need nframes parameter.]) + fi +fi + +# Python checking +AM_PATH_PYTHON(2.4) +AM_CHECK_PYTHON_HEADERS(,[AC_MSG_ERROR(Could not find Python headers)]) +#AS_AC_EXPAND(PYTHONDIR, $pythondir) +#AC_SUBST(PYTHONDIR) + +AM_GCONF_SOURCE_2 + +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT + +AC_MSG_RESULT([]) +AC_MSG_RESULT([**********************************************************************]) +AC_MSG_RESULT([]) +AC_MSG_RESULT([Prefix: $prefix]) +AC_MSG_RESULT([Python dir: $PYTHON_INCLUDES]) +#AC_MSG_RESULT([GConf schema dir: $GCONF_SCHEMA_FILE_DIR]) +AC_MSG_RESULT([]) +AC_MSG_RESULT([MIDI support: $have_jackmidi]) +AC_MSG_RESULT([]) +AC_MSG_RESULT([**********************************************************************]) +AC_MSG_RESULT([]) diff --git a/jack_compat.h b/jack_compat.h new file mode 100644 index 0000000..0325e23 --- /dev/null +++ b/jack_compat.h @@ -0,0 +1,64 @@ +/* -*- Mode: C ; c-basic-offset: 2 -*- */ +/***************************************************************************** + * + * This file is part of jack_nuke + * + * Copyright (C) 2007 Nedko Arnaudov + * + * 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 + * the Free Software Foundation; version 2 of the License + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + *****************************************************************************/ + +#if defined(JACK_MIDI_NEEDS_NFRAMES) + +jack_nframes_t +jack_midi_get_event_count_compat( + void * port_buffer) +{ +#if defined(HAVE_OLD_JACK_MIDI) + return jack_midi_port_get_info(port_buffer, 0)->event_count; +#else + return jack_midi_get_event_count(port_buffer, 0); +#endif +} + +#define jack_midi_get_event_count jack_midi_get_event_count_compat + +int +jack_midi_event_get_compat( + jack_midi_event_t * event, + void * port_buffer, + jack_nframes_t event_index) +{ + return jack_midi_event_get(event, port_buffer, event_index, 0); +} + +#define jack_midi_event_get jack_midi_event_get_compat + +void +jack_midi_clear_buffer_compat( + void * port_buffer) +{ + jack_midi_clear_buffer(port_buffer, 0); +} + +#define jack_midi_clear_buffer jack_midi_clear_buffer_compat + +#else + +#if defined(HAVE_OLD_JACK_MIDI) +#error "Old (0.102.20) JACK MIDI API needs nframes (autotools probably gone mad)" +#endif + +#endif /* #if defined(JACK_MIDI_NEEDS_NFRAMES) */ -- 2.11.4.GIT