Skip to content

Commit

Permalink
build: specify SDL2 header and library paths separately
Browse files Browse the repository at this point in the history
  • Loading branch information
zeim839 committed Nov 27, 2024
1 parent 5182f3b commit a77bfae
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 65 deletions.
103 changes: 68 additions & 35 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -699,8 +699,10 @@ SHELL'
ac_subst_files=''
ac_user_opts='
enable_option_checking
with_sdl_prefix
with_sdl_ttf_prefix
with_sdl_headers
with_sdl_lib
with_sdl_ttf_headers
with_sdl_ttf_lib
'
ac_precious_vars='build_alias
host_alias
Expand Down Expand Up @@ -1327,9 +1329,12 @@ if test -n "$ac_init_help"; then
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-sdl-prefix=DIR Specify the prefix directory for SDL2
--with-sdl-ttf-prefix=DIR
Specify the prefix directory for SDL2_ttf
--with-sdl-headers=DIR Specify the directory containing SDL2 headers
--with-sdl-lib=DIR Specify the directory containing the SDL2 library
--with-sdl-ttf-headers=DIR
Specify the directory containing SDL2_ttf headers
--with-sdl-ttf-lib=DIR Specify the directory containing the SDL2_ttf
library
Some influential environment variables:
CC C compiler command
Expand Down Expand Up @@ -3420,36 +3425,64 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
# User-specified SDL2 path.
# User-specified SDL2 headers path.
# Check whether --with-sdl-prefix was given.
if test ${with_sdl_prefix+y}
# Check whether --with-sdl-headers was given.
if test ${with_sdl_headers+y}
then :
withval=$with_sdl_prefix; sdl_prefix=$withval
withval=$with_sdl_headers; sdl_headers=$withval
else $as_nop
sdl_prefix=""
sdl_headers=""
fi
if test -n "$sdl_prefix"; then
CFLAGS="$CFLAGS -I$sdl_prefix/include"
LDFLAGS="$LDFLAGS -L$sdl_prefix/lib"
if test -n "$sdl_headers"; then
CFLAGS="$CFLAGS -I$sdl_headers"
fi
# User-specified SDL2_ttf path.
# User-specified SDL2 libraries path.
# Check whether --with-sdl-ttf-prefix was given.
if test ${with_sdl_ttf_prefix+y}
# Check whether --with-sdl-lib was given.
if test ${with_sdl_lib+y}
then :
withval=$with_sdl_ttf_prefix; sdl_ttf_prefix=$withval
withval=$with_sdl_lib; sdl_lib=$withval
else $as_nop
sdl_ttf_prefix=""
sdl_lib=""
fi
if test -n "$sdl_ttf_prefix"; then
CFLAGS="$CFLAGS -I$sdl_ttf_prefix/include/SDL2"
LDFLAGS="$LDFLAGS -L$sdl_ttf_prefix/lib"
if test -n "$sdl_lib"; then
LDFLAGS="$LDFLAGS -L$sdl_lib"
fi
# User-specified SDL2_ttf headers path.
# Check whether --with-sdl-ttf-headers was given.
if test ${with_sdl_ttf_headers+y}
then :
withval=$with_sdl_ttf_headers; sdl_ttf_headers=$withval
else $as_nop
sdl_ttf_headers=""
fi
if test -n "$sdl_ttf_headers"; then
CFLAGS="$CFLAGS -I$sdl_ttf_headers"
fi
# User-specified SDL2 libraries path.
# Check whether --with-sdl-ttf-lib was given.
if test ${with_sdl_ttf_lib+y}
then :
withval=$with_sdl_ttf_lib; sdl_ttf_lib=$withval
else $as_nop
sdl_ttf_lib=""
fi
if test -n "$sdl_ttf_lib"; then
LDFLAGS="$LDFLAGS -L$sdl_ttf_lib"
fi
# Validate SDL2 installation.
Expand Down Expand Up @@ -3483,13 +3516,13 @@ then :
printf "%s\n" "#define STDC_HEADERS 1" >>confdefs.h
fi
ac_fn_c_check_header_compile "$LINENO" "SDL2/SDL_ttf.h" "ac_cv_header_SDL2_SDL_ttf_h" "$ac_includes_default"
if test "x$ac_cv_header_SDL2_SDL_ttf_h" = xyes
ac_fn_c_check_header_compile "$LINENO" "SDL_ttf.h" "ac_cv_header_SDL_ttf_h" "$ac_includes_default"
if test "x$ac_cv_header_SDL_ttf_h" = xyes
then :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: SDL2_ttf headers found" >&5
printf "%s\n" "$as_me: SDL2_ttf headers found" >&6;}
else $as_nop
as_fn_error $? "SDL2_ttf headers not found in $sdl_ttf_prefix/include/SDL2" "$LINENO" 5
as_fn_error $? "SDL2_ttf headers not found in $sdl_ttf_headers" "$LINENO" 5
fi
Expand Down Expand Up @@ -3533,17 +3566,17 @@ then :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: SDL2_ttf library found" >&5
printf "%s\n" "$as_me: SDL2_ttf library found" >&6;}
else $as_nop
as_fn_error $? "SDL2_ttf library not found in $sdl_ttf_prefix/lib" "$LINENO" 5
as_fn_error $? "SDL2_ttf library not found in $sdl_ttf_lib" "$LINENO" 5
fi
ac_fn_c_check_header_compile "$LINENO" "SDL2/SDL.h" "ac_cv_header_SDL2_SDL_h" "$ac_includes_default"
if test "x$ac_cv_header_SDL2_SDL_h" = xyes
ac_fn_c_check_header_compile "$LINENO" "SDL.h" "ac_cv_header_SDL_h" "$ac_includes_default"
if test "x$ac_cv_header_SDL_h" = xyes
then :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: SDL2 headers found" >&5
printf "%s\n" "$as_me: SDL2 headers found" >&6;}
else $as_nop
as_fn_error $? "SDL2 headers not found in $sdl_prefix/include/SDL2" "$LINENO" 5
as_fn_error $? "SDL2 headers not found in $sdl_headers" "$LINENO" 5
fi
Expand Down Expand Up @@ -3587,7 +3620,7 @@ then :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: SDL2 library found" >&5
printf "%s\n" "$as_me: SDL2 library found" >&6;}
else $as_nop
as_fn_error $? "SDL2 library not found in $sdl_prefix/lib" "$LINENO" 5
as_fn_error $? "SDL2 library not found in $sdl_lib" "$LINENO" 5
fi
Expand All @@ -3610,16 +3643,16 @@ then :
printf "%s\n" "#define HAVE_TIME_H 1" >>confdefs.h
fi
ac_fn_c_check_header_compile "$LINENO" "SDL2/SDL.h" "ac_cv_header_SDL2_SDL_h" "$ac_includes_default"
if test "x$ac_cv_header_SDL2_SDL_h" = xyes
ac_fn_c_check_header_compile "$LINENO" "SDL.h" "ac_cv_header_SDL_h" "$ac_includes_default"
if test "x$ac_cv_header_SDL_h" = xyes
then :
printf "%s\n" "#define HAVE_SDL2_SDL_H 1" >>confdefs.h
printf "%s\n" "#define HAVE_SDL_H 1" >>confdefs.h
fi
ac_fn_c_check_header_compile "$LINENO" "SDL2/SDL_ttf.h" "ac_cv_header_SDL2_SDL_ttf_h" "$ac_includes_default"
if test "x$ac_cv_header_SDL2_SDL_ttf_h" = xyes
ac_fn_c_check_header_compile "$LINENO" "SDL_ttf.h" "ac_cv_header_SDL_ttf_h" "$ac_includes_default"
if test "x$ac_cv_header_SDL_ttf_h" = xyes
then :
printf "%s\n" "#define HAVE_SDL2_SDL_TTF_H 1" >>confdefs.h
printf "%s\n" "#define HAVE_SDL_TTF_H 1" >>confdefs.h
fi
ac_fn_c_check_header_compile "$LINENO" "stdarg.h" "ac_cv_header_stdarg_h" "$ac_includes_default"
Expand Down
72 changes: 46 additions & 26 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -8,51 +8,71 @@ AC_CONFIG_HEADERS([src/config.h])
AC_PROG_CC
AC_PROG_INSTALL

# User-specified SDL2 path.
AC_ARG_WITH([sdl-prefix],
[AS_HELP_STRING([--with-sdl-prefix=DIR],
[Specify the prefix directory for SDL2])],
[sdl_prefix=$withval],
[sdl_prefix=""])

if test -n "$sdl_prefix"; then
CFLAGS="$CFLAGS -I$sdl_prefix/include"
LDFLAGS="$LDFLAGS -L$sdl_prefix/lib"
# User-specified SDL2 headers path.
AC_ARG_WITH([sdl-headers],
[AS_HELP_STRING([--with-sdl-headers=DIR],
[Specify the directory containing SDL2 headers])],
[sdl_headers=$withval],
[sdl_headers=""])

if test -n "$sdl_headers"; then
CFLAGS="$CFLAGS -I$sdl_headers"
fi

# User-specified SDL2 libraries path.
AC_ARG_WITH([sdl-lib],
[AS_HELP_STRING([--with-sdl-lib=DIR],
[Specify the directory containing the SDL2 library])],
[sdl_lib=$withval],
[sdl_lib=""])

if test -n "$sdl_lib"; then
LDFLAGS="$LDFLAGS -L$sdl_lib"
fi

# User-specified SDL2_ttf headers path.
AC_ARG_WITH([sdl-ttf-headers],
[AS_HELP_STRING([--with-sdl-ttf-headers=DIR],
[Specify the directory containing SDL2_ttf headers])],
[sdl_ttf_headers=$withval],
[sdl_ttf_headers=""])

if test -n "$sdl_ttf_headers"; then
CFLAGS="$CFLAGS -I$sdl_ttf_headers"
fi

# User-specified SDL2_ttf path.
AC_ARG_WITH([sdl-ttf-prefix],
[AS_HELP_STRING([--with-sdl-ttf-prefix=DIR],
[Specify the prefix directory for SDL2_ttf])],
[sdl_ttf_prefix=$withval],
[sdl_ttf_prefix=""])
# User-specified SDL2 libraries path.
AC_ARG_WITH([sdl-ttf-lib],
[AS_HELP_STRING([--with-sdl-ttf-lib=DIR],
[Specify the directory containing the SDL2_ttf library])],
[sdl_ttf_lib=$withval],
[sdl_ttf_lib=""])

if test -n "$sdl_ttf_prefix"; then
CFLAGS="$CFLAGS -I$sdl_ttf_prefix/include/SDL2"
LDFLAGS="$LDFLAGS -L$sdl_ttf_prefix/lib"
if test -n "$sdl_ttf_lib"; then
LDFLAGS="$LDFLAGS -L$sdl_ttf_lib"
fi

# Validate SDL2 installation.
AC_CHECK_HEADER([SDL2/SDL_ttf.h],
AC_CHECK_HEADER([SDL_ttf.h],
[AC_MSG_NOTICE([SDL2_ttf headers found])],
[AC_MSG_ERROR([SDL2_ttf headers not found in $sdl_ttf_prefix/include/SDL2])])
[AC_MSG_ERROR([SDL2_ttf headers not found in $sdl_ttf_headers])])

AC_CHECK_LIB([SDL2_ttf], [TTF_Init],
[AC_MSG_NOTICE([SDL2_ttf library found])],
[AC_MSG_ERROR([SDL2_ttf library not found in $sdl_ttf_prefix/lib])])
[AC_MSG_ERROR([SDL2_ttf library not found in $sdl_ttf_lib])])

AC_CHECK_HEADER([SDL2/SDL.h],
AC_CHECK_HEADER([SDL.h],
[AC_MSG_NOTICE([SDL2 headers found])],
[AC_MSG_ERROR([SDL2 headers not found in $sdl_prefix/include/SDL2])])
[AC_MSG_ERROR([SDL2 headers not found in $sdl_headers])])

AC_CHECK_LIB([SDL2], [SDL_Init],
[AC_MSG_NOTICE([SDL2 library found])],
[AC_MSG_ERROR([SDL2 library not found in $sdl_prefix/lib])])
[AC_MSG_ERROR([SDL2 library not found in $sdl_lib])])

# Checks for header files.
AC_CHECK_HEADERS([
stdlib.h stdint.h time.h
SDL2/SDL.h SDL2/SDL_ttf.h
SDL.h SDL_ttf.h
stdarg.h stdio.h
])

Expand Down
8 changes: 4 additions & 4 deletions src/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H

/* Define to 1 if you have the <SDL2/SDL.h> header file. */
#undef HAVE_SDL2_SDL_H
/* Define to 1 if you have the <SDL.h> header file. */
#undef HAVE_SDL_H

/* Define to 1 if you have the <SDL2/SDL_ttf.h> header file. */
#undef HAVE_SDL2_SDL_TTF_H
/* Define to 1 if you have the <SDL_ttf.h> header file. */
#undef HAVE_SDL_TTF_H

/* Define to 1 if you have the <stdarg.h> header file. */
#undef HAVE_STDARG_H
Expand Down

0 comments on commit a77bfae

Please sign in to comment.