0

I wrote an alias for cross-compiling.

alias cross_compile="make CROSS_COMPILE=x86_64-buildroot-linux-uclibc- -C /home/jamal//buildroot-2019.05/output/build/linux-4.19.16 M='$PWD' modules"

But the PWD is not being evaluated each time i call cross_compile from terminal, it is set to a static directory.

How can i make sure the pwd is being picked up each time i call cross_compile.

1
  • If you are using make, anyway, I would strongly recommend defining your targets that need cross-compiling in the makefile. However, the issue with your alias is that the PWD is evaluated once, when the alias is defined. You need to defer evaluation until it is invoked. '${PWD}' should probably have escaped double-quotes, like \"${PWD}\". You can check what it looks like after being defined with alias cross_compile. Dec 19, 2019 at 16:40

1 Answer 1

1

You need to invert all single-quote to double-quote, and all double-quote to single-quote. This defers the expansion of PWD until the alias is invoked. Shortened example:

Paul-) alias cross_compile='echo linux-4.19.16 M="${PWD}" modules'
Paul-) 
Paul-) alias cross_compile
alias cross_compile='echo linux-4.19.16 M="${PWD}" modules'
Paul-) 
Paul-) cross_compile
linux-4.19.16 M=/home/paul modules
Paul-) 
Paul-) cd Sand*
Paul-) pwd
/home/paul/SandBox
Paul-) cross_compile
linux-4.19.16 M=/home/paul/SandBox modules
Paul-) 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.