Fixed bug 2335 - Fails to build on Debian GNU/kFreeBSD
authorSam Lantinga <slouken@libsdl.org>
Sat, 22 Feb 2014 18:01:18 -0800
changeset 8240334257cd613d
parent 8239 05cbb1cb4f27
child 8241 b6d5a589ce3f
Fixed bug 2335 - Fails to build on Debian GNU/kFreeBSD

Felix Geyer

Starting from version 2.0.1 libsdl fails to build on Debian GNU/kFreeBSD in SDL_cpuinfo.c.

GNU/kFreeBSD defines __FreeBSD_kernel__ but not __FreeBSD__.
The #ifdef __FreeBSD__ check should be extended for __FreeBSD_kernel__, see the attached patch.

Build log:
libtool: compile: gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -DUSING_GENERATED_CONFIG_H -Iinclude -I/«BUILDDIR»/libsdl2-2.0.1+dfsg1/include -mmmx -m3dnow -msse -msse2 -fvisibility=hidden -D_REENTRANT -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-kfreebsd-gnu/dbus-1.0/include -DHAVE_USBHID_H -DUSBHID_NEW -D_REENTRANT -Wall -c /«BUILDDIR»/libsdl2-2.0.1+dfsg1/src/cpuinfo/SDL_cpuinfo.c -fPIC -DPIC -o build/.libs/SDL_cpuinfo.o
/«BUILDDIR»/libsdl2-2.0.1+dfsg1/src/cpuinfo/SDL_cpuinfo.c: In function 'SDL_GetSystemRAM':
/«BUILDDIR»/libsdl2-2.0.1+dfsg1/src/cpuinfo/SDL_cpuinfo.c:632:35: error: 'HW_MEMSIZE' undeclared (first use in this function)
int mib[2] = {CTL_HW, HW_MEMSIZE};
^
/«BUILDDIR»/libsdl2-2.0.1+dfsg1/src/cpuinfo/SDL_cpuinfo.c:632:35: note: each undeclared identifier is reported only once for each function it appears in
make[2]: *** [build/SDL_cpuinfo.lo] Error 1
src/cpuinfo/SDL_cpuinfo.c
     1.1 --- a/src/cpuinfo/SDL_cpuinfo.c	Sat Feb 22 17:55:58 2014 -0800
     1.2 +++ b/src/cpuinfo/SDL_cpuinfo.c	Sat Feb 22 18:01:18 2014 -0800
     1.3 @@ -653,7 +653,7 @@
     1.4  #endif
     1.5  #ifdef HAVE_SYSCTLBYNAME
     1.6          if (SDL_SystemRAM <= 0) {
     1.7 -#ifdef __FreeBSD__
     1.8 +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
     1.9  #ifdef HW_REALMEM
    1.10              int mib[2] = {CTL_HW, HW_REALMEM};
    1.11  #else
    1.12 @@ -662,7 +662,7 @@
    1.13  #endif /* HW_REALMEM */
    1.14  #else
    1.15              int mib[2] = {CTL_HW, HW_MEMSIZE};
    1.16 -#endif /* __FreeBSD__ */
    1.17 +#endif /* __FreeBSD__ || __FreeBSD_kernel__ */
    1.18              Uint64 memsize = 0;
    1.19              size_t len = sizeof(memsize);
    1.20