Moved $(MODULE).o rule out of Make.rules into the individual
[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 # ASM_SRCS     : assembly sources
12 # GEN_C_SRCS   : generated C files
13 # GEN_ASM_SRCS : generated assembly sources
14 # RC_SRCS      : resource source files
15 # SPEC_SRCS    : interface definition files
16 # GLUE         : C sources for which glue code needs to be generated
17 # EXTRA_SRCS   : extra source files for make depend
18 # EXTRA_OBJS   : extra object files
19 # WRCEXTRA     : extra wrc flags (e.g. '-p _SysRes')
20 # SUBDIRS      : subdirectories that contain a Makefile
21 # EXTRASUBDIRS : subdirectories that do not contain a Makefile
22
23 # First some useful definitions
24
25 SHELL     = /bin/sh
26 CC        = @CC@
27 CPP       = @CPP@
28 CFLAGS    = @CFLAGS@
29 OPTIONS   = @OPTIONS@ -D_REENTRANT
30 X_CFLAGS  = @X_CFLAGS@
31 X_LIBS    = @X_LIBS@
32 XLIB      = @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@
33 DLL_LINK  = @DLL_LINK@
34 LIBS      = @LIBS@
35 YACC      = @YACC@
36 LEX       = @LEX@
37 LEXLIB    = @LEXLIB@
38 RANLIB    = @RANLIB@
39 LN_S      = @LN_S@
40 DIVINCL   = -I$(SRCDIR) -I. -I$(TOPSRCDIR)/include -I$(TOPOBJDIR)/include
41 ALLCFLAGS = $(DIVINCL) $(CFLAGS) $(DEFS) $(OPTIONS) $(X_CFLAGS)
42 LDCOMBINE = ld -r
43 LDFLAGS   = @LDFLAGS@
44 AR        = ar rc
45 RM        = rm -f
46 MV        = mv
47 MKDIR     = mkdir -p
48 C2MAN     = @C2MAN@
49 MANSPECS  = -w $(TOPSRCDIR)/dlls/gdi/gdi32.spec \
50             -w $(TOPSRCDIR)/dlls/user/user32.spec \
51             -w $(TOPSRCDIR)/dlls/comctl32/comctl32.spec \
52             -w $(TOPSRCDIR)/dlls/comdlg32/comdlg32.spec \
53             -w $(TOPSRCDIR)/dlls/kernel/kernel32.spec 
54 LINT      = @LINT@
55 LINTFLAGS = @LINTFLAGS@
56 ALLLINTFLAGS = $(LINTFLAGS) $(DEFS) $(OPTIONS) $(DIVINCL)
57 WINAPI_CHECK = $(TOPSRCDIR)/tools/winapi_check/winapi_check
58 BUILD     = $(TOPOBJDIR)/tools/winebuild/winebuild
59 MAKEDEP   = $(TOPOBJDIR)/tools/makedep
60 WRC       = $(TOPOBJDIR)/tools/wrc/wrc
61 WRCFLAGS  = -c -s -p $*
62 WMC       = $(TOPOBJDIR)/tools/wmc/wmc
63 DLLDIR    = $(TOPOBJDIR)/dlls
64 @SET_MAKE@
65
66 # Installation infos
67
68 INSTALL         = @INSTALL@
69 INSTALL_PROGRAM = @INSTALL_PROGRAM@
70 INSTALL_DATA    = @INSTALL_DATA@
71 prefix          = @prefix@
72 exec_prefix     = @exec_prefix@
73 bindir          = @bindir@
74 libdir          = @libdir@
75 infodir         = @infodir@
76 mandir          = @mandir@
77 prog_manext     = 1
78 conf_manext     = 5
79 includedir      = @includedir@/wine
80 CLEAN_FILES     = *.o *.a *.so *.ln \\\#*\\\# *~ *% .\\\#* *.bak *.orig *.rej \
81                   *.flc *.spec.c *.glue.c y.tab.c y.tab.h lex.yy.c core
82
83 OBJS = $(SPEC_SRCS:.spec=.spec.o) $(C_SRCS:.c=.o) $(GEN_C_SRCS:.c=.o) $(GEN_ASM_SRCS:.s=.o) \
84        $(ASM_SRCS:.S=.o) $(RC_SRCS:.rc=.o) $(GLUE:.c=.glue.o) $(EXTRA_OBJS)
85
86 LINTS = $(C_SRCS:.c=.ln)
87
88 # DLL list
89
90 X_DLLS = \
91         ddraw \
92         @OPENGL32_DLL@ \
93         x11drv
94
95 DLLS = \
96         @X_DLLS@ \
97         advapi32 \
98         avifil32 \
99         comctl32 \
100         comdlg32 \
101         crtdll \
102         dciman32 \
103         dinput \
104         dplay \
105         dplayx \
106         dsound \
107         gdi32 \
108         icmp \
109         imagehlp \
110         imm32 \
111         joystick.drv \
112         kernel32 \
113         lz32 \
114         mcianim.drv \
115         mciavi.drv \
116         mcicda.drv \
117         mciseq.drv \
118         mciwave.drv \
119         midimap.drv \
120         mpr \
121         msacm.drv \
122         msacm32 \
123         msnet32 \
124         msvfw32 \
125         odbc32 \
126         ole32 \
127         oleaut32 \
128         olecli32 \
129         oledlg \
130         olepro32 \
131         olesvr32 \
132         psapi \
133         rasapi32 \
134         riched32 \
135         rpcrt4 \
136         serialui \
137         setupapi \
138         shell32 \
139         shfolder \
140         shlwapi \
141         tapi32 \
142         ttydrv \
143         urlmon \
144         user32 \
145         version \
146         w32skrnl \
147         wineoss.drv \
148         wineps \
149         wininet \
150         winmm \
151         winspool.drv \
152         wnaspi32 \
153         wow32 \
154         ws2_32 \
155         wsock32
156
157 # Implicit rules
158
159 .SUFFIXES: .mc .rc .res .spec .spec.c .spec.o .glue.c
160
161 .c.o:
162         $(CC) -c $(ALLCFLAGS) -o $*.o $<
163
164 .spec.c.spec.o:
165         $(CC) -c $(ALLCFLAGS) @GCC_NO_BUILTIN@ -o $*.spec.o $<
166
167 .s.o:
168         $(AS) -o $*.o $<  
169
170 .S.o:
171         $(CC) -c -o $*.o $<  
172
173 .mc.rc:
174         LD_LIBRARY_PATH="$(TOPOBJDIR):$$LD_LIBRARY_PATH" $(WMC) -i -H /dev/null -o $@ $<
175
176 .rc.s:
177         $(WRC) $(WRCFLAGS) $(WRCEXTRA) $(DIVINCL) $<
178
179 .rc.h:
180         $(WRC) $(WRCFLAGS) $(WRCEXTRA) $(DIVINCL) -nh $<
181
182 .rc.res:
183         $(WRC) $(WRCFLAGS) $(WRCEXTRA) $(DIVINCL) -r $<
184
185 .res.s:
186         $(WRC) $(WRCFLAGS) $(WRCEXTRA) -b $<
187
188 .res.h:
189         $(WRC) $(WRCFLAGS) $(WRCEXTRA) -bnh $<
190
191 .spec.spec.c:
192         $(BUILD) @DLLFLAGS@ -o $@ -spec $<
193
194 .c.glue.c:
195         $(BUILD) @DLLFLAGS@ -o $@ -glue $<
196
197 .c.ln:
198         $(LINT) -c $(ALLLINTFLAGS) $< || ( $(RM) $@ && exit 1 )
199
200 .PHONY: all install uninstall clean distclean depend dummy
201
202 # 'all' target first in case the enclosing Makefile didn't define any target
203
204 all: Makefile
205
206 # Rule to rebuild the resource compiler
207
208 $(WRC) check_wrc:
209         cd $(TOPOBJDIR)/tools/wrc && $(MAKE) wrc
210
211 # Rule to rebuild the message compiler
212
213 $(WMC) check_wmc:
214         cd $(TOPOBJDIR)/tools/wmc && $(MAKE) wmc
215
216 # Rule to rebuild the 'makedep' program
217
218 $(MAKEDEP) check_makedep:
219         cd $(TOPOBJDIR)/tools && $(MAKE) makedep
220
221 # Rule to rebuild the 'winebuild' program
222
223 $(BUILD) check_winebuild:
224         cd $(TOPOBJDIR)/tools/winebuild && $(MAKE) winebuild
225
226 # Rules for makefile
227
228 Makefile: Makefile.in $(TOPSRCDIR)/configure
229         @echo Makefile is older than $?, please rerun $(TOPSRCDIR)/configure
230         @exit 1
231
232 # Rules for auto documentation
233
234 man: $(C_SRCS)
235         for i in $(C_SRCS); do $(C2MAN) -L -o $(TOPOBJDIR)/documentation/man3w -S3w $(DIVINCL) -D__WINE__ $(MANSPECS) $$i; done
236
237 doc-html: $(C_SRCS)
238         for i in $(C_SRCS); do $(C2MAN) -L -o $(TOPOBJDIR)/documentation/html -Th -iwindows.h  $(DIVINCL) -D__WINE__ $(MANSPECS) $$i; done
239
240 # Rule for linting
241
242 $(MODULE).ln : $(LINTS)
243         if test "$(LINTS)" ; \
244         then \
245                 $(LINT) $(ALLLINTFLAGS) -o$(MODULE) $(LINTS) ; \
246                 $(MV) llib-l$(MODULE).ln $(MODULE).ln ; \
247         else \
248                 $(LINT) $(ALLLINTFLAGS) -C$(MODULE) /dev/null ; \
249         fi
250
251 lint:: $(MODULE).ln
252
253 # Rules for Windows API checking
254
255 winapi_check::
256         $(WINAPI_CHECK) $(WINAPI_CHECK_FLAGS) $(WINAPI_CHECK_EXTRA_FLAGS) .
257
258 # Rules for dependencies
259
260 $(SUBDIRS:%=%/__depend__): $(MAKEDEP) dummy
261         cd `dirname $@` && $(MAKE) depend
262
263 depend: $(MAKEDEP) $(C_SRCS) $(RC_SRCS) $(EXTRA_SRCS) $(GEN_C_SRCS) $(SUBDIRS:%=%/__depend__)
264         $(MAKEDEP) $(DIVINCL) -C$(SRCDIR) $(C_SRCS) $(RC_SRCS) $(EXTRA_SRCS) -C. $(GEN_C_SRCS)
265
266 # Rules for cleaning
267
268 $(SUBDIRS:%=%/__clean__): dummy
269         cd `dirname $@` && $(MAKE) clean
270
271 $(EXTRASUBDIRS:%=%/__clean__): dummy
272         -cd `dirname $@` && $(RM) $(CLEAN_FILES)
273
274 clean:: $(SUBDIRS:%=%/__clean__) $(EXTRASUBDIRS:%=%/__clean__)
275         $(RM) $(CLEAN_FILES) $(GEN_C_SRCS) $(GEN_ASM_SRCS) $(RC_SRCS:.rc=.s) $(RC_SRCS:.rc=.h) $(MC_SRCS:.mc=.rc) $(PROGRAMS)
276
277 # Rules for installing
278
279 $(SUBDIRS:%=%/__install__): dummy
280         cd `dirname $@` && $(MAKE) install
281
282 $(SUBDIRS:%=%/__uninstall__): dummy
283         cd `dirname $@` && $(MAKE) uninstall
284
285 # Misc. rules
286
287 $(SPEC_SRCS:.spec=.spec.c): $(BUILD) $(TOPSRCDIR)/include/builtin16.h
288
289 $(GLUE:.c=.glue.c): $(BUILD) $(TOPSRCDIR)/include/builtin16.h
290
291 $(RC_SRCS:.rc=.s): $(WRC)
292
293 $(MC_SRCS:.mc=.rc): $(WMC)
294
295 $(SUBDIRS): dummy
296         @cd $@ && $(MAKE)
297
298 dummy:
299
300 # End of global rules