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 INCLUDES = -I$(SRCDIR) -I. -I$(TOPSRCDIR)/include -I$(TOPOBJDIR)/include $(EXTRAINCL)
56 EXTRACFLAGS = @EXTRACFLAGS@
57 ALLCFLAGS = $(INCLUDES) $(DEFS) $(EXTRACFLAGS) $(CPPFLAGS) $(CFLAGS)
58 ALLLINTFLAGS = $(INCLUDES) $(DEFS) $(LINTFLAGS)
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 WMC = $(TOOLSDIR)/tools/wmc/wmc
68 WIDL = $(TOOLSDIR)/tools/widl/widl
71 RCFLAGS = --nostdinc $(INCLUDES) $(EXTRARCFLAGS)
72 RC16FLAGS = -O res16 $(RCFLAGS)
74 DLLDIR = $(TOPOBJDIR)/dlls
75 LIBDIR = $(TOPOBJDIR)/libs
76 LIBPORT = -L$(TOPOBJDIR)/libs/port -lwine_port
77 LIBUNICODE = -L$(TOPOBJDIR)/libs/unicode -lwine_unicode
78 LIBUUID = -L$(TOPOBJDIR)/libs/uuid -lwine_uuid
79 LIBWINE = -L$(TOPOBJDIR)/libs/wine -lwine
85 INSTALL = @INSTALL@ $(INSTALL_FLAGS)
86 INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(INSTALL_PROGRAM_FLAGS)
87 INSTALL_SCRIPT = @INSTALL_SCRIPT@ $(INSTALL_SCRIPT_FLAGS)
88 INSTALL_DATA = @INSTALL_DATA@ $(INSTALL_DATA_FLAGS)
90 exec_prefix = @exec_prefix@
96 sysconfdir = @sysconfdir@
97 includedir = @includedir@/wine
98 dlldir = @libdir@/wine
102 CLEAN_FILES = *.o *.a *.so *.ln *.$(LIBEXT) \\\#*\\\# *~ *% .\\\#* *.bak *.orig *.rej \
103 *.flc *.spec.c *.spec.def *.dbg.c y.tab.c y.tab.h @LEX_OUTPUT_ROOT@.c core
105 OBJS = $(C_SRCS:.c=.o) $(EXTRA_OBJS)
107 RCOBJS = $(RC_SRCS:.rc=.res.o)
108 LINTS = $(C_SRCS:.c=.ln)
112 .SUFFIXES: .mc .rc .mc.rc .res .res.o .spec .spec.c .spec.def .ok
115 $(CC) -c $(ALLCFLAGS) -o $@ $<
121 $(LDPATH) $(WMC) -i -U -H /dev/null -o $@ $<
124 $(LDPATH) $(RC) $(RCFLAGS) -fo$@ $<
127 $(WINDRES) -i $< -o $@
130 $(WINEBUILD) $(DEFS) -o $@ --main-module $(MODULE) --spec $<
133 $(WINEBUILD) $(DEFS) -o $@ --def $<
136 $(LINT) -c $(ALLLINTFLAGS) $< || ( $(RM) $@ && exit 1 )
139 $(RUNTEST) $(RUNTESTFLAGS) $< && touch $@
141 # 'all' target first in case the enclosing Makefile didn't define any target
146 @$(TOPSRCDIR)/tools/winapi/make_filter --make $(MAKE) all
150 # Rule for main module debug channels
152 $(MODULE).dbg.c: $(C_SRCS) $(C_SRCS16) $(WINEBUILD)
153 $(WINEBUILD) $(DEFS) -o $@ --debug -C$(SRCDIR) $(C_SRCS) $(C_SRCS16)
155 # Rule to rebuild the tools
158 cd $(TOOLSDIR)/tools && $(MAKE) `basename $@`
162 Makefile: Makefile.in $(TOPSRCDIR)/configure
163 @echo Makefile is older than $?, please rerun $(TOPSRCDIR)/configure
168 $(MODULE).ln : $(LINTS)
169 if test "$(LINTS)" ; \
171 $(LINT) $(ALLLINTFLAGS) -o$(MODULE) $(LINTS) ; \
172 $(MV) llib-l$(MODULE).ln $(MODULE).ln ; \
174 $(LINT) $(ALLLINTFLAGS) -C$(MODULE) /dev/null ; \
179 # Rules for Windows API checking
182 $(WINAPI_CHECK) $(WINAPI_CHECK_FLAGS) $(WINAPI_CHECK_EXTRA_FLAGS) .
186 # Rules for dependencies
188 $(SUBDIRS:%=%/__depend__): $(MAKEDEP) dummy
189 cd `dirname $@` && $(MAKE) depend
191 depend: $(MAKEDEP) $(SUBDIRS:%=%/__depend__)
192 $(MAKEDEP) $(INCLUDES) -C$(SRCDIR) $(C_SRCS) $(C_SRCS16) $(RC_SRCS) $(RC_SRCS16) $(MC_SRCS) $(IDL_SRCS) $(EXTRA_SRCS)
194 .PHONY: depend $(SUBDIRS:%=%/__depend__)
198 $(SUBDIRS:%=%/__clean__): dummy
199 cd `dirname $@` && $(MAKE) clean
201 $(SUBDIRS:%=%/__testclean__): dummy
202 cd `dirname $@` && $(MAKE) testclean
204 $(EXTRASUBDIRS:%=%/__clean__): dummy
205 -cd `dirname $@` && $(RM) $(CLEAN_FILES)
207 testclean:: $(SUBDIRS:%=%/__testclean__)
209 clean:: $(SUBDIRS:%=%/__clean__) $(EXTRASUBDIRS:%=%/__clean__)
210 $(RM) $(CLEAN_FILES) $(RC_SRCS:.rc=.res) $(RC_SRCS16:.rc=.res) $(MC_SRCS:.mc=.mc.rc) $(PROGRAMS)
212 .PHONY: clean testclean $(SUBDIRS:%=%/__clean__) $(SUBDIRS:%=%/__testclean__) $(EXTRASUBDIRS:%=%/__clean__)
214 # Rules for installing
216 $(SUBDIRS:%=%/__install__): dummy
217 cd `dirname $@` && $(MAKE) install
219 $(SUBDIRS:%=%/__install-lib__): dummy
220 cd `dirname $@` && $(MAKE) install-lib
222 $(SUBDIRS:%=%/__install-dev__): dummy
223 cd `dirname $@` && $(MAKE) install-dev
225 $(SUBDIRS:%=%/__uninstall__): dummy
226 cd `dirname $@` && $(MAKE) uninstall
228 install:: $(INSTALLSUBDIRS:%=%/__install__)
230 uninstall:: $(INSTALLSUBDIRS:%=%/__uninstall__)
232 .PHONY: install install-lib install-dev uninstall \
233 $(SUBDIRS:%=%/__install__) $(SUBDIRS:%=%/__uninstall__) \
234 $(SUBDIRS:%=%/__install-lib__) $(SUBDIRS:%=%/__install-dev__)
236 # Rules for checking that no imports are missing
238 $(SUBDIRS:%=%/__checklink__): dummy
239 @cd `dirname $@` && $(MAKE) checklink
241 .PHONY: checklink $(SUBDIRS:%=%/__checklink__)
245 $(SUBDIRS:%=%/__test__): dummy
246 @cd `dirname $@` && $(MAKE) test
248 $(SUBDIRS:%=%/__crosstest__): dummy
249 @cd `dirname $@` && $(MAKE) crosstest
251 .PHONY: check test crosstest $(SUBDIRS:%=%/__test__) $(SUBDIRS:%=%/__crosstest__)
255 $(RC_SRCS:.rc=.res) $(RC_SRCS16:.rc=.res): $(WRC)
257 $(MC_SRCS:.mc=.mc.rc): $(WMC)
259 $(IDL_SRCS:.idl=.h): $(WIDL)
266 .PHONY: dummy $(SUBDIRS)
268 # End of global rules