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 LINTS = $(C_SRCS:.c=.ln)
123 .SUFFIXES: .mc .rc .mc.rc .res .res.o .spec .spec.c .spec.def .glue.c .pl .ok
126 $(CC) -c $(ALLCFLAGS) -o $@ $<
135 $(LDPATH) $(WMC) -i -H /dev/null -o $@ $<
138 $(LDPATH) $(WRC) $(WRCFLAGS) $(DIVINCL) -o $@ -r $<
141 $(WINDRES) -i $< -o $@
144 $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -M $(MODULE) -spec $<
147 $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -def $<
150 $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -glue $<
153 $(LINT) -c $(ALLLINTFLAGS) $< || ( $(RM) $@ && exit 1 )
156 $(RUNTEST) $(RUNTESTFLAGS) -p $(TESTPROGRAM)$(DLLEXT) $< && touch $@
159 $(RUNTEST) $(RUNTESTFLAGS) $< && touch $@
161 # 'all' target first in case the enclosing Makefile didn't define any target
166 @$(TOPSRCDIR)/tools/winapi/make_filter --make $(MAKE) all
170 # Rule for main module intermediate object
172 $(MODULE).tmp.o: $(SPEC_SRCS:.spec=.spec.o) $(OBJS) Makefile.in
173 $(LDCOMBINE) $(SPEC_SRCS:.spec=.spec.o) $(OBJS) -o $@
174 -$(STRIP) --strip-unneeded $@
176 # Rule for main module debug channels
178 $(MODULE).dbg.c: $(C_SRCS) $(WINEBUILD)
179 $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -debug -C$(SRCDIR) $(C_SRCS)
181 # Rule to rebuild the resource compiler
184 cd $(TOOLSDIR)/tools/wrc && $(MAKE) wrc
186 # Rule to rebuild the message compiler
189 cd $(TOOLSDIR)/tools/wmc && $(MAKE) wmc
191 # Rule to rebuild the 'makedep' program
194 cd $(TOOLSDIR)/tools && $(MAKE) makedep
196 # Rule to rebuild the 'winebuild' program
199 cd $(TOOLSDIR)/tools/winebuild && $(MAKE) winebuild
203 Makefile: Makefile.in $(TOPSRCDIR)/configure
204 @echo Makefile is older than $?, please rerun $(TOPSRCDIR)/configure
207 # Rules for auto documentation
209 $(SUBDIRS:%=%/__man__): dummy
210 cd `dirname $@` && $(MAKE) man
212 man: $(C_SRCS) $(SUBDIRS:%=%/__man__)
213 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
215 $(SUBDIRS:%=%/__doc_html__): dummy
216 cd `dirname $@` && $(MAKE) doc-html
218 doc-html: $(C_SRCS) $(SUBDIRS:%=%/__doc_html__)
219 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
221 .PHONY: man doc-html $(SUBDIRS:%=%/__man__) $(SUBDIRS:%=%/__doc_html__)
225 $(MODULE).ln : $(LINTS)
226 if test "$(LINTS)" ; \
228 $(LINT) $(ALLLINTFLAGS) -o$(MODULE) $(LINTS) ; \
229 $(MV) llib-l$(MODULE).ln $(MODULE).ln ; \
231 $(LINT) $(ALLLINTFLAGS) -C$(MODULE) /dev/null ; \
236 # Rules for Windows API checking
239 $(WINAPI_CHECK) $(WINAPI_CHECK_FLAGS) $(WINAPI_CHECK_EXTRA_FLAGS) .
243 # Rules for dependencies
245 $(SUBDIRS:%=%/__depend__): $(MAKEDEP) dummy
246 cd `dirname $@` && $(MAKE) depend
248 depend: $(MAKEDEP) $(SUBDIRS:%=%/__depend__)
249 $(MAKEDEP) $(DIVINCL) -C$(SRCDIR) $(C_SRCS) $(RC_SRCS) $(RC_SRCS16) $(MC_SRCS) $(EXTRA_SRCS) $(CTESTS)
251 .PHONY: depend $(SUBDIRS:%=%/__depend__)
255 $(SUBDIRS:%=%/__clean__): dummy
256 cd `dirname $@` && $(MAKE) clean
258 $(SUBDIRS:%=%/__testclean__): dummy
259 cd `dirname $@` && $(MAKE) testclean
261 $(EXTRASUBDIRS:%=%/__clean__): dummy
262 -cd `dirname $@` && $(RM) $(CLEAN_FILES)
264 testclean:: $(SUBDIRS:%=%/__testclean__)
267 clean:: $(SUBDIRS:%=%/__clean__) $(EXTRASUBDIRS:%=%/__clean__)
268 $(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)
270 .PHONY: clean testclean $(SUBDIRS:%=%/__clean__) $(SUBDIRS:%=%/__testclean__) $(EXTRASUBDIRS:%=%/__clean__)
272 # Rules for installing
274 $(INSTALLSUBDIRS:%=%/__install__): dummy
275 cd `dirname $@` && $(MAKE) install
277 $(INSTALLSUBDIRS:%=%/__uninstall__): dummy
278 cd `dirname $@` && $(MAKE) uninstall
280 install:: $(INSTALLSUBDIRS:%=%/__install__)
282 uninstall:: $(INSTALLSUBDIRS:%=%/__uninstall__)
284 .PHONY: install uninstall $(INSTALLSUBDIRS:%=%/__install__) $(INSTALLSUBDIRS:%=%/__uninstall__)
288 check test:: $(TESTRESULTS)
290 $(SUBDIRS:%=%/__test__): dummy
291 @cd `dirname $@` && $(MAKE) test
293 .PHONY: check test $(SUBDIRS:%=%/__test__)
295 $(PLTESTS:.c=.ok): $(WINETEST)
296 $(CTESTS:.c=.ok): $(TESTPROGRAM)$(DLLEXT)
299 cd $(TOPOBJDIR)/programs/winetest && $(MAKE) winetest.exe$(DLLEXT)
302 cd $(TOPOBJDIR)/programs/winetest && $(MAKE) wtmain.o
304 $(TESTLIST): Makefile.in
305 $(TOPSRCDIR)/programs/winetest/make_ctests $(CTESTS) >$(TESTLIST) || $(RM) $(TESTLIST)
307 $(TESTPROGRAM).so: $(TESTPROGRAM).spec.o $(TESTOBJS)
308 $(LDSHARED) $(LDDLLFLAGS) $(TESTPROGRAM).spec.o $(TESTOBJS) -o $@ $(LIBWINE) $(LIBS)
310 $(TESTPROGRAM).tmp.o: $(TESTOBJS)
311 $(LDCOMBINE) $(TESTOBJS) -o $@
312 -$(STRIP) --strip-unneeded $@
314 $(TESTPROGRAM).spec.c: $(TESTPROGRAM).tmp.o $(WINEBUILD)
315 $(LDPATH) $(WINEBUILD) $(DEFS) -sym $(TESTPROGRAM).tmp.o -o $@ -exe $(TESTPROGRAM) -mcui -L$(DLLDIR) $(TESTIMPORTS:%=-l%)
317 $(TESTPROGRAM): $(TESTOBJS)
318 $(CC) $(TESTOBJS) -o $@ $(TESTIMPORTS:%=-l%) $(LIBWINE) $(LIBS)
322 $(SPEC_SRCS:.spec=.spec.c): $(WINEBUILD)
324 $(GLUE:.c=.glue.c): $(WINEBUILD)
326 $(RC_SRCS:.rc=.res): $(WRC)
328 $(RC_SRCS16:.rc=.res): $(WRC)
330 $(MC_SRCS:.mc=.mc.rc): $(WMC)
337 .PHONY: dummy $(SUBDIRS)
339 # End of global rules