public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] autoconf-cache.eclass: helper functions for managing autoconf cache variables
@ 2011-11-30  0:11 Mike Frysinger
  0 siblings, 0 replies; only message in thread
From: Mike Frysinger @ 2011-11-30  0:11 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 2196 bytes --]

as i started to write more open coded autoconf cache variable tweaks, i got
annoyed to write a simple eclass.  here's a rough PoC.
-mike

# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/autotools.eclass,v 1.110 2011/11/14 17:08:49 vapier Exp $

# @ECLASS: autotools-cache.eclass
# @MAINTAINER:
# base-system@gentoo.org
# @BLURB: Simplify management of autotool cache variables

# just for usex()
inherit eutils

_ac_varify() {
	echo ${1//[![:alnum:]_]/_}
}

ac_cv() {
	export ac_cv_$(_ac_varify "$1")="$2"
}

# @FUNCTION: ac_check_lib
# @USAGE: "<function> <library> [value]" ["<function> <library> [value]" ...]
ac_check_lib() {
	local line
	for line in "$@" ; do
		local args=( ${line} )
		local func=${args[0]} lib=${args[1]} val=${args[2]}
		ac_cv "lib_${lib}_${func}" "${val:-no}"
	done
}
# @FUNCTION: use_ac_check_lib
# @USAGE: <USE flag> "<function> <library>" ["<function> <library>" ...]
use_ac_check_lib() {
	local flag=$1 line packed=()
	for line in "${@:2}" ; do
		packed+=$( "${line} $(usex ${flag})" )
	done
	${FUNCNAME#use_} "${packed[@]}"
}

# @FUNCTION: ac_search_libs
# @USAGE: "<function> [value]" ["<function> [value]" ...]
ac_search_libs() {
	local line
	for line in "$@" ; do
		local args=( ${line} )
		local func=${args[0]} val=${args[1]}
		ac_cv "search_${func}" "${val:-no}"
	done
}
# @FUNCTION: use_ac_search_libs
# @USAGE: <USE flag> "<function> <library>" ["<function> <library>" ...]
use_ac_search_libs() {
	local flag=$1 line packed=()
	for line in "${@:2}" ; do
		local args=( ${line} )
		local lib=${args[1]}
		packed+=( "${line} $(usex ${flag} -l${lib})" )
	done
	${FUNCNAME#use_} "${packed[@]}"
}

# @FUNCTION: ac_check_headers
# @USAGE: "<header> [value]" ["<header> [value]" ...]
ac_check_headers() {
	local line
	for line in "$@" ; do
		local args=( ${line} )
		local h=${args[0]} val=${args[1]}
		ac_cv "header_${h}" "${val:-no}"
	done
}
# @FUNCTION: use_ac_check_headers
# @USAGE: <USE flag> <headers>
use_ac_check_headers() {
	local flag=$1 h packed=()
	for h in "${@:2}" ; do
		packed+=( "${h} $(usex ${flag})" )
	done
	ac_check_headers "${packed[@]}"
}

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-11-30  0:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-30  0:11 [gentoo-dev] autoconf-cache.eclass: helper functions for managing autoconf cache variables Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox