winegcc: Automatically add the correct lib paths when building inside the Wine tree.
[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 # C_SRCS16     : 16-bit C sources for the module
12 # RC_SRCS      : resource source files
13 # EXTRA_SRCS   : extra source files for make depend
14 # EXTRA_OBJS   : extra object files
15 # IMPORTS      : dlls to import
16 # DELAYIMPORTS : dlls to import in delayed mode
17 # SUBDIRS      : subdirectories that contain a Makefile
18 # EXTRASUBDIRS : subdirectories that do not contain a Makefile
19 # INSTALLSUBDIRS : subdirectories to run make install/uninstall into
20 # MODCFLAGS    : extra CFLAGS for this module
21
22 # First some useful definitions
23
24 SHELL     = /bin/sh
25 CC        = @CC@
26 CFLAGS    = @CFLAGS@
27 CPPFLAGS  = @CPPFLAGS@
28 LIBS      = @LIBS@
29 BISON     = @BISON@
30 LEX       = @LEX@
31 LEXLIB    = @LEXLIB@
32 EXEEXT    = @EXEEXT@
33 OBJEXT    = @OBJEXT@
34 LIBEXT    = @LIBEXT@
35 DLLEXT    = @DLLEXT@
36 IMPLIBEXT = @IMPLIBEXT@
37 LDSHARED  = @LDSHARED@
38 DLLTOOL   = @DLLTOOL@
39 DLLWRAP   = @DLLWRAP@
40 AR        = @AR@ rc
41 RANLIB    = @RANLIB@
42 STRIP     = @STRIP@
43 WINDRES   = @WINDRES@
44 LN        = @LN@
45 LN_S      = @LN_S@
46 TOOLSDIR  = @TOOLSDIR@
47 AS        = @AS@
48 LD        = @LD@
49 LDFLAGS   = @LDFLAGS@
50 PRELINK   = @PRELINK@
51 RM        = rm -f
52 MV        = mv
53 LINT      = @LINT@
54 LINTFLAGS = @LINTFLAGS@
55 FONTFORGE = @FONTFORGE@
56 INCLUDES     = -I$(SRCDIR) -I. -I$(TOPSRCDIR)/include -I$(TOPOBJDIR)/include $(EXTRAINCL)
57 EXTRACFLAGS  = @EXTRACFLAGS@
58 ALLCFLAGS    = $(INCLUDES) $(DEFS) $(DLLFLAGS) $(EXTRACFLAGS) $(CPPFLAGS) $(CFLAGS) $(MODCFLAGS)
59 ALLLINTFLAGS = $(INCLUDES) $(DEFS) $(LINTFLAGS)
60 IDLFLAGS     = $(INCLUDES) $(DEFS) $(EXTRAIDLFLAGS)
61 WINEBUILDFLAGS = $(DLLFLAGS) --as-cmd "$(AS)"
62 MKINSTALLDIRS= $(TOPSRCDIR)/tools/mkinstalldirs -m 755
63 WINAPI_CHECK = $(TOPSRCDIR)/tools/winapi/winapi_check
64 WINEWRAPPER  = $(TOPSRCDIR)/tools/winewrapper
65 C2MAN        = $(TOPSRCDIR)/tools/c2man.pl
66 RUNTEST      = $(TOPSRCDIR)/tools/runtest
67 WINEBUILD    = $(TOOLSDIR)/tools/winebuild/winebuild
68 MAKEDEP      = $(TOOLSDIR)/tools/makedep
69 MAKECTESTS   = $(TOOLSDIR)/tools/make_ctests
70 WRC          = $(TOOLSDIR)/tools/wrc/wrc
71 BIN2RES      = $(TOOLSDIR)/tools/bin2res
72 WMC          = $(TOOLSDIR)/tools/wmc/wmc
73 WIDL         = $(TOOLSDIR)/tools/widl/widl
74 WINEGCC      = $(TOOLSDIR)/tools/winegcc/winegcc
75 RELPATH      = $(TOOLSDIR)/tools/relpath
76 SFNT2FNT     = $(TOOLSDIR)/tools/sfnt2fnt
77 FNT2FON      = $(TOOLSDIR)/tools/fnt2fon
78 RC           = $(WRC)
79 RC16         = $(WRC)
80 RCFLAGS      = --nostdinc $(INCLUDES) $(DEFS) $(EXTRARCFLAGS)
81 RC16FLAGS    = -O res16 $(RCFLAGS)
82 LDPATH       = @LDPATH@
83 DLLDIR       = $(TOPOBJDIR)/dlls
84 LIBPORT      = $(TOPOBJDIR)/libs/port/libwine_port.a
85 LIBWPP       = $(TOPOBJDIR)/libs/wpp/libwpp.a
86 LIBWINE      = -L$(TOPOBJDIR)/libs/wine -lwine
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 prog_manext     = 1
108 api_manext      = 3w
109 conf_manext     = 5
110 CLEAN_FILES     = *.o *.a *.so *.ln *.$(LIBEXT) \\\#*\\\# *~ *% .\\\#* *.bak *.orig *.rej \
111                   *.flc *.tab.c *.tab.h @LEX_OUTPUT_ROOT@.c core
112
113 OBJS = $(C_SRCS:.c=.o) $(EXTRA_OBJS)
114
115 RCOBJS = $(RC_SRCS:.rc=.res.o)
116 LINTS  = $(C_SRCS:.c=.ln)
117
118 # Implicit rules
119
120 .SUFFIXES: .mc .rc .mc.rc .res .res.o .spec .spec.o .idl .tlb .h .ok .sfd .ttf .man.in .man
121
122 .c.o:
123         $(CC) -c $(ALLCFLAGS) -o $@ $<
124
125 .s.o:
126         $(AS) -o $@ $<
127
128 .mc.mc.rc:
129         $(LDPATH) $(WMC) -i -U -H /dev/null -o $@ $<
130
131 .rc.res:
132         $(LDPATH) $(RC) $(RCFLAGS) -fo$@ $<
133
134 .res.res.o:
135         $(WINDRES) -i $< -o $@
136
137 .spec.spec.o:
138         $(WINEBUILD) $(WINEBUILDFLAGS) --dll -o $@ --main-module $(MODULE) --export $<
139
140 .idl.h:
141         $(WIDL) $(IDLFLAGS) -h -H $@ $<
142
143 .idl.tlb:
144         $(WIDL) $(IDLFLAGS) -t -T $@ $<
145
146 .c.ln:
147         $(LINT) -c $(ALLLINTFLAGS) $< || ( $(RM) $@ && exit 1 )
148
149 .c.ok:
150         $(RUNTEST) $(RUNTESTFLAGS) $< && touch $@
151
152 .sfd.ttf:
153         $(FONTFORGE) -script $(TOPSRCDIR)/fonts/genttf.ff $< $@
154
155 .man.in.man:
156         sed -e 's,@bindir\@,$(bindir),g' -e 's,@dlldir\@,$(dlldir),g' -e 's,@PACKAGE_STRING\@,@PACKAGE_STRING@,g' $< >$@ || ($(RM) $@ && false)
157
158 # 'all' target first in case the enclosing Makefile didn't define any target
159
160 all: Makefile
161
162 filter:
163         @$(TOPSRCDIR)/tools/winapi/make_filter --make $(MAKE) all
164
165 .PHONY: all filter
166
167 # Rules for resources
168
169 $(RC_BINARIES): $(BIN2RES) $(RC_BINSRC)
170         $(BIN2RES) -f -o $@ $(SRCDIR)/$(RC_BINSRC)
171
172 $(RC_SRCS:.rc=.res) $(RC_SRCS16:.rc=.res): $(WRC) $(RC_BINARIES) $(RC_TLB)
173
174 # Rules for makefile
175
176 Makefile: Makefile.in $(TOPSRCDIR)/configure
177         @echo Makefile is older than $?, please rerun $(TOPSRCDIR)/configure
178         @exit 1
179
180 # Rule for linting
181
182 $(MODULE).ln : $(LINTS)
183         if test "$(LINTS)" ; \
184         then \
185                 $(LINT) $(ALLLINTFLAGS) -o$(MODULE) $(LINTS) ; \
186                 $(MV) llib-l$(MODULE).ln $(MODULE).ln ; \
187         else \
188                 $(LINT) $(ALLLINTFLAGS) -C$(MODULE) /dev/null ; \
189         fi
190
191 lint:: $(MODULE).ln
192
193 # Rules for Windows API checking
194
195 winapi_check:: dummy
196         $(WINAPI_CHECK) $(WINAPI_CHECK_FLAGS) $(WINAPI_CHECK_EXTRA_FLAGS) .
197
198 .PHONY: winapi_check
199
200 # Rules for dependencies
201
202 $(SUBDIRS:%=%/__depend__): dummy
203         cd `dirname $@` && $(MAKE) depend
204
205 depend: $(IDL_SRCS:.idl=.h) $(SUBDIRS:%=%/__depend__)
206         $(MAKEDEP) $(INCLUDES) -C$(SRCDIR) $(C_SRCS) $(C_SRCS16) $(RC_SRCS) $(RC_SRCS16) $(MC_SRCS) $(IDL_SRCS) $(EXTRA_SRCS)
207
208 .PHONY: depend $(SUBDIRS:%=%/__depend__)
209
210 # Rules for cleaning
211
212 $(SUBDIRS:%=%/__clean__): dummy
213         cd `dirname $@` && $(MAKE) clean
214
215 $(SUBDIRS:%=%/__testclean__): dummy
216         cd `dirname $@` && $(MAKE) testclean
217
218 $(EXTRASUBDIRS:%=%/__clean__): dummy
219         -cd `dirname $@` && $(RM) $(CLEAN_FILES)
220
221 testclean:: $(SUBDIRS:%=%/__testclean__)
222
223 clean:: $(SUBDIRS:%=%/__clean__) $(EXTRASUBDIRS:%=%/__clean__)
224         $(RM) $(CLEAN_FILES) $(RC_SRCS:.rc=.res) $(RC_SRCS16:.rc=.res) $(MC_SRCS:.mc=.mc.rc) $(IDL_SRCS:.idl=.h) $(PROGRAMS) $(RC_BINARIES) $(RC_TLB) $(MANPAGES)
225
226 .PHONY: clean testclean $(SUBDIRS:%=%/__clean__) $(SUBDIRS:%=%/__testclean__) $(EXTRASUBDIRS:%=%/__clean__)
227
228 # Rules for installing
229
230 $(SUBDIRS:%=%/__install__): dummy
231         cd `dirname $@` && $(MAKE) install
232
233 $(SUBDIRS:%=%/__install-lib__): dummy
234         cd `dirname $@` && $(MAKE) install-lib
235
236 $(SUBDIRS:%=%/__install-dev__): dummy
237         cd `dirname $@` && $(MAKE) install-dev
238
239 $(SUBDIRS:%=%/__uninstall__): dummy
240         cd `dirname $@` && $(MAKE) uninstall
241
242 install:: $(INSTALLSUBDIRS:%=%/__install__)
243
244 uninstall:: $(INSTALLSUBDIRS:%=%/__uninstall__)
245
246 .PHONY: install install-lib install-dev uninstall \
247         $(SUBDIRS:%=%/__install__) $(SUBDIRS:%=%/__uninstall__) \
248         $(SUBDIRS:%=%/__install-lib__) $(SUBDIRS:%=%/__install-dev__)
249
250 # Rules for checking that no imports are missing
251
252 $(SUBDIRS:%=%/__checklink__): dummy
253         @cd `dirname $@` && $(MAKE) checklink
254
255 .PHONY: checklink $(SUBDIRS:%=%/__checklink__)
256
257 # Rules for testing
258
259 $(SUBDIRS:%=%/__test__): dummy
260         @cd `dirname $@` && $(MAKE) test
261
262 $(SUBDIRS:%=%/__crosstest__): dummy
263         @cd `dirname $@` && $(MAKE) crosstest
264
265 .PHONY: check test crosstest $(SUBDIRS:%=%/__test__) $(SUBDIRS:%=%/__crosstest__)
266
267 # Misc. rules
268
269 $(MC_SRCS:.mc=.mc.rc): $(WMC)
270
271 $(IDL_SRCS:.idl=.h): $(WIDL)
272
273 $(RC_TLB:.idl=.tlb): $(WIDL)
274
275 $(SUBDIRS): dummy
276         @cd $@ && $(MAKE)
277
278 dummy:
279
280 .PHONY: dummy $(SUBDIRS)
281
282 # End of global rules