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 # C_SRCS16 : 16-bit C sources for the module
12 # RC_SRCS : resource source files
13 # EXTRA_SRCS : extra source files for make depend
14 # EXTRA_OBJS : extra object files
15 # IMPORTS : dlls to import
16 # DELAYIMPORTS : dlls to import in delayed mode
17 # SUBDIRS : subdirectories that contain a Makefile
18 # EXTRASUBDIRS : subdirectories that do not contain a Makefile
19 # INSTALLSUBDIRS : subdirectories to run make install/uninstall into
21 # First some useful definitions
36 IMPLIBEXT = @IMPLIBEXT@
54 LINTFLAGS = @LINTFLAGS@
55 LDDLLFLAGS = @LDDLLFLAGS@
56 LDDLL = $(CC) $(LDDLLFLAGS)
57 INCLUDES = -I$(SRCDIR) -I. -I$(TOPSRCDIR)/include -I$(TOPOBJDIR)/include $(EXTRAINCL)
58 EXTRACFLAGS = @EXTRACFLAGS@
59 ALLCFLAGS = $(INCLUDES) $(DEFS) $(DLLFLAGS) $(EXTRACFLAGS) $(CPPFLAGS) $(CFLAGS)
60 ALLLINTFLAGS = $(INCLUDES) $(DEFS) $(LINTFLAGS)
61 IDLFLAGS = $(INCLUDES) $(DEFS) $(EXTRAIDLFLAGS)
62 MKINSTALLDIRS= $(TOPSRCDIR)/tools/mkinstalldirs -m 755
63 WINAPI_CHECK = $(TOPSRCDIR)/tools/winapi_check/winapi_check
64 WINEWRAPPER = $(TOPSRCDIR)/tools/winewrapper
65 C2MAN = $(TOPSRCDIR)/tools/c2man.pl
66 RUNTEST = $(TOPSRCDIR)/tools/runtest
67 WINEBUILD = $(TOOLSDIR)/tools/winebuild/winebuild
68 MAKEDEP = $(TOOLSDIR)/tools/makedep
69 WRC = $(TOOLSDIR)/tools/wrc/wrc
70 BIN2RES = $(TOOLSDIR)/tools/bin2res
71 WMC = $(TOOLSDIR)/tools/wmc/wmc
72 WIDL = $(TOOLSDIR)/tools/widl/widl
73 WINEGCC = $(TOOLSDIR)/tools/winegcc/winegcc
76 RCFLAGS = --nostdinc $(INCLUDES) $(DEFS) $(EXTRARCFLAGS)
77 RC16FLAGS = -O res16 $(RCFLAGS)
79 DLLDIR = $(TOPOBJDIR)/dlls
80 LIBDIR = $(TOPOBJDIR)/libs
81 LIBPORT = -L$(TOPOBJDIR)/libs/port -lwine_port
82 LIBUNICODE = -L$(TOPOBJDIR)/libs/unicode -lwine_unicode
83 LIBWINE = -L$(TOPOBJDIR)/libs/wine -lwine
89 INSTALL = @INSTALL@ $(INSTALL_FLAGS)
90 INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(INSTALL_PROGRAM_FLAGS)
91 INSTALL_SCRIPT = @INSTALL_SCRIPT@ $(INSTALL_SCRIPT_FLAGS)
92 INSTALL_DATA = @INSTALL_DATA@ $(INSTALL_DATA_FLAGS)
94 exec_prefix = @exec_prefix@
100 sysconfdir = @sysconfdir@
101 includedir = @includedir@/wine
102 dlldir = @libdir@/wine
106 CLEAN_FILES = *.o *.a *.so *.ln *.$(LIBEXT) \\\#*\\\# *~ *% .\\\#* *.bak *.orig *.rej \
107 *.flc *.spec.c *.spec.def *.dbg.c *.tab.c *.tab.h @LEX_OUTPUT_ROOT@.c core
109 OBJS = $(C_SRCS:.c=.o) $(EXTRA_OBJS)
111 RCOBJS = $(RC_SRCS:.rc=.res.o)
112 LINTS = $(C_SRCS:.c=.ln)
116 .SUFFIXES: .mc .rc .mc.rc .res .res.o .spec .spec.c .spec.def .ok
119 $(CC) -c $(ALLCFLAGS) -o $@ $<
125 $(LDPATH) $(WMC) -i -U -H /dev/null -o $@ $<
128 $(LDPATH) $(RC) $(RCFLAGS) -fo$@ $<
131 $(WINDRES) -i $< -o $@
134 $(WINEBUILD) $(DEFS) -o $@ --main-module $(MODULE) --dll $<
137 $(WINEBUILD) $(DEFS) -o $@ --def $<
140 $(LINT) -c $(ALLLINTFLAGS) $< || ( $(RM) $@ && exit 1 )
143 $(RUNTEST) $(RUNTESTFLAGS) $< && touch $@
145 # 'all' target first in case the enclosing Makefile didn't define any target
150 @$(TOPSRCDIR)/tools/winapi/make_filter --make $(MAKE) all
154 # Rules for resources
156 $(RC_BINARIES): $(BIN2RES) $(RC_BINSRC)
157 $(BIN2RES) -f -o $@ $(SRCDIR)/$(RC_BINSRC)
159 $(RC_SRCS:.rc=.res) $(RC_SRCS16:.rc=.res): $(WRC) $(RC_BINARIES)
161 # Rule for main module debug channels
163 $(MODULE).dbg.c: $(C_SRCS) $(C_SRCS16) $(WINEBUILD)
164 $(WINEBUILD) $(DEFS) -o $@ --debug -C$(SRCDIR) $(C_SRCS) $(C_SRCS16)
166 # Rule to rebuild the tools
169 cd $(TOOLSDIR)/tools && $(MAKE) `basename $@`
173 Makefile: Makefile.in $(TOPSRCDIR)/configure
174 @echo Makefile is older than $?, please rerun $(TOPSRCDIR)/configure
179 $(MODULE).ln : $(LINTS)
180 if test "$(LINTS)" ; \
182 $(LINT) $(ALLLINTFLAGS) -o$(MODULE) $(LINTS) ; \
183 $(MV) llib-l$(MODULE).ln $(MODULE).ln ; \
185 $(LINT) $(ALLLINTFLAGS) -C$(MODULE) /dev/null ; \
190 # Rules for Windows API checking
193 $(WINAPI_CHECK) $(WINAPI_CHECK_FLAGS) $(WINAPI_CHECK_EXTRA_FLAGS) .
197 # Rules for dependencies
199 $(SUBDIRS:%=%/__depend__): $(MAKEDEP) dummy
200 cd `dirname $@` && $(MAKE) depend
202 depend: $(MAKEDEP) $(SUBDIRS:%=%/__depend__)
203 $(MAKEDEP) $(INCLUDES) -C$(SRCDIR) $(C_SRCS) $(C_SRCS16) $(RC_SRCS) $(RC_SRCS16) $(MC_SRCS) $(IDL_SRCS) $(EXTRA_SRCS)
205 .PHONY: depend $(SUBDIRS:%=%/__depend__)
209 $(SUBDIRS:%=%/__clean__): dummy
210 cd `dirname $@` && $(MAKE) clean
212 $(SUBDIRS:%=%/__testclean__): dummy
213 cd `dirname $@` && $(MAKE) testclean
215 $(EXTRASUBDIRS:%=%/__clean__): dummy
216 -cd `dirname $@` && $(RM) $(CLEAN_FILES)
218 testclean:: $(SUBDIRS:%=%/__testclean__)
220 clean:: $(SUBDIRS:%=%/__clean__) $(EXTRASUBDIRS:%=%/__clean__)
221 $(RM) $(CLEAN_FILES) $(RC_SRCS:.rc=.res) $(RC_SRCS16:.rc=.res) $(MC_SRCS:.mc=.mc.rc) $(PROGRAMS) $(RC_BINARIES)
223 .PHONY: clean testclean $(SUBDIRS:%=%/__clean__) $(SUBDIRS:%=%/__testclean__) $(EXTRASUBDIRS:%=%/__clean__)
225 # Rules for installing
227 $(SUBDIRS:%=%/__install__): dummy
228 cd `dirname $@` && $(MAKE) install
230 $(SUBDIRS:%=%/__install-lib__): dummy
231 cd `dirname $@` && $(MAKE) install-lib
233 $(SUBDIRS:%=%/__install-dev__): dummy
234 cd `dirname $@` && $(MAKE) install-dev
236 $(SUBDIRS:%=%/__uninstall__): dummy
237 cd `dirname $@` && $(MAKE) uninstall
239 install:: $(INSTALLSUBDIRS:%=%/__install__)
241 uninstall:: $(INSTALLSUBDIRS:%=%/__uninstall__)
243 .PHONY: install install-lib install-dev uninstall \
244 $(SUBDIRS:%=%/__install__) $(SUBDIRS:%=%/__uninstall__) \
245 $(SUBDIRS:%=%/__install-lib__) $(SUBDIRS:%=%/__install-dev__)
247 # Rules for checking that no imports are missing
249 $(SUBDIRS:%=%/__checklink__): dummy
250 @cd `dirname $@` && $(MAKE) checklink
252 .PHONY: checklink $(SUBDIRS:%=%/__checklink__)
256 $(SUBDIRS:%=%/__test__): dummy
257 @cd `dirname $@` && $(MAKE) test
259 $(SUBDIRS:%=%/__crosstest__): dummy
260 @cd `dirname $@` && $(MAKE) crosstest
262 .PHONY: check test crosstest $(SUBDIRS:%=%/__test__) $(SUBDIRS:%=%/__crosstest__)
266 $(MC_SRCS:.mc=.mc.rc): $(WMC)
268 $(IDL_SRCS:.idl=.h): $(WIDL)
275 .PHONY: dummy $(SUBDIRS)
277 # End of global rules