Search code examples
makefileportfreebsdcd

Call make on a FreeBSD port outside the port's directory


Can make be called on a FreeBSD port outside of the port's directory? I.e. without the use of the cd command.

To contextualise, whilst the following can be done :cd /usr/ports/www/apache24 && sudo make config-recursive install distclean, something like this pseudocode would be preferred: sudo make config-recursive install distclean -p /usr/ports/www/apache24

Thank you


Solution

  • This is what the -C option of make is for.

    -C directory
         Change to directory before reading the makefiles or doing any-
         thing else.  If multiple -C options are specified, each is inter-
         preted relative to the previous one: -C / -C etc is equivalent to
         -C /etc.
    

    So you want to use this:

    make -C /usr/ports/www/apache24 config-recursive install distclean