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
24 OPTIONS = @OPTIONS@ -D_REENTRANT
27 XLIB = @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@
29 WINELIB = $(WINESTUB) $(DLL_LINK)
36 DIVINCL = -I$(SRCDIR) -I. -I$(TOPSRCDIR)/include -I$(TOPOBJDIR)/include
37 ALLCFLAGS = $(DIVINCL) $(CFLAGS) $(DEFS) $(OPTIONS) $(X_CFLAGS)
39 SONAME = lib$(MODULE).so
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
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@
60 WINESTUB = $(TOPOBJDIR)/library/winestub.o
61 DLLDIR = $(TOPOBJDIR)/dlls
67 INSTALL_PROGRAM = @INSTALL_PROGRAM@
68 INSTALL_DATA = @INSTALL_DATA@
70 exec_prefix = @exec_prefix@
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)
135 .SUFFIXES: .rc .res .spec .spec.c .spec.o .glue.c $(SUFFIXES)
138 $(CC) -c $(ALLCFLAGS) -o $*.o $<
141 $(CC) -c $(ALLCFLAGS) @GCC_NO_BUILTIN@ -o $*.spec.o $<
150 $(WRC) $(WRCFLAGS) $(WRCEXTRA) $(DIVINCL) $<
153 $(WRC) $(WRCFLAGS) $(WRCEXTRA) $(DIVINCL) -nh $<
156 $(WRC) $(WRCFLAGS) $(WRCEXTRA) $(DIVINCL) -r $<
159 $(WRC) $(WRCFLAGS) $(WRCEXTRA) -b $<
162 $(WRC) $(WRCFLAGS) $(WRCEXTRA) -bnh $<
165 $(BUILD) @BUILDFLAGS@ -o $@ -spec $<
168 $(BUILD) @BUILDFLAGS@ -o $@ -glue $<
171 $(LINT) -c $(ALLLINTFLAGS) $< || ( $(RM) $@ && exit 1 )
173 .PHONY: all install uninstall clean distclean depend dummy
175 # Rule to rebuild the resource compiler
178 cd $(TOPOBJDIR)/tools/wrc && $(MAKE) wrc@PROGEXT@
180 # Rule to rebuild the 'makedep' program
182 $(MAKEDEP) check_makedep:
183 cd $(TOPOBJDIR)/tools && $(MAKE) makedep@PROGEXT@
185 # Rule to rebuild the 'build' program
188 cd $(TOPOBJDIR)/tools && $(MAKE) build@PROGEXT@
190 # Rule to rebuild winestub.o
192 $(WINESTUB) check_winestub:
193 cd $(TOPOBJDIR)/library && $(MAKE) winestub.o
195 # Rule for main module
197 $(MODULE).o: $(OBJS) Makefile.in $(TOPSRCDIR)/Make.rules.in
198 $(LDCOMBINE) $(OBJS) -o $(MODULE).o
200 lib$(MODULE).so.$(SOVERSION): $(OBJS) Makefile.in $(TOPSRCDIR)/Make.rules.in
201 $(LDSHARED) $(OBJS) -o $@
203 lib$(MODULE).so: lib$(MODULE).so.$(SOVERSION)
205 $(LN_S) lib$(MODULE).so.$(SOVERSION) $@
207 lib$(MODULE).a: $(OBJS) Makefile.in $(TOPSRCDIR)/Make.rules.in
214 Makefile: Makefile.in $(TOPSRCDIR)/configure
215 @echo Makefile is older than $?, please rerun $(TOPSRCDIR)/configure
220 # Rules for checking that no imports are missing
222 IMPORTLIBS = $(IMPORTS:%=$(DLLDIR)/lib%.$(LIBEXT))
224 checklink_so checklink_a: lib$(MODULE).$(LIBEXT) $(IMPORTLIBS)
225 $(CC) -o checklink $(TOPSRCDIR)/library/checklink.c -L. -l$(MODULE) -L$(DLLDIR) $(IMPORTS:%=-l%) -L$(TOPOBJDIR) -lwine $(LDOPTIONS) $(X_LIBS) $(XLIB) $(LIBS) && $(RM) checklink
227 checklink:: $(LIBEXT:%=checklink_%)
230 @cd $(DLLDIR) && $(MAKE) `basename $@`
232 # Rules for installation
234 install_so: lib$(MODULE).so.$(SOVERSION)
235 [ -d $(libdir) ] || $(MKDIR) $(libdir)
236 $(INSTALL_PROGRAM) lib$(MODULE).so.$(SOVERSION) $(libdir)/lib$(MODULE).so.$(SOVERSION)
237 cd $(libdir) && $(RM) lib$(MODULE).so && $(LN_S) lib$(MODULE).so.$(SOVERSION) lib$(MODULE).so
239 install_a: lib$(MODULE).a
240 [ -d $(libdir) ] || $(MKDIR) $(libdir)
241 $(INSTALL_DATA) lib$(MODULE).a $(libdir)/lib$(MODULE).a
243 uninstall_so uninstall_a:
244 cd $(libdir) && $(RM) lib$(MODULE).so lib$(MODULE).so.$(SOVERSION) lib$(MODULE).a
246 install:: $(LIBEXT:%=install_%)
248 uninstall:: $(LIBEXT:%=uninstall_%)
250 # Rules for auto documentation
253 for i in $(C_SRCS); do $(C2MAN) -L -o $(TOPOBJDIR)/documentation/man3w -S3w $(DIVINCL) -D__WINE__ $(MANSPECS) $$i; done
256 for i in $(C_SRCS); do $(C2MAN) -L -o $(TOPOBJDIR)/documentation/html -Th -iwindows.h $(DIVINCL) -D__WINE__ $(MANSPECS) $$i; done
260 $(MODULE).ln : $(LINTS)
261 if test "$(LINTS)" ; \
263 $(LINT) $(ALLLINTFLAGS) -o$(MODULE) $(LINTS) ; \
264 $(MV) llib-l$(MODULE).ln $(MODULE).ln ; \
266 $(LINT) $(ALLLINTFLAGS) -C$(MODULE) /dev/null ; \
271 # Rules for Windows API checking
274 $(WINAPI_CHECK) $(WINAPI_CHECK_FLAGS) $(WINAPI_CHECK_EXTRA_FLAGS) .
278 $(SPEC_SRCS:.spec=.spec.c): $(BUILD) $(TOPSRCDIR)/include/builtin16.h $(TOPSRCDIR)/include/builtin32.h
280 $(GLUE:.c=.glue.c): $(BUILD) $(TOPSRCDIR)/include/builtin16.h $(TOPSRCDIR)/include/builtin32.h
282 depend:: $(MAKEDEP) $(C_SRCS) $(RC_SRCS) $(EXTRA_SRCS)
283 $(MAKEDEP) $(DIVINCL) -C$(SRCDIR) $(C_SRCS) $(RC_SRCS) $(EXTRA_SRCS)
286 $(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 # End of global rules