OpenWrt Forum Archive

Topic: sed in package Makefile

The content of this topic has been archived on 23 Mar 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

hi..

I'm trying to run the following in a package Makefile, but the ${CMAKE_CURRENT_BINARY_DIR} seems to get replaced with a blank during Makefile processing before sed sees it.

define Build/Configure
  SED="$(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)sed" \
  ${SED} "s/COMMAND exdaub/COMMAND ${CMAKE_CURRENT_BINARY_DIR}\/exdaub/" $(PKG_BUILD_DIR)/daub-2.1/CMakeLists.txt
...

When i run:

make V=s

the output displayed is:

.../staging_dir/host/bin/sed -i -e "s/COMMAND exdaub/COMMAND \/exdaub/" ...

It seems to be treating ${CMAKE_CURRENT_BINARY_DIR} as a variable during processing of the Makefile before sed sees it. Tried using a sed script file, but the toolchain sed automatically inserts "-i -e" options and won't allow "-f".

Does anyone know of a good way to handle this? I could create my own version of the github project i'm using, but it's harder to maintain.

thanks!

Got around it by using $(PKG_BUILD_DIR) instead of the cmake variable. It is converted into a string containing "/" characters before sed parses it so it is necessary to use something like "s#COMMAND exdaub#COMMAND $(PKG_BUILD_DIR)/exdaub#".

wombat365 wrote:

Tried using a sed script file, but the toolchain sed automatically inserts "-i -e" options and won't allow "-f".

I just use $(STAGING_DIR_HOST)/bin/sed instead of $(SED) to avoid the above problem.

(Last edited by mazilo on 15 Feb 2015, 21:11)

The discussion might have continued from here.