Menu

#218 Try finding SDL2 with pkg-config before sdl2-config

v3.x
closed-accepted
compyx
None
bugfix
2020-12-01
2020-03-04
No

As discussed on IRC, pkg-config handles cross-compiling a lot better than sdl2-config does. I did not give SDL1 the same treatment because the logic around this seems much more complex and I don't really care about it anyway! The patch is actually simpler than it looks because it's mostly whitespace changes.

1 Attachments

Discussion

  • Greg King

    Greg King - 2020-03-05

    I think that you should remove the SDL2 prefix stuff -- it's pointless! VICE never will need a prefix! sdl2.pc and sdl2-config always point directly to the headers directory.

     
    • James Le Cuirot

      James Le Cuirot - 2020-03-05

      I would agree but the MacOS case gets in the way. I'm not very familiar with the platform so I don't really know what this "framework" stuff is but if I change <SDL2/SDL.h> to just <SDL.h> here then it won't work and I don't think -F$FW_DIR/SDL2 will work either.

          CFLAGS="$VICE_FLAGS -F$FW_DIR"
          CXXFLAGS="$VICE_CXXFLAGS -F$FW_DIR"
          LIBS="$LIBS -F$FW_DIR -framework SDL2"
      
          AC_MSG_CHECKING(for SDL2.framework)
          AC_TRY_LINK([#include <SDL2/SDL.h>],
                      [SDL_GetNumRenderDrivers()],
                      [AC_MSG_RESULT(yes);
                       use_sdl_prefix=no;
                       use_sdl2_prefix=yes;
                       found_sdl2=yes;
                       VICE_CFLAGS="$CFLAGS";
                       VICE_CXXFLAGS="$CXXFLAGS"],
                      [AC_MSG_RESULT(no);
                       LIBS=$old_libs])
      
       
  • James Le Cuirot

    James Le Cuirot - 2020-09-09

    Ping? Carrying this patch in Gentoo is annoying as we have to do an autoreconf and that's particularly awkward when there are multiple configure scripts. I know the issue above was not resolved but this is still an improvement regardless.

     
  • gpz

    gpz - 2020-09-10

    What exactly is the problem that is fixed here? I am using gentoo myself, and never had a problem building any of the ports shrug

     
    • James Le Cuirot

      James Le Cuirot - 2020-09-10

      As mentioned above, it helps with more exotic situations like cross-compiling. For example, if you use sdl2-config, it will add -I/usr/include/SDL2 instead of -I/path/to/cross/system/usr/include/SDL2. pkg-config is much smarter than this. I'm Gentoo's "cross guy" so I deal with this sort of thing a lot. I even had curl upstream admit that pkg-config should generally be used over their own curl-config script the other day.

       

      Last edit: James Le Cuirot 2020-09-10
  • compyx

    compyx - 2020-10-04

    I'd like to get this patch in before 3.5, but I cannot check if it breaks on MacOS. Perhaps @dqh can have a peek to see if there's any breakage to be expected on MacOS?

     
  • compyx

    compyx - 2020-11-10

    Have we had any progress on this?

     
  • dqh

    dqh - 2020-11-11

    so the patch appears to work fine on macOS + macports. I discovered that sdl2_image isn't being found when mac deps are installed using homebrew, but we also have this problem in the unpatched configure.ac so this patch isn't at fault.

    The SDL2 folder prefix thing appears to be needed on macOS for both macports and homebrew.

     
    • dqh

      dqh - 2020-11-11

      actually nope. SDL2 prefix isn't needed on mac

       
  • compyx

    compyx - 2020-11-28

    Looks like this patch was implemented, more or less. The patch is against configure.proto, which doesn't exist anymore, but we do now using pkg-config for SDL2, the sdl2-config stuff has been removed in current configure.ac.

    So can we close this as 'accepted', if only just for pointing us in the right direction?

     
  • compyx

    compyx - 2020-11-28

    Also, since I've added a dependency on SDL2_image, which needs to be checked for by pkg-config, not sdl2-config, the whole sdl2-config stuff seems moot.

     
  • James Le Cuirot

    James Le Cuirot - 2020-11-28

    I've seen the changes now and they look great but I haven't tried them yet. I trust they work though so please go ahead and close this.

     
  • compyx

    compyx - 2020-12-01
    • status: open --> closed-accepted
     
  • compyx

    compyx - 2020-12-01

    Indeed this works for me on Linux, Windows and even Haiku. Closing.

     

Log in to post a comment.

MongoDB Logo MongoDB