3 # Copyright 2009 Free Software Foundation, Inc.
5 # This file is part of GNU Radio
7 # GNU Radio is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3, or (at your option)
12 # GNU Radio is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with GNU Radio; see the file COPYING. If not, write to
19 # the Free Software Foundation, Inc., 51 Franklin Street,
20 # Boston, MA 02110-1301, USA.
23 STAMPS += $(DEPDIR)/sources-generate-*
25 # Ensure parallel make does the right thing.
26 # http://sources.redhat.com/automake/automake.html#Multiple-Outputs
28 $(DEPDIR)/sources-generate-stamp: $(gen_sources_deps)
29 @rm -f $(DEPDIR)/sources-generate-tmp
30 @touch $(DEPDIR)/sources-generate-tmp
31 PYTHONPATH=$(top_srcdir)/gnuradio-core/src/python srcdir=$(srcdir) $(PYTHON) $(srcdir)/generate_all.py
32 @mv -f $(DEPDIR)/sources-generate-tmp $@
34 $(gen_sources): $(DEPDIR)/sources-generate-stamp
35 ## Recover from the removal of $@
36 @if test -f $@; then :; else \
37 trap 'rm -rf $(DEPDIR)/sources-generate-*' 1 2 13 15; \
38 if mkdir $(DEPDIR)/sources-generate-lock 2>/dev/null; then \
39 ## This code is being executed by the first process.
40 rm -f $(DEPDIR)/sources-generate-stamp; \
41 $(MAKE) $(AM_MAKEFLAGS) $(DEPDIR)/sources-generate-stamp; \
42 rmdir $(DEPDIR)/sources-generate-lock; \
44 ## This code is being executed by the follower processes.
45 ## Wait until the first process is done.
46 while test -d $(DEPDIR)/sources-generate-lock; do sleep 1; done; \
47 ## Succeed if and only if the first process succeeded.
48 test -f $(DEPDIR)/sources-generate-stamp; exit $$?; \
52 ## ----------------------------------------------------------------
53 ## Special rule for regenerating the local Makefile.gen
55 STAMPS += $(DEPDIR)/generate-makefile-generate-*
57 generate-makefile $(srcdir)/Makefile.gen:
58 ## parallel make protection; can't hurt
59 @trap 'rm -rf $(DEPDIR)/Makefile.gen-generate-*' 1 2 13 15; \
60 if mkdir $(DEPDIR)/Makefile.gen-generate-lock 2>/dev/null; then \
61 ## This code is being executed by the first process.
62 rm -f $(DEPDIR)/Makefile.gen-generate-stamp; \
63 rm -f $(DEPDIR)/Makefile.gen-generate-tmp; \
64 touch $(DEPDIR)/Makefile.gen-generate-tmp; \
65 ## recreate $(srcdir)/Makefile.gen only if ...
67 if test -f $(srcdir)/Makefile.gen; then \
68 ## the file exists and can be removed; or ...
69 if $(RM) $(srcdir)/Makefile.gen 2>/dev/null; then \
73 ## the file doesn't exist, but can be created (e.g., by touching it).
74 if touch $(srcdir)/Makefile.gen 2>/dev/null; then \
78 if test "$$do_recreate" == "1"; then \
79 echo "Regenerating $(srcdir)/Makefile.gen"; \
80 PYTHONPATH=$(top_srcdir)/gnuradio-core/src/python srcdir=$(srcdir) do_makefile=1 do_sources=0 $(PYTHON) $(srcdir)/generate_all.py; \
82 echo "Cannot recreate $(srcdir)/Makefile.gen because the directory or file is write-protected."; \
84 mv -f $(DEPDIR)/Makefile.gen-generate-tmp $(DEPDIR)/Makefile.gen-generate-stamp; \
85 rmdir $(DEPDIR)/Makefile.gen-generate-lock; \
87 ## This code is being executed by the follower processes.
88 ## Wait until the first process is done.
89 while test -d $(DEPDIR)/$@-generate-lock; do sleep 1; done; \
90 ## Succeed if and only if the first process succeeded.
91 test -f $(DEPDIR)/$@-generate-stamp; exit $$?; \
94 ## ----------------------------------------------------------------
96 MOSTLYCLEANFILES += $(STAMPS)