Various makefile fixes.
[dyninst.git] / Makefile
1 #
2 # TopLevel Makefile for the Paradyn (and DyninstAPI) system.
3 #
4 # $Id: Makefile,v 1.95 2008/10/03 21:12:39 legendre Exp $
5 #
6
7 TO_CORE = .
8 # Include additional local definitions (if available)
9 -include ./make.config.local
10 # Include the make configuration specification (site configuration options)
11 include ./make.config
12
13 BUILD_ID = "$(SUITE_NAME) v$(RELEASE_NUM)$(BUILD_MARK)$(BUILD_NUM)"
14
15 SymtabAPI       = ready common symtabAPI dynutil
16 StackwalkerAPI = ready common symtabAPI stackwalk
17 DyninstAPI      = ready common symtabAPI instructionAPI dyninstAPI_RT dyninstAPI dynutil
18 InstructionAPI  = ready common instructionAPI dynutil
19 ProcControlAPI = ready common proccontrol
20 DepGraphAPI = depGraphAPI
21 ValueAdded = valueAdded/sharedMem
22 SymEval = symEval
23
24
25 testsuites = dyninstAPI/tests 
26 allSubdirs_noinstall =
27
28 ifndef DONT_BUILD_DYNINST
29 fullSystem      += $(DyninstAPI)
30 Build_list      += DyninstAPI
31 endif
32
33 ifndef DONT_BUILD_PROCCONTROL
34 fullSystem += proccontrol
35 Build_list += proccontrol
36 endif
37
38 ifndef DONT_BUILD_NEWTESTSUITE
39 testsuites += testsuite parseThat
40 allSubdirs_noinstall += testsuite 
41 fullSystem += testsuite parseThat
42 Build_list += testsuite parseThat
43 endif
44
45 allCoreSubdirs  = dyninstAPI_RT common dyninstAPI symtabAPI dynutil instructionAPI
46 allSubdirs      = $(allCoreSubdirs) parseThat testsuites valueAdded/sharedMem depGraphAPI stackwalk symEval proccontrol
47
48 # We're not building the new test suite on all platforms yet
49
50
51 # Note that the first rule listed ("all") is what gets made by default,
52 # i.e., if make is given no arguments.  Don't add other targets before all!
53
54 all: ready world
55
56 # This rule makes most of the normal recursive stuff.  Just about any
57 # target can be passed down to the lower-level Makefiles by listing it
58 # as a target here:
59
60 depend:
61         +@for subsystem in $(fullSystem); do                    \
62             if [ -f $$subsystem/$(PLATFORM)/Makefile ]; then    \
63                         $(MAKE) -C $$subsystem/$(PLATFORM) $@;          \
64             else                                                \
65                         true;                                           \
66             fi                                                  \
67         done
68
69 clean distclean:
70         +@for subsystem in $(allSubdirs); do                    \
71             if [ -f $$subsystem/$(PLATFORM)/Makefile ]; then    \
72                         $(MAKE) -C $$subsystem/$(PLATFORM) $@;          \
73             else                                                \
74                         true;                                           \
75             fi                                                  \
76         done
77
78 install:        ready world
79         +@for subsystem in $(fullSystem); do                    \
80                 if [ -f $$subsystem/$(PLATFORM)/Makefile ]; then        \
81                         $(MAKE) -C $$subsystem/$(PLATFORM) install;             \
82                 elif [ -f $$subsytem/Makefile ]; then                   \
83                         $(MAKE) -C $$subsystem install; \
84            else \
85                         true;                                           \
86            fi                                                   \
87         done    
88
89 # Check that the main installation directories, etc., are ready for a build,
90 # creating them if they don't already exist!  Also touch make.config.local
91 # if needed.
92
93 ready:
94         +@for installdir in $(LIBRARY_DEST) $(PROGRAM_DEST) $(INCLUDE_DEST); do \
95             if [ -d $$installdir ]; then                        \
96                 echo "Installation directory $$installdir exists...";   \
97                 true;                                           \
98             else                                                \
99                 echo "Creating installation directory $$installdir ...";\
100                 mkdir -p $$installdir;                          \
101             fi                                                  \
102         done
103
104         +@if [ ! -f make.config.local ]; then   \
105             touch make.config.local;            \
106         fi
107
108         +@echo "Primary compiler for Paradyn build is:"
109         +@if [ `basename $(CXX)` = "xlC" ]; then                \
110                echo "xlC"; \
111         elif [ `basename $(CXX)` = "insure" ]; then \
112                 echo "insure"; \
113         else \
114         echo CXX = $(CXX); \
115           $(CXX) -v; \
116      true; \
117         fi
118
119 # The "make world" target is set up to build things in the "correct"
120 # order for a build from scratch.  It builds and installs things in the
121 # "basicComps" list first, then builds and installs the remaining
122 # Paradyn "subSystems" (excluding the currently optional DyninstAPI).
123 # NB: "make world" has also been set up locally to build the DyninstAPI,
124 # however, this is optional and can be removed if desired.
125 #
126 # This make target doesn't go first in the Makefile, though, since we
127 # really only want to make "install" when it's specifically requested.
128 # Note that "world" doesn't do a "clean", since it's nice to be able
129 # to restart a compilation that fails without re-doing a lot of
130 # unnecessary work.
131
132 intro:
133         @echo "Build of $(BUILD_ID) starting for $(PLATFORM)!"
134 ifdef DONT_BUILD_DYNINST
135         @echo "Build of DyninstAPI components skipped!"
136 endif
137
138 world: intro
139         $(MAKE) $(fullSystem)
140         @echo "Build of $(BUILD_ID) complete for $(PLATFORM)!"
141
142 # "make Paradyn" and "make DyninstAPI" are also useful and valid build targets!
143
144 DyninstAPI SymtabAPI StackwalkerAPI basicComps subSystems testsuites InstructionAPI ValueAdded DepGraphAPI SymEval ProcControlAPI: 
145         $(MAKE) $($@)
146         @echo "Build of $@ complete."
147         @date
148
149 # Low-level directory-targets  (used in the sets defined above)
150 # Explicit specification of these rules permits better parallelization
151 # than building subsystems using a for loop
152
153 .PHONY: $(allSubdirs) $(allSubdirs_noinstall)
154
155 $(allSubdirs): 
156         @if [ -f $@/$(PLATFORM)/Makefile ]; then \
157                 $(MAKE) -C $@/$(PLATFORM) && \
158                 $(MAKE) -C $@/$(PLATFORM) install; \
159         elif [ -f $@/Makefile ]; then \
160                 $(MAKE) -C $@ && \
161                 $(MAKE) -C $@ install; \
162         else \
163                 echo $@ has no Makefile; \
164                 true; \
165         fi
166
167 $(allSubdirs_noinstall):
168         +@if [ -f $@/$(PLATFORM)/Makefile ]; then \
169                 $(MAKE) -C $@/$(PLATFORM); \
170         elif [ -f $@/Makefile ]; then \
171                 $(MAKE) -C $@; \
172         else \
173                 echo $@ has no Makefile; \
174                 false; \
175         fi
176
177 # Generate targets of the form install_<target> for all directories in
178 # allSubdirs_noinstall
179 allSubdirs_explicitInstall = $(patsubst %,install_%,$(allSubdirs_noinstall))
180 coreSubdirs_explicitInstall = $(patsubst %,install_%,$(allCoreSubdirs))
181
182 $(allSubdirs_explicitInstall): install_%: %
183         +@if [ -f $(@:install_%=%)/$(PLATFORM)/Makefile ]; then \
184                 $(MAKE) -C $(@:install_%=%)/$(PLATFORM) install; \
185         elif [ -f $(@:install_%=%)/Makefile ]; then \
186                 $(MAKE) -C $(@:install_%=%) install; \
187         else \
188                 echo $(@:install_%=%) has no Makefile; \
189                 true; \
190         fi
191
192
193 $(coreSubdirs_explicitInstall): install_%: %
194         +@if [ -f $(@:install_%=%)/$(PLATFORM)/Makefile ]; then \
195                 $(MAKE) -C $(@:install_%=%)/$(PLATFORM) install; \
196         elif [ -f $(@:install_%=%)/Makefile ]; then \
197                 $(MAKE) -C $(@:install_%=%) install; \
198         else \
199                 echo $(@:install_%=%) has no Makefiles; \
200                 true; \
201         fi
202 # dependencies -- keep parallel make from building out of order
203 symtabAPI igen: common
204 stackwalk: symtabAPI dynutil
205 dyninstAPI: symtabAPI instructionAPI
206 symtabAPI dyninstAPI: dynutil
207 dyner codeCoverage dyninstAPI/tests testsuite: dyninstAPI
208 testsuite: $(coreSubdirs_explicitInstall)
209 testsuite: parseThat
210 parseThat: $(coreSubdirs_explicitInstall)
211 proccontrol: $(coreSubdirs_explicitInstall)
212 #depGraphAPI: instructionAPI $(coreSubdirs_explicitInstall)
213 # depGraphAPI: instructionAPI dyninstAPI
214
215 # This rule passes down the documentation-related make stuff to
216 # lower-level Makefiles in the individual "docs" directories.
217
218 docs install-man:
219         +for subsystem in $(fullSystem); do                     \
220             if [ -f $$subsystem/docs/Makefile ]; then           \
221                 $(MAKE) -C $$subsystem/docs $@;                 \
222             else                                                \
223                 true;                                           \
224             fi                                                  \
225         done
226
227
228 # The "make nightly" target is what should get run automatically every
229 # night.  It uses "make world" to build things in the right order for
230 # a build from scratch.  
231 #
232 # Note that "nightly" should only be run on the primary build site,
233 # and does things like building documentation that don't need to be
234 # built for each different architecture.  Other "non-primary" build
235 # sites that run each night should just run "make clean world".
236
237 umd-nightly:
238         $(MAKE) clean
239         $(MAKE) DyninstAPI ValueAdded
240
241 # Used for UW nightly builds
242 nightly: DyninstAPI ValueAdded parseThat 
243         $(MAKE) -C testsuite/$(PLATFORM) all
244
245 #nightly:
246 #       $(MAKE) clean
247 #       $(MAKE) world
248 ##      $(MAKE) DyninstAPI
249 #       $(MAKE) docs
250 #       $(MAKE) install-man
251 #       chmod 644 /p/paradyn/man/man?/*