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 # EXTRA_SRCS : extra source files for make depend
17 # EXTRA_OBJS : extra object files
18 # IMPORTS : dlls to import
19 # DELAYIMPORTS : dlls to import in delayed mode
20 # SUBDIRS : subdirectories that contain a Makefile
21 # EXTRASUBDIRS : subdirectories that do not contain a Makefile
22 # INSTALLSUBDIRS : subdirectories to run make install/uninstall into
23 # PLTESTS : Perl test scripts
24 # CTESTS : C test sources
26 # First some useful definitions
31 CFLAGS = @CFLAGS@ $(EXTRACFLAGS)
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 RUNTEST = $(TOPSRCDIR)/programs/winetest/runtest
85 RUNTESTFLAGS = -q -P wine -M $(MODULE) -T $(TOPOBJDIR)
86 TESTRESULTS = $(PLTESTS:.pl=.ok) $(CTESTS:.c=.ok)
87 TESTPROGRAM = tests/$(MODULE:%.dll=%)_test.exe
88 TESTLIST = tests/testlist.c
89 TESTOBJS = $(TESTMAIN) $(TESTLIST:.c=.o) $(CTESTS:.c=.o)
90 TESTMAIN = $(TOPOBJDIR)/programs/winetest/wtmain.o
96 INSTALL = @INSTALL@ $(INSTALL_FLAGS)
97 INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(INSTALL_PROGRAM_FLAGS)
98 INSTALL_SCRIPT = @INSTALL_SCRIPT@ $(INSTALL_SCRIPT_FLAGS)
99 INSTALL_DATA = @INSTALL_DATA@ $(INSTALL_DATA_FLAGS)
101 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) $(ASM_SRCS:.S=.o) $(EXTRA_OBJS)
117 RCOBJS = $(RC_SRCS:.rc=.res.o)
118 LINTS = $(C_SRCS:.c=.ln)
122 .SUFFIXES: .mc .rc .mc.rc .res .res.o .spec .spec.c .spec.def .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 $@ -M $(MODULE) -spec $<
146 $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -def $<
149 $(LINT) -c $(ALLLINTFLAGS) $< || ( $(RM) $@ && exit 1 )
152 $(RUNTEST) $(RUNTESTFLAGS) -p $(TESTPROGRAM)$(DLLEXT) $< && touch $@
155 $(RUNTEST) $(RUNTESTFLAGS) $(PLTESTPROGRAM:%=-p %) $< && touch $@
157 # 'all' target first in case the enclosing Makefile didn't define any target
162 @$(TOPSRCDIR)/tools/winapi/make_filter --make $(MAKE) all
166 # Rule for main module debug channels
168 $(MODULE).dbg.c: $(C_SRCS) $(WINEBUILD)
169 $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -debug -C$(SRCDIR) $(C_SRCS)
171 # Rule for 16-bit glue
173 $(MODULE).glue.c: $(C_SRCS) $(WINEBUILD)
174 $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -glue -C$(SRCDIR) $(C_SRCS)
176 # Rule to rebuild the tools
178 $(MAKEDEP) $(WINEBUILD) $(WMC) $(WRC):
179 cd $(TOOLSDIR)/tools && $(MAKE) `basename $@`
183 Makefile: Makefile.in $(TOPSRCDIR)/configure
184 @echo Makefile is older than $?, please rerun $(TOPSRCDIR)/configure
187 # Rules for auto documentation
189 $(SUBDIRS:%=%/__man__): dummy
190 cd `dirname $@` && $(MAKE) man
192 man: $(C_SRCS) $(SUBDIRS:%=%/__man__)
193 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
195 $(SUBDIRS:%=%/__doc_html__): dummy
196 cd `dirname $@` && $(MAKE) doc-html
198 doc-html: $(C_SRCS) $(SUBDIRS:%=%/__doc_html__)
199 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
201 .PHONY: man doc-html $(SUBDIRS:%=%/__man__) $(SUBDIRS:%=%/__doc_html__)
205 $(MODULE).ln : $(LINTS)
206 if test "$(LINTS)" ; \
208 $(LINT) $(ALLLINTFLAGS) -o$(MODULE) $(LINTS) ; \
209 $(MV) llib-l$(MODULE).ln $(MODULE).ln ; \
211 $(LINT) $(ALLLINTFLAGS) -C$(MODULE) /dev/null ; \
216 # Rules for Windows API checking
219 $(WINAPI_CHECK) $(WINAPI_CHECK_FLAGS) $(WINAPI_CHECK_EXTRA_FLAGS) .
223 # Rules for dependencies
225 $(SUBDIRS:%=%/__depend__): $(MAKEDEP) dummy
226 cd `dirname $@` && $(MAKE) depend
228 depend: $(MAKEDEP) $(SUBDIRS:%=%/__depend__)
229 $(MAKEDEP) $(DIVINCL) -C$(SRCDIR) $(C_SRCS) $(RC_SRCS) $(RC_SRCS16) $(MC_SRCS) $(EXTRA_SRCS) $(CTESTS)
231 .PHONY: depend $(SUBDIRS:%=%/__depend__)
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) $(TESTPROGRAM) $(PROGRAMS)
250 .PHONY: clean testclean $(SUBDIRS:%=%/__clean__) $(SUBDIRS:%=%/__testclean__) $(EXTRASUBDIRS:%=%/__clean__)
252 # Rules for installing
254 $(INSTALLSUBDIRS:%=%/__install__): dummy
255 cd `dirname $@` && $(MAKE) install
257 $(INSTALLSUBDIRS:%=%/__uninstall__): dummy
258 cd `dirname $@` && $(MAKE) uninstall
260 install:: $(INSTALLSUBDIRS:%=%/__install__)
262 uninstall:: $(INSTALLSUBDIRS:%=%/__uninstall__)
264 .PHONY: install uninstall $(INSTALLSUBDIRS:%=%/__install__) $(INSTALLSUBDIRS:%=%/__uninstall__)
268 check test:: $(TESTRESULTS)
270 $(SUBDIRS:%=%/__test__): dummy
271 @cd `dirname $@` && $(MAKE) test
273 .PHONY: check test $(SUBDIRS:%=%/__test__)
275 $(PLTESTS:.pl=.ok): $(PLTESTPROGRAM)
276 $(CTESTS:.c=.ok): $(TESTPROGRAM)$(DLLEXT)
279 cd $(TOPOBJDIR)/programs/winetest && $(MAKE) wtmain.o
281 $(TESTLIST): Makefile.in
282 $(TOPSRCDIR)/programs/winetest/make_ctests $(CTESTS) >$(TESTLIST) || $(RM) $(TESTLIST)
284 $(TESTPROGRAM).so: $(TESTPROGRAM).spec.o $(TESTOBJS)
285 $(LDSHARED) @LDDLLFLAGS@ $(TESTPROGRAM).spec.o $(TESTOBJS) -o $@ $(LIBWINE) $(LIBS)
287 $(TESTPROGRAM).spec.c: $(TESTOBJS) $(WINEBUILD)
288 $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -exe $(TESTPROGRAM) -mcui $(TESTOBJS) -L$(DLLDIR) $(TESTIMPORTS:%=-l%)
290 $(TESTPROGRAM): $(TESTOBJS)
291 $(CC) $(TESTOBJS) -o $@ $(TESTIMPORTS:%=-l%) $(LIBWINE) $(LIBS)
295 $(SPEC_SRCS:.spec=.spec.c): $(WINEBUILD)
297 $(RC_SRCS:.rc=.res): $(WRC)
299 $(RC_SRCS16:.rc=.res): $(WRC)
301 $(MC_SRCS:.mc=.mc.rc): $(WMC)
308 .PHONY: dummy $(SUBDIRS)
310 # End of global rules