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
32 OPTIONS = @OPTIONS@ -D_REENTRANT
35 XLIB = @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@
46 DLLWRAPFLAGS = --add-stdcall-alias
54 DIVINCL = -I$(SRCDIR) -I. -I$(TOPSRCDIR)/include -I$(TOPOBJDIR)/include $(EXTRAINCL)
55 ALLCFLAGS = $(DIVINCL) $(CFLAGS) $(DEFS) $(OPTIONS) $(X_CFLAGS)
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
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
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
98 INSTALL_PROGRAM = @INSTALL_PROGRAM@
99 INSTALL_SCRIPT = @INSTALL_SCRIPT@
100 INSTALL_DATA = @INSTALL_DATA@
102 exec_prefix = @exec_prefix@
107 sysconfdir = @sysconfdir@
108 includedir = @includedir@/wine
109 dlldir = @libdir@/wine
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)
122 .SUFFIXES: .mc .rc .mc.rc .res .res.o .spec .spec.c .spec.def .glue.c .pl .ok
125 $(CC) -c $(ALLCFLAGS) -o $@ $<
134 $(LDPATH) $(WMC) -i -H /dev/null -o $@ $<
137 $(LDPATH) $(WRC) $(WRCFLAGS) $(DIVINCL) -o $@ -r $<
140 $(WINDRES) -i $< -o $@
143 $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -spec $<
146 $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -def $<
149 $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -glue $<
152 $(LINT) -c $(ALLLINTFLAGS) $< || ( $(RM) $@ && exit 1 )
155 $(RUNTEST) $(RUNTESTFLAGS) -p $(TESTPROGRAM)$(DLLEXT) $< && touch $@
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
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
183 cd $(TOOLSDIR)/tools/wrc && $(MAKE) wrc
185 # Rule to rebuild the message compiler
188 cd $(TOOLSDIR)/tools/wmc && $(MAKE) wmc
190 # Rule to rebuild the 'makedep' program
193 cd $(TOOLSDIR)/tools && $(MAKE) makedep
195 # Rule to rebuild the 'winebuild' program
198 cd $(TOOLSDIR)/tools/winebuild && $(MAKE) winebuild
202 Makefile: Makefile.in $(TOPSRCDIR)/configure
203 @echo Makefile is older than $?, please rerun $(TOPSRCDIR)/configure
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
222 $(MODULE).ln : $(LINTS)
223 if test "$(LINTS)" ; \
225 $(LINT) $(ALLLINTFLAGS) -o$(MODULE) $(LINTS) ; \
226 $(MV) llib-l$(MODULE).ln $(MODULE).ln ; \
228 $(LINT) $(ALLLINTFLAGS) -C$(MODULE) /dev/null ; \
233 # Rules for Windows API checking
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)
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__)
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
273 check test:: $(TESTRESULTS)
275 $(SUBDIRS:%=%/__test__): dummy
276 @cd `dirname $@` && $(MAKE) test
278 $(PLTESTS:.c=.ok): $(WINETEST)
279 $(CTESTS:.c=.ok): $(TESTPROGRAM)$(DLLEXT)
282 cd $(TOPOBJDIR)/programs/winetest && $(MAKE) winetest.exe$(DLLEXT)
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)
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)
320 # End of global rules