quine.c: Fix double-close bug.
[quine] / Makefile.am
1 ## Process with `automake' to generate `Makefile.in'
2 ## -*-makefile-*-
3 ##
4 ## Makefile for Quine
5 ##
6 ## (c) 1999 Mark Wooding
7 ##
8
9 ##----- Licensing notice ----------------------------------------------------
10 ##
11 ## This file is part of Quine.
12 ##
13 ## Quine is free software; you can redistribute it and/or modify it
14 ## under the terms of the GNU General Public License as published by
15 ## the Free Software Foundation; either version 2 of the License, or
16 ## (at your option) any later version.
17 ##
18 ## Quine is distributed in the hope that it will be useful, but
19 ## WITHOUT ANY WARRANTY; without even the implied warranty of
20 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ## GNU General Public License for more details.
22 ##
23 ## You should have received a copy of the GNU General Public License
24 ## along with Quine; if not, write to the Free Software Foundation,
25 ## Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26
27 AUTOMAKE_OPTIONS = foreign
28
29 ## --- What needs installing ---
30
31 bin_PROGRAMS = quine
32 noinst_PROGRAMS = ansicquine
33 include_HEADERS = quine.h
34
35 ## --- How to build the program ---
36
37 quine_SOURCES = quine.c qqout.c mdwopt.c quine.h mdwopt.h
38 ansicquine_SOURCES = ansicquine.c
39 EXTRA_DIST = \
40 qqlib.c qqout.c qqlout.c rexxquine.exec bournequine \
41 debian/control debian/changelog debian/rules debian/copyright
42 CLEANFILES = xquine yquine
43 MAINTAINERCLEANFILES = qqout.c qqlout.c $(srcdir)/qqout.c $(srcdir)/qqlout.c
44
45 ## --- I need recursive makeness ---
46 ##
47 ## In this way, I can rebuild `xquine' and `yquine' only when they really
48 ## get needed.
49
50 @SET_MAKE@
51
52 ## --- Some hacking for the bootstrapping process ---
53 ##
54 ## The outputtable library gets built from `qqlib.c'. I therefore have to
55 ## build a `quine' which can do this. This is `xquine'. Then, I can
56 ## build a `yquine' which is capable of writing full `qqout.c' files, with
57 ## which I can build the final glorious `quine'.
58
59 xquine: xquine.o qqlib.o mdwopt.o
60 $(LINK) xquine.o qqlib.o mdwopt.o
61 xquine.o: quine.c
62 $(COMPILE) -c -DQQ_XQUINE $(srcdir)/quine.c -o xquine.o
63
64 yquine: yquine.o qqlib.o qqlout.o mdwopt.o
65 $(LINK) yquine.o qqlib.o qqlout.o mdwopt.o
66 yquine.o: quine.c
67 $(COMPILE) -c -DQQ_YQUINE $(srcdir)/quine.c -o yquine.o
68
69 ## --- The `qqlout.c' file ---
70 ##
71 ## The contents of `qqlib.c' are included in every `qqout.c' file we write.
72 ## But I've got to get it from somewhere so that I can write it to the first
73 ## `qqout.c' file. The solution is, as described above, to use a cut-down
74 ## `quine' program which can just about build `qqlout.c' which contains only
75 ## the library.
76
77 qqlout.c: qqlib.c
78 if [ -z "$(qq_xquine)" ]; then \
79 $(MAKE) qq_xquine=true xquine; \
80 else :; fi
81 ./xquine --qqlib $(srcdir)/qqlib.c -o qqlout.c
82
83 ## --- The `qqout.c' file ---
84 ##
85 ## This contains the complete source code for the program.
86
87 qqout.c: quine.c qqlout.c qqlib.c mdwopt.c quine.h mdwopt.h
88 if [ -z "$(qq_yquine)" ]; then \
89 $(MAKE) qq_yquine=true yquine; \
90 else :; fi
91 touch qqout.c
92 -ln qqout.c qqlout.c $(srcdir)
93 $(MAKE) distdir
94 rm qqout.c
95 find $(distdir) \( -type f -o -type l \) ! -name qqout.c -print | \
96 ./yquine -o $(distdir)/qqout.c
97 ln $(distdir)/qqout.c qqout.c
98 rm -rf $(distdir)
99
100 ##----- That's all, folks ---------------------------------------------------