configure: fix some ordering issues
authornotaz <notasas@gmail.com>
Thu, 2 Aug 2012 22:38:51 +0000 (01:38 +0300)
committernotaz <notasas@gmail.com>
Thu, 2 Aug 2012 22:45:11 +0000 (01:45 +0300)
Makefile
configure

index 61bec8b..c10f739 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@
 # default stuff goes here, so that config can override
 TARGET = pcsx
 CFLAGS += -Wall -ggdb -Ifrontend -ffast-math
-LDLIBS += -lpthread -lm
+LDLIBS += -lpthread
 ifndef DEBUG
 CFLAGS += -O2 -DNDEBUG
 endif
index f5e3b6f..0618ac2 100755 (executable)
--- a/configure
+++ b/configure
@@ -47,6 +47,7 @@ have_armv7=""
 have_arm_neon=""
 have_tslib=""
 enable_dynarec="yes"
+need_sdl="no"
 # these are for known platforms
 optimize_cortexa8="no"
 optimize_arm926ej="no"
@@ -56,7 +57,7 @@ CC="${CC-${CROSS_COMPILE}gcc}"
 CXX="${CXX-${CROSS_COMPILE}g++}"
 AS="${AS-${CROSS_COMPILE}as}"
 AR="${AS-${CROSS_COMPILE}ar}"
-MAIN_LDLIBS="$LDLIBS -ldl -lpng -lz"
+MAIN_LDLIBS="$LDLIBS -ldl -lm"
 config_mak="config.mak"
 
 fail()
@@ -247,10 +248,7 @@ fi
 
 case "$platform" in
 generic)
-  generic_cflags=`sdl-config --cflags`
-  generic_ldlibs=`sdl-config --libs`
-  CFLAGS="$CFLAGS $generic_cflags"
-  MAIN_LDLIBS="$MAIN_LDLIBS $generic_ldlibs"
+  need_sdl="yes"
   ;;
 maemo)
   maemo_cflags=`pkg-config --cflags hildon-1`
@@ -320,27 +318,38 @@ EOF
   compile_binary "$@"
 }
 
-check_zlib || fail "please install libz-dev"
-check_bzlib || fail "please install libbz2-dev"
-check_libpng || fail "please install libpng-dev"
+MAIN_LDLIBS="$MAIN_LDLIBS -lz"
+check_zlib || fail "please install zlib/libz-dev"
+
+check_bzlib || fail "please install bz2lib/libbz2-dev"
+
+MAIN_LDLIBS="-lpng $MAIN_LDLIBS"
+check_libpng || fail "please install libpng/libpng-dev"
 
 # find what audio support we can compile
 if [ "x$sound_drivers" = "x" ]; then
   if check_oss; then sound_drivers="$sound_drivers oss"; fi
-  if check_alsa -lasound; then sound_drivers="$sound_drivers alsa"; fi
-  if check_sdl; then sound_drivers="$sound_drivers sdl"; fi
+  if check_alsa -lasound; then
+    sound_drivers="$sound_drivers alsa"
+    MAIN_LDLIBS="-lasound $MAIN_LDLIBS"
+  fi
+  if [ "$need_sdl" == "yes" ] || check_sdl `sdl-config --cflags -libs`; then
+    sound_drivers="$sound_drivers sdl"
+    need_sdl="yes"
+  fi
+else
+  if echo $sound_drivers | grep -q "\<oss\>"; then
+    check_oss || fail "oss support is missing"
+  fi
+  if echo $sound_drivers | grep -q "\<alsa\>"; then
+    MAIN_LDLIBS="-lasound $MAIN_LDLIBS"
+    check_alsa || fail "please install libasound2-dev"
+  fi
 fi
 
-if echo $sound_drivers | grep -q "\<oss\>"; then
-  check_oss || fail "oss support missing"
-fi
-if echo $sound_drivers | grep -q "\<alsa\>"; then
-  MAIN_LDLIBS="$MAIN_LDLIBS -lasound"
-  check_alsa || fail "please install libasound2-dev"
-fi
-if echo $sound_drivers | grep -q "\<sdl\>"; then
-  echo $MAIN_LDLIBS | grep -qi SDL || CFLAGS="$CFLAGS `sdl-config --cflags`"
-  echo $MAIN_LDLIBS | grep -qi SDL || MAIN_LDLIBS="$MAIN_LDLIBS `sdl-config --libs`"
+if [ "$need_sdl" == "yes" ]; then
+  CFLAGS="$CFLAGS `sdl-config --cflags`"
+  MAIN_LDLIBS="`sdl-config --libs` $MAIN_LDLIBS"
   check_sdl || fail "please install libsdl1.2-dev"
 fi