FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo Development

 
 
LinkBack Thread Tools
 
Old 11-29-2011, 11:11 PM
Mike Frysinger
 
Default autoconf-cache.eclass: helper functions for managing autoconf cache variables

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[@]}"
}
 

Thread Tools




All times are GMT. The time now is 02:53 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org