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
This commit is contained in:
hselasky 2011-06-22 17:28:40 +00:00
parent 867088c88c
commit c76aed55f2
11 changed files with 177 additions and 119 deletions

68
CMakeLists.txt Normal file
View File

@ -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)

47
Makefile Normal file
View File

@ -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}

View File

@ -1,2 +0,0 @@
SUBDIRS = src man pixmaps

28
cmake/FindJACK.cmake Normal file
View File

@ -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
)

27
cmake/FindLASH.cmake Normal file
View File

@ -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
)

View File

@ -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

View File

@ -1,4 +0,0 @@
man_MANS = jack-keyboard.1
EXTRA_DIST = $(man_MANS)

View File

@ -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

View File

@ -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)

View File

@ -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 <trasz@FreeBSD.org>. * For questions and comments, you can contact:
* - Edward Tomasz Napierala <trasz@FreeBSD.org>
* - Hans Petter Selasky <hselasky@FreeBSD.org>.
*/ */
#include <stdio.h> #include <stdio.h>
@ -1689,7 +1691,7 @@ log_handler(const gchar *log_domain, GLogLevelFlags log_level, const gchar *mess
void void
show_version(void) show_version(void)
{ {
fprintf(stdout, "%s\n", PACKAGE_STRING); fprintf(stdout, "%s\n", PACKAGE_NAME " v" PACKAGE_VERSION);
exit(EX_OK); exit(EX_OK);
} }

View File

@ -217,11 +217,11 @@ key_binding(PianoKeyboard *pk, const char *key)
if (!found) if (!found)
return (-1); return (-1);
return ((int)note); return ((long)note);
} }
static void 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); assert(pk->key_bindings != NULL);