Menu

#25 Patch to find SDL.h, png.h (configure --enable-sdl-graphics)

open
nobody
None
5
2008-01-14
2008-01-14
No

I normally build slashem using the configure script from autoconf, and it works okay with win/tty. When I decided to try the win/gl interface using configure --enable-sdl-graphics, I encountered build problems over a system running OpenBSD 4.2, using the system gcc. The build could not find SDL.h nor png.h.

I modified some files to solve these problems, and provide the attached patch.

--Kernigh http://nethack.wikia.com/wiki/User:Kernigh

I changed a line of include/winGL.h from "#include <SDL/SDL.h>" to "#include <SDL.h>", because sdl-config --cflags tells the compiler how to find SDL.h but not SDL/SDL.h. I hear that some systems have SDL.h at /usr/include/SDL/SDL.h, but I have it at /usr/local/include/SDL/SDL.h and the system gcc would need a -I/usr/local/include flag that sdl-config --cflags does not provide.

The SDL interface also requires the libpng library. OpenBSD puts libpng in a strange place, but either pkg-config libpng or libpng-config may find it. I noticed that configure already uses pkg-config libpng to find libpng, but does not use the result when building the SDL interface. I modified sys/autoconf/Makefile.src and sys/autoconf/Makefile.utl to use the @NETHACK_LIBPNG_CFLAGS@ and @NETHACK_LIBPNG_LIBS@ result. I also made an unrelated change in Makefile.utl, after noticing that ./tilemap does not write ../src/tile.c in $(srcdir).

Meanwhile, I modified sys/autoconf/configure.ac to complain if missing libpng while enabling sdl interface (like it complains when enabling proxy interface), and reindented some code. I then used aclocal 1.9.6 and autoconf 2.59 with bootstrap.sh to regenerate configure.

Finally, I could not install slashem until I changed some "make" into "$(MAKE)" in sys/autoconf/Makefile.utl so that it would run gmake instead of make. I have to use gmake because OpenBSD make does not understanding rules involving % signs; those rules install some data for the sdl interface.

TODO - (1) make equivalent changes to sys/unix/Makefile.* (2) remove % signs from rules so that GNU make is not a requirement to install the sdl interface.

Discussion

  • George Koehler

    George Koehler - 2008-01-14

    an output of cd slashem; cvs -z3 -Q diff -u

     
  • J. Ali Harlow

    J. Ali Harlow - 2008-01-14

    Logged In: YES
    user_id=64456
    Originator: NO

    Without looking at your actual patch, the basic ideas seem good apart from writing to $(srcdir). $(srcdir) is supposed to be read-only. If you want to play it may be easiest to do a VPATH build since that normally shows up problems with such things. (That is, unpack the sources into one directory and then run configure from another directory with something like ../slashem/configure; make; make install)

    The SDL port is unmaintained at this point so I'm very happy for you to make any changes you want to it.

     
  • George Koehler

    George Koehler - 2008-01-20

    adds support for BSD make, looks for libGL in X11R[67] installations

     
  • George Koehler

    George Koehler - 2008-01-20

    Logged In: YES
    user_id=1607454
    Originator: YES

    I want to clarify that my $(srcdir) does not contain src/tile.c

    When I noticed that ./tilemap does not write ../src/tile.c in $(srcdir), I changed one Makefile rule Makefile.utl from "$(srcdir)/../src/tile.c: tilemap" to "../src/tile.c: tilemap". I needed to do this because OpenBSD make complained about not knowing how to make ../src/tile.c

    (I guess that OpenBSD make only searches VPATH for existing files. GNU make seems smart enough to search VPATH for unbuilt targets.)

    I am attaching slashem-make-sdl-2.diff which supersedes my previous patch. I removed those % signs, replacing pattern rules with individual rules, so that BSD make can install slashem tiles. I changed an #include from <GL/gl.h> to <SDL_opengl.h>, hoping that helps if someone ever tries to build this above Mac OS X or Windows. I also added some code to configure.ac and acinclude.m4 to find -I flags and -L flags for libGL, in case libGL hides in the X11R6 or X11R7 installation.

    My libGL hides in /usr/X11R6 (the silly prefix for my X11R7). After solving some syntax problems my giant configure script (I forgot 'then' after one 'if', and I tried to end one 'for' loop with 'end' instead of 'done'), I have a working --enable-gl-graphics build. (My previous build was --enable-sdl-graphics.) Because my system has OpenGL without acceleration, my GL interface has lag that feels nicely like playing on a remote server.

    TODO - configure.ac can still produce useless binaries with "GL" as the default windowtype, but no GL interface in the binary, because the libpng or sdl check fails. So I need to revise my patch at least one more time.

    --Kernigh, 20 January 2008
    File Added: slashem-make-sdl-2.diff

     

Log in to post a comment.

MongoDB Logo MongoDB