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 # WRCEXTRA : extra wrc flags (e.g. '-p _SysRes')
20 # SUBDIRS : subdirectories that contain a Makefile
21 # EXTRASUBDIRS : subdirectories that do not contain a Makefile
23 # First some useful definitions
29 OPTIONS = @OPTIONS@ -D_REENTRANT
32 XLIB = @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@
40 DIVINCL = -I$(SRCDIR) -I. -I$(TOPSRCDIR)/include -I$(TOPOBJDIR)/include
41 ALLCFLAGS = $(DIVINCL) $(CFLAGS) $(DEFS) $(OPTIONS) $(X_CFLAGS)
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
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
69 INSTALL_PROGRAM = @INSTALL_PROGRAM@
70 INSTALL_DATA = @INSTALL_DATA@
72 exec_prefix = @exec_prefix@
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
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)
86 LINTS = $(C_SRCS:.c=.ln)
159 .SUFFIXES: .mc .rc .res .spec .spec.c .spec.o .glue.c
162 $(CC) -c $(ALLCFLAGS) -o $*.o $<
165 $(CC) -c $(ALLCFLAGS) @GCC_NO_BUILTIN@ -o $*.spec.o $<
174 LD_LIBRARY_PATH="$(TOPOBJDIR):$$LD_LIBRARY_PATH" $(WMC) -i -H /dev/null -o $@ $<
177 $(WRC) $(WRCFLAGS) $(WRCEXTRA) $(DIVINCL) $<
180 $(WRC) $(WRCFLAGS) $(WRCEXTRA) $(DIVINCL) -nh $<
183 $(WRC) $(WRCFLAGS) $(WRCEXTRA) $(DIVINCL) -r $<
186 $(WRC) $(WRCFLAGS) $(WRCEXTRA) -b $<
189 $(WRC) $(WRCFLAGS) $(WRCEXTRA) -bnh $<
192 $(BUILD) @DLLFLAGS@ -o $@ -spec $<
195 $(BUILD) @DLLFLAGS@ -o $@ -glue $<
198 $(LINT) -c $(ALLLINTFLAGS) $< || ( $(RM) $@ && exit 1 )
200 .PHONY: all install uninstall clean distclean depend dummy
202 # 'all' target first in case the enclosing Makefile didn't define any target
206 # Rule to rebuild the resource compiler
209 cd $(TOPOBJDIR)/tools/wrc && $(MAKE) wrc
211 # Rule to rebuild the message compiler
214 cd $(TOPOBJDIR)/tools/wmc && $(MAKE) wmc
216 # Rule to rebuild the 'makedep' program
218 $(MAKEDEP) check_makedep:
219 cd $(TOPOBJDIR)/tools && $(MAKE) makedep
221 # Rule to rebuild the 'winebuild' program
223 $(BUILD) check_winebuild:
224 cd $(TOPOBJDIR)/tools/winebuild && $(MAKE) winebuild
228 Makefile: Makefile.in $(TOPSRCDIR)/configure
229 @echo Makefile is older than $?, please rerun $(TOPSRCDIR)/configure
232 # Rules for auto documentation
235 for i in $(C_SRCS); do $(C2MAN) -L -o $(TOPOBJDIR)/documentation/man3w -S3w $(DIVINCL) -D__WINE__ $(MANSPECS) $$i; done
238 for i in $(C_SRCS); do $(C2MAN) -L -o $(TOPOBJDIR)/documentation/html -Th -iwindows.h $(DIVINCL) -D__WINE__ $(MANSPECS) $$i; done
242 $(MODULE).ln : $(LINTS)
243 if test "$(LINTS)" ; \
245 $(LINT) $(ALLLINTFLAGS) -o$(MODULE) $(LINTS) ; \
246 $(MV) llib-l$(MODULE).ln $(MODULE).ln ; \
248 $(LINT) $(ALLLINTFLAGS) -C$(MODULE) /dev/null ; \
253 # Rules for Windows API checking
256 $(WINAPI_CHECK) $(WINAPI_CHECK_FLAGS) $(WINAPI_CHECK_EXTRA_FLAGS) .
258 # Rules for dependencies
260 $(SUBDIRS:%=%/__depend__): $(MAKEDEP) dummy
261 cd `dirname $@` && $(MAKE) depend
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)
268 $(SUBDIRS:%=%/__clean__): dummy
269 cd `dirname $@` && $(MAKE) clean
271 $(EXTRASUBDIRS:%=%/__clean__): dummy
272 -cd `dirname $@` && $(RM) $(CLEAN_FILES)
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)
277 # Rules for installing
279 $(SUBDIRS:%=%/__install__): dummy
280 cd `dirname $@` && $(MAKE) install
282 $(SUBDIRS:%=%/__uninstall__): dummy
283 cd `dirname $@` && $(MAKE) uninstall
287 $(SPEC_SRCS:.spec=.spec.c): $(BUILD) $(TOPSRCDIR)/include/builtin16.h
289 $(GLUE:.c=.glue.c): $(BUILD) $(TOPSRCDIR)/include/builtin16.h
291 $(RC_SRCS:.rc=.s): $(WRC)
293 $(MC_SRCS:.mc=.rc): $(WMC)
300 # End of global rules