diff --git a/.gitignore b/.gitignore index 6b624a1..9605959 100644 --- a/.gitignore +++ b/.gitignore @@ -53,3 +53,6 @@ aptdec # CMake build + +libpng*/ +zlib*/ diff --git a/README.md b/README.md index 3e4d0ca..76e72d1 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,22 @@ To stop the decode and calibrate the image simply kill the `sox` process. Palettes are just simple PNG images, 256x256px in size with 24bit RGB color. The X axis represents the value of Channel A and the Y axis the value of Channel B. +## Compiling with cmake + +Thanks to the help of [Aang23](https://github.com/Aang23) aptdec is moving towards cmake + cpack for builds. + +To use cmake to build instead of GNU automake: +``` +mkdir build && cd build +cmake .. +make +``` + +Since cmake is now being used for building, windows support has come. You can build for windows with the `build_windows.sh` script, you will need wine and mingw64 installed: +``` +./build_windows.sh +``` + ## Further Reading [User's Guide for Building and Operating diff --git a/build_windows.sh b/build_windows.sh new file mode 100755 index 0000000..c9b1018 --- /dev/null +++ b/build_windows.sh @@ -0,0 +1,44 @@ +WINE_LIBSNDFILE_PATH=~/.wine/drive_c/Program\ Files/Mega-Nerd/libsndfile +TEMP_PATH=/tmp/windows_build + +# Compile zlib +git clone https://github.com/madler/zlib && cd zlib +mkdir build && cd build +cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../../cmake/toolchain-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$TEMP_PATH .. +make -j4 +make install +cd ../../ + +# Compile libpng +git clone https://github.com/glennrp/libpng && cd libpng +mkdir build && cd build +cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../../cmake/toolchain-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$TEMP_PATH .. +make -j4 +make install +cd ../../ + +# Download libsndfile (compiling from source is an absolute bitch) +if [[ ! -e $WINE_LIBSNDFILE_PATH ]]; then + wget http://www.mega-nerd.com/libsndfile/files/libsndfile-1.0.28-w64-setup.exe + echo "This build script has guessed that you don't have libsndfile installed under wine, the libsndfile installer will be launched" + read + wine libsndfile-1.0.28-w64-setup.exe +fi +if [[ ! -e $WINE_LIBSNDFILE_PATH ]]; then + echo "Something went wrong installing libsndfile" + exit +fi + +cp "$WINE_LIBSNDFILE_PATH/lib/libsndfile-1.def" $TEMP_PATH/lib/libsndfile-1.def +cp "$WINE_LIBSNDFILE_PATH/lib/libsndfile-1.lib" $TEMP_PATH/lib/libsndfile-1.lib +cp "$WINE_LIBSNDFILE_PATH/lib/pkgconfig/sndfile.pc" $TEMP_PATH/lib/pkgconfig/sndfile.pc +cp "$WINE_LIBSNDFILE_PATH/bin/libsndfile-1.dll" $TEMP_PATH/bin/libsndfile-1.dll +cp "$WINE_LIBSNDFILE_PATH/include/sndfile.h" $TEMP_PATH/include/sndfile.h + +sed -i "s/c:\/devel\/target\/libsndfile/$(echo $TEMP_PATH | sed 's/\//\\\//g')/g" $TEMP_PATH/lib/pkgconfig/sndfile.pc + +mkdir build && cd build +cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain-mingw32.cmake -DCMAKE_INSTALL_PREFIX=$TEMP_PATH .. +cp $TEMP_PATH/bin/*.dll ./ + +echo "Done, you should have a executable called aptdec.exe" diff --git a/cmake/FindLibSndFile.cmake b/cmake/FindLibSndFile.cmake index cd28788..2537b21 100644 --- a/cmake/FindLibSndFile.cmake +++ b/cmake/FindLibSndFile.cmake @@ -2,7 +2,7 @@ FIND_PATH(LIBSNDFILE_INCLUDE_DIR sndfile.h) -SET(LIBSNDFILE_NAMES ${LIBSNDFILE_NAMES} sndfile libsndfile) +SET(LIBSNDFILE_NAMES ${LIBSNDFILE_NAMES} sndfile libsndfile libsndfile-1) FIND_LIBRARY(LIBSNDFILE_LIBRARY NAMES ${LIBSNDFILE_NAMES} PATH) IF (LIBSNDFILE_INCLUDE_DIR AND LIBSNDFILE_LIBRARY) diff --git a/cmake/toolchain-mingw32.cmake b/cmake/toolchain-mingw32.cmake new file mode 100644 index 0000000..b316fd3 --- /dev/null +++ b/cmake/toolchain-mingw32.cmake @@ -0,0 +1,17 @@ +# the name of the target operating system +SET(CMAKE_SYSTEM_NAME Windows) + +# which compilers to use for C and C++ +SET(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) +SET(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++) +SET(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres) + +# here is the target environment located +SET(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32 ${CMAKE_INSTALL_PREFIX}) + +# adjust the default behaviour of the FIND_XXX() commands: +# search headers and libraries in the target environment, search +# programs in the host environment +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)