Skip to contentSkip to conversation

packages: use backtick instead of $(shell ...) make function

PATCH New Arnout Vandecappelle (Essensium/Mind) 2 participants 6 messages Jul 12, 2015 – Jul 14, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 packages: use backtick instead of $(shell ...) make function

It is often difficult to know exactly when make will expand the variable, and usually it can only be expanded after the dependencies have been built (e.g. pkg-config or the .pc file). Using a backtick instead makes it very clear that it will be expanded only while executing the command.

This change is useful for two cases:

1. The per-package staging (and host) directory will be created as part of the configure step, so any $(shell ...) variable that is used in the configure step will fail because the directory doesn't exist yet.

2. 'make printvars' evaluates the variables it prints. It will therefore trigger a lot of errors from missing .pc files and others. The backticks, on the other hand, are not expanded, so with this change the output of 'make printvars' becomes clean again.

This commit contains only the easy changes: replace $(shell ...) with ..., and also replace ' with " where needed. Follow-up commits will tackle the more complicated cases that need additional explanation.

After this change, the following instances of $(shell ...) will remain:

- All assignments that use :=
- All variables that are used in make conditionals (which don't expand the backticks).
- All variables that only refer to system executables and make variables that don't change.
- The calls to check-host-* in dependencies.mk, because it is eval'ed.

[Original patch by Fabio Porcedda, but extended quite a bit by Arnout.]

---
v2: Taken over by Arnout
- expanded the commit log to cover the printvars use case, and to explain which cases remain unchanged
- added all other similar cases.

---
 package/aiccu/aiccu.mk                                  |  2 +-
 package/aircrack-ng/aircrack-ng.mk                      |  2 +-
 package/bustle/bustle.mk                                |  2 +-
 package/dbus-python/dbus-python.mk                      |  8 ++++----
 package/dhcpdump/dhcpdump.mk                            |  2 +-
 package/ejabberd/ejabberd.mk                            |  2 +-
 package/fbv/fbv.mk                                      |  2 +-
 package/gdk-pixbuf/gdk-pixbuf.mk                        |  2 +-
 package/gstreamer1/gst1-plugins-bad/gst1-plugins-bad.mk |  4 ++--
 package/iftop/iftop.mk                                  |  2 +-
 package/knock/knock.mk                                  |  2 +-
 package/kodi/kodi.mk                                    |  2 +-
 package/libgtk3/libgtk3.mk                              |  3 +--
 package/libmicrohttpd/libmicrohttpd.mk                  |  2 +-
 package/libssh2/libssh2.mk                              |  2 +-
 package/libupnpp/libupnpp.mk                            |  2 +-
 package/lmbench/lmbench.mk                              |  4 ++--
 package/logrotate/logrotate.mk                          |  2 +-
 package/madplay/madplay.mk                              |  2 +-
 package/mpg123/mpg123.mk                                |  2 +-
 package/neardal/neardal.mk                              |  2 +-
 package/ngrep/ngrep.mk                                  |  2 +-
 package/nmap/nmap.mk                                    |  4 ++--
 package/openldap/openldap.mk                            |  2 +-
 package/php/php.mk                                      |  4 ++--
 package/poppler/poppler.mk                              |  2 +-
 package/prboom/prboom.mk                                |  2 +-
 package/ptpd2/ptpd2.mk                                  |  2 +-
 package/python-gobject/python-gobject.mk                |  4 ++--
 package/python-pygame/python-pygame.mk                  |  6 +++---
 package/qt/qt.mk                                        | 14 +++++++-------
 package/tcpdump/tcpdump.mk                              |  2 +-
 package/tcpreplay/tcpreplay.mk                          |  6 +++---
 package/ti-utils/ti-utils.mk                            |  4 ++--
 package/upmpdcli/upmpdcli.mk                            |  2 +-
 package/vsftpd/vsftpd.mk                                |  2 +-
 package/xl2tp/xl2tp.mk                                  |  2 +-
 37 files changed, 56 insertions(+), 57 deletions(-)
package/aiccu/aiccu.mk +1 -1
index f2cd3de..fc328fd 100644
@@ -16,7 +16,7 @@ AICCU_LFDLAGS = $(TARGET_LDFLAGS)
 # aiccu forgets to link with gnutls' dependencies breaking the build when
 # linking statically
 ifeq ($(BR2_STATIC_LIBS),y)
-AICCU_LDFLAGS += $(shell $(PKG_CONFIG_HOST_BINARY) --static --libs gnutls)
+AICCU_LDFLAGS += `$(PKG_CONFIG_HOST_BINARY) --static --libs gnutls`
 endif
 
 # dummy RPM_OPT_FLAGS to disable stripping
package/aircrack-ng/aircrack-ng.mk +1 -1
index fc72c3b..7e5464d 100644
@@ -27,7 +27,7 @@ endif
 ifeq ($(BR2_PACKAGE_LIBPCAP),y)
 AIRCRACK_NG_DEPENDENCIES += libpcap
 AIRCRACK_NG_MAKE_OPTS += HAVE_PCAP=yes \
-	$(if $(BR2_STATIC_LIBS),LIBPCAP="-lpcap $(shell $(STAGING_DIR)/usr/bin/pcap-config --static --additional-libs)")
+	$(if $(BR2_STATIC_LIBS),LIBPCAP="-lpcap `$(STAGING_DIR)/usr/bin/pcap-config --static --additional-libs`")
 else
 AIRCRACK_NG_MAKE_OPTS += HAVE_PCAP=no
 endif
package/bustle/bustle.mk +1 -1
index 1ba36e0..0b85536 100644
@@ -12,7 +12,7 @@ BUSTLE_DEPENDENCIES = libglib2 libpcap host-pkgconf
 
 BUSTLE_PCAP_FLAGS = "-lpcap"
 ifeq ($(BR2_STATIC_LIBS),y)
-BUSTLE_PCAP_FLAGS += $(shell $(STAGING_DIR)/usr/bin/pcap-config --static --additional-libs)
+BUSTLE_PCAP_FLAGS += `$(STAGING_DIR)/usr/bin/pcap-config --static --additional-libs`
 endif
 
 define BUSTLE_BUILD_CMDS
package/dbus-python/dbus-python.mk +4 -4
index 9bda018..4079967 100644
@@ -17,15 +17,15 @@ DBUS_PYTHON_DEPENDENCIES += python host-python
 
 DBUS_PYTHON_CONF_ENV += \
 	PYTHON=$(HOST_DIR)/usr/bin/python2 \
-	PYTHON_INCLUDES="$(shell $(STAGING_DIR)/usr/bin/python2-config --includes)" \
-	PYTHON_LIBS="$(shell $(STAGING_DIR)/usr/bin/python2-config --ldflags)"
+	PYTHON_INCLUDES="`$(STAGING_DIR)/usr/bin/python2-config --includes`" \
+	PYTHON_LIBS="`$(STAGING_DIR)/usr/bin/python2-config --ldflags`"
 else
 DBUS_PYTHON_DEPENDENCIES += python3 host-python3
 
 DBUS_PYTHON_CONF_ENV += \
 	PYTHON=$(HOST_DIR)/usr/bin/python3 \
-	PYTHON_INCLUDES="$(shell $(STAGING_DIR)/usr/bin/python3-config --includes)" \
-	PYTHON_LIBS="$(shell $(STAGING_DIR)/usr/bin/python3-config --ldflags)"
+	PYTHON_INCLUDES="`$(STAGING_DIR)/usr/bin/python3-config --includes`" \
+	PYTHON_LIBS="`$(STAGING_DIR)/usr/bin/python3-config --ldflags`"
 endif
 
 $(eval $(autotools-package))
package/dhcpdump/dhcpdump.mk +1 -1
index 0756319..15fc02f 100644
@@ -12,7 +12,7 @@ DHCPDUMP_LICENSE_FILES = LICENSE
 
 DHCPDUMP_LIBS = -lpcap
 ifeq ($(BR2_STATIC_LIBS),y)
-DHCPDUMP_LIBS += $(shell $(STAGING_DIR)/usr/bin/pcap-config --static --additional-libs)
+DHCPDUMP_LIBS += `$(STAGING_DIR)/usr/bin/pcap-config --static --additional-libs`
 endif
 
 define DHCPDUMP_BUILD_CMDS
package/ejabberd/ejabberd.mk +1 -1
index b413c8b..7e22e0c 100644
@@ -26,7 +26,7 @@ EJABBERD_ERLANG_LIBS = sasl crypto public_key ssl mnesia inets compiler
 EJABBERD_CONF_ENV = \
 	ac_cv_erlang_root_dir="$(HOST_DIR)/usr/lib/erlang" \
 	$(foreach lib,$(EJABBERD_ERLANG_LIBS), \
-		ac_cv_erlang_lib_dir_$(lib)="$(shell package/ejabberd/check-erlang-lib $(lib))")
+		ac_cv_erlang_lib_dir_$(lib)="`package/ejabberd/check-erlang-lib $(lib)`")
 
 define EJABBERD_INSTALL_TARGET_CMDS
 	$(TARGET_MAKE_ENV) $(MAKE) DESTDIR=$(TARGET_DIR) install -C $(@D)
package/fbv/fbv.mk +1 -1
index 8788b0e..5f7dc8c 100644
@@ -18,7 +18,7 @@ FBV_DEPENDENCIES += libpng
 
 # libpng in turn depends on other libraries
 ifeq ($(BR2_STATIC_LIBS),y)
-FBV_CONFIGURE_OPTS += "--libs=$(shell $(PKG_CONFIG_HOST_BINARY) --libs libpng --static)"
+FBV_CONFIGURE_OPTS += "--libs=`$(PKG_CONFIG_HOST_BINARY) --libs libpng --static`"
 endif
 
 else
package/gdk-pixbuf/gdk-pixbuf.mk +1 -1
index eb30215..3a66e61 100644
@@ -35,7 +35,7 @@ GDK_PIXBUF_CONF_OPTS += --without-libtiff
 else
 GDK_PIXBUF_DEPENDENCIES += tiff host-pkgconf
 GDK_PIXBUF_CONF_ENV += \
-	LIBS='$(shell $(PKG_CONFIG_HOST_BINARY) --libs libtiff-4)'
+	LIBS="`$(PKG_CONFIG_HOST_BINARY) --libs libtiff-4`"
 endif
 
 ifeq ($(BR2_PACKAGE_XLIB_LIBX11),y)
package/gstreamer1/gst1-plugins-bad/gst1-plugins-bad.mk +2 -2
index faf0e2a..ee936fe 100644
@@ -119,8 +119,8 @@ ifeq ($(BR2_PACKAGE_GST1_PLUGINS_BAD_LIB_OPENGL_EGL),y)
 GST1_PLUGINS_BAD_CONF_OPTS += --enable-egl
 GST1_PLUGINS_BAD_DEPENDENCIES += libegl
 GST1_PLUGINS_BAD_CONF_ENV += \
-	CPPFLAGS="$(TARGET_CPPFLAGS) $(shell $(PKG_CONFIG_HOST_BINARY) --cflags egl)" \
-	LIBS="$(shell $(PKG_CONFIG_HOST_BINARY) --libs egl)"
+	CPPFLAGS="$(TARGET_CPPFLAGS) `$(PKG_CONFIG_HOST_BINARY) --cflags egl`" \
+	LIBS="`$(PKG_CONFIG_HOST_BINARY) --libs egl`"
 else
 GST1_PLUGINS_BAD_CONF_OPTS += --disable-egl
 endif
package/iftop/iftop.mk +1 -1
index bea05ba..042f2b2 100644
@@ -12,7 +12,7 @@ IFTOP_LICENSE_FILES = COPYING
 
 IFTOP_LIBS = -lpcap
 ifeq ($(BR2_STATIC_LIBS),y)
-IFTOP_LIBS += $(shell $(STAGING_DIR)/usr/bin/pcap-config --static --additional-libs)
+IFTOP_LIBS += `$(STAGING_DIR)/usr/bin/pcap-config --static --additional-libs`
 endif
 IFTOP_CONF_ENV += LIBS+="$(IFTOP_LIBS)"
 
package/knock/knock.mk +1 -1
index 2c0adb1..28db1eb 100644
@@ -11,7 +11,7 @@ KNOCK_LICENSE_FILES = COPYING
 KNOCK_DEPENDENCIES = libpcap
 
 ifeq ($(BR2_STATIC_LIBS),y)
-KNOCK_CONF_OPTS = LIBS="$(shell $(STAGING_DIR)/usr/bin/pcap-config --static --additional-libs)"
+KNOCK_CONF_OPTS = LIBS="`$(STAGING_DIR)/usr/bin/pcap-config --static --additional-libs`"
 endif
 
 $(eval $(autotools-package))
package/kodi/kodi.mk +1 -1
index cc42df4..ad61f0d 100644
@@ -112,7 +112,7 @@ else
 KODI_CONF_OPTS += --disable-gl --disable-rsxs --disable-sdl --disable-x11 --disable-xrandr
 ifeq ($(BR2_PACKAGE_KODI_EGL_GLES),y)
 KODI_DEPENDENCIES += libegl libgles
-KODI_CONF_ENV += CXXFLAGS="$(TARGET_CXXFLAGS) $(shell $(PKG_CONFIG_HOST_BINARY) --cflags egl)"
+KODI_CONF_ENV += CXXFLAGS="$(TARGET_CXXFLAGS) `$(PKG_CONFIG_HOST_BINARY) --cflags egl`"
 KODI_CONF_OPTS += --enable-gles
 else
 KODI_CONF_OPTS += --disable-gles
package/libgtk3/libgtk3.mk +1 -2
index ee73291..80dbf94 100644
@@ -149,8 +149,7 @@ HOST_LIBGTK3_DEPENDENCIES = \
 	host-pkgconf
 
 HOST_LIBGTK3_CFLAGS = \
-	$(shell $(HOST_DIR)/usr/bin/pkgconf \
-	--cflags --libs gdk-pixbuf-2.0)
+	`$(HOST_DIR)/usr/bin/pkgconf --cflags --libs gdk-pixbuf-2.0`
 
 define HOST_LIBGTK3_CONFIGURE_CMDS
 	echo "#define GETTEXT_PACKAGE \"gtk30\"" >> $(@D)/gtk/config.h
package/libmicrohttpd/libmicrohttpd.mk +1 -1
index a6662a7..f8a9d22 100644
@@ -13,7 +13,7 @@ LIBMICROHTTPD_CONF_OPTS = --disable-curl --disable-spdy --disable-examples
 ifeq ($(BR2_PACKAGE_LIBMICROHTTPD_SSL),y)
 LIBMICROHTTPD_LICENSE = LGPLv2.1+
 LIBMICROHTTPD_DEPENDENCIES += host-pkgconf gnutls libgcrypt
-LIBMICROHTTPD_CONF_ENV += LIBS="$(shell $(PKG_CONFIG_HOST_BINARY) --libs gnutls)"
+LIBMICROHTTPD_CONF_ENV += LIBS="`$(PKG_CONFIG_HOST_BINARY) --libs gnutls`"
 LIBMICROHTTPD_CONF_OPTS += --enable-https --with-gnutls=$(STAGING_DIR)/usr \
 	--with-libgcrypt-prefix=$(STAGING_DIR)/usr
 else
package/libssh2/libssh2.mk +1 -1
index 3b4df37..bf040a8 100644
@@ -20,7 +20,7 @@ LIBSSH2_CONF_OPTS += --with-libgcrypt \
 	--without-openssl
 # configure.ac forgets to link to dependent libraries of gcrypt breaking static
 # linking
-LIBSSH2_CONF_ENV += LIBS="$(shell $(STAGING_DIR)/usr/bin/libgcrypt-config --libs)"
+LIBSSH2_CONF_ENV += LIBS="`$(STAGING_DIR)/usr/bin/libgcrypt-config --libs`"
 else
 LIBSSH2_DEPENDENCIES += openssl
 LIBSSH2_CONF_OPTS += --with-openssl \
package/libupnpp/libupnpp.mk +1 -1
index caf61af..1075ff9 100644
@@ -16,7 +16,7 @@ LIBUPNPP_DEPENDENCIES = expat libcurl libupnp
 ifeq ($(BR2_STATIC_LIBS),y)
 LIBUPNPP_DEPENDENCIES += host-pkgconf
 LIBUPNPP_CONF_ENV += \
-	LIBS='$(shell $(PKG_CONFIG_HOST_BINARY) --libs libupnp libcurl)'
+	LIBS="`$(PKG_CONFIG_HOST_BINARY) --libs libupnp libcurl`"
 endif
 
 $(eval $(autotools-package))
package/lmbench/lmbench.mk +2 -2
index f593428..dc758c6 100644
@@ -14,8 +14,8 @@ LMBENCH_CFLAGS = $(TARGET_CFLAGS)
 
 ifeq ($(BR2_PACKAGE_LIBTIRPC),y)
 LMBENCH_DEPENDENCIES += host-pkgconf libtirpc
-LMBENCH_CFLAGS += $(shell $(PKG_CONFIG_HOST_BINARY) --cflags libtirpc)
-LMBENCH_LDLIBS = $(shell $(PKG_CONFIG_HOST_BINARY) --libs libtirpc)
+LMBENCH_CFLAGS += `$(PKG_CONFIG_HOST_BINARY) --cflags libtirpc`
+LMBENCH_LDLIBS = `$(PKG_CONFIG_HOST_BINARY) --libs libtirpc`
 endif
 
 define LMBENCH_CONFIGURE_CMDS
package/logrotate/logrotate.mk +1 -1
index 0af7f4a..4a70040 100644
@@ -11,7 +11,7 @@ LOGROTATE_LICENSE_FILES = COPYING
 LOGROTATE_DEPENDENCIES = popt host-pkgconf
 # tarball does not have a generated configure script
 LOGROTATE_AUTORECONF = YES
-LOGROTATE_CONF_ENV = LIBS="$(shell $(PKG_CONFIG_HOST_BINARY) --libs popt)"
+LOGROTATE_CONF_ENV = LIBS="`$(PKG_CONFIG_HOST_BINARY) --libs popt`"
 LOGROTATE_CONF_OPTS = --without-selinux
 
 ifeq ($(BR2_PACKAGE_ACL),y)
package/madplay/madplay.mk +1 -1
index ff12aa1..2606ac8 100644
@@ -16,7 +16,7 @@ MADPLAY_DEPENDENCIES = libmad libid3tag $(if $(BR2_PACKAGE_GETTEXT),gettext)
 ifeq ($(BR2_PACKAGE_MADPLAY_ALSA),y)
 MADPLAY_CONF_OPTS += --with-alsa
 MADPLAY_DEPENDENCIES += host-pkgconf alsa-lib
-MADPLAY_CONF_ENV += LIBS="$(shell $(PKG_CONFIG_HOST_BINARY) --libs alsa)"
+MADPLAY_CONF_ENV += LIBS="`$(PKG_CONFIG_HOST_BINARY) --libs alsa`"
 endif
 
 $(eval $(autotools-package))
package/mpg123/mpg123.mk +1 -1
index a16e400..4c534e2 100644
@@ -54,7 +54,7 @@ MPG123_CONF_OPTS += --with-default-audio=portaudio
 MPG123_DEPENDENCIES += portaudio
 # configure script does NOT use pkg-config to figure out how to link
 # with portaudio, breaking static linking as portaudio uses pthreads
-MPG123_CONF_ENV += LIBS='$(shell $(PKG_CONFIG_HOST_BINARY) --libs portaudio-2.0)'
+MPG123_CONF_ENV += LIBS="`$(PKG_CONFIG_HOST_BINARY) --libs portaudio-2.0`"
 endif
 
 ifeq ($(BR2_PACKAGE_SDL),y)
package/neardal/neardal.mk +1 -1
index ddaecbe..c3164ef 100644
@@ -25,7 +25,7 @@ endif
 # forgets to take that into account, causing the detection to fail
 # when linking statically
 ifeq ($(BR2_STATIC_LIBS),y)
-NEARDAL_CONF_ENV += LIBS='$(shell $(PKG_CONFIG_HOST_BINARY) --libs ncurses)'
+NEARDAL_CONF_ENV += LIBS="`$(PKG_CONFIG_HOST_BINARY) --libs ncurses`"
 endif
 
 define NEARDAL_INSTALL_NCL
package/ngrep/ngrep.mk +1 -1
index f2fcb73..c4ad528 100644
@@ -13,7 +13,7 @@ NGREP_INSTALL_STAGING = YES
 
 NGREP_LIBS = -lpcap -lpcre
 ifeq ($(BR2_STATIC_LIBS),y)
-NGREP_LIBS += $(shell $(STAGING_DIR)/usr/bin/pcap-config --static --additional-libs)
+NGREP_LIBS += `$(STAGING_DIR)/usr/bin/pcap-config --static --additional-libs`
 endif
 NGREP_CONF_ENV += LIBS+="$(NGREP_LIBS)"
 
package/nmap/nmap.mk +2 -2
index d46d58b..d450f5e 100644
@@ -15,10 +15,10 @@ NMAP_LICENSE = GPLv2
 NMAP_LICENSE_FILES = COPYING
 
 # needed by libpcap
-NMAP_LIBS_FOR_STATIC_LINK += $(shell $(STAGING_DIR)/usr/bin/pcap-config --static --additional-libs)
+NMAP_LIBS_FOR_STATIC_LINK += `$(STAGING_DIR)/usr/bin/pcap-config --static --additional-libs`
 
 ifeq ($(BR2_STATIC_LIBS),y)
-NMAP_CONF_ENV += LIBS='$(NMAP_LIBS_FOR_STATIC_LINK)'
+NMAP_CONF_ENV += LIBS="$(NMAP_LIBS_FOR_STATIC_LINK)"
 endif
 
 # for 0001-libdnet-wrapper-configure.patch
package/openldap/openldap.mk +1 -1
index ecb1bce..4c3a71a 100644
@@ -31,7 +31,7 @@ endif
 ifeq ($(BR2_PACKAGE_OPENSSL),y)
 OPENLDAP_MP = bignum
 OPENLDAP_DEPENDENCIES += openssl
-OPENLDAP_CONF_ENV = LIBS="$(shell $(PKG_CONFIG_HOST_BINARY) --libs libssl libcrypto)"
+OPENLDAP_CONF_ENV = LIBS="`$(PKG_CONFIG_HOST_BINARY) --libs libssl libcrypto`"
 else ifeq ($(BR2_PACKAGE_GMP),y)
 OPENLDAP_MP = gmp
 OPENLDAP_DEPENDENCIES += gmp
package/php/php.mk +2 -2
index 53aaecf..39f4e2a 100644
@@ -116,7 +116,7 @@ PHP_CONF_OPTS += --with-openssl=$(STAGING_DIR)/usr
 PHP_DEPENDENCIES += openssl
 # openssl needs zlib, but the configure script forgets to link against
 # it causing detection failures with static linking
-PHP_STATIC_LIBS += $(shell $(PKG_CONFIG_HOST_BINARY) --libs --static openssl)
+PHP_STATIC_LIBS += `$(PKG_CONFIG_HOST_BINARY) --libs --static openssl`
 endif
 
 ifeq ($(BR2_PACKAGE_PHP_EXT_LIBXML2),y)
@@ -187,7 +187,7 @@ endif
 ifeq ($(BR2_PACKAGE_PHP_EXT_SQLITE),y)
 PHP_CONF_OPTS += --with-sqlite3=$(STAGING_DIR)/usr
 PHP_DEPENDENCIES += sqlite
-PHP_STATIC_LIBS += $(shell $(PKG_CONFIG_HOST_BINARY) --libs --static sqlite3)
+PHP_STATIC_LIBS += `$(PKG_CONFIG_HOST_BINARY) --libs --static sqlite3`
 endif
 
 ### PDO
package/poppler/poppler.mk +1 -1
index 234b7cc..6142cba 100644
@@ -24,7 +24,7 @@ ifeq ($(BR2_PACKAGE_TIFF),y)
 POPPLER_CONF_OPTS += --enable-libtiff
 # Help poppler to find libtiff in static linking scenarios
 POPPLER_CONF_ENV += \
-	LIBTIFF_LIBS="$(shell $(PKG_CONFIG_HOST_BINARY) --libs libtiff-4)"
+	LIBTIFF_LIBS="`$(PKG_CONFIG_HOST_BINARY) --libs libtiff-4`"
 POPPLER_DEPENDENCIES += tiff
 else
 POPPLER_CONF_OPTS += --disable-libtiff
package/prboom/prboom.mk +1 -1
index 3d131cd..5f5e7fb 100644
@@ -18,7 +18,7 @@ endif
 ifeq ($(BR2_STATIC_LIBS),y)
 # SDL_mixer uses symbols from SDL, but ends up after it on the link
 # cmdline. Fix it by forcing the SDL libs at the very end
-PRBOOM_CONF_ENV += LIBS="$(shell $(STAGING_DIR)/usr/bin/sdl-config --static-libs)"
+PRBOOM_CONF_ENV += LIBS="`$(STAGING_DIR)/usr/bin/sdl-config --static-libs`"
 endif
 
 PRBOOM_CONF_OPTS = \
package/ptpd2/ptpd2.mk +1 -1
index e1d4f27..5ef69e5 100644
@@ -14,7 +14,7 @@ PTPD2_LICENSE = BSD-2c
 PTPD2_LICENSE_FILES = COPYRIGHT
 
 ifeq ($(BR2_STATIC_LIBS),y)
-PTPD2_CONF_OPTS += LIBS="$(shell $(STAGING_DIR)/usr/bin/pcap-config --static --additional-libs)"
+PTPD2_CONF_OPTS += LIBS="`$(STAGING_DIR)/usr/bin/pcap-config --static --additional-libs`"
 endif
 
 ifeq ($(BR2_PACKAGE_NETSNMP),y)
package/python-gobject/python-gobject.mk +2 -2
index c47954c..74cb054 100644
@@ -20,13 +20,13 @@ PYTHON_GOBJECT_DEPENDENCIES += python host-python
 
 PYTHON_GOBJECT_CONF_ENV = \
 	PYTHON=$(HOST_DIR)/usr/bin/python2 \
-	PYTHON_INCLUDES="$(shell $(STAGING_DIR)/usr/bin/python2-config --includes)"
+	PYTHON_INCLUDES="`$(STAGING_DIR)/usr/bin/python2-config --includes`"
 else
 PYTHON_GOBJECT_DEPENDENCIES += python3 host-python3
 
 PYTHON_GOBJECT_CONF_ENV = \
 	PYTHON=$(HOST_DIR)/usr/bin/python3 \
-	PYTHON_INCLUDES="$(shell $(STAGING_DIR)/usr/bin/python3-config --includes)"
+	PYTHON_INCLUDES="`$(STAGING_DIR)/usr/bin/python3-config --includes`"
 endif
 
 ifeq ($(BR2_PACKAGE_LIBFFI),y)
package/python-pygame/python-pygame.mk +3 -3
index 51f1c20..995f80a 100644
@@ -66,14 +66,14 @@ define PYTHON_PYGAME_UNCONFIGURE_SCRAP
 endef
 endif
 
-PYTHON_PYGAME_SDL_FLAGS = $(shell $(STAGING_DIR)/usr/bin/sdl-config --cflags)
-PYTHON_PYGAME_SDL_FLAGS += $(shell $(STAGING_DIR)/usr/bin/sdl-config --libs)
+PYTHON_PYGAME_SDL_FLAGS = `$(STAGING_DIR)/usr/bin/sdl-config --cflags`
+PYTHON_PYGAME_SDL_FLAGS += `$(STAGING_DIR)/usr/bin/sdl-config --libs`
 
 # Pygame needs a Setup file where options should be commented out if
 # dependencies are not available
 define PYTHON_PYGAME_CONFIGURE_CMDS
 	cp -f $(@D)/Setup.in $(@D)/Setup
-	$(SED) 's~^SDL = ~SDL = $(PYTHON_PYGAME_SDL_FLAGS) \n#~' $(@D)/Setup
+	$(SED) "s~^SDL = ~SDL = $(PYTHON_PYGAME_SDL_FLAGS) \n#~" $(@D)/Setup
 	$(SED) 's/^pypm/#pypm/' $(@D)/Setup
 	$(PYTHON_PYGAME_UNCONFIGURE_IMAGE)
 	$(PYTHON_PYGAME_UNCONFIGURE_FONT)
package/qt/qt.mk +7 -7
index 02b6db7..e0e5d22 100644
@@ -230,9 +230,9 @@ QT_DEPENDENCIES += fontconfig xlib_libXi xlib_libX11 xlib_libXrender \
 	xlib_libXcursor xlib_libXrandr xlib_libXext xlib_libXv
 # Using pkg-config avoids us some logic to redefine and sed again mkspecs files
 # to add X11 include path and link options
-QT_CFLAGS += $(shell $(PKG_CONFIG_HOST_BINARY) --cflags x11)
-QT_CXXFLAGS += $(shell $(PKG_CONFIG_HOST_BINARY) --cflags x11)
-QT_LDFLAGS += $(shell $(PKG_CONFIG_HOST_BINARY) --libs x11 xext)
+QT_CFLAGS += `$(PKG_CONFIG_HOST_BINARY) --cflags x11`
+QT_CXXFLAGS += `$(PKG_CONFIG_HOST_BINARY) --cflags x11`
+QT_LDFLAGS += `$(PKG_CONFIG_HOST_BINARY) --libs x11 xext`
 QT_CONFIGURE_OPTS += -arch $(QT_EMB_PLATFORM) \
 		-xplatform qws/linux-$(QT_EMB_PLATFORM)-g++ -x11 -no-gtkstyle -no-sm \
 		-no-openvg
@@ -329,9 +329,9 @@ endif
 ifeq ($(BR2_PACKAGE_QT_OPENGL_ES),y)
 QT_CONFIGURE_OPTS += -opengl es2 -egl
 QT_DEPENDENCIES += libgles libegl
-QT_CFLAGS += $(shell $(PKG_CONFIG_HOST_BINARY) --cflags egl)
-QT_CXXFLAGS += $(shell $(PKG_CONFIG_HOST_BINARY) --cflags egl)
-QT_LDFLAGS += $(shell $(PKG_CONFIG_HOST_BINARY) --libs egl)
+QT_CFLAGS += `$(PKG_CONFIG_HOST_BINARY) --cflags egl`
+QT_CXXFLAGS += `$(PKG_CONFIG_HOST_BINARY) --cflags egl`
+QT_LDFLAGS += `$(PKG_CONFIG_HOST_BINARY) --libs egl`
 else
 QT_CONFIGURE_OPTS += -no-opengl
 endif
@@ -473,7 +473,7 @@ QT_QMAKE = $(HOST_DIR)/usr/bin/qmake -spec qws/linux-$(QT_EMB_PLATFORM)-g++
 ################################################################################
 define QT_QMAKE_SET
 	$(SED) '/$(1)/d' $(3)/mkspecs/qws/linux-$(QT_EMB_PLATFORM)-g++/qmake.conf
-	$(SED) '/include.*qws.conf/a$(1) = $(2)' $(3)/mkspecs/qws/linux-$(QT_EMB_PLATFORM)-g++/qmake.conf
+	$(SED) "/include.*qws.conf/a$(1) = $(2)" $(3)/mkspecs/qws/linux-$(QT_EMB_PLATFORM)-g++/qmake.conf
 endef
 
 ifneq ($(QT_CONFIG_FILE),)
package/tcpdump/tcpdump.mk +1 -1
index 6a88305..14b3503 100644
@@ -19,7 +19,7 @@ TCPDUMP_CONF_OPTS = \
 TCPDUMP_DEPENDENCIES = zlib libpcap
 
 ifeq ($(BR2_STATIC_LIBS),y)
-TCPDUMP_CONF_OPTS += LIBS="$(shell $(STAGING_DIR)/usr/bin/pcap-config --static --additional-libs)"
+TCPDUMP_CONF_OPTS += LIBS="`$(STAGING_DIR)/usr/bin/pcap-config --static --additional-libs`"
 endif
 
 # make install installs an unneeded extra copy of the tcpdump binary
package/tcpreplay/tcpreplay.mk +3 -3
index 1dbe453..f6bd08f 100644
@@ -16,9 +16,9 @@ TCPREPLAY_CONF_OPTS = --with-libpcap=$(STAGING_DIR)/usr
 TCPREPLAY_DEPENDENCIES = libpcap
 
 # libpcap may depend on symbols in other libs
-TCPREPLAY_LIBS = $(shell $(STAGING_DIR)/usr/bin/pcap-config --static --libs)
-TCPREPLAY_CONF_ENV += ac_cv_search_pcap_close='$(TCPREPLAY_LIBS)' \
-	LIBS="$(TCPREPLAY_LIBS)"
+TCPREPLAY_LIBS = $(STAGING_DIR)/usr/bin/pcap-config --static --libs
+TCPREPLAY_CONF_ENV += ac_cv_search_pcap_close="`$(TCPREPLAY_LIBS)`" \
+	LIBS="`$(TCPREPLAY_LIBS)`"
 
 ifeq ($(BR2_PACKAGE_TCPDUMP),y)
 TCPREPLAY_CONF_ENV += ac_cv_path_tcpdump_path=/usr/sbin/tcpdump
package/ti-utils/ti-utils.mk +2 -2
index 3141219..06aca6d 100644
@@ -10,8 +10,8 @@ TI_UTILS_DEPENDENCIES = libnl host-pkgconf
 TI_UTILS_LICENSE = BSD-3c
 TI_UTILS_LICENSE_FILES = COPYING
 
-TI_UTILS_CFLAGS = $(shell $(PKG_CONFIG_HOST_BINARY) --cflags libnl-genl-3.0)
-TI_UTILS_LIBS = $(shell $(PKG_CONFIG_HOST_BINARY) --libs libnl-genl-3.0)
+TI_UTILS_CFLAGS = `$(PKG_CONFIG_HOST_BINARY) --cflags libnl-genl-3.0`
+TI_UTILS_LIBS = `$(PKG_CONFIG_HOST_BINARY) --libs libnl-genl-3.0`
 
 define TI_UTILS_BUILD_CMDS
 	$(MAKE1) NFSROOT="$(STAGING_DIR)" \
package/upmpdcli/upmpdcli.mk +1 -1
index 9531b61..8dde87d 100644
@@ -19,7 +19,7 @@ ifeq ($(BR2_STATIC_LIBS),y)
 # manually pass it to make.
 UPMPDCLI_DEPENDENCIES += host-pkgconf
 UPMPDCLI_MAKE_OPTS = \
-	LIBS='$(shell $(PKG_CONFIG_HOST_BINARY) --libs expat libcurl libupnp)'
+	LIBS="`$(PKG_CONFIG_HOST_BINARY) --libs expat libcurl libupnp`"
 endif
 
 # Upmpdcli only runs if user upmpdcli exists
package/vsftpd/vsftpd.mk +1 -1
index 3091f06..e5b505d 100644
@@ -24,7 +24,7 @@ endif
 
 ifeq ($(BR2_PACKAGE_OPENSSL),y)
 VSFTPD_DEPENDENCIES += openssl host-pkgconf
-VSFTPD_LIBS += $(shell $(PKG_CONFIG_HOST_BINARY) --libs libssl libcrypto)
+VSFTPD_LIBS += `$(PKG_CONFIG_HOST_BINARY) --libs libssl libcrypto`
 VSFTPD_POST_CONFIGURE_HOOKS += VSFTPD_ENABLE_SSL
 endif
 
package/xl2tp/xl2tp.mk +1 -1
index d6b849a..a823716 100644
@@ -11,7 +11,7 @@ XL2TP_LICENSE = GPLv2
 XL2TP_LICENSE_FILES = LICENSE
 
 ifeq ($(BR2_STATIC_LIBS),y)
-XL2TP_LDLIBS = LDLIBS="$(shell $(STAGING_DIR)/usr/bin/pcap-config --static --additional-libs)"
+XL2TP_LDLIBS = LDLIBS="`$(STAGING_DIR)/usr/bin/pcap-config --static --additional-libs`"
 endif
 
 define XL2TP_BUILD_CMDS
Signature · 1 line
2.1.4
#1 lore raw

PATCH 2/5 linux: use backtick instead of $(shell ...) make function

Verified that LINUX_VERSION_PROBED is only used in "-quoted commands (actually, usually it's not quoted).

---
Note: this one is not needed for per-package staging, and for printvars it's maybe not such a great idea since we may want to see the actual probed value. OTOH, if linux has not been configured yet (or is not selected in .config), it still looks pretty bad.

---
 linux/linux.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
linux/linux.mk +1 -1
index eca1450..9deec36 100644
@@ -76,7 +76,7 @@ LINUX_MAKE_ENV = \
 
 # Get the real Linux version, which tells us where kernel modules are
 # going to be installed in the target filesystem.
-LINUX_VERSION_PROBED = $(shell $(MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_DIR) --no-print-directory -s kernelrelease)
+LINUX_VERSION_PROBED = `$(MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_DIR) --no-print-directory -s kernelrelease`
 
 ifeq ($(BR2_LINUX_KERNEL_USE_INTREE_DTS),y)
 KERNEL_DTS_NAME = $(call qstrip,$(BR2_LINUX_KERNEL_INTREE_DTS_NAME))
Signature · 1 line
2.1.4
#2 lore raw

PATCH 3/5 boost: use backtick instead of $(shell ...) make function

In reply to Arnout Vandecappelle (Essensium/Mind)

Also remove the variables TARGET_CC_VERSION and HOST_CC_VERSION which lack the BOOST_ prefix and are used only once.

---
 package/boost/boost.mk | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
package/boost/boost.mk +2 -5
index dbb5de5..cc3ba9e 100644
@@ -11,9 +11,6 @@ BOOST_INSTALL_STAGING = YES
 BOOST_LICENSE = Boost Software License 1.0
 BOOST_LICENSE_FILES = LICENSE_1_0.txt
 
-TARGET_CC_VERSION = $(shell $(TARGET_CC) -dumpversion)
-HOST_CC_VERSION = $(shell $(HOSTCC) -dumpversion)
-
 HOST_BOOST_DEPENDENCIES =
 
 # keep host variant as minimal as possible
@@ -111,13 +108,13 @@ BOOST_LAYOUT = $(call qstrip, $(BR2_PACKAGE_BOOST_LAYOUT))
 
 define BOOST_CONFIGURE_CMDS
 	(cd $(@D) && ./bootstrap.sh $(BOOST_FLAGS))
-	echo "using gcc : $(TARGET_CC_VERSION) : $(TARGET_CXX) : <cxxflags>\"$(BOOST_TARGET_CXXFLAGS)\" <linkflags>\"$(TARGET_LDFLAGS)\" ;" > $(@D)/user-config.jam
+	echo "using gcc : `$(TARGET_CC) -dumpversion` : $(TARGET_CXX) : <cxxflags>\"$(BOOST_TARGET_CXXFLAGS)\" <linkflags>\"$(TARGET_LDFLAGS)\" ;" > $(@D)/user-config.jam
 	echo "" >> $(@D)/user-config.jam
 endef
 
 define HOST_BOOST_CONFIGURE_CMDS
 	(cd $(@D) && ./bootstrap.sh $(HOST_BOOST_FLAGS))
-	echo "using gcc : $(HOST_CC_VERSION) : $(HOSTCXX) : <cxxflags>\"$(HOST_CXXFLAGS)\" <linkflags>\"$(HOST_LDFLAGS)\" ;" > $(@D)/user-config.jam
+	echo "using gcc : `$(HOST_CC) -dumpversion` : $(HOSTCXX) : <cxxflags>\"$(HOST_CXXFLAGS)\" <linkflags>\"$(HOST_LDFLAGS)\" ;" > $(@D)/user-config.jam
 	echo "" >> $(@D)/user-config.jam
 endef
 
Signature · 1 line
2.1.4
#3 lore raw

PATCH 4/5 mpg123: replace $(shell ...) call with $(subst ...)

In reply to Arnout Vandecappelle (Essensium/Mind)

There's no reason to use a shell here.

---
 package/mpg123/mpg123.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/mpg123/mpg123.mk +1 -1
index 4c534e2..171cbde 100644
@@ -69,7 +69,7 @@ MPG123_CONF_OPTS += --with-default-audio=alsa
 MPG123_DEPENDENCIES += alsa-lib
 endif
 
-MPG123_CONF_OPTS += --with-audio=$(shell echo $(MPG123_AUDIO) | tr ' ' ,)
+MPG123_CONF_OPTS += --with-audio=$(subst $(space),$(comma),$(MPG123_AUDIO))
 
 ifeq ($(BR2_PACKAGE_LIBTOOL),y)
 MPG123_DEPENDENCIES += libtool
Signature · 1 line
2.1.4
#4 lore raw

PATCH 5/5 system: use backtick instead of $(shell ...) make function

In reply to Arnout Vandecappelle (Essensium/Mind)

Only the instance for setting the root password is changed. The instance in SYSTEM_GETTY is harmless since it just uses echo and tail.

If TARGET_GENERIC_ROOT_PASSWD is passed as a hashed password by the user, it contains $, so the '-quotes are needed. If it is not, we need the backtick to be expanded so "-quotes are needed. Therefore, the quoting is moved to the definition of SYSTEM_ROOT_PASSWORD.

---
This one is a bit complicated so could perhaps also be dropped. It is only useful for printvars, not for per-package staging.

---
 system/system.mk | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
system/system.mk +4 -6
index 2794667..a85678f 100644
@@ -69,19 +69,17 @@ ifeq ($(BR2_TARGET_ENABLE_ROOT_LOGIN),y)
 ifeq ($(TARGET_GENERIC_ROOT_PASSWD),)
 SYSTEM_ROOT_PASSWORD =
 else ifneq ($(filter $$1$$% $$5$$% $$6$$%,$(TARGET_GENERIC_ROOT_PASSWD)),)
-SYSTEM_ROOT_PASSWORD = $(TARGET_GENERIC_ROOT_PASSWD)
+SYSTEM_ROOT_PASSWORD = '$(TARGET_GENERIC_ROOT_PASSWD)'
 else
 PACKAGES += host-mkpasswd
-# This variable will only be evaluated in the finalize stage, so we can
-# be sure that host-mkpasswd will have already been built by that time.
-SYSTEM_ROOT_PASSWORD = $(shell $(MKPASSWD) -m "$(TARGET_GENERIC_PASSWD_METHOD)" "$(TARGET_GENERIC_ROOT_PASSWD)")
+SYSTEM_ROOT_PASSWORD = "`$(MKPASSWD) -m "$(TARGET_GENERIC_PASSWD_METHOD)" "$(TARGET_GENERIC_ROOT_PASSWD)"`"
 endif
 else # !BR2_TARGET_ENABLE_ROOT_LOGIN
-SYSTEM_ROOT_PASSWORD = *
+SYSTEM_ROOT_PASSWORD = "*"
 endif
 
 define SYSTEM_SET_ROOT_PASSWD
-	$(SED) 's,^root:[^:]*:,root:$(SYSTEM_ROOT_PASSWORD):,' $(TARGET_DIR)/etc/shadow
+	$(SED) s,^root:[^:]*:,root:$(SYSTEM_ROOT_PASSWORD):, $(TARGET_DIR)/etc/shadow
 endef
 TARGET_FINALIZE_HOOKS += SYSTEM_SET_ROOT_PASSWD
 
Signature · 1 line
2.1.4
#5 lore raw

PATCH 1/5 packages: use backtick instead of $(shell ...) make function

In reply to Arnout Vandecappelle (Essensium/Mind)

Dear Arnout Vandecappelle (Essensium/Mind),

Quoted 13 lines · Arnout Vandecappelle (Essensium/Mind)

It is often difficult to know exactly when make will expand the variable, and usually it can only be expanded after the dependencies have been built (e.g. pkg-config or the .pc file). Using a backtick instead makes it very clear that it will be expanded only while executing the command.

This change is useful for two cases:

1. The per-package staging (and host) directory will be created as part of the configure step, so any $(shell ...) variable that is used in the configure step will fail because the directory doesn't exist yet.

Quoted 4 lines

2. 'make printvars' evaluates the variables it prints. It will therefore trigger a lot of errors from missing .pc files and others. The backticks, on the other hand, are not expanded, so with this change the output of 'make printvars' becomes clean again.

I've applied the entire series. For the last patch, I had to adapt it due to the change from system/system.mk to package/skeleton/skeleton.mk. It seems to work fine from the quick tests I've done, but doing an additional review of what I committed would be useful.

Thanks!

Thomas

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