$NetBSD: patch-ad,v 1.19 2015/11/18 14:09:25 ryoon Exp $

*BSD and qnx are identified as linux.
Add another SDK path on Mac OS X.
All sparc cpus can not do unaligned access.
Detect NetBSD ARMv7 hardfloat toolchain.

--- build/make/configure.sh.orig	2015-11-09 22:12:38.000000000 +0000
+++ build/make/configure.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/pkg/bin/bash
 ##
 ##  configure.sh
 ##
@@ -647,7 +647,7 @@ process_common_toolchain() {
       armv6*)
         tgt_isa=armv6
         ;;
-      armv7*-hardfloat*)
+      armv7*-hardfloat*|armv7*-netbsd*-*hf)
         tgt_isa=armv7
         float_abi=hard
         ;;
@@ -695,7 +695,7 @@ process_common_toolchain() {
         [ -z "$tgt_isa" ] && tgt_isa=x86
         tgt_os=win32
         ;;
-      *linux*|*bsd*)
+      *linux*|*bsd*|*qnx6*)
         tgt_os=linux
         ;;
       *solaris2.10)
@@ -738,6 +738,9 @@ process_common_toolchain() {
     mips*)
       enable_feature mips
       ;;
+    sparc*)
+      disable_feature fast_unaligned
+      ;;
   esac
 
   # PIC is probably what we want when building shared libs
@@ -869,7 +872,7 @@ process_common_toolchain() {
 
       case ${tgt_cc} in
         gcc)
-          CROSS=${CROSS:-arm-none-linux-gnueabi-}
+#          CROSS=${CROSS:-arm-none-linux-gnueabi-}
           link_with_cc=gcc
           setup_gnu_toolchain
           arch_int=${tgt_isa##armv}
@@ -1338,7 +1341,7 @@ EOF
   check_cc <<EOF
 unsigned int e = 'O'<<24 | '2'<<16 | 'B'<<8 | 'E';
 EOF
-    [ -f "${TMP_O}" ] && od -A n -t x1 "${TMP_O}" | tr -d '\n' |
+    [ -f "${TMP_O}" ] && od -t x1 "${TMP_O}" | tr -d '\n' |
         grep '4f *32 *42 *45' >/dev/null 2>&1 && enable_feature big_endian
 
     # Try to find which inline keywords are supported
@@ -1354,11 +1357,33 @@ EOF
       *-android-gcc)
         ;;
       *)
-        check_header pthread.h && add_extralibs -lpthread
+        check_header pthread.h && add_extralibs ${PTHREAD_LDFLAGS} ${PTHREAD_LIBS}
         ;;
     esac
   fi
 
+  case ${tgt_os} in
+  darwin*)
+     add_extralibs -lm
+     ;;
+  solaris*)
+     add_extralibs -lm -lrt
+     ;;
+  linux*)
+     case ${gcctarget} in
+     *qnx6*)
+         add_extralibs -lm
+         ;;
+     *openbsd*)
+         add_extralibs -lm
+         ;;
+     *)
+         add_extralibs -lm -lrt
+         ;;
+     esac
+     ;;
+  esac
+
   # only for MIPS platforms
   case ${toolchain} in
     mips*)
