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