How can I make a target “private” in GNU make for internal use only? OR: how to best enforce target-specific variable-values?

后端 未结 5 1907
别那么骄傲
别那么骄傲 2021-02-19 13:14

I have some ancillary targets in a makefile that I want to restrict for internal or \"private\" use (only) inside the makefile. That is, I want to be able to specify these targ

5条回答
  •  天涯浪人
    2021-02-19 13:55

    You kind of can define private targets by starting their name with two hyphens.

    --private-target:
        @echo private
    
    public-target: --private-target
        @echo public
    

    You can call make public-target but make --private-target will complain about an unknown option:

    $ make public-target
    private
    public
    
    $ make --private-target
    /Library/Developer/CommandLineTools/usr/bin/make: unrecognized option `--private-target'
    

    $ make --version
    GNU Make 3.81
    Copyright (C) 2006  Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.
    There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
    PARTICULAR PURPOSE.
    
    This program built for i386-apple-darwin11.3.0
    

提交回复
热议问题