## would see a "make flag" equal to "nap" when analyzing $(MAKEFLAGS), and
## would wrongly misinterpret that as and indication that make is running
## in dry mode. This has already happened in practice. So we need the
-## hack with $(subst \, ...).
+## hack with $(subst \ , ...).
am__make_dryrun := \
$(strip $(if $(strip \
$(foreach am__v, $(subst \ ,,$(strip $(MAKEFLAGS))), \
$(findstring n,$(am__v))))), \
true, false))
+# An empty strings. It only serves to make the code readable
+# in some places.
+am__empty :=
+
+# GNU make 3.80 lacks $(lastword).
+## FIXME: the best thing to do here is ts
+am__lastword = $(word $(words $(1)),$(1))
+
+am__strip_firstword = $(wordlist 2,$(words $(1)),$(1))
+am__strip_lastword = $(wordlist 2,$(words $(1)),dummy $(1))
+
+## Remove repeated elements from the given list (without reordering),
+## and return the reduced list.
+am__uniq = $(strip \
+## If the list is empty, we have nothing to do. Otherwise, go on.
+ $(if $(strip $(1)), \
+## Call the function recursively on the list of all the elements
+## but the last one.
+ $(call am__uniq, \
+ $(call am__strip_lastword, $(1))) \
+## And append the last element, unless it was already present.
+ $(if $(filter $(call am__lastword, $(1)), \
+ $(call am__strip_lastword, $(1))), \
+ $(am__empty), \
+ $(call am__lastword,$(1)))))
+
+
## Some derived variables that have been found to be useful.
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
--- /dev/null
+#! /bin/sh
+# Copyright (C) 2012 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test some generic Automake-provided internal macros and make functions.
+
+am_create_testdir=empty
+. ./defs || Exit 1
+
+plan_ 3
+
+cp "$am_amdir"/header-vars.am . \
+ || fatal_ "fetching makefile fragment headers-vars.am"
+
+# Filter out Automake comments and things that would need configure
+# substitutions.
+LC_ALL=C $EGREP -v '(^##|=.*@[a-zA-Z0-9_]+@)' header-vars.am > defn.mk
+rm -f header-vars.am
+
+cat > Makefile << 'END'
+include ./defn.mk
+
+default:
+ @echo Please select an explicit test; exit 1
+.PHONY: default
+
+.PHONY: test-strip-firstword
+test-strip-firstword:
+ test '$(call am__strip_firstword,)' = ''
+ test '$(call am__strip_firstword,1)' = ''
+ test '$(call am__strip_firstword,1 1)' = '1'
+ test '$(call am__strip_firstword,1 2)' = '2'
+ test '$(call am__strip_firstword,1 2 3 4 5 6 7 8)' = '2 3 4 5 6 7 8'
+ test '$(call am__strip_firstword, 1 2 )' = '2'
+
+.PHONY: test-strip-lastword
+test-strip-lastword:
+ test '$(call am__strip_lastword,)' = ''
+ test '$(call am__strip_lastword,1)' = ''
+ test '$(call am__strip_lastword,1 1)' = '1'
+ test '$(call am__strip_lastword,1 2)' = '1'
+ test '$(call am__strip_lastword,1 2 3 4 5 6 7 8)' = '1 2 3 4 5 6 7'
+ test '$(call am__strip_lastword, 1 2 )' = '1'
+
+.PHONY: test-uniq
+test-uniq:
+ test '$(call am__uniq,)' = ''
+ test '$(call am__uniq,1)' = '1'
+ test '$(call am__uniq,1 1)' = '1'
+ test '$(call am__uniq,1 2)' = '1 2'
+ test '$(call am__uniq,2 1)' = '2 1'
+ test '$(call am__uniq,1 2 3)' = '1 2 3'
+ test '$(call am__uniq,2 3 1)' = '2 3 1'
+ test '$(call am__uniq,1 1 1)' = '1'
+ test '$(call am__uniq,1 2 1)' = '1 2'
+ test '$(call am__uniq,2 1 1)' = '2 1'
+ test '$(call am__uniq,2 1 1)' = '2 1'
+ test '$(call am__uniq,2 2 1)' = '2 1'
+ test '$(call am__uniq,1 1 1 3 1 1 1)' = '1 3'
+ test '$(call am__uniq,3 1 1 4 1 4 1 1)' = '3 1 4'
+ test '$(call am__uniq, 1 3 1 )' = '1 3'
+
+END
+
+command_ok_ "am__strip_firstword" $MAKE test-strip-firstword
+command_ok_ "am__strip_lastword" $MAKE test-strip-lastword
+command_ok_ "am__uniq" $MAKE test-uniq
+
+: