makefiles: Move all the recursion rules to the top-level makefile.
[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 # RC_SRCS      : resource source files
12 # EXTRA_SRCS   : extra source files for make depend
13 # EXTRA_OBJS   : extra object files
14 # IMPORTS      : dlls to import
15 # DELAYIMPORTS : dlls to import in delayed mode
16 # EXTRASUBDIRS : subdirectories that do not contain a Makefile
17 # MODCFLAGS    : extra CFLAGS for this module
18
19 # First some useful definitions
20
21 SHELL     = /bin/sh
22 CC        = @CC@
23 CFLAGS    = @CFLAGS@
24 CPPFLAGS  = @CPPFLAGS@
25 LIBS      = @LIBS@
26 BISON     = @BISON@
27 FLEX      = @FLEX@
28 EXEEXT    = @EXEEXT@
29 OBJEXT    = @OBJEXT@
30 LIBEXT    = @LIBEXT@
31 DLLEXT    = @DLLEXT@
32 TOOLSEXT  = @TOOLSEXT@
33 IMPLIBEXT = @IMPLIBEXT@
34 LDSHARED  = @LDSHARED@
35 DLLTOOL   = @DLLTOOL@
36 DLLWRAP   = @DLLWRAP@
37 AR        = @AR@
38 ARFLAGS   = @ARFLAGS@
39 RANLIB    = @RANLIB@
40 STRIP     = @STRIP@
41 LN_S      = @LN_S@
42 TOOLSDIR  = @TOOLSDIR@
43 LDFLAGS   = @LDFLAGS@
44 PRELINK   = @PRELINK@
45 RM        = rm -f
46 MV        = mv
47 LINT      = @LINT@
48 LINTFLAGS = @LINTFLAGS@
49 FONTFORGE = @FONTFORGE@
50 RSVG      = @RSVG@
51 ICOTOOL   = @ICOTOOL@
52 CROSSCC   = @CROSSCC@
53 CROSSTARGET = @CROSSTARGET@
54 CROSSAR     = $(CROSSTARGET)-ar
55 CROSSRANLIB = $(CROSSTARGET)-ranlib
56 FAKEEXT   = $(DLLEXT:.so=.fake)
57 INCLUDES     = -I$(SRCDIR) -I. -I$(TOPSRCDIR)/include -I$(TOPOBJDIR)/include $(EXTRAINCL)
58 EXTRACFLAGS  = @EXTRACFLAGS@
59 ALLCFLAGS    = $(INCLUDES) $(DEFS) $(DLLFLAGS) $(EXTRACFLAGS) $(CPPFLAGS) $(CFLAGS) $(MODCFLAGS)
60 ALLLINTFLAGS = $(INCLUDES) $(DEFS) $(LINTFLAGS)
61 IDLFLAGS     = $(INCLUDES) $(DEFS) $(EXTRAIDLFLAGS)
62 TARGETFLAGS  = @TARGETFLAGS@
63 WINEBUILDFLAGS = $(TARGETFLAGS) $(DLLFLAGS)
64 MKINSTALLDIRS= $(TOPSRCDIR)/tools/mkinstalldirs -m 755
65 WINAPI_CHECK = $(TOPSRCDIR)/tools/winapi/winapi_check
66 C2MAN        = $(TOPSRCDIR)/tools/c2man.pl
67 RUNTEST      = $(TOPSRCDIR)/tools/runtest
68 WINEBUILD    = $(TOOLSDIR)/tools/winebuild/winebuild$(TOOLSEXT)
69 MAKEDEP      = $(TOOLSDIR)/tools/makedep$(TOOLSEXT)
70 MAKECTESTS   = $(TOOLSDIR)/tools/make_ctests$(TOOLSEXT)
71 WRC          = $(TOOLSDIR)/tools/wrc/wrc$(TOOLSEXT)
72 WMC          = $(TOOLSDIR)/tools/wmc/wmc$(TOOLSEXT)
73 WIDL         = $(TOOLSDIR)/tools/widl/widl$(TOOLSEXT)
74 WINEGCC      = $(TOOLSDIR)/tools/winegcc/winegcc $(TARGETFLAGS) -B$(TOOLSDIR)/tools/winebuild --sysroot=$(TOPOBJDIR)
75 CROSSWINEGCC = $(TOOLSDIR)/tools/winegcc/winegcc $(CROSSTARGET:%=-b %) -B$(TOOLSDIR)/tools/winebuild --sysroot=$(TOPOBJDIR) --lib-suffix=.cross.a
76 RELPATH      = $(TOOLSDIR)/tools/relpath$(TOOLSEXT)
77 SFNT2FNT     = $(TOOLSDIR)/tools/sfnt2fnt$(TOOLSEXT)
78 RC           = $(WRC)
79 RCFLAGS      = --nostdinc $(INCLUDES) $(DEFS) $(EXTRARCFLAGS)
80 LDPATH       = @LDPATH@
81 DLLDIR       = $(TOPOBJDIR)/dlls
82 LIBPORT      = $(TOPOBJDIR)/libs/port/libwine_port.a
83 LIBWPP       = $(TOPOBJDIR)/libs/wpp/libwpp.a
84 LIBWINE      = -L$(TOPOBJDIR)/libs/wine -lwine
85 LDRPATH_INSTALL = @LDRPATH_INSTALL@
86 LDRPATH_LOCAL   = @LDRPATH_LOCAL@
87
88 @SET_MAKE@
89
90 # Installation infos
91
92 INSTALL         = @INSTALL@ $(INSTALL_FLAGS)
93 INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(INSTALL_PROGRAM_FLAGS)
94 INSTALL_SCRIPT  = @INSTALL_SCRIPT@ $(INSTALL_SCRIPT_FLAGS)
95 INSTALL_DATA    = @INSTALL_DATA@ $(INSTALL_DATA_FLAGS)
96 prefix          = @prefix@
97 exec_prefix     = @exec_prefix@
98 bindir          = @bindir@
99 libdir          = @libdir@
100 datarootdir     = @datarootdir@
101 datadir         = @datadir@
102 infodir         = @infodir@
103 mandir          = @mandir@
104 sysconfdir      = @sysconfdir@
105 includedir      = @includedir@/wine
106 dlldir          = @libdir@/wine
107 fakedlldir      = $(dlldir)/fakedlls
108 prog_manext     = 1
109 api_manext      = 3w
110 conf_manext     = 5
111 CLEAN_FILES     = *.o *.a *.so *.ln *.res *.fake *.$(LIBEXT) \\\#*\\\# *~ *% .\\\#* *.bak *.orig *.rej *.flc core
112
113 IDL_GEN_C_SRCS  = $(IDL_C_SRCS:.idl=_c.c) $(IDL_I_SRCS:.idl=_i.c) \
114                   $(IDL_P_SRCS:.idl=_p.c) $(IDL_S_SRCS:.idl=_s.c)
115 IDL_GEN_HEADERS = $(IDL_H_SRCS:.idl=.h) $(IDL_C_SRCS:.idl=.h) $(IDL_I_SRCS:.idl=.h) \
116                   $(IDL_P_SRCS:.idl=.h) $(IDL_S_SRCS:.idl=.h)
117
118 CLEAN_TARGETS = $(IDL_GEN_C_SRCS) $(IDL_GEN_HEADERS) $(IDL_TLB_SRCS:.idl=.tlb) $(IDL_P_SRCS:%=dlldata.c) \
119                 $(BISON_SRCS:.y=.tab.c) $(BISON_SRCS:.y=.tab.h) $(LEX_SRCS:.l=.yy.c) $(MC_SRCS:.mc=.mc.rc)
120
121 OBJS = $(C_SRCS:.c=.o) $(BISON_SRCS:.y=.tab.o) $(LEX_SRCS:.l=.yy.o) $(IDL_GEN_C_SRCS:.c=.o) \
122        $(RC_SRCS:.rc=.res) $(MC_SRCS:.mc=.mc.res) $(EXTRA_OBJS)
123
124 CROSSOBJS = $(OBJS:.o=.cross.o)
125 LINTS  = $(C_SRCS:.c=.ln)
126
127 # 'all' target first in case the enclosing Makefile didn't define any target
128
129 all:
130
131 filter: dummy
132         @$(TOPSRCDIR)/tools/winapi/make_filter --make $(MAKE) all
133
134 .PHONY: all filter
135
136 # Implicit rules
137
138 .SUFFIXES: .mc .rc .mc.rc .res .idl .tlb .h .y .l .tab.c .tab.h .yy.c .ok .man.in .man _c.c _i.c _p.c _s.c .cross.o @MAINTAINER_MODE@ .sfd .ttf .svg .ico
139
140 .c.o:
141         $(CC) -c $(ALLCFLAGS) -o $@ $<
142
143 .c.cross.o:
144         $(CROSSCC) -c $(INCLUDES) $(DEFS) $(CPPFLAGS) $(CFLAGS) -o $@ $<
145
146 .y.tab.c:
147         $(BISON) $(BISONFLAGS) -p $*_ -o $@ $<
148
149 .y.tab.h:
150         $(BISON) $(BISONFLAGS) -p $*_ -o $*.tab.c -d $<
151
152 .l.yy.c:
153         $(FLEX) $(LEXFLAGS) -o$@ $<
154
155 .mc.mc.rc:
156         $(LDPATH) $(WMC) -i -U -H /dev/null -o $@ $<
157
158 .rc.res:
159         $(LDPATH) $(RC) $(RCFLAGS) -fo$@ $<
160
161 .idl.h:
162         $(WIDL) $(IDLFLAGS) -h -H $@ $<
163
164 .idl_c.c:
165         $(WIDL) $(IDLFLAGS) -c -C $@ $<
166
167 .idl_i.c:
168         $(WIDL) $(IDLFLAGS) -u -U $@ $<
169
170 .idl_p.c:
171         $(WIDL) $(IDLFLAGS) -p -P $@ $<
172
173 .idl_s.c:
174         $(WIDL) $(IDLFLAGS) -s -S $@ $<
175
176 .idl.tlb:
177         $(WIDL) $(TARGETFLAGS) $(IDLFLAGS) -t -T $@ $<
178
179 .c.ln:
180         $(LINT) -c $(ALLLINTFLAGS) $< || ( $(RM) $@ && exit 1 )
181
182 .c.ok:
183         $(RUNTEST) $(RUNTESTFLAGS) $< && touch $@
184
185 .sfd.ttf:
186         $(FONTFORGE) -script $(TOPSRCDIR)/fonts/genttf.ff $< $@
187
188 .man.in.man:
189         LC_ALL=C sed -e 's,@bindir\@,$(bindir),g' -e 's,@dlldir\@,$(dlldir),g' -e 's,@PACKAGE_STRING\@,@PACKAGE_STRING@,g' $< >$@ || ($(RM) $@ && false)
190
191 .svg.ico:
192         $(RSVG) -w 16 -h 16 -f png $< $*-16.png
193         $(RSVG) -w 32 -h 32 -f png $< $*-32.png
194         $(RSVG) -w 48 -h 48 -f png $< $*-48.png
195         $(ICOTOOL) -c -o $@ $*-16.png $*-32.png $*-48.png
196         $(RM) $*-16.png $*-32.png $*-48.png
197
198 # Rules for IDL files
199
200 dlldata.c: $(WIDL) Makefile.in
201         $(WIDL) $(IDLFLAGS) --dlldata-only --dlldata=$@ $(IDL_P_SRCS)
202
203 # Rule for linting
204
205 $(MODULE).ln : $(LINTS)
206         if test "$(LINTS)" ; \
207         then \
208                 $(LINT) $(ALLLINTFLAGS) -o$(MODULE) $(LINTS) ; \
209                 $(MV) llib-l$(MODULE).ln $(MODULE).ln ; \
210         else \
211                 $(LINT) $(ALLLINTFLAGS) -C$(MODULE) /dev/null ; \
212         fi
213
214 lint:: $(MODULE).ln
215
216 # Rules for Windows API checking
217
218 winapi_check:: dummy
219         $(WINAPI_CHECK) $(WINAPI_CHECK_FLAGS) $(WINAPI_CHECK_EXTRA_FLAGS) .
220
221 .PHONY: winapi_check
222
223 # Rules for dependencies
224
225 DEPEND_SRCS = $(C_SRCS) $(RC_SRCS) $(MC_SRCS) \
226               $(IDL_H_SRCS) $(IDL_C_SRCS) $(IDL_I_SRCS) $(IDL_P_SRCS) $(IDL_S_SRCS) \
227               $(IDL_GEN_C_SRCS) $(IDL_TLB_SRCS) $(IDL_TLB_SRCS:.idl=.tlb) \
228               $(BISON_SRCS) $(LEX_SRCS) $(EXTRA_SRCS)
229
230 depend: dummy
231         $(MAKEDEP) $(MAKEDEPFLAGS) -C$(SRCDIR) -S$(TOPSRCDIR) -T$(TOPOBJDIR) $(EXTRAINCL) $(DEPEND_SRCS)
232
233 .PHONY: depend
234
235 # Rules for cleaning
236
237 $(EXTRASUBDIRS:%=%/__clean__): dummy
238         -cd `dirname $@` && $(RM) $(CLEAN_FILES)
239
240 clean:: $(EXTRASUBDIRS:%=%/__clean__)
241         $(RM) $(CLEAN_FILES) $(CLEAN_TARGETS) $(PROGRAMS) $(MANPAGES)
242
243 .PHONY: clean $(EXTRASUBDIRS:%=%/__clean__)
244
245 # Rules for installing
246
247 $(INSTALLDIRS):
248         $(MKINSTALLDIRS) $@
249
250 install install-lib install-dev uninstall::
251
252 .PHONY: install install-lib install-dev uninstall
253
254 # Misc. rules
255
256 $(MC_SRCS:.mc=.mc.rc): $(WMC)
257
258 $(IDL_GEN_HEADERS) $(IDL_GEN_C_SRCS) $(IDL_TLB_SRCS:.idl=.tlb): $(WIDL)
259
260 $(RC_SRCS:.rc=.res) $(MC_SRCS:.mc=.mc.res): $(WRC)
261
262 dummy:
263
264 .PHONY: dummy
265
266 # End of global rules