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 # GLUE : C sources for which glue code needs to be generated
17 # EXTRA_SRCS : extra source files for make depend
18 # EXTRA_OBJS : extra object files
19 # SUBDIRS : subdirectories that contain a Makefile
20 # EXTRASUBDIRS : subdirectories that do not contain a Makefile
22 # First some useful definitions
28 OPTIONS = @OPTIONS@ -D_REENTRANT
31 XLIB = @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@
39 DLLWRAPFLAGS = --add-stdcall-alias
42 DIVINCL = -I$(SRCDIR) -I. -I$(TOPSRCDIR)/include -I$(TOPOBJDIR)/include $(EXTRAINCL)
43 ALLCFLAGS = $(DIVINCL) $(CFLAGS) $(DEFS) $(OPTIONS) $(X_CFLAGS)
44 LDCOMBINE = @LDCOMBINE@
51 MANSPECS = -w $(TOPSRCDIR)/dlls/gdi/gdi32.spec \
52 -w $(TOPSRCDIR)/dlls/user/user32.spec \
53 -w $(TOPSRCDIR)/dlls/comctl32/comctl32.spec \
54 -w $(TOPSRCDIR)/dlls/commdlg/comdlg32.spec \
55 -w $(TOPSRCDIR)/dlls/kernel/kernel32.spec
57 LINTFLAGS = @LINTFLAGS@
58 ALLLINTFLAGS = $(LINTFLAGS) $(DEFS) $(OPTIONS) $(DIVINCL)
59 WINAPI_CHECK = $(TOPSRCDIR)/tools/winapi_check/winapi_check
60 WINEBUILD = $(TOPOBJDIR)/tools/winebuild/winebuild
61 MAKEDEP = $(TOPOBJDIR)/tools/makedep
62 WRC = $(TOPOBJDIR)/tools/wrc/wrc
63 WMC = $(TOPOBJDIR)/tools/wmc/wmc
65 DLLDIR = $(TOPOBJDIR)/dlls
66 LIBWINE = -L$(TOPOBJDIR)/library -lwine
67 LIBTSX11 = -L$(TOPOBJDIR)/tsx11 -lwine_tsx11
68 LIBUNICODE= -L$(TOPOBJDIR)/unicode -lwine_unicode
69 LIBUUID = -L$(TOPOBJDIR)/ole -lwine_uuid
76 INSTALL_PROGRAM = @INSTALL_PROGRAM@
77 INSTALL_SCRIPT = @INSTALL_SCRIPT@
78 INSTALL_DATA = @INSTALL_DATA@
80 exec_prefix = @exec_prefix@
87 includedir = @includedir@/wine
88 CLEAN_FILES = *.o *.a *.so *.ln \\\#*\\\# *~ *% .\\\#* *.bak *.orig *.rej \
89 *.flc *.spec.c *.glue.c y.tab.c y.tab.h lex.yy.c core
91 OBJS = $(SPEC_SRCS:.spec=.spec.o) $(C_SRCS:.c=.o) $(GEN_C_SRCS:.c=.o) $(GEN_ASM_SRCS:.s=.o) \
92 $(ASM_SRCS:.S=.o) $(GLUE:.c=.glue.o) $(EXTRA_OBJS)
94 LINTS = $(C_SRCS:.c=.ln)
98 .SUFFIXES: .mc .rc .mc.rc .res .spec .spec.c .glue.c
101 $(CC) -c $(ALLCFLAGS) -o $*.o $<
110 $(LDPATH) $(WMC) -i -H /dev/null -o $@ $<
113 $(LDPATH) $(WRC) $(WRCFLAGS) $(DIVINCL) -o $@ -r $<
116 $(LDPATH) $(WINEBUILD) @DLLFLAGS@ -L$(DLLDIR) -o $@ -spec $<
119 $(LDPATH) $(WINEBUILD) @DLLFLAGS@ -o $@ -glue $<
122 $(LINT) -c $(ALLLINTFLAGS) $< || ( $(RM) $@ && exit 1 )
124 .PHONY: all install uninstall clean distclean depend dummy
126 # 'all' target first in case the enclosing Makefile didn't define any target
131 @$(TOPSRCDIR)/tools/winapi/make_filter --make $(MAKE) all
133 # Rule for main module intermediate object
135 $(MODULE).tmp.o: $(OBJS) Makefile.in
136 $(LDCOMBINE) $(OBJS) -o $@
137 -strip --strip-unneeded $@
139 # Rule for main module spec file
141 $(MODULE).spec.c: $(MODULE).spec $(RC_SRCS:.rc=.res) $(SYMBOLFILE) $(WINEBUILD)
142 $(LDPATH) $(WINEBUILD) @DLLFLAGS@ -L$(DLLDIR) $(SYMBOLFILE:%=-sym %) -o $@ -spec $(SRCDIR)/$(MODULE).spec
144 # Rule to rebuild the resource compiler
147 cd $(TOPOBJDIR)/tools/wrc && $(MAKE) wrc
149 # Rule to rebuild the message compiler
152 cd $(TOPOBJDIR)/tools/wmc && $(MAKE) wmc
154 # Rule to rebuild the 'makedep' program
157 cd $(TOPOBJDIR)/tools && $(MAKE) makedep
159 # Rule to rebuild the 'winebuild' program
162 cd $(TOPOBJDIR)/tools/winebuild && $(MAKE) winebuild
166 Makefile: Makefile.in $(TOPSRCDIR)/configure
167 @echo Makefile is older than $?, please rerun $(TOPSRCDIR)/configure
170 # Rules for auto documentation
172 $(SUBDIRS:%=%/__man__): dummy
173 cd `dirname $@` && $(MAKE) man
175 man: $(C_SRCS) $(SUBDIRS:%=%/__man__)
176 if [ -n "$(C_SRCS)" ]; then $(MKDIR) $(TOPOBJDIR)/documentation/man3w; for i in $(C_SRCS); do $(C2MAN) -L -o $(TOPOBJDIR)/documentation/man3w -S3w $(DIVINCL) -D__WINE__ $(MANSPECS) $$i; done; fi
178 $(SUBDIRS:%=%/__doc_html__): dummy
179 cd `dirname $@` && $(MAKE) doc-html
181 doc-html: $(C_SRCS) $(SUBDIRS:%=%/__doc_html__)
182 if [ -n "$(C_SRCS)" ]; then $(MKDIR) $(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
186 $(MODULE).ln : $(LINTS)
187 if test "$(LINTS)" ; \
189 $(LINT) $(ALLLINTFLAGS) -o$(MODULE) $(LINTS) ; \
190 $(MV) llib-l$(MODULE).ln $(MODULE).ln ; \
192 $(LINT) $(ALLLINTFLAGS) -C$(MODULE) /dev/null ; \
197 # Rules for Windows API checking
200 $(WINAPI_CHECK) $(WINAPI_CHECK_FLAGS) $(WINAPI_CHECK_EXTRA_FLAGS) .
202 # Rules for dependencies
204 $(SUBDIRS:%=%/__depend__): $(MAKEDEP) dummy
205 cd `dirname $@` && $(MAKE) depend
207 depend: $(MAKEDEP) $(GEN_C_SRCS) $(SUBDIRS:%=%/__depend__)
208 $(MAKEDEP) $(DIVINCL) -C$(SRCDIR) $(C_SRCS) $(RC_SRCS) $(RC_SRCS16) $(MC_SRCS) $(EXTRA_SRCS) -C. $(GEN_C_SRCS)
212 $(SUBDIRS:%=%/__clean__): dummy
213 cd `dirname $@` && $(MAKE) clean
215 $(EXTRASUBDIRS:%=%/__clean__): dummy
216 -cd `dirname $@` && $(RM) $(CLEAN_FILES)
218 clean:: $(SUBDIRS:%=%/__clean__) $(EXTRASUBDIRS:%=%/__clean__)
219 $(RM) $(CLEAN_FILES) $(GEN_C_SRCS) $(GEN_ASM_SRCS) $(RC_SRCS:.rc=.res) $(RC_SRCS16:.rc=.res) $(MC_SRCS:.mc=.mc.rc) $(PROGRAMS)
221 # Rules for installing
223 $(SUBDIRS:%=%/__install__): dummy
224 cd `dirname $@` && $(MAKE) install
226 $(SUBDIRS:%=%/__uninstall__): dummy
227 cd `dirname $@` && $(MAKE) uninstall
231 $(SPEC_SRCS:.spec=.spec.c): $(WINEBUILD) $(TOPSRCDIR)/include/builtin16.h
233 $(GLUE:.c=.glue.c): $(WINEBUILD) $(TOPSRCDIR)/include/builtin16.h
235 $(RC_SRCS:.rc=.res): $(WRC)
237 $(RC_SRCS16:.rc=.res): $(WRC)
239 $(MC_SRCS:.mc=.mc.rc): $(WMC)
246 # End of global rules