[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Reorganize definition of languages
From: |
Paolo Bonzini |
Subject: |
[PATCH] Reorganize definition of languages |
Date: |
Mon, 3 Nov 2008 10:20:11 +0100 |
This patch reorganizes the definition of languages so that for
similar languages it's not necessary to manually do a lot of
macro copies.
It also automates the definition of some of the macros that
have to be defined for all languages.
I did this to simplify the next patch, which adds dispatching
to AC_LANG_CONFTEST.
Tested separately and with the next patch. Ok?
Paolo
* lib/autoconf/c.m4 (AC_LANG(C), AC_LANG(C++), AC_LANG(Objective C),
_AC_LANG_ABBREV(C), _AC_LANG_ABBREV(C++), _AC_LANG_ABBREV(Objective C),
_AC_LANG_PREFIX(C), _AC_LANG_PREFIX(C++), _AC_LANG_PREFIX(Objective C)):
Replace definitions with usage of AC_LANG_DEFINE.
(Sections 2b, 2c): Delete.
(Sections 1b, 1c): Move after section 2a.
* lib/autoconf/erlang.m4 (AC_LANG(Erlang), _AC_LANG_ABBREV(Erlang),
_AC_LANG_PREFIX(Erlang), AC_LANG_SOURCE(Erlang)): Replace definitions
with usage of AC_LANG_DEFINE.
(AC_LANG_ERLANG): Define using AU_DEFUN.
* lib/autoconf/fortran.m4 (AC_LANG(Fortran), AC_LANG(Fortran 77),
_AC_LANG_ABBREV(Fortran), _AC_LANG_ABBREV(Fortran 77),
_AC_LANG_PREFIX(Fortran), _AC_LANG_PREFIX(Fortran 77),
_AC_LANG_SOURCE(Fortran), AC_LANG_SOURCE(Fortran 77)): Replace
definitions with usage of AC_LANG_DEFINE.
* lib/autoconf/lang.m4 (AC_LANG_DEFINE, AC_LANG_SOURCE()): New.
---
lib/autoconf/c.m4 | 194 +++++++++++------------------------------------
lib/autoconf/erlang.m4 | 28 ++-----
lib/autoconf/fortran.m4 | 35 +--------
lib/autoconf/lang.m4 | 21 +++++
4 files changed, 74 insertions(+), 204 deletions(-)
diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4
index 90a091c..2260879 100644
--- a/lib/autoconf/c.m4
+++ b/lib/autoconf/c.m4
@@ -54,11 +54,10 @@
# Table of Contents:
#
# 1. Language selection
-# and routines to produce programs in a given language.
-# 1a. C 1b. C++ 1c. Objective C
-#
-# 2. Producing programs in a given language.
-# 2a. C 2b. C++ 2c. Objective C
+# 2. and routines to produce programs in a given language.
+# 1a. C 2a. C
+# 1b. C++
+# 1c. Objective C
#
# 3. Looking for a compiler
# And possibly the associated preprocessor.
@@ -70,18 +69,18 @@
## ----------------------- ##
-## 1. Language selection. ##
+## 1a/2a. The C language. ##
## ----------------------- ##
-# -------------------- #
-# 1a. The C language. #
-# -------------------- #
+# ------------------------ #
+# 1a. Language selection. #
+# ------------------------ #
# AC_LANG(C)
# ----------
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-m4_define([AC_LANG(C)],
+AC_LANG_DEFINE([C], [c], [C], [],
[ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
@@ -95,89 +94,9 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
AU_DEFUN([AC_LANG_C], [AC_LANG(C)])
-# _AC_LANG_ABBREV(C)
-# ------------------
-m4_define([_AC_LANG_ABBREV(C)], [c])
-
-
-# _AC_LANG_PREFIX(C)
-# ------------------
-m4_define([_AC_LANG_PREFIX(C)], [C])
-
-
-
-# ---------------------- #
-# 1b. The C++ language. #
-# ---------------------- #
-
-
-# AC_LANG(C++)
-# ------------
-# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-m4_define([AC_LANG(C++)],
-[ac_ext=cpp
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS
conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-])
-
-
-# AC_LANG_CPLUSPLUS
-# -----------------
-AU_DEFUN([AC_LANG_CPLUSPLUS], [AC_LANG(C++)])
-
-
-# _AC_LANG_ABBREV(C++)
-# --------------------
-m4_define([_AC_LANG_ABBREV(C++)], [cxx])
-
-
-# _AC_LANG_PREFIX(C++)
-# --------------------
-m4_define([_AC_LANG_PREFIX(C++)], [CXX])
-
-
-
-# ------------------------------ #
-# 1c. The Objective C language. #
-# ------------------------------ #
-
-
-# AC_LANG(Objective C)
-# --------------------
-m4_define([AC_LANG(Objective C)],
-[ac_ext=m
-ac_cpp='$OBJCPP $CPPFLAGS'
-ac_compile='$OBJC -c $OBJCFLAGS $CPPFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
-ac_link='$OBJC -o conftest$ac_exeext $OBJCFLAGS $CPPFLAGS $LDFLAGS
conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
-ac_compiler_gnu=$ac_cv_objc_compiler_gnu
-])
-
-
-# AC_LANG_OBJC
-# ------------
-AU_DEFUN([AC_LANG_OBJC], [AC_LANG(Objective C)])
-
-
-# _AC_LANG_ABBREV(Objective C)
-# ----------------------------
-m4_define([_AC_LANG_ABBREV(Objective C)], [objc])
-
-
-# _AC_LANG_PREFIX(Objective C)
-# ----------------------------
-m4_define([_AC_LANG_PREFIX(Objective C)], [OBJC])
-
-
-
-## ----------------------- ##
-## 2. Producing programs. ##
-## ----------------------- ##
-
-# --------------- #
-# 2a. C sources. #
-# --------------- #
+# ------------------------ #
+# 2a. Producing programs. #
+# ------------------------ #
# AC_LANG_SOURCE(C)(BODY)
@@ -322,75 +241,48 @@ static unsigned long int ulongval () { return $2; }
-# ----------------- #
-# 2b. C++ sources. #
-# ----------------- #
-
-
-# AC_LANG_SOURCE(C++)(BODY)
-# -------------------------
-m4_copy([AC_LANG_SOURCE(C)], [AC_LANG_SOURCE(C++)])
-
-
-# AC_LANG_PROGRAM(C++)([PROLOGUE], [BODY])
-# ----------------------------------------
-m4_copy([AC_LANG_PROGRAM(C)], [AC_LANG_PROGRAM(C++)])
-
-
-# AC_LANG_CALL(C++)(PROLOGUE, FUNCTION)
-# -------------------------------------
-m4_copy([AC_LANG_CALL(C)], [AC_LANG_CALL(C++)])
-
-
-# AC_LANG_FUNC_LINK_TRY(C++)(FUNCTION)
-# ------------------------------------
-m4_copy([AC_LANG_FUNC_LINK_TRY(C)], [AC_LANG_FUNC_LINK_TRY(C++)])
-
-
-# AC_LANG_BOOL_COMPILE_TRY(C++)(PROLOGUE, EXPRESSION)
-# ---------------------------------------------------
-m4_copy([AC_LANG_BOOL_COMPILE_TRY(C)], [AC_LANG_BOOL_COMPILE_TRY(C++)])
-
-
-# AC_LANG_INT_SAVE(C++)(PROLOGUE, EXPRESSION)
-# -------------------------------------------
-m4_copy([AC_LANG_INT_SAVE(C)], [AC_LANG_INT_SAVE(C++)])
-
-
+## ---------------------- ##
+## 1b. The C++ language. ##
+## ---------------------- ##
-# ------------------------- #
-# 2c. Objective C sources. #
-# ------------------------- #
-
-
-# AC_LANG_SOURCE(Objective C)(BODY)
-# ---------------------------------
-m4_copy([AC_LANG_SOURCE(C)], [AC_LANG_SOURCE(Objective C)])
+# AC_LANG(C++)
+# ------------
+# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+AC_LANG_DEFINE([C++], [cxx], [CXX], [C],
+[ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS
conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+])
-# AC_LANG_PROGRAM(Objective C)([PROLOGUE], [BODY])
-# ------------------------------------------------
-m4_copy([AC_LANG_PROGRAM(C)], [AC_LANG_PROGRAM(Objective C)])
+# AC_LANG_CPLUSPLUS
+# -----------------
+AU_DEFUN([AC_LANG_CPLUSPLUS], [AC_LANG(C++)])
-# AC_LANG_CALL(Objective C)(PROLOGUE, FUNCTION)
-# ---------------------------------------------
-m4_copy([AC_LANG_CALL(C)], [AC_LANG_CALL(Objective C)])
-# AC_LANG_FUNC_LINK_TRY(Objective C)(FUNCTION)
-# --------------------------------------------
-m4_copy([AC_LANG_FUNC_LINK_TRY(C)], [AC_LANG_FUNC_LINK_TRY(Objective C)])
+## ------------------------------ ##
+## 1c. The Objective C language. ##
+## ------------------------------ ##
-# AC_LANG_BOOL_COMPILE_TRY(Objective C)(PROLOGUE, EXPRESSION)
-# -----------------------------------------------------------
-m4_copy([AC_LANG_BOOL_COMPILE_TRY(C)], [AC_LANG_BOOL_COMPILE_TRY(Objective C)])
+# AC_LANG(Objective C)
+# --------------------
+AC_LANG_DEFINE([Objective C], [objc], [OBJC], [C],
+[ac_ext=m
+ac_cpp='$OBJCPP $CPPFLAGS'
+ac_compile='$OBJC -c $OBJCFLAGS $CPPFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
+ac_link='$OBJC -o conftest$ac_exeext $OBJCFLAGS $CPPFLAGS $LDFLAGS
conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
+ac_compiler_gnu=$ac_cv_objc_compiler_gnu
+])
-# AC_LANG_INT_SAVE(Objective C)(PROLOGUE, EXPRESSION)
-# ---------------------------------------------------
-m4_copy([AC_LANG_INT_SAVE(C)], [AC_LANG_INT_SAVE(Objective C)])
+# AC_LANG_OBJC
+# ------------
+AU_DEFUN([AC_LANG_OBJC], [AC_LANG(Objective C)])
diff --git a/lib/autoconf/erlang.m4 b/lib/autoconf/erlang.m4
index 9bed007..7f6d92d 100644
--- a/lib/autoconf/erlang.m4
+++ b/lib/autoconf/erlang.m4
@@ -121,38 +121,24 @@ fi
# AC_LANG(Erlang)
# ---------------
-m4_define([AC_LANG(Erlang)],
+AC_LANG_DEFINE([Erlang], [erl], [ERL], [],
[ac_ext=erl
ac_compile='$ERLC $ERLCFLAGS -b beam conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
ac_link='$ERLC $ERLCFLAGS -b beam conftest.$ac_ext >&AS_MESSAGE_LOG_FD ; echo
"[#]!/bin/sh" > conftest$ac_exeext ; AS_ECHO(["\"$ERL\" -run conftest start
-run init stop -noshell"]) >> conftest$ac_exeext ; chmod +x conftest$ac_exeext'
])
-# AC_LANG_ERLANG
-# --------------
-m4_define([AC_LANG_ERLANG], [AC_LANG(Erlang)])
-
-
-# _AC_LANG_ABBREV(Erlang)
-# -----------------------
-m4_define([_AC_LANG_ABBREV(Erlang)], [erl])
-
-
-# _AC_LANG_PREFIX(Erlang)
-# -----------------------
-m4_define([_AC_LANG_PREFIX(Erlang)], [ERL])
+# AC_LANG_ERLANG
+# -----------------
+AU_DEFUN([AC_LANG_ERLANG], [AC_LANG(Erlang)])
-## ---------------------- ##
-## 2.Producing programs. ##
-## ---------------------- ##
+## ----------------------- ##
+## 2. Producing programs. ##
+## ----------------------- ##
-# AC_LANG_SOURCE(Erlang)(BODY)
-# ----------------------------
-m4_define([AC_LANG_SOURCE(Erlang)],
-[$1])
# AC_LANG_PROGRAM(Erlang)([PROLOGUE], [BODY])
# -------------------------------------------
diff --git a/lib/autoconf/fortran.m4 b/lib/autoconf/fortran.m4
index 519f3f0..6743aa8 100644
--- a/lib/autoconf/fortran.m4
+++ b/lib/autoconf/fortran.m4
@@ -162,7 +162,7 @@ fi[]dnl
# AC_LANG(Fortran 77)
# -------------------
-m4_define([AC_LANG(Fortran 77)],
+AC_LANG_DEFINE([Fortran 77], [f77], [F], [],
[ac_ext=f
ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS
>&AS_MESSAGE_LOG_FD'
@@ -172,13 +172,14 @@ ac_compiler_gnu=$ac_cv_f77_compiler_gnu
# AC_LANG(Fortran)
# ----------------
-m4_define([AC_LANG(Fortran)],
+AC_LANG_DEFINE([Fortran], [fc], [FC], [],
[ac_ext=${ac_fc_srcext-f}
ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext
>&AS_MESSAGE_LOG_FD'
ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext
conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
ac_compiler_gnu=$ac_cv_fc_compiler_gnu
])
+
# AC_LANG_FORTRAN77
# -----------------
AU_DEFUN([AC_LANG_FORTRAN77], [AC_LANG(Fortran 77)])
@@ -193,24 +194,6 @@ m4_defun([_AC_FORTRAN_ASSERT],
[m4_fatal([$0: current language is not Fortran: ] _AC_LANG)])])])
-# _AC_LANG_ABBREV(Fortran 77)
-# ---------------------------
-m4_define([_AC_LANG_ABBREV(Fortran 77)], [f77])
-
-# _AC_LANG_ABBREV(Fortran)
-# ------------------------
-m4_define([_AC_LANG_ABBREV(Fortran)], [fc])
-
-
-# _AC_LANG_PREFIX(Fortran 77)
-# ---------------------------
-m4_define([_AC_LANG_PREFIX(Fortran 77)], [F])
-
-# _AC_LANG_PREFIX(Fortran)
-# ------------------------
-m4_define([_AC_LANG_PREFIX(Fortran)], [FC])
-
-
# _AC_FC
# ------
# Return F77 or FC, depending upon the language.
@@ -226,18 +209,6 @@ AC_LANG_CASE([Fortran 77], [F77],
## ----------------------- ##
-# AC_LANG_SOURCE(Fortran 77)(BODY)
-# AC_LANG_SOURCE(Fortran)(BODY)
-# --------------------------------
-# FIXME: Apparently, according to former AC_TRY_COMPILER, the CPP
-# directives must not be included. But AC_TRY_RUN_NATIVE was not
-# avoiding them, so?
-m4_define([AC_LANG_SOURCE(Fortran 77)],
-[$1])
-m4_define([AC_LANG_SOURCE(Fortran)],
-[$1])
-
-
# AC_LANG_PROGRAM(Fortran 77)([PROLOGUE], [BODY])
# -----------------------------------------------
# Yes, we discard the PROLOGUE.
diff --git a/lib/autoconf/lang.m4 b/lib/autoconf/lang.m4
index 9ebc7d6..563c381 100644
--- a/lib/autoconf/lang.m4
+++ b/lib/autoconf/lang.m4
@@ -182,6 +182,20 @@ m4_defun([AC_LANG_ASSERT],
+# AC_LANG_DEFINE(NAME, ABBREV, PREFIX, COPY-FROM, SHELL-VARS)
+# -----------------------------------------------------------
+m4_define([AC_LANG_DEFINE],
+[m4_define([AC_LANG($1)], [$5])]
+[m4_define([_AC_LANG_ABBREV($1)], [$2])]
+[m4_define([_AC_LANG_PREFIX($1)], [$3])]
+[m4_copy([AC_LANG_SOURCE($4)], [AC_LANG_SOURCE($1)])]
+[m4_ifval([$4],
+[m4_copy([AC_LANG_PROGRAM($4)], [AC_LANG_PROGRAM($1)])]
+[m4_copy([AC_LANG_CALL($4)], [AC_LANG_CALL($1)])]
+[m4_copy([AC_LANG_FUNC_LINK_TRY($4)], [AC_LANG_FUNC_LINK_TRY($1)])]
+[m4_copy([AC_LANG_BOOL_COMPILE_TRY($4)], [AC_LANG_BOOL_COMPILE_TRY($1)])]
+[m4_copy([AC_LANG_INT_SAVE($4)], [AC_LANG_INT_SAVE($1)])])])
+
## ----------------------- ##
## 2. Producing programs. ##
## ----------------------- ##
@@ -204,6 +218,13 @@ AC_DEFUN([AC_LANG_SOURCE],
[_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])
+# AC_LANG_SOURCE()(BODY)
+# ----------------------
+# Default implementation of AC_LANG_SOURCE.
+m4_define([AC_LANG_SOURCE()],
+[$1])
+
+
# AC_LANG_PROGRAM([PROLOGUE], [BODY])
# -----------------------------------
# Produce a valid source for the current language. Prepend the
--
1.5.6.5
- [PATCH] Reorganize definition of languages,
Paolo Bonzini <=