Skip to content

Commit 3a8b61e

Browse files
committed
Merge branch 'sezero-misc-fixes'
2 parents b7660b1 + 63133e8 commit 3a8b61e

25 files changed

+279
-237
lines changed

CMakeLists.txt

Lines changed: 75 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,81 @@
1-
cmake_minimum_required(VERSION 2.8.0)
1+
cmake_minimum_required(VERSION 2.8.12)
22

33
project(libmodplug)
4+
5+
set(VERSION "0.8.9.1")
6+
7+
option(BUILD_SHARED_LIBS "Build Shared Library (DLL)" OFF)
8+
49
add_definitions(-DMODPLUG_BUILD)
510

611
include (CheckFunctionExists)
712
include (CheckIncludeFile)
13+
include (CheckCCompilerFlag)
14+
include (CheckCSourceCompiles)
15+
include (TestBigEndian)
16+
17+
TEST_BIG_ENDIAN(WORDS_BIGENDIAN)
18+
if(WORDS_BIGENDIAN)
19+
add_definitions(-DWORDS_BIGENDIAN=1)
20+
endif()
21+
22+
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
23+
add_definitions(-Wall)
24+
# check symbol visibility attributes
25+
set(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
26+
if(NOT WIN32 AND NOT CYGWIN)
27+
set(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Werror")
28+
check_c_source_compiles("int foo(void) __attribute__((visibility(\"default\")));
29+
int main(void) {return 0;}" HAVE_VISIBILITY_DEFAULT)
30+
if(HAVE_VISIBILITY_DEFAULT)
31+
check_c_compiler_flag(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN)
32+
endif()
33+
endif()
34+
set(CMAKE_REQUIRED_FLAGS "-Wl,--no-undefined")
35+
check_c_compiler_flag("" HAVE_NO_UNDEFINED)
36+
set(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}")
37+
endif()
838

939
include_directories(AFTER
1040
src
1141
src/libmodplug
1242
${PROJECT_BINARY_DIR}
13-
)
43+
)
1444

15-
if (UNIX)
16-
set (CMAKE_REQUIRED_LIBRARIES m)
45+
if(UNIX AND NOT APPLE)
46+
find_library(MATH_LIB m)
47+
if(MATH_LIB)
48+
set(CMAKE_REQUIRED_LIBRARIES m)
49+
endif()
1750
endif()
1851

1952
if (WIN32)
2053
add_definitions(-D_USE_MATH_DEFINES)
2154
add_definitions(-DNOMINMAX)
2255
endif()
2356

24-
if (WIN32 AND NOT (MINGW OR MSYS))
25-
set(MSINTTYPES_PATH "$ENV{MSINTTYPES_PATH}" CACHE PATH "search path for inttypes.h and stdint.h")
26-
27-
find_path(STDINT_INCLUDE_DIR
28-
stdint.h
29-
PATHS
30-
${MSINTTYPES_PATH})
31-
32-
if (STDINT_INCLUDE_DIR)
33-
add_definitions(-DHAVE_STDINT_H)
34-
include_directories(AFTER "${STDINT_INCLUDE_DIR}")
35-
endif()
36-
37-
find_path(INTTYPES_INCLUDE_DIR
38-
inttypes.h
39-
PATHS
40-
${MSINTTYPES_PATH})
41-
42-
if (INTTYPES_INCLUDE_DIR)
43-
add_definitions(-DHAVE_INTTYPES_H)
44-
include_directories(AFTER "${INTTYPES_INCLUDE_DIR}")
45-
endif()
46-
47-
if (NOT STDINT_INCLUDE_DIR OR NOT INTTYPES_INCLUDE_DIR)
48-
message(WARNING
49-
"Compilation may fail if inttypes.h is not natively supported by the compiler."
50-
"You can get inttypes.h from http://code.google.com/p/msinttypes/")
51-
endif()
52-
else()
53-
check_include_file("stdint.h" HAVE_STDINT)
54-
if (HAVE_STDINT)
55-
add_definitions(-DHAVE_STDINT_H)
56-
endif()
57+
check_include_file("stdint.h" HAVE_STDINT)
58+
if (HAVE_STDINT)
59+
add_definitions(-DHAVE_STDINT_H)
5760
endif()
5861

5962
check_function_exists("sinf" HAVE_SINF)
60-
61-
# Allow the developer to select if Dynamic or Static libraries are built
62-
option(BUILD_SHARED_LIBS "Build Shared Library (DLL)" OFF)
63-
64-
# Set the LIB_TYPE variable to STATIC
65-
set(LIB_TYPE STATIC)
63+
if(HAVE_SINF)
64+
add_definitions(-DHAVE_SINF)
65+
endif()
6666

6767
if (BUILD_SHARED_LIBS)
68-
# User wants to build Dynamic Libraries,
69-
# so change the LIB_TYPE variable to CMake keyword 'SHARED'
7068
set (LIB_TYPE SHARED)
71-
add_definitions(-DDLL_EXPORT)
72-
else (BUILD_SHARED_LIBS)
69+
if (WIN32 OR CYGWIN)
70+
add_definitions(-DDLL_EXPORT)
71+
elseif (HAVE_VISIBILITY_HIDDEN)
72+
add_definitions(-fvisibility=hidden)
73+
add_definitions("-DSYM_VISIBILITY")
74+
endif()
75+
else ()
76+
set(LIB_TYPE STATIC)
7377
add_definitions(-DMODPLUG_STATIC)
74-
endif (BUILD_SHARED_LIBS)
78+
endif()
7579

7680
add_library(modplug ${LIB_TYPE}
7781
src/libmodplug/it_defs.h
@@ -115,7 +119,24 @@ add_library(modplug ${LIB_TYPE}
115119
src/sndfile.cpp
116120
src/sndmix.cpp
117121
src/tables.h
118-
)
122+
)
123+
124+
if (BUILD_SHARED_LIBS)
125+
if(APPLE)
126+
target_link_libraries(modplug -Wl,-undefined,error)
127+
target_link_libraries(modplug -Wl,-compatibility_version,2.0.0)
128+
target_link_libraries(modplug -Wl,-current_version,2.0.0)
129+
else()
130+
if(HAVE_NO_UNDEFINED)
131+
target_link_libraries(modplug -Wl,--no-undefined)
132+
endif()
133+
set_target_properties(modplug PROPERTIES
134+
VERSION 1.0.0 SOVERSION 1)
135+
endif()
136+
if(MATH_LIB)
137+
target_link_libraries(modplug m)
138+
endif()
139+
endif()
119140

120141
# install the library:
121142
include (GNUInstallDirs)
@@ -128,17 +149,13 @@ install(TARGETS modplug
128149
# install the headers:
129150
install(FILES
130151
src/modplug.h
131-
${HEADERS_CXX}
152+
src/libmodplug/it_defs.h
153+
src/libmodplug/sndfile.h
154+
src/libmodplug/stdafx.h
132155

133156
DESTINATION
134157
${CMAKE_INSTALL_INCLUDEDIR}/libmodplug
135-
)
136-
137-
set(VERSION "0.8.9.1")
138-
139-
if(HAVE_SINF)
140-
add_definitions(-DHAVE_SINF)
141-
endif(HAVE_SINF)
158+
)
142159

143160
if (NOT WIN32)
144161
set(prefix ${CMAKE_INSTALL_PREFIX})
@@ -149,6 +166,6 @@ if (NOT WIN32)
149166

150167
# install pkg-config file:
151168
install(FILES "${PROJECT_BINARY_DIR}/libmodplug.pc"
152-
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
169+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
153170
)
154171
endif (NOT WIN32)

Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ ACLOCAL_AMFLAGS = -I m4
22

33
SUBDIRS = src
44

5-
EXTRA_DIST = \
5+
EXTRA_DIST = CMakeLists.txt \
66
AUTHORS COPYING ChangeLog \
77
INSTALL README TODO
88

README

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -188,21 +188,6 @@ Solution:
188188
turn down your volume again when you play an MP3.
189189

190190

191-
Problem:
192-
You have a mod which is rendered incorrectly by ModPlug-XMMS.
193-
194-
Possible cause:
195-
This could be our fault. :)
196-
197-
Solution:
198-
First, test the mod using the Windows version of ModPlug, if you can.
199-
If it sounds wrong there, then send the mod and a bug report to
200-
Olivier Lapicque <olivierl@jps.net>. If the mod plays correctly in
201-
Windows, however, then the bug is my fault. In that case, e-mail
202-
me (Konstanty) <konstanty@ieee.org>. (previously Kenton Varda at
203-
<temporal@gauge3d.org>).
204-
205-
206191
Problem:
207192
I have a problem which is not listed here, or an idea for a cool
208193
feature.

configure.ac

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
dnl Process this file with autoconf to produce a configure script.
22

3-
AC_PREREQ([2.71])
3+
AC_PREREQ([2.63])
44

55
AC_INIT([libmodplug],[0.8.9.1])
66
AC_CONFIG_SRCDIR([Makefile.am])
@@ -17,48 +17,42 @@ AC_PROG_CXX
1717
AC_LANG([C++])
1818
AC_C_BIGENDIAN
1919

20-
#AC_LIBTOOL_WIN32_DLL
21-
#AC_PROG_LIBTOOL
22-
LT_INIT([win32-dll])
23-
24-
m4_warn([obsolete],
25-
[The preprocessor macro `STDC_HEADERS' is obsolete.
26-
Except in unusual embedded environments, you can safely include all
27-
ISO C90 headers unconditionally.])dnl
28-
# Autoupdate added the next two lines to ensure that your configure
29-
# script's behavior did not change. They are probably safe to remove.
30-
AC_CHECK_INCLUDES_DEFAULT
31-
AC_PROG_EGREP
20+
LT_INIT([win32-dll disable-static])
3221

3322
AC_CHECK_HEADERS([inttypes.h stdint.h malloc.h])
34-
AC_CHECK_FUNCS(sinf)
3523

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

3826
AC_CANONICAL_HOST
39-
case "$host" in
40-
*mingw* | *cygwin*)
41-
LT_LDFLAGS="-no-undefined"
42-
;;
43-
*)
44-
LT_LDFLAGS=""
45-
;;
46-
esac
47-
AC_SUBST(LT_LDFLAGS)
4827

49-
# require 10.5+ for osx/x86_64 builds
50-
case "$host" in
51-
x86_64-*-darwin*)
52-
CXXFLAGS="$CXXFLAGS -mmacosx-version-min=10.5"
53-
LDFLAGS="$LDFLAGS -mmacosx-version-min=10.5" ;;
28+
LIBM=
29+
case "${host_os}" in
30+
dnl Djgpp has all c89 math funcs in libc.a
31+
*djgpp)
32+
;;
33+
dnl These systems don't have libm or don't need it (list based on libtool)
34+
darwin*|haiku*|beos*|cegcc*|pw32*)
35+
;;
36+
dnl MinGW and Cygwin don't need libm, either
37+
mingw*|cygwin*)
38+
;;
39+
dnl All others:
40+
*) AC_CHECK_LIB(m, pow, LIBM="-lm")
41+
if test x$LIBM != x; then
42+
LIBS="${LIBS} ${LIBM}"
43+
fi
44+
;;
5445
esac
46+
AC_CHECK_FUNCS(sinf)
5547

5648
# symbol visibility
5749
ac_save_CXXFLAGS="$CXXFLAGS"
5850
CXXFLAGS="$CXXFLAGS -fvisibility=hidden -Werror"
5951
AC_CACHE_CHECK([if compiler supports visibility attributes],[libmodplug_cv_gcc_visibility],
6052
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[void foo(void);
61-
__attribute__((visibility("default"))) void foo(void) {}]], [[]])],[libmodplug_cv_gcc_visibility=yes],[libmodplug_cv_gcc_visibility=no])
53+
__attribute__((visibility("default"))) void foo(void) {}]], [])],
54+
[libmodplug_cv_gcc_visibility=yes],
55+
[libmodplug_cv_gcc_visibility=no])
6256
)
6357
# we want symbol -fvisibility for elf targets, however it works
6458
# with darwin/macho too. other than that, windows, dos and os2

src/Makefile.am

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ AM_CXXFLAGS = -DMODPLUG_BUILD=1
55
AM_CPPFLAGS = -I$(top_srcdir)/src/libmodplug
66

77
lib_LTLIBRARIES = libmodplug.la
8-
libmodplug_la_LDFLAGS = -version-info $(MODPLUG_LIBRARY_VERSION) $(LT_LDFLAGS)
9-
libmodplug_la_LIBADD = -lm
8+
libmodplug_la_LDFLAGS = -no-undefined -version-info $(MODPLUG_LIBRARY_VERSION)
109
libmodplug_la_SOURCES = tables.h \
1110
sndmix.cpp \
1211
sndfile.cpp \

src/fastmix.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,16 +287,22 @@ CzWINDOWEDFIR sfir;
287287
// ----------------------------------------------------------------------------
288288
// MIXING MACROS
289289
// ----------------------------------------------------------------------------
290+
#if defined(__cplusplus) && (__cplusplus >= 201402L)
291+
#define REGISTER
292+
#else
293+
#define REGISTER register
294+
#endif
295+
290296
#define SNDMIX_BEGINSAMPLELOOP8\
291-
register MODCHANNEL * const pChn = pChannel;\
297+
REGISTER MODCHANNEL * const pChn = pChannel;\
292298
nPos = pChn->nPosLo;\
293299
const signed char *p = (signed char *)(pChn->pCurrentSample+pChn->nPos);\
294300
if (pChn->dwFlags & CHN_STEREO) p += pChn->nPos;\
295301
int *pvol = pbuffer;\
296302
do {
297303

298304
#define SNDMIX_BEGINSAMPLELOOP16\
299-
register MODCHANNEL * const pChn = pChannel;\
305+
REGISTER MODCHANNEL * const pChn = pChannel;\
300306
nPos = pChn->nPosLo;\
301307
const signed short *p = (signed short *)(pChn->pCurrentSample+(pChn->nPos*2));\
302308
if (pChn->dwFlags & CHN_STEREO) p += pChn->nPos;\
@@ -1485,13 +1491,13 @@ UINT CSoundFile::CreateStereoMix(int count)
14851491
{
14861492
const LPMIXINTERFACE *pMixFuncTable;
14871493
MODCHANNEL * const pChannel = &Chn[ChnMix[nChn]];
1488-
UINT nFlags, nMasterCh;
1494+
UINT nFlags;//, nMasterCh
14891495
LONG nSmpCount;
14901496
int nsamples;
14911497
int *pbuffer;
14921498

14931499
if (!pChannel->pCurrentSample) continue;
1494-
nMasterCh = (ChnMix[nChn] < m_nChannels) ? ChnMix[nChn]+1 : pChannel->nMasterChn;
1500+
//nMasterCh = (ChnMix[nChn] < m_nChannels) ? ChnMix[nChn]+1 : pChannel->nMasterChn;
14951501
pOfsR = &gnDryROfsVol;
14961502
pOfsL = &gnDryLOfsVol;
14971503
nFlags = 0;
@@ -1606,7 +1612,7 @@ UINT CSoundFile::CreateStereoMix(int count)
16061612
}
16071613

16081614

1609-
#ifdef MSC_VER
1615+
#ifdef _MSC_VER
16101616
#pragma warning (disable:4100)
16111617
#endif
16121618

@@ -1700,7 +1706,6 @@ DWORD MPPASMCALL X86_Convert32To8(LPVOID lp8, int *pBuffer, DWORD lSampleCount,
17001706
}
17011707
#endif //MSC_VER, else
17021708

1703-
17041709
#if defined(_MSC_VER) && defined(_M_IX86)
17051710
// Clip and convert to 16 bit
17061711
__declspec(naked) DWORD MPPASMCALL X86_Convert32To16(LPVOID lp16, int *pBuffer, DWORD lSampleCount, LPLONG lpMin, LPLONG lpMax)

0 commit comments

Comments
 (0)