2020-09-05 16:11:04 +00:00
|
|
|
# $Id: options.mk,v 1.13 2020/08/19 17:51:53 sjg Exp $
|
2013-01-31 16:44:23 +00:00
|
|
|
#
|
|
|
|
# @(#) Copyright (c) 2012, Simon J. Gerraty
|
|
|
|
#
|
|
|
|
# This file is provided in the hope that it will
|
|
|
|
# be of use. There is absolutely NO WARRANTY.
|
|
|
|
# Permission to copy, redistribute or otherwise
|
2020-09-05 16:11:04 +00:00
|
|
|
# use this file is hereby granted provided that
|
2013-01-31 16:44:23 +00:00
|
|
|
# the above copyright notice and this notice are
|
2020-09-05 16:11:04 +00:00
|
|
|
# left intact.
|
|
|
|
#
|
2013-01-31 16:44:23 +00:00
|
|
|
# Please send copies of changes and bug-fixes to:
|
|
|
|
# sjg@crufty.net
|
|
|
|
#
|
|
|
|
|
2013-05-20 22:35:32 +00:00
|
|
|
# Inspired by FreeBSD bsd.own.mk, but intentionally simpler and more flexible.
|
2013-01-31 16:44:23 +00:00
|
|
|
|
|
|
|
# Options are normally listed in either OPTIONS_DEFAULT_{YES,NO}
|
|
|
|
# We convert these to ${OPTION}/{yes,no} in OPTIONS_DEFAULT_VALUES.
|
|
|
|
# We add the OPTIONS_DEFAULT_NO first so they take precedence.
|
|
|
|
# This allows override of an OPTIONS_DEFAULT_YES by adding it to
|
|
|
|
# OPTIONS_DEFAULT_NO or adding ${OPTION}/no to OPTIONS_DEFAULT_VALUES.
|
|
|
|
# An OPTIONS_DEFAULT_NO option can only be overridden by putting
|
|
|
|
# ${OPTION}/yes in OPTIONS_DEFAULT_VALUES.
|
|
|
|
# A makefile may set NO_* (or NO*) to indicate it cannot do something.
|
|
|
|
# User sets WITH_* and WITHOUT_* to indicate what they want.
|
2013-05-20 22:35:32 +00:00
|
|
|
# We set ${OPTION_PREFIX:UMK_}* which is then all we need care about.
|
2013-01-31 16:44:23 +00:00
|
|
|
OPTIONS_DEFAULT_VALUES += \
|
|
|
|
${OPTIONS_DEFAULT_NO:O:u:S,$,/no,} \
|
|
|
|
${OPTIONS_DEFAULT_YES:O:u:S,$,/yes,}
|
|
|
|
|
2013-05-20 22:35:32 +00:00
|
|
|
OPTION_PREFIX ?= MK_
|
2014-07-02 21:24:54 +00:00
|
|
|
|
|
|
|
# NO_* takes precedence
|
|
|
|
# If both WITH_* and WITHOUT_* are defined, WITHOUT_ wins unless
|
|
|
|
# DOMINANT_* is set to "yes"
|
|
|
|
# Otherwise WITH_* and WITHOUT_* override the default.
|
2013-01-31 16:44:23 +00:00
|
|
|
.for o in ${OPTIONS_DEFAULT_VALUES:M*/*}
|
2014-07-02 21:24:54 +00:00
|
|
|
.if defined(NO_${o:H}) || defined(NO${o:H})
|
|
|
|
# we cannot do it
|
|
|
|
${OPTION_PREFIX}${o:H} ?= no
|
|
|
|
.elif defined(WITH_${o:H}) && defined(WITHOUT_${o:H})
|
|
|
|
# normally WITHOUT_ wins
|
|
|
|
DOMINANT_${o:H} ?= no
|
|
|
|
${OPTION_PREFIX}${o:H} ?= ${DOMINANT_${o:H}}
|
|
|
|
.elif ${o:T:tl} == "no"
|
|
|
|
.if defined(WITH_${o:H})
|
2013-05-20 22:35:32 +00:00
|
|
|
${OPTION_PREFIX}${o:H} ?= yes
|
2013-01-31 16:44:23 +00:00
|
|
|
.else
|
2013-05-20 22:35:32 +00:00
|
|
|
${OPTION_PREFIX}${o:H} ?= no
|
2013-01-31 16:44:23 +00:00
|
|
|
.endif
|
|
|
|
.else
|
2014-07-02 21:24:54 +00:00
|
|
|
.if defined(WITHOUT_${o:H})
|
2013-05-20 22:35:32 +00:00
|
|
|
${OPTION_PREFIX}${o:H} ?= no
|
2013-01-31 16:44:23 +00:00
|
|
|
.else
|
2013-05-20 22:35:32 +00:00
|
|
|
${OPTION_PREFIX}${o:H} ?= yes
|
2013-01-31 16:44:23 +00:00
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
.endfor
|
|
|
|
|
|
|
|
# OPTIONS_DEFAULT_DEPENDENT += FOO_UTILS/FOO
|
2014-07-02 21:24:54 +00:00
|
|
|
# If neither WITH[OUT]_FOO_UTILS is set, (see rules above)
|
|
|
|
# use the value of ${OPTION_PREFIX}FOO
|
2013-01-31 16:44:23 +00:00
|
|
|
.for o in ${OPTIONS_DEFAULT_DEPENDENT:M*/*:O:u}
|
2014-07-02 21:24:54 +00:00
|
|
|
.if defined(NO_${o:H}) || defined(NO${o:H})
|
|
|
|
# we cannot do it
|
|
|
|
${OPTION_PREFIX}${o:H} ?= no
|
|
|
|
.elif defined(WITH_${o:H}) && defined(WITHOUT_${o:H})
|
|
|
|
# normally WITHOUT_ wins
|
|
|
|
DOMINANT_${o:H} ?= no
|
|
|
|
${OPTION_PREFIX}${o:H} ?= ${DOMINANT_${o:H}}
|
|
|
|
.elif defined(WITH_${o:H})
|
2013-05-20 22:35:32 +00:00
|
|
|
${OPTION_PREFIX}${o:H} ?= yes
|
2014-07-02 21:24:54 +00:00
|
|
|
.elif defined(WITHOUT_${o:H})
|
2013-05-20 22:35:32 +00:00
|
|
|
${OPTION_PREFIX}${o:H} ?= no
|
2013-01-31 16:44:23 +00:00
|
|
|
.else
|
2013-05-20 22:35:32 +00:00
|
|
|
${OPTION_PREFIX}${o:H} ?= ${${OPTION_PREFIX}${o:T}}
|
2013-01-31 16:44:23 +00:00
|
|
|
.endif
|
|
|
|
.endfor
|
2020-09-05 16:11:04 +00:00
|
|
|
.undef OPTIONS_DEFAULT_VALUES
|
|
|
|
.undef OPTIONS_DEFAULT_NO
|
|
|
|
.undef OPTIONS_DEFAULT_YES
|