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)
48 MANSPECS = -w $(TOPSRCDIR)/relay32/gdi32.spec \
49 -w $(TOPSRCDIR)/relay32/user32.spec \
50 -w $(TOPSRCDIR)/relay32/comctl32.spec \
51 -w $(TOPSRCDIR)/relay32/comdlg32.spec \
52 -w $(TOPSRCDIR)/relay32/kernel32.spec
54 LINTFLAGS = @LINTFLAGS@
55 ALLLINTFLAGS = $(LINTFLAGS) $(DEFS) $(OPTIONS) $(DIVINCL)
56 WINAPI_CHECK = $(TOPSRCDIR)/tools/winapi_check/winapi_check
57 BUILD = $(TOPOBJDIR)/tools/winebuild/winebuild
58 MAKEDEP = $(TOPOBJDIR)/tools/makedep
59 WRC = $(TOPOBJDIR)/tools/wrc/wrc
60 WRCFLAGS = -c -s -p $*
61 WMC = $(TOPOBJDIR)/tools/wmc/wmc
62 DLLDIR = $(TOPOBJDIR)/dlls
68 INSTALL_PROGRAM = @INSTALL_PROGRAM@
69 INSTALL_DATA = @INSTALL_DATA@
71 exec_prefix = @exec_prefix@
78 includedir = @includedir@/wine
79 CLEAN_FILES = *.o *.a *.so *.ln \\\#*\\\# *~ *% .\\\#* *.bak *.orig *.rej \
80 *.flc *.spec.c *.glue.c y.tab.c y.tab.h lex.yy.c core
82 OBJS = $(SPEC_SRCS:.spec=.spec.o) $(C_SRCS:.c=.o) $(GEN_C_SRCS:.c=.o) $(GEN_ASM_SRCS:.s=.o) \
83 $(ASM_SRCS:.S=.o) $(RC_SRCS:.rc=.o) $(GLUE:.c=.glue.o) $(EXTRA_OBJS)
85 LINTS = $(C_SRCS:.c=.ln)
156 .SUFFIXES: .rc .res .spec .spec.c .spec.o .glue.c
159 $(CC) -c $(ALLCFLAGS) -o $*.o $<
162 $(CC) -c $(ALLCFLAGS) @GCC_NO_BUILTIN@ -o $*.spec.o $<
171 $(WRC) $(WRCFLAGS) $(WRCEXTRA) $(DIVINCL) $<
174 $(WRC) $(WRCFLAGS) $(WRCEXTRA) $(DIVINCL) -nh $<
177 $(WRC) $(WRCFLAGS) $(WRCEXTRA) $(DIVINCL) -r $<
180 $(WRC) $(WRCFLAGS) $(WRCEXTRA) -b $<
183 $(WRC) $(WRCFLAGS) $(WRCEXTRA) -bnh $<
186 $(BUILD) @DLLFLAGS@ -o $@ -spec $<
189 $(BUILD) @DLLFLAGS@ -o $@ -glue $<
192 $(LINT) -c $(ALLLINTFLAGS) $< || ( $(RM) $@ && exit 1 )
194 .PHONY: all install uninstall clean distclean depend dummy
196 # 'all' target first in case the enclosing Makefile didn't define any target
200 # Rule to rebuild the resource compiler
203 cd $(TOPOBJDIR)/tools/wrc && $(MAKE) wrc
205 # Rule to rebuild the message compiler
208 cd $(TOPOBJDIR)/tools/wmc && $(MAKE) wmc
210 # Rule to rebuild the 'makedep' program
212 $(MAKEDEP) check_makedep:
213 cd $(TOPOBJDIR)/tools && $(MAKE) makedep
215 # Rule to rebuild the 'winebuild' program
217 $(BUILD) check_winebuild:
218 cd $(TOPOBJDIR)/tools/winebuild && $(MAKE) winebuild
220 # Rule for main module
222 $(MODULE).o: $(OBJS) Makefile.in $(TOPSRCDIR)/Make.rules.in
223 $(LDCOMBINE) $(OBJS) -o $(MODULE).o
227 Makefile: Makefile.in $(TOPSRCDIR)/configure
228 @echo Makefile is older than $?, please rerun $(TOPSRCDIR)/configure
231 # Rules for auto documentation
234 for i in $(C_SRCS); do $(C2MAN) -L -o $(TOPOBJDIR)/documentation/man3w -S3w $(DIVINCL) -D__WINE__ $(MANSPECS) $$i; done
237 for i in $(C_SRCS); do $(C2MAN) -L -o $(TOPOBJDIR)/documentation/html -Th -iwindows.h $(DIVINCL) -D__WINE__ $(MANSPECS) $$i; done
241 $(MODULE).ln : $(LINTS)
242 if test "$(LINTS)" ; \
244 $(LINT) $(ALLLINTFLAGS) -o$(MODULE) $(LINTS) ; \
245 $(MV) llib-l$(MODULE).ln $(MODULE).ln ; \
247 $(LINT) $(ALLLINTFLAGS) -C$(MODULE) /dev/null ; \
252 # Rules for Windows API checking
255 $(WINAPI_CHECK) $(WINAPI_CHECK_FLAGS) $(WINAPI_CHECK_EXTRA_FLAGS) .
257 # Rules for dependencies
259 $(SUBDIRS:%=%/__depend__): $(MAKEDEP) dummy
260 cd `dirname $@` && $(MAKE) depend
262 depend: $(MAKEDEP) $(C_SRCS) $(RC_SRCS) $(EXTRA_SRCS) $(GEN_C_SRCS) $(SUBDIRS:%=%/__depend__)
263 $(MAKEDEP) $(DIVINCL) -C$(SRCDIR) $(C_SRCS) $(RC_SRCS) $(EXTRA_SRCS) -C. $(GEN_C_SRCS)
267 $(SUBDIRS:%=%/__clean__): dummy
268 cd `dirname $@` && $(MAKE) clean
270 $(EXTRASUBDIRS:%=%/__clean__): dummy
271 -cd `dirname $@` && $(RM) $(CLEAN_FILES)
273 clean:: $(SUBDIRS:%=%/__clean__) $(EXTRASUBDIRS:%=%/__clean__)
274 $(RM) $(CLEAN_FILES) $(GEN_C_SRCS) $(GEN_ASM_SRCS) $(RC_SRCS:.rc=.s) $(RC_SRCS:.rc=.h) $(PROGRAMS)
276 # Rules for installing
278 $(SUBDIRS:%=%/__install__): dummy
279 cd `dirname $@` && $(MAKE) install
281 $(SUBDIRS:%=%/__uninstall__): dummy
282 cd `dirname $@` && $(MAKE) uninstall
286 $(SPEC_SRCS:.spec=.spec.c): $(BUILD) $(TOPSRCDIR)/include/builtin16.h $(TOPSRCDIR)/include/builtin32.h
288 $(GLUE:.c=.glue.c): $(BUILD) $(TOPSRCDIR)/include/builtin16.h $(TOPSRCDIR)/include/builtin32.h
290 $(RC_SRCS:.rc=.s): $(WRC)
297 # End of global rules