summaryrefslogtreecommitdiff
path: root/Build/source/am/rebuild.am
blob: 9b53015b1929a536ae0dbd00b95f173e753222f6 (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
## 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:
	echo timestamp >$@

.PHONY: rebuild
rebuild: $(rebuild_prereq)
	@dry=; for f in x $$MAKEFLAGS; do \
	  case $$f in \
	    *=*|--*);; \
	    *n*) dry=:;; \
	  esac; \
	done; \
	$$dry rm -f rebuild.stamp; \
	$$dry trap 'rm -rf rebuild.lock' 1 2 13 15; \
	if $$dry mkdir rebuild.lock 2>/dev/null; then \
	  $(MAKE) $(AM_MAKEFLAGS) $(rebuild_target) 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

CLEANFILES += rebuild.stamp