add an own version of `autopoint' which works well here
[dragora.git] / archive / gettext-tiny / autopoint
blob971020fe5c88ef4f3e1374b34f5aa6d995f0a61e
1 #! /bin/sh -
3 # autopoint: Copies standard gettext infrastructure (lightweight version).
5 # Alternative version for Dragora GNU/Linux-Libre.
6 # Under the terms of the Apache License version 2.
8 PROGRAM="${0##*/}"
10 # A parser function to extract the value of 'AC_CONFIG_AUX_DIR'
12 aparse()
14 inside='.*'
15 search='AC_CONFIG_AUX_DIR'
16 pre='([' stu='])'
18 export inside search pre stu
20 awk '#!/usr/bin/awk -f
21 BEGIN {
22 npre = length( pre = ENVIRON[ "search" ] ENVIRON[ "pre" ] )
23 nstu = length( stu = ENVIRON[ "stu" ] )
25 function g( s ) { gsub(/./, "[&]", s); return s }
27 match( $0, g( pre ) ENVIRON["inside"] g( stu ) ) {
28 print substr( $0, RSTART + npre, RLENGTH -npre -nstu )
29 }' "$@"
31 unset inside search pre
34 # Default directory for gettext infrastructure
35 DATADIR="${DATADIR:-/usr/share/gettext-tiny}"
37 # Sanity checks
39 if test ! -d "$DATADIR"
40 then
41 echo "${PROGRAM}: ${DATADIR}: Internal directory does not exist." 1>&2
42 exit 1
44 if test "$PWD" = / || test "$PWD" = "$DATADIR"
45 then
46 echo "${PROGRAM}: Current working directory is $PWD (forbidden)" 1>&2
47 exit 1
49 if test ! -e configure.ac
50 then
51 echo "${PROGRAM}: cannot access configure.ac: No such file or directory" 1>&2
52 exit 1
55 # Remove write permission for group and other
56 umask 022
58 mkdir -p -- m4 intl po
60 for file in "${DATADIR}/m4"/*.m4
62 cp -f -- "$file" m4/
63 done
64 unset file
66 dirprefix="$(aparse configure.ac)"
68 mkdir -p -- "$dirprefix"
69 touch "${dirprefix}/config.rpath" ABOUT-NLS
71 unset dirprefix
73 for file in intl/Makefile.in po/Makefile.in.in
75 cp -f "${DATADIR}/data/autopoint_Makefile.in" -- "$file"
76 chmod 644 -- "$file"
77 done
78 unset file
80 cp -f "${DATADIR}/data/Makevars.template" po/Makevars.template
81 chmod 644 po/Makevars.template