Deduplicate options to compiler and linker, as well as consecutive LIBS
[sxemacs] / m4 / sxe-bldchain-progs.m4
1 dnl sxe-bldchain-progs.m4 -- Necessary build chain stuff
2
3
4
5 AC_DEFUN([SXE_PROG_AR], [dnl
6         AC_ARG_VAR([AR], [the ar command])
7         AC_CHECK_TOOL([AR], [ar], [:], [$PATH])
8         if test "$AR" = ":"; then
9                 AC_PATH_TOOL([USR_CCS_BIN_AR], [ar], [:],
10                         [$PATH:/usr/ccs/bin])
11         fi
12         if test "$AR" = ":" -a "$USR_CCS_BIN_AR" = ":"; then
13                 AC_MSG_ERROR([Uh oh, no ar is rilly bad news.])
14         elif test "$AR" = ":"; then
15                 AR=$USR_CCS_BIN_AR
16         fi
17         AC_SUBST(AR)
18 ])dnl SXE_PROG_AR
19
20
21 AC_DEFUN([SXE_PROG_BISON], [
22         AC_PROG_YACC()
23         SXE_MSG_CHECKING([for bison])
24         if test "$YACC" != "bison -y"; then
25                 AC_SUBST([BISON], [:], [location of bison])
26                 have_bison="no"
27                 sxe_cv_feat_bison="no"
28                 dnl AC_MSG_ERROR([bison not found but required])
29         else
30                 AC_SUBST([BISON], [bison], [location of bison])
31                 have_bison="yes"
32                 sxe_cv_feat_bison="yes"
33         fi
34         SXE_MSG_RESULT([${sxe_cv_feat_bison}])
35
36         ## check if bison is capable
37         if test "$sxe_cv_feat_bison" = "yes"; then
38                 SXE_MSG_CHECKING([if bison is recent enough])
39                 sxe_cv_feat_bison_version="$(${BISON} --version | head -n1)"
40                 case "$sxe_cv_feat_bison_version" in
41                 *\ 1.875 | *\ 2.*)
42                         ;;
43                 *)
44                         have_bison="no"
45                         ;;
46                 esac
47                 SXE_MSG_RESULT([${have_bison} (${sxe_cv_feat_bison_version})])
48         fi
49 ])dnl SXE_PROG_BISON
50
51
52 AC_DEFUN([SXE_CHECK_AUTOTOOL], [dnl
53         ## arg 1 tool's binary name
54         ## arg 2 sxemacs_version.m4's name
55         ## arg 3 config.h.in description
56         pushdef([autotool], [$1])
57         pushdef([AUTOTOOL], translit($1, [-a-z], [_A-Z]))
58         pushdef([v3rs1on], indir($2))
59         pushdef([descr], [$3])
60
61         AC_MSG_CHECKING([for ]autotool[ version])
62         AC_MSG_RESULT(v3rs1on)
63         AC_DEFINE_UNQUOTED(AUTOTOOL[_VERSION], "v3rs1on", descr)
64
65         popdef([descr])
66         popdef([v3rs1on])
67         popdef([AUTOTOOL])
68         popdef([autotool])
69 ])dnl SXE_CHECK_AUTOTOOL
70
71 AC_DEFUN([SXE_CHECK_AUTOTOOLS], [dnl
72         ## brag about the autotools versions
73         m4_ifdef([4UTOCONF_VERSION], [dnl
74                 SXE_CHECK_AUTOTOOL([autoconf], [4UTOCONF_VERSION],
75                         [version of autoconf used to build the configure script])])
76         m4_ifdef([4UTOHEADER_VERSION], [dnl
77                 SXE_CHECK_AUTOTOOL([autoheader], [4UTOHEADER_VERSION],
78                         [version of autoheader used to build the config.h.in])])
79         m4_ifdef([4CLOCAL_VERSION], [dnl
80                 SXE_CHECK_AUTOTOOL([aclocal], [4CLOCAL_VERSION],
81                         [version of aclocal used to incorporate m4 macros])])
82         m4_ifdef([4UTOMAKE_VERSION], [dnl
83                 SXE_CHECK_AUTOTOOL([automake], [4UTOMAKE_VERSION],
84                         [version of automake used to build the Makefiles])])
85         m4_ifdef([4IBTOOL_VERSION], [dnl
86                 SXE_CHECK_AUTOTOOL([libtool], [4IBTOOL_VERSION],
87                         [version of libtool used to provide portable linking])])
88 ])dnl SXE_CHECK_AUTOTOOLS
89
90
91 dnl recommended interface function
92 AC_DEFUN([SXE_CHECK_BUILDCHAIN], [dnl
93         AC_PROG_LN_S
94         AC_PROG_AWK
95         AC_PROG_EGREP
96         AC_PROG_FGREP
97         AC_PROG_INSTALL
98
99         SXE_CHECK_AUTOTOOLS
100         SXE_CHECK_USER_VARS
101
102 dnl     dnl Soon ...
103 dnl     dnl m4_ifdef([LT_INIT], [LT_INIT], [AC_PROG_LIBTOOL])
104         AC_PROG_RANLIB
105         SXE_PROG_AR
106 ])dnl SXE_CHECK_BUILDCHAIN
107
108 dnl recommended interface macro for parser/lexer
109 AC_DEFUN([SXE_CHECK_PARSER_LEXER], [dnl
110         SXE_PROG_BISON
111         AC_PROG_LEX
112         AM_PROG_LEX
113 ])dnl SXE_CHECK_PARSER_LEXER
114
115
116 dnl sxe-bldchain-progs.m4 ends here