blob: c3043ee1fedb08965de1d608d212362a421f17df (
plain)
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
|
<!-- $Id$ -->
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="GENERATOR" CONTENT="Mozilla/4.04 [en] (X11; I; Linux 2.0.32 i486) [Netscape]">
<META NAME="Author" CONTENT="Billy Quinn">
<META NAME="Description" CONTENT="A first step towards using ACE productively">
<TITLE>ACE Tutorial 005</TITLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#000FFF" VLINK="#FF0F0F">
<CENTER><B><FONT SIZE=+2>ACE Tutorial 005</FONT></B></CENTER>
<CENTER><B><FONT SIZE=+2>On the road to a multithreaded server</FONT></B></CENTER>
<P>
<HR WIDTH="100%">
<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%">
<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>
|