[uClibc] tool links in bin

Miles Bader miles at lsi.nec.co.jp
Thu Sep 18 05:27:24 UTC 2003


This code in extra/gcc-uClibc/Makefile seems vaguely bogus:

	for app in addr2line ar as cpp gasp nm objcopy \
	    objdump ranlib size strings strip; do \
	  APPNAME=`which $(CROSS)$${app}`; \
	  if [ -x "$$APPNAME" ] ; then \
	  ln -fs "$$APPNAME" $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/$${app}; \
	  ln -fs "$$APPNAME" $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-$${app}; \
	  fi; \

... because it doesn't work when cross-compiling (and in general, I'm
always a bit suspicious of `which' other than for purely information
purposes).

At the least, it seems like it should do something like:


--- Makefile.~1.57.~	2003-03-10 14:31:01.000000000 +0900
+++ Makefile	2003-09-18 14:23:08.000000000 +0900
@@ -75,13 +75,17 @@ ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y)
 	ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/c++
 	ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/g++
 endif
-	for app in addr2line ar as cpp gasp nm objcopy \
-	    objdump ranlib size strings strip; do \
-	  APPNAME=`which $(CROSS)$${app}`; \
-	  if [ -x "$$APPNAME" ] ; then \
-	  ln -fs "$$APPNAME" $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/$${app}; \
-	  ln -fs "$$APPNAME" $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-$${app}; \
-	  fi; \
+	for app in addr2line ar as cpp gasp nm objcopy			  \
+	    objdump ranlib size strings strip; do			  \
+	  APPNAME="$(SYSTEM_DEVEL_PREFIX)/bin/$(CROSS)$${app}";		  \
+	  if ! test -x "$(PREFIX)$$APPNAME"; then			  \
+	    APPNAME=`which $(CROSS)$${app}`;				  \
+	    test -x "$$APPNAME" || APPNAME="";				  \
+	  fi;								  \
+	  if test "$$APPNAME"; then					  \
+	    ln -fs "$$APPNAME" $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/$${app}; \
+	    ln -fs "$$APPNAME" $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-$${app}; \
+	  fi;								  \
 	done
 
 clean:


So that installing into a `consistent' tree won't use which.

I'm not sure if that should be $(DEVEL_TOOL_PREFIX) or
$(SYSTEM_DEVEL_PREFIX) -- in my target envrionment they are both empty
(I've always found the uClibc system of prefixes confusing...).

Thanks,

-Miles
-- 
We have met the enemy, and he is us.  -- Pogo



More information about the uClibc mailing list