Skip to content

Commit edcf4ca

Browse files
committed
build: Add m4 macro to assert argument is literal
Add a new m4 macro, OAC_ASSERT_LITERAL, that will fail autoconf if the first argument is not a string literal (in the Autoconf sense of the word). Note that this macro will not emit any shell code; it will either cause a fatal m4 error (with useful stack trace to where the error occurred) or evaluate to an empty string. Signed-off-by: Brian Barrett <[email protected]>
1 parent deb71ff commit edcf4ca

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

config/oac_literal.m4

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
dnl -*- autoconf -*-
2+
dnl
3+
dnl Copyright (c) 2022 Amazon.com, Inc. or its affiliates. All Rights reserved.
4+
dnl $COPYRIGHT$
5+
dnl
6+
dnl Additional copyrights may follow
7+
8+
dnl OAC_ASSERT_LITERAL: Assert if first argument is not an Autoconf literal
9+
dnl
10+
dnl 1 -> Variable which must be a literal
11+
dnl 2 -> Argument reference string (usually an integer argument number)
12+
dnl
13+
dnl Assert that the first argument is a literal (in the Autoconf sense
14+
dnl of the word) Second argument is the argument number (ie, a bare
15+
dnl number) to make the error message easier to parse.
16+
AC_DEFUN([OAC_ASSERT_LITERAL],
17+
[AS_LITERAL_IF([$1], [], [m4_fatal([argument $2 ($1) must be a literal])])])dnl

config/opal_check_compiler_version.m4

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ AC_DEFUN([OPAL_CHECK_COMPILER_VERSION_ID],
2727

2828

2929
AC_DEFUN([OPAL_CHECK_COMPILER], [
30-
AS_LITERAL_IF([$1], [],
31-
[m4_fatal([OPAL_CHECK_COMPILER argument must be a literal])])
30+
OAC_ASSERT_LITERAL([$1], [1])dnl
3231
lower=m4_tolower([$1])
3332
AC_CACHE_CHECK([for compiler $lower], [opal_cv_compiler_$1],
3433
[

0 commit comments

Comments
 (0)