- Reduce the number of messages being passed to itself by using the
[wine] / Make.rules.in
1 # Global rules shared by all makefiles     -*-Makefile-*-
2 #
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
8 #
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
23
24 # First some useful definitions
25
26 SHELL     = /bin/sh
27 CC        = @CC@
28 CPP       = @CPP@
29 CFLAGS    = @CFLAGS@ $(EXTRACFLAGS)
30 OPTIONS   = @OPTIONS@ -D_REENTRANT
31 X_CFLAGS  = @X_CFLAGS@
32 X_LIBS    = @X_LIBS@
33 XLIB      = @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@
34 LIBS      = @LIBS@
35 YACC      = @YACC@
36 LEX       = @LEX@
37 LEXLIB    = @LEXLIB@
38 EXEEXT    = @EXEEXT@
39 OBJEXT    = @OBJEXT@
40 LIBEXT    = @LIBEXT@
41 DLLEXT    = @DLLEXT@
42 LDSHARED  = @LDSHARED@
43 DLLWRAP   = @DLLWRAP@
44 DLLWRAPFLAGS = --add-stdcall-alias
45 AR        = @AR@ rc
46 RANLIB    = @RANLIB@
47 STRIP     = @STRIP@
48 WINDRES   = @WINDRES@
49 LN        = @LN@
50 LN_S      = @LN_S@
51 TOOLSDIR  = @TOOLSDIR@
52 DIVINCL   = -I$(SRCDIR) -I. -I$(TOPSRCDIR)/include -I$(TOPOBJDIR)/include $(EXTRAINCL)
53 ALLCFLAGS = $(DIVINCL) $(CFLAGS) $(DEFS) $(OPTIONS) $(X_CFLAGS)
54 LD        = @LD@
55 LDFLAGS   = @LDFLAGS@
56 LDCOMBINE = $(LD) -r
57 RM        = rm -f
58 MV        = mv
59 C2MAN     = @C2MAN@
60 MANSPECS  = -w $(TOPSRCDIR)/dlls/gdi/gdi32.spec \
61             -w $(TOPSRCDIR)/dlls/user/user32.spec \
62             -w $(TOPSRCDIR)/dlls/comctl32/comctl32.spec \
63             -w $(TOPSRCDIR)/dlls/commdlg/comdlg32.spec \
64             -w $(TOPSRCDIR)/dlls/kernel/kernel32.spec
65 LINT      = @LINT@
66 LINTFLAGS = @LINTFLAGS@
67 ALLLINTFLAGS = $(LINTFLAGS) $(DEFS) $(OPTIONS) $(DIVINCL)
68 MKINSTALLDIRS= $(TOPSRCDIR)/tools/mkinstalldirs
69 WINAPI_CHECK = $(TOPSRCDIR)/tools/winapi_check/winapi_check
70 WINEWRAPPER  = $(TOPSRCDIR)/tools/winewrapper
71 RUNTEST      = $(TOPSRCDIR)/programs/winetest/runtest
72 WINEBUILD    = $(TOOLSDIR)/tools/winebuild/winebuild
73 MAKEDEP      = $(TOOLSDIR)/tools/makedep
74 WRC          = $(TOOLSDIR)/tools/wrc/wrc
75 WMC          = $(TOOLSDIR)/tools/wmc/wmc
76 LDPATH    = @LDPATH@
77 DLLDIR    = $(TOPOBJDIR)/dlls
78 LIBWINE   = -L$(TOPOBJDIR)/library -lwine
79 LIBTSX11  = -L$(TOPOBJDIR)/tsx11 -lwine_tsx11
80 LIBUNICODE= -L$(TOPOBJDIR)/unicode -lwine_unicode
81 LIBUUID   = -L$(TOPOBJDIR)/ole -lwine_uuid
82
83 @SET_MAKE@
84
85 # Installation infos
86
87 INSTALL         = @INSTALL@ $(INSTALL_FLAGS)
88 INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(INSTALL_PROGRAM_FLAGS)
89 INSTALL_SCRIPT  = @INSTALL_SCRIPT@ $(INSTALL_SCRIPT_FLAGS)
90 INSTALL_DATA    = @INSTALL_DATA@ $(INSTALL_DATA_FLAGS)
91 prefix          = @prefix@
92 exec_prefix     = @exec_prefix@
93 bindir          = @bindir@
94 libdir          = @libdir@
95 datadir         = @datadir@
96 infodir         = @infodir@
97 mandir          = @mandir@
98 sysconfdir      = @sysconfdir@
99 includedir      = @includedir@/wine
100 dlldir          = @libdir@/wine
101 prog_manext     = 1
102 conf_manext     = 5
103 CLEAN_FILES     = *.o *.a *.so *.ln *.$(LIBEXT) \\\#*\\\# *~ *% .\\\#* *.bak *.orig *.rej \
104                   *.flc *.spec.c *.spec.def *.glue.c *.dbg.c y.tab.c y.tab.h @LEX_OUTPUT_ROOT@.c core
105
106 OBJS = $(C_SRCS:.c=.o) $(GEN_C_SRCS:.c=.o) $(GEN_ASM_SRCS:.s=.o) $(ASM_SRCS:.S=.o) $(EXTRA_OBJS)
107
108 RCOBJS = $(RC_SRCS:.rc=.res.o)
109 LINTS  = $(C_SRCS:.c=.ln)
110
111 # Implicit rules
112
113 .SUFFIXES: .mc .rc .mc.rc .res .res.o .spec .spec.c .spec.def .pl .ok
114
115 .c.o:
116         $(CC) -c $(ALLCFLAGS) -o $@ $<
117
118 .s.o:
119         $(AS) -o $@ $<
120
121 .S.o:
122         $(CC) -c -o $@ $<
123
124 .mc.mc.rc:
125         $(LDPATH) $(WMC) -i -H /dev/null -o $@ $<
126
127 .rc.res:
128         $(LDPATH) $(WRC) $(WRCFLAGS) $(DIVINCL) -o $@ -r $<
129
130 .res.res.o:
131         $(WINDRES) -i $< -o $@
132
133 .spec.spec.c:
134         $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -M $(MODULE) -spec $<
135
136 .spec.spec.def:
137         $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -def $<
138
139 .c.ln:
140         $(LINT) -c $(ALLLINTFLAGS) $< || ( $(RM) $@ && exit 1 )
141
142 .c.ok:
143         $(RUNTEST) $(RUNTESTFLAGS) $< && touch $@
144
145 .pl.ok:
146         $(RUNTEST) $(RUNTESTFLAGS) $< && touch $@
147
148 # 'all' target first in case the enclosing Makefile didn't define any target
149
150 all: Makefile
151
152 filter:
153         @$(TOPSRCDIR)/tools/winapi/make_filter --make $(MAKE) all
154
155 .PHONY: all filter
156
157 # Rule for main module debug channels
158
159 $(MODULE).dbg.c: $(C_SRCS) $(WINEBUILD)
160         $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -debug -C$(SRCDIR) $(C_SRCS)
161
162 # Rule for 16-bit glue
163
164 $(MODULE).glue.c: $(C_SRCS) $(WINEBUILD)
165         $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -glue -C$(SRCDIR) $(C_SRCS)
166
167 # Rule to rebuild the tools
168
169 $(MAKEDEP) $(WINEBUILD) $(WMC) $(WRC):
170         cd $(TOOLSDIR)/tools && $(MAKE) `basename $@`
171
172 # Rules for makefile
173
174 Makefile: Makefile.in $(TOPSRCDIR)/configure
175         @echo Makefile is older than $?, please rerun $(TOPSRCDIR)/configure
176         @exit 1
177
178 # Rules for auto documentation
179
180 $(SUBDIRS:%=%/__man__): dummy
181         cd `dirname $@` && $(MAKE) man
182
183 man: $(C_SRCS) $(SUBDIRS:%=%/__man__)
184         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
185
186 $(SUBDIRS:%=%/__doc_html__): dummy
187         cd `dirname $@` && $(MAKE) doc-html
188
189 doc-html: $(C_SRCS) $(SUBDIRS:%=%/__doc_html__)
190         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
191
192 .PHONY: man doc-html $(SUBDIRS:%=%/__man__) $(SUBDIRS:%=%/__doc_html__)
193
194 # Rule for linting
195
196 $(MODULE).ln : $(LINTS)
197         if test "$(LINTS)" ; \
198         then \
199                 $(LINT) $(ALLLINTFLAGS) -o$(MODULE) $(LINTS) ; \
200                 $(MV) llib-l$(MODULE).ln $(MODULE).ln ; \
201         else \
202                 $(LINT) $(ALLLINTFLAGS) -C$(MODULE) /dev/null ; \
203         fi
204
205 lint:: $(MODULE).ln
206
207 # Rules for Windows API checking
208
209 winapi_check:: dummy
210         $(WINAPI_CHECK) $(WINAPI_CHECK_FLAGS) $(WINAPI_CHECK_EXTRA_FLAGS) .
211
212 .PHONY: winapi_check
213
214 # Rules for dependencies
215
216 $(SUBDIRS:%=%/__depend__): $(MAKEDEP) dummy
217         cd `dirname $@` && $(MAKE) depend
218
219 depend: $(MAKEDEP) $(SUBDIRS:%=%/__depend__)
220         $(MAKEDEP) $(DIVINCL) -C$(SRCDIR) $(C_SRCS) $(RC_SRCS) $(RC_SRCS16) $(MC_SRCS) $(EXTRA_SRCS)
221
222 .PHONY: depend $(SUBDIRS:%=%/__depend__)
223
224 # Rules for cleaning
225
226 $(SUBDIRS:%=%/__clean__): dummy
227         cd `dirname $@` && $(MAKE) clean
228
229 $(SUBDIRS:%=%/__testclean__): dummy
230         cd `dirname $@` && $(MAKE) testclean
231
232 $(EXTRASUBDIRS:%=%/__clean__): dummy
233         -cd `dirname $@` && $(RM) $(CLEAN_FILES)
234
235 testclean:: $(SUBDIRS:%=%/__testclean__)
236
237 clean:: $(SUBDIRS:%=%/__clean__) $(EXTRASUBDIRS:%=%/__clean__)
238         $(RM) $(CLEAN_FILES) $(GEN_C_SRCS) $(GEN_ASM_SRCS) $(RC_SRCS:.rc=.res) $(RC_SRCS16:.rc=.res) $(MC_SRCS:.mc=.mc.rc) $(PROGRAMS)
239
240 .PHONY: clean testclean $(SUBDIRS:%=%/__clean__) $(SUBDIRS:%=%/__testclean__) $(EXTRASUBDIRS:%=%/__clean__)
241
242 # Rules for installing
243
244 $(INSTALLSUBDIRS:%=%/__install__): dummy
245         cd `dirname $@` && $(MAKE) install
246
247 $(INSTALLSUBDIRS:%=%/__uninstall__): dummy
248         cd `dirname $@` && $(MAKE) uninstall
249
250 install:: $(INSTALLSUBDIRS:%=%/__install__)
251
252 uninstall:: $(INSTALLSUBDIRS:%=%/__uninstall__)
253
254 .PHONY: install uninstall $(INSTALLSUBDIRS:%=%/__install__) $(INSTALLSUBDIRS:%=%/__uninstall__)
255
256 # Rules for checking that no imports are missing
257
258 $(SUBDIRS:%=%/__checklink__): dummy
259         @cd `dirname $@` && $(MAKE) checklink
260
261 .PHONY: checklink $(SUBDIRS:%=%/__checklink__)
262
263 # Rules for testing
264
265 $(SUBDIRS:%=%/__test__): dummy
266         @cd `dirname $@` && $(MAKE) test
267
268 .PHONY: check test $(SUBDIRS:%=%/__test__)
269
270 # Misc. rules
271
272 $(SPEC_SRCS:.spec=.spec.c): $(WINEBUILD)
273
274 $(RC_SRCS:.rc=.res): $(WRC)
275
276 $(RC_SRCS16:.rc=.res): $(WRC)
277
278 $(MC_SRCS:.mc=.mc.rc): $(WMC)
279
280 $(SUBDIRS): dummy
281         @cd $@ && $(MAKE)
282
283 dummy:
284
285 .PHONY: dummy $(SUBDIRS)
286
287 # End of global rules