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@
41 DLLWRAPFLAGS = --add-stdcall-alias
44 DIVINCL = -I$(SRCDIR) -I. -I$(TOPSRCDIR)/include -I$(TOPOBJDIR)/include $(EXTRAINCL)
45 ALLCFLAGS = $(DIVINCL) $(CFLAGS) $(DEFS) $(OPTIONS) $(X_CFLAGS)
46 LDCOMBINE = @LDCOMBINE@
53 MANSPECS = -w $(TOPSRCDIR)/dlls/gdi/gdi32.spec \
54 -w $(TOPSRCDIR)/dlls/user/user32.spec \
55 -w $(TOPSRCDIR)/dlls/comctl32/comctl32.spec \
56 -w $(TOPSRCDIR)/dlls/commdlg/comdlg32.spec \
57 -w $(TOPSRCDIR)/dlls/kernel/kernel32.spec
59 LINTFLAGS = @LINTFLAGS@
60 ALLLINTFLAGS = $(LINTFLAGS) $(DEFS) $(OPTIONS) $(DIVINCL)
61 WINAPI_CHECK = $(TOPSRCDIR)/tools/winapi_check/winapi_check
62 WINEBUILD = $(TOPOBJDIR)/tools/winebuild/winebuild
63 MAKEDEP = $(TOPOBJDIR)/tools/makedep
64 WRC = $(TOPOBJDIR)/tools/wrc/wrc
65 WMC = $(TOPOBJDIR)/tools/wmc/wmc
67 DLLDIR = $(TOPOBJDIR)/dlls
68 LIBWINE = -L$(TOPOBJDIR)/library -lwine
69 LIBTSX11 = -L$(TOPOBJDIR)/tsx11 -lwine_tsx11
70 LIBUNICODE= -L$(TOPOBJDIR)/unicode -lwine_unicode
71 LIBUUID = -L$(TOPOBJDIR)/ole -lwine_uuid
73 WINETEST = $(TOPOBJDIR)/programs/winetest/winetest
74 RUNTEST = $(TOPSRCDIR)/programs/winetest/runtest
75 RUNTESTFLAGS = -q -P wine -M $(MODULE) -T $(TOPOBJDIR)
76 TESTRESULTS = $(PLTESTS:.pl=.ok) $(CTESTS:.c=.ok)
77 TESTPROGRAM = tests/$(MODULE)_test
78 TESTLIST = tests/testlist.c
79 TESTOBJS = $(TESTMAIN) $(TESTLIST:.c=.o) $(CTESTS:.c=.o)
80 TESTMAIN = $(TOPOBJDIR)/programs/winetest/wtmain.o
87 INSTALL_PROGRAM = @INSTALL_PROGRAM@
88 INSTALL_SCRIPT = @INSTALL_SCRIPT@
89 INSTALL_DATA = @INSTALL_DATA@
91 exec_prefix = @exec_prefix@
98 includedir = @includedir@/wine
99 CLEAN_FILES = *.o *.a *.so *.ln \\\#*\\\# *~ *% .\\\#* *.bak *.orig *.rej \
100 *.flc *.spec.c *.spec.def *.glue.c y.tab.c y.tab.h @LEX_OUTPUT_ROOT@.c core
102 OBJS = $(SPEC_SRCS:.spec=.spec.o) $(C_SRCS:.c=.o) $(GEN_C_SRCS:.c=.o) $(GEN_ASM_SRCS:.s=.o) \
103 $(ASM_SRCS:.S=.o) $(GLUE:.c=.glue.o) $(EXTRA_OBJS)
105 LINTS = $(C_SRCS:.c=.ln)
109 .SUFFIXES: .mc .rc .mc.rc .res .spec .spec.c .spec.def .glue.c .pl .ok
112 $(CC) -c $(ALLCFLAGS) -o $@ $<
121 $(LDPATH) $(WMC) -i -H /dev/null -o $@ $<
124 $(LDPATH) $(WRC) $(WRCFLAGS) $(DIVINCL) -o $@ -r $<
127 $(LDPATH) $(WINEBUILD) @DLLFLAGS@ -L$(DLLDIR) -o $@ -spec $<
130 $(LDPATH) $(WINEBUILD) @DLLFLAGS@ -L$(DLLDIR) -o $@ -def $<
133 $(LDPATH) $(WINEBUILD) @DLLFLAGS@ -o $@ -glue $<
136 $(LINT) -c $(ALLLINTFLAGS) $< || ( $(RM) $@ && exit 1 )
139 $(RUNTEST) $(RUNTESTFLAGS) -p $(TESTPROGRAM) $< && touch $@
142 $(RUNTEST) $(RUNTESTFLAGS) $< && touch $@
144 .PHONY: all install uninstall clean distclean depend dummy check test testclean
146 # 'all' target first in case the enclosing Makefile didn't define any target
151 @$(TOPSRCDIR)/tools/winapi/make_filter --make $(MAKE) all
153 # Rule for main module intermediate object
155 $(MODULE).tmp.o: $(OBJS) Makefile.in
156 $(LDCOMBINE) $(OBJS) -o $@
157 -strip --strip-unneeded $@
159 # Rule for main module spec file
161 $(MODULE).spec.c: $(MODULE).spec $(RC_SRCS:.rc=.res) $(SYMBOLFILE) $(WINEBUILD)
162 $(LDPATH) $(WINEBUILD) @DLLFLAGS@ -L$(DLLDIR) $(SYMBOLFILE:%=-sym %) -o $@ -spec $(SRCDIR)/$(MODULE).spec
164 # Rule to rebuild the resource compiler
167 cd $(TOPOBJDIR)/tools/wrc && $(MAKE) wrc
169 # Rule to rebuild the message compiler
172 cd $(TOPOBJDIR)/tools/wmc && $(MAKE) wmc
174 # Rule to rebuild the 'makedep' program
177 cd $(TOPOBJDIR)/tools && $(MAKE) makedep
179 # Rule to rebuild the 'winebuild' program
182 cd $(TOPOBJDIR)/tools/winebuild && $(MAKE) winebuild
186 Makefile: Makefile.in $(TOPSRCDIR)/configure
187 @echo Makefile is older than $?, please rerun $(TOPSRCDIR)/configure
190 # Rules for auto documentation
192 $(SUBDIRS:%=%/__man__): dummy
193 cd `dirname $@` && $(MAKE) man
195 man: $(C_SRCS) $(SUBDIRS:%=%/__man__)
196 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
198 $(SUBDIRS:%=%/__doc_html__): dummy
199 cd `dirname $@` && $(MAKE) doc-html
201 doc-html: $(C_SRCS) $(SUBDIRS:%=%/__doc_html__)
202 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
206 $(MODULE).ln : $(LINTS)
207 if test "$(LINTS)" ; \
209 $(LINT) $(ALLLINTFLAGS) -o$(MODULE) $(LINTS) ; \
210 $(MV) llib-l$(MODULE).ln $(MODULE).ln ; \
212 $(LINT) $(ALLLINTFLAGS) -C$(MODULE) /dev/null ; \
217 # Rules for Windows API checking
220 $(WINAPI_CHECK) $(WINAPI_CHECK_FLAGS) $(WINAPI_CHECK_EXTRA_FLAGS) .
222 # Rules for dependencies
224 $(SUBDIRS:%=%/__depend__): $(MAKEDEP) dummy
225 cd `dirname $@` && $(MAKE) depend
227 depend: $(MAKEDEP) $(GEN_C_SRCS) $(SUBDIRS:%=%/__depend__)
228 $(MAKEDEP) $(DIVINCL) -C$(SRCDIR) $(C_SRCS) $(RC_SRCS) $(RC_SRCS16) $(MC_SRCS) $(EXTRA_SRCS) $(CTESTS) -C. $(GEN_C_SRCS)
232 $(SUBDIRS:%=%/__clean__): dummy
233 cd `dirname $@` && $(MAKE) clean
235 $(SUBDIRS:%=%/__testclean__): dummy
236 cd `dirname $@` && $(MAKE) testclean
238 $(EXTRASUBDIRS:%=%/__clean__): dummy
239 -cd `dirname $@` && $(RM) $(CLEAN_FILES)
241 testclean:: $(SUBDIRS:%=%/__testclean__)
244 clean:: $(SUBDIRS:%=%/__clean__) $(EXTRASUBDIRS:%=%/__clean__)
245 $(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)
247 # Rules for installing
249 $(SUBDIRS:%=%/__install__): dummy
250 cd `dirname $@` && $(MAKE) install
252 $(SUBDIRS:%=%/__uninstall__): dummy
253 cd `dirname $@` && $(MAKE) uninstall
257 check test:: $(TESTRESULTS)
259 $(PLTESTS:.c=.ok): $(WINETEST)
260 $(CTESTS:.c=.ok): $(TESTPROGRAM).so
263 cd $(TOPOBJDIR)/programs/winetest && $(MAKE) winetest
266 cd $(TOPOBJDIR)/programs/winetest && $(MAKE) wtmain.o
268 $(TESTLIST): Makefile.in
269 $(TOPSRCDIR)/programs/winetest/make_ctests $(CTESTS) >$(TESTLIST) || $(RM) $(TESTLIST)
271 $(TESTPROGRAM).so: $(TESTPROGRAM).spec.o $(TESTOBJS)
272 $(LDSHARED) $(LDDLLFLAGS) $(TESTPROGRAM).spec.o $(TESTOBJS) -o $@ $(LIBWINE) $(LIBS)
274 $(TESTPROGRAM).tmp.o: $(TESTOBJS)
275 $(LDCOMBINE) $(TESTOBJS) -o $@
276 -strip --strip-unneeded $@
278 $(TESTPROGRAM).spec.c: $(TESTPROGRAM).spec $(TESTPROGRAM).tmp.o $(WINEBUILD)
279 $(LDPATH) $(WINEBUILD) @DLLFLAGS@ -L$(DLLDIR) -sym $(TESTPROGRAM).tmp.o -o $@ -spec $(SRCDIR)/$(TESTPROGRAM).spec
283 $(SPEC_SRCS:.spec=.spec.c): $(WINEBUILD)
285 $(SPEC_SRCS:.spec=.spec.def): $(WINEBUILD)
287 $(GLUE:.c=.glue.c): $(WINEBUILD)
289 $(RC_SRCS:.rc=.res): $(WRC)
291 $(RC_SRCS16:.rc=.res): $(WRC)
293 $(MC_SRCS:.mc=.mc.rc): $(WMC)
300 # End of global rules