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