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 # SUBDIRS : subdirectories that contain a Makefile
20 # EXTRASUBDIRS : subdirectories that do not contain a Makefile
21 # PLTESTS : Perl test scripts
22 # CTESTS : C test sources
24 # First some useful definitions
30 OPTIONS = @OPTIONS@ -D_REENTRANT
33 XLIB = @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@
42 DLLWRAPFLAGS = --add-stdcall-alias
45 DIVINCL = -I$(SRCDIR) -I. -I$(TOPSRCDIR)/include -I$(TOPOBJDIR)/include $(EXTRAINCL)
46 ALLCFLAGS = $(DIVINCL) $(CFLAGS) $(DEFS) $(OPTIONS) $(X_CFLAGS)
47 LDCOMBINE = @LDCOMBINE@
54 MANSPECS = -w $(TOPSRCDIR)/dlls/gdi/gdi32.spec \
55 -w $(TOPSRCDIR)/dlls/user/user32.spec \
56 -w $(TOPSRCDIR)/dlls/comctl32/comctl32.spec \
57 -w $(TOPSRCDIR)/dlls/commdlg/comdlg32.spec \
58 -w $(TOPSRCDIR)/dlls/kernel/kernel32.spec
60 LINTFLAGS = @LINTFLAGS@
61 ALLLINTFLAGS = $(LINTFLAGS) $(DEFS) $(OPTIONS) $(DIVINCL)
62 WINAPI_CHECK = $(TOPSRCDIR)/tools/winapi_check/winapi_check
63 WINEBUILD = $(TOPOBJDIR)/tools/winebuild/winebuild
64 MAKEDEP = $(TOPOBJDIR)/tools/makedep
65 WRC = $(TOPOBJDIR)/tools/wrc/wrc
66 WMC = $(TOPOBJDIR)/tools/wmc/wmc
68 DLLDIR = $(TOPOBJDIR)/dlls
69 MAINSPEC = $(MODULE:%.dll=%).spec
70 LIBWINE = -L$(TOPOBJDIR)/library -lwine
71 LIBTSX11 = -L$(TOPOBJDIR)/tsx11 -lwine_tsx11
72 LIBUNICODE= -L$(TOPOBJDIR)/unicode -lwine_unicode
73 LIBUUID = -L$(TOPOBJDIR)/ole -lwine_uuid
75 WINETEST = $(TOPOBJDIR)/programs/winetest/winetest
76 RUNTEST = $(TOPSRCDIR)/programs/winetest/runtest
77 RUNTESTFLAGS = -q -P wine -M $(MODULE) -T $(TOPOBJDIR)
78 TESTRESULTS = $(PLTESTS:.pl=.ok) $(CTESTS:.c=.ok)
79 TESTPROGRAM = tests/$(MODULE:%.dll=%)_test
80 TESTLIST = tests/testlist.c
81 TESTOBJS = $(TESTMAIN) $(TESTLIST:.c=.o) $(CTESTS:.c=.o)
82 TESTMAIN = $(TOPOBJDIR)/programs/winetest/wtmain.o
89 INSTALL_PROGRAM = @INSTALL_PROGRAM@
90 INSTALL_SCRIPT = @INSTALL_SCRIPT@
91 INSTALL_DATA = @INSTALL_DATA@
93 exec_prefix = @exec_prefix@
98 dlldir = @libdir@/wine
101 includedir = @includedir@/wine
102 CLEAN_FILES = *.o *.a *.so *.ln \\\#*\\\# *~ *% .\\\#* *.bak *.orig *.rej \
103 *.flc *.spec.c *.spec.def *.glue.c y.tab.c y.tab.h @LEX_OUTPUT_ROOT@.c core
105 OBJS = $(SPEC_SRCS:.spec=.spec.o) $(C_SRCS:.c=.o) $(GEN_C_SRCS:.c=.o) $(GEN_ASM_SRCS:.s=.o) \
106 $(ASM_SRCS:.S=.o) $(GLUE:.c=.glue.o) $(EXTRA_OBJS)
108 LINTS = $(C_SRCS:.c=.ln)
112 .SUFFIXES: .mc .rc .mc.rc .res .spec .spec.c .spec.def .glue.c .pl .ok
115 $(CC) -c $(ALLCFLAGS) -o $@ $<
124 $(LDPATH) $(WMC) -i -H /dev/null -o $@ $<
127 $(LDPATH) $(WRC) $(WRCFLAGS) $(DIVINCL) -o $@ -r $<
130 $(LDPATH) $(WINEBUILD) @DLLFLAGS@ -L$(DLLDIR) -o $@ -spec $<
133 $(LDPATH) $(WINEBUILD) @DLLFLAGS@ -L$(DLLDIR) -o $@ -def $<
136 $(LDPATH) $(WINEBUILD) @DLLFLAGS@ -o $@ -glue $<
139 $(LINT) -c $(ALLLINTFLAGS) $< || ( $(RM) $@ && exit 1 )
142 $(RUNTEST) $(RUNTESTFLAGS) -p $(TESTPROGRAM) $< && touch $@
145 $(RUNTEST) $(RUNTESTFLAGS) $< && touch $@
147 .PHONY: all install uninstall clean distclean depend dummy check test testclean
149 # 'all' target first in case the enclosing Makefile didn't define any target
154 @$(TOPSRCDIR)/tools/winapi/make_filter --make $(MAKE) all
156 # Rule for main module intermediate object
158 $(MODULE).tmp.o: $(OBJS) Makefile.in
159 $(LDCOMBINE) $(OBJS) -o $@
160 -strip --strip-unneeded $@
162 # Rule for main module spec file
164 $(MAINSPEC).c: $(MAINSPEC) $(RC_SRCS:.rc=.res) $(SYMBOLFILE) $(WINEBUILD)
165 $(LDPATH) $(WINEBUILD) @DLLFLAGS@ -L$(DLLDIR) $(SYMBOLFILE:%=-sym %) -o $@ -spec $(SRCDIR)/$(MAINSPEC)
167 # Rule to rebuild the resource compiler
170 cd $(TOPOBJDIR)/tools/wrc && $(MAKE) wrc
172 # Rule to rebuild the message compiler
175 cd $(TOPOBJDIR)/tools/wmc && $(MAKE) wmc
177 # Rule to rebuild the 'makedep' program
180 cd $(TOPOBJDIR)/tools && $(MAKE) makedep
182 # Rule to rebuild the 'winebuild' program
185 cd $(TOPOBJDIR)/tools/winebuild && $(MAKE) winebuild
189 Makefile: Makefile.in $(TOPSRCDIR)/configure
190 @echo Makefile is older than $?, please rerun $(TOPSRCDIR)/configure
193 # Rules for auto documentation
195 $(SUBDIRS:%=%/__man__): dummy
196 cd `dirname $@` && $(MAKE) man
198 man: $(C_SRCS) $(SUBDIRS:%=%/__man__)
199 if [ -n "$(C_SRCS)" ]; then $(MKDIR) $(TOPOBJDIR)/documentation/man3w; for i in $(C_SRCS); do $(C2MAN) -L -o $(TOPOBJDIR)/documentation/man3w -S3w $(DIVINCL) -D__WINE__ $(MANSPECS) $$i; done; fi
201 $(SUBDIRS:%=%/__doc_html__): dummy
202 cd `dirname $@` && $(MAKE) doc-html
204 doc-html: $(C_SRCS) $(SUBDIRS:%=%/__doc_html__)
205 if [ -n "$(C_SRCS)" ]; then $(MKDIR) $(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
209 $(MODULE).ln : $(LINTS)
210 if test "$(LINTS)" ; \
212 $(LINT) $(ALLLINTFLAGS) -o$(MODULE) $(LINTS) ; \
213 $(MV) llib-l$(MODULE).ln $(MODULE).ln ; \
215 $(LINT) $(ALLLINTFLAGS) -C$(MODULE) /dev/null ; \
220 # Rules for Windows API checking
223 $(WINAPI_CHECK) $(WINAPI_CHECK_FLAGS) $(WINAPI_CHECK_EXTRA_FLAGS) .
225 # Rules for dependencies
227 $(SUBDIRS:%=%/__depend__): $(MAKEDEP) dummy
228 cd `dirname $@` && $(MAKE) depend
230 depend: $(MAKEDEP) $(GEN_C_SRCS) $(SUBDIRS:%=%/__depend__)
231 $(MAKEDEP) $(DIVINCL) -C$(SRCDIR) $(C_SRCS) $(RC_SRCS) $(RC_SRCS16) $(MC_SRCS) $(EXTRA_SRCS) $(CTESTS) -C. $(GEN_C_SRCS)
235 $(SUBDIRS:%=%/__clean__): dummy
236 cd `dirname $@` && $(MAKE) clean
238 $(SUBDIRS:%=%/__testclean__): dummy
239 cd `dirname $@` && $(MAKE) testclean
241 $(EXTRASUBDIRS:%=%/__clean__): dummy
242 -cd `dirname $@` && $(RM) $(CLEAN_FILES)
244 testclean:: $(SUBDIRS:%=%/__testclean__)
247 clean:: $(SUBDIRS:%=%/__clean__) $(EXTRASUBDIRS:%=%/__clean__)
248 $(RM) $(CLEAN_FILES) $(GEN_C_SRCS) $(GEN_ASM_SRCS) $(RC_SRCS:.rc=.res) $(RC_SRCS16:.rc=.res) $(MC_SRCS:.mc=.mc.rc) $(TESTRESULTS) $(TESTLIST) $(PROGRAMS)
250 # Rules for installing
252 $(SUBDIRS:%=%/__install__): dummy
253 cd `dirname $@` && $(MAKE) install
255 $(SUBDIRS:%=%/__uninstall__): dummy
256 cd `dirname $@` && $(MAKE) uninstall
260 check test:: $(TESTRESULTS)
262 $(SUBDIRS:%=%/__test__): dummy
263 @cd `dirname $@` && $(MAKE) test
265 $(PLTESTS:.c=.ok): $(WINETEST)
266 $(CTESTS:.c=.ok): $(TESTPROGRAM).so
269 cd $(TOPOBJDIR)/programs/winetest && $(MAKE) winetest
272 cd $(TOPOBJDIR)/programs/winetest && $(MAKE) wtmain.o
274 $(TESTLIST): Makefile.in
275 $(TOPSRCDIR)/programs/winetest/make_ctests $(CTESTS) >$(TESTLIST) || $(RM) $(TESTLIST)
277 $(TESTPROGRAM).so: $(TESTPROGRAM).spec.o $(TESTOBJS)
278 $(LDSHARED) $(LDDLLFLAGS) $(TESTPROGRAM).spec.o $(TESTOBJS) -o $@ $(LIBWINE) $(LIBS)
280 $(TESTPROGRAM).tmp.o: $(TESTOBJS)
281 $(LDCOMBINE) $(TESTOBJS) -o $@
282 -strip --strip-unneeded $@
284 $(TESTPROGRAM).spec.c: $(TESTPROGRAM).spec $(TESTPROGRAM).tmp.o $(WINEBUILD)
285 $(LDPATH) $(WINEBUILD) @DLLFLAGS@ -L$(DLLDIR) -sym $(TESTPROGRAM).tmp.o -o $@ -spec $(SRCDIR)/$(TESTPROGRAM).spec
289 $(SPEC_SRCS:.spec=.spec.c): $(WINEBUILD)
291 $(SPEC_SRCS:.spec=.spec.def): $(WINEBUILD)
293 $(GLUE:.c=.glue.c): $(WINEBUILD)
295 $(RC_SRCS:.rc=.res): $(WRC)
297 $(RC_SRCS16:.rc=.res): $(WRC)
299 $(MC_SRCS:.mc=.mc.rc): $(WMC)
306 # End of global rules