From 5c2bdee638bae9ecf59f628e9543624e1fd76d7c Mon Sep 17 00:00:00 2001 From: michaelh Date: Wed, 2 Feb 2000 06:10:06 +0000 Subject: [PATCH 1/1] Made configure use the native libgc if available. Saves 40k on the exec. git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@60 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- Makefile.common.in | 7 ++++++- configure | 45 ++++++++++++++++++++++++++++++++++++++++++++- configure.in | 3 +++ sdccconf_in.h | 1 - src/Makefile.in | 6 +++++- 5 files changed, 58 insertions(+), 4 deletions(-) diff --git a/Makefile.common.in b/Makefile.common.in index 73ef6bec..0a8a494d 100644 --- a/Makefile.common.in +++ b/Makefile.common.in @@ -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@ diff --git a/configure b/configure index b3ef23a5..26cab167 100755 --- 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 <&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 <&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 diff --git a/configure.in b/configure.in index 0469622c..8cda52be 100755 --- a/configure.in +++ b/configure.in @@ -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 # =========================================================================== diff --git a/sdccconf_in.h b/sdccconf_in.h index 80abeae0..c1a64fc8 100644 --- a/sdccconf_in.h +++ b/sdccconf_in.h @@ -24,7 +24,6 @@ #undef HAVE_SYS_SOCKET_H #undef HAVE_SYS_ISA_DEFS_H #undef HAVE_ENDIAN_H - #endif /* End of config.h */ diff --git a/src/Makefile.in b/src/Makefile.in index 6d0e631c..302309ce 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -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 -- 2.30.2