Make.rules.in 9.62 KB
Newer Older
Alexandre Julliard's avatar
Alexandre Julliard committed
1
# Global rules shared by all makefiles     -*-Makefile-*-
Alexandre Julliard's avatar
Alexandre Julliard committed
2
#
3
# Each individual makefile must define the following variables:
Alexandre Julliard's avatar
Alexandre Julliard committed
4 5 6 7
# TOPSRCDIR    : top-level source directory
# TOPOBJDIR    : top-level object directory
# SRCDIR       : source directory for this module
# MODULE       : name of the module being built
8 9 10 11 12 13
#
# Each individual makefile may define the following additional variables:
# C_SRCS       : C sources for the module
# RC_SRCS      : resource source files
# EXTRA_SRCS   : extra source files for make depend
# EXTRA_OBJS   : extra object files
14 15
# IMPORTS      : dlls to import
# DELAYIMPORTS : dlls to import in delayed mode
16 17
# SUBDIRS      : subdirectories that contain a Makefile
# EXTRASUBDIRS : subdirectories that do not contain a Makefile
18
# INSTALLSUBDIRS : subdirectories to run make install/uninstall into
19
# MODCFLAGS    : extra CFLAGS for this module
Alexandre Julliard's avatar
Alexandre Julliard committed
20

Alexandre Julliard's avatar
Alexandre Julliard committed
21 22
# First some useful definitions

Alexandre Julliard's avatar
Alexandre Julliard committed
23 24
SHELL     = /bin/sh
CC        = @CC@
25
CFLAGS    = @CFLAGS@
26
CPPFLAGS  = @CPPFLAGS@
Alexandre Julliard's avatar
Alexandre Julliard committed
27
LIBS      = @LIBS@
28
BISON     = @BISON@
29
FLEX      = @FLEX@
30 31
EXEEXT    = @EXEEXT@
OBJEXT    = @OBJEXT@
32
LIBEXT    = @LIBEXT@
33
DLLEXT    = @DLLEXT@
34
TOOLSEXT  = @TOOLSEXT@
35
IMPLIBEXT = @IMPLIBEXT@
36
LDSHARED  = @LDSHARED@
37
DLLTOOL   = @DLLTOOL@
38
DLLWRAP   = @DLLWRAP@
39 40
AR        = @AR@
ARFLAGS   = @ARFLAGS@
Alexandre Julliard's avatar
Alexandre Julliard committed
41
RANLIB    = @RANLIB@
42
STRIP     = @STRIP@
Alexandre Julliard's avatar
Alexandre Julliard committed
43
LN        = @LN@
Alexandre Julliard's avatar
Alexandre Julliard committed
44
LN_S      = @LN_S@
45
TOOLSDIR  = @TOOLSDIR@
46
LDFLAGS   = @LDFLAGS@
47
PRELINK   = @PRELINK@
Alexandre Julliard's avatar
Alexandre Julliard committed
48
RM        = rm -f
49 50 51
MV        = mv
LINT      = @LINT@
LINTFLAGS = @LINTFLAGS@
52
FONTFORGE = @FONTFORGE@
53 54
RSVG      = @RSVG@
ICOTOOL   = @ICOTOOL@
55
FAKEEXT   = $(DLLEXT:.so=.fake)
56 57
INCLUDES     = -I$(SRCDIR) -I. -I$(TOPSRCDIR)/include -I$(TOPOBJDIR)/include $(EXTRAINCL)
EXTRACFLAGS  = @EXTRACFLAGS@
58
ALLCFLAGS    = $(INCLUDES) $(DEFS) $(DLLFLAGS) $(EXTRACFLAGS) $(CPPFLAGS) $(CFLAGS) $(MODCFLAGS)
59
ALLLINTFLAGS = $(INCLUDES) $(DEFS) $(LINTFLAGS)
60
IDLFLAGS     = $(INCLUDES) $(DEFS) $(EXTRAIDLFLAGS)
61
TARGETFLAGS  = @TARGETFLAGS@
62
WINEBUILDFLAGS = $(TARGETFLAGS) $(DLLFLAGS)
63
MKINSTALLDIRS= $(TOPSRCDIR)/tools/mkinstalldirs -m 755
64
WINAPI_CHECK = $(TOPSRCDIR)/tools/winapi/winapi_check
65
WINEWRAPPER  = $(TOPSRCDIR)/tools/winewrapper
66
C2MAN        = $(TOPSRCDIR)/tools/c2man.pl
67
RUNTEST      = $(TOPSRCDIR)/tools/runtest
68 69 70 71 72 73
WINEBUILD    = $(TOOLSDIR)/tools/winebuild/winebuild$(TOOLSEXT)
MAKEDEP      = $(TOOLSDIR)/tools/makedep$(TOOLSEXT)
MAKECTESTS   = $(TOOLSDIR)/tools/make_ctests$(TOOLSEXT)
WRC          = $(TOOLSDIR)/tools/wrc/wrc$(TOOLSEXT)
WMC          = $(TOOLSDIR)/tools/wmc/wmc$(TOOLSEXT)
WIDL         = $(TOOLSDIR)/tools/widl/widl$(TOOLSEXT)
74
WINEGCC      = $(TOOLSDIR)/tools/winegcc/winegcc $(TARGETFLAGS) -B$(TOOLSDIR)/tools/winebuild --sysroot=$(TOPOBJDIR)
75 76
RELPATH      = $(TOOLSDIR)/tools/relpath$(TOOLSEXT)
SFNT2FNT     = $(TOOLSDIR)/tools/sfnt2fnt$(TOOLSEXT)
77
RC           = $(WRC)
78
RCFLAGS      = --nostdinc $(INCLUDES) $(DEFS) $(EXTRARCFLAGS)
79 80
LDPATH       = @LDPATH@
DLLDIR       = $(TOPOBJDIR)/dlls
81 82
LIBPORT      = $(TOPOBJDIR)/libs/port/libwine_port.a
LIBWPP       = $(TOPOBJDIR)/libs/wpp/libwpp.a
83
LIBWINE      = -L$(TOPOBJDIR)/libs/wine -lwine
84 85
LDRPATH_INSTALL = @LDRPATH_INSTALL@
LDRPATH_LOCAL   = @LDRPATH_LOCAL@
86

Alexandre Julliard's avatar
Alexandre Julliard committed
87 88
@SET_MAKE@

Alexandre Julliard's avatar
Alexandre Julliard committed
89 90
# Installation infos

91 92 93 94
INSTALL         = @INSTALL@ $(INSTALL_FLAGS)
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(INSTALL_PROGRAM_FLAGS)
INSTALL_SCRIPT  = @INSTALL_SCRIPT@ $(INSTALL_SCRIPT_FLAGS)
INSTALL_DATA    = @INSTALL_DATA@ $(INSTALL_DATA_FLAGS)
Alexandre Julliard's avatar
Alexandre Julliard committed
95 96 97 98
prefix          = @prefix@
exec_prefix     = @exec_prefix@
bindir          = @bindir@
libdir          = @libdir@
99
datarootdir     = @datarootdir@
100
datadir         = @datadir@
Alexandre Julliard's avatar
Alexandre Julliard committed
101
infodir         = @infodir@
102
mandir          = @mandir@
103 104
sysconfdir      = @sysconfdir@
includedir      = @includedir@/wine
105
dlldir          = @libdir@/wine
106
fakedlldir      = $(dlldir)/fakedlls
107
prog_manext     = 1
108
api_manext      = 3w
109
conf_manext     = 5
110
CLEAN_FILES     = *.o *.a *.so *.ln *.res *.fake *.$(LIBEXT) \\\#*\\\# *~ *% .\\\#* *.bak *.orig *.rej *.flc core
111

112 113 114 115
IDL_GEN_C_SRCS  = $(IDL_C_SRCS:.idl=_c.c) $(IDL_I_SRCS:.idl=_i.c) \
                  $(IDL_P_SRCS:.idl=_p.c) $(IDL_S_SRCS:.idl=_s.c)
IDL_GEN_HEADERS = $(IDL_H_SRCS:.idl=.h) $(IDL_C_SRCS:.idl=.h) $(IDL_I_SRCS:.idl=.h) \
                  $(IDL_P_SRCS:.idl=.h) $(IDL_S_SRCS:.idl=.h)
116

117
CLEAN_TARGETS = $(IDL_GEN_C_SRCS) $(IDL_GEN_HEADERS) $(IDL_TLB_SRCS:.idl=.tlb) $(IDL_P_SRCS:%=dlldata.c) \
118
                $(BISON_SRCS:.y=.tab.c) $(BISON_SRCS:.y=.tab.h) $(LEX_SRCS:.l=.yy.c) $(MC_SRCS:.mc=.mc.rc)
Alexandre Julliard's avatar
Alexandre Julliard committed
119

120 121
OBJS = $(C_SRCS:.c=.o) $(BISON_SRCS:.y=.tab.o) $(LEX_SRCS:.l=.yy.o) $(IDL_GEN_C_SRCS:.c=.o) \
       $(RC_SRCS:.rc=.res) $(MC_SRCS:.mc=.mc.res) $(EXTRA_OBJS)
Alexandre Julliard's avatar
Alexandre Julliard committed
122

123
LINTS  = $(C_SRCS:.c=.ln)
124

125 126 127 128 129 130 131 132 133
# 'all' target first in case the enclosing Makefile didn't define any target

all:

filter: dummy
	@$(TOPSRCDIR)/tools/winapi/make_filter --make $(MAKE) all

.PHONY: all filter

Alexandre Julliard's avatar
Alexandre Julliard committed
134 135
# Implicit rules

136
.SUFFIXES: .mc .rc .mc.rc .res .spec .spec.o .idl .tlb .h .y .l .tab.c .tab.h .yy.c .ok .man.in .man _c.c _i.c _p.c _s.c @MAINTAINER_MODE@ .sfd .ttf .svg .ico
Alexandre Julliard's avatar
Alexandre Julliard committed
137 138

.c.o:
139
	$(CC) -c $(ALLCFLAGS) -o $@ $<
Alexandre Julliard's avatar
Alexandre Julliard committed
140

141
.y.tab.c:
142
	$(BISON) $(BISONFLAGS) -p $*_ -o $@ $<
143 144

.y.tab.h:
145
	$(BISON) $(BISONFLAGS) -p $*_ -o $*.tab.c -d $<
146 147

.l.yy.c:
148
	$(FLEX) $(LEXFLAGS) -o$@ $<
149

150
.mc.mc.rc:
151
	$(LDPATH) $(WMC) -i -U -H /dev/null -o $@ $<
152

Alexandre Julliard's avatar
Alexandre Julliard committed
153
.rc.res:
154
	$(LDPATH) $(RC) $(RCFLAGS) -fo$@ $<
Alexandre Julliard's avatar
Alexandre Julliard committed
155

156 157
.spec.spec.o:
	$(WINEBUILD) $(WINEBUILDFLAGS) --dll -o $@ --main-module $(MODULE) --export $<
158

159
.idl.h:
160
	$(WIDL) $(IDLFLAGS) -h -H $@ $<
161

162 163 164 165 166 167 168 169 170 171 172 173
.idl_c.c:
	$(WIDL) $(IDLFLAGS) -c -C $@ $<

.idl_i.c:
	$(WIDL) $(IDLFLAGS) -u -U $@ $<

.idl_p.c:
	$(WIDL) $(IDLFLAGS) -p -P $@ $<

.idl_s.c:
	$(WIDL) $(IDLFLAGS) -s -S $@ $<

Huw Davies's avatar
Huw Davies committed
174
.idl.tlb:
175
	$(WIDL) $(TARGETFLAGS) $(IDLFLAGS) -t -T $@ $<
Huw Davies's avatar
Huw Davies committed
176

177 178 179
.c.ln:
	$(LINT) -c $(ALLLINTFLAGS) $< || ( $(RM) $@ && exit 1 )

180
.c.ok:
181
	$(RUNTEST) $(RUNTESTFLAGS) $< && touch $@
182

183
.sfd.ttf:
184
	$(FONTFORGE) -script $(TOPSRCDIR)/fonts/genttf.ff $< $@
185

186
.man.in.man:
187
	LC_ALL=C sed -e 's,@bindir\@,$(bindir),g' -e 's,@dlldir\@,$(dlldir),g' -e 's,@PACKAGE_STRING\@,@PACKAGE_STRING@,g' $< >$@ || ($(RM) $@ && false)
188

189 190 191 192 193 194 195
.svg.ico:
	$(RSVG) -w 16 -h 16 -f png $< $*-16.png
	$(RSVG) -w 32 -h 32 -f png $< $*-32.png
	$(RSVG) -w 48 -h 48 -f png $< $*-48.png
	$(ICOTOOL) -c -o $@ $*-16.png $*-32.png $*-48.png
	$(RM) $*-16.png $*-32.png $*-48.png

196 197 198 199 200
# Rules for IDL files

dlldata.c: $(WIDL) Makefile.in
	$(WIDL) $(IDLFLAGS) --dlldata-only --dlldata=$@ $(IDL_P_SRCS)

Alexandre Julliard's avatar
Alexandre Julliard committed
201 202
# Rule for linting

203 204 205 206 207 208 209 210 211 212
$(MODULE).ln : $(LINTS)
	if test "$(LINTS)" ; \
	then \
		$(LINT) $(ALLLINTFLAGS) -o$(MODULE) $(LINTS) ; \
	        $(MV) llib-l$(MODULE).ln $(MODULE).ln ; \
	else \
		$(LINT) $(ALLLINTFLAGS) -C$(MODULE) /dev/null ; \
	fi

lint:: $(MODULE).ln
Alexandre Julliard's avatar
Alexandre Julliard committed
213

214 215
# Rules for Windows API checking

216
winapi_check:: dummy
217 218
	$(WINAPI_CHECK) $(WINAPI_CHECK_FLAGS) $(WINAPI_CHECK_EXTRA_FLAGS) .

219 220
.PHONY: winapi_check

221 222
# Rules for dependencies

223
DEPEND_SRCS = $(C_SRCS) $(RC_SRCS) $(MC_SRCS) \
224 225 226
              $(IDL_H_SRCS) $(IDL_C_SRCS) $(IDL_I_SRCS) $(IDL_P_SRCS) $(IDL_S_SRCS) \
              $(IDL_GEN_C_SRCS) $(IDL_TLB_SRCS) $(IDL_TLB_SRCS:.idl=.tlb) \
              $(BISON_SRCS) $(LEX_SRCS) $(EXTRA_SRCS)
227

228
$(SUBDIRS:%=%/__depend__): dummy
229
	@cd `dirname $@` && $(MAKE) depend
230

231
depend: $(SUBDIRS:%=%/__depend__) dummy
232
	$(MAKEDEP) $(MAKEDEPFLAGS) -C$(SRCDIR) -S$(TOPSRCDIR) -T$(TOPOBJDIR) $(EXTRAINCL) $(DEPEND_SRCS)
233

234 235
.PHONY: depend $(SUBDIRS:%=%/__depend__)

236 237 238
# Rules for cleaning

$(SUBDIRS:%=%/__clean__): dummy
239
	@cd `dirname $@` && $(MAKE) clean
240 241 242 243 244

$(EXTRASUBDIRS:%=%/__clean__): dummy
	-cd `dirname $@` && $(RM) $(CLEAN_FILES)

clean:: $(SUBDIRS:%=%/__clean__) $(EXTRASUBDIRS:%=%/__clean__)
245
	$(RM) $(CLEAN_FILES) $(CLEAN_TARGETS) $(PROGRAMS) $(MANPAGES)
246

247
.PHONY: clean $(SUBDIRS:%=%/__clean__) $(EXTRASUBDIRS:%=%/__clean__)
248

249 250
# Rules for installing

251
$(SUBDIRS:%=%/__install__): dummy
252
	@cd `dirname $@` && $(MAKE) install
253

254
$(SUBDIRS:%=%/__install-lib__): dummy
255
	@cd `dirname $@` && $(MAKE) install-lib
256 257

$(SUBDIRS:%=%/__install-dev__): dummy
258
	@cd `dirname $@` && $(MAKE) install-dev
259 260

$(SUBDIRS:%=%/__uninstall__): dummy
261
	@cd `dirname $@` && $(MAKE) uninstall
262

263 264 265 266
install:: $(INSTALLSUBDIRS:%=%/__install__) dummy
install-lib:: $(INSTALLSUBDIRS:%=%/__install-lib__) dummy
install-dev:: $(INSTALLSUBDIRS:%=%/__install-dev__) dummy
uninstall:: $(INSTALLSUBDIRS:%=%/__uninstall__) dummy
267

268 269 270
$(INSTALLDIRS):
	$(MKINSTALLDIRS) $@

271
.PHONY: install install-lib install-dev uninstall \
272 273
	$(SUBDIRS:%=%/__install__) $(SUBDIRS:%=%/__uninstall__) \
	$(SUBDIRS:%=%/__install-lib__) $(SUBDIRS:%=%/__install-dev__)
274

275
# Rules for testing
276

277
$(TESTSUBDIRS:%=%/__test__): dummy
278 279
	@cd `dirname $@` && $(MAKE) test

280
$(TESTSUBDIRS:%=%/__crosstest__): dummy
281 282
	@cd `dirname $@` && $(MAKE) crosstest

283 284 285
$(TESTSUBDIRS:%=%/__testclean__): dummy
	@cd `dirname $@` && $(MAKE) testclean

286
check test:: $(TESTSUBDIRS:%=%/__test__) dummy
287

288
crosstest:: $(TESTSUBDIRS:%=%/__crosstest__) dummy
289

290
testclean:: $(TESTSUBDIRS:%=%/__testclean__) dummy
291 292 293 294 295 296 297 298 299 300 301 302 303 304

.PHONY: check test testclean crosstest $(TESTSUBDIRS:%=%/__test__) $(TESTSUBDIRS:%=%/__crosstest__) $(TESTSUBDIRS:%=%/__testclean__) 

# Rules for auto documentation

$(DOCSUBDIRS:%=%/__man__): dummy
	@cd `dirname $@` && $(MAKE) man

$(DOCSUBDIRS:%=%/__doc_html__): dummy
	@cd `dirname $@` && $(MAKE) doc-html

$(DOCSUBDIRS:%=%/__doc_sgml__): dummy
	@cd `dirname $@` && $(MAKE) doc-sgml

305 306 307
$(DOCSUBDIRS:%=%/__doc_xml__): dummy
	@cd `dirname $@` && $(MAKE) doc-xml

308 309 310
man: $(DOCSUBDIRS:%=%/__man__)
doc-html: $(DOCSUBDIRS:%=%/__doc_html__)
doc-sgml: $(DOCSUBDIRS:%=%/__doc_sgml__)
311
doc-xml: $(DOCSUBDIRS:%=%/__doc_xml__)
312

313
.PHONY: man doc-html doc-sgml doc-xml $(DOCSUBDIRS:%=%/__man__) $(DOCSUBDIRS:%=%/__doc_html__) $(DOCSUBDIRS:%=%/__doc_sgml__) $(DOCSUBDIRS:%=%/__doc_xml__)
314

Alexandre Julliard's avatar
Alexandre Julliard committed
315 316
# Misc. rules

317
$(MC_SRCS:.mc=.mc.rc): $(WMC)
318

319
$(IDL_GEN_HEADERS) $(IDL_GEN_C_SRCS) $(IDL_TLB_SRCS:.idl=.tlb): $(WIDL)
320

321
$(RC_SRCS:.rc=.res) $(MC_SRCS:.mc=.mc.res): $(WRC)
322

323 324
$(SUBDIRS): dummy
	@cd $@ && $(MAKE)
Alexandre Julliard's avatar
Alexandre Julliard committed
325 326

dummy:
Alexandre Julliard's avatar
Alexandre Julliard committed
327

328 329
.PHONY: dummy $(SUBDIRS)

Alexandre Julliard's avatar
Alexandre Julliard committed
330
# End of global rules