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