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 LIBTSX11 = -L$(TOPOBJDIR)/tsx11 -lwine_tsx11
81 LIBUNICODE= -L$(TOPOBJDIR)/unicode -lwine_unicode
82 LIBUUID = -L$(TOPOBJDIR)/ole -lwine_uuid
88 INSTALL = @INSTALL@ $(INSTALL_FLAGS)
89 INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(INSTALL_PROGRAM_FLAGS)
90 INSTALL_SCRIPT = @INSTALL_SCRIPT@ $(INSTALL_SCRIPT_FLAGS)
91 INSTALL_DATA = @INSTALL_DATA@ $(INSTALL_DATA_FLAGS)
93 exec_prefix = @exec_prefix@
99 sysconfdir = @sysconfdir@
100 includedir = @includedir@/wine
101 dlldir = @libdir@/wine
104 CLEAN_FILES = *.o *.a *.so *.ln *.$(LIBEXT) \\\#*\\\# *~ *% .\\\#* *.bak *.orig *.rej \
105 *.flc *.spec.c *.spec.def *.glue.c *.dbg.c y.tab.c y.tab.h @LEX_OUTPUT_ROOT@.c core
107 OBJS = $(C_SRCS:.c=.o) $(GEN_C_SRCS:.c=.o) $(GEN_ASM_SRCS:.s=.o) $(ASM_SRCS:.S=.o) $(EXTRA_OBJS)
109 RCOBJS = $(RC_SRCS:.rc=.res.o)
110 LINTS = $(C_SRCS:.c=.ln)
114 .SUFFIXES: .mc .rc .mc.rc .res .res.o .spec .spec.c .spec.def .pl .ok .cross.o
117 $(CC) -c $(ALLCFLAGS) -o $@ $<
120 $(CROSSCC) -c $(ALLCFLAGS) -o $@ $<
129 $(LDPATH) $(WMC) -i -H /dev/null -o $@ $<
132 $(LDPATH) $(WRC) $(WRCFLAGS) $(DIVINCL) -o $@ -r $<
135 $(WINDRES) -i $< -o $@
138 $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -M $(MODULE) -spec $<
141 $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -def $<
144 $(LINT) -c $(ALLLINTFLAGS) $< || ( $(RM) $@ && exit 1 )
147 $(RUNTEST) $(RUNTESTFLAGS) $< && touch $@
150 $(RUNTEST) $(RUNTESTFLAGS) $< && touch $@
152 # 'all' target first in case the enclosing Makefile didn't define any target
157 @$(TOPSRCDIR)/tools/winapi/make_filter --make $(MAKE) all
161 # Rule for main module debug channels
163 $(MODULE).dbg.c: $(C_SRCS) $(WINEBUILD)
164 $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -debug -C$(SRCDIR) $(C_SRCS)
166 # Rule for 16-bit glue
168 $(MODULE).glue.c: $(C_SRCS) $(WINEBUILD)
169 $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -glue -C$(SRCDIR) $(C_SRCS)
171 # Rule to rebuild the tools
173 $(MAKEDEP) $(WINEBUILD) $(WMC) $(WRC):
174 cd $(TOOLSDIR)/tools && $(MAKE) `basename $@`
178 Makefile: Makefile.in $(TOPSRCDIR)/configure
179 @echo Makefile is older than $?, please rerun $(TOPSRCDIR)/configure
182 # Rules for auto documentation
184 $(SUBDIRS:%=%/__man__): dummy
185 cd `dirname $@` && $(MAKE) man
187 man: $(C_SRCS) $(SUBDIRS:%=%/__man__)
188 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
190 $(SUBDIRS:%=%/__doc_html__): dummy
191 cd `dirname $@` && $(MAKE) doc-html
193 doc-html: $(C_SRCS) $(SUBDIRS:%=%/__doc_html__)
194 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
196 .PHONY: man doc-html $(SUBDIRS:%=%/__man__) $(SUBDIRS:%=%/__doc_html__)
200 $(MODULE).ln : $(LINTS)
201 if test "$(LINTS)" ; \
203 $(LINT) $(ALLLINTFLAGS) -o$(MODULE) $(LINTS) ; \
204 $(MV) llib-l$(MODULE).ln $(MODULE).ln ; \
206 $(LINT) $(ALLLINTFLAGS) -C$(MODULE) /dev/null ; \
211 # Rules for Windows API checking
214 $(WINAPI_CHECK) $(WINAPI_CHECK_FLAGS) $(WINAPI_CHECK_EXTRA_FLAGS) .
218 # Rules for dependencies
220 $(SUBDIRS:%=%/__depend__): $(MAKEDEP) dummy
221 cd `dirname $@` && $(MAKE) depend
223 depend: $(MAKEDEP) $(SUBDIRS:%=%/__depend__)
224 $(MAKEDEP) $(DIVINCL) -C$(SRCDIR) $(C_SRCS) $(RC_SRCS) $(RC_SRCS16) $(MC_SRCS) $(EXTRA_SRCS)
226 .PHONY: depend $(SUBDIRS:%=%/__depend__)
230 $(SUBDIRS:%=%/__clean__): dummy
231 cd `dirname $@` && $(MAKE) clean
233 $(SUBDIRS:%=%/__testclean__): dummy
234 cd `dirname $@` && $(MAKE) testclean
236 $(EXTRASUBDIRS:%=%/__clean__): dummy
237 -cd `dirname $@` && $(RM) $(CLEAN_FILES)
239 testclean:: $(SUBDIRS:%=%/__testclean__)
241 clean:: $(SUBDIRS:%=%/__clean__) $(EXTRASUBDIRS:%=%/__clean__)
242 $(RM) $(CLEAN_FILES) $(GEN_C_SRCS) $(GEN_ASM_SRCS) $(RC_SRCS:.rc=.res) $(RC_SRCS16:.rc=.res) $(MC_SRCS:.mc=.mc.rc) $(PROGRAMS)
244 .PHONY: clean testclean $(SUBDIRS:%=%/__clean__) $(SUBDIRS:%=%/__testclean__) $(EXTRASUBDIRS:%=%/__clean__)
246 # Rules for installing
248 $(INSTALLSUBDIRS:%=%/__install__): dummy
249 cd `dirname $@` && $(MAKE) install
251 $(INSTALLSUBDIRS:%=%/__uninstall__): dummy
252 cd `dirname $@` && $(MAKE) uninstall
254 install:: $(INSTALLSUBDIRS:%=%/__install__)
256 uninstall:: $(INSTALLSUBDIRS:%=%/__uninstall__)
258 .PHONY: install uninstall $(INSTALLSUBDIRS:%=%/__install__) $(INSTALLSUBDIRS:%=%/__uninstall__)
260 # Rules for checking that no imports are missing
262 $(SUBDIRS:%=%/__checklink__): dummy
263 @cd `dirname $@` && $(MAKE) checklink
265 .PHONY: checklink $(SUBDIRS:%=%/__checklink__)
269 $(SUBDIRS:%=%/__test__): dummy
270 @cd `dirname $@` && $(MAKE) test
272 $(SUBDIRS:%=%/__crosstest__): dummy
273 @cd `dirname $@` && $(MAKE) crosstest
275 .PHONY: check test crosstest $(SUBDIRS:%=%/__test__) $(SUBDIRS:%=%/__crosstest__)
279 $(SPEC_SRCS:.spec=.spec.c): $(WINEBUILD)
281 $(RC_SRCS:.rc=.res): $(WRC)
283 $(RC_SRCS16:.rc=.res): $(WRC)
285 $(MC_SRCS:.mc=.mc.rc): $(WMC)
292 .PHONY: dummy $(SUBDIRS)
294 # End of global rules