]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Add test for reallocf. 24/head
authorMika Lindqvist <postmaster@raasu.org>
Mon, 11 May 2015 18:43:16 +0000 (21:43 +0300)
committerHans Kristian Rosbach <hk-git@circlestorm.org>
Mon, 11 May 2015 19:13:41 +0000 (21:13 +0200)
Makefile.in
configure

index 9948dcd2e9c624c40451b688103f2062c149e6d9..75e65c3113f2d2a4f043d3de37f4aefc34c128a7 100644 (file)
@@ -48,6 +48,7 @@ SHELL=/bin/sh
 EXE=
 
 SRCDIR=.
+BSDLIBS=
 
 ARCHDIR=arch/generic
 ARCH_STATIC_OBJS=
@@ -134,7 +135,7 @@ infcover.o: $(SRCDIR)/test/infcover.c $(SRCDIR)/zlib.h zconf.h
        $(CC) $(CFLAGS) -I. -I$(SRCDIR) -c -o $@ $(SRCDIR)/test/infcover.c
 
 infcover: infcover.o libz.a
-       $(CC) $(CFLAGS) -o $@ infcover.o libz.a
+       $(CC) $(CFLAGS) -o $@ infcover.o libz.a $(BSDLIBS)
 
 cover: infcover
        rm -f *.gcda
index ff8ec84292b0bb964614deedae6913910a54cf1a..d9e515bdcf27c4d635fdd4ec6981a5228080f45e 100755 (executable)
--- a/configure
+++ b/configure
@@ -533,12 +533,55 @@ EOF
   if tryboth $CC -c $CFLAGS $test.c; then
     CFLAGS="$CFLAGS -DHAVE_HIDDEN"
     SFLAGS="$SFLAGS -DHAVE_HIDDEN"
+    echo >> configure.log
     echo "Checking for attribute(visibility) support... Yes." | tee -a configure.log
   else
+    echo >> configure.log
     echo "Checking for attribute(visibility) support... No." | tee -a configure.log
   fi
 fi
 
+# check where reallocf is defined
+cat > $test.c << EOF
+#include <stdlib.h>
+
+int main()
+{
+   void *p = reallocf(NULL, 255);
+   return p != NULL;
+}
+EOF
+if try $CC -c $CFLAGS -Werror $test.c; then
+  echo "Checking where reallocf is defined... stdlib.h" | tee -a configure.log
+else
+cat > $test.c << EOF
+#include <bsd/stdlib.h>
+
+int main()
+{
+   void *p = reallocf(NULL, 255);
+   return p != NULL;
+}
+EOF
+if try $CC -c $CFLAGS -Werror $test.c; then
+  echo "Checking where reallocf is defined... bsd/stdlib.h" | tee -a configure.log
+  CFLAGS="$CFLAGS -DHAVE_BSD_STDLIB"
+else
+  echo "Checking where reallocf is defined... Not found!" | tee -a configure.log
+fi;
+fi;
+
+# check if we need -lbsd for reallocf
+BSDLIBS=
+if ($CC $CFLAGS -o $test $test.c) 2>> configure.log ; then
+  echo "Checking for reallocf... Yes." | tee -a configure.log
+elif ($CC $CFLAGS -o $test $test.c -lbsd) 2>> configure.log ; then
+  BSDLIBS=-lbsd
+  echo "Checking for reallocf... -lbsd" | tee -a configure.log
+else
+  echo "Checking for reallocf... No." | tee -a configure.log
+fi;
+
 # Check for __builtin_ctzl() support in compiler
 cat > $test.c << EOF
 int main(void)
@@ -692,6 +735,7 @@ echo LDCONFIG = $LDCONFIG >> configure.log
 echo LDFLAGS = $LDFLAGS >> configure.log
 echo LDSHARED = $LDSHARED >> configure.log
 echo LDSHAREDLIBC = $LDSHAREDLIBC >> configure.log
+echo BSDLIBS = $BSDLIBS >> configure.log
 echo OBJC = $OBJC >> configure.log
 echo PIC_OBJC = $PIC_OBJC >> configure.log
 echo RANLIB = $RANLIB >> configure.log
@@ -743,6 +787,7 @@ sed < $SRCDIR/Makefile.in "
 /^includedir *=/s#=.*#=$includedir#
 /^mandir *=/s#=.*#=$mandir#
 /^SRCDIR *=/s#=.*#=$SRCDIR#
+/^BSDLIBS *=/s#=.*#=$BSDLIBS#
 /^OBJC *=/s#=.*#= $OBJC#
 /^PIC_OBJC *=/s#=.*#= $PIC_OBJC#
 /^all: */s#:.*#: $ALL#