help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

shell functions from env not available in make?


From: gk
Subject: shell functions from env not available in make?
Date: Thu, 24 Oct 2002 20:09:52 -0700

I have sourced a function 'xmsubdirs' into my current shell and was expecting it to be available from a makefile rule but it is not. The Gnu make manual doesn't seem to address this issue; it simply addresses the use of shell environmental variables. Functions are exported to subshells in bash; why isn't make able to access them?

--- Makefile:

.PHONY: foo goo boo moo

boo :
        @xmsubdirs

# i tried treating xmsubdirs like a variable
moo :
        @$(xmsubdirs)

foo :
        @echo $(shell $(xmsubdirs))
        
goo :
        @echo $$(xmsubdirs)

--- output

address@hidden test]$ xmsubdirs
foo.html.xm goo junkme moo.xm project
address@hidden test]$ make boo
make: xmsubdirs: Command not found
make: *** [boo] Error 127
address@hidden test]$ make moo
make: Nothing to be done for `moo'.
address@hidden test]$ make foo

address@hidden test]$ make goo
/bin/sh: xmsubdirs: command not found

--- function source

function xmsubdirs(){
        [ -z "$1" ] && set .
    XMLMAKE_BUILD_EXCLUDE_DIRS_RE='(^CVS$)|(^trash$)'
    if [[ ! -z "$XMLMAKE_BUILD_EXCLUDE_DIRS_RE" ]]
    then
export CURRENT_SUBDIRS=$(find "$1" -name '*' -type d -maxdepth 1| xargs --replace=d basename d | grep -v -E $XMLMAKE_BUILD_EXCLUDE_DIRS_RE)
    else
export CURRENT_SUBDIRS=$(find "$1" -name '*' -type d -maxdepth 1| xargs --replace=d basename d )
    fi
    echo ${CURRENT_SUBDIRS}
}

Thanks,
Greg Keraunen





reply via email to

[Prev in Thread] Current Thread [Next in Thread]