1 # $Id: options.mk,v 1.7 2013/04/17 20:32:38 sjg Exp $
3 # @(#) Copyright (c) 2012, Simon J. Gerraty
5 # This file is provided in the hope that it will
6 # be of use. There is absolutely NO WARRANTY.
7 # Permission to copy, redistribute or otherwise
8 # use this file is hereby granted provided that
9 # the above copyright notice and this notice are
12 # Please send copies of changes and bug-fixes to:
16 # Inspired by FreeBSD bsd.own.mk, but intentionally simpler and more flexible.
18 # Options are normally listed in either OPTIONS_DEFAULT_{YES,NO}
19 # We convert these to ${OPTION}/{yes,no} in OPTIONS_DEFAULT_VALUES.
20 # We add the OPTIONS_DEFAULT_NO first so they take precedence.
21 # This allows override of an OPTIONS_DEFAULT_YES by adding it to
22 # OPTIONS_DEFAULT_NO or adding ${OPTION}/no to OPTIONS_DEFAULT_VALUES.
23 # An OPTIONS_DEFAULT_NO option can only be overridden by putting
24 # ${OPTION}/yes in OPTIONS_DEFAULT_VALUES.
25 # A makefile may set NO_* (or NO*) to indicate it cannot do something.
26 # User sets WITH_* and WITHOUT_* to indicate what they want.
27 # We set ${OPTION_PREFIX:UMK_}* which is then all we need care about.
28 OPTIONS_DEFAULT_VALUES += \
29 ${OPTIONS_DEFAULT_NO:O:u:S,$,/no,} \
30 ${OPTIONS_DEFAULT_YES:O:u:S,$,/yes,}
33 .for o in ${OPTIONS_DEFAULT_VALUES:M*/*}
35 .if defined(WITH_${o:H}) && !defined(NO_${o:H}) && !defined(NO${o:H})
36 ${OPTION_PREFIX}${o:H} ?= yes
38 ${OPTION_PREFIX}${o:H} ?= no
41 .if defined(WITHOUT_${o:H}) || defined(NO_${o:H}) || defined(NO${o:H})
42 ${OPTION_PREFIX}${o:H} ?= no
44 ${OPTION_PREFIX}${o:H} ?= yes
49 # OPTIONS_DEFAULT_DEPENDENT += FOO_UTILS/FOO
50 # if neither WITH[OUT]_FOO_UTILS is set, use value of ${OPTION_PREFIX}FOO
51 .for o in ${OPTIONS_DEFAULT_DEPENDENT:M*/*:O:u}
52 .if defined(WITH_${o:H}) && !defined(NO_${o:H}) && !defined(NO${o:H})
53 ${OPTION_PREFIX}${o:H} ?= yes
54 .elif defined(WITHOUT_${o:H}) || defined(NO_${o:H}) || defined(NO${o:H})
55 ${OPTION_PREFIX}${o:H} ?= no
57 ${OPTION_PREFIX}${o:H} ?= ${${OPTION_PREFIX}${o:T}}