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
24 # First some useful definitions
29 CFLAGS = @CFLAGS@ $(EXTRACFLAGS)
30 OPTIONS = @OPTIONS@ -D_REENTRANT
33 XLIB = @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@
45 DLLWRAPFLAGS = --add-stdcall-alias
53 DIVINCL = -I$(SRCDIR) -I. -I$(TOPSRCDIR)/include -I$(TOPOBJDIR)/include $(EXTRAINCL)
54 ALLCFLAGS = $(DIVINCL) $(CFLAGS) $(DEFS) $(OPTIONS) $(X_CFLAGS)
61 MANSPECS = -w $(TOPSRCDIR)/dlls/gdi/gdi32.spec \
62 -w $(TOPSRCDIR)/dlls/user/user32.spec \
63 -w $(TOPSRCDIR)/dlls/comctl32/comctl32.spec \
64 -w $(TOPSRCDIR)/dlls/commdlg/comdlg32.spec \
65 -w $(TOPSRCDIR)/dlls/kernel/kernel32.spec
67 LINTFLAGS = @LINTFLAGS@
68 ALLLINTFLAGS = $(LINTFLAGS) $(DEFS) $(OPTIONS) $(DIVINCL)
69 MKINSTALLDIRS= $(TOPSRCDIR)/tools/mkinstalldirs
70 WINAPI_CHECK = $(TOPSRCDIR)/tools/winapi_check/winapi_check
71 WINEWRAPPER = $(TOPSRCDIR)/tools/winewrapper
72 RUNTEST = $(TOPSRCDIR)/programs/winetest/runtest
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 LIBUNICODE= -L$(TOPOBJDIR)/unicode -lwine_unicode
81 LIBUUID = -L$(TOPOBJDIR)/ole -lwine_uuid
87 INSTALL = @INSTALL@ $(INSTALL_FLAGS)
88 INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(INSTALL_PROGRAM_FLAGS)
89 INSTALL_SCRIPT = @INSTALL_SCRIPT@ $(INSTALL_SCRIPT_FLAGS)
90 INSTALL_DATA = @INSTALL_DATA@ $(INSTALL_DATA_FLAGS)
92 exec_prefix = @exec_prefix@
98 sysconfdir = @sysconfdir@
99 includedir = @includedir@/wine
100 dlldir = @libdir@/wine
103 CLEAN_FILES = *.o *.a *.so *.ln *.$(LIBEXT) \\\#*\\\# *~ *% .\\\#* *.bak *.orig *.rej \
104 *.flc *.spec.c *.spec.def *.glue.c *.dbg.c y.tab.c y.tab.h @LEX_OUTPUT_ROOT@.c core
106 OBJS = $(C_SRCS:.c=.o) $(GEN_C_SRCS:.c=.o) $(GEN_ASM_SRCS:.s=.o) $(ASM_SRCS:.S=.o) $(EXTRA_OBJS)
108 RCOBJS = $(RC_SRCS:.rc=.res.o)
109 LINTS = $(C_SRCS:.c=.ln)
113 .SUFFIXES: .mc .rc .mc.rc .res .res.o .spec .spec.c .spec.def .pl .ok .cross.o
116 $(CC) -c $(ALLCFLAGS) -o $@ $<
119 $(CROSSCC) -c $(ALLCFLAGS) -o $@ $<
128 $(LDPATH) $(WMC) -i -H /dev/null -o $@ $<
131 $(LDPATH) $(WRC) $(WRCFLAGS) $(DIVINCL) -o $@ -r $<
134 $(WINDRES) -i $< -o $@
137 $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -M $(MODULE) -spec $<
140 $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -def $<
143 $(LINT) -c $(ALLLINTFLAGS) $< || ( $(RM) $@ && exit 1 )
146 $(RUNTEST) $(RUNTESTFLAGS) $< && touch $@
149 $(RUNTEST) $(RUNTESTFLAGS) $< && touch $@
151 # 'all' target first in case the enclosing Makefile didn't define any target
156 @$(TOPSRCDIR)/tools/winapi/make_filter --make $(MAKE) all
160 # Rule for main module debug channels
162 $(MODULE).dbg.c: $(C_SRCS) $(WINEBUILD)
163 $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -debug -C$(SRCDIR) $(C_SRCS)
165 # Rule for 16-bit glue
167 $(MODULE).glue.c: $(C_SRCS) $(WINEBUILD)
168 $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -glue -C$(SRCDIR) $(C_SRCS)
170 # Rule to rebuild the tools
172 $(MAKEDEP) $(WINEBUILD) $(WMC) $(WRC):
173 cd $(TOOLSDIR)/tools && $(MAKE) `basename $@`
177 Makefile: Makefile.in $(TOPSRCDIR)/configure
178 @echo Makefile is older than $?, please rerun $(TOPSRCDIR)/configure
181 # Rules for auto documentation
183 $(SUBDIRS:%=%/__man__): dummy
184 cd `dirname $@` && $(MAKE) man
186 man: $(C_SRCS) $(SUBDIRS:%=%/__man__)
187 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
189 $(SUBDIRS:%=%/__doc_html__): dummy
190 cd `dirname $@` && $(MAKE) doc-html
192 doc-html: $(C_SRCS) $(SUBDIRS:%=%/__doc_html__)
193 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
195 .PHONY: man doc-html $(SUBDIRS:%=%/__man__) $(SUBDIRS:%=%/__doc_html__)
199 $(MODULE).ln : $(LINTS)
200 if test "$(LINTS)" ; \
202 $(LINT) $(ALLLINTFLAGS) -o$(MODULE) $(LINTS) ; \
203 $(MV) llib-l$(MODULE).ln $(MODULE).ln ; \
205 $(LINT) $(ALLLINTFLAGS) -C$(MODULE) /dev/null ; \
210 # Rules for Windows API checking
213 $(WINAPI_CHECK) $(WINAPI_CHECK_FLAGS) $(WINAPI_CHECK_EXTRA_FLAGS) .
217 # Rules for dependencies
219 $(SUBDIRS:%=%/__depend__): $(MAKEDEP) dummy
220 cd `dirname $@` && $(MAKE) depend
222 depend: $(MAKEDEP) $(SUBDIRS:%=%/__depend__)
223 $(MAKEDEP) $(DIVINCL) -C$(SRCDIR) $(C_SRCS) $(RC_SRCS) $(RC_SRCS16) $(MC_SRCS) $(EXTRA_SRCS)
225 .PHONY: depend $(SUBDIRS:%=%/__depend__)
229 $(SUBDIRS:%=%/__clean__): dummy
230 cd `dirname $@` && $(MAKE) clean
232 $(SUBDIRS:%=%/__testclean__): dummy
233 cd `dirname $@` && $(MAKE) testclean
235 $(EXTRASUBDIRS:%=%/__clean__): dummy
236 -cd `dirname $@` && $(RM) $(CLEAN_FILES)
238 testclean:: $(SUBDIRS:%=%/__testclean__)
240 clean:: $(SUBDIRS:%=%/__clean__) $(EXTRASUBDIRS:%=%/__clean__)
241 $(RM) $(CLEAN_FILES) $(GEN_C_SRCS) $(GEN_ASM_SRCS) $(RC_SRCS:.rc=.res) $(RC_SRCS16:.rc=.res) $(MC_SRCS:.mc=.mc.rc) $(PROGRAMS)
243 .PHONY: clean testclean $(SUBDIRS:%=%/__clean__) $(SUBDIRS:%=%/__testclean__) $(EXTRASUBDIRS:%=%/__clean__)
245 # Rules for installing
247 $(INSTALLSUBDIRS:%=%/__install__): dummy
248 cd `dirname $@` && $(MAKE) install
250 $(INSTALLSUBDIRS:%=%/__uninstall__): dummy
251 cd `dirname $@` && $(MAKE) uninstall
253 install:: $(INSTALLSUBDIRS:%=%/__install__)
255 uninstall:: $(INSTALLSUBDIRS:%=%/__uninstall__)
257 .PHONY: install uninstall $(INSTALLSUBDIRS:%=%/__install__) $(INSTALLSUBDIRS:%=%/__uninstall__)
259 # Rules for checking that no imports are missing
261 $(SUBDIRS:%=%/__checklink__): dummy
262 @cd `dirname $@` && $(MAKE) checklink
264 .PHONY: checklink $(SUBDIRS:%=%/__checklink__)
268 $(SUBDIRS:%=%/__test__): dummy
269 @cd `dirname $@` && $(MAKE) test
271 $(SUBDIRS:%=%/__crosstest__): dummy
272 @cd `dirname $@` && $(MAKE) crosstest
274 .PHONY: check test crosstest $(SUBDIRS:%=%/__test__) $(SUBDIRS:%=%/__crosstest__)
278 $(SPEC_SRCS:.spec=.spec.c): $(WINEBUILD)
280 $(RC_SRCS:.rc=.res): $(WRC)
282 $(RC_SRCS16:.rc=.res): $(WRC)
284 $(MC_SRCS:.mc=.mc.rc): $(WMC)
291 .PHONY: dummy $(SUBDIRS)
293 # End of global rules