1#!/bin/sh 2# 3# configure: Automatically configure install locations for x11-ssh-askpass 4# 5# by Jim Knoble <jmknoble@pobox.com> 6# Copyright (C) 2001 Jim Knoble 7# 8# Disclaimer: 9# 10# This software is provided "as is", without warranty of any kind, 11# express or implied, including but not limited to the warranties of 12# merchantability, fitness for a particular purpose and 13# noninfringement. In no event shall the author(s) be liable for any 14# claim, damages or other liability, whether in an action of 15# contract, tort or otherwise, arising from, out of or in connection 16# with the software or the use or other dealings in the software. 17# 18# Permission to use, copy, modify, distribute, and sell this software 19# and its documentation for any purpose is hereby granted without 20# fee, provided that the above copyright notice appear in all copies 21# and that both that copyright notice and this permission notice 22# appear in supporting documentation. 23 24PrintHelp() { 25 cat <<EOF 26 27Usage: $0 [options] 28 29Options: 30 --prefix=PREFIX install architecture-independent files in PREFIX 31 [${default_prefix}] 32 --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX 33 [same as prefix] 34 --libexecdir=DIR program executables in DIR [EPREFIX/libexec] 35 --mandir=DIR man documentation in DIR [PREFIX/man] 36 37 --bindir=DIR ignored 38 --sbindir=DIR ignored 39 --datadir=DIR ignored 40 --sysconfdir=DIR ignored 41 --sharedstatedir=DIR ignored 42 --localstatedir=DIR ignored 43 --libdir=DIR ignored 44 --includedir=DIR ignored 45 --infodir=DIR ignored 46 47 --with-app-defaults=FILE Use application defaults from FILE 48 [${default_app_defaults}] 49 --with-app-defaults-dir=DIR Install application defaults file into DIR 50 [wherever imake prefers] 51 --disable-installing-app-defaults Do not install the application defaults 52 file (overrides --with-app-defaults-dir) 53 [enabled] 54 55EOF 56 exit 1 57} 58 59GetOptionArg() { 60 opt="$1" 61 if [ -z "${opt}" ]; then 62 return 63 fi 64 varname=`echo "${opt}" |sed -e 's/^--//' -e 's/=.*$//' -e 'y/-/_/'` 65 case "${opt}" in 66 *=*) 67 arg=`echo "${opt}" |sed -e 's/^[^=]*=//'` 68 eval "${varname}=\"${arg}\"" 69 ;; 70 esac 71} 72 73GetWithOption() { 74 opt="$1" 75 if [ -z "${opt}" ]; then 76 return 77 fi 78 varname=`echo "${opt}" |sed -e 's/^--with-//' -e 's/=.*$//' -e 'y/-/_/'` 79 case "${opt}" in 80 --with-*=*) 81 arg=`echo "${opt}" |sed -e 's/^[^=]*=//'` 82 eval "${varname}=\"${arg}\"" 83 ;; 84 esac 85} 86 87GetEnableOption() { 88 opt="$1" 89 if [ -z "${opt}" ]; then 90 return 91 fi 92 varname=`echo "${opt}" |sed -e 's/^--dis/en/' -e 's/^--//' -e 's/=.*$//' \ 93 -e 'y/-/_/'` 94 case "${opt}" in 95 --enable-*=*) 96 arg=`echo "${opt}" |sed -e 's/^[^=]*=//'` 97 ;; 98 --enable-*) 99 arg=yes 100 ;; 101 --disable-*) 102 arg=no 103 ;; 104 *) 105 return 106 ;; 107 esac 108 case "${arg}" in 109 1|[yY]|[tT]|[oO][nN]|[yY][eE][sS]|[tT][rR][uU][eE]|[eE][nN][aA][bB][lL][eE][dD]) 110 eval "${varname}=yes" 111 ;; 112 0|[nN]|[fF]|[oO][fF][fF]|[nN][oO]|[fF][aA][lL][sS][eE]|[dD][iI][sS][aA][bB][lL][eE][dD]) 113 eval "${varname}=no" 114 ;; 115 *) 116 echo "$0: error: I don't understand '${arg}' (from '${opt}')." 117 exit 1 118 ;; 119 esac 120} 121 122UseDefaults () { 123 unset CC 124 unset CFLAGS 125 unset LDFLAGS 126 127 prefix='' 128 exec_prefix='' 129 libexecdir='' 130 mandir='' 131 app_defaults='' 132 app_defaults_dir='' 133 enable_installing_app_defaults='' 134} 135 136IMAKEFILE_SRC="Imakefile.in" 137IMAKEFILE_DST="Imakefile" 138 139default_default_app_defaults_dir='$(XAPPLOADDIR)' 140 141default_prefix='/usr/local' 142 143if [ -f ../configure ]; then 144 eval `cat ../configure |awk '/^[ ]*ac_default_prefix=/ { print $0 }'` 145fi 146if [ -n "${ac_default_prefix}" ]; then 147 default_prefix="${ac_default_prefix}" 148fi 149 150default_exec_prefix='${prefix}' 151default_libexecdir='${exec_prefix}/libexec' 152default_mandir='${prefix}/man' 153default_app_defaults='SshAskpass-default.ad' 154default_app_defaults_dir='${default_default_app_defaults_dir}' 155default_enable_installing_app_defaults='yes' 156 157prefix='' 158exec_prefix='' 159libexecdir='' 160mandir='' 161app_defaults='' 162app_defaults_dir='' 163enable_installing_app_defaults='' 164 165while [ $# -gt 0 ]; do 166 case "$1" in 167 -h|--help|-help|-\?) 168 PrintHelp 169 ;; 170 -d|--default|--defaults|--use-defaults) 171 UseDefaults 172 break 173 ;; 174 --prefix=*|--exec-prefix=*|--libexecdir=*|--mandir=*) 175 GetOptionArg "$1" 176 shift 177 ;; 178 --with-app-defaults=*|--with-app-defaults-dir=*) 179 GetWithOption "$1" 180 shift 181 ;; 182 --enable-installing-app-defaults|--enable-installing-app-defaults=*|--disable-installing-app-defaults) 183 GetEnableOption "$1" 184 shift 185 ;; 186 -*) 187 shift 188 ;; 189 *) 190 break 191 ;; 192 esac 193done 194 195for i in \ 196 prefix \ 197 exec_prefix \ 198 libexecdir \ 199 mandir \ 200 app_defaults \ 201 app_defaults_dir \ 202 enable_installing_app_defaults \ 203; do 204 if eval [ -z \"\${"${i}"}\" ]; then 205 eval ${i}=\"\`eval echo \${default_"${i}"}\`\" 206 fi 207done 208 209if [ ! -f "${IMAKEFILE_SRC}" ]; then 210 echo "$0: error: I can't seem to find ${IMAKEFILE_SRC}." 211 echo "$0: Are you sure you're running me from the x11-ssh-askpass source directory?" 212 exit 1 213fi 214 215cat "${IMAKEFILE_SRC}" |sed \ 216 -e 's#^\([ ]*BINDIR[ ]*=\).*$#\1 '"${libexecdir}"'#' \ 217 -e 's#^\([ ]*MANPATH[ ]*=\).*$#\1 '"${mandir}"'#' \ 218 -e 's#^\([ ]*APPDEFDIR[ ]*=\).*$#\1 '"${app_defaults_dir}"'#' \ 219 -e 's#^\([ ]*APP_DEFAULTS[ ]*=\).*#\1 '"${app_defaults}"'#' \ 220 >"${IMAKEFILE_DST}.tmp" \ 221&& mv -f "${IMAKEFILE_DST}.tmp" "${IMAKEFILE_DST}" 222 223case "${enable_installing_app_defaults}" in 224 yes) 225 cat "${IMAKEFILE_DST}" |sed \ 226 -e 's#^[ ]*\(XCOMM[ ]\+\)\?\(install::[ ]\+install-app-defaults.*\)$#\2#' \ 227 >"${IMAKEFILE_DST}.tmp" \ 228 && mv -f "${IMAKEFILE_DST}.tmp" "${IMAKEFILE_DST}" 229 ;; 230 no) 231 cat "${IMAKEFILE_DST}" |sed \ 232 -e 's#^[ ]*\(XCOMM[ ]\+\)\?\(install::[ ]\+install-app-defaults.*\)$#XCOMM \2#' \ 233 >"${IMAKEFILE_DST}.tmp" \ 234 && mv -f "${IMAKEFILE_DST}.tmp" "${IMAKEFILE_DST}" 235 ;; 236esac 237 238if [ -n "${CC}" ]; then 239 cat "${IMAKEFILE_DST}" |sed \ 240 -e 's#^[ ]*XCOMM[ ]\+\(CC[ ]*=\).*$#\1 '"${CC}"'#' \ 241 >"${IMAKEFILE_DST}.tmp" \ 242 && mv -f "${IMAKEFILE_DST}.tmp" "${IMAKEFILE_DST}" 243else 244 CC='default' 245fi 246 247if [ -n "${CFLAGS}" ]; then 248 cat "${IMAKEFILE_DST}" |sed \ 249 -e 's#^[ ]*XCOMM[ ]\+\(CDEBUGFLAGS[ ]*=\).*$#\1 '"${CFLAGS}"'#' \ 250 >"${IMAKEFILE_DST}.tmp" \ 251 && mv -f "${IMAKEFILE_DST}.tmp" "${IMAKEFILE_DST}" 252else 253 CFLAGS='default' 254fi 255 256if [ -n "${LDFLAGS}" ]; then 257 cat "${IMAKEFILE_DST}" |sed \ 258 -e 's#^[ ]*XCOMM[ ]\+\(LOCAL_LDFLAGS[ ]*=\).*$#\1 '"${LDFLAGS}"'#' \ 259 >"${IMAKEFILE_DST}.tmp" \ 260 && mv -f "${IMAKEFILE_DST}.tmp" "${IMAKEFILE_DST}" 261else 262 LDFLAGS='default' 263fi 264 265if [ "${app_defaults_dir}" = "${default_default_app_defaults_dir}" ]; then 266 app_defaults_dir='default' 267fi 268 269cat <<EOF 270 271x11-ssh-askpass has been configured with the following options: 272 273 Askpass directory: ${libexecdir} 274 Manual page: ${mandir}/man1 275 Application defaults file: ${app_defaults} 276 Application defaults directory: ${app_defaults_dir} 277 Install application defaults file: ${enable_installing_app_defaults} 278 279 Compiler: ${CC} 280 Compiler flags: ${CFLAGS} 281 Linker flags: ${LDFLAGS} 282 283You may now create the Makefile and build x11-ssh-askpass using the 284following commands: 285 286 xmkmf 287 make includes 288 make 289 290EOF 291