| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
if test "x$CC" = "x"; then |
| 4 |
CC=cc |
| 5 |
fi |
| 6 |
|
| 7 |
machine="$($CC -dumpmachine)" |
| 8 |
case "$machine" in |
| 9 |
*mingw* ) |
| 10 |
EXEPREFIX="" |
| 11 |
EXESUFFIX=".exe" |
| 12 |
;; |
| 13 |
*android* ) |
| 14 |
EXEPREFIX="lib" |
| 15 |
EXESUFFIX=".so" |
| 16 |
LDFLAGS="$LDFLAGS -shared" |
| 17 |
;; |
| 18 |
* ) |
| 19 |
EXEPREFIX="" |
| 20 |
EXESUFFIX="" |
| 21 |
;; |
| 22 |
esac |
| 23 |
|
| 24 |
set -e |
| 25 |
|
| 26 |
test_static=yes |
| 27 |
if [ "x$1" = "x--no-static" ]; then |
| 28 |
test_static=no |
| 29 |
fi |
| 30 |
|
| 31 |
# Get the canonical path of the folder containing this script |
| 32 |
testdir=$(cd -P -- "$(dirname -- "$0")" && printf '%s\n' "$(pwd -P)") |
| 33 |
SDL_CFLAGS="$( sdl2-config --cflags )" |
| 34 |
SDL_LDFLAGS="$( sdl2-config --libs )" |
| 35 |
if [ "x$test_static" = "xyes" ]; then |
| 36 |
SDL_STATIC_LDFLAGS="$( sdl2-config --static-libs )" |
| 37 |
fi |
| 38 |
|
| 39 |
compile_cmd="$CC -c "$testdir/main_gui.c" -o main_gui_sdlconfig.c.o $CFLAGS $SDL_CFLAGS" |
| 40 |
link_cmd="$CC main_gui_sdlconfig.c.o -o ${EXEPREFIX}main_gui_sdlconfig${EXESUFFIX} $SDL_LDFLAGS $LDFLAGS" |
| 41 |
if [ "x$test_static" = "xyes" ]; then |
| 42 |
static_link_cmd="$CC main_gui_sdlconfig.c.o -o ${EXEPREFIX}main_gui_sdlconfig_static${EXESUFFIX} $SDL_STATIC_LDFLAGS $LDFLAGS" |
| 43 |
fi |
| 44 |
|
| 45 |
echo "-- CC: $CC" |
| 46 |
echo "-- CFLAGS: $CFLAGS" |
| 47 |
echo "-- LDFLAGS: $LDFLAGS" |
| 48 |
echo "-- SDL_CFLAGS: $SDL_CFLAGS" |
| 49 |
echo "-- SDL_LDFLAGS: $SDL_LDFLAGS" |
| 50 |
if [ "x$test_static" = "xyes" ]; then |
| 51 |
echo "-- SDL_STATIC_LDFLAGS: $SDL_STATIC_LDFLAGS" |
| 52 |
fi |
| 53 |
|
| 54 |
echo "-- COMPILE: $compile_cmd" |
| 55 |
echo "-- LINK: $link_cmd" |
| 56 |
if [ "x$test_static" = "xyes" ]; then |
| 57 |
echo "-- STATIC_LINK: $static_link_cmd" |
| 58 |
fi |
| 59 |
|
| 60 |
set -x |
| 61 |
|
| 62 |
$compile_cmd |
| 63 |
$link_cmd |
| 64 |
if [ "x$test_static" = "xyes" ]; then |
| 65 |
$static_link_cmd |
| 66 |
fi |