@@ -326,6 +326,103 @@ dnl #######################################################################
326326dnl # ######################################################################
327327dnl # ######################################################################
328328
329+ # Remove all duplicate -I, -L, and -l flags from the variable named $1
330+ AC_DEFUN([PMIX_FLAGS_UNIQ],[
331+ # 1 is the variable name to be uniq-ized
332+ pmix_name= $1
333+
334+ # Go through each item in the variable and only keep the unique ones
335+
336+ pmix_count= 0
337+ for val in ${$1 } ; do
338+ pmix_done=0
339+ pmix_i=1
340+ pmix_found=0
341+
342+ # Loop over every token we've seen so far
343+
344+ pmix_done=" ` expr $pmix_i \> $pmix_count ` "
345+ while test " $pmix_found " = " 0" && test " $pmix_done " = " 0" ; do
346+
347+ # Have we seen this token already? Prefix the comparison
348+ # with "x" so that "-Lfoo" values won't be cause an error.
349+
350+ pmix_eval=" expr x$val = x\$ pmix_array_$pmix_i "
351+ pmix_found=` eval $pmix_eval `
352+
353+ # Check the ending condition
354+
355+ pmix_done=" ` expr $pmix_i \> = $pmix_count ` "
356+
357+ # Increment the counter
358+
359+ pmix_i=" ` expr $pmix_i + 1` "
360+ done
361+
362+ # Check for special cases where we do want to allow repeated
363+ # arguments (per
364+ # http://www.open-mpi.org/community/lists/devel/2012/08/11362.php
365+ # and
366+ # https://github.com/open-mpi/ompi/issues/324).
367+
368+ case $val in
369+ -Xclang)
370+ pmix_found=0
371+ pmix_i=` expr $pmix_count + 1`
372+ ;;
373+ -framework)
374+ pmix_found=0
375+ pmix_i=` expr $pmix_count + 1`
376+ ;;
377+ --param)
378+ pmix_found=0
379+ pmix_i=` expr $pmix_count + 1`
380+ ;;
381+ esac
382+
383+ # If we didn't find the token, add it to the "array"
384+
385+ if test " $pmix_found " = " 0" ; then
386+ pmix_eval=" pmix_array_$pmix_i =$val "
387+ eval $pmix_eval
388+ pmix_count=" ` expr $pmix_count + 1` "
389+ else
390+ pmix_i=" ` expr $pmix_i - 1` "
391+ fi
392+ done
393+
394+ # Take all the items in the "array" and assemble them back into a
395+ # single variable
396+
397+ pmix_i= 1
398+ pmix_done= " ` expr $pmix_i \> $pmix_count ` "
399+ pmix_newval=
400+ while test " $pmix_done " = " 0" ; do
401+ pmix_eval=" pmix_newval=\" $pmix_newval \$ pmix_array_$pmix_i \" "
402+ eval $pmix_eval
403+
404+ pmix_eval=" unset pmix_array_$pmix_i "
405+ eval $pmix_eval
406+
407+ pmix_done=" ` expr $pmix_i \> = $pmix_count ` "
408+ pmix_i=" ` expr $pmix_i + 1` "
409+ done
410+
411+ # Done; do the assignment
412+
413+ pmix_newval= " ` echo $pmix_newval ` "
414+ pmix_eval= " $pmix_name =\" $pmix_newval \" "
415+ eval $pmix_eval
416+
417+ # Clean up
418+
419+ unset pmix_name pmix_i pmix_done pmix_newval pmix_eval pmix_count
420+ ])dnl
421+
422+ dnl # ######################################################################
423+ dnl # ######################################################################
424+ dnl # ######################################################################
425+
329426# PMIX_APPEND_UNIQ(variable, new_argument)
330427# ----------------------------------------
331428# Append new_argument to variable if not already in variable. This assumes a
0 commit comments