@@ -16,6 +16,8 @@ dnl Copyright (c) 2009-2020 Cisco Systems, Inc. All rights reserved.
16
16
dnl Copyright (c) 2014 Intel, Inc. All rights reserved.
17
17
dnl Copyright (c) 2015-2017 Research Organization for Information Science
18
18
dnl and Technology (RIST). All rights reserved.
19
+ dnl Copyright (c) 2021 Amazon.com, Inc. or its affiliates. All Rights
20
+ dnl reserved.
19
21
dnl
20
22
dnl $COPYRIGHT $
21
23
dnl
@@ -317,6 +319,18 @@ dnl #######################################################################
317
319
dnl # ######################################################################
318
320
dnl # ######################################################################
319
321
322
+ # OPAL_APPEND(variable, new_argument)
323
+ # ----------------------------------------
324
+ # Append new_argument to variable, assuming a space separated list.
325
+ #
326
+ AC_DEFUN([OPAL_APPEND], [
327
+ AS_IF([test -z " $$ 1" ], [$1 = " $2 " ], [$1 = " $$ 1 $2 " ])
328
+ ])
329
+
330
+ dnl # ######################################################################
331
+ dnl # ######################################################################
332
+ dnl # ######################################################################
333
+
320
334
# OPAL_APPEND_UNIQ(variable, new_argument)
321
335
# ----------------------------------------
322
336
# Append new_argument to variable if not already in variable. This assumes a
@@ -333,11 +347,7 @@ for arg in $2; do
333
347
fi
334
348
done
335
349
if test " $opal_found " = " 0" ; then
336
- if test -z " $$ 1" ; then
337
- $1 =" $arg "
338
- else
339
- $1 =" $$ 1 $arg "
340
- fi
350
+ OPAL_APPEND([$1 ], [$arg ])
341
351
fi
342
352
done
343
353
unset opal_found
@@ -463,7 +473,50 @@ AC_DEFUN([OPAL_FLAGS_APPEND_UNIQ], [
463
473
AS_IF([test " x$val " = " x$arg " ], [opal_append= 0])
464
474
done])
465
475
AS_IF([test " $opal_append " = " 1" ],
466
- [AS_IF([test -z " $$ 1" ], [$1 = $arg ], [$1 = " $$ 1 $arg " ])])
476
+ [OPAL_APPEND([$1 ], [$arg ])])
477
+ done
478
+
479
+ OPAL_VAR_SCOPE_POP
480
+ ])
481
+
482
+ dnl # ######################################################################
483
+ dnl # ######################################################################
484
+ dnl # ######################################################################
485
+
486
+ # OPAL_FLAGS_APPEND_MOVE(variable, new_argument)
487
+ # ----------------------------------------------
488
+ # add new_arguments to the end of variable.
489
+ #
490
+ # If an argument in new_arguments does not begin with -I, -L, or -l OR
491
+ # the argument begins with -I, -L, or -l and it is not already in
492
+ # variable, it is appended to variable.
493
+ #
494
+ # If an argument in new_argument begins with a -l and is already in
495
+ # variable, the existing occurances of the argument are removed from
496
+ # variable and the argument is appended to variable. This behavior
497
+ # is most useful in LIBS, where ordering matters and being rightmost
498
+ # is usually the right behavior.
499
+ #
500
+ # This macro assumes a space separated list.
501
+ AC_DEFUN([OPAL_FLAGS_APPEND_MOVE], [
502
+ OPAL_VAR_SCOPE_PUSH([opal_tmp_variable opal_tmp opal_append])
503
+
504
+ for arg in $2 ; do
505
+ AS_CASE([$arg ],
506
+ [-I* | -L* ],
507
+ [opal_append= 1
508
+ for val in ${$1 } ; do
509
+ AS_IF([test " x$val " = " x$arg " ], [opal_append= 0])
510
+ done
511
+ AS_IF([test $opal_append -eq 1], [OPAL_APPEND([$1 ], [$arg ])])],
512
+ [-l* ],
513
+ [opal_tmp_variable=
514
+ for val in ${$1 } ; do
515
+ AS_IF([test " x$val " != " x$arg " ],
516
+ [OPAL_APPEND([opal_tmp_variable], [$val ])])
517
+ done
518
+ OPAL_APPEND([opal_tmp_variable], [$arg ])])
519
+ $1 =" $opal_tmp_variable "
467
520
done
468
521
469
522
OPAL_VAR_SCOPE_POP
0 commit comments