Search code examples
makefilecsh

Variable in makefile needed in csh


I have a variable in a makefile that holds a value.

Example in MakefileA.mk:

VAR1 = 1

This value needs to be used in a csh file, for example CshA.csh:

if ($VAR1) then

How can you include the makefile in the csh or extract the value of VAR1 to be used in the csh file?


Solution

  • Revised based on input from OP:

    Consider adding a target to the make file to query the "var1"

    query-var1:
        @echo $(VAR1)
    

    Then in the CshA.csh script, use the target to query the variable

    ...
    make -f MakefileA
    set VAR1=`make -f MakefileA query-var1`
    if ($VAR1) then
       ...
    endif