1 # Global rules shared by all makefiles -*-Makefile-*-
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
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
22 # First some useful definitions
28 OPTIONS = @OPTIONS@ -D_REENTRANT
31 XLIB = @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@
39 DIVINCL = -I$(SRCDIR) -I. -I$(TOPSRCDIR)/include -I$(TOPOBJDIR)/include
40 ALLCFLAGS = $(DIVINCL) $(CFLAGS) $(DEFS) $(OPTIONS) $(X_CFLAGS)
48 MANSPECS = -w $(TOPSRCDIR)/dlls/gdi/gdi32.spec \
49 -w $(TOPSRCDIR)/dlls/user/user32.spec \
50 -w $(TOPSRCDIR)/dlls/comctl32/comctl32.spec \
51 -w $(TOPSRCDIR)/dlls/comdlg32/comdlg32.spec \
52 -w $(TOPSRCDIR)/dlls/kernel/kernel32.spec
54 LINTFLAGS = @LINTFLAGS@
55 ALLLINTFLAGS = $(LINTFLAGS) $(DEFS) $(OPTIONS) $(DIVINCL)
56 WINAPI_CHECK = $(TOPSRCDIR)/tools/winapi_check/winapi_check
57 WINEBUILD = $(TOPOBJDIR)/tools/winebuild/winebuild
58 MAKEDEP = $(TOPOBJDIR)/tools/makedep
59 WRC = $(TOPOBJDIR)/tools/wrc/wrc
60 WMC = $(TOPOBJDIR)/tools/wmc/wmc
61 DLLDIR = $(TOPOBJDIR)/dlls
67 INSTALL_PROGRAM = @INSTALL_PROGRAM@
68 INSTALL_DATA = @INSTALL_DATA@
70 exec_prefix = @exec_prefix@
77 includedir = @includedir@/wine
78 CLEAN_FILES = *.o *.a *.so *.ln \\\#*\\\# *~ *% .\\\#* *.bak *.orig *.rej \
79 *.flc *.spec.c *.glue.c y.tab.c y.tab.h lex.yy.c core
81 OBJS = $(SPEC_SRCS:.spec=.spec.o) $(C_SRCS:.c=.o) $(GEN_C_SRCS:.c=.o) $(GEN_ASM_SRCS:.s=.o) \
82 $(ASM_SRCS:.S=.o) $(RC16_SRCS:.rc16=.o) $(GLUE:.c=.glue.o) $(EXTRA_OBJS)
84 LINTS = $(C_SRCS:.c=.ln)
157 .SUFFIXES: .mc .rc .rc16 .res .spec .spec.c .spec.o .glue.c
160 $(CC) -c $(ALLCFLAGS) -o $*.o $<
163 $(CC) -c $(ALLCFLAGS) @GCC_NO_BUILTIN@ -o $*.spec.o $<
172 LD_LIBRARY_PATH="$(TOPOBJDIR):$$LD_LIBRARY_PATH" $(WMC) -i -H /dev/null -o $@ $<
175 LD_LIBRARY_PATH="$(TOPOBJDIR):$$LD_LIBRARY_PATH" $(WRC) $(WRCFLAGS) $(DIVINCL) -o $@ -w16 -m -c -p `basename $*` -s $<
178 LD_LIBRARY_PATH="$(TOPOBJDIR):$$LD_LIBRARY_PATH" $(WRC) $(WRCFLAGS) $(DIVINCL) -o $@ -r $<
181 LD_LIBRARY_PATH="$(TOPOBJDIR):$$LD_LIBRARY_PATH" $(WINEBUILD) @DLLFLAGS@ -o $@ -spec $<
184 LD_LIBRARY_PATH="$(TOPOBJDIR):$$LD_LIBRARY_PATH" $(WINEBUILD) @DLLFLAGS@ -o $@ -glue $<
187 $(LINT) -c $(ALLLINTFLAGS) $< || ( $(RM) $@ && exit 1 )
189 .PHONY: all install uninstall clean distclean depend dummy
191 # 'all' target first in case the enclosing Makefile didn't define any target
195 # Rule to rebuild the resource compiler
198 cd $(TOPOBJDIR)/tools/wrc && $(MAKE) wrc
200 # Rule to rebuild the message compiler
203 cd $(TOPOBJDIR)/tools/wmc && $(MAKE) wmc
205 # Rule to rebuild the 'makedep' program
208 cd $(TOPOBJDIR)/tools && $(MAKE) makedep
210 # Rule to rebuild the 'winebuild' program
213 cd $(TOPOBJDIR)/tools/winebuild && $(MAKE) winebuild
215 # Rule for main module spec file
217 $(MODULE).spec.c: $(RC_SRCS:.rc=.res)
221 Makefile: Makefile.in $(TOPSRCDIR)/configure
222 @echo Makefile is older than $?, please rerun $(TOPSRCDIR)/configure
225 # Rules for auto documentation
228 for i in $(C_SRCS); do $(C2MAN) -L -o $(TOPOBJDIR)/documentation/man3w -S3w $(DIVINCL) -D__WINE__ $(MANSPECS) $$i; done
231 for i in $(C_SRCS); do $(C2MAN) -L -o $(TOPOBJDIR)/documentation/html -Th -iwindows.h $(DIVINCL) -D__WINE__ $(MANSPECS) $$i; done
235 $(MODULE).ln : $(LINTS)
236 if test "$(LINTS)" ; \
238 $(LINT) $(ALLLINTFLAGS) -o$(MODULE) $(LINTS) ; \
239 $(MV) llib-l$(MODULE).ln $(MODULE).ln ; \
241 $(LINT) $(ALLLINTFLAGS) -C$(MODULE) /dev/null ; \
246 # Rules for Windows API checking
249 $(WINAPI_CHECK) $(WINAPI_CHECK_FLAGS) $(WINAPI_CHECK_EXTRA_FLAGS) .
251 # Rules for dependencies
253 $(SUBDIRS:%=%/__depend__): $(MAKEDEP) dummy
254 cd `dirname $@` && $(MAKE) depend
256 depend: $(MAKEDEP) $(C_SRCS) $(RC_SRCS) $(RC16_SRCS) $(EXTRA_SRCS) $(GEN_C_SRCS) $(SUBDIRS:%=%/__depend__)
257 $(MAKEDEP) $(DIVINCL) -C$(SRCDIR) $(C_SRCS) $(RC_SRCS) $(RC16_SRCS) $(EXTRA_SRCS) -C. $(GEN_C_SRCS)
261 $(SUBDIRS:%=%/__clean__): dummy
262 cd `dirname $@` && $(MAKE) clean
264 $(EXTRASUBDIRS:%=%/__clean__): dummy
265 -cd `dirname $@` && $(RM) $(CLEAN_FILES)
267 clean:: $(SUBDIRS:%=%/__clean__) $(EXTRASUBDIRS:%=%/__clean__)
268 $(RM) $(CLEAN_FILES) $(GEN_C_SRCS) $(GEN_ASM_SRCS) $(RC_SRCS:.rc=.res) $(RC16_SRCS:.rc16=.s) $(MC_SRCS:.mc=.rc) $(PROGRAMS)
270 # Rules for installing
272 $(SUBDIRS:%=%/__install__): dummy
273 cd `dirname $@` && $(MAKE) install
275 $(SUBDIRS:%=%/__uninstall__): dummy
276 cd `dirname $@` && $(MAKE) uninstall
280 $(SPEC_SRCS:.spec=.spec.c): $(WINEBUILD) $(TOPSRCDIR)/include/builtin16.h
282 $(GLUE:.c=.glue.c): $(WINEBUILD) $(TOPSRCDIR)/include/builtin16.h
284 $(RC_SRCS:.rc=.res) $(RC16_SRCS:.rc16=.s): $(WRC)
286 $(MC_SRCS:.mc=.rc): $(WMC)
293 # End of global rules