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@
53 LINTFLAGS = @LINTFLAGS@
54 INCLUDES = -I$(SRCDIR) -I. -I$(TOPSRCDIR)/include -I$(TOPOBJDIR)/include $(EXTRAINCL)
55 EXTRACFLAGS = @EXTRACFLAGS@
56 ALLCFLAGS = $(INCLUDES) $(DEFS) $(DLLFLAGS) $(EXTRACFLAGS) $(CPPFLAGS) $(CFLAGS)
57 ALLLINTFLAGS = $(INCLUDES) $(DEFS) $(LINTFLAGS)
58 IDLFLAGS = $(INCLUDES) $(DEFS) $(EXTRAIDLFLAGS)
59 MKINSTALLDIRS= $(TOPSRCDIR)/tools/mkinstalldirs -m 755
60 WINAPI_CHECK = $(TOPSRCDIR)/tools/winapi_check/winapi_check
61 WINEWRAPPER = $(TOPSRCDIR)/tools/winewrapper
62 C2MAN = $(TOPSRCDIR)/tools/c2man.pl
63 RUNTEST = $(TOPSRCDIR)/tools/runtest
64 WINEBUILD = $(TOOLSDIR)/tools/winebuild/winebuild
65 MAKEDEP = $(TOOLSDIR)/tools/makedep
66 WRC = $(TOOLSDIR)/tools/wrc/wrc
67 BIN2RES = $(TOOLSDIR)/tools/bin2res
68 WMC = $(TOOLSDIR)/tools/wmc/wmc
69 WIDL = $(TOOLSDIR)/tools/widl/widl
70 WINEGCC = $(TOOLSDIR)/tools/winegcc/winegcc
73 RCFLAGS = --nostdinc $(INCLUDES) $(DEFS) $(EXTRARCFLAGS)
74 RC16FLAGS = -O res16 $(RCFLAGS)
76 DLLDIR = $(TOPOBJDIR)/dlls
77 LIBDIR = $(TOPOBJDIR)/libs
78 LIBPORT = -L$(TOPOBJDIR)/libs/port -lwine_port
79 LIBUNICODE = -L$(TOPOBJDIR)/libs/unicode -lwine_unicode
80 LIBWINE = -L$(TOPOBJDIR)/libs/wine -lwine
86 INSTALL = @INSTALL@ $(INSTALL_FLAGS)
87 INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(INSTALL_PROGRAM_FLAGS)
88 INSTALL_SCRIPT = @INSTALL_SCRIPT@ $(INSTALL_SCRIPT_FLAGS)
89 INSTALL_DATA = @INSTALL_DATA@ $(INSTALL_DATA_FLAGS)
91 exec_prefix = @exec_prefix@
97 sysconfdir = @sysconfdir@
98 includedir = @includedir@/wine
99 dlldir = @libdir@/wine
103 CLEAN_FILES = *.o *.a *.so *.ln *.$(LIBEXT) \\\#*\\\# *~ *% .\\\#* *.bak *.orig *.rej \
104 *.flc *.spec.c *.spec.def *.dbg.c *.tab.c *.tab.h @LEX_OUTPUT_ROOT@.c core
106 OBJS = $(C_SRCS:.c=.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 .ok
116 $(CC) -c $(ALLCFLAGS) -o $@ $<
122 $(LDPATH) $(WMC) -i -U -H /dev/null -o $@ $<
125 $(LDPATH) $(RC) $(RCFLAGS) -fo$@ $<
128 $(WINDRES) -i $< -o $@
131 $(WINEBUILD) $(DEFS) -o $@ --main-module $(MODULE) --dll $<
134 $(WINEBUILD) $(DEFS) -o $@ --def $<
137 $(LINT) -c $(ALLLINTFLAGS) $< || ( $(RM) $@ && exit 1 )
140 $(RUNTEST) $(RUNTESTFLAGS) $< && touch $@
142 # 'all' target first in case the enclosing Makefile didn't define any target
147 @$(TOPSRCDIR)/tools/winapi/make_filter --make $(MAKE) all
151 # Rules for resources
153 $(RC_BINARIES): $(BIN2RES) $(RC_BINSRC)
154 $(BIN2RES) -f -o $@ $(SRCDIR)/$(RC_BINSRC)
156 $(RC_SRCS:.rc=.res) $(RC_SRCS16:.rc=.res): $(WRC) $(RC_BINARIES)
158 # Rule for main module debug channels
160 $(MODULE).dbg.c: $(C_SRCS) $(C_SRCS16) $(WINEBUILD)
161 $(WINEBUILD) $(DEFS) -o $@ --debug -C$(SRCDIR) $(C_SRCS) $(C_SRCS16)
163 # Rule to rebuild the tools
166 cd $(TOOLSDIR)/tools && $(MAKE) `basename $@`
170 Makefile: Makefile.in $(TOPSRCDIR)/configure
171 @echo Makefile is older than $?, please rerun $(TOPSRCDIR)/configure
176 $(MODULE).ln : $(LINTS)
177 if test "$(LINTS)" ; \
179 $(LINT) $(ALLLINTFLAGS) -o$(MODULE) $(LINTS) ; \
180 $(MV) llib-l$(MODULE).ln $(MODULE).ln ; \
182 $(LINT) $(ALLLINTFLAGS) -C$(MODULE) /dev/null ; \
187 # Rules for Windows API checking
190 $(WINAPI_CHECK) $(WINAPI_CHECK_FLAGS) $(WINAPI_CHECK_EXTRA_FLAGS) .
194 # Rules for dependencies
196 $(SUBDIRS:%=%/__depend__): $(MAKEDEP) dummy
197 cd `dirname $@` && $(MAKE) depend
199 depend: $(MAKEDEP) $(SUBDIRS:%=%/__depend__)
200 $(MAKEDEP) $(INCLUDES) -C$(SRCDIR) $(C_SRCS) $(C_SRCS16) $(RC_SRCS) $(RC_SRCS16) $(MC_SRCS) $(IDL_SRCS) $(EXTRA_SRCS)
202 .PHONY: depend $(SUBDIRS:%=%/__depend__)
206 $(SUBDIRS:%=%/__clean__): dummy
207 cd `dirname $@` && $(MAKE) clean
209 $(SUBDIRS:%=%/__testclean__): dummy
210 cd `dirname $@` && $(MAKE) testclean
212 $(EXTRASUBDIRS:%=%/__clean__): dummy
213 -cd `dirname $@` && $(RM) $(CLEAN_FILES)
215 testclean:: $(SUBDIRS:%=%/__testclean__)
217 clean:: $(SUBDIRS:%=%/__clean__) $(EXTRASUBDIRS:%=%/__clean__)
218 $(RM) $(CLEAN_FILES) $(RC_SRCS:.rc=.res) $(RC_SRCS16:.rc=.res) $(MC_SRCS:.mc=.mc.rc) $(PROGRAMS) $(RC_BINARIES)
220 .PHONY: clean testclean $(SUBDIRS:%=%/__clean__) $(SUBDIRS:%=%/__testclean__) $(EXTRASUBDIRS:%=%/__clean__)
222 # Rules for installing
224 $(SUBDIRS:%=%/__install__): dummy
225 cd `dirname $@` && $(MAKE) install
227 $(SUBDIRS:%=%/__install-lib__): dummy
228 cd `dirname $@` && $(MAKE) install-lib
230 $(SUBDIRS:%=%/__install-dev__): dummy
231 cd `dirname $@` && $(MAKE) install-dev
233 $(SUBDIRS:%=%/__uninstall__): dummy
234 cd `dirname $@` && $(MAKE) uninstall
236 install:: $(INSTALLSUBDIRS:%=%/__install__)
238 uninstall:: $(INSTALLSUBDIRS:%=%/__uninstall__)
240 .PHONY: install install-lib install-dev uninstall \
241 $(SUBDIRS:%=%/__install__) $(SUBDIRS:%=%/__uninstall__) \
242 $(SUBDIRS:%=%/__install-lib__) $(SUBDIRS:%=%/__install-dev__)
244 # Rules for checking that no imports are missing
246 $(SUBDIRS:%=%/__checklink__): dummy
247 @cd `dirname $@` && $(MAKE) checklink
249 .PHONY: checklink $(SUBDIRS:%=%/__checklink__)
253 $(SUBDIRS:%=%/__test__): dummy
254 @cd `dirname $@` && $(MAKE) test
256 $(SUBDIRS:%=%/__crosstest__): dummy
257 @cd `dirname $@` && $(MAKE) crosstest
259 .PHONY: check test crosstest $(SUBDIRS:%=%/__test__) $(SUBDIRS:%=%/__crosstest__)
263 $(MC_SRCS:.mc=.mc.rc): $(WMC)
265 $(IDL_SRCS:.idl=.h): $(WIDL)
272 .PHONY: dummy $(SUBDIRS)
274 # End of global rules