summaryrefslogtreecommitdiff
path: root/Makefile.par.gen
blob: 22eb1a08fd0c4c7342f56abbf81eca8e59a5fdad (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# -*- Makefile -*-
#
# Copyright 2009 Free Software Foundation, Inc.
# 
# This file is part of GNU Radio
# 
# GNU Radio 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 3, or (at your option)
# any later version.
# 
# GNU Radio 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 GNU Radio; see the file COPYING.  If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
# 

STAMPS ?=
EXTRA_DIST ?=
MOSTLYCLEANFILES ?=

## ----------------------------------------------------------------
## Special rules for generating sources.  Include this file when there
## are multiple targets ('gen_sources') being created using a single
## command.  In this case, parallel build protection is required, and
## is provided by this file using a reasonably generic ruleset.  For
## more info, see:
##
## http://sources.redhat.com/automake/automake.html#Multiple-Outputs
##
## If a single source is being created, then normal rules can be used;
## using this parallel protection will not hurt, but it also won't help.
##
## Define the variable 'par_gen_command' to be the command that
## creates the sources 'gen_sources' from the dependency files
## 'gen_sources_deps'.
##

## These STAMPS will be removed upon "make clean", but are otherwise
## not used.

STAMPS += $(DEPDIR)/stamp-sources-generate*

## The following STAMP will be included in the archive, to show that
## this these rules have been followed.

EXTRA_DIST += stamp-sources-generate
MOSTLYCLEANFILES += stamp-sources-generate

stamp-sources-generate: $(gen_sources_deps)
	@rm -f $(DEPDIR)/stamp-sources-generate-tmp
	@touch $(DEPDIR)/stamp-sources-generate-tmp
	$(par_gen_command)
	@mv -f $(DEPDIR)/stamp-sources-generate-tmp $@

$(gen_sources): stamp-sources-generate
## Recover from the removal of $@
	@if test -f $@; then :; else \
		trap 'rm -rf $(DEPDIR)/stamp-sources-generate-*' 1 2 13 15; \
		if mkdir $(DEPDIR)/stamp-sources-generate-lock 2>/dev/null; then \
## This code is being executed by the first process.
			rm -f stamp-sources-generate; \
			$(MAKE) $(AM_MAKEFLAGS) stamp-sources-generate; \
			rmdir $(DEPDIR)/stamp-sources-generate-lock; \
		else \
## This code is being executed by the follower processes.
## Wait until the first process is done.
			while test -d $(DEPDIR)/stamp-sources-generate-lock; do sleep 1; done; \
## Succeed iff the first process succeeded.
			test -f stamp-sources-generate; exit $$?; \
		fi; \
	fi;