From c76aed55f2ad7e60bb75a7dbc8aca9e1198c1bcd Mon Sep 17 00:00:00 2001 From: hselasky Date: Wed, 22 Jun 2011 17:28:40 +0000 Subject: [PATCH] Convert build system into using cmake. git-svn-id: svn://svn.code.sf.net/p/jack-keyboard/code/trunk@21 1fa2bf75-7d80-4145-9e94-f9b4e25a1cb2 --- CMakeLists.txt | 68 +++++++++++++++++++++++++++++++++++++ Makefile | 47 +++++++++++++++++++++++++ Makefile.am | 2 -- cmake/FindJACK.cmake | 28 +++++++++++++++ cmake/FindLASH.cmake | 27 +++++++++++++++ configure.ac | 81 -------------------------------------------- man/Makefile.am | 4 --- pixmaps/Makefile.am | 17 ---------- src/Makefile.am | 10 ------ src/jack-keyboard.c | 8 +++-- src/pianokeyboard.c | 4 +-- 11 files changed, 177 insertions(+), 119 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 Makefile delete mode 100644 Makefile.am create mode 100644 cmake/FindJACK.cmake create mode 100644 cmake/FindLASH.cmake delete mode 100644 configure.ac delete mode 100644 man/Makefile.am delete mode 100644 pixmaps/Makefile.am delete mode 100644 src/Makefile.am diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..878cdb1 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,68 @@ +# +# Copyright (c) 2011 Hans Petter Selasky. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# +# Makefile for Jack Keyboard +# +cmake_minimum_required(VERSION 2.8) + +set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/") +set(VERSION "2.6") + +set(JackEnable ON CACHE BOOL "Enable support for Jack") +set(LashEnable ON CACHE BOOL "Enable support for Lash") +set(X11Enable ON CACHE BOOL "Enable support for X11") + +project(jack-keyboard) + +add_executable(jack-keyboard src/jack-keyboard src/pianokeyboard) + +find_package(GTK2 2.2 REQUIRED gtk) +include_directories(${GTK2_INCLUDE_DIRS}) +target_link_libraries(jack-keyboard ${GTK2_LIBRARIES}) + +if(JackEnable) +find_package(JACK) +include_directories(${JACK_INCLUDE_DIR}) +target_link_libraries(jack-keyboard ${JACK_LIBRARIES}) +add_definitions(-DHAVE_JACK=1) +endif() + +if(LashEnable) +find_package(LASH) +include_directories(${LASH_INCLUDE_DIR}) +target_link_libraries(jack-keyboard ${LASH_LIBRARIES}) +add_definitions(-DHAVE_LASH=1) +endif() + +if(X11Enable) +find_package(X11) +include_directories(${X11_INCLUDE_DIR}) +target_link_libraries(jack-keyboard ${X11_LIBRARIES}) +add_definitions(-DHAVE_X11=1) +endif() + +install(TARGETS jack-keyboard RUNTIME DESTINATION bin) +install(FILES pixmaps/jack-keyboard.png DESTINATION share/pixmaps) +install(FILES src/jack-keyboard.desktop DESTINATION share/applications) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..dff20fe --- /dev/null +++ b/Makefile @@ -0,0 +1,47 @@ +VERSION?=2.6 + +help: + @echo "Targets: configure all clean install package" + +configure: + + rm -rf build + + mkdir build + + cd build ; cmake .. + +all: + make -C build all + +install: + make -C build install + +clean: + make -C build clean + +package: + make -C build clean || echo -n + + tar -cvf temp.tar --exclude="*~" --exclude="*#" \ + --exclude=".svn" --exclude="*.orig" --exclude="*.rej" \ + AUTHORS \ + CMakeLists.txt \ + COPYING \ + Makefile \ + NEWS \ + README \ + TODO \ + cmake \ + man \ + src + + rm -rf jack-keyboard-${VERSION} + + mkdir jack-keyboard-${VERSION} + + tar -xvf temp.tar -C jack-keyboard-${VERSION} + + rm -rf temp.tar + + tar -zcvf jack-keyboard-${VERSION}.tar.gz jack-keyboard-${VERSION} diff --git a/Makefile.am b/Makefile.am deleted file mode 100644 index e5086d1..0000000 --- a/Makefile.am +++ /dev/null @@ -1,2 +0,0 @@ -SUBDIRS = src man pixmaps - diff --git a/cmake/FindJACK.cmake b/cmake/FindJACK.cmake new file mode 100644 index 0000000..577107c --- /dev/null +++ b/cmake/FindJACK.cmake @@ -0,0 +1,28 @@ +# - Try to find Jack library +# Once done this will define: +# JACK_FOUND - system has JACK +# JACK_INCLUDE_DIR - incude paths to use +# JACK_LIBRARIES - Link these to use + +SET(JACK_FOUND 0) + +FIND_PATH(JACK_INCLUDE_DIR jack/ringbuffer.h + /usr/local/include + /usr/include +) + +FIND_LIBRARY(JACK_LIBRARIES jack + /usr/local/lib + /usr/lib +) + +# handle the QUIETLY and REQUIRED arguments and set JACK_FOUND to TRUE +# if all listed variables are TRUE +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(JACK DEFAULT_MSG JACK_LIBRARIES JACK_INCLUDE_DIR) + +MARK_AS_ADVANCED( + JACK_INCLUDE_DIR + JACK_LIBRARIES +) + diff --git a/cmake/FindLASH.cmake b/cmake/FindLASH.cmake new file mode 100644 index 0000000..7b47beb --- /dev/null +++ b/cmake/FindLASH.cmake @@ -0,0 +1,27 @@ +# - Try to find Lash library +# Once done this will define: +# LASH_FOUND - system has LASH +# LASH_INCLUDE_DIR - incude paths to use +# LASH_LIBRARIES - Link these to use + +SET(LASH_FOUND 0) + +FIND_PATH(LASH_INCLUDE_DIR lash/lash.h + /usr/local/include/lash-1.0 + /usr/include/lash-1.0 +) + +FIND_LIBRARY(LASH_LIBRARIES lash + /usr/local/lib + /usr/lib +) + +# handle the QUIETLY and REQUIRED arguments and set LASH_FOUND to TRUE +# if all listed variables are TRUE +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(LASH DEFAULT_MSG LASH_LIBRARIES LASH_INCLUDE_DIR) + +MARK_AS_ADVANCED( + LASH_INCLUDE_DIR + LASH_LIBRARIES +) diff --git a/configure.ac b/configure.ac deleted file mode 100644 index 154f9f5..0000000 --- a/configure.ac +++ /dev/null @@ -1,81 +0,0 @@ -# -*- Autoconf -*- -# Process this file with autoconf to produce a configure script. - -AC_PREREQ(2.61) -AC_INIT([jack-keyboard], [2.6], [trasz@FreeBSD.org]) -AM_INIT_AUTOMAKE([-Wall foreign]) -AC_CONFIG_SRCDIR([config.h.in]) -AC_CONFIG_HEADERS([config.h]) - -# Checks for programs. -AC_PROG_CC - -# Checks for libraries. - -# Checks for header files. -AC_HEADER_STDC -AC_CHECK_HEADERS([stdlib.h string.h sys/time.h unistd.h]) - -# Checks for typedefs, structures, and compiler characteristics. -AC_C_CONST -AC_HEADER_TIME -AC_C_VOLATILE - -# Checks for library functions. -AC_FUNC_MALLOC -AC_FUNC_STRTOD -AC_CHECK_FUNCS([gettimeofday memset strcasecmp strdup]) - -PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.2) -AC_SUBST(GTK_CFLAGS) -AC_SUBST(GTK_LIBS) - -PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.12) -AC_SUBST(GLIB_CFLAGS) -AC_SUBST(GLIB_LIBS) - -PKG_CHECK_MODULES(GTHREAD, gthread-2.0 >= 2.2) -AC_SUBST(GTHREAD_CFLAGS) -AC_SUBST(GTHREAD_LIBS) - -AC_ARG_WITH([x11], - [AS_HELP_STRING([--with-x11], - [support keyboard grabbing @<:@default=check@:>@])], - [], - [with_x11=check]) - -AS_IF([test "x$with_x11" != xno], - [PKG_CHECK_MODULES(X11, x11, AC_DEFINE([HAVE_X11], [], [Defined if we have X11 support.]), - [if test "x$with_x11" != xcheck; then - AC_MSG_FAILURE([--with-x11 was given, but x11 was not found]) - fi - ])]) - -AC_SUBST(X11_CFLAGS) -AC_SUBST(X11_LIBS) - -PKG_CHECK_MODULES(JACK, jack >= 0.102.0) -AC_SUBST(JACK_CFLAGS) -AC_SUBST(JACK_LIBS) - -PKG_CHECK_MODULES(JACK_MIDI_NEEDS_NFRAMES, jack < 0.105.00, AC_DEFINE(JACK_MIDI_NEEDS_NFRAMES, 1, [whether or not JACK routines need nframes parameter]), true) - -AC_ARG_WITH([lash], - [AS_HELP_STRING([--with-lash], - [support LASH @<:@default=check@:>@])], - [], - [with_lash=check]) - -AS_IF([test "x$with_lash" != xno], - [PKG_CHECK_MODULES(LASH, lash-1.0, AC_DEFINE([HAVE_LASH], [], [Defined if we have LASH support.]), - [if test "x$with_lash" != xcheck; then - AC_MSG_FAILURE([--with-lash was given, but LASH was not found]) - fi - ])]) - -AC_SUBST(LASH_CFLAGS) -AC_SUBST(LASH_LIBS) - -AC_CONFIG_FILES([Makefile src/Makefile man/Makefile pixmaps/Makefile]) -AC_OUTPUT - diff --git a/man/Makefile.am b/man/Makefile.am deleted file mode 100644 index 524ab5b..0000000 --- a/man/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ -man_MANS = jack-keyboard.1 - -EXTRA_DIST = $(man_MANS) - diff --git a/pixmaps/Makefile.am b/pixmaps/Makefile.am deleted file mode 100644 index a7011ab..0000000 --- a/pixmaps/Makefile.am +++ /dev/null @@ -1,17 +0,0 @@ -pixmapsdir = $(datadir)/pixmaps -pixmaps_DATA = jack-keyboard.png -EXTRA_DIST = $(pixmaps_DATA) - -gtk_update_icon_cache = gtk-update-icon-cache -f -t $(datadir)/icons/hicolor - -install-data-hook: update-icon-cache -uninstall-hook: update-icon-cache -update-icon-cache: - @-if test -z "$(DESTDIR)"; then \ - echo "Updating Gtk icon cache."; \ - $(gtk_update_icon_cache); \ - else \ - echo "*** Icon cache not updated. After (un)install, run this:"; \ - echo "*** $(gtk_update_icon_cache)"; \ - fi - diff --git a/src/Makefile.am b/src/Makefile.am deleted file mode 100644 index b5b3e91..0000000 --- a/src/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -bin_PROGRAMS = jack-keyboard -jack_keyboard_SOURCES = jack-keyboard.c pianokeyboard.c pianokeyboard.h -jack_keyboard_LDADD = $(GTK_LIBS) $(GLIB_LIBS) $(GTHREAD_LIBS) $(X11_LIBS) $(JACK_LIBS) $(LASH_LIBS) -jack_keyboard_CFLAGS = $(GTK_CFLAGS) $(GLIB_CFLAGS) $(GTHREAD_CFLAGS) $(X11_CFLAGS) $(JACK_CFLAGS) $(LASH_CFLAGS) \ - -DG_LOG_DOMAIN=\"jack-keyboard\" - -desktopdir = $(datadir)/applications -desktop_DATA = jack-keyboard.desktop -EXTRA_DIST = $(desktop_DATA) - diff --git a/src/jack-keyboard.c b/src/jack-keyboard.c index a4e7129..266a0c3 100644 --- a/src/jack-keyboard.c +++ b/src/jack-keyboard.c @@ -25,9 +25,11 @@ */ /* - * This is jack-keyboard 2.6, a virtual keyboard for JACK MIDI. + * jack-keyboard is a virtual keyboard for JACK MIDI. * - * For questions and comments, contact Edward Tomasz Napierala . + * For questions and comments, you can contact: + * - Edward Tomasz Napierala + * - Hans Petter Selasky . */ #include @@ -1689,7 +1691,7 @@ log_handler(const gchar *log_domain, GLogLevelFlags log_level, const gchar *mess void show_version(void) { - fprintf(stdout, "%s\n", PACKAGE_STRING); + fprintf(stdout, "%s\n", PACKAGE_NAME " v" PACKAGE_VERSION); exit(EX_OK); } diff --git a/src/pianokeyboard.c b/src/pianokeyboard.c index afa6d8a..6e7c57b 100644 --- a/src/pianokeyboard.c +++ b/src/pianokeyboard.c @@ -217,11 +217,11 @@ key_binding(PianoKeyboard *pk, const char *key) if (!found) return (-1); - return ((int)note); + return ((long)note); } static void -bind_key(PianoKeyboard *pk, const char *key, int note) +bind_key(PianoKeyboard *pk, const char *key, long note) { assert(pk->key_bindings != NULL);