Restored MakeCriticalSectionGlobal that got lost somewhere.
[wine/multimedia.git] / Make.rules.in
blobc3d77fbae3805d072274acef50351e912335a567
1 # Global rules shared by all makefiles     -*-Makefile-*-
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
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
26 # First some useful definitions
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 LD        = @LD@
57 LDFLAGS   = @LDFLAGS@
58 LDCOMBINE = $(LD) -r
59 RM        = rm -f
60 MV        = mv
61 C2MAN     = @C2MAN@
62 MANSPECS  = -w $(TOPSRCDIR)/dlls/gdi/gdi32.spec \
63             -w $(TOPSRCDIR)/dlls/user/user32.spec \
64             -w $(TOPSRCDIR)/dlls/comctl32/comctl32.spec \
65             -w $(TOPSRCDIR)/dlls/commdlg/comdlg32.spec \
66             -w $(TOPSRCDIR)/dlls/kernel/kernel32.spec
67 LINT      = @LINT@
68 LINTFLAGS = @LINTFLAGS@
69 ALLLINTFLAGS = $(LINTFLAGS) $(DEFS) $(OPTIONS) $(DIVINCL)
70 MKINSTALLDIRS= $(TOPSRCDIR)/tools/mkinstalldirs
71 WINAPI_CHECK = $(TOPSRCDIR)/tools/winapi_check/winapi_check
72 WINEWRAPPER  = $(TOPSRCDIR)/tools/winewrapper
73 WINEBUILD    = $(TOOLSDIR)/tools/winebuild/winebuild
74 MAKEDEP      = $(TOOLSDIR)/tools/makedep
75 WRC          = $(TOOLSDIR)/tools/wrc/wrc
76 WMC          = $(TOOLSDIR)/tools/wmc/wmc
77 LDPATH    = @LDPATH@
78 DLLDIR    = $(TOPOBJDIR)/dlls
79 LIBWINE   = -L$(TOPOBJDIR)/library -lwine
80 LIBTSX11  = -L$(TOPOBJDIR)/tsx11 -lwine_tsx11
81 LIBUNICODE= -L$(TOPOBJDIR)/unicode -lwine_unicode
82 LIBUUID   = -L$(TOPOBJDIR)/ole -lwine_uuid
84 WINETEST     = $(TOPOBJDIR)/programs/winetest/winetest.exe$(DLLEXT)
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
93 @SET_MAKE@
95 # Installation infos
97 INSTALL         = @INSTALL@
98 INSTALL_PROGRAM = @INSTALL_PROGRAM@
99 INSTALL_SCRIPT  = @INSTALL_SCRIPT@
100 INSTALL_DATA    = @INSTALL_DATA@
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
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)
118 LINTS = $(C_SRCS:.c=.ln)
120 # Implicit rules
122 .SUFFIXES: .mc .rc .mc.rc .res .res.o .spec .spec.c .spec.def .glue.c .pl .ok
124 .c.o:
125         $(CC) -c $(ALLCFLAGS) -o $@ $<
127 .s.o:
128         $(AS) -o $@ $<
130 .S.o:
131         $(CC) -c -o $@ $<
133 .mc.mc.rc:
134         $(LDPATH) $(WMC) -i -H /dev/null -o $@ $<
136 .rc.res:
137         $(LDPATH) $(WRC) $(WRCFLAGS) $(DIVINCL) -o $@ -r $<
139 .res.res.o:
140         $(WINDRES) -i $< -o $@
142 .spec.spec.c:
143         $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -spec $<
145 .spec.spec.def:
146         $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -def $<
148 .c.glue.c:
149         $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -glue $<
151 .c.ln:
152         $(LINT) -c $(ALLLINTFLAGS) $< || ( $(RM) $@ && exit 1 )
154 .c.ok:
155         $(RUNTEST) $(RUNTESTFLAGS) -p $(TESTPROGRAM)$(DLLEXT) $< && touch $@
157 .pl.ok:
158         $(RUNTEST) $(RUNTESTFLAGS) $< && touch $@
160 .PHONY: all install uninstall clean distclean depend dummy check test testclean
162 # 'all' target first in case the enclosing Makefile didn't define any target
164 all: Makefile
166 filter:
167         @$(TOPSRCDIR)/tools/winapi/make_filter --make $(MAKE) all
169 # Rule for main module intermediate object
171 $(MODULE).tmp.o: $(SPEC_SRCS:.spec=.spec.o) $(OBJS) Makefile.in
172         $(LDCOMBINE) $(SPEC_SRCS:.spec=.spec.o) $(OBJS) -o $@
173         -$(STRIP) --strip-unneeded $@
175 # Rule for main module debug channels
177 $(MODULE).dbg.c: $(C_SRCS) $(WINEBUILD)
178         $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -debug -C$(SRCDIR) $(C_SRCS)
180 # Rule to rebuild the resource compiler
182 $(WRC):
183         cd $(TOOLSDIR)/tools/wrc && $(MAKE) wrc
185 # Rule to rebuild the message compiler
187 $(WMC):
188         cd $(TOOLSDIR)/tools/wmc && $(MAKE) wmc
190 # Rule to rebuild the 'makedep' program
192 $(MAKEDEP):
193         cd $(TOOLSDIR)/tools && $(MAKE) makedep
195 # Rule to rebuild the 'winebuild' program
197 $(WINEBUILD):
198         cd $(TOOLSDIR)/tools/winebuild && $(MAKE) winebuild
200 # Rules for makefile
202 Makefile: Makefile.in $(TOPSRCDIR)/configure
203         @echo Makefile is older than $?, please rerun $(TOPSRCDIR)/configure
204         @exit 1
206 # Rules for auto documentation
208 $(SUBDIRS:%=%/__man__): dummy
209         cd `dirname $@` && $(MAKE) man
211 man: $(C_SRCS) $(SUBDIRS:%=%/__man__)
212         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 $(SUBDIRS:%=%/__doc_html__): dummy
215         cd `dirname $@` && $(MAKE) doc-html
217 doc-html: $(C_SRCS) $(SUBDIRS:%=%/__doc_html__)
218         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 # Rule for linting
222 $(MODULE).ln : $(LINTS)
223         if test "$(LINTS)" ; \
224         then \
225                 $(LINT) $(ALLLINTFLAGS) -o$(MODULE) $(LINTS) ; \
226                 $(MV) llib-l$(MODULE).ln $(MODULE).ln ; \
227         else \
228                 $(LINT) $(ALLLINTFLAGS) -C$(MODULE) /dev/null ; \
229         fi
231 lint:: $(MODULE).ln
233 # Rules for Windows API checking
235 winapi_check::
236         $(WINAPI_CHECK) $(WINAPI_CHECK_FLAGS) $(WINAPI_CHECK_EXTRA_FLAGS) .
238 # Rules for dependencies
240 $(SUBDIRS:%=%/__depend__): $(MAKEDEP) dummy
241         cd `dirname $@` && $(MAKE) depend
243 depend: $(MAKEDEP) $(SUBDIRS:%=%/__depend__)
244         $(MAKEDEP) $(DIVINCL) -C$(SRCDIR) $(C_SRCS) $(RC_SRCS) $(RC_SRCS16) $(MC_SRCS) $(EXTRA_SRCS) $(CTESTS)
246 # Rules for cleaning
248 $(SUBDIRS:%=%/__clean__): dummy
249         cd `dirname $@` && $(MAKE) clean
251 $(SUBDIRS:%=%/__testclean__): dummy
252         cd `dirname $@` && $(MAKE) testclean
254 $(EXTRASUBDIRS:%=%/__clean__): dummy
255         -cd `dirname $@` && $(RM) $(CLEAN_FILES)
257 testclean:: $(SUBDIRS:%=%/__testclean__)
258         $(RM) $(TESTRESULTS)
260 clean:: $(SUBDIRS:%=%/__clean__) $(EXTRASUBDIRS:%=%/__clean__)
261         $(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)
263 # Rules for installing
265 $(SUBDIRS:%=%/__install__): dummy
266         cd `dirname $@` && $(MAKE) install
268 $(SUBDIRS:%=%/__uninstall__): dummy
269         cd `dirname $@` && $(MAKE) uninstall
271 # Rules for testing
273 check test:: $(TESTRESULTS)
275 $(SUBDIRS:%=%/__test__): dummy
276         @cd `dirname $@` && $(MAKE) test
278 $(PLTESTS:.c=.ok): $(WINETEST)
279 $(CTESTS:.c=.ok): $(TESTPROGRAM)$(DLLEXT)
281 $(WINETEST):
282         cd $(TOPOBJDIR)/programs/winetest && $(MAKE) winetest.exe$(DLLEXT)
284 $(TESTMAIN):
285         cd $(TOPOBJDIR)/programs/winetest && $(MAKE) wtmain.o
287 $(TESTLIST): Makefile.in
288         $(TOPSRCDIR)/programs/winetest/make_ctests $(CTESTS) >$(TESTLIST) || $(RM) $(TESTLIST)
290 $(TESTPROGRAM).so: $(TESTPROGRAM).spec.o $(TESTOBJS)
291         $(LDSHARED) $(LDDLLFLAGS) $(TESTPROGRAM).spec.o $(TESTOBJS) -o $@ $(LIBWINE) $(LIBS)
293 $(TESTPROGRAM).tmp.o: $(TESTOBJS)
294         $(LDCOMBINE) $(TESTOBJS) -o $@
295         -$(STRIP) --strip-unneeded $@
297 $(TESTPROGRAM).spec.c: $(TESTPROGRAM).tmp.o $(WINEBUILD)
298         $(LDPATH) $(WINEBUILD) $(DEFS) -sym $(TESTPROGRAM).tmp.o -o $@ -exe $(TESTPROGRAM) -mcui -L$(DLLDIR) $(TESTIMPORTS:%=-l%)
300 $(TESTPROGRAM): $(TESTOBJS)
301         $(CC) $(TESTOBJS) -o $@ $(TESTIMPORTS:%=-l%) $(LIBWINE) $(LIBS)
303 # Misc. rules
305 $(SPEC_SRCS:.spec=.spec.c): $(WINEBUILD)
307 $(GLUE:.c=.glue.c): $(WINEBUILD)
309 $(RC_SRCS:.rc=.res): $(WRC)
311 $(RC_SRCS16:.rc=.res): $(WRC)
313 $(MC_SRCS:.mc=.mc.rc): $(WMC)
315 $(SUBDIRS): dummy
316         @cd $@ && $(MAKE)
318 dummy:
320 # End of global rules