From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Petazzoni Date: Fri, 2 Jan 2015 16:24:55 +0100 Subject: [Buildroot] [PATCH v2] Allow a single DHCP configuration via the system configuration submenu In-Reply-To: <1420211162-9189-1-git-send-email-jeremy.rosen@openwide.fr> References: <1420211162-9189-1-git-send-email-jeremy.rosen@openwide.fr> Message-ID: <20150102162455.0198a79e@free-electrons.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: buildroot@busybox.net Dear J?r?my Rosen, On Fri, 2 Jan 2015 16:06:02 +0100, J?r?my Rosen wrote: > +define SIMPLE_NETWORK > + mkdir -p $(TARGET_DIR)/etc/network/ > + > + echo "# interface file auto-generated by buildroot" > $(TARGET_DIR)/etc/network/interfaces > + echo >> $(TARGET_DIR)/etc/network/interfaces > + echo "auto lo" >> $(TARGET_DIR)/etc/network/interfaces > + echo "iface lo inet loopback" >> $(TARGET_DIR)/etc/network/interfaces > + echo >> $(TARGET_DIR)/etc/network/interfaces > + > + if [ -n "$(BR2_SIMPLE_DHCP)" ] ; then \ > + echo "auto $(BR2_SIMPLE_DHCP)" >> $(TARGET_DIR)/etc/network/interfaces ; \ > + echo "iface $(BR2_SIMPLE_DHCP) inet dhcp" >> $(TARGET_DIR)/etc/network/interfaces ; \ > + fi Can we use make instead of the shell for this condition? Also, BR_SIMPLE_DHCP has some double quotes, so you probably want to use qstrip. Something like: define SET_NETWORK_LOCALHOST echo "# interface file auto-generated by buildroot" > $(TARGET_DIR)/etc/network/interfaces echo >> $(TARGET_DIR)/etc/network/interfaces echo "auto lo" >> $(TARGET_DIR)/etc/network/interfaces echo "iface lo inet loopback" >> $(TARGET_DIR)/etc/network/interfaces echo >> $(TARGET_DIR)/etc/network/interfaces endef NETWORK_DHCP_IFACE = $(call qstrip,$(BR2_SIMPLE_DHCP)) ifneq ($(NETWORK_DHCP_IFACE),) define SET_NETWORK_DHCP echo "auto $(NETWORK_DHCP_IFACE)" >> $(TARGET_DIR)/etc/network/interfaces echo "iface $(NETWORK_DHCP_IFACE) inet dhcp" >> $(TARGET_DIR)/etc/network/interfaces endef endif define SET_NETWORK mkdir -p $(TARGET_DIR)/etc/network/ $(SET_NETWORK_LOCALHOST) $(SET_NETWORK_DHCP) endef TARGET_FINALIZE_HOOKS += SET_NETWORK It would be good to avoid the repeated redirects to $(TARGET_DIR)/etc/network/interfaces, but I don't immediately see an elegant way of doing that. Thanks, Thomas -- Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com