summaryrefslogtreecommitdiff
path: root/Build/source/am/rebuild.am
blob: 81f7d33b623573aabf21f31cc8dfacc00c35e51a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
## am/rebuild.am: Makefile fragment to rebuild a library.
##
## Copyright (C) 2013 Peter Breitenlohner <tex-live@tug.org>
## You may freely use, modify and/or distribute this file.
##
## requires $(rebuild_prereq), $(rebuild_target), and CLEANFILES.
##
## Serialize concurrent rebuild attempts
## Compare Automake manual (info Automake) 27.9: Multiple Outputs
##
rebuild.stamp: $(rebuild_target)
	echo timestamp >$@

.PHONY: rebuild
rebuild: $(rebuild_prereq)
	@dry=; for f in x $$MAKEFLAGS; do \
	  case $$f in \
	    *=*|--*);; \
	    *n*) dry=:;; \
	  esac; \
	done; \
	if test -f rebuild.stamp; then :; else \
	  $$dry trap 'rm -rf rebuild.lock' 1 2 13 15; \
	  if $$dry mkdir rebuild.lock 2>/dev/null; then \
	    $(MAKE) $(AM_MAKEFLAGS) rebuild.stamp; \
	    $$dry rmdir rebuild.lock; \
	  else \
	    while test -d rebuild.lock && test -z "$$dry"; do sleep 1; done; \
	  fi; \
	  $$dry test -f rebuild.stamp; exit $$?; \
	fi

CLEANFILES += rebuild.stamp