Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sibras committed Feb 13, 2022
2 parents fb60d95 + d1b97ed commit 2f40f53
Show file tree
Hide file tree
Showing 38 changed files with 1,129 additions and 820 deletions.
159 changes: 90 additions & 69 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,78 +1,86 @@
cmake_minimum_required(VERSION 2.8.0)
cmake_minimum_required(VERSION 2.8.12)

project(libmodplug)

set(VERSION "0.8.9.1")

option(BUILD_SHARED_LIBS "Build Shared Library (DLL)" OFF)

add_definitions(-DMODPLUG_BUILD)

include (CheckFunctionExists)
include (CheckIncludeFile)
include (CheckCCompilerFlag)
include (CheckCSourceCompiles)
include (TestBigEndian)

TEST_BIG_ENDIAN(WORDS_BIGENDIAN)
if(WORDS_BIGENDIAN)
add_definitions(-DWORDS_BIGENDIAN=1)
endif()

if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
add_definitions(-Wall)
# check symbol visibility attributes
set(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
if(NOT WIN32 AND NOT CYGWIN)
set(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Werror")
check_c_source_compiles("int foo(void) __attribute__((visibility(\"default\")));
int main(void) {return 0;}" HAVE_VISIBILITY_DEFAULT)
if(HAVE_VISIBILITY_DEFAULT)
check_c_compiler_flag(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN)
endif()
endif()
set(CMAKE_REQUIRED_FLAGS "-Wl,--no-undefined")
check_c_compiler_flag("" HAVE_NO_UNDEFINED)
set(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}")
endif()

include_directories(AFTER
src
src/libmodplug
${PROJECT_BINARY_DIR}
)
)

if (UNIX)
set (CMAKE_REQUIRED_LIBRARIES m)
if(UNIX AND NOT APPLE)
find_library(MATH_LIB m)
if(MATH_LIB)
set(CMAKE_REQUIRED_LIBRARIES m)
endif()
endif()

if (WIN32)
add_definitions(-D_USE_MATH_DEFINES)
add_definitions(-DNOMINMAX)
endif()

if (WIN32 AND NOT (MINGW OR MSYS))
set(MSINTTYPES_PATH "$ENV{MSINTTYPES_PATH}" CACHE PATH "search path for inttypes.h and stdint.h")

find_path(STDINT_INCLUDE_DIR
stdint.h
PATHS
${MSINTTYPES_PATH})

if (STDINT_INCLUDE_DIR)
add_definitions(-DHAVE_STDINT_H)
include_directories(AFTER "${STDINT_INCLUDE_DIR}")
endif()

find_path(INTTYPES_INCLUDE_DIR
inttypes.h
PATHS
${MSINTTYPES_PATH})

if (INTTYPES_INCLUDE_DIR)
add_definitions(-DHAVE_INTTYPES_H)
include_directories(AFTER "${INTTYPES_INCLUDE_DIR}")
endif()
check_include_file("stdint.h" HAVE_STDINT_H)
if (HAVE_STDINT_H)
add_definitions(-DHAVE_STDINT_H)
endif()

if (NOT STDINT_INCLUDE_DIR OR NOT INTTYPES_INCLUDE_DIR)
message(WARNING
"Compilation may fail if inttypes.h is not natively supported by the compiler."
"You can get inttypes.h from http://code.google.com/p/msinttypes/")
endif()
else()
check_include_file("stdint.h" HAVE_STDINT)
if (HAVE_STDINT)
add_definitions(-DHAVE_STDINT_H)
endif()
check_include_file("strings.h" HAVE_STRINGS_H)
if (HAVE_STRINGS_H)
add_definitions(-DHAVE_STRINGS_H)
endif()

check_function_exists("setenv" HAVE_SETENV)
check_function_exists("sinf" HAVE_SINF)

# Allow the developer to select if Dynamic or Static libraries are built
option(BUILD_SHARED_LIBS "Build Shared Library (DLL)" OFF)

# Set the LIB_TYPE variable to STATIC
set(LIB_TYPE STATIC)
if(HAVE_SINF)
add_definitions(-DHAVE_SINF)
endif()

if (BUILD_SHARED_LIBS)
# User wants to build Dynamic Libraries,
# so change the LIB_TYPE variable to CMake keyword 'SHARED'
set (LIB_TYPE SHARED)
add_definitions(-DDLL_EXPORT)
else (BUILD_SHARED_LIBS)
if (WIN32 OR CYGWIN)
add_definitions(-DDLL_EXPORT)
elseif (HAVE_VISIBILITY_HIDDEN)
add_definitions(-fvisibility=hidden)
add_definitions("-DSYM_VISIBILITY")
endif()
else ()
set(LIB_TYPE STATIC)
add_definitions(-DMODPLUG_STATIC)
endif (BUILD_SHARED_LIBS)
endif()

add_library(modplug ${LIB_TYPE}
src/libmodplug/it_defs.h
Expand Down Expand Up @@ -116,40 +124,53 @@ add_library(modplug ${LIB_TYPE}
src/sndfile.cpp
src/sndmix.cpp
src/tables.h
)
)

# install the library:
install(TARGETS modplug DESTINATION lib)
if (BUILD_SHARED_LIBS)
if(APPLE)
target_link_libraries(modplug -Wl,-undefined,error)
target_link_libraries(modplug -Wl,-compatibility_version,2.0.0)
target_link_libraries(modplug -Wl,-current_version,2.0.0)
else()
if(HAVE_NO_UNDEFINED)
target_link_libraries(modplug -Wl,--no-undefined)
endif()
set_target_properties(modplug PROPERTIES
VERSION 1.0.0 SOVERSION 1)
endif()
if(MATH_LIB)
target_link_libraries(modplug m)
endif()
endif()

# incstall the headers:
# install the library:
include (GNUInstallDirs)
install(TARGETS modplug
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

# install the headers:
install(FILES
src/modplug.h
src/libmodplug/it_defs.h
src/libmodplug/sndfile.h
src/libmodplug/stdafx.h
src/modplug.h

DESTINATION
include/libmodplug
)

set(VERSION "0.8.8.5")

if(HAVE_SETENV)
add_definitions(-DHAVE_SETENV)
endif(HAVE_SETENV)
if(HAVE_SINF)
add_definitions(-DHAVE_SINF)
endif(HAVE_SINF)
${CMAKE_INSTALL_INCLUDEDIR}/libmodplug
)

if (NOT WIN32)
set(prefix "${CMAKE_INSTALL_PREFIX}")
set(exec_prefix "${CMAKE_INSTALL_PREFIX}")
set(libdir "${CMAKE_INSTALL_PREFIX}/lib")
set(includedir "${CMAKE_INSTALL_PREFIX}/include")
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix ${CMAKE_INSTALL_PREFIX})
set(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
set(includedir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR})
configure_file(libmodplug.pc.in libmodplug.pc)

# install pkg-config file:
install(FILES "${PROJECT_BINARY_DIR}/libmodplug.pc"
DESTINATION lib/pkgconfig
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)
endif (NOT WIN32)
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ACLOCAL_AMFLAGS = -I m4

SUBDIRS = src

EXTRA_DIST = \
EXTRA_DIST = CMakeLists.txt \
AUTHORS COPYING ChangeLog \
INSTALL README TODO

Expand Down
15 changes: 0 additions & 15 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -188,21 +188,6 @@ Solution:
turn down your volume again when you play an MP3.


Problem:
You have a mod which is rendered incorrectly by ModPlug-XMMS.

Possible cause:
This could be our fault. :)

Solution:
First, test the mod using the Windows version of ModPlug, if you can.
If it sounds wrong there, then send the mod and a bug report to
Olivier Lapicque <[email protected]>. If the mod plays correctly in
Windows, however, then the bug is my fault. In that case, e-mail
me (Konstanty) <[email protected]>. (previously Kenton Varda at
<[email protected]>).


Problem:
I have a problem which is not listed here, or an idea for a cool
feature.
Expand Down
57 changes: 25 additions & 32 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
dnl Process this file with autoconf to produce a configure script.

AC_PREREQ(2.63)
AC_PREREQ([2.63])

AC_INIT([libmodplug], [0.8.9.0])
AC_INIT([libmodplug],[0.8.9.1])
AC_CONFIG_SRCDIR([Makefile.am])

AM_INIT_AUTOMAKE
Expand All @@ -12,52 +12,45 @@ AC_CONFIG_MACRO_DIR([m4])
AM_MAINTAINER_MODE([enable])

dnl Checks for programs.
dnl I am disabling static libraries here because otherwise libtool insists on
dnl compiling everything twice -- once with and once without -fPIC. Pisses me
dnl off. Just do everything with -fPIC, damnit! Compiling everything twice
dnl probably wastes more cycles than not using -fPIC saves.
AC_DISABLE_STATIC
AC_DISABLE_STATIC([])
AC_PROG_CC
AC_PROG_CXX
AC_LANG([C++])
AC_C_BIGENDIAN

#AC_LIBTOOL_WIN32_DLL
#AC_PROG_LIBTOOL
LT_INIT([win32-dll])
LT_INIT([win32-dll disable-static])

AC_HEADER_STDC
AC_CHECK_HEADERS([inttypes.h stdint.h malloc.h])
AC_CHECK_FUNCS(setenv sinf)
AC_CHECK_HEADERS([inttypes.h stdint.h malloc.h strings.h])

CXXFLAGS="$CXXFLAGS -fno-exceptions -Wall -ffast-math -fno-common -D_REENTRANT"

AC_CANONICAL_HOST
case "$host" in
*mingw* | *cygwin*)
LT_LDFLAGS="-no-undefined"
;;
*)
LT_LDFLAGS=""
;;
esac
AC_SUBST(LT_LDFLAGS)

# require 10.5+ for osx/x86_64 builds
case "$host" in
x86_64-*-darwin*)
CXXFLAGS="$CXXFLAGS -mmacosx-version-min=10.5"
LDFLAGS="$LDFLAGS -mmacosx-version-min=10.5" ;;
LIBM=
case "${host_os}" in
dnl Djgpp has all c89 math funcs in libc.a
*djgpp)
;;
dnl These systems don't have libm or don't need it (list based on libtool)
darwin*|haiku*|beos*|cegcc*|pw32*)
;;
dnl MinGW and Cygwin don't need libm, either
mingw*|cygwin*)
;;
dnl All others:
*) AC_CHECK_LIB(m, pow, LIBM="-lm")
if test x$LIBM != x; then
LIBS="${LIBS} ${LIBM}"
fi
;;
esac
AC_CHECK_FUNCS(sinf)

# symbol visibility
ac_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -fvisibility=hidden -Werror"
AC_CACHE_CHECK([if compiler supports visibility attributes],[libmodplug_cv_gcc_visibility],
AC_TRY_COMPILE([void foo(void);
__attribute__((visibility("default"))) void foo(void) {}],
[],
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[void foo(void);
__attribute__((visibility("default"))) void foo(void) {}]], [])],
[libmodplug_cv_gcc_visibility=yes],
[libmodplug_cv_gcc_visibility=no])
)
Expand Down Expand Up @@ -99,6 +92,6 @@ MODPLUG_LIBRARY_VERSION=1:0:0
AC_SUBST(MODPLUG_LIBRARY_VERSION)

AC_CONFIG_FILES([Makefile
src/Makefile
src/Makefile
libmodplug.pc])
AC_OUTPUT
3 changes: 1 addition & 2 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ AM_CXXFLAGS = -DMODPLUG_BUILD=1
AM_CPPFLAGS = -I$(top_srcdir)/src/libmodplug

lib_LTLIBRARIES = libmodplug.la
libmodplug_la_LDFLAGS = -version-info $(MODPLUG_LIBRARY_VERSION) $(LT_LDFLAGS)
libmodplug_la_LIBADD = -lm
libmodplug_la_LDFLAGS = -no-undefined -version-info $(MODPLUG_LIBRARY_VERSION)
libmodplug_la_SOURCES = tables.h \
sndmix.cpp \
sndfile.cpp \
Expand Down
3 changes: 0 additions & 3 deletions src/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H

/* Define to 1 if you have the `setenv' function. */
#undef HAVE_SETENV

/* Define to 1 if you have the `sinf' function. */
#undef HAVE_SINF

Expand Down
Loading

0 comments on commit 2f40f53

Please sign in to comment.