Skip to contentSkip to conversation

PATH cleanup

PATCH Superseded Samuel Martin 4 participants 13 messages Nov 11, 2013 – Jan 2, 2014

Subsystems (2)

v1 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

cover PATH cleanup

All,

Here is some cleanup about the *_PATH variables we carry in the Buildroot infrastructure.

Note that, I'm not certain whether the last patch of this series, the one exporting the PATH in the Buildroot environment, should be merged; though I don't see anything against this.

Yours,
Samuel

Samuel Martin (6):
Makefile: introduce BR2_PATH
Makefile: add $(HOST_DIR)/sbin to BR2_PATH
*.mk: replace (TARGET|HOST)_PATH by BR2_PATH
infra: remove unused {TARGET,HOST}_PATH definition pkg-cmake.mk, pkg-autotools.mk: add PATH in the configure command
environment
Makefile: export PATH

 Makefile                                   |  4 ++++
 fs/ext2/ext2.mk                            |  2 +-
 package/Makefile.in                        | 12 ++++--------
 package/bustle/bustle.mk                   |  2 +-
 package/libhid/libhid.mk                   |  2 +-
 package/pkg-autotools.mk                   |  2 ++
 package/pkg-cmake.mk                       |  2 ++
 package/python-protobuf/python-protobuf.mk |  2 +-
 8 files changed, 16 insertions(+), 12 deletions(-)

--
1.8.4.2

#1 lore raw

PATCH 1/6 Makefile: introduce BR2_PATH

Since the HOST_PATH and TARGET_PATH variables almost contain the same things, let's factorize this in a single BR2_PATH.

---
 Makefile            | 3 +++
 package/Makefile.in | 4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)
Makefile +3 -0
index 2f7db59..5a99bbb 100644
@@ -266,6 +266,9 @@ TAR_OPTIONS=$(call qstrip,$(BR2_TAR_OPTIONS)) -xf
 # packages compiled for the host go here
 HOST_DIR:=$(call qstrip,$(BR2_HOST_DIR))
 
+# Set BR2_PATH (including host bindirs)
+BR2_PATH:="$(HOST_DIR)/bin:$(HOST_DIR)/usr/bin:$(HOST_DIR)/usr/sbin/:$(PATH)"
+
 # locales to generate
 GENERATE_LOCALE=$(call qstrip,$(BR2_GENERATE_LOCALE))
 
package/Makefile.in +2 -2
index 612f3c7..b5829cb 100644
@@ -145,7 +145,7 @@ TARGET_CROSS=$(HOST_DIR)/usr/bin/$(call qstrip,$(BR2_TOOLCHAIN_EXTERNAL_PREFIX))
 endif
 
 # Quotes are needed for spaces et al in path components.
-TARGET_PATH="$(HOST_DIR)/bin:$(HOST_DIR)/usr/bin:$(HOST_DIR)/usr/sbin/:$(PATH)"
+TARGET_PATH = $(BR2_PATH)
 
 # Define TARGET_xx variables for all common binutils/gcc
 TARGET_AR       = $(TARGET_CROSS)ar
@@ -200,7 +200,7 @@ HOST_CFLAGS   ?= -O2
 HOST_CFLAGS   += $(HOST_CPPFLAGS)
 HOST_CXXFLAGS += $(HOST_CFLAGS)
 HOST_LDFLAGS  += -L$(HOST_DIR)/lib -L$(HOST_DIR)/usr/lib -Wl,-rpath,$(HOST_DIR)/usr/lib
-HOST_PATH=$(HOST_DIR)/bin:$(HOST_DIR)/usr/bin:$(PATH)
+HOST_PATH = $(BR2_PATH)
 
 # hostcc version as an integer - E.G. 4.3.2 => 432
 HOSTCC_VERSION:=$(shell $(HOSTCC_NOCCACHE) --version | \
Signature · 1 line
1.8.4.2
#2 lore raw

PATCH 2/6 Makefile: add $(HOST_DIR)/sbin to BR2_PATH

In reply to Samuel Martin

Extend BR2_PATH because few host-packages install programs in this location.

---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
index 5a99bbb..4010c65 100644
@@ -267,7 +267,7 @@ TAR_OPTIONS=$(call qstrip,$(BR2_TAR_OPTIONS)) -xf
 HOST_DIR:=$(call qstrip,$(BR2_HOST_DIR))
 
 # Set BR2_PATH (including host bindirs)
-BR2_PATH:="$(HOST_DIR)/bin:$(HOST_DIR)/usr/bin:$(HOST_DIR)/usr/sbin/:$(PATH)"
+BR2_PATH:="$(HOST_DIR)/bin:$(HOST_DIR)/sbin:$(HOST_DIR)/usr/bin:$(HOST_DIR)/usr/sbin/:$(PATH)"
 
 # locales to generate
 GENERATE_LOCALE=$(call qstrip,$(BR2_GENERATE_LOCALE))
Signature · 1 line
1.8.4.2
#3 lore raw

PATCH 3/6 *.mk: replace (TARGET|HOST)_PATH by BR2_PATH

In reply to Samuel Martin
---
 fs/ext2/ext2.mk                            | 2 +-
 package/Makefile.in                        | 8 ++++----
 package/bustle/bustle.mk                   | 2 +-
 package/libhid/libhid.mk                   | 2 +-
 package/python-protobuf/python-protobuf.mk | 2 +-
 5 files changed, 8 insertions(+), 8 deletions(-)
fs/ext2/ext2.mk +1 -1
index 0af955f..7b96dda 100644
@@ -24,7 +24,7 @@ EXT2_ENV  = GEN=$(BR2_TARGET_ROOTFS_EXT2_GEN)
 EXT2_ENV += REV=$(BR2_TARGET_ROOTFS_EXT2_REV)
 
 define ROOTFS_EXT2_CMD
-	PATH=$(TARGET_PATH) $(EXT2_ENV) fs/ext2/genext2fs.sh -d $(TARGET_DIR) $(EXT2_OPTS) $@
+	PATH=$(BR2_PATH) $(EXT2_ENV) fs/ext2/genext2fs.sh -d $(TARGET_DIR) $(EXT2_OPTS) $@
 endef
 
 rootfs-ext2-symlink:
package/Makefile.in +4 -4
index b5829cb..7ce84ce 100644
@@ -206,7 +206,7 @@ HOST_PATH = $(BR2_PATH)
 HOSTCC_VERSION:=$(shell $(HOSTCC_NOCCACHE) --version | \
 	sed -n 's/^.* \([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)[ ]*.*$$/\1\2\3/p')
 
-TARGET_CONFIGURE_OPTS=PATH=$(TARGET_PATH) \
+TARGET_CONFIGURE_OPTS=PATH=$(BR2_PATH) \
 		AR="$(TARGET_AR)" \
 		AS="$(TARGET_AS)" \
 		LD="$(TARGET_LD)" \
@@ -244,10 +244,10 @@ TARGET_CONFIGURE_OPTS=PATH=$(TARGET_PATH) \
 		PERLLIB="$(HOST_DIR)/usr/lib/perl" \
 		STAGING_DIR="$(STAGING_DIR)"
 
-TARGET_MAKE_ENV=PATH=$(TARGET_PATH) \
+TARGET_MAKE_ENV=PATH=$(BR2_PATH) \
 		PERLLIB="$(HOST_DIR)/usr/lib/perl"
 
-HOST_CONFIGURE_OPTS=PATH=$(HOST_PATH) \
+HOST_CONFIGURE_OPTS=PATH=$(BR2_PATH) \
 		AR="$(HOSTAR)" \
 		AS="$(HOSTAS)" \
 		LD="$(HOSTLD)" \
@@ -268,7 +268,7 @@ HOST_CONFIGURE_OPTS=PATH=$(HOST_PATH) \
 		PERLLIB="$(HOST_DIR)/usr/lib/perl" \
 		LD_LIBRARY_PATH="$(HOST_DIR)/usr/lib:$(LD_LIBRARY_PATH)"
 
-HOST_MAKE_ENV=PATH=$(HOST_PATH) \
+HOST_MAKE_ENV=PATH=$(BR2_PATH) \
 		LD_LIBRARY_PATH="$(HOST_DIR)/usr/lib:$(LD_LIBRARY_PATH)" \
 		PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY)" \
 		PKG_CONFIG_SYSROOT_DIR="/" \
package/bustle/bustle.mk +1 -1
index 68b7b24..6c6c67f 100644
@@ -11,7 +11,7 @@ BUSTLE_LICENSE_FILES = LICENSE
 BUSTLE_DEPENDENCIES = libglib2 libpcap host-pkgconf
 
 define BUSTLE_BUILD_CMDS
-	PATH=$(TARGET_PATH) $(MAKE) $(TARGET_CONFIGURE_OPTS) \
+	PATH=$(BR2_PATH) $(MAKE) $(TARGET_CONFIGURE_OPTS) \
 		PCAP_FLAGS='-lpcap' -C $(@D) dist/build/bustle-pcap
 endef
 
package/libhid/libhid.mk +1 -1
index 97aab5d..ba0ad6b 100644
@@ -11,7 +11,7 @@ LIBHID_INSTALL_STAGING = YES
 LIBHID_AUTORECONF = YES
 # configure runs libusb-config for cflags/ldflags. Ensure it picks up
 # the target version
-LIBHID_CONF_ENV = PATH=$(STAGING_DIR)/usr/bin:$(TARGET_PATH)
+LIBHID_CONF_ENV = PATH=$(STAGING_DIR)/usr/bin:$(BR2_PATH)
 LIBHID_CONF_OPT = \
 	--disable-swig \
 	--disable-werror \
package/python-protobuf/python-protobuf.mk +1 -1
index dcf67c2..1ed366e 100644
@@ -16,7 +16,7 @@ PYTHON_PROTOBUF_DEPENDENCIES = python host-python-setuptools \
 define PYTHON_PROTOBUF_BUILD_CMDS
 	(cd $(@D)/python; \
 		PYTHONXCPREFIX="$(STAGING_DIR)/usr/" \
-		PATH=$(HOST_PATH) \
+		PATH=$(BR2_PATH) \
 	$(HOST_DIR)/usr/bin/python setup.py build -x)
 endef
 
Signature · 1 line
1.8.4.2
#4 lore raw

PATCH 4/6 infra: remove unused {TARGET, HOST}_PATH definition

In reply to Samuel Martin
---
 package/Makefile.in | 4 ----
 1 file changed, 4 deletions(-)
package/Makefile.in +0 -4
index 7ce84ce..501a0b3 100644
@@ -144,9 +144,6 @@ else
 TARGET_CROSS=$(HOST_DIR)/usr/bin/$(call qstrip,$(BR2_TOOLCHAIN_EXTERNAL_PREFIX))-
 endif
 
-# Quotes are needed for spaces et al in path components.
-TARGET_PATH = $(BR2_PATH)
-
 # Define TARGET_xx variables for all common binutils/gcc
 TARGET_AR       = $(TARGET_CROSS)ar
 TARGET_AS       = $(TARGET_CROSS)as
@@ -200,7 +197,6 @@ HOST_CFLAGS   ?= -O2
 HOST_CFLAGS   += $(HOST_CPPFLAGS)
 HOST_CXXFLAGS += $(HOST_CFLAGS)
 HOST_LDFLAGS  += -L$(HOST_DIR)/lib -L$(HOST_DIR)/usr/lib -Wl,-rpath,$(HOST_DIR)/usr/lib
-HOST_PATH = $(BR2_PATH)
 
 # hostcc version as an integer - E.G. 4.3.2 => 432
 HOSTCC_VERSION:=$(shell $(HOSTCC_NOCCACHE) --version | \
Signature · 1 line
1.8.4.2
#5 lore raw

PATCH 5/6 pkg-cmake.mk, pkg-autotools.mk: add PATH in the configure command environment

In reply to Samuel Martin
---
 package/pkg-autotools.mk | 2 ++
 package/pkg-cmake.mk     | 2 ++
 2 files changed, 4 insertions(+)
package/pkg-autotools.mk +2 -0
index 9523529..b405eb1 100644
@@ -102,6 +102,7 @@ ifeq ($(5),target)
 # Configure package for target
 define $(2)_CONFIGURE_CMDS
 	(cd $$($$(PKG)_SRCDIR) && rm -rf config.cache && \
+	PATH=$(BR2_PATH) \
 	$$(TARGET_CONFIGURE_OPTS) \
 	$$(TARGET_CONFIGURE_ARGS) \
 	$$($$(PKG)_CONF_ENV) \
@@ -129,6 +130,7 @@ else
 # installed.
 define $(2)_CONFIGURE_CMDS
 	(cd $$($$(PKG)_SRCDIR) && rm -rf config.cache; \
+		PATH=$(BR2_PATH) \
 	        $$(HOST_CONFIGURE_OPTS) \
 		CFLAGS="$$(HOST_CFLAGS)" \
 		LDFLAGS="$$(HOST_LDFLAGS)" \
package/pkg-cmake.mk +2 -0
index 0e08722..956fce8 100644
@@ -62,6 +62,7 @@ ifeq ($(5),target)
 define $(2)_CONFIGURE_CMDS
 	(cd $$($$(PKG)_BUILDDIR) && \
 	rm -f CMakeCache.txt && \
+	PATH=$(BR2_PATH) \
 	$$($$(PKG)_CONF_ENV) $(HOST_DIR)/usr/bin/cmake $$($$(PKG)_SRCDIR) \
 		-DCMAKE_TOOLCHAIN_FILE="$$(HOST_DIR)/usr/share/buildroot/toolchainfile.cmake" \
 		-DCMAKE_INSTALL_PREFIX="/usr" \
@@ -74,6 +75,7 @@ else
 define $(2)_CONFIGURE_CMDS
 	(cd $$($$(PKG)_BUILDDIR) && \
 	rm -f CMakeCache.txt && \
+	PATH=$(BR2_PATH) \
 	$(HOST_DIR)/usr/bin/cmake $$($$(PKG)_SRCDIR) \
 		-DCMAKE_INSTALL_SO_NO_EXE=0 \
 		-DCMAKE_FIND_ROOT_PATH="$$(HOST_DIR)" \
Signature · 1 line
1.8.4.2
#6 lore raw

PATCH 5/6 pkg-cmake.mk, pkg-autotools.mk: add PATH in the configure command environment

Dear Samuel Martin,

Quoted 13 lines · Samuel Martin
package/pkg-autotools.mk +1 -0
index 9523529..b405eb1 100644
@@ -102,6 +102,7 @@ ifeq ($(5),target)
 # Configure package for target
 define $(2)_CONFIGURE_CMDS
 	(cd $$($$(PKG)_SRCDIR) && rm -rf config.cache && \
+	PATH=$(BR2_PATH) \
 	$$(TARGET_CONFIGURE_OPTS) \
 	$$(TARGET_CONFIGURE_ARGS) \
 	$$($$(PKG)_CONF_ENV) \

package/pkg-autotools.mk else · line 136

Quoted 7 lines
package/pkg-autotools.mk +1 -0
@@ -129,6 +130,7 @@ else
 # installed.
 define $(2)_CONFIGURE_CMDS
 	(cd $$($$(PKG)_SRCDIR) && rm -rf config.cache; \
+		PATH=$(BR2_PATH) \
 	        $$(HOST_CONFIGURE_OPTS) \
 		CFLAGS="$$(HOST_CFLAGS)" \
 		LDFLAGS="$$(HOST_LDFLAGS)" \

These two chunks are not needed, since HOST_CONFIGURE_OPTS and TARGET_CONFIGURE_OPTS already contain PATH=$(BR2_PATH) (you changed them in PATH 3/6).

Quoted 13 lines
package/pkg-cmake.mk +1 -0
index 0e08722..956fce8 100644
@@ -62,6 +62,7 @@ ifeq ($(5),target)
 define $(2)_CONFIGURE_CMDS
 	(cd $$($$(PKG)_BUILDDIR) && \
 	rm -f CMakeCache.txt && \
+	PATH=$(BR2_PATH) \
 	$$($$(PKG)_CONF_ENV) $(HOST_DIR)/usr/bin/cmake $$($$(PKG)_SRCDIR) \
 		-DCMAKE_TOOLCHAIN_FILE="$$(HOST_DIR)/usr/share/buildroot/toolchainfile.cmake" \
 		-DCMAKE_INSTALL_PREFIX="/usr" \

package/pkg-cmake.mk else · line 81

Quoted 7 lines
package/pkg-cmake.mk +1 -0
@@ -74,6 +75,7 @@ else
 define $(2)_CONFIGURE_CMDS
 	(cd $$($$(PKG)_BUILDDIR) && \
 	rm -f CMakeCache.txt && \
+	PATH=$(BR2_PATH) \
 	$(HOST_DIR)/usr/bin/cmake $$($$(PKG)_SRCDIR) \
 		-DCMAKE_INSTALL_SO_NO_EXE=0 \
 		-DCMAKE_FIND_ROOT_PATH="$$(HOST_DIR)" \

However, I agree with those ones. An user recently reported a problem that was caused by cmake not having a proper PATH passed into its environment, and therefore failing to find some Buildroot tools (I think it was pkg-config).

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#7 lore raw

PATCH 6/6 Makefile: export PATH

In reply to Samuel Martin
---
 Makefile | 1 +
 1 file changed, 1 insertion(+)
Makefile +1 -0
index 4010c65..d587b4f 100644
@@ -294,6 +294,7 @@ export STAGING_DIR
 export HOST_DIR
 export BINARIES_DIR
 export BASE_DIR
+export PATH:=$(BR2_PATH)
 
 ################################################################################
 #
Signature · 1 line
1.8.4.2
#8 lore raw

PATCH 6/6 Makefile: export PATH

Dear Samuel Martin,

Quoted 10 lines · Samuel Martin
---
 Makefile | 1 +
 1 file changed, 1 insertion(+)
Makefile +0 -0
index 4010c65..d587b4f 100644

Makefile export STAGING_DIR · line 297

Quoted 4 lines
Makefile +1 -0
@@ -294,6 +294,7 @@ export STAGING_DIR
 export HOST_DIR
 export BINARIES_DIR
 export BASE_DIR
+export PATH:=$(BR2_PATH)

Why?

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#9 lore raw

PATCH 6/6 Makefile: export PATH

Thomas,

2013/11/11 Thomas Petazzoni <[email protected]>

Quoted 8 lines

Dear Samuel Martin,

Quoted 5 lines · Samuel Martin
---
 Makefile | 1 +
 1 file changed, 1 insertion(+)
Quoted 12 lines

Makefile export STAGING_DIR · line 297

Quoted 9 lines
Makefile +1 -0
index 4010c65..d587b4f 100644
@@ -294,6 +294,7 @@ export STAGING_DIR
 export HOST_DIR
 export BINARIES_DIR
 export BASE_DIR
+export PATH:=$(BR2_PATH)

Why?

To me, this could make easier writing post-{build,image} scripts. But, as I said in the cover letter, I'm dubious about this patch.

Regards,

Signature · 4 lines
Samuel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20131115/350b7808/attachment.html>
#10 lore raw

PATCH 6/6 Makefile: export PATH

Samuel, Thomas, All,

On 2013-11-15 21:37 +0100, Samuel Martin spake thusly:

Quoted 23 lines

2013/11/11 Thomas Petazzoni <[email protected]>

Quoted 8 lines

Dear Samuel Martin,

Quoted 5 lines · Samuel Martin
---
 Makefile | 1 +
 1 file changed, 1 insertion(+)
Quoted 12 lines

Makefile export STAGING_DIR · line 297

Quoted 9 lines
Makefile +1 -0
index 4010c65..d587b4f 100644
@@ -294,6 +294,7 @@ export STAGING_DIR
 export HOST_DIR
 export BINARIES_DIR
 export BASE_DIR
+export PATH:=$(BR2_PATH)

Why?

Quoted 1 line

To me, this could make easier writing post-{build,image} scripts.

Indeed, it *is* usefull for those scripts.

The first thing I do in br.config is to exactly set PATH to include the host/usr/bin and host/usr/sbin directories in front of the user's PATH.

But maybe we should just set PATH at the time we call them?

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#11 lore raw

PATCH 6/6 Makefile: export PATH

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Yann" == Yann E MORIN <[email protected]> writes:

Hi,

Quoted 8 lines
Quoted 1 line

To me, this could make easier writing post-{build,image} scripts.

Indeed, it *is* usefull for those scripts.

The first thing I do in br.config is to exactly set PATH to include the host/usr/bin and host/usr/sbin directories in front of the user's PATH.

But maybe we should just set PATH at the time we call them?

I *THINK* always adding those host directories to the path would be safe, as long as it happens after 'which' calls in the toplevel makefile. This would also allow us to get rid of HOST_PATH / TARGET_PATH (which are currently not identical, but should be).

But it will need some testing.

Signature · 1 line
Bye, Peter Korsgaard
#12 lore raw

PATCH 6/6 Makefile: export PATH

Hi all,

2013/11/17 Peter Korsgaard <[email protected]>

Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Yann" == Yann E MORIN <[email protected]> writes:

Hi,

Quoted 3 lines
Quoted 1 line

To me, this could make easier writing post-{build,image} scripts.

Indeed, it *is* usefull for those scripts.

Quoted 8 lines
Quoted 4 lines

The first thing I do in br.config is to exactly set PATH to include the host/usr/bin and host/usr/sbin directories in front of the user's PATH.

But maybe we should just set PATH at the time we call them?

I *THINK* always adding those host directories to the path would be safe, as long as it happens after 'which' calls in the toplevel makefile.

This is already the case. :-)

Quoted 5 lines

This would also allow us to get rid of HOST_PATH / TARGET_PATH (which are currently not identical, but should be).

But it will need some testing.

For what is worth, I use this series on top of master since this first submission
and I haven't got any problem so far.

Quoted 4 lines

--
Bye, Peter Korsgaard

Regards,

Signature · 4 lines
Samuel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20140102/14f37043/attachment.html>