summaryrefslogtreecommitdiff
path: root/Build/source/texk/m4/kpse_subdirs.m4
blob: 4537b26824d5b32b679911fdd3553ee776e8f3f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Private macros for the kpathsea library.
# Copyright (C) 2008 Peter Breitenlohner <tex-live@tug.org>
#
# This file is free software; the copyright holder
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

# serial 3

# KPSE_WITH_SUBDIRS(PKGLIST)
# -----------------------
# Specify optional packages to be built.  For each PKG in PKGLIST expand
#	AC_ARG_WITH([PKG], [  --without-PKG           do not build the PKG package])
# to produce standardized help messages.
AC_DEFUN([KPSE_WITH_SUBDIRS],
[AC_FOREACH([AC_Pkg], [$1],
  [AC_ARG_WITH(AC_Pkg,
    AS_HELP_STRING([--without-[]]AC_Pkg, [do not build the ]AC_Pkg[ package]))])
])

# KPSE_CONFIG_SUBDIRS(PKGLIST, [DIR])
# -----------------------------------
# Specify optional subdirectories to be configured.
# First initialize the shell variable ESUBDIRS (to empty).  Then for
# each PKG in PKGLIST, test if [DIR/]PKG exists as subdirectory of
# $srcdir and the value of the shell variable with_PKG is not "no";
# if so append this subdirectory to the list of subdirectories to be
# configured and to the shell variable ESUBDIRS.
# Finally ESUBDIRS is AC_SUBSTed.
#
# Examples: KPSE_CONFIG_SUBDIRS([dialog lcdf-typetools], [utils]) is
# roughly equivalent to the shell code
#	ESUBDIRS=
#	  test -d utils || mkdir utils
#	  for pkg in dialog lcdf-typetools; do
#	    if test -d $srcdir/utils/$pkg; then
#	      if eval "test \"`echo '$with_'${pkg}|sed 's/-/_/g'`\" != no"; then
#	        ESUBDIRS="$ESUBDIRS utils/$pkg"
#	        AC_CONFIG_SUBDIRS([utils/$pkg])
#	      fi
#	    fi
#	  done
#	AC_SUBST(ESUBDIRS)
# whereas KPSE_CONFIG_SUBDIRS([afm2pl bibtex8]) corresponds to
#	ESUBDIRS=
#	for pkg in afm2pl bibtex8; do
#	  if test -d $srcdir/utils/$pkg; then
#	    if eval "test \"x`echo '$with_'${pkg}`\" != xno"; then
#	      ESUBDIRS="$ESUBDIRS $pkg"
#	      AC_CONFIG_SUBDIRS([$pkg])
#	    fi
#	  fi
#	done
#	AC_SUBST(ESUBDIRS)
#
# The main difference is that these macros replace the shell loop by
# an M4 loop and therefore M4 variables (i.e., shell literals) are
# passed as arguments to AC_CONFIG_SUBDIRS, as required by modern
# versions of Autoconf and Automake.
AC_DEFUN([KPSE_CONFIG_SUBDIRS],
[ESUBDIRS=
m4_ifval([$2], [test -d $2 || mkdir $2])
AC_FOREACH([AC_Pkg], [$1],
  [_KPSE_CONFIG_SUBDIR(m4_ifval([$2], [$2/])AC_Pkg,
     [with_]m4_bpatsubst(AC_Pkg, [-], [_]))])
AC_SUBST(ESUBDIRS)dnl
])

# _KPSE_CONFIG_SUBDIR(DIR, WITH_VAR)
# ----------------------------------
# See above; test if $srcdir/DIR exists and $WITH_VAR != no; if so
# append DIR to the list of subdirectories to be configured.
m4_define([_KPSE_CONFIG_SUBDIR],
[if test -d $srcdir/$1; then
  if test "x$[]$2" != xno; then
    ESUBDIRS="$ESUBDIRS $1"
    AC_CONFIG_SUBDIRS([$1])dnl
  fi
fi
])