summaryrefslogtreecommitdiff
path: root/docs/tutorials/005/page06.html
blob: 76c545e5cf876ca8953a4823e235b52cef989688 (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
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
<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>Before we go, I wanted you to see the <A HREF="Makefile">Makefile</A>.

<P>
<HR WIDTH="100%">
<PRE>
#----------------------------------------------------------------------------
#	$Id$
#----------------------------------------------------------------------------

#----------------------------------------------------------------------------
#	Local macros
#----------------------------------------------------------------------------

# You can generally find a Makefile in the ACE examples, tests or the library
# itself that will satisfy our application needs.  This one was taken from
# one of the examples.

	# Define the name of the binary we want to create.  There has to be
	# a CPP file $(BIN).cpp but it doesn't necessarily have to have your
	# main() in it.  Most of the time, though, it will.
BIN    = server

	# Few applications will have a single source file.  We use the FILES
	# macro to build up a list of additional files to compile.  Notice
	# that we leave off the extension just as with BIN
FILES  = 
FILES += client_handler

	# The BUILD macro is used by the ACE makefiles.  Basically, it tells
	# the system what to build.  I don't really know what VBIN is other
	# than it is constructed from the value of BIN.  Just go with it...
BUILD	= $(VBIN)

	# Here we use some GNU make extensions to build the SRC macro. Basically,
	# we're just adding .cpp to the value of BIN and for each entry of the
	# FILES macro.
SRC = $(addsuffix .cpp,$(BIN)) $(addsuffix .cpp,$(FILES))

	# This is used by my Indent target below.  It's not a part of standard
	# ACE and you don't need it yourself.
HDR = *.h

#----------------------------------------------------------------------------
#	Include macros and targets
#----------------------------------------------------------------------------

	# This is where the real power lies!  These included makefile components
	# are similar to the C++ templates in ACE.  That is, they do a tremendous
	# amount of work for you and all you have to do is include them.
	# As a matter of fact, in our project, I created a single file named
	# "<font color=green>app.mk</font>" that includes all of these.  Our project makefiles then just
	# need to include app.mk to get everything they need.

include	$(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU
include	$(ACE_ROOT)/include/makeinclude/macros.GNU
include	$(ACE_ROOT)/include/makeinclude/rules.common.GNU
include	$(ACE_ROOT)/include/makeinclude/rules.nonested.GNU
include	$(ACE_ROOT)/include/makeinclude/rules.bin.GNU
include	$(ACE_ROOT)/include/makeinclude/rules.local.GNU

#----------------------------------------------------------------------------
#	Local targets
#----------------------------------------------------------------------------

	# Sometimes I like to reformat my code to make it more readable.  This is
	# more useful for the comments than anything else.  Unfortunately, the
	# "<font color=green>indent</font>" program doesn't quite grok C++ so I have to post-process it's
	# output just a bit.
Indent : #
	for i in $(SRC) $(HDR) ; do \
		indent -npsl -l80 -fca -fc1 -cli0 -cdb &lt; $$i | \
			sed -e 's/: :/::/g'  \
			    -e 's/^.*\(public:\)/\1/' \
			    -e 's/^.*\(protected:\)/\1/' \
			    -e 's/^.*\(private:\)/\1/' \
			    -e 's/:\(public\)/ : \1/' \
			    -e 's/:\(protected\)/ : \1/' \
			    -e 's/:\(private\)/ : \1/' \
			> $$i~ ;\
		mv $$i~ $$i ;\
	done

	# One of the targets in the ACE makefiles is "<font color=green>depend</font>".  It will invoke
	# your compiler in a way that will generate a list of dependencies for
	# you.  This is a great thing!  Unfortunately, it puts all of that mess
	# directly into the Makefile.  I prefer my Makefile to stay clean and
	# uncluttered.  The perl script referenced here pulls the dependency
	# stuff back out of the Makefile and into a file "<font color=green>.depend</font>" which we then
	# include just like the makefile components above.
Depend : depend
	perl ../fix.Makefile

.depend : #
	touch .depend


HTML : #
	[ -f hdr ] || $(MAKE) UNSHAR
	perl ../combine *.pre ; chmod +r *.html

SHAR : #
	[ ! -f combine.shar ] || exit 1
	shar -T hdr bodies *.pre > combine.shar && rm -f hdr bodies *.pre *.pst

UNSHAR : #
	sh combine.shar

#----------------------------------------------------------------------------
#	Dependencies
#----------------------------------------------------------------------------

	# Don't put anything below here.  Between the "<font color=green>depend</font>" target and fix.Makefile
	# it's guaranteed to be lost!

	# This is inserted by the fix.Makefile script
include .depend
</PRE>
<P><HR WIDTH="100%">
<CENTER>[<A HREF="../online-tutorials.html">Tutorial Index</A>] [<A HREF="page07.html">Continue This Tutorial</A>]</CENTER>