blob: a6df8b8f36e34f26bf29b1fac64ed37503b3834b (
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
|
# -*- 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.
#
## ----------------------------------------------------------------
## Special rule for regenerating the local Makefile.gen
##
## Define the variable 'makefile_gen_gen_command' to be the command
## that creates $(srcdir)/Makefile.gen . The rule below will check to
## make sure that it can create the generated file, and if not exits
## with an error -1.
##
STAMPS += $(DEPDIR)/Makefile.gen-generate-generate-*
generate-makefile $(srcdir)/Makefile.gen:
## parallel make protection; can't hurt
@trap 'rm -rf $(DEPDIR)/Makefile.gen-generate-*' 1 2 13 15; \
if mkdir $(DEPDIR)/Makefile.gen-generate-lock 2>/dev/null; then \
## This code is being executed by the first process.
rm -f $(DEPDIR)/Makefile.gen-generate-stamp; \
rm -f $(DEPDIR)/Makefile.gen-generate-tmp; \
touch $(DEPDIR)/Makefile.gen-generate-tmp; \
## recreate $(srcdir)/Makefile.gen only if ...
do_recreate=0; \
if test -f $(srcdir)/Makefile.gen; then \
## the file exists and can be removed; or ...
if $(RM) $(srcdir)/Makefile.gen 2>/dev/null; then \
do_recreate=1; \
fi; \
else \
## the file doesn't exist, but can be created (e.g., by touching it).
if touch $(srcdir)/Makefile.gen 2>/dev/null; then \
do_recreate=1; \
fi; \
fi; \
if test "$$do_recreate" == "1"; then \
echo "Regenerating $(srcdir)/Makefile.gen"; \
$(makefile_gen_gen_command); \
else \
echo "Cannot recreate $(srcdir)/Makefile.gen because the directory or file is write-protected."; \
exit -1; \
fi; \
mv -f $(DEPDIR)/Makefile.gen-generate-tmp $(DEPDIR)/Makefile.gen-generate-stamp; \
rmdir $(DEPDIR)/Makefile.gen-generate-lock; \
else \
## This code is being executed by the follower processes.
## Wait until the first process is done.
while test -d $(DEPDIR)/Makefile.gen-generate-lock; do sleep 1; done; \
## Succeed if and only if the first process succeeded.
test -f $(DEPDIR)/Makefile.gen-generate-stamp; exit $$?; \
fi;
|