list_add LINKARGS "@libdir@\libsimgrid.dll"
fi
-list_set CMDLINE
+list_set CMDLINE "${CC}"
+list_add_not_empty CMDLINE "${CFLAGS}"
while [ $# -gt 0 ]; do
ARG="$1"
shift
esac
done
-list_set CMDLINE "${CFLAGS}" "${CMDLINE}" ${INCLUDEARGS} ${CMAKE_LINKARGS} "${LINKARGS}"
-eval $(list_get CMDLINE)
+list_add_not_empty CMDLINE ${INCLUDEARGS}
+list_add_not_empty CMDLINE ${CMAKE_LINKARGS}
+list_add_not_empty CMDLINE "${LINKARGS}"
-"${CC}" "$@"
+eval $(list_get CMDLINE)
+"$@"
}
trap 'cleanup' EXIT
-list_set CMDLINE
+list_set CMDLINE "${F90}"
+list_add_not_empty CMDLINE "${FFLAGS}"
while [ $# -gt 0 ]; do
ARG="$1"
shift
esac
done
-list_set CMDLINE "${FFLAGS}" "${CMDLINE}" ${INCLUDEARGS} ${CMAKE_LINKARGS} "${LINKARGS}"
-eval $(list_get CMDLINE)
+list_add_not_empty CMDLINE ${INCLUDEARGS}
+list_add_not_empty CMDLINE ${CMAKE_LINKARGS}
+list_add_not_empty CMDLINE "${LINKARGS}"
-"${F90}" "$@"
+eval $(list_get CMDLINE)
+"$@"
;;
esac
done
-list_add ARGS "${LINKARGS}"
+list_add_not_empty ARGS "${LINKARGS}"
build () {
local SRCFILE
# Add a word to the end of a list (words separated by LISTSEP)
# $1: list, $2...: words to add
list_add () {
- local list content
+ local list content newcontent
list="$1"
shift
- eval content=\"\${$list}\"
- IFS="$LISTSEP"
- if [ -z "$content" ]; then
- content="$*"
- else
- content="$content${LISTSEP}$*"
+ if [ $# -gt 0 ]; then
+ eval content=\"\${$list}\"
+ IFS="$LISTSEP"
+ newcontent="$*"
+ IFS="$SAVEIFS"
+ if [ -z "$content" ]; then
+ content="$newcontent"
+ else
+ content="$content${LISTSEP}$newcontent"
+ fi
+ eval $list=\"\${content}\"
+ fi
+}
+
+# Like list_add, but only if first word to add ($2) is not empty
+list_add_not_empty () {
+ if [ -n "$2" ]; then
+ list_add "$@"
fi
- IFS="$SAVEIFS"
- eval $list=\"\${content}\"
}
# Set contents of a list (words separated by LISTSEP)