Added winebuild support for generating a .dbg.c file containing the
[wine/multimedia.git] / Make.rules.in
blob1e66fdfdaff40b54f304c2bd9121f4336a1b91d5
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_S      = @LN_S@
52 TOOLSDIR  = @TOOLSDIR@
53 DIVINCL   = -I$(SRCDIR) -I. -I$(TOPSRCDIR)/include -I$(TOPOBJDIR)/include $(EXTRAINCL)
54 ALLCFLAGS = $(DIVINCL) $(CFLAGS) $(DEFS) $(OPTIONS) $(X_CFLAGS)
55 LDCOMBINE = @LDCOMBINE@
56 LDFLAGS   = @LDFLAGS@
57 RM        = rm -f
58 MV        = mv
59 C2MAN     = @C2MAN@
60 MANSPECS  = -w $(TOPSRCDIR)/dlls/gdi/gdi32.spec \
61             -w $(TOPSRCDIR)/dlls/user/user32.spec \
62             -w $(TOPSRCDIR)/dlls/comctl32/comctl32.spec \
63             -w $(TOPSRCDIR)/dlls/commdlg/comdlg32.spec \
64             -w $(TOPSRCDIR)/dlls/kernel/kernel32.spec 
65 LINT      = @LINT@
66 LINTFLAGS = @LINTFLAGS@
67 ALLLINTFLAGS = $(LINTFLAGS) $(DEFS) $(OPTIONS) $(DIVINCL)
68 MKINSTALLDIRS= $(TOPSRCDIR)/tools/mkinstalldirs
69 WINAPI_CHECK = $(TOPSRCDIR)/tools/winapi_check/winapi_check
70 WINEBUILD    = $(TOOLSDIR)/tools/winebuild/winebuild
71 MAKEDEP      = $(TOOLSDIR)/tools/makedep
72 WRC          = $(TOOLSDIR)/tools/wrc/wrc
73 WMC          = $(TOOLSDIR)/tools/wmc/wmc
74 LDPATH    = @LDPATH@
75 DLLDIR    = $(TOPOBJDIR)/dlls
76 LIBWINE   = -L$(TOPOBJDIR)/library -lwine
77 LIBTSX11  = -L$(TOPOBJDIR)/tsx11 -lwine_tsx11
78 LIBUNICODE= -L$(TOPOBJDIR)/unicode -lwine_unicode
79 LIBUUID   = -L$(TOPOBJDIR)/ole -lwine_uuid
81 WINETEST     = $(TOPOBJDIR)/programs/winetest/winetest
82 RUNTEST      = $(TOPSRCDIR)/programs/winetest/runtest
83 RUNTESTFLAGS = -q -P wine -M $(MODULE) -T $(TOPOBJDIR)
84 TESTRESULTS  = $(PLTESTS:.pl=.ok) $(CTESTS:.c=.ok)
85 TESTPROGRAM  = tests/$(MODULE:%.dll=%)_test
86 TESTLIST     = tests/testlist.c
87 TESTOBJS     = $(TESTMAIN) $(TESTLIST:.c=.o) $(CTESTS:.c=.o)
88 TESTMAIN     = $(TOPOBJDIR)/programs/winetest/wtmain.o
90 @SET_MAKE@
92 # Installation infos
94 INSTALL         = @INSTALL@
95 INSTALL_PROGRAM = @INSTALL_PROGRAM@
96 INSTALL_SCRIPT  = @INSTALL_SCRIPT@
97 INSTALL_DATA    = @INSTALL_DATA@
98 prefix          = @prefix@
99 exec_prefix     = @exec_prefix@
100 bindir          = @bindir@
101 libdir          = @libdir@
102 infodir         = @infodir@
103 mandir          = @mandir@
104 sysconfdir      = @sysconfdir@
105 includedir      = @includedir@/wine
106 dlldir          = @libdir@/wine
107 prog_manext     = 1
108 conf_manext     = 5
109 CLEAN_FILES     = *.o *.a *.so *.ln *.$(LIBEXT) \\\#*\\\# *~ *% .\\\#* *.bak *.orig *.rej \
110                   *.flc *.spec.c *.spec.def *.glue.c *.dbg.c y.tab.c y.tab.h @LEX_OUTPUT_ROOT@.c core
112 OBJS = $(C_SRCS:.c=.o) $(GEN_C_SRCS:.c=.o) $(GEN_ASM_SRCS:.s=.o) \
113        $(ASM_SRCS:.S=.o) $(GLUE:.c=.glue.o) $(EXTRA_OBJS)
115 LINTS = $(C_SRCS:.c=.ln)
117 # Implicit rules
119 .SUFFIXES: .mc .rc .mc.rc .res .res.o .spec .spec.c .spec.def .glue.c .pl .ok
121 .c.o:
122         $(CC) -c $(ALLCFLAGS) -o $@ $<
124 .s.o:
125         $(AS) -o $@ $<
127 .S.o:
128         $(CC) -c -o $@ $<
130 .mc.mc.rc:
131         $(LDPATH) $(WMC) -i -H /dev/null -o $@ $<
133 .rc.res:
134         $(LDPATH) $(WRC) $(WRCFLAGS) $(DIVINCL) -o $@ -r $<
136 .res.res.o:
137         $(WINDRES) -i $< -o $@
139 .spec.spec.c:
140         $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -spec $<
142 .spec.spec.def:
143         $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -def $<
145 .c.glue.c:
146         $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -glue $<
148 .c.ln:
149         $(LINT) -c $(ALLLINTFLAGS) $< || ( $(RM) $@ && exit 1 )
151 .c.ok:
152         $(RUNTEST) $(RUNTESTFLAGS) -p $(TESTPROGRAM) $< && touch $@
154 .pl.ok:
155         $(RUNTEST) $(RUNTESTFLAGS) $< && touch $@
157 .PHONY: all install uninstall clean distclean depend dummy check test testclean
159 # 'all' target first in case the enclosing Makefile didn't define any target
161 all: Makefile
163 filter:
164         @$(TOPSRCDIR)/tools/winapi/make_filter --make $(MAKE) all
166 # Rule for main module intermediate object
168 $(MODULE).tmp.o: $(SPEC_SRCS:.spec=.spec.o) $(OBJS) Makefile.in
169         $(LDCOMBINE) $(SPEC_SRCS:.spec=.spec.o) $(OBJS) -o $@
170         -$(STRIP) --strip-unneeded $@
172 # Rule for main module debug channels
174 $(MODULE).dbg.c: $(C_SRCS) $(WINEBUILD)
175         $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -debug -C$(SRCDIR) $(C_SRCS)
177 # Rule to rebuild the resource compiler
179 $(WRC):
180         cd $(TOOLSDIR)/tools/wrc && $(MAKE) wrc
182 # Rule to rebuild the message compiler
184 $(WMC):
185         cd $(TOOLSDIR)/tools/wmc && $(MAKE) wmc
187 # Rule to rebuild the 'makedep' program
189 $(MAKEDEP):
190         cd $(TOOLSDIR)/tools && $(MAKE) makedep
192 # Rule to rebuild the 'winebuild' program
194 $(WINEBUILD):
195         cd $(TOOLSDIR)/tools/winebuild && $(MAKE) winebuild
197 # Rules for makefile
199 Makefile: Makefile.in $(TOPSRCDIR)/configure
200         @echo Makefile is older than $?, please rerun $(TOPSRCDIR)/configure
201         @exit 1
203 # Rules for auto documentation
205 $(SUBDIRS:%=%/__man__): dummy
206         cd `dirname $@` && $(MAKE) man
208 man: $(C_SRCS) $(SUBDIRS:%=%/__man__)
209         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
211 $(SUBDIRS:%=%/__doc_html__): dummy
212         cd `dirname $@` && $(MAKE) doc-html
214 doc-html: $(C_SRCS) $(SUBDIRS:%=%/__doc_html__)
215         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
217 # Rule for linting
219 $(MODULE).ln : $(LINTS)
220         if test "$(LINTS)" ; \
221         then \
222                 $(LINT) $(ALLLINTFLAGS) -o$(MODULE) $(LINTS) ; \
223                 $(MV) llib-l$(MODULE).ln $(MODULE).ln ; \
224         else \
225                 $(LINT) $(ALLLINTFLAGS) -C$(MODULE) /dev/null ; \
226         fi
228 lint:: $(MODULE).ln
230 # Rules for Windows API checking
232 winapi_check::
233         $(WINAPI_CHECK) $(WINAPI_CHECK_FLAGS) $(WINAPI_CHECK_EXTRA_FLAGS) .
235 # Rules for dependencies
237 $(SUBDIRS:%=%/__depend__): $(MAKEDEP) dummy
238         cd `dirname $@` && $(MAKE) depend
240 depend: $(MAKEDEP) $(SUBDIRS:%=%/__depend__)
241         $(MAKEDEP) $(DIVINCL) -C$(SRCDIR) $(C_SRCS) $(RC_SRCS) $(RC_SRCS16) $(MC_SRCS) $(EXTRA_SRCS) $(CTESTS)
243 # Rules for cleaning
245 $(SUBDIRS:%=%/__clean__): dummy
246         cd `dirname $@` && $(MAKE) clean
248 $(SUBDIRS:%=%/__testclean__): dummy
249         cd `dirname $@` && $(MAKE) testclean
251 $(EXTRASUBDIRS:%=%/__clean__): dummy
252         -cd `dirname $@` && $(RM) $(CLEAN_FILES)
254 testclean:: $(SUBDIRS:%=%/__testclean__)
255         $(RM) $(TESTRESULTS)
257 clean:: $(SUBDIRS:%=%/__clean__) $(EXTRASUBDIRS:%=%/__clean__)
258         $(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)$(EXEEXT) $(PROGRAMS)
260 # Rules for installing
262 $(SUBDIRS:%=%/__install__): dummy
263         cd `dirname $@` && $(MAKE) install
265 $(SUBDIRS:%=%/__uninstall__): dummy
266         cd `dirname $@` && $(MAKE) uninstall
268 # Rules for testing
270 check test:: $(TESTRESULTS)
272 $(SUBDIRS:%=%/__test__): dummy
273         @cd `dirname $@` && $(MAKE) test
275 $(PLTESTS:.c=.ok): $(WINETEST)
276 $(CTESTS:.c=.ok): $(TESTPROGRAM)$(EXEEXT)
278 $(WINETEST):
279         cd $(TOPOBJDIR)/programs/winetest && $(MAKE) winetest
281 $(TESTMAIN):
282         cd $(TOPOBJDIR)/programs/winetest && $(MAKE) wtmain.o
284 $(TESTLIST): Makefile.in
285         $(TOPSRCDIR)/programs/winetest/make_ctests $(CTESTS) >$(TESTLIST) || $(RM) $(TESTLIST)
287 $(TESTPROGRAM): $(TESTPROGRAM).so
288         $(RM) $(TESTPROGRAM) && cd tests && $(LN_S) $(TOPOBJDIR)/../wine `basename $(TESTPROGRAM)`
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).exe: $(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