1# ================================================================================
2#  https://www.gnu.org/software/autoconf-archive/ax_set_default_paths_system.html
3# ================================================================================
4#
5# SYNOPSIS
6#
7#   AX_SET_DEFAULT_PATHS_SYSTEM
8#
9# DESCRIPTION
10#
11#   the most interesting changes go about windows-targets - where the
12#   default_prefix is set to /programs, and quite some directories are
13#   aliased: sbindir := libdir := bindir and the docprefix-defaults are also
14#   a bit different, even on FHS2-compliant systems where the mandir is
15#   going to $prefix/man only if prefix=/usr, otherwise they shall go to
16#   $datadir/man. We use an extra docprefix to express it which is either
17#   defined as being prefix or datadir. not SUBSTed here.
18#
19# LICENSE
20#
21#   Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
22#
23#   Copying and distribution of this file, with or without modification, are
24#   permitted in any medium without royalty provided the copyright notice
25#   and this notice are preserved.  This file is offered as-is, without any
26#   warranty.
27
28#serial 10
29
30AU_ALIAS([AC_SET_DEFAULT_PATHS_SYSTEM], [AX_SET_DEFAULT_PATHS_SYSTEM])
31AC_DEFUN([AX_SET_DEFAULT_PATHS_SYSTEM],
32[AC_REQUIRE([AC_CANONICAL_HOST]) # --------------------------------------------
33case "$prefix:$ac_default_prefix" in
34  NONE:/usr/local)
35    result=""
36    AC_MSG_CHECKING(default prefix path)
37    case "${target_os}" in
38      *cygwin* | *mingw* | *uwin* | *djgpp | *emx* )
39	if test "${host_os}" = "${target_os}" ; then
40           ac_default_prefix="/programs"
41           result="(win/dos target)"
42        else
43           case "$PATH" in
44              *:/usr/local/cross-tools/$target_alias/bin:*)
45		  ac_default_prefix="/usr/local/cross-tools/$target_alias" ;;
46              *:/usr/local/$target_alias/bin:*)
47		  ac_default_prefix="/usr/local/$target_alias" ;;
48              *:/usr/local/$target_cpu-$target_os/bin:*)
49		  ac_default_prefix="/usr/local/$target_cpu-$target_os" ;;
50              *)
51                  ac_default_prefix="/programs" ;;
52           esac
53           result="(win/dos cross-compiler)"
54        fi
55    ;;
56    esac
57    AC_MSG_RESULT($ac_default_prefix $result)
58  ;;
59esac
60AC_MSG_CHECKING(default prefix system)
61result="$prefix" ; test "$result" = "NONE" && result="$ac_default_prefix"
62case ${result} in
63  /programs | /programs/*) result="is win-/programs"
64     # on win/dos, .exe .dll and .cfg live in the same directory
65     libdir=`echo $libdir |sed -e 's:^..exec_prefix./lib$:${bindir}:'`
66     sbindir=`echo $sbindir |sed -e 's:^..exec_prefix./sbin$:${libdir}:'`
67     sysconfdir=`echo $sysconfdir |sed -e 's:^..prefix./etc$:${sbindir}:'`
68     libexecdir=`echo $libexecdir |sed -e 's:/libexec$:/system:'`
69     # help-files shall be set with --infodir, docprefix is datadir
70     docprefix="${datadir}"
71     mandir=`echo $mandir \
72			     |sed -e 's:^..prefix./man$:${datadir}/info:'`
73     includedir=`echo $includedir \
74                |sed -e 's:^..prefix./include$:${datadir}/include:'`
75     # other state files (but /etc) are moved to datadir
76     sharedstatedir=`echo $sharedstatedir \
77                     |sed -e 's:^..prefix./com$:${datadir}/default:'`
78     localstatedir=`echo $localstatedir \
79                     |sed -e 's:^..prefix./var$:${datadir}/current:'`
80  ;;
81  /usr) result="is /usr-shipped"
82     # doc files are left at prefix
83     docprefix="${prefix}"
84     # state files go under /top
85     sysconfdir=`echo $sysconfdir |sed -e 's:^..prefix./etc$:/etc:'`
86     sharedstatedir=`echo $sharedstatedir \
87                     |sed -e 's:^..prefix./com$:/etc/default:'`
88     # $prefix/var is going to end up in /var/lib
89     localstatedir=`echo $localstatedir \
90                     |sed -e 's:^..prefix./var$:/var/lib:'`
91  ;;
92  /opt | /opt/*) result="is /opt-package"
93     # state files go under /top/prefix
94     sysconfdir=`echo $sysconfdir \
95                     |sed -e 's:^..prefix./etc$:/etc${prefix}:'`
96     sharedstatedir=`echo $sharedstatedir \
97                     |sed -e 's:^..prefix./com$:/etc/default${prefix}:'`
98     # $prefix/var is going to be /var$prefix... once again
99     localstatedir=`echo $localstatedir \
100                     |sed -e 's:^..prefix./var$:/var${prefix}:'`
101     # doc files are left at prefix
102     docprefix="${prefix}"
103  ;;
104  *) result="is /local-package"
105     # doc files are moved from prefix down to datadir
106     docprefix="${datadir}"
107     mandir=`echo $mandir \
108                     |sed -e 's:^..prefix./man$:${datadir}/man:'`
109     infodir=`echo $infodir \
110                     |sed -e 's:^..prefix./infodir$:${datadir}/info:'`
111     # never use $prefix/com - that is no good idea
112     sharedstatedir=`echo $sharedstatedir \
113                     |sed -e 's:^..prefix./com$:${sysconfdir}/default:'`
114  ;;
115esac
116AC_MSG_RESULT($result)
117# --------------------------------------------------------
118])
119