This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC] Adding bison, lex, etc. build modules?


What the toplevel configure is doing currently to find development tools
like yacc is:

1) find a yacc using Autoconf (DEFAULT_YACC).  This will be a build
yacc, not a host yacc!
2) for a Canadian, find a "reasonable" build yacc (YACC).  This is bogus
because we already have one in DEFAULT_YACC.
3) for a non Canadian, look if a host yacc was compiled, else use the
DEFAULT_YACC that was found by Autoconf (USUAL_YACC, to which YACC expands)

Plus, BISON and M4 are handled differently than LEX/YACC/MAKEINFO.

After Nathanael's work, adding modules is easy, so it seems to me that
it is much better to make yacc a build module (for Canadian crosses),
and then

1) find a yacc using Autoconf (CONFIGURED_YACC)
2) look if a build (for Canadian) or host (for non Canadian) yacc was
compiled.  If not, use the CONFIGURED_YACC.

This also provides a way to fix in a more elegant way the Texinfo bug
that was reported by Corinna Vinschen.  Just make sure with the
appropriate dependencies that the build texinfo is built before anything
else that has Texinfo manuals, and pick the in-tree makeinfo if the
Makefile exists (rather than the actual program).

Would something like the attached patch be acceptable?  To test it, is
it ok to build a native configuration and a Canadian cross, add check
manually that the bison/flex/texinfo that are invoked are always those
in the tree?

Paolo

2004-06-23 Paolo Bonzini <bonzini@gnu.org>

	* configure.in (BISON, MAKEINFO, LEX, YACC): Don't set them.
	(CC): Use AC_PROG_CC to set it.
	(DEFAULT_YACC, DEFAULT_M4, DEFAULT_LEX): Rename to...
	(CONFIGURED_YACC, CONFIGURED_M4, CONFIGURED_LEX): ... this.
	(CONFIGURED_BISON, CONFIGURED_MAKEINFO): Find these as well.
	(BUILD_DIR_PREFIX): New variable.
	* Makefile.def (bison, byacc, lex, m4, texinfo): Add as build
	modules.
	* Makefile.tpl (USUAL_BISON, USUAL_YACC, USUAL_LEX,
	USUAL_MAKEINFO): Remove.
	(BISON, YACC, LEX, M4, MAKEINFO): Look in the build directory,
	else resort to those found by configure.
	(CONFIGURED_YACC, CONFIGURED_M4, CONFIGURED_LEX,
	(CONFIGURED_BISON, CONFIGURED_MAKEINFO, BUILD_DIR_PREFIX): Set
	from substituted variables.
	(all-build-bison, all-build-m4, all-build-flex,
	all-build-texinfo): Add dependencies.









Index: configure.in
===================================================================
RCS file: /cvs/src/src/configure.in,v
retrieving revision 1.222
diff -u -r1.222 configure.in
*** configure.in	22 Jun 2004 01:38:35 -0000	1.222
--- configure.in	23 Jun 2004 09:32:10 -0000
***************
*** 956,962 ****
    # If we are doing a Canadian Cross, in which the host and build systems
    # are not the same, we set reasonable default values for the tools.
  
-   BISON=${BISON-bison}
    CC=${CC-${host_alias}-gcc}
    CFLAGS=${CFLAGS-"-g -O2"}
    CXX=${CXX-${host_alias}-c++}
--- 956,961 ----
***************
*** 966,1014 ****
    CXX_FOR_TARGET=${CXX_FOR_TARGET-${target_alias}-c++}
    GCJ_FOR_TARGET=${GCJ_FOR_TARGET-${target_alias}-gcj}
    GCC_FOR_TARGET=${GCC_FOR_TARGET-${CC_FOR_TARGET-${target_alias}-gcc}}
    BUILD_PREFIX=${build_alias}-
    BUILD_PREFIX_1=${build_alias}-
-   MAKEINFO=${MAKEINFO-makeinfo}
- 
-   if test -z "${YACC}" ; then
-     IFS="${IFS= 	}"; save_ifs="$IFS"; IFS="${IFS}:"
-     for dir in $PATH; do
-       test -z "$dir" && dir=.
-       if test -f $dir/bison; then
- 	YACC="bison -y"
- 	break
-       fi
-       if test -f $dir/byacc; then
- 	YACC=byacc
- 	break
-       fi
-       if test -f $dir/yacc; then
- 	YACC=yacc
- 	break
-       fi
-     done
-     IFS="$save_ifs"
-     if test -z "${YACC}" ; then
-       YACC="bison -y"
-     fi
-   fi
- 
-   if test -z "${LEX}" ; then
-     IFS="${IFS= 	}"; save_ifs="$IFS"; IFS="${IFS}:"
-     for dir in $PATH; do
-       test -z "$dir" && dir=.
-       if test -f $dir/flex; then
- 	LEX=flex
- 	break
-       fi
-       if test -f $dir/lex; then
- 	LEX=lex
- 	break
-       fi
-     done
-     IFS="$save_ifs"
-     LEX=${LEX-flex}
-   fi
  
  else
    # Set reasonable default values for some tools even if not Canadian.
--- 965,973 ----
    CXX_FOR_TARGET=${CXX_FOR_TARGET-${target_alias}-c++}
    GCJ_FOR_TARGET=${GCJ_FOR_TARGET-${target_alias}-gcj}
    GCC_FOR_TARGET=${GCC_FOR_TARGET-${CC_FOR_TARGET-${target_alias}-gcc}}
+   BUILD_DIR_PREFIX=${build_subdir}
    BUILD_PREFIX=${build_alias}-
    BUILD_PREFIX_1=${build_alias}-
  
  else
    # Set reasonable default values for some tools even if not Canadian.
***************
*** 1019,1089 ****
    # in Makefile.in, so can still be overridden by fragments.
    # This is all going to change when we autoconfiscate...
  
-   BISON="\$(USUAL_BISON)"
    CC_FOR_BUILD="\$(CC)"
    GCC_FOR_TARGET="\$(USUAL_GCC_FOR_TARGET)"
    BUILD_PREFIX=
    BUILD_PREFIX_1=loser-
!   MAKEINFO="\$(USUAL_MAKEINFO)"
!   LEX="\$(USUAL_LEX)"
!   YACC="\$(USUAL_YACC)"
! 
!   # If CC is still not set, try to get gcc.
!   cc_prog_is_gcc=
!   if test -z "${CC}" ; then
!     IFS="${IFS= 	}"; save_ifs="$IFS"; IFS="${IFS}:"
!     for dir in $PATH; do
!       test -z "$dir" && dir=.
!       if test -f $dir/gcc; then
! 	CC="gcc"
! 	cc_prog_is_gcc=yes
! 	echo 'void f(){}' > conftest.c
! 	if test -z "`${CC} -g -c conftest.c 2>&1`"; then
! 	  CFLAGS=${CFLAGS-"-g -O2"}
! 	  CXXFLAGS=${CXXFLAGS-"-g -O2"}
! 	else
! 	  CFLAGS=${CFLAGS-"-O2"}
! 	  CXXFLAGS=${CXXFLAGS-"-O2"}
! 	fi
! 	rm -f conftest*
! 	break
!       fi
!     done
!     IFS="$save_ifs"
!     CC=${CC-cc}
!   else
!     # Determine if we are using gcc.
!     cat > conftest.c <<EOF
! #ifdef __GNUC__
!   yes;
! #endif
! EOF
!     if ${CC} -E conftest.c | grep yes >/dev/null 2>&1; then
!       cc_prog_is_gcc=yes
!     fi
!     rm -f conftest.c
!     if test -z "${CFLAGS}"; then
!       # Here CC is set but CFLAGS is not.  Use a quick hack to use -O2 if CC
!       # is set to a version of gcc.
!       if test "$cc_prog_is_gcc" = yes; then
! 	echo 'void f(){}' > conftest.c
! 	if test -z "`${CC} -g -c conftest.c 2>&1`"; then
! 	  CFLAGS=${CFLAGS-"-g -O2"}
! 	  CXXFLAGS=${CXXFLAGS-"-g -O2"}
! 	else
! 	  CFLAGS=${CFLAGS-"-O2"}
! 	  CXXFLAGS=${CXXFLAGS-"-O2"}
! 	fi
! 	rm -f conftest*
!       fi
!     fi
!   fi
  
    # We must set the default linker to the linker used by gcc for the correct
    # operation of libtool.  If LD is not defined and we are using gcc, try to
    # set the LD default to the ld used by gcc.
    if test -z "$LD"; then
!     if test "$cc_prog_is_gcc" = yes; then
        case $build in
        *-*-mingw*)
  	gcc_prog_ld=`$CC -print-prog-name=ld 2>&1 | tr -d '\015'` ;;
--- 978,996 ----
    # in Makefile.in, so can still be overridden by fragments.
    # This is all going to change when we autoconfiscate...
  
    CC_FOR_BUILD="\$(CC)"
    GCC_FOR_TARGET="\$(USUAL_GCC_FOR_TARGET)"
+   BUILD_DIR_PREFIX=
    BUILD_PREFIX=
    BUILD_PREFIX_1=loser-
! 
!   AC_PROG_CC
  
    # We must set the default linker to the linker used by gcc for the correct
    # operation of libtool.  If LD is not defined and we are using gcc, try to
    # set the LD default to the ld used by gcc.
    if test -z "$LD"; then
!     if test "$GCC" = yes; then
        case $build in
        *-*-mingw*)
  	gcc_prog_ld=`$CC -print-prog-name=ld 2>&1 | tr -d '\015'` ;;
***************
*** 1600,1608 ****
  # Generate default definitions for YACC, M4, LEX.  These are used if the
  # Makefile can't locate these programs in objdir.
  MISSING=`cd $ac_aux_dir && ${PWDCMD-pwd}`/missing
! AC_CHECK_PROGS([DEFAULT_YACC], ['bison -y' byacc yacc], [$MISSING bison])
! AC_CHECK_PROGS([DEFAULT_M4], [gm4 gnum4 m4], [$MISSING m4])
! AC_CHECK_PROGS([DEFAULT_LEX], [flex lex], [$MISSING flex])
  
  # Create a .gdbinit file which runs the one in srcdir
  # and tells GDB to look there for source files.
--- 1507,1517 ----
  # Generate default definitions for YACC, M4, LEX.  These are used if the
  # Makefile can't locate these programs in objdir.
  MISSING=`cd $ac_aux_dir && ${PWDCMD-pwd}`/missing
! AC_CHECK_PROG([CONFIGURED_BISON], [bison], [$MISSING bison])
! AC_CHECK_PROGS([CONFIGURED_YACC], ['bison -y' byacc yacc], [$MISSING bison -y])
! AC_CHECK_PROGS([CONFIGURED_M4], [gm4 gnum4 m4], [$MISSING m4])
! AC_CHECK_PROGS([CONFIGURED_LEX], [flex lex], [$MISSING flex])
! AC_CHECK_PROG([CONFIGURED_MAKEINFO], makeinfo, [$MISSING makeinfo])
  
  # Create a .gdbinit file which runs the one in srcdir
  # and tells GDB to look there for source files.
***************
*** 2138,2143 ****
--- 2047,2053 ----
  # Miscellanea: directories, flags, etc.
  AC_SUBST(SET_LIB_PATH)
  AC_SUBST(RPATH_ENVVAR)
+ AC_SUBST(BUILD_DIR_PREFIX)
  AC_SUBST(BUILD_PREFIX)
  AC_SUBST(BUILD_PREFIX_1)
  AC_SUBST(gcc_version_trigger)
***************
*** 2162,2172 ****
  AC_SUBST(target_configdirs)
  
  # Build tools.
- AC_SUBST(BISON)
  AC_SUBST(CC_FOR_BUILD)
- AC_SUBST(LEX)
- AC_SUBST(MAKEINFO)
- AC_SUBST(YACC)
  AC_SUBST(config_shell)
  
  # Host tools.
--- 2072,2078 ----
***************
*** 2184,2192 ****
  AC_SUBST(CFLAGS)
  AC_SUBST(CFLAGS_FOR_BUILD)
  AC_SUBST(CXXFLAGS)
- AC_SUBST(DEFAULT_YACC)
- AC_SUBST(DEFAULT_LEX)
- AC_SUBST(DEFAULT_M4)
  
  # Target tools.
  NCN_STRICT_CHECK_TARGET_TOOL(CONFIGURED_AR_FOR_TARGET, ar)
--- 2090,2095 ----
Index: Makefile.def
===================================================================
RCS file: /cvs/src/src/Makefile.def,v
retrieving revision 1.25
diff -u -r1.25 Makefile.def
*** Makefile.def	9 Jun 2004 08:32:32 -0000	1.25
--- Makefile.def	23 Jun 2004 09:32:10 -0000
***************
*** 26,31 ****
--- 26,36 ----
  
  build_modules= { module= libiberty; };
  build_modules= { module= libbanshee; };
+ build_modules= { module= bison; };
+ build_modules= { module= byacc; };
+ build_modules= { module= lex; };
+ build_modules= { module= m4; };
+ build_modules= { module= texinfo; };
  
  host_modules= { module= ash; };
  host_modules= { module= autoconf; };
Index: Makefile.tpl
===================================================================
RCS file: /cvs/src/src/Makefile.tpl,v
retrieving revision 1.106
diff -u -r1.106 Makefile.tpl
*** Makefile.tpl	23 Jun 2004 08:36:45 -0000	1.106
--- Makefile.tpl	23 Jun 2004 09:32:10 -0000
***************
*** 233,279 ****
  
  CXX_FOR_BUILD = $(CXX)
  
  # Special variables passed down in EXTRA_GCC_FLAGS.  They are defined
  # here so that they can be overridden by Makefile fragments.
  BUILD_PREFIX = @BUILD_PREFIX@
  BUILD_PREFIX_1 = @BUILD_PREFIX_1@
  
! BISON=@BISON@
! USUAL_BISON = `if [ -f $$r/bison/bison ] ; then \
! 	    echo $$r/bison/bison -L $$s/bison/ ; \
  	 else \
! 	    echo bison ; \
  	 fi`
  
! DEFAULT_YACC = @DEFAULT_YACC@
! YACC=@YACC@
! USUAL_YACC = `if [ -f $$r/bison/bison ] ; then \
! 	    echo $$r/bison/bison -y -L $$s/bison/ ; \
! 	elif [ -f $$r/byacc/byacc ] ; then \
! 	    echo $$r/byacc/byacc ; \
  	else \
! 	    echo ${DEFAULT_YACC} ; \
  	fi`
  
! DEFAULT_LEX = @DEFAULT_LEX@
! LEX=@LEX@
! USUAL_LEX = `if [ -f $$r/flex/flex ] ; \
! 	then echo $$r/flex/flex ; \
! 	else echo ${DEFAULT_LEX} ; fi`
! 
! DEFAULT_M4 = @DEFAULT_M4@
! M4 = `if [ -f $$r/m4/m4 ] ; \
! 	then echo $$r/m4/m4 ; \
! 	else echo ${DEFAULT_M4} ; fi`
  
  # For an installed makeinfo, we require it to be from texinfo 4.2 or
! # higher, else we use the "missing" dummy.
! MAKEINFO=@MAKEINFO@
! USUAL_MAKEINFO = `if [ -f $$r/texinfo/makeinfo/makeinfo ] ; \
! 	then echo $$r/texinfo/makeinfo/makeinfo ; \
! 	else if (makeinfo --version \
  	  | egrep 'texinfo[^0-9]*([1-3][0-9]|4\.[2-9]|[5-9])') >/dev/null 2>&1; \
!         then echo makeinfo; else echo $$s/missing makeinfo; fi; fi`
  
  # This just becomes part of the MAKEINFO definition passed down to
  # sub-makes.  It lets flags be given on the command line while still
--- 233,282 ----
  
  CXX_FOR_BUILD = $(CXX)
  
+ # Path to the build directory for a Canadian cross, empty otherwise.
+ BUILD_DIR_PREFIX = @BUILD_DIR_PREFIX@
+ 
  # Special variables passed down in EXTRA_GCC_FLAGS.  They are defined
  # here so that they can be overridden by Makefile fragments.
  BUILD_PREFIX = @BUILD_PREFIX@
  BUILD_PREFIX_1 = @BUILD_PREFIX_1@
  
! CONFIGURED_BISON = @CONFIGURED_BISON@
! BISON = `if [ -f $$r/$(BUILD_DIR_PREFIX)/bison/bison ] ; then \
! 	    echo $$r/$(BUILD_DIR_PREFIX)/bison/bison -L $$s/bison/ ; \
  	 else \
! 	    echo ${CONFIGURED_BISON} ; \
  	 fi`
  
! CONFIGURED_YACC = @CONFIGURED_YACC@
! YACC = `if [ -f $$s/$(BUILD_DIR_PREFIX)/bison/bison ] ; then \
! 	    echo $$r/$(BUILD_DIR_PREFIX)/bison/bison -y -L $$s/bison/ ; \
! 	elif [ -f $$s/$(BUILD_DIR_PREFIX)/byacc/byacc ] ; then \
! 	    echo $$r/$(BUILD_DIR_PREFIX)/byacc/byacc ; \
  	else \
! 	    echo ${CONFIGURED_YACC} ; \
  	fi`
  
! CONFIGURED_LEX = @CONFIGURED_LEX@
! LEX = `if [ -f $$r/$(BUILD_DIR_PREFIX)/flex/flex ] ; \
! 	then echo $$r/$(BUILD_DIR_PREFIX)/flex/flex ; \
! 	else echo ${CONFIGURED_LEX} ; fi`
! 
! CONFIGURED_M4 = @CONFIGURED_M4@
! M4 = `if [ -f $$r/$(BUILD_DIR_PREFIX)/m4/m4 ] ; \
! 	then echo $$r/$(BUILD_DIR_PREFIX)/m4/m4 ; \
! 	else echo ${CONFIGURED_M4} ; fi`
  
  # For an installed makeinfo, we require it to be from texinfo 4.2 or
! # higher, else we use the "missing" dummy.  We also pass the subdirectory
! # makeinfo even if only the Makefile is there, because Texinfo builds its
! # manual when made, and it requires its own version.
! CONFIGURED_MAKEINFO = @CONFIGURED_MAKEINFO@
! MAKEINFO = `if [ -f $$r/$(BUILD_DIR_PREFIX)/texinfo/makeinfo/Makefile ] ; \
! 	then echo $$r/$(BUILD_DIR_PREFIX)/texinfo/makeinfo/makeinfo ; \
! 	else if (${CONFIGURED_MAKEINFO} --version \
  	  | egrep 'texinfo[^0-9]*([1-3][0-9]|4\.[2-9]|[5-9])') >/dev/null 2>&1; \
!         then echo ${CONFIGURED_MAKEINFO}; else echo $$s/missing makeinfo; fi; fi`
  
  # This just becomes part of the MAKEINFO definition passed down to
  # sub-makes.  It lets flags be given on the command line while still
***************
*** 1642,1647 ****
--- 1647,1658 ----
  # are specified by depending on a 'maybe-' target.  If you're not sure,
  # it's safer to use a soft dependency.
  
+ # Build modules
+ all-build-bison: maybe-all-build-texinfo
+ all-build-m4: maybe-all-build-libiberty maybe-all-build-texinfo
+ all-build-flex: maybe-all-build-texinfo
+ all-build-texinfo: maybe-all-build-libiberty
+ 
  # Host modules specific to gcc.
  # GCC needs to identify certain tools.
  # GCC also needs the information exported by the intl configure script.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]