Commit 7d69a796 authored by Arnout Vandecappelle's avatar Arnout Vandecappelle Committed by Thomas Petazzoni
Browse files

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.]

Signed-off-by: default avatarFabio Porcedda <fabio.porcedda@gmail.com>
Signed-off-by: default avatarArnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Signed-off-by: default avatarThomas Petazzoni <thomas.petazzoni@free-electrons.com>
parent b4857df7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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
+1 −1
Original line number Diff line number Diff line
@@ -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
+1 −1
Original line number Diff line number Diff line
@@ -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
+4 −4
Original line number Diff line number Diff line
@@ -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))
+1 −1
Original line number Diff line number Diff line
@@ -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
Loading