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 ## ----------------------------------------------------------------
24 ## Special rule for regenerating the local Makefile.gen
26 ## Define the variable 'makefile_gen_gen_command' to be the command
27 ## that creates $(srcdir)/Makefile.gen . The rule below will check to
28 ## make sure that it can create the generated file, and if not exits
32 STAMPS += $(DEPDIR)/Makefile.gen-generate-generate-*
34 generate-makefile $(srcdir)/Makefile.gen:
35 ## parallel make protection; can't hurt
36 @trap 'rm -rf $(DEPDIR)/Makefile.gen-generate-*' 1 2 13 15; \
37 if mkdir $(DEPDIR)/Makefile.gen-generate-lock 2>/dev/null; then \
38 ## This code is being executed by the first process.
39 rm -f $(DEPDIR)/Makefile.gen-generate-stamp; \
40 rm -f $(DEPDIR)/Makefile.gen-generate-tmp; \
41 touch $(DEPDIR)/Makefile.gen-generate-tmp; \
42 ## recreate $(srcdir)/Makefile.gen only if ...
44 if test -f $(srcdir)/Makefile.gen; then \
45 ## the file exists and can be removed; or ...
46 if $(RM) $(srcdir)/Makefile.gen 2>/dev/null; then \
50 ## the file doesn't exist, but can be created (e.g., by touching it).
51 if touch $(srcdir)/Makefile.gen 2>/dev/null; then \
55 if test "$$do_recreate" == "1"; then \
56 echo "Regenerating $(srcdir)/Makefile.gen"; \
57 $(makefile_gen_gen_command); \
59 echo "Cannot recreate $(srcdir)/Makefile.gen because the directory or file is write-protected."; \
62 mv -f $(DEPDIR)/Makefile.gen-generate-tmp $(DEPDIR)/Makefile.gen-generate-stamp; \
63 rmdir $(DEPDIR)/Makefile.gen-generate-lock; \
65 ## This code is being executed by the follower processes.
66 ## Wait until the first process is done.
67 while test -d $(DEPDIR)/Makefile.gen-generate-lock; do sleep 1; done; \
68 ## Succeed if and only if the first process succeeded.
69 test -f $(DEPDIR)/Makefile.gen-generate-stamp; exit $$?; \