This is the mail archive of the gcc-patches@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]

PATCH: Use GNU Makeisms to simplify libgcc build


I've attached a ceremonial first patch using GNU make features.  This
patch eliminates a problem we had building on hppa64-hp-hpux11.11,
where AR_FOR_TARGET, RANLIB_FOR_TARGET, and NM_FOR_TARGET were not
getting passed down correctly everywhere.  By using the GNU "export"
directive, we ensure that they are passed do (considered harmful)
recursive invocations of (GNU) make.  And nobody has to explicitly
remember to pass them.

Ideally, now that we are requiring GNU make, libgcc.mk would just be
"include"d in the Makefile, and we could avoid having to recursively
invoke make at all, at which point these export directives can go
away.  But, Zack says that's going to be pretty complicated, so this
at least improves the situation.

Tested on i686-pc-linux-gnu, and with some additional poking and
experimenting in the form of setting things explicitly on the command
line.  Installed on the mainline.

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2003-08-26  Mark Mitchell  <mark@codesourcery.com>

	* Makefile.in (AR_FOR_TARGET): Export it.
	(AR_CREATE_FOR_TARGET): Likewise.
	(AR_FLAGS_FOR_TARGET): Likewise.
	(AR_EXTRACT_FOR_TARGET): Likewise.
	(AWK): Likewise.
	(BUILD_PREFIX): Likewise.
	(BUILD_PREFIX_1): Likewise.
	(DESTDIR): Likewise.
	(GCC_FOR_TARGET): Likewise.
	(INCLUDES): Likewise.
	(INSTALL_DATA): Likewise.
	(LIB1ASMSRC): Likewise.
	(LIBGCC2_CFLAGS): Likewise.
	(MACHMODE_H): Likewise.
	(NM_FOR_TARGET): Likewise.
	(RANLIB_FOR_TARGET): Likewise.
	(libsubdir): Likewise.
	(slibdir): Likewise.
	(ORDINARY_FLAGS_TO_PASS): Remove stuff that we're
	exporting.
	(libgcc.a): Don't pass them here.
	(stmp-multilib): Or here.
	(install-libgcc): Or here.
	(install-multilib): Or here.
	(POSTSTAGE1_FLAGS_TO_PASS): Or here.
	(stage1_build): Or here.

Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.1140
diff -c -5 -p -r1.1140 Makefile.in
*** Makefile.in	20 Aug 2003 10:50:20 -0000	1.1140
--- Makefile.in	26 Aug 2003 17:39:48 -0000
*************** LANG_STAGESTUFF = @all_stagestuff@
*** 742,770 ****
  # Flags to pass to recursive makes.
  # CC is set by configure.  Hosts without symlinks need special handling
  # because we need CC="stage1/xgcc -Bstage1/" to work in the language
  # subdirectories.
  # ??? The choices here will need some experimenting with.
  ORDINARY_FLAGS_TO_PASS = \
- 	"AR_FLAGS_FOR_TARGET=$(AR_FLAGS_FOR_TARGET)" \
- 	"AR_CREATE_FOR_TARGET=$(AR_CREATE_FOR_TARGET)" \
- 	"AR_EXTRACT_FOR_TARGET=$(AR_EXTRACT_FOR_TARGET)" \
- 	"AR_FOR_TARGET=$(AR_FOR_TARGET)" \
  	"BISON=$(BISON)" \
  	"BISONFLAGS=$(BISONFLAGS)" \
  	"CFLAGS=$(CFLAGS) $(WARN_CFLAGS)" \
- 	"DESTDIR=$(DESTDIR)" \
- 	"GCC_FOR_TARGET=$(GCC_FOR_TARGET)" \
  	"LDFLAGS=$(LDFLAGS)" \
  	"FLEX=$(FLEX)" \
  	"FLEXFLAGS=$(FLEXFLAGS)" \
  	"LN=$(LN)" \
  	"LN_S=$(LN_S)" \
  	"MAKEINFO=$(MAKEINFO)" \
  	"MAKEINFOFLAGS=$(MAKEINFOFLAGS)" \
  	"MAKEOVERRIDES=" \
- 	"RANLIB_FOR_TARGET=$(RANLIB_FOR_TARGET)" \
  	"SHELL=$(SHELL)" \
  	"exeext=$(exeext)" \
  	"build_exeext=$(build_exeext)" \
  	"objext=$(objext)" \
  	"exec_prefix=$(exec_prefix)" \
--- 742,783 ----
  # Flags to pass to recursive makes.
  # CC is set by configure.  Hosts without symlinks need special handling
  # because we need CC="stage1/xgcc -Bstage1/" to work in the language
  # subdirectories.
  # ??? The choices here will need some experimenting with.
+ 
+ export AR_FOR_TARGET
+ export AR_CREATE_FOR_TARGET
+ export AR_FLAGS_FOR_TARGET
+ export AR_EXTRACT_FOR_TARGET
+ export AWK
+ export BUILD_PREFIX
+ export BUILD_PREFIX_1
+ export DESTDIR
+ export GCC_FOR_TARGET
+ export INCLUDES
+ export INSTALL_DATA
+ export LIB1ASMSRC
+ export LIBGCC2_CFLAGS
+ export MACHMODE_H
+ export NM_FOR_TARGET
+ export RANLIB_FOR_TARGET
+ export libsubdir
+ export slibdir
+ 
  ORDINARY_FLAGS_TO_PASS = \
  	"BISON=$(BISON)" \
  	"BISONFLAGS=$(BISONFLAGS)" \
  	"CFLAGS=$(CFLAGS) $(WARN_CFLAGS)" \
  	"LDFLAGS=$(LDFLAGS)" \
  	"FLEX=$(FLEX)" \
  	"FLEXFLAGS=$(FLEXFLAGS)" \
  	"LN=$(LN)" \
  	"LN_S=$(LN_S)" \
  	"MAKEINFO=$(MAKEINFO)" \
  	"MAKEINFOFLAGS=$(MAKEINFOFLAGS)" \
  	"MAKEOVERRIDES=" \
  	"SHELL=$(SHELL)" \
  	"exeext=$(exeext)" \
  	"build_exeext=$(build_exeext)" \
  	"objext=$(objext)" \
  	"exec_prefix=$(exec_prefix)" \
*************** ORDINARY_FLAGS_TO_PASS = \
*** 772,782 ****
  	"local_prefix=$(local_prefix)" \
  	"gxx_include_dir=$(gcc_gxx_include_dir)" \
  	"build_tooldir=$(build_tooldir)" \
  	"gcc_tooldir=$(gcc_tooldir)" \
  	"bindir=$(bindir)" \
- 	"libsubdir=$(libsubdir)" \
  	"libexecsubdir=$(libsubdir)" \
  	"datadir=$(datadir)" \
  	"localedir=$(localedir)"
  FLAGS_TO_PASS = $(ORDINARY_FLAGS_TO_PASS) "CC=@cc_set_by_configure@" \
  	"STAGE_PREFIX=@stage_prefix_set_by_configure@"
--- 785,794 ----
*************** LIBGCC_DEPS = $(GCC_PASSES) $(LANGUAGES)
*** 1133,1154 ****
  	$(srcdir)/gcov-io.h $(srcdir)/gcov-io.c gcov-iov.h
  
  libgcov.a: libgcc.a; @true
  
  libgcc.a: $(LIBGCC_DEPS)
! 	$(MAKE) GCC_FOR_TARGET="$(GCC_FOR_TARGET)" \
! 	  BUILD_PREFIX="$(BUILD_PREFIX)" BUILD_PREFIX_1="$(BUILD_PREFIX_1)" \
! 	  AR_FOR_TARGET="$(AR_FOR_TARGET)" \
! 	  AR_CREATE_FOR_TARGET="$(AR_CREATE_FOR_TARGET)" \
! 	  AR_FLAGS_FOR_TARGET="$(AR_FLAGS_FOR_TARGET)" \
  	  CFLAGS="$(CFLAGS) $(WARN_CFLAGS)" \
! 	  RANLIB_FOR_TARGET="$(RANLIB_FOR_TARGET)" \
! 	  NM_FOR_TARGET="$(NM_FOR_TARGET)" AWK="$(AWK)" \
! 	  LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)" \
! 	  INCLUDES="$(INCLUDES)" \
! 	  CONFIG_H="$(TCONFIG_H)" MACHMODE_H="$(MACHMODE_H)" TM_H="$(TM_H)" \
! 	  LIB1ASMSRC='$(LIB1ASMSRC)' \
  	  MAKEOVERRIDES= \
  	  -f libgcc.mk all
  
  # Use the genmultilib shell script to generate the information the gcc
  # driver program needs to select the library directory based on the
--- 1145,1157 ----
  	$(srcdir)/gcov-io.h $(srcdir)/gcov-io.c gcov-iov.h
  
  libgcov.a: libgcc.a; @true
  
  libgcc.a: $(LIBGCC_DEPS)
! 	$(MAKE) \
  	  CFLAGS="$(CFLAGS) $(WARN_CFLAGS)" \
! 	  CONFIG_H="$(TCONFIG_H)" TM_H="$(TM_H)" \
  	  MAKEOVERRIDES= \
  	  -f libgcc.mk all
  
  # Use the genmultilib shell script to generate the information the gcc
  # driver program needs to select the library directory based on the
*************** s-mlib: $(srcdir)/genmultilib Makefile
*** 1174,1195 ****
  	$(SHELL) $(srcdir)/move-if-change tmp-mlib.h multilib.h
  	$(STAMP) s-mlib
  
  # Build multiple copies of libgcc.a, one for each target switch.
  stmp-multilib: $(LIBGCC_DEPS)
! 	$(MAKE) GCC_FOR_TARGET="$(GCC_FOR_TARGET)" \
! 	  BUILD_PREFIX="$(BUILD_PREFIX)" BUILD_PREFIX_1="$(BUILD_PREFIX_1)" \
! 	  AR_FOR_TARGET="$(AR_FOR_TARGET)" \
! 	  AR_CREATE_FOR_TARGET="$(AR_CREATE_FOR_TARGET)" \
! 	  AR_FLAGS_FOR_TARGET="$(AR_FLAGS_FOR_TARGET)" \
  	  CFLAGS="$(CFLAGS) $(WARN_CFLAGS)" \
! 	  RANLIB_FOR_TARGET="$(RANLIB_FOR_TARGET)" \
! 	  NM_FOR_TARGET="$(NM_FOR_TARGET)" AWK="$(AWK)" \
! 	  LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)" \
! 	  INCLUDES="$(INCLUDES)" \
! 	  CONFIG_H="$(CONFIG_H)" MACHMODE_H="$(MACHMODE_H)" \
! 	  LIB1ASMSRC='$(LIB1ASMSRC)' \
  	  MAKEOVERRIDES= \
  	  -f libgcc.mk all
  	$(STAMP) stmp-multilib
  
  # Compile two additional files that are linked with every program
--- 1177,1189 ----
  	$(SHELL) $(srcdir)/move-if-change tmp-mlib.h multilib.h
  	$(STAMP) s-mlib
  
  # Build multiple copies of libgcc.a, one for each target switch.
  stmp-multilib: $(LIBGCC_DEPS)
! 	$(MAKE) \
  	  CFLAGS="$(CFLAGS) $(WARN_CFLAGS)" \
! 	  CONFIG_H="$(CONFIG_H)" \
  	  MAKEOVERRIDES= \
  	  -f libgcc.mk all
  	$(STAMP) stmp-multilib
  
  # Compile two additional files that are linked with every program
*************** install-man: installdirs $(GENERATED_MAN
*** 3088,3135 ****
  	-$(INSTALL_DATA) $(docobjdir)/gpl.7 $(DESTDIR)$(man7dir)/gpl$(man7ext)
  	-chmod a-x $(DESTDIR)$(man7dir)/gpl$(man7ext)
  
  # Install the library.
  install-libgcc: libgcc.mk libgcc.a libgcov.a installdirs
! 	$(MAKE) GCC_FOR_TARGET="$(GCC_FOR_TARGET)" \
! 	  BUILD_PREFIX="$(BUILD_PREFIX)" BUILD_PREFIX_1="$(BUILD_PREFIX_1)" \
! 	  AR_FOR_TARGET="$(AR_FOR_TARGET)" \
! 	  AR_CREATE_FOR_TARGET="$(AR_CREATE_FOR_TARGET)" \
! 	  AR_FLAGS_FOR_TARGET="$(AR_FLAGS_FOR_TARGET)" \
  	  CFLAGS="$(CFLAGS) $(WARN_CFLAGS)" \
! 	  NM_FOR_TARGET="$(NM_FOR_TARGET)" AWK="$(AWK)" \
! 	  LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)" \
! 	  INCLUDES="$(INCLUDES)" \
! 	  CONFIG_H="$(TCONFIG_H)" MACHMODE_H="$(MACHMODE_H)" \
! 	  LIB1ASMSRC='$(LIB1ASMSRC)' \
  	  MAKEOVERRIDES= \
- 	  INSTALL_DATA="$(INSTALL_DATA)" \
- 	  RANLIB_FOR_TARGET="$(RANLIB_FOR_TARGET)" \
- 	  DESTDIR="$(DESTDIR)" \
- 	  libsubdir="$(libsubdir)" \
- 	  slibdir="$(slibdir)" \
  	  -f libgcc.mk install
  
  # Install multiple versions of libgcc.a, libgcov.a.
  install-multilib: stmp-multilib installdirs
! 	$(MAKE) GCC_FOR_TARGET="$(GCC_FOR_TARGET)" \
! 	  BUILD_PREFIX="$(BUILD_PREFIX)" BUILD_PREFIX_1="$(BUILD_PREFIX_1)" \
! 	  AR_FOR_TARGET="$(AR_FOR_TARGET)" \
! 	  AR_CREATE_FOR_TARGET="$(AR_CREATE_FOR_TARGET)" \
! 	  AR_FLAGS_FOR_TARGET="$(AR_FLAGS_FOR_TARGET)" \
  	  CFLAGS="$(CFLAGS) $(WARN_CFLAGS)" \
! 	  NM_FOR_TARGET="$(NM_FOR_TARGET)" AWK="$(AWK)" \
! 	  LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)" \
! 	  INCLUDES="$(INCLUDES)" \
! 	  CONFIG_H="$(CONFIG_H)" MACHMODE_H="$(MACHMODE_H)" \
! 	  LIB1ASMSRC='$(LIB1ASMSRC)' \
  	  MAKEOVERRIDES= \
- 	  INSTALL_DATA="$(INSTALL_DATA)" \
- 	  RANLIB_FOR_TARGET="$(RANLIB_FOR_TARGET)" \
- 	  DESTDIR="$(DESTDIR)" \
- 	  libsubdir="$(libsubdir)" \
- 	  slibdir="$(slibdir)" \
  	  -f libgcc.mk install
  
  # Install all the header files built in the include subdirectory.
  install-headers: $(INSTALL_HEADERS_DIR)
  # Fix symlinks to absolute paths in the installed include directory to
--- 3082,3103 ----
  	-$(INSTALL_DATA) $(docobjdir)/gpl.7 $(DESTDIR)$(man7dir)/gpl$(man7ext)
  	-chmod a-x $(DESTDIR)$(man7dir)/gpl$(man7ext)
  
  # Install the library.
  install-libgcc: libgcc.mk libgcc.a libgcov.a installdirs
! 	$(MAKE) \
  	  CFLAGS="$(CFLAGS) $(WARN_CFLAGS)" \
! 	  CONFIG_H="$(TCONFIG_H)" \
  	  MAKEOVERRIDES= \
  	  -f libgcc.mk install
  
  # Install multiple versions of libgcc.a, libgcov.a.
  install-multilib: stmp-multilib installdirs
! 	$(MAKE) \
  	  CFLAGS="$(CFLAGS) $(WARN_CFLAGS)" \
! 	  CONFIG_H="$(CONFIG_H)" \
  	  MAKEOVERRIDES= \
  	  -f libgcc.mk install
  
  # Install all the header files built in the include subdirectory.
  install-headers: $(INSTALL_HEADERS_DIR)
  # Fix symlinks to absolute paths in the installed include directory to
*************** VOL_FILES=`echo $(BACKEND) $(OBJS) $(C_O
*** 3478,3488 ****
  # WARN_CFLAGS setting can't be to the expansion of GCC_WARN_CFLAGS in
  # the context of the stage_x rule.
  
  POSTSTAGE1_FLAGS_TO_PASS = \
  	ADAC="\$$(CC)" \
- 	GCC_FOR_TARGET="$(GCC_FOR_TARGET)" \
  	CFLAGS="$(BOOT_CFLAGS)" \
  	LDFLAGS="$(BOOT_LDFLAGS)" \
  	WARN_CFLAGS="\$$(GCC_WARN_CFLAGS)" \
  	STRICT_WARN="$(STRICT2_WARN)" \
  	libdir=$(libdir) \
--- 3446,3455 ----
*************** STAGEFEEDBACK_FLAGS_TO_PASS = \
*** 3508,3518 ****
  # MAKEINFO and MAKEINFOFLAGS are explicitly passed here to make them
  # overrideable (for a bootstrap build stage1 also builds gcc.info).
  stage1_build:
  	$(MAKE) CC="$(CC)" libdir=$(libdir) LANGUAGES="$(BOOT_LANGUAGES)" \
  		CFLAGS="$(STAGE1_CFLAGS)" MAKEINFO="$(MAKEINFO)" \
- 		GCC_FOR_TARGET="$(GCC_FOR_TARGET)" \
  		MAKEINFOFLAGS="$(MAKEINFOFLAGS)" COVERAGE_FLAGS= \
  		OBJS-onestep="$(OBJS)"
  	$(STAMP) stage1_build
  	echo stage1_build > stage_last
  
--- 3475,3484 ----


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