/[gentoo-x86]/eclass/portability.eclass
Gentoo

Diff of /eclass/portability.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.12 Revision 1.17
1# Copyright 1999-2005 Gentoo Foundation 1# Copyright 1999-2005 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/portability.eclass,v 1.12 2009/03/22 11:26:45 grobian Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/portability.eclass,v 1.17 2010/09/24 14:29:49 vapier Exp $
4# 4#
5# Author: Diego Pettenò <flameeyes@gentoo.org> 5# Author: Diego Pettenò <flameeyes@gentoo.org>
6# 6#
7# This eclass is created to avoid using non-portable GNUisms inside ebuilds 7# This eclass is created to avoid using non-portable GNUisms inside ebuilds
8# 8#
26 26
27# seq min max 27# seq min max
28# 28#
29# compatibility function that mimes seq command if not available 29# compatibility function that mimes seq command if not available
30seq() { 30seq() {
31 # First try `seq`
31 local p=$(type -P seq) 32 local p=$(type -P seq)
33 if [[ -n ${p} ]] ; then
34 "${p}" "$@"
35 return $?
36 fi
32 37
33 case $# in 38 case $# in
34 1) min=1 max=$1 step=1 ;; 39 1) min=1 max=$1 step=1 ;;
35 2) min=$1 max=$2 step=1 ;; 40 2) min=$1 max=$2 step=1 ;;
36 3) min=$1 max=$3 step=$2 ;; 41 3) min=$1 max=$3 step=$2 ;;
37 *) die "seq called with wrong number of arguments" ;; 42 *) die "seq called with wrong number of arguments" ;;
38 esac 43 esac
39 44
45 # Then try `jot`
46 p=$(type -P jot)
40 if [[ -z ${p} ]] ; then 47 if [[ -n ${p} ]] ; then
41 local reps 48 local reps
42 # BSD userland 49 # BSD userland
43 if [[ ${step} != 0 ]]; then 50 if [[ ${step} != 0 ]] ; then
44 reps=$(( ($max-$min) / $step +1 )) 51 reps=$(( (max - min) / step + 1 ))
45 else 52 else
46 reps=0 53 reps=0
47 fi 54 fi
48 55
49 jot $reps $min $max $step 56 jot $reps $min $max $step
50 else 57 return $?
51 "${p}" $min $step $max
52 fi 58 fi
59
60 # Screw it, do the output ourselves
61 while :; do
62 [[ $max < $min && $step > 0 ]] && break
63 [[ $min < $max && $step < 0 ]] && break
64 echo $min
65 : $(( min += step ))
66 done
67 return 0
53} 68}
54 69
55# Gets the linker flag to link to dlopen() function 70# Gets the linker flag to link to dlopen() function
56dlopen_lib() { 71dlopen_lib() {
57 # this might need a proper case statement, so far this seems to work as is
58 # - Solaris needs nothing 72 # - Solaris needs nothing
59 # - Darwin needs nothing 73 # - Darwin needs nothing
60 # - *BSD needs nothing 74 # - *BSD needs nothing
75 # - Linux needs -ldl (glibc and uclibc)
61 # - Linux needs -ldl 76 # - Interix needs -ldl
62 if [[ ${CHOST} == *-linux-gnu ]]; then 77 case "${CHOST}" in
78 *-linux-gnu*|*-linux-uclibc|*-interix*)
63 echo "-ldl" 79 echo "-ldl"
64 fi 80 ;;
81 esac
65} 82}
66 83
67# Gets the home directory for the specified user 84# Gets the home directory for the specified user
68# it's a wrap around egetent as the position of the home directory in the line 85# it's a wrap around egetent as the position of the home directory in the line
69# varies depending on the os used. 86# varies depending on the os used.

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.17

  ViewVC Help
Powered by ViewVC 1.1.20