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 # INSTALLSUBDIRS : subdirectories to run make install/uninstall into
24 # PLTESTS : Perl test scripts
25 # CTESTS : C test sources
27 # First some useful definitions
33 OPTIONS = @OPTIONS@ -D_REENTRANT
36 XLIB = @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@
47 DLLWRAPFLAGS = --add-stdcall-alias
55 DIVINCL = -I$(SRCDIR) -I. -I$(TOPSRCDIR)/include -I$(TOPOBJDIR)/include $(EXTRAINCL)
56 ALLCFLAGS = $(DIVINCL) $(CFLAGS) $(DEFS) $(OPTIONS) $(X_CFLAGS)
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
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
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
85 WINETEST = $(TOPOBJDIR)/programs/winetest/winetest.exe$(DLLEXT)
86 RUNTEST = $(TOPSRCDIR)/programs/winetest/runtest
87 RUNTESTFLAGS = -q -P wine -M $(MODULE) -T $(TOPOBJDIR)
88 TESTRESULTS = $(PLTESTS:.pl=.ok) $(CTESTS:.c=.ok)
89 TESTPROGRAM = tests/$(MODULE:%.dll=%)_test.exe
90 TESTLIST = tests/testlist.c
91 TESTOBJS = $(TESTMAIN) $(TESTLIST:.c=.o) $(CTESTS:.c=.o)
92 TESTMAIN = $(TOPOBJDIR)/programs/winetest/wtmain.o
98 INSTALL = @INSTALL@ $(INSTALL_FLAGS)
99 INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(INSTALL_PROGRAM_FLAGS)
100 INSTALL_SCRIPT = @INSTALL_SCRIPT@ $(INSTALL_SCRIPT_FLAGS)
101 INSTALL_DATA = @INSTALL_DATA@ $(INSTALL_DATA_FLAGS)
103 exec_prefix = @exec_prefix@
108 sysconfdir = @sysconfdir@
109 includedir = @includedir@/wine
110 dlldir = @libdir@/wine
113 CLEAN_FILES = *.o *.a *.so *.ln *.$(LIBEXT) \\\#*\\\# *~ *% .\\\#* *.bak *.orig *.rej \
114 *.flc *.spec.c *.spec.def *.glue.c *.dbg.c y.tab.c y.tab.h @LEX_OUTPUT_ROOT@.c core
116 OBJS = $(C_SRCS:.c=.o) $(GEN_C_SRCS:.c=.o) $(GEN_ASM_SRCS:.s=.o) \
117 $(ASM_SRCS:.S=.o) $(GLUE:.c=.glue.o) $(EXTRA_OBJS)
119 RCOBJS = $(RC_SRCS:.rc=.res.o)
120 LINTS = $(C_SRCS:.c=.ln)
124 .SUFFIXES: .mc .rc .mc.rc .res .res.o .spec .spec.c .spec.def .glue.c .pl .ok
127 $(CC) -c $(ALLCFLAGS) -o $@ $<
136 $(LDPATH) $(WMC) -i -H /dev/null -o $@ $<
139 $(LDPATH) $(WRC) $(WRCFLAGS) $(DIVINCL) -o $@ -r $<
142 $(WINDRES) -i $< -o $@
145 $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -M $(MODULE) -spec $<
148 $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -def $<
151 $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -glue $<
154 $(LINT) -c $(ALLLINTFLAGS) $< || ( $(RM) $@ && exit 1 )
157 $(RUNTEST) $(RUNTESTFLAGS) -p $(TESTPROGRAM)$(DLLEXT) $< && touch $@
160 $(RUNTEST) $(RUNTESTFLAGS) $< && touch $@
162 # 'all' target first in case the enclosing Makefile didn't define any target
167 @$(TOPSRCDIR)/tools/winapi/make_filter --make $(MAKE) all
171 # Rule for main module intermediate object
173 $(MODULE).tmp.o: $(SPEC_SRCS:.spec=.spec.o) $(OBJS) Makefile.in
174 $(LDCOMBINE) $(SPEC_SRCS:.spec=.spec.o) $(OBJS) -o $@
175 -$(STRIP) --strip-unneeded $@
177 # Rule for main module debug channels
179 $(MODULE).dbg.c: $(C_SRCS) $(WINEBUILD)
180 $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -debug -C$(SRCDIR) $(C_SRCS)
182 # Rule to rebuild the resource compiler
185 cd $(TOOLSDIR)/tools/wrc && $(MAKE) wrc
187 # Rule to rebuild the message compiler
190 cd $(TOOLSDIR)/tools/wmc && $(MAKE) wmc
192 # Rule to rebuild the 'makedep' program
195 cd $(TOOLSDIR)/tools && $(MAKE) makedep
197 # Rule to rebuild the 'winebuild' program
200 cd $(TOOLSDIR)/tools/winebuild && $(MAKE) winebuild
204 Makefile: Makefile.in $(TOPSRCDIR)/configure
205 @echo Makefile is older than $?, please rerun $(TOPSRCDIR)/configure
208 # Rules for auto documentation
210 $(SUBDIRS:%=%/__man__): dummy
211 cd `dirname $@` && $(MAKE) man
213 man: $(C_SRCS) $(SUBDIRS:%=%/__man__)
214 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
216 $(SUBDIRS:%=%/__doc_html__): dummy
217 cd `dirname $@` && $(MAKE) doc-html
219 doc-html: $(C_SRCS) $(SUBDIRS:%=%/__doc_html__)
220 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
222 .PHONY: man doc-html $(SUBDIRS:%=%/__man__) $(SUBDIRS:%=%/__doc_html__)
226 $(MODULE).ln : $(LINTS)
227 if test "$(LINTS)" ; \
229 $(LINT) $(ALLLINTFLAGS) -o$(MODULE) $(LINTS) ; \
230 $(MV) llib-l$(MODULE).ln $(MODULE).ln ; \
232 $(LINT) $(ALLLINTFLAGS) -C$(MODULE) /dev/null ; \
237 # Rules for Windows API checking
240 $(WINAPI_CHECK) $(WINAPI_CHECK_FLAGS) $(WINAPI_CHECK_EXTRA_FLAGS) .
244 # Rules for dependencies
246 $(SUBDIRS:%=%/__depend__): $(MAKEDEP) dummy
247 cd `dirname $@` && $(MAKE) depend
249 depend: $(MAKEDEP) $(SUBDIRS:%=%/__depend__)
250 $(MAKEDEP) $(DIVINCL) -C$(SRCDIR) $(C_SRCS) $(RC_SRCS) $(RC_SRCS16) $(MC_SRCS) $(EXTRA_SRCS) $(CTESTS)
252 .PHONY: depend $(SUBDIRS:%=%/__depend__)
256 $(SUBDIRS:%=%/__clean__): dummy
257 cd `dirname $@` && $(MAKE) clean
259 $(SUBDIRS:%=%/__testclean__): dummy
260 cd `dirname $@` && $(MAKE) testclean
262 $(EXTRASUBDIRS:%=%/__clean__): dummy
263 -cd `dirname $@` && $(RM) $(CLEAN_FILES)
265 testclean:: $(SUBDIRS:%=%/__testclean__)
268 clean:: $(SUBDIRS:%=%/__clean__) $(EXTRASUBDIRS:%=%/__clean__)
269 $(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)
271 .PHONY: clean testclean $(SUBDIRS:%=%/__clean__) $(SUBDIRS:%=%/__testclean__) $(EXTRASUBDIRS:%=%/__clean__)
273 # Rules for installing
275 $(INSTALLSUBDIRS:%=%/__install__): dummy
276 cd `dirname $@` && $(MAKE) install
278 $(INSTALLSUBDIRS:%=%/__uninstall__): dummy
279 cd `dirname $@` && $(MAKE) uninstall
281 install:: $(INSTALLSUBDIRS:%=%/__install__)
283 uninstall:: $(INSTALLSUBDIRS:%=%/__uninstall__)
285 .PHONY: install uninstall $(INSTALLSUBDIRS:%=%/__install__) $(INSTALLSUBDIRS:%=%/__uninstall__)
289 check test:: $(TESTRESULTS)
291 $(SUBDIRS:%=%/__test__): dummy
292 @cd `dirname $@` && $(MAKE) test
294 .PHONY: check test $(SUBDIRS:%=%/__test__)
296 $(PLTESTS:.c=.ok): $(WINETEST)
297 $(CTESTS:.c=.ok): $(TESTPROGRAM)$(DLLEXT)
300 cd $(TOPOBJDIR)/programs/winetest && $(MAKE) winetest.exe$(DLLEXT)
303 cd $(TOPOBJDIR)/programs/winetest && $(MAKE) wtmain.o
305 $(TESTLIST): Makefile.in
306 $(TOPSRCDIR)/programs/winetest/make_ctests $(CTESTS) >$(TESTLIST) || $(RM) $(TESTLIST)
308 $(TESTPROGRAM).so: $(TESTPROGRAM).spec.o $(TESTOBJS)
309 $(LDSHARED) @LDDLLFLAGS@ $(TESTPROGRAM).spec.o $(TESTOBJS) -o $@ $(LIBWINE) $(LIBS)
311 $(TESTPROGRAM).tmp.o: $(TESTOBJS)
312 $(LDCOMBINE) $(TESTOBJS) -o $@
313 -$(STRIP) --strip-unneeded $@
315 $(TESTPROGRAM).spec.c: $(TESTPROGRAM).tmp.o $(WINEBUILD)
316 $(LDPATH) $(WINEBUILD) $(DEFS) -sym $(TESTPROGRAM).tmp.o -o $@ -exe $(TESTPROGRAM) -mcui -L$(DLLDIR) $(TESTIMPORTS:%=-l%)
318 $(TESTPROGRAM): $(TESTOBJS)
319 $(CC) $(TESTOBJS) -o $@ $(TESTIMPORTS:%=-l%) $(LIBWINE) $(LIBS)
323 $(SPEC_SRCS:.spec=.spec.c): $(WINEBUILD)
325 $(GLUE:.c=.glue.c): $(WINEBUILD)
327 $(RC_SRCS:.rc=.res): $(WRC)
329 $(RC_SRCS16:.rc=.res): $(WRC)
331 $(MC_SRCS:.mc=.mc.rc): $(WMC)
338 .PHONY: dummy $(SUBDIRS)
340 # End of global rules