From e40c32d8addf3ab94dae42d8c0fcf9ef27e453c2 Mon Sep 17 00:00:00 2001 From: balr0g Date: Sun, 7 Jul 2013 17:55:33 -0400 Subject: [PATCH] Convert build system to use cmake and fix for Mac OS X build --- .gitignore | 5 ++++- CMakeLists.txt | 21 +++++++++++++++++++++ Makefile | 6 +++--- cmake_uninstall.cmake.in | 23 +++++++++++++++++++++++ dsd.h | 2 +- dsd_audio.c | 4 ++-- 6 files changed, 54 insertions(+), 7 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 cmake_uninstall.cmake.in diff --git a/.gitignore b/.gitignore index f5e3b6a..9d4ef4e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ -*.o dsd +*.[ao] +*.so* +*.dylib +build diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..8690a6c --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,21 @@ +project(dsd) +cmake_minimum_required(VERSION 2.6) + +FILE(GLOB SRCS *.c) + +INCLUDE_DIRECTORIES("${PROJECT_SOURCE_DIR}" "${CMAKE_INSTALL_PREFIX}/include") +LINK_DIRECTORIES("${CMAKE_INSTALL_PREFIX}/lib") + +ADD_EXECUTABLE(dsd ${SRCS}) +TARGET_LINK_LIBRARIES(dsd mbe) + +install(TARGETS dsd DESTINATION bin) + +# uninstall target +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" + IMMEDIATE @ONLY) + +add_custom_target(uninstall + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) \ No newline at end of file diff --git a/Makefile b/Makefile index cc2c14c..fcf64a4 100644 --- a/Makefile +++ b/Makefile @@ -14,9 +14,9 @@ # PERFORMANCE OF THIS SOFTWARE. CC = gcc -CFLAGS = -O2 -Wall -INCLUDES = -I. -I/usr/local/include -I/usr/include -LIBS = -L/usr/local/lib -lm -lmbe +CFLAGS = -O2 -Wall -g +INCLUDES = -I. -I/usr/local/include -I/usr/include -I../mbelib-master +LIBS = -L/usr/local/lib -L../mbelib-master -lm -lmbe INSTALL=install AR=ar RANLIB=ranlib diff --git a/cmake_uninstall.cmake.in b/cmake_uninstall.cmake.in new file mode 100644 index 0000000..4dc1b63 --- /dev/null +++ b/cmake_uninstall.cmake.in @@ -0,0 +1,23 @@ +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}") +cmake_policy(SET CMP0007 OLD) +list(REVERSE files) +foreach (file ${files}) + message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") + if (EXISTS "$ENV{DESTDIR}${file}") + execute_process( + COMMAND @CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${file}" + OUTPUT_VARIABLE rm_out + RESULT_VARIABLE rm_retval + ) + if(NOT ${rm_retval} EQUAL 0) + message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") + endif (NOT ${rm_retval} EQUAL 0) + else (EXISTS "$ENV{DESTDIR}${file}") + message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") + endif (EXISTS "$ENV{DESTDIR}${file}") +endforeach(file) \ No newline at end of file diff --git a/dsd.h b/dsd.h index 2373a3a..90160a9 100644 --- a/dsd.h +++ b/dsd.h @@ -31,7 +31,7 @@ #ifdef SOLARIS #include #endif -#ifdef BSD +#if defined(BSD) && !defined(__APPLE__) #include #endif #include diff --git a/dsd_audio.c b/dsd_audio.c index 9ae6d8b..e558dfd 100644 --- a/dsd_audio.c +++ b/dsd_audio.c @@ -237,7 +237,7 @@ openAudioOutDevice (dsd_opts * opts, int speed) } #endif -#ifdef BSD +#if defined(BSD) && !defined(__APPLE__) int fmt; @@ -318,7 +318,7 @@ openAudioInDevice (dsd_opts * opts) } #endif -#ifdef BSD +#if defined(BSD) && !defined(__APPLE__) int fmt; if (opts->split == 1)