makefiles: Generate explicit build rules for bison files from makedep.
[wine.git] / Make.rules.in
bloba7da5ef4822d6cb68741a0aa918bb479c5d5f93c
1 # Global rules shared by all makefiles     -*-Makefile-*-
3 # Each individual makefile may define the following variables:
4 # C_SRCS       : C sources for the module
5 # OBJC_SRCS    : Objective-C sources for the module
6 # RC_SRCS      : resource source files
7 # EXTRA_OBJS   : extra object files
8 # IMPORTS      : dlls to import
9 # DELAYIMPORTS : dlls to import in delayed mode
10 # EXTRASUBDIRS : subdirectories that do not contain a Makefile
11 # MODCFLAGS    : extra CFLAGS for this module
13 # First some useful definitions
15 INCLUDES     = -I$(srcdir) -I. -I$(top_srcdir)/include -I$(top_builddir)/include $(EXTRAINCL)
16 DEFS         = -D__WINESRC__ $(EXTRADEFS)
17 ALLCFLAGS    = $(INCLUDES) $(DEFS) $(DLLFLAGS) $(EXTRACFLAGS) $(CPPFLAGS) $(CFLAGS) $(MODCFLAGS)
18 IDLFLAGS     = $(INCLUDES) $(DEFS) $(EXTRAIDLFLAGS)
19 RCFLAGS      = --nostdinc $(PORCFLAGS) $(TARGETFLAGS) $(INCLUDES) $(DEFS) $(EXTRARCFLAGS)
21 IDL_GEN_C_SRCS  = $(IDL_C_SRCS:.idl=_c.c) $(IDL_I_SRCS:.idl=_i.c) \
22                   $(IDL_P_SRCS:.idl=_p.c) $(IDL_S_SRCS:.idl=_s.c)
23 IDL_GEN_HEADERS = $(IDL_H_SRCS:.idl=.h) $(IDL_C_SRCS:.idl=.h) $(IDL_I_SRCS:.idl=.h) \
24                   $(IDL_P_SRCS:.idl=.h) $(IDL_S_SRCS:.idl=.h)
26 CLEAN_FILES   = *.o *.a *.so *.mo *.res *.fake *.ok *.tab.[ch] *.yy.c
27 CLEAN_TARGETS = $(MODULE) $(IMPORTLIB:%=lib%.@IMPLIBEXT@) $(IDL_GEN_C_SRCS) $(IDL_GEN_HEADERS) \
28                 $(IDL_TLB_SRCS:.idl=.tlb) $(IDL_P_SRCS:.idl=_p.c dlldata.c) \
29                 $(PO_SRCS:.rc=.res rsrc.pot) $(MC_SRCS:.mc=.res msg.pot) $(XTEMPLATE_SRCS:.x=.h) \
30                 $(TESTMODULE:%=% testlist.c) $(CROSSTESTMODULE)
32 OBJS = $(C_SRCS:.c=.o) $(BISON_SRCS:.y=.tab.o) $(LEX_SRCS:.l=.yy.o) $(IDL_GEN_C_SRCS:.c=.o) $(OBJC_SRCS:.m=.o) \
33        $(IDL_R_SRCS:.idl=_r.res) $(IDL_TLB_RES) $(RC_SRCS:.rc=.res) $(MC_SRCS:.mc=.res) $(EXTRA_OBJS)
35 CROSSOBJS = $(OBJS:.o=.cross.o)
37 # Implicit rules
39 .SUFFIXES: .mc .rc .res .idl .tlb .h .ok .man.in .man _c.c _i.c _p.c _s.c _r.res _t.res .cross.o .po .mo @MAINTAINER_MODE@ .sfd .ttf .svg .ico .bmp
41 .c.o:
42         $(CC) -c $(ALLCFLAGS) -o $@ $<
44 .m.o:
45         $(CC) -c $(ALLCFLAGS) -o $@ $<
47 .c.cross.o:
48         $(CROSSCC) -c $(INCLUDES) $(DEFS) -DWINE_CROSSTEST $(CPPFLAGS) $(CFLAGS) -o $@ $<
50 .mc.res:
51         $(WMC) -U -O res $(PORCFLAGS) -o $@ $<
53 .rc.res:
54         $(WRC) $(RCFLAGS) -o $@ $<
56 .idl.h:
57         $(WIDL) $(IDLFLAGS) -h -o $@ $<
59 .idl_c.c:
60         $(WIDL) $(IDLFLAGS) -c -o $@ $<
62 .idl_i.c:
63         $(WIDL) $(IDLFLAGS) -u -o $@ $<
65 .idl_p.c:
66         $(WIDL) $(IDLFLAGS) -p -o $@ $<
68 .idl_r.res:
69         $(WIDL) $(IDLFLAGS) -r -o $@ $<
71 .idl_s.c:
72         $(WIDL) $(IDLFLAGS) -s -o $@ $<
74 .idl.tlb:
75         $(WIDL) $(TARGETFLAGS) $(IDLFLAGS) -t -o $@ $<
77 .idl_t.res:
78         $(WIDL) $(TARGETFLAGS) $(IDLFLAGS) -t -o $@ $<
80 .c.ok:
81         $(RUNTEST) $(RUNTESTFLAGS) $< && touch $@
83 .sfd.ttf:
84         $(FONTFORGE) -script $(top_srcdir)/fonts/genttf.ff $< $@
86 .man.in.man:
87         LC_ALL=C sed -e 's,@bindir\@,$(bindir),g' -e 's,@dlldir\@,$(dlldir),g' -e 's,@PACKAGE_STRING\@,@PACKAGE_STRING@,g' $< >$@ || ($(RM) $@ && false)
89 .svg.ico:
90         CONVERT="$(CONVERT)" ICOTOOL="$(ICOTOOL)" RSVG="$(RSVG)" $(BUILDIMAGE) $< $@
92 .svg.bmp:
93         CONVERT="$(CONVERT)" ICOTOOL="$(ICOTOOL)" RSVG="$(RSVG)" $(BUILDIMAGE) $< $@
95 .po.mo:
96         $(MSGFMT) -o $@ $<
98 # Rules for IDL files
100 dlldata.c: $(WIDL) Makefile.in
101         $(WIDL) $(IDLFLAGS) --dlldata-only -o $@ $(IDL_P_SRCS)
103 # Rules for main module
105 $(MODULE) $(MODULE:%=%.so) $(MODULE:%=%.fake): $(MAINSPEC) $(OBJS) Makefile.in
106         $(WINEGCC) $(APPMODE) $(MODULEFLAGS) $(OBJS) -o $@ $(DELAYIMPORTS:%=-l%) $(IMPORTS:%=-l%) $(DELAYIMPORTS:%=-Wb,-d%) -lwine $(LIBPORT) $(EXTRALIBS) $(LDFLAGS) $(LIBS)
108 # Rules for static libraries
110 all: $(STATICLIB)
112 $(STATICLIB): $(OBJS) Makefile.in
113         $(RM) $@
114         $(AR) $(ARFLAGS) $@ $(OBJS)
115         $(RANLIB) $@
117 $(STATICLIB:.a=.cross.a): $(CROSSOBJS) Makefile.in
118         $(RM) $@
119         $(CROSSAR) $(ARFLAGS) $@ $(CROSSOBJS)
120         $(CROSSRANLIB) $@
122 # Rules for import libraries
124 $(IMPORTLIB:%=lib%.def.a): $(IMPLIB_SRCS:.c=.o)
125         $(RM) $@
126         $(AR) $(ARFLAGS) $@ $(IMPLIB_SRCS:.c=.o)
127         $(RANLIB) $@
129 $(IMPORTLIB:%=lib%.a): $(MAINSPEC) $(IMPLIB_SRCS:.c=.o)
130         $(WINEBUILD) $(TARGETFLAGS) -w --implib -o $@ --export $(srcdir)/$(MAINSPEC) $(IMPLIB_SRCS:.c=.o)
132 $(IMPORTLIB:%=lib%.cross.a): $(MAINSPEC) $(IMPLIB_SRCS:.c=.cross.o)
133         $(WINEBUILD) $(CROSSTARGET:%=-b %) -w --implib -o $@ --export $(srcdir)/$(MAINSPEC) $(IMPLIB_SRCS:.c=.cross.o)
135 # Rules for dependencies
137 DEPEND_SRCS = $(C_SRCS) $(OBJC_SRCS) $(RC_SRCS) $(MC_SRCS) \
138               $(IDL_H_SRCS) $(IDL_C_SRCS) $(IDL_I_SRCS) $(IDL_P_SRCS) $(IDL_S_SRCS) \
139               $(IDL_GEN_C_SRCS) $(IDL_R_SRCS:.idl=_r.res) $(IDL_TLB_SRCS) $(IDL_TLB_SRCS:.idl=.tlb) \
140               $(BISON_SRCS) $(LEX_SRCS) $(EXTRA_OBJS)
142 depend: dummy
143         $(MAKEDEP) $(MAKEDEPFLAGS) -C$(srcdir) -S$(top_srcdir) -T$(top_builddir) $(EXTRAINCL) $(DEPEND_SRCS)
145 .PHONY: depend
147 # Rules for tests
149 $(TESTMODULE) $(TESTMODULE:%=%.so): $(OBJS) Makefile.in
150         $(WINEGCC) $(APPMODE) $(OBJS) -o $@ $(IMPORTS:%=-l%) $(LDFLAGS) $(LIBS)
152 $(TESTMODULE_STRIPPED): $(OBJS) Makefile.in
153         $(WINEGCC) -s -Wb,-F,$(TESTMODULE) $(APPMODE) $(OBJS) -o $@ $(IMPORTS:%=-l%) $(LDFLAGS) $(LIBS)
155 $(CROSSTESTMODULE): $(CROSSOBJS) Makefile.in
156         $(CROSSWINEGCC) $(CROSSOBJS) -o $@ $(IMPORTS:%=-l%) $(LDFLAGS) $(LIBS)
158 $(WINETEST_RES): $(TESTMODULE_STRIPPED)
159         echo "$(TESTMODULE) TESTRES \"$(TESTMODULE_STRIPPED)\"" | $(WRC) $(RCFLAGS) -o $@
161 testlist.c: Makefile.in $(MAKECTESTS)
162         $(MAKECTESTS) -o $@ $(C_SRCS)
164 testclean::
165         $(RM) *.ok
167 .PHONY: check test testclean
169 # Rules for man pages
171 MANPAGES = $(MANPAGE) $(EXTRA_MANPAGES)
173 all: $(MANPAGES)
175 install-man-pages:: $(MANPAGE) $(DESTDIR)$(mandir)/man$(prog_manext)
176         $(INSTALL_DATA) $(MANPAGE) $(DESTDIR)$(mandir)/man$(prog_manext)/$(MANPAGE:.man=).$(prog_manext)
178 uninstall-man-pages::
179         $(RM) $(DESTDIR)$(mandir)/man$(prog_manext)/$(MANPAGE:.man=).$(prog_manext)
181 .PHONY: install-man-pages uninstall-man-pages
183 # Rules for auto documentation
185 manpages:: $(C_SRCS) dummy
186         $(C2MAN) -o $(top_builddir)/documentation/man$(api_manext) -R$(top_builddir) -C$(srcdir) $(INCLUDES) -S$(api_manext) $(MAINSPEC:%=-w %) $(C_SRCS)
188 htmlpages:: $(C_SRCS) dummy
189         $(C2MAN) -o $(top_builddir)/documentation/html -R$(top_builddir) -C$(srcdir) $(INCLUDES) -Th $(MAINSPEC:%=-w %) $(C_SRCS)
191 sgmlpages:: $(C_SRCS) dummy
192         $(C2MAN) -o $(top_builddir)/documentation/api-guide -R$(top_builddir) -C$(srcdir) $(INCLUDES) -Ts $(MAINSPEC:%=-w %) $(C_SRCS)
194 xmlpages:: $(C_SRCS) dummy
195         $(C2MAN) -o $(top_builddir)/documentation/api-guide-xml -R$(top_builddir) -C$(srcdir) $(INCLUDES) -Tx $(MAINSPEC:%=-w %) $(C_SRCS)
197 # Rules for cleaning
199 $(EXTRASUBDIRS:%=%/clean): dummy
200         -cd `dirname $@` && $(RM) $(CLEAN_FILES)
202 clean:: $(EXTRASUBDIRS:%=%/clean)
203         $(RM) $(CLEAN_FILES) $(CLEAN_TARGETS) $(PROGRAMS) $(MANPAGES)
205 .PHONY: clean $(EXTRASUBDIRS:%=%/clean)
207 # Rules for installing
209 $(INSTALLDIRS):
210         $(MKDIR_P) -m 755 $@
212 install install-lib install-dev uninstall::
214 .PHONY: install install-lib install-dev uninstall
216 # Rules for resources
218 rsrc.pot: $(WRC)
219         $(WRC) $(RCFLAGS) -O pot -o $@ $(PO_SRCS)
221 msg.pot: $(WMC)
222         $(WMC) -O pot -o $@ $(MC_SRCS)
224 $(MC_SRCS:.mc=.res): $(WMC) $(ALL_MO_FILES)
225 $(RC_SRCS:.rc=.res): $(WRC)
226 $(PO_SRCS:.rc=.res): $(ALL_MO_FILES)
228 # Misc. rules
230 $(IDL_GEN_HEADERS) $(IDL_GEN_C_SRCS) $(IDL_TLB_SRCS:.idl=.tlb) $(IDL_TLB_RES) $(IDL_R_SRCS:.idl=_r.res): $(WIDL)
232 # End of global rules