Updated.
[wine/wine64.git] / Make.rules.in
blob76189622fca2f49fa0bf4f0192eb77f6c42921df
1 # Global rules shared by all makefiles     -*-Makefile-*-
3 # Each individual makefile should 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 # C_SRCS       : C sources for the module (optional)
9 # ASM_SRCS     : assembly sources (optional)
10 # GEN_ASM_SRCS : generated assembly sources (optional)
11 # RC_SRCS      : resource source files (optional)
12 # SPEC_SRCS    : interface definition files (optional)
13 # GLUE         : C sources for which glue code needs to be generated (optional)
14 # EXTRA_SRCS   : extra source files for make depend (optional)
15 # EXTRA_OBJS   : extra object files (optional)
16 # WRCEXTRA     : extra wrc flags (e.g. '-p _SysRes') (optional)
18 # First some useful definitions
20 SHELL     = /bin/sh
21 CC        = @CC@
22 CPP       = @CPP@
23 CFLAGS    = @CFLAGS@
24 OPTIONS   = @OPTIONS@ -D_REENTRANT
25 X_CFLAGS  = @X_CFLAGS@
26 X_LIBS    = @X_LIBS@
27 XLIB      = @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@
28 DLL_LINK  = @DLL_LINK@
29 WINELIB   = $(WINESTUB) $(DLL_LINK)
30 LIBS      = @LIBS@
31 YACC      = @YACC@
32 LEX       = @LEX@
33 LEXLIB    = @LEXLIB@
34 RANLIB    = @RANLIB@
35 LN_S      = @LN_S@
36 DIVINCL   = -I$(SRCDIR) -I. -I$(TOPSRCDIR)/include -I$(TOPOBJDIR)/include
37 ALLCFLAGS = $(DIVINCL) $(CFLAGS) $(DEFS) $(OPTIONS) $(X_CFLAGS)
38 LDCOMBINE = ld -r
39 SONAME    = lib$(MODULE).so
40 LDSHARED  = @LDSHARED@
41 AR        = ar rc
42 RM        = rm -f
43 MV        = mv
44 MKDIR     = mkdir -p
45 C2MAN     = @C2MAN@
46 LDCONFIG  = @LDCONFIG@
47 MANSPECS  = -w $(TOPSRCDIR)/relay32/gdi32.spec \
48             -w $(TOPSRCDIR)/relay32/user32.spec \
49             -w $(TOPSRCDIR)/relay32/comctl32.spec \
50             -w $(TOPSRCDIR)/relay32/comdlg32.spec \
51             -w $(TOPSRCDIR)/relay32/kernel32.spec 
52 LINT      = @LINT@
53 LINTFLAGS = @LINTFLAGS@
54 ALLLINTFLAGS = $(LINTFLAGS) $(DEFS) $(OPTIONS) $(DIVINCL)
55 WINAPI_CHECK = $(TOPSRCDIR)/tools/winapi_check/winapi_check
56 BUILD     = $(TOPOBJDIR)/tools/build@PROGEXT@
57 MAKEDEP   = $(TOPOBJDIR)/tools/makedep@PROGEXT@
58 WRC       = $(TOPOBJDIR)/tools/wrc/wrc@PROGEXT@
59 WRCFLAGS  = -c
60 WINESTUB  = $(TOPOBJDIR)/library/winestub.o
61 DLLDIR    = $(TOPOBJDIR)/dlls
62 @SET_MAKE@
64 # Installation infos
66 INSTALL         = @INSTALL@
67 INSTALL_PROGRAM = @INSTALL_PROGRAM@
68 INSTALL_DATA    = @INSTALL_DATA@
69 prefix          = @prefix@
70 exec_prefix     = @exec_prefix@
71 bindir          = @bindir@
72 libdir          = @libdir@
73 infodir         = @infodir@
74 mandir          = @mandir@
75 prog_manext     = 1
76 conf_manext     = 5
77 includedir      = @includedir@/wine
79 OBJS = $(SPEC_SRCS:.spec=.spec.o) $(C_SRCS:.c=.o) $(GEN_ASM_SRCS:.s=.o) \
80        $(ASM_SRCS:.S=.o) $(RC_SRCS:.rc=.o) $(GLUE:.c=.glue.o) $(EXTRA_OBJS)
82 LINTS = $(C_SRCS:.c=.ln)
84 # DLL list
86 DLLS = \
87         avifil32 \
88         comctl32 \
89         comdlg32 \
90         dciman32 \
91         dplayx \
92         dsound \
93         icmp \
94         imagehlp \
95         imm32 \
96         joystick.drv \
97         lz32 \
98         mcianim.drv \
99         mciavi.drv \
100         mcicda.drv \
101         mciseq.drv \
102         mciwave.drv \
103         midimap.drv \
104         msacm \
105         msacm.drv \
106         msacm32 \
107         msnet32 \
108         msvfw32 \
109         odbc32 \
110         ole32 \
111         oleaut32 \
112         olecli32 \
113         oledlg \
114         olepro32 \
115         olesvr32 \
116         psapi \
117         rasapi32 \
118         setupx \
119         shell32 \
120         sound \
121         stress \
122         tapi32 \
123         version \
124         win32s \
125         win87em \
126         windebug \
127         wineoss.drv \
128         wing \
129         winmm \
130         winspool \
131         wnaspi32 \
132         wsock32
134 # Implicit rules
136 .SUFFIXES:
137 .SUFFIXES: .rc .res .spec .spec.c .spec.o .glue.c $(SUFFIXES)
139 .c.o:
140         $(CC) -c $(ALLCFLAGS) -o $*.o $<
142 .spec.c.spec.o:
143         $(CC) -c $(ALLCFLAGS) @GCC_NO_BUILTIN@ -o $*.spec.o $<
145 .s.o:
146         $(AS) -o $*.o $<  
148 .S.o:
149         $(CC) -c -o $*.o $<  
151 .rc.s:
152         $(WRC) $(WRCFLAGS) $(WRCEXTRA) $(DIVINCL) $<
154 .rc.h:
155         $(WRC) $(WRCFLAGS) $(WRCEXTRA) $(DIVINCL) -nh $<
157 .rc.res:
158         $(WRC) $(WRCFLAGS) $(WRCEXTRA) $(DIVINCL) -r $<
160 .res.s:
161         $(WRC) $(WRCFLAGS) $(WRCEXTRA) -b $<
163 .res.h:
164         $(WRC) $(WRCFLAGS) $(WRCEXTRA) -bnh $<
166 .spec.spec.c:
167         $(BUILD) @BUILDFLAGS@ -o $@ -spec $<
169 .c.glue.c:
170         $(BUILD) @BUILDFLAGS@ -o $@ -glue $<
172 .c.ln:
173         $(LINT) -c $(ALLLINTFLAGS) $< || ( $(RM) $@ && exit 1 )
175 .PHONY: all install uninstall clean distclean depend dummy
177 # Rule to rebuild the resource compiler
179 $(WRC) check_wrc:
180         cd $(TOPOBJDIR)/tools/wrc && $(MAKE) wrc@PROGEXT@
182 # Rule to rebuild the 'makedep' program
184 $(MAKEDEP) check_makedep:
185         cd $(TOPOBJDIR)/tools && $(MAKE) makedep@PROGEXT@
187 # Rule to rebuild the 'build' program
189 $(BUILD) checkbuild:
190         cd $(TOPOBJDIR)/tools && $(MAKE) build@PROGEXT@
192 # Rule to rebuild winestub.o
194 $(WINESTUB) check_winestub:
195         cd $(TOPOBJDIR)/library && $(MAKE) winestub.o
197 # Rule for main module
199 $(MODULE).o: $(OBJS) Makefile.in $(TOPSRCDIR)/Make.rules.in
200         $(LDCOMBINE) $(OBJS) -o $(MODULE).o
202 lib$(MODULE).so.$(SOVERSION): $(OBJS) Makefile.in $(TOPSRCDIR)/Make.rules.in
203         $(LDSHARED) $(OBJS) -o $@
205 lib$(MODULE).so: lib$(MODULE).so.$(SOVERSION)
206         $(RM) $@
207         $(LN_S) lib$(MODULE).so.$(SOVERSION) $@
209 lib$(MODULE).a: $(OBJS) Makefile.in $(TOPSRCDIR)/Make.rules.in
210         $(RM) $@
211         $(AR) $@ $(OBJS)
212         $(RANLIB) $@
214 # Rules for makefile
216 Makefile: Makefile.in $(TOPSRCDIR)/configure
217         @echo Makefile is older than $?, please rerun $(TOPSRCDIR)/configure
218         @exit 1
220 all: Makefile
222 # Rules for checking that no imports are missing
224 IMPORTLIBS = $(IMPORTS:%=$(DLLDIR)/lib%.$(LIBEXT))
226 checklink_so checklink_a: lib$(MODULE).$(LIBEXT) $(IMPORTLIBS)
227         $(CC) -o checklink $(TOPSRCDIR)/library/checklink.c -L. -l$(MODULE) -L$(DLLDIR) $(IMPORTS:%=-l%) -L$(TOPOBJDIR) -lwine $(LDOPTIONS) $(X_LIBS) $(XLIB) $(LIBS) && $(RM) checklink
229 checklink:: $(LIBEXT:%=checklink_%)
231 $(IMPORTLIBS): dummy
232         @cd $(DLLDIR) && $(MAKE) `basename $@`
234 # Rules for installation
236 install_so: lib$(MODULE).so.$(SOVERSION)
237         [ -d $(libdir) ] || $(MKDIR) $(libdir)
238         $(INSTALL_PROGRAM) lib$(MODULE).so.$(SOVERSION) $(libdir)/lib$(MODULE).so.$(SOVERSION)
239         cd $(libdir) && $(RM) lib$(MODULE).so && $(LN_S) lib$(MODULE).so.$(SOVERSION) lib$(MODULE).so
241 install_a: lib$(MODULE).a
242         [ -d $(libdir) ] || $(MKDIR) $(libdir)
243         $(INSTALL_DATA) lib$(MODULE).a $(libdir)/lib$(MODULE).a
245 uninstall_so uninstall_a:
246         cd $(libdir) && $(RM) lib$(MODULE).so lib$(MODULE).so.$(SOVERSION) lib$(MODULE).a
248 install:: $(LIBEXT:%=install_%)
250 uninstall:: $(LIBEXT:%=uninstall_%)
252 # Rules for auto documentation
254 man: $(C_SRCS)
255         for i in $(C_SRCS); do $(C2MAN) -L -o $(TOPOBJDIR)/documentation/man3w -S3w $(DIVINCL) -D__WINE__ $(MANSPECS) $$i; done
257 html: $(C_SRCS)
258         for i in $(C_SRCS); do $(C2MAN) -L -o $(TOPOBJDIR)/documentation/html -Th -iwindows.h  $(DIVINCL) -D__WINE__ $(MANSPECS) $$i; done
260 # Rule for linting
262 $(MODULE).ln : $(LINTS)
263         if test "$(LINTS)" ; \
264         then \
265                 $(LINT) $(ALLLINTFLAGS) -o$(MODULE) $(LINTS) ; \
266                 $(MV) llib-l$(MODULE).ln $(MODULE).ln ; \
267         else \
268                 $(LINT) $(ALLLINTFLAGS) -C$(MODULE) /dev/null ; \
269         fi
271 lint:: $(MODULE).ln
273 # Rules for Windows API checking
275 winapi_check::
276         $(WINAPI_CHECK) $(WINAPI_CHECK_FLAGS) $(WINAPI_CHECK_EXTRA_FLAGS) .
278 # Misc. rules
280 $(SPEC_SRCS:.spec=.spec.c): $(BUILD) $(TOPSRCDIR)/include/builtin16.h $(TOPSRCDIR)/include/builtin32.h
282 $(GLUE:.c=.glue.c): $(BUILD) $(TOPSRCDIR)/include/builtin16.h $(TOPSRCDIR)/include/builtin32.h
284 depend:: $(MAKEDEP) $(C_SRCS) $(RC_SRCS) $(EXTRA_SRCS)
285         $(MAKEDEP) $(DIVINCL) -C$(SRCDIR) $(C_SRCS) $(RC_SRCS) $(EXTRA_SRCS)
287 clean::
288         $(RM) *.o *.a *.so *.ln \#*\# *~ *% .\#* *.bak *.orig *.rej *.flc *.spec.c *.glue.c y.tab.c y.tab.h lex.yy.c core $(GEN_ASM_SRCS) $(RC_SRCS:.rc=.s) $(RC_SRCS:.rc=.h) $(PROGRAMS)
290 dummy:
292 # End of global rules