mhd_print_first_word.m4 (1183B)
1 # SPDX-License-Identifier: FSFAP 2 # 3 # SYNOPSIS 4 # 5 # MHD_PRINT_FIRST_WORD([some string or $variable]) 6 # 7 # DESCRIPTION 8 # 9 # This macro prints the first word from the first parameter after 10 # performing shell variable expansion and word-splitting. 11 # 12 # Example usage: 13 # 14 # cc_cmd=`MHD_PRINT_FIRST_WORD([$CC])` 15 # 16 # If CC is set to "gcc -std=c11' then just cc_cmd will be set to "gcc". 17 # 18 # LICENSE 19 # 20 # Copyright (c) 2026 Karlson2k (Evgeny Grin) <k2k@drgrin.dev> 21 # 22 # Copying and distribution of this file, with or without modification, are 23 # permitted in any medium without royalty provided the copyright notice 24 # and this notice are preserved. This file is offered as-is, without any 25 # warranty. 26 27 #serial 1 28 29 AC_DEFUN([MHD_PRINT_FIRST_WORD],[dnl 30 AC_REQUIRE([_MHD_PRINT_FIRST_WORD_BODY])dnl 31 m4_bmatch([$1], ["], [m4_fatal([$0: First macro argument must not contain double quote char '"'])])dnl 32 mhd_fn_print_first_word "$1"])dnl AC_DEFUN MHD_PRINT_FIRST_WORD 33 34 35 AC_DEFUN([_MHD_PRINT_FIRST_WORD_BODY], [m4_divert_text([SHELL_FN],[dnl 36 mhd_fn_print_first_word () { 37 set dummy $[]1 38 AS_ECHO_N(["$[]2"]) 39 } # _mhd_fn_print_first_word 40 ])])dnl AC_DEFUN _MHD_PRINT_FIRST_WORD_BODY