A few optimizations in the process startup requests now that Winelib
[wine] / Make.rules.in
1 # Global rules shared by all makefiles     -*-Makefile-*-
2 #
3 # Each individual makefile must define the following variables:
4 # TOPSRCDIR    : top-level source directory
5 # TOPOBJDIR    : top-level object directory
6 # SRCDIR       : source directory for this module
7 # MODULE       : name of the module being built
8 #
9 # Each individual makefile may define the following additional variables:
10 # C_SRCS       : C sources for the module
11 # ASM_SRCS     : assembly sources
12 # GEN_C_SRCS   : generated C files
13 # GEN_ASM_SRCS : generated assembly sources
14 # RC_SRCS      : resource source files
15 # SPEC_SRCS    : interface definition files
16 # GLUE         : C sources for which glue code needs to be generated
17 # EXTRA_SRCS   : extra source files for make depend
18 # EXTRA_OBJS   : extra object files
19 # IMPORTS      : dlls to import
20 # DELAYIMPORTS : dlls to import in delayed mode
21 # SUBDIRS      : subdirectories that contain a Makefile
22 # EXTRASUBDIRS : subdirectories that do not contain a Makefile
23 # PLTESTS      : Perl test scripts
24 # CTESTS       : C test sources
25
26 # First some useful definitions
27
28 SHELL     = /bin/sh
29 CC        = @CC@
30 CPP       = @CPP@
31 CFLAGS    = @CFLAGS@
32 OPTIONS   = @OPTIONS@ -D_REENTRANT
33 X_CFLAGS  = @X_CFLAGS@
34 X_LIBS    = @X_LIBS@
35 XLIB      = @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@
36 LIBS      = @LIBS@
37 YACC      = @YACC@
38 LEX       = @LEX@
39 LEXLIB    = @LEXLIB@
40 EXEEXT    = @EXEEXT@
41 OBJEXT    = @OBJEXT@
42 LIBEXT    = @LIBEXT@
43 DLLEXT    = @DLLEXT@
44 LDSHARED  = @LDSHARED@
45 DLLWRAP   = @DLLWRAP@
46 DLLWRAPFLAGS = --add-stdcall-alias
47 AR        = @AR@ rc
48 RANLIB    = @RANLIB@
49 STRIP     = @STRIP@
50 WINDRES   = @WINDRES@
51 LN        = @LN@
52 LN_S      = @LN_S@
53 TOOLSDIR  = @TOOLSDIR@
54 DIVINCL   = -I$(SRCDIR) -I. -I$(TOPSRCDIR)/include -I$(TOPOBJDIR)/include $(EXTRAINCL)
55 ALLCFLAGS = $(DIVINCL) $(CFLAGS) $(DEFS) $(OPTIONS) $(X_CFLAGS)
56 LDCOMBINE = @LDCOMBINE@
57 LDFLAGS   = @LDFLAGS@
58 RM        = rm -f
59 MV        = mv
60 C2MAN     = @C2MAN@
61 MANSPECS  = -w $(TOPSRCDIR)/dlls/gdi/gdi32.spec \
62             -w $(TOPSRCDIR)/dlls/user/user32.spec \
63             -w $(TOPSRCDIR)/dlls/comctl32/comctl32.spec \
64             -w $(TOPSRCDIR)/dlls/commdlg/comdlg32.spec \
65             -w $(TOPSRCDIR)/dlls/kernel/kernel32.spec 
66 LINT      = @LINT@
67 LINTFLAGS = @LINTFLAGS@
68 ALLLINTFLAGS = $(LINTFLAGS) $(DEFS) $(OPTIONS) $(DIVINCL)
69 MKINSTALLDIRS= $(TOPSRCDIR)/tools/mkinstalldirs
70 WINAPI_CHECK = $(TOPSRCDIR)/tools/winapi_check/winapi_check
71 WINEWRAPPER  = $(TOPSRCDIR)/tools/winewrapper
72 WINEBUILD    = $(TOOLSDIR)/tools/winebuild/winebuild
73 MAKEDEP      = $(TOOLSDIR)/tools/makedep
74 WRC          = $(TOOLSDIR)/tools/wrc/wrc
75 WMC          = $(TOOLSDIR)/tools/wmc/wmc
76 LDPATH    = @LDPATH@
77 DLLDIR    = $(TOPOBJDIR)/dlls
78 LIBWINE   = -L$(TOPOBJDIR)/library -lwine
79 LIBTSX11  = -L$(TOPOBJDIR)/tsx11 -lwine_tsx11
80 LIBUNICODE= -L$(TOPOBJDIR)/unicode -lwine_unicode
81 LIBUUID   = -L$(TOPOBJDIR)/ole -lwine_uuid
82
83 WINETEST     = $(TOPOBJDIR)/programs/winetest/winetest.exe$(DLLEXT)
84 RUNTEST      = $(TOPSRCDIR)/programs/winetest/runtest
85 RUNTESTFLAGS = -q -P wine -M $(MODULE) -T $(TOPOBJDIR)
86 TESTRESULTS  = $(PLTESTS:.pl=.ok) $(CTESTS:.c=.ok)
87 TESTPROGRAM  = tests/$(MODULE:%.dll=%)_test.exe
88 TESTLIST     = tests/testlist.c
89 TESTOBJS     = $(TESTMAIN) $(TESTLIST:.c=.o) $(CTESTS:.c=.o)
90 TESTMAIN     = $(TOPOBJDIR)/programs/winetest/wtmain.o
91
92 @SET_MAKE@
93
94 # Installation infos
95
96 INSTALL         = @INSTALL@
97 INSTALL_PROGRAM = @INSTALL_PROGRAM@
98 INSTALL_SCRIPT  = @INSTALL_SCRIPT@
99 INSTALL_DATA    = @INSTALL_DATA@
100 prefix          = @prefix@
101 exec_prefix     = @exec_prefix@
102 bindir          = @bindir@
103 libdir          = @libdir@
104 infodir         = @infodir@
105 mandir          = @mandir@
106 sysconfdir      = @sysconfdir@
107 includedir      = @includedir@/wine
108 dlldir          = @libdir@/wine
109 prog_manext     = 1
110 conf_manext     = 5
111 CLEAN_FILES     = *.o *.a *.so *.ln *.$(LIBEXT) \\\#*\\\# *~ *% .\\\#* *.bak *.orig *.rej \
112                   *.flc *.spec.c *.spec.def *.glue.c *.dbg.c y.tab.c y.tab.h @LEX_OUTPUT_ROOT@.c core
113
114 OBJS = $(C_SRCS:.c=.o) $(GEN_C_SRCS:.c=.o) $(GEN_ASM_SRCS:.s=.o) \
115        $(ASM_SRCS:.S=.o) $(GLUE:.c=.glue.o) $(EXTRA_OBJS)
116
117 LINTS = $(C_SRCS:.c=.ln)
118
119 # Implicit rules
120
121 .SUFFIXES: .mc .rc .mc.rc .res .res.o .spec .spec.c .spec.def .glue.c .pl .ok
122
123 .c.o:
124         $(CC) -c $(ALLCFLAGS) -o $@ $<
125
126 .s.o:
127         $(AS) -o $@ $<
128
129 .S.o:
130         $(CC) -c -o $@ $<
131
132 .mc.mc.rc:
133         $(LDPATH) $(WMC) -i -H /dev/null -o $@ $<
134
135 .rc.res:
136         $(LDPATH) $(WRC) $(WRCFLAGS) $(DIVINCL) -o $@ -r $<
137
138 .res.res.o:
139         $(WINDRES) -i $< -o $@
140
141 .spec.spec.c:
142         $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -spec $<
143
144 .spec.spec.def:
145         $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -def $<
146
147 .c.glue.c:
148         $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -glue $<
149
150 .c.ln:
151         $(LINT) -c $(ALLLINTFLAGS) $< || ( $(RM) $@ && exit 1 )
152
153 .c.ok:
154         $(RUNTEST) $(RUNTESTFLAGS) -p $(TESTPROGRAM)$(DLLEXT) $< && touch $@
155
156 .pl.ok:
157         $(RUNTEST) $(RUNTESTFLAGS) $< && touch $@
158
159 .PHONY: all install uninstall clean distclean depend dummy check test testclean
160
161 # 'all' target first in case the enclosing Makefile didn't define any target
162
163 all: Makefile
164
165 filter:
166         @$(TOPSRCDIR)/tools/winapi/make_filter --make $(MAKE) all
167
168 # Rule for main module intermediate object
169
170 $(MODULE).tmp.o: $(SPEC_SRCS:.spec=.spec.o) $(OBJS) Makefile.in
171         $(LDCOMBINE) $(SPEC_SRCS:.spec=.spec.o) $(OBJS) -o $@
172         -$(STRIP) --strip-unneeded $@
173
174 # Rule for main module debug channels
175
176 $(MODULE).dbg.c: $(C_SRCS) $(WINEBUILD)
177         $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -debug -C$(SRCDIR) $(C_SRCS)
178
179 # Rule to rebuild the resource compiler
180
181 $(WRC):
182         cd $(TOOLSDIR)/tools/wrc && $(MAKE) wrc
183
184 # Rule to rebuild the message compiler
185
186 $(WMC):
187         cd $(TOOLSDIR)/tools/wmc && $(MAKE) wmc
188
189 # Rule to rebuild the 'makedep' program
190
191 $(MAKEDEP):
192         cd $(TOOLSDIR)/tools && $(MAKE) makedep
193
194 # Rule to rebuild the 'winebuild' program
195
196 $(WINEBUILD):
197         cd $(TOOLSDIR)/tools/winebuild && $(MAKE) winebuild
198
199 # Rules for makefile
200
201 Makefile: Makefile.in $(TOPSRCDIR)/configure
202         @echo Makefile is older than $?, please rerun $(TOPSRCDIR)/configure
203         @exit 1
204
205 # Rules for auto documentation
206
207 $(SUBDIRS:%=%/__man__): dummy
208         cd `dirname $@` && $(MAKE) man
209
210 man: $(C_SRCS) $(SUBDIRS:%=%/__man__)
211         if [ -n "$(C_SRCS)" ]; then $(MKINSTALLDIRS) $(TOPOBJDIR)/documentation/man3w; for i in $(C_SRCS); do $(C2MAN) -L -o $(TOPOBJDIR)/documentation/man3w -S3w $(DIVINCL) -D__WINE__ $(MANSPECS) $$i; done; fi
212
213 $(SUBDIRS:%=%/__doc_html__): dummy
214         cd `dirname $@` && $(MAKE) doc-html
215
216 doc-html: $(C_SRCS) $(SUBDIRS:%=%/__doc_html__)
217         if [ -n "$(C_SRCS)" ]; then $(MKINSTALLDIRS) $(TOPOBJDIR)/documentation/html; for i in $(C_SRCS); do $(C2MAN) -L -o $(TOPOBJDIR)/documentation/html -Th -iwindows.h  $(DIVINCL) -D__WINE__ $(MANSPECS) $$i; done; fi
218
219 # Rule for linting
220
221 $(MODULE).ln : $(LINTS)
222         if test "$(LINTS)" ; \
223         then \
224                 $(LINT) $(ALLLINTFLAGS) -o$(MODULE) $(LINTS) ; \
225                 $(MV) llib-l$(MODULE).ln $(MODULE).ln ; \
226         else \
227                 $(LINT) $(ALLLINTFLAGS) -C$(MODULE) /dev/null ; \
228         fi
229
230 lint:: $(MODULE).ln
231
232 # Rules for Windows API checking
233
234 winapi_check::
235         $(WINAPI_CHECK) $(WINAPI_CHECK_FLAGS) $(WINAPI_CHECK_EXTRA_FLAGS) .
236
237 # Rules for dependencies
238
239 $(SUBDIRS:%=%/__depend__): $(MAKEDEP) dummy
240         cd `dirname $@` && $(MAKE) depend
241
242 depend: $(MAKEDEP) $(SUBDIRS:%=%/__depend__)
243         $(MAKEDEP) $(DIVINCL) -C$(SRCDIR) $(C_SRCS) $(RC_SRCS) $(RC_SRCS16) $(MC_SRCS) $(EXTRA_SRCS) $(CTESTS)
244
245 # Rules for cleaning
246
247 $(SUBDIRS:%=%/__clean__): dummy
248         cd `dirname $@` && $(MAKE) clean
249
250 $(SUBDIRS:%=%/__testclean__): dummy
251         cd `dirname $@` && $(MAKE) testclean
252
253 $(EXTRASUBDIRS:%=%/__clean__): dummy
254         -cd `dirname $@` && $(RM) $(CLEAN_FILES)
255
256 testclean:: $(SUBDIRS:%=%/__testclean__)
257         $(RM) $(TESTRESULTS)
258
259 clean:: $(SUBDIRS:%=%/__clean__) $(EXTRASUBDIRS:%=%/__clean__)
260         $(RM) $(CLEAN_FILES) $(GEN_C_SRCS) $(GEN_ASM_SRCS) $(RC_SRCS:.rc=.res) $(RC_SRCS16:.rc=.res) $(MC_SRCS:.mc=.mc.rc) $(TESTRESULTS) $(TESTLIST) $(TESTPROGRAM) $(PROGRAMS)
261
262 # Rules for installing
263
264 $(SUBDIRS:%=%/__install__): dummy
265         cd `dirname $@` && $(MAKE) install
266
267 $(SUBDIRS:%=%/__uninstall__): dummy
268         cd `dirname $@` && $(MAKE) uninstall
269
270 # Rules for testing
271
272 check test:: $(TESTRESULTS)
273
274 $(SUBDIRS:%=%/__test__): dummy
275         @cd `dirname $@` && $(MAKE) test
276
277 $(PLTESTS:.c=.ok): $(WINETEST)
278 $(CTESTS:.c=.ok): $(TESTPROGRAM)$(DLLEXT)
279
280 $(WINETEST):
281         cd $(TOPOBJDIR)/programs/winetest && $(MAKE) winetest.exe$(DLLEXT)
282
283 $(TESTMAIN):
284         cd $(TOPOBJDIR)/programs/winetest && $(MAKE) wtmain.o
285
286 $(TESTLIST): Makefile.in
287         $(TOPSRCDIR)/programs/winetest/make_ctests $(CTESTS) >$(TESTLIST) || $(RM) $(TESTLIST)
288
289 $(TESTPROGRAM).so: $(TESTPROGRAM).spec.o $(TESTOBJS)
290         $(LDSHARED) $(LDDLLFLAGS) $(TESTPROGRAM).spec.o $(TESTOBJS) -o $@ $(LIBWINE) $(LIBS)
291
292 $(TESTPROGRAM).tmp.o: $(TESTOBJS)
293         $(LDCOMBINE) $(TESTOBJS) -o $@
294         -$(STRIP) --strip-unneeded $@
295
296 $(TESTPROGRAM).spec.c: $(TESTPROGRAM).tmp.o $(WINEBUILD)
297         $(LDPATH) $(WINEBUILD) $(DEFS) -sym $(TESTPROGRAM).tmp.o -o $@ -exe $(TESTPROGRAM) -mcui -L$(DLLDIR) $(TESTIMPORTS:%=-l%)
298
299 $(TESTPROGRAM): $(TESTOBJS)
300         $(CC) $(TESTOBJS) -o $@ $(TESTIMPORTS:%=-l%) $(LIBWINE) $(LIBS)
301
302 # Misc. rules
303
304 $(SPEC_SRCS:.spec=.spec.c): $(WINEBUILD)
305
306 $(GLUE:.c=.glue.c): $(WINEBUILD)
307
308 $(RC_SRCS:.rc=.res): $(WRC)
309
310 $(RC_SRCS16:.rc=.res): $(WRC)
311
312 $(MC_SRCS:.mc=.mc.rc): $(WMC)
313
314 $(SUBDIRS): dummy
315         @cd $@ && $(MAKE)
316
317 dummy:
318
319 # End of global rules