Made configure use the native libgc if available. Saves 40k on the exec.
authormichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 2 Feb 2000 06:10:06 +0000 (06:10 +0000)
committermichaelh <michaelh@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 2 Feb 2000 06:10:06 +0000 (06:10 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@60 4a8a32a2-be11-0410-ad9d-d568d2c75423

Makefile.common.in
configure
configure.in
sdccconf_in.h
src/Makefile.in

index 73ef6bec513c0911675064559b29653ca6a07aef..0a8a494df21abdbc24837cd1607fc61318e7a0cd 100644 (file)
@@ -34,8 +34,13 @@ infodir         = @infodir@
 srcdir          = @srcdir@
 
 # Flags
+HAVE_LIBGC     = @HAVE_LIBGC@
 DEFS            = $(subs -DHAVE_CONFIG_H,,@DEFS@)
-CPPFLAGS        = @CPPFLAGS@ -I$(PRJDIR) -I$(PRJDIR)/support
+CPPFLAGS        = @CPPFLAGS@ -I$(PRJDIR)
+ifeq ($(HAVE_LIBGC),1)
+else
+CPPFLAGS       += -I$(PRJDIR)/support
+endif
 CFLAGS          = @CFLAGS@ -Wall
 M_OR_MM         = @M_OR_MM@
 
index b3ef23a5c45cd31ba4c6f1ed1147b28e29f44d6d..26cab167926911fc8855aa24e23f1e0087f92356 100755 (executable)
--- a/configure
+++ b/configure
@@ -523,7 +523,7 @@ fi
 
 
 
-for ac_prog in gawk mawk nawk awk
+for ac_prog in mawk gawk nawk awk
 do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
@@ -2447,6 +2447,48 @@ cat >> confdefs.h <<EOF
 EOF
 
 
+# mlh: dont compile libgc if it's available locally
+echo $ac_n "checking for GC_malloc in -lgc""... $ac_c" 1>&6
+echo "configure:2453: checking for GC_malloc in -lgc" >&5
+ac_lib_var=`echo gc'_'GC_malloc | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-lgc  $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 2461 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char GC_malloc();
+
+int main() {
+GC_malloc()
+; return 0; }
+EOF
+if { (eval echo configure:2472: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  HAVE_LIBGC=1
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+
 
 # Generating output files
 # ===========================================================================
@@ -2613,6 +2655,7 @@ s%@AUTOCONF@%$AUTOCONF%g
 s%@AS@%$AS%g
 s%@CP@%$CP%g
 s%@M_OR_MM@%$M_OR_MM%g
+s%@HAVE_LIBGC@%$HAVE_LIBGC%g
 s%@subdirs@%$subdirs%g
 
 CEOF
index 0469622c43723fb14a98f1ab746c42481fb4e628..8cda52be13a2391225a13d3d441c0b317dabcacf 100755 (executable)
@@ -189,6 +189,9 @@ AC_DEFINE_UNQUOTED(PREFIX, "${prefix}")
 AC_DEFINE_UNQUOTED(DATADIR, "${sdcc_datadir}")
 AC_DEFINE_UNQUOTED(SRCDIR, "${config_in}")
 
+# mlh: dont compile libgc if it's available locally
+AC_CHECK_LIB(gc,GC_malloc,HAVE_LIBGC=1)
+AC_SUBST(HAVE_LIBGC)
 
 # Generating output files
 # ===========================================================================
index 80abeae0bbab1d665e43e61cab106168bc74ed2f..c1a64fc814349475c9cc60705c6bb6355bb28ce8 100644 (file)
@@ -24,7 +24,6 @@
 #undef HAVE_SYS_SOCKET_H
 #undef HAVE_SYS_ISA_DEFS_H
 #undef HAVE_ENDIAN_H
-
 #endif
 
 /* End of config.h */
index 6d0e631ce6a1ba7680d8c83cdd790fda81761036..302309cee864246d0ed3d1b952b00e71e057ca1e 100644 (file)
@@ -10,7 +10,11 @@ PORTS                = mcs51 z80
 PORT_LIBS      = $(PORTS:%=%/port.a)
 
 LIBS           = -lgc @LIBS@
+ifeq ($(HAVE_LIBGC), 1)
+else
 LIBDIRS                = -L$(PRJDIR)/support/gc
+LIBGC          = $(PRJDIR)/support/gc/libgc.a
+endif
 
 OBJECTS        = SDCCy.o SDCClex.o SDCCerr.o SDCChasht.o SDCCmain.o \
                  SDCCsymt.o SDCCopt.o SDCCast.o SDCCmem.o SDCCval.o \
@@ -23,7 +27,7 @@ TARGET                = $(PRJDIR)/bin/sdcc
 
 # Compiling entire program or any subproject
 # ------------------------------------------
-all: ports checkconf $(PRJDIR)/support/gc/libgc.a $(TARGET)
+all: ports checkconf $(LIBGC) $(TARGET)
 
 ports:
        for i in $(PORTS); do $(MAKE) -C $$i; done