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]

Fix RANLIB problem that affects target gperf


People who build gperf along with GCC have noticed that gperf fails to
build because RANLIB (for the target) is passed down as an empty
string instead of the appropriate value, and gperf's top-level
Makefile just passes it down to the lib sub-directory, overriding the
correct RANLIB setting that lib/configure found.

Here's a patch that fixes a number of iffy passages in Makefile.in
that were possibly related with the problem.  I was happy to find out
that, after making these changes, a gperf build would succeed.  I'm
not sure which of the changes did it, or if all of them are needed,
but all of them are correct, so I didn't try to find it out.

Note that this does NOT fix the problem that gperf won't build
correctly with a C++-disabled tool-chain.  I'm not sure whether the
best fix is to adjust gperf so that it sets up a limited configuration
if it can't find a working C++ compiler (I'm not even sure if this
makes sense) or if it would be better to disable gperf in case the C++
language isn't enabled.


This was tested by myself and Diego Novillo on a number of different
set ups, so I'm checking it in.  Please let me know if it happens to
break on some obscure OS or with some obscure setting of
RANLIB_FOR_TARGET.

Index: ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* Makefile.in (AS_FOR_TARGET, LD_FOR_TARGET,
	DLLTOOL_FOR_TARGET, WINDRES_FOR_TARGET, AR_FOR_TARGET,
	RANLIB_FOR_TARGET, NM_FOR_TARGET): Don't use double quotes to
	avoid quotes nesting problems.
	(NATIVE_CHECK_MODULES): Ditto, just for consistency.
	(DO_X): Export only variables that are set.

Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/egcs/Makefile.in,v
retrieving revision 1.85
diff -u -p -r1.85 Makefile.in
--- Makefile.in 2001/08/11 09:43:31 1.85
+++ Makefile.in 2001/09/21 05:03:54
@@ -234,7 +234,7 @@ AS_FOR_TARGET = ` \
   elif [ -f $$r/gcc/xgcc ]; then \
     $(CC_FOR_TARGET) -print-prog-name=as ; \
   else \
-    if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
+    if [ '$(host_canonical)' = '$(target_canonical)' ] ; then \
       echo $(AS); \
     else \
        t='$(program_transform_name)'; echo as | sed -e 's/x/x/' $$t ; \
@@ -247,7 +247,7 @@ LD_FOR_TARGET = ` \
   elif [ -f $$r/gcc/xgcc ]; then \
     $(CC_FOR_TARGET) -print-prog-name=ld ; \
   else \
-    if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
+    if [ '$(host_canonical)' = '$(target_canonical)' ] ; then \
       echo $(LD); \
     else \
        t='$(program_transform_name)'; echo ld | sed -e 's/x/x/' $$t ; \
@@ -258,7 +258,7 @@ DLLTOOL_FOR_TARGET = ` \
   if [ -f $$r/binutils/dlltool ] ; then \
     echo $$r/binutils/dlltool ; \
   else \
-    if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
+    if [ '$(host_canonical)' = '$(target_canonical)' ] ; then \
       echo $(DLLTOOL); \
     else \
        t='$(program_transform_name)'; echo dlltool | sed -e 's/x/x/' $$t ; \
@@ -269,7 +269,7 @@ WINDRES_FOR_TARGET = ` \
   if [ -f $$r/binutils/windres ] ; then \
     echo $$r/binutils/windres ; \
   else \
-    if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
+    if [ '$(host_canonical)' = '$(target_canonical)' ] ; then \
       echo $(WINDRES); \
     else \
        t='$(program_transform_name)'; echo windres | sed -e 's/x/x/' $$t ; \
@@ -280,7 +280,7 @@ AR_FOR_TARGET = ` \
   if [ -f $$r/binutils/ar ] ; then \
     echo $$r/binutils/ar ; \
   else \
-    if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
+    if [ '$(host_canonical)' = '$(target_canonical)' ] ; then \
       echo $(AR); \
     else \
        t='$(program_transform_name)'; echo ar | sed -e 's/x/x/' $$t ; \
@@ -291,8 +291,8 @@ RANLIB_FOR_TARGET = ` \
   if [ -f $$r/binutils/ranlib ] ; then \
     echo $$r/binutils/ranlib ; \
   else \
-    if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
-      if [ x"$(RANLIB)" != x ]; then \
+    if [ '$(host_canonical)' = '$(target_canonical)' ] ; then \
+      if [ x'$(RANLIB)' != x ]; then \
          echo $(RANLIB); \
       else \
          echo ranlib; \
@@ -308,7 +308,7 @@ NM_FOR_TARGET = ` \
   elif [ -f $$r/gcc/xgcc ]; then \
     $(CC_FOR_TARGET) -print-prog-name=nm ; \
   else \
-    if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
+    if [ '$(host_canonical)' = '$(target_canonical)' ] ; then \
       echo $(NM); \
     else \
        t='$(program_transform_name)'; echo nm | sed -e 's/x/x/' $$t ; \
@@ -976,16 +976,15 @@ $(DO_X):
 	    case $$i in \
 	    gcc) \
 	      for flag in $(EXTRA_GCC_FLAGS); do \
-		eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'|"`; \
+		eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
 	      done; \
 	      ;; \
 	    *) \
 	      for flag in $(EXTRA_HOST_FLAGS); do \
-		eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'|"`; \
+		eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
 	      done; \
 	      ;; \
 	    esac ; \
-	    export AR AS CC CXX LD NM RANLIB DLLTOOL WINDRES; \
 	    if (cd ./$$i; \
 	        $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
 			"CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
@@ -1002,9 +1001,8 @@ $(DO_X):
 	for i in $(TARGET_CONFIGDIRS) -dummy-; do \
 	  if [ -f $(TARGET_SUBDIR)/$$i/Makefile ]; then \
 	    for flag in $(EXTRA_TARGET_FLAGS); do \
-		eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'|"`; \
+		eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \
 	    done; \
-	    export AR AS CC CXX LD NM RANLIB DLLTOOL WINDRES; \
 	    if (cd $(TARGET_SUBDIR)/$$i; \
 	        $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \
 			"CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \
@@ -1215,7 +1213,7 @@ $(ALL_MODULES) all-gui all-libproc:
 
 .PHONY: $(CHECK_MODULES) $(NATIVE_CHECK_MODULES) $(CROSS_CHECK_MODULES)
 $(NATIVE_CHECK_MODULES):
-	@if [ "$(host_canonical)" = "$(target_canonical)" ] ; then \
+	@if [ '$(host_canonical)' = '$(target_canonical)' ] ; then \
 	  dir=`echo $@ | sed -e 's/check-//'`; \
 	  if [ -f ./$${dir}/Makefile ] ; then \
 	    r=`pwd`; export r; \

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me

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