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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!--Converted with LaTeX2HTML 98.1p1 release (March 2nd, 1998)
originally by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds
* revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>A Makefile</TITLE>
<META NAME="description" CONTENT="A Makefile">
<META NAME="keywords" CONTENT="tpman">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<LINK REL="STYLESHEET" HREF="tpman.css">
<LINK REL="next" HREF="node25.html">
<LINK REL="previous" HREF="node23.html">
<LINK REL="up" HREF="node22.html">
<LINK REL="next" HREF="node25.html">
</HEAD>
<BODY >
<!--Navigation Panel-->
<A NAME="tex2html422"
HREF="node25.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next"
SRC="/usr/share/latex2html/icons/next.png"></A>
<A NAME="tex2html418"
HREF="node22.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up"
SRC="/usr/share/latex2html/icons/up.png"></A>
<A NAME="tex2html412"
HREF="node23.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous"
SRC="/usr/share/latex2html/icons/prev.png"></A>
<A NAME="tex2html420"
HREF="node4.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents"
SRC="/usr/share/latex2html/icons/contents.png"></A>
<A NAME="tex2html421"
HREF="node58.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index"
SRC="/usr/share/latex2html/icons/index.png"></A>
<BR>
<B> Next:</B> <A NAME="tex2html423"
HREF="node25.html">Using lint</A>
<B> Up:</B> <A NAME="tex2html419"
HREF="node22.html">Running It</A>
<B> Previous:</B> <A NAME="tex2html413"
HREF="node23.html">The Program and the</A>
<BR>
<BR>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION00082000000000000000"> </A>
<A NAME="makefile"> </A>
<BR>
A Makefile
</H2>
For the sake of convenience, we give here a typical <I>makefile</I>
for use with the term
processor, <I>yacc</I> and <I>lex</I>.
This example illustrates a naming convention: the input files are called
<I>file1.k</I> and <I>file2.k</I>, all user-provided C code is in the file <I>examplemain.c</I>,
the <I>yacc</I> input is in <I>exampley.y</I>, and the <I>lex</I> input is in
<I>examplel.l</I>.
Note that the makefile makes extensive use of <I>make</I>'s defaults,
and that it attempts to
avoid superfluous recompilations.
<A NAME="1002"> </A>
<PRE><HR><!--lgrindfile: makefile.make 14:14 Oct 27 1992-->
<I># /* Makefile for the term processor */
</I><I># /* 2 input .k-files plus yacc and lex usage. */
</I>IT = example
KFILES = file1.k file2.k
YOURFILES = ${KFILES} ${IT}y.y ${IT}l.l ${IT}main.c
ALLOBJS = k.o rk.o csgiok.o unpk.o\
${KFILES:k=o} ${IT}y.o ${IT}l.o ${IT}main.o
GENERATED_BY_KC = k.c rk.c csgiok.c unpk.c ${KFILES:k=c}\
k.h rk.h csgiok.h unpk.h ${KFILES:k=h}
YFLAGS = -d
<BR>
${IT}: ${ALLOBJS}
${CC} ${CFLAGS} ${ALLOBJS} -ll -o $@
<BR>
${GENERATED_BY_KC}: kctimestamp
<BR>
kctimestamp: ${KFILES}
kc ${KFILES}; touch kctimestamp
<BR>
${ALLOBJS}: k.h
${IT}main.o ${IT}l.o: x.tab.h
${IT}main.o ${KFILES:k=o}: ${KFILES:k=h}
${IT}main.o rk.o: rk.h
${IT}main.o csgiok.o: csgiok.h
${IT}main.o unpk.o: unpk.h
<BR>
<I># /* making copies to prevent unnecessary recompilation after yacc run */
</I>x.tab.h: y.tab.h
-cmp -s x.tab.h y.tab.h || cp y.tab.h x.tab.h
<BR>
<I># /* if you clean up, don't forget to remove the file kctimestamp */
</I>
<HR></PRE>
This makefile is rather complicated, for the following reason.
The target (<I>${IT}</I>) depends on a number of object files, which depend
on a number of <I>.c</I> and <I>.h</I> files, some of which depend on the <I>.k</I> files.
However, if <I>example.k</I> is changed the term processor does not always change
all <I>.c</I> and <I>.h</I> files, and
we want to avoid recompilations of unchanged files.
For this reason, an intermediate target <I>kctimestamp</I> is introduced that `remembers'
when <I>kc</I> was last executed successfully.
<P>
The last rule (for <I>x.tab.h</I>) helps to avoid recompilations when <I>yacc</I>
overwrites the file <I>y.tab.h</I> but doesn't change it.
<P>
There is still a problem with this makefile.
It assumes that if <I>kctimestamp</I> is up to date the generated
files are also accurate.
The user can mess this up.
<P>
How to adapt this to your situation?
If you have a different number of <I>.k</I> files, you will have to adapt the definition of the <I>KFILES</I> macro.
If you do not use <I>yacc</I> you can remove the lines containing <I>x.tab.h</I> (2 lines)
and the filenames
<I>${IT}y.[yo]</I>.
If you do not use <I>lex</I> you can remove the filenames <I>${IT}l.[lo]</I> and the
loader option <I>-ll</I>.
In either case it is sufficient to remove the object file names
from the definition of the macro <I>ALLOBJS</I>.
This is also true for other files that need not be included in the final program.
For example, if no rewriting functions are used you can delete <I>rk.o</I> from <I>ALLOBJS</I>
and it will not be compiled.
<P>
<HR>
<!--Navigation Panel-->
<A NAME="tex2html422"
HREF="node25.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next"
SRC="/usr/share/latex2html/icons/next.png"></A>
<A NAME="tex2html418"
HREF="node22.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up"
SRC="/usr/share/latex2html/icons/up.png"></A>
<A NAME="tex2html412"
HREF="node23.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous"
SRC="/usr/share/latex2html/icons/prev.png"></A>
<A NAME="tex2html420"
HREF="node4.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents"
SRC="/usr/share/latex2html/icons/contents.png"></A>
<A NAME="tex2html421"
HREF="node58.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index"
SRC="/usr/share/latex2html/icons/index.png"></A>
<BR>
<B> Next:</B> <A NAME="tex2html423"
HREF="node25.html">Using lint</A>
<B> Up:</B> <A NAME="tex2html419"
HREF="node22.html">Running It</A>
<B> Previous:</B> <A NAME="tex2html413"
HREF="node23.html">The Program and the</A>
<!--End of Navigation Panel-->
<ADDRESS>
<I></I>
<BR><I>2000-04-17</I>
</ADDRESS>
</BODY>
</HTML>
|