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)
36 ALLCROSSCFLAGS = $(INCLUDES) $(DEFS) -DWINE_CROSSTEST $(CPPFLAGS) $(CFLAGS)
40 .SUFFIXES: .ok .man.in .man .cross.o .po .mo @MAINTAINER_MODE@ .sfd .ttf .svg .ico .bmp
43 $(CC) -c $(ALLCFLAGS) -o $@ $<
46 $(CC) -c $(ALLCFLAGS) -o $@ $<
49 $(CROSSCC) -c $(INCLUDES) $(DEFS) -DWINE_CROSSTEST $(CPPFLAGS) $(CFLAGS) -o $@ $<
52 $(RUNTEST) $(RUNTESTFLAGS) $< && touch $@
55 $(FONTFORGE) -script $(top_srcdir)/fonts/genttf.ff $< $@
58 LC_ALL=C sed -e 's,@bindir\@,$(bindir),g' -e 's,@dlldir\@,$(dlldir),g' -e 's,@PACKAGE_STRING\@,@PACKAGE_STRING@,g' $< >$@ || ($(RM) $@ && false)
61 CONVERT="$(CONVERT)" ICOTOOL="$(ICOTOOL)" RSVG="$(RSVG)" $(BUILDIMAGE) $< $@
64 CONVERT="$(CONVERT)" ICOTOOL="$(ICOTOOL)" RSVG="$(RSVG)" $(BUILDIMAGE) $< $@
69 # Rules for main module
71 $(MODULE) $(MODULE:%=%.so) $(MODULE:%=%.fake): $(MAINSPEC) $(OBJS) Makefile.in
72 $(WINEGCC) $(APPMODE) $(MODULEFLAGS) $(OBJS) -o $@ $(DELAYIMPORTS:%=-l%) $(IMPORTS:%=-l%) $(DELAYIMPORTS:%=-Wb,-d%) -lwine $(LIBPORT) $(EXTRALIBS) $(LDFLAGS) $(LIBS)
74 # Rules for static libraries
78 $(STATICLIB): $(OBJS) Makefile.in
80 $(AR) $(ARFLAGS) $@ $(OBJS)
83 $(STATICLIB:.a=.cross.a): $(CROSSOBJS) Makefile.in
85 $(CROSSAR) $(ARFLAGS) $@ $(CROSSOBJS)
88 # Rules for import libraries
90 $(IMPORTLIB:%=lib%.def.a): $(IMPLIB_SRCS:.c=.o)
92 $(AR) $(ARFLAGS) $@ $(IMPLIB_SRCS:.c=.o)
95 $(IMPORTLIB:%=lib%.a): $(MAINSPEC) $(IMPLIB_SRCS:.c=.o)
96 $(WINEBUILD) $(TARGETFLAGS) -w --implib -o $@ --export $(srcdir)/$(MAINSPEC) $(IMPLIB_SRCS:.c=.o)
98 $(IMPORTLIB:%=lib%.cross.a): $(MAINSPEC) $(IMPLIB_SRCS:.c=.cross.o)
99 $(WINEBUILD) $(CROSSTARGET:%=-b %) -w --implib -o $@ --export $(srcdir)/$(MAINSPEC) $(IMPLIB_SRCS:.c=.cross.o)
101 # Rules for dependencies
103 DEPEND_SRCS = $(C_SRCS) $(OBJC_SRCS) $(RC_SRCS) $(MC_SRCS) $(PO_SRCS:.rc=.pot) \
104 $(IDL_H_SRCS) $(IDL_GEN_C_SRCS) $(IDL_R_SRCS:.idl=_r.res) $(IDL_TLB_SRCS:.idl=.tlb) \
105 $(BISON_SRCS) $(LEX_SRCS) $(EXTRA_OBJS)
108 $(MAKEDEP) $(MAKEDEPFLAGS) -C$(srcdir) -S$(top_srcdir) -T$(top_builddir) $(EXTRAINCL) $(DEPEND_SRCS)
114 $(TESTMODULE) $(TESTMODULE:%=%.so): $(OBJS) Makefile.in
115 $(WINEGCC) $(APPMODE) $(OBJS) -o $@ $(IMPORTS:%=-l%) $(LDFLAGS) $(LIBS)
117 $(TESTMODULE_STRIPPED): $(OBJS) Makefile.in
118 $(WINEGCC) -s -Wb,-F,$(TESTMODULE) $(APPMODE) $(OBJS) -o $@ $(IMPORTS:%=-l%) $(LDFLAGS) $(LIBS)
120 $(CROSSTESTMODULE): $(CROSSOBJS) Makefile.in
121 $(CROSSWINEGCC) $(CROSSOBJS) -o $@ $(IMPORTS:%=-l%) $(LDFLAGS) $(LIBS)
123 $(WINETEST_RES): $(TESTMODULE_STRIPPED)
124 echo "$(TESTMODULE) TESTRES \"$(TESTMODULE_STRIPPED)\"" | $(WRC) $(RCFLAGS) -o $@
129 .PHONY: check test testclean
131 # Rules for man pages
133 MANPAGES = $(MANPAGE) $(EXTRA_MANPAGES)
137 install-man-pages:: $(MANPAGE) $(DESTDIR)$(mandir)/man$(prog_manext)
138 $(INSTALL_DATA) $(MANPAGE) $(DESTDIR)$(mandir)/man$(prog_manext)/$(MANPAGE:.man=).$(prog_manext)
140 uninstall-man-pages::
141 $(RM) $(DESTDIR)$(mandir)/man$(prog_manext)/$(MANPAGE:.man=).$(prog_manext)
143 .PHONY: install-man-pages uninstall-man-pages
145 # Rules for auto documentation
147 manpages:: $(C_SRCS) dummy
148 $(C2MAN) -o $(top_builddir)/documentation/man$(api_manext) -R$(top_builddir) -C$(srcdir) $(INCLUDES) -S$(api_manext) $(MAINSPEC:%=-w %) $(C_SRCS)
150 htmlpages:: $(C_SRCS) dummy
151 $(C2MAN) -o $(top_builddir)/documentation/html -R$(top_builddir) -C$(srcdir) $(INCLUDES) -Th $(MAINSPEC:%=-w %) $(C_SRCS)
153 sgmlpages:: $(C_SRCS) dummy
154 $(C2MAN) -o $(top_builddir)/documentation/api-guide -R$(top_builddir) -C$(srcdir) $(INCLUDES) -Ts $(MAINSPEC:%=-w %) $(C_SRCS)
156 xmlpages:: $(C_SRCS) dummy
157 $(C2MAN) -o $(top_builddir)/documentation/api-guide-xml -R$(top_builddir) -C$(srcdir) $(INCLUDES) -Tx $(MAINSPEC:%=-w %) $(C_SRCS)
161 $(EXTRASUBDIRS:%=%/clean): dummy
162 -cd `dirname $@` && $(RM) $(CLEAN_FILES)
164 clean:: $(EXTRASUBDIRS:%=%/clean)
165 $(RM) $(CLEAN_FILES) $(CLEAN_TARGETS) $(PROGRAMS) $(MANPAGES)
167 .PHONY: clean $(EXTRASUBDIRS:%=%/clean)
169 # Rules for installing
174 install install-lib install-dev uninstall::
176 .PHONY: install install-lib install-dev uninstall
178 # End of global rules