本文展示rpm spec中, 条件宏 定义与否, 分别是怎么展开的.
Conditional macro expansion
Undefined macros do not get expanded. In most cases this is not
desirable so conditional macro expansions can be used to deal with
undefined macros. The following table summarizes the expansion of
conditional macros when the “foo” macro is defined and the value
is “bar” or not defined:
Expansion when %foo is
Macro | defined as bar | undefined |
---|---|---|
%foo | bar | %foo |
%{?foo} | bar | <empty string> |
%{?foo:fred} | fred | <empty string> |
%{?!foo:fred} | <empty string> | fred |
%{!?foo:fred} | <empty string> | fred |
Macro expansions can be nested:
%define fred %{?foo}%{!?foo:%{bar}}
参考:
http://pkgbuild.sourceforge.net/spec-files.txt