makefileopenwrt

What does the symbol pipe '|' means in a Makefile


From target/linux/ar71xx/image/Makefile

KERNEL := kernel-bin | patch-cmdline | lzma | uImage lzma

Could you please help me understand what does this line means and provide an example on how to use the symbol pipe | in a Makefile


Solution

  • This line is simply setting the make variable KERNEL to the string kernel-bin | patch-cmdline | lzma | uImage lzma. The pipe symbol (|) has no special meaning to make here.

    You'll have to see how the variable is being used. Most likely it appears in a recipe somewhere, like this:

    foo:
           $(KERNEL)
    

    In that case the variable is expanded and the results are sent to the shell. In the shell, the pipe symbol causes the stdout from the command on the lefto be hooked up to the stdin of the command on the righ: it's called a pipeline or piping data.

    Here you have a pipeline of 4 comands: kernel-bin's output is sent to 'patch-cmdline's input, patch-cmdline's output is sent to lzma's input, lzma's output is sent to uImage lzma's input.