diff options
Diffstat (limited to 'docs/tutorials/005/page07.html')
-rw-r--r-- | docs/tutorials/005/page07.html | 174 |
1 files changed, 73 insertions, 101 deletions
diff --git a/docs/tutorials/005/page07.html b/docs/tutorials/005/page07.html index 069f94be956..3a7433dbd34 100644 --- a/docs/tutorials/005/page07.html +++ b/docs/tutorials/005/page07.html @@ -16,108 +16,80 @@ <P> <HR WIDTH="100%"> -<P>And last (and probably least) is the <A HREF="fix.Makefile">perl script</A> +<P>And last (and probably least) is the <A HREF="../fix.Makefile">perl script</A> that pulls the dependency stuff out of Makefile and into .depend. <P> <HR WIDTH="100%"> -<BR> <FONT FACE="Arial,Helvetica">#!/usr/bin/perl</FONT><FONT FACE="Arial,Helvetica"></FONT> - -<P><FONT FACE="Arial,Helvetica"> -# Open the Makefile that has been mangled by 'make depend'</FONT> -<BR><FONT FACE="Arial,Helvetica"> -# and suck it into a perl array.</FONT> -<BR><FONT FACE="Arial,Helvetica">open(IF,"<Makefile") || die;</FONT> -<BR><FONT FACE="Arial,Helvetica">@makefile = <IF>;</FONT> -<BR><FONT FACE="Arial,Helvetica">close(IF);</FONT><FONT FACE="Arial,Helvetica"></FONT> - -<P><FONT FACE="Arial,Helvetica"> -# Now open our .depend file and a temporary Makefile.</FONT> -<BR><FONT FACE="Arial,Helvetica"> -# We'll split the original Makefile between these two.</FONT> -<BR><FONT FACE="Arial,Helvetica">open(DF,">.depend") || die;</FONT> -<BR><FONT FACE="Arial,Helvetica">open(MF,">Makefile.tmp") || die;</FONT><FONT FACE="Arial,Helvetica"></FONT> - -<P><FONT FACE="Arial,Helvetica"> -# For each line we read out of the original file...</FONT> -<BR><FONT FACE="Arial,Helvetica">foreach (@makefile) {</FONT><FONT FACE="Arial,Helvetica"></FONT> - -<P><FONT FACE="Arial,Helvetica"> -# If we're into the dependency section, write the line</FONT> -<BR><FONT FACE="Arial,Helvetica"> -# into the .depend file.</FONT> -<BR><FONT FACE="Arial,Helvetica"> -#</FONT> -<BR><FONT FACE="Arial,Helvetica"> -if( $depend ) {</FONT> -<BR><FONT FACE="Arial,Helvetica"> -print DF $_;</FONT> -<BR><FONT FACE="Arial,Helvetica"> -}</FONT> -<BR><FONT FACE="Arial,Helvetica"> -else {</FONT> -<BR><FONT FACE="Arial,Helvetica"> -# If we haven't gotten to the dependency section yet</FONT> -<BR><FONT FACE="Arial,Helvetica"> -# then see if the current line is the separator that</FONT> -<BR><FONT FACE="Arial,Helvetica"> -# "make depend" causes to be inserted.</FONT> -<BR><FONT FACE="Arial,Helvetica"> -#</FONT> -<BR><FONT FACE="Arial,Helvetica"> -if( m/^\Q# DO NOT DELETE THIS LINE -- g++dep uses it.\E/ ) {</FONT><FONT FACE="Arial,Helvetica"></FONT> - -<P><FONT FACE="Arial,Helvetica"> -# If so, change our "mode" and skip this line.</FONT> -<BR><FONT FACE="Arial,Helvetica"> -++$depend;</FONT> -<BR><FONT FACE="Arial,Helvetica"> -next;</FONT> -<BR><FONT FACE="Arial,Helvetica"> -}</FONT><FONT FACE="Arial,Helvetica"></FONT> - -<P><FONT FACE="Arial,Helvetica"> -# Also skip the "include .depend" that we insert. If we</FONT> -<BR><FONT FACE="Arial,Helvetica"> -# don't do this, it is possible to have a bunch of these</FONT> -<BR><FONT FACE="Arial,Helvetica"> -# inserted into the output when we read an unmangled Makefile</FONT> -<BR><FONT FACE="Arial,Helvetica"> -next if( m/^include .depend/ );</FONT><FONT FACE="Arial,Helvetica"></FONT> - -<P><FONT FACE="Arial,Helvetica"> -# Print the non-dependency info to the temporary Makefile</FONT> -<BR><FONT FACE="Arial,Helvetica"> -print MF $_;</FONT> -<BR><FONT FACE="Arial,Helvetica"> -}</FONT> -<BR><FONT FACE="Arial,Helvetica">}</FONT><FONT FACE="Arial,Helvetica"></FONT> - -<P><FONT FACE="Arial,Helvetica"># Tell our new Makefile to include the -dependency file</FONT> -<BR><FONT FACE="Arial,Helvetica">print MF "include .depend\n";</FONT><FONT FACE="Arial,Helvetica"></FONT> - -<P><FONT FACE="Arial,Helvetica"># Close the two output files...</FONT> -<BR><FONT FACE="Arial,Helvetica">close(DF);</FONT> -<BR><FONT FACE="Arial,Helvetica">close(MF);</FONT><FONT FACE="Arial,Helvetica"></FONT> - -<P><FONT FACE="Arial,Helvetica"># Unlink (remove) the original Makefile -and rename our</FONT> -<BR><FONT FACE="Arial,Helvetica"># temporary file. There's obviously -room for error checking</FONT> -<BR><FONT FACE="Arial,Helvetica"># here but we've got the Makefile checked -into some revision</FONT> -<BR><FONT FACE="Arial,Helvetica"># control system anyway. Don't we?</FONT><FONT FACE="Arial,Helvetica"></FONT> - -<P><FONT FACE="Arial,Helvetica">unlink("Makefile");</FONT> -<BR><FONT FACE="Arial,Helvetica">rename("Makefile.tmp","Makefile");</FONT><FONT FACE="Arial,Helvetica"></FONT> - -<P><FONT FACE="Arial,Helvetica">exit(0);</FONT> - -<P> -<HR WIDTH="100%"> -<CENTER>[<A HREF="..">Tutorial -Index</A>] [<A HREF="page08.html">Continue This Tutorial</A>]</CENTER> - -</BODY> -</HTML> +<PRE> +eval '(exit $?0)' && eval 'exec perl -w -S $0 ${1+"<font color=green>$@</font>"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +require "<font color=green>getopts.pl</font>"; +&Getopts("<font color=green>f:o:</font>"); + +$opt_f = "<font color=green>Makefile</font>" if( ! $opt_f ); +$opt_o = "<font color=green>.depend</font>" if( ! $opt_o ); + + # Open the Makefile that has been mangled by 'make depend' + # and suck it into a perl array. +open(IF,"<font color=green><$opt_f</font>") || die; +@makefile = <IF>; +close(IF); + + # Now open our .depend file and a temporary Makefile. + # We'll split the original Makefile between these two. +open(DF,"<font color=green>>$opt_o</font>") || die; +open(MF,"<font color=green>>$opt_f.tmp</font>") || die; + + # For each line we read out of the original file... +foreach (@makefile) { + + # If we're into the dependency section, write the line + # into the .depend file. + # + if( $depend ) { + print DF $_; + } + else { + # If we haven't gotten to the dependency section yet + # then see if the current line is the separator that + # "<font color=green>make depend</font>" causes to be inserted. + # + if( m/^\Q# DO NOT DELETE THIS LINE -- g++dep uses it.\E/ ) { + + # If so, change our "<font color=green>mode</font>" and skip this line. + ++$depend; + next; + } + + # Also skip the "<font color=green>include .depend</font>" that we insert. If we + # don't do this, it is possible to have a bunch of these + # inserted into the output when we read an unmangled Makefile + next if( m/^include $opt_o/ ); + + # Print the non-dependency info to the temporary Makefile + print MF $_; + } +} + +# Tell our new Makefile to include the dependency file +print MF "<font color=green>include $opt_o\n</font>"; + +# Close the two output files... +close(DF); +close(MF); + +# Unlink (remove) the original Makefile and rename our +# temporary file. There's obviously room for error checking +# here but we've got the Makefile checked into some revision +# control system anyway. Don't we? + +unlink("<font color=green>$opt_f</font>"); +rename("<font color=green>$opt_f.tmp</font>","<font color=green>$opt_f</font>"); + +exit(0); +</PRE> +<P><HR WIDTH="100%"> +<CENTER>[<A HREF="../online-tutorials.html">Tutorial Index</A>] [<A HREF="page08.html">Continue This Tutorial</A>]</CENTER> |