aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt141
-rw-r--r--audio_read.h2
-rw-r--r--bitstream.h2
-rw-r--r--cmake/Modules/Version.cmake115
-rw-r--r--cmake/cmake_uninstall.cmake.in21
-rw-r--r--common.h6
-rw-r--r--toolame.c19
7 files changed, 289 insertions, 17 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2c05ebb..a263fb7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,113 @@
-cmake_minimum_required (VERSION 2.6)
-project (Toolame-DAB)
-add_executable(toolame common.c
+########################################################################
+# Project setup
+########################################################################
+
+cmake_minimum_required(VERSION 2.8)
+project(Toolame-DAB C)
+
+# Select the release build type by default to get optimization flags
+if(NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE "Release")
+ message(STATUS "Build type not specified: defaulting to release.")
+endif(NOT CMAKE_BUILD_TYPE)
+set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "")
+
+list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
+
+
+########################################################################
+# Version information
+########################################################################
+
+set(VERSION_INFO_MAJOR 0)
+set(VERSION_INFO_MINOR 0)
+set(VERSION_INFO_PATCH 0)
+
+if(NOT DEFINED VERSION_INFO_EXTRA)
+ set(VERSION_INFO_EXTRA "git")
+endif()
+include(Version)
+
+set(VERSION "${VERSION_INFO}")
+
+
+########################################################################
+# Compiler specific setup
+########################################################################
+
+set(CMAKE_CFLAGS "${CMAKE_C_FLAGS} -W -Wall")
+add_definitions(-fomit-frame-pointer)
+add_definitions(-march=native)
+add_definitions(-DGIT_VERSION="${VERSION}")
+add_definitions(-DINLINE=)
+add_definitions(-DNEWENCODE)
+
+
+########################################################################
+# Find build dependencies
+########################################################################
+
+find_package(PkgConfig)
+
+# libm
+find_library(M_LIB m REQUIRED)
+
+# threads
+find_package(Threads REQUIRED)
+
+# libzmq
+pkg_check_modules(ZMQ libzmq>=4.0 REQUIRED)
+if(NOT ZMQ_FOUND)
+ message(FATAL_ERROR "libzmq required to compile Toolame-DAB \n")
+endif()
+include_directories(${ZMQ_INCLUDE_DIRS})
+
+# libjack
+pkg_check_modules(JACK jack)
+
+# libvlc
+pkg_check_modules(VLC libvlc)
+
+
+########################################################################
+# Options
+########################################################################
+
+# vlc input
+option(ENABLE_INPUT_VLC
+ "libvlc input plugin" ${VLC_FOUND})
+
+# jack input
+option(ENABLE_INPUT_JACK
+ "Jack input plugin" ${JACK_FOUND})
+
+
+if(ENABLE_INPUT_VLC)
+ if(NOT VLC_FOUND)
+ message(FATAL_ERROR "libvlc required to compile Toolame-DAB with ENABLE_INPUT_VLC \n")
+ endif()
+ add_definitions(-DVLC_INPUT)
+ include_directories(${VLC_INCLUDE_DIRS})
+ list(APPEND other_libs ${VLC_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
+endif()
+
+
+if(ENABLE_INPUT_JACK)
+ if(NOT JACK_FOUND)
+ message(FATAL_ERROR "libjack required to compile Toolame-DAB with ENABLE_INPUT_JACK \n")
+ endif()
+ add_definitions(-DJACK_INPUT)
+ include_directories(${JACK_INCLUDE_DIRS})
+ list(APPEND other_libs ${JACK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
+endif()
+
+
+########################################################################
+# Setup apps
+########################################################################
+
+list(APPEND toolame_sources
+ common.c
encode.c
ieeefloat.c
toolame.c
@@ -24,16 +131,26 @@ add_executable(toolame common.c
zmqoutput.c
utils.c
xpad.c
- vlc_input.c)
+ vlc_input.c
+ )
+
+add_executable(toolame ${toolame_sources})
+set_target_properties(toolame PROPERTIES OUTPUT_NAME toolame-dab)
+target_link_libraries(toolame ${M_LIB} ${ZMQ_LIBRARIES} ${other_libs})
+
+install(TARGETS toolame DESTINATION bin)
+
+
+########################################################################
+# Create uninstall target
+########################################################################
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -g -fomit-frame-pointer")
-set(CMAKE_C_FLAGS "-DGIT_VERSION=")
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native -Wall -DNEWENCODE")
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DINLINE=")
+configure_file(
+ "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
+ IMMEDIATE @ONLY)
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DENABLE_INPUT_VLC=0")
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DENABLE_INPUT_JACK=0")
+add_custom_target(uninstall
+ COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
-target_link_libraries(toolame m zmq)
-install (TARGETS toolame DESTINATION bin)
diff --git a/audio_read.h b/audio_read.h
index ab17a8f..215e89d 100644
--- a/audio_read.h
+++ b/audio_read.h
@@ -28,8 +28,10 @@ typedef struct IFF_AIFF_struct
}
IFF_AIFF;
+#if defined(JACK_INPUT)
void setup_jack(frame_header *header, const char* jackname);
int process(jack_nframes_t nframes, void *arg);
+#endif
void jack_shutdown(void *arg);
void parse_input_file (FILE *musicin, char *, frame_header *header, unsigned long *num_samples);
diff --git a/bitstream.h b/bitstream.h
index 66f8ae4..db67ac5 100644
--- a/bitstream.h
+++ b/bitstream.h
@@ -9,7 +9,7 @@ unsigned int get1bit (Bit_stream_struc *);
void put1bit (Bit_stream_struc *, int);
unsigned long look_ahead (Bit_stream_struc *, int);
unsigned long getbits (Bit_stream_struc *, int);
-INLINE void putbits (Bit_stream_struc *, unsigned int, int);
+extern INLINE void putbits (Bit_stream_struc *, unsigned int, int);
void byte_ali_putbits (Bit_stream_struc *, unsigned int, int);
unsigned long byte_ali_getbits (Bit_stream_struc *, int);
unsigned long sstell (Bit_stream_struc *);
diff --git a/cmake/Modules/Version.cmake b/cmake/Modules/Version.cmake
new file mode 100644
index 0000000..96ee6b7
--- /dev/null
+++ b/cmake/Modules/Version.cmake
@@ -0,0 +1,115 @@
+# Portions of this file have been borrowed from and/or inspired by
+# the Version.cmake from the rtl-sdr project.
+# http://sdr.osmocom.org/trac/wiki/rtl-sdr
+#
+# Provides:
+# ${VERSION_INFO_BASE} - Major.Minor.Patch
+# ${VERSION_INFO} - Major.minor.Patch[-git_info]
+#
+# Requires values for:
+# ${VERSION_INFO_MAJOR} - Increment on API compatibility changes.
+# ${VERSION_INFO_MINOR} - Increment when adding features.
+# ${VERSION_INFO_PATCH} - Increment for bug and documentation changes.
+#
+# Optional:
+# ${VERSION_INFO_EXTRA} - Set to "git" to append git info. This is
+# intended only for non-versioned development
+# builds
+# ${VERSION_INFO_OVERRIDE} - Set to a non-null value to override the
+# VERSION_INFO_EXTRA logic. This is intended
+# for automated snapshot builds from exported
+# trees, to pass in the git revision info.
+#
+if(DEFINED __INCLUDED_TOOLAME-DAB_VERSION_CMAKE)
+ return()
+endif()
+set(__INCLUDED_TOOLAME-DAB_VERSION_CMAKE TRUE)
+
+################################################################################
+# Gather up variables provided by parent script
+################################################################################
+
+if(NOT DEFINED VERSION_INFO_MAJOR)
+ message(FATAL_ERROR "VERSION_INFO_MAJOR is not defined")
+else()
+ set(VER_MAJ ${VERSION_INFO_MAJOR})
+endif()
+
+if(NOT DEFINED VERSION_INFO_MINOR)
+ message(FATAL_ERROR "VERSION_INFO_MINOR is not defined")
+else()
+ set(VER_MIN ${VERSION_INFO_MINOR})
+endif()
+
+if(NOT DEFINED VERSION_INFO_PATCH)
+ message(FATAL_ERROR "VERSION_INFO_PATCH is not defined")
+else()
+ set(VER_PAT ${VERSION_INFO_PATCH})
+endif()
+
+
+################################################################################
+# Craft version number, using git, if needed
+################################################################################
+find_package(Git QUIET)
+
+if(GIT_FOUND)
+ execute_process(
+ COMMAND ${GIT_EXECUTABLE} rev-parse --
+ ERROR_QUIET
+ RESULT_VARIABLE NOT_GIT_REPOSITORY
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ )
+
+ if(NOT_GIT_REPOSITORY)
+ set(GIT_INFO "-unknown")
+ else()
+ execute_process(
+ COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD --
+ OUTPUT_VARIABLE GIT_REV OUTPUT_STRIP_TRAILING_WHITESPACE
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ )
+
+ execute_process(
+ COMMAND ${GIT_EXECUTABLE} diff-index --quiet HEAD --
+ RESULT_VARIABLE GIT_DIRTY
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ )
+
+ if(GIT_DIRTY)
+ set(GIT_INFO "-${GIT_REV}-dirty")
+ else()
+ set(GIT_INFO "-${GIT_REV}")
+ endif()
+ endif()
+
+else()
+ message(WARNING "git missing -- unable to check libladeRF version.")
+ unset(NOT_GIT_REPOSITORY)
+ unset(GIT_REV)
+ unset(GIT_DIRTY)
+endif()
+
+
+################################################################################
+# Provide
+################################################################################
+set(VERSION_INFO_BASE "${VER_MAJ}.${VER_MIN}.${VER_PAT}")
+
+# Force the version suffix. Used for automated export builds.
+if(VERSION_INFO_OVERRIDE)
+ set(VERSION_INFO "${VERSION_INFO_BASE}-${VERSION_INFO_OVERRIDE}")
+
+# Intra-release builds
+elseif("${VERSION_INFO_EXTRA}" STREQUAL "git")
+ set(VERSION_INFO "${VERSION_INFO_BASE}-git${GIT_INFO}")
+
+# Versioned releases
+elseif("${VERSION_INFO_EXTRA}" STREQUAL "")
+ set(VERSION_INFO "${VERSION_INFO_BASE}")
+
+# Invalid
+else()
+ message(FATAL_ERROR
+ "Unexpected definition of VERSION_INFO_EXTRA: ${VERSION_INFO_EXTRA}")
+endif()
diff --git a/cmake/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in
new file mode 100644
index 0000000..2037e36
--- /dev/null
+++ b/cmake/cmake_uninstall.cmake.in
@@ -0,0 +1,21 @@
+if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+ message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+
+file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
+string(REGEX REPLACE "\n" ";" files "${files}")
+foreach(file ${files})
+ message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
+ if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+ exec_program(
+ "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
+ OUTPUT_VARIABLE rm_out
+ RETURN_VALUE rm_retval
+ )
+ if(NOT "${rm_retval}" STREQUAL 0)
+ message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
+ endif(NOT "${rm_retval}" STREQUAL 0)
+ else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+ message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
+ endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+endforeach(file)
diff --git a/common.h b/common.h
index 36d65a1..49ef1ae 100644
--- a/common.h
+++ b/common.h
@@ -89,7 +89,9 @@
#include <stdio.h>
#include <stdlib.h>
-#include <jack/jack.h>
+#if defined(JACK_INPUT)
+# include <jack/jack.h>
+#endif
/* Structure for Reading Layer II Allocation Tables from File */
@@ -169,8 +171,10 @@ typedef struct music_in_s
/* Data for the wav input */
FILE* wav_input;
+#if defined(JACK_INPUT)
/* Data for the jack input */
jack_client_t* jack_client;
+#endif
const char* jack_name;
} music_in_t;
diff --git a/toolame.c b/toolame.c
index 03d4d95..0aa71bd 100644
--- a/toolame.c
+++ b/toolame.c
@@ -1,8 +1,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <jack/jack.h>
-#include <jack/ringbuffer.h>
+#if defined(JACK_INPUT)
+# include <jack/jack.h>
+# include <jack/ringbuffer.h>
+#endif
#include "common.h"
#include "encoder.h"
#include "musicin.h"
@@ -732,7 +734,18 @@ void short_usage (void)
fprintf (stderr, "Toolame-DAB version %s\n (http://opendigitalradio.org)\n",
toolameversion);
fprintf (stderr, "MPEG Audio Layer II encoder for DAB\n\n");
+#if defined(JACK_INPUT) && defined(VLC_INPUT)
fprintf (stderr, "USAGE: %s [options] (<infile>|-j <jackname>|-V <libvlc url>) [output]\n\n", programName);
+#elif defined(JACK_INPUT)
+ fprintf (stderr, "USAGE: %s [options] (<infile>|-j <jackname>) [output]\n\n", programName);
+ fprintf (stderr, "VLC input not compiled in\n");
+#elif defined(VLC_INPUT)
+ fprintf (stderr, "USAGE: %s [options] (<infile>|-V <libvlc url>) [output]\n\n", programName);
+ fprintf (stderr, "JACK input not compiled in\n");
+#else
+ fprintf (stderr, "USAGE: %s [options] <infile> [output]\n\n", programName);
+ fprintf (stderr, "Neither JACK nor libVLC input compiled in\n");
+#endif
fprintf (stderr, "Try \"%s -h\" for more information.\n", programName);
exit (0);
}
@@ -1052,10 +1065,10 @@ void parse_args (int argc, char **argv, frame_info * frame, int *psy,
}
if (glopts.input_select == INPUT_SELECT_JACK) {
+#if defined(JACK_INPUT)
musicin.jack_name = inPath;
*num_samples = MAX_U_32_NUM;
-#if defined(JACK_INPUT)
setup_jack(header, musicin.jack_name);
#else
fprintf(stderr, "JACK input not compiled in\n");