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_ASM_SRCS : generated assembly sources
13 # RC_SRCS : resource source files
14 # SPEC_SRCS : interface definition files
15 # GLUE : C sources for which glue code needs to be generated
16 # EXTRA_SRCS : extra source files for make depend
17 # EXTRA_OBJS : extra object files
18 # WRCEXTRA : extra wrc flags (e.g. '-p _SysRes')
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)
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 DLLDIR = $(TOPOBJDIR)/dlls
66 INSTALL_PROGRAM = @INSTALL_PROGRAM@
67 INSTALL_DATA = @INSTALL_DATA@
69 exec_prefix = @exec_prefix@
76 includedir = @includedir@/wine
77 CLEAN_FILES = *.o *.a *.so *.ln \\\#*\\\# *~ *% .\\\#* *.bak *.orig *.rej *.flc \
78 *.spec.c *.glue.c y.tab.c y.tab.h lex.yy.c core
80 OBJS = $(SPEC_SRCS:.spec=.spec.o) $(C_SRCS:.c=.o) $(GEN_ASM_SRCS:.s=.o) \
81 $(ASM_SRCS:.S=.o) $(RC_SRCS:.rc=.o) $(GLUE:.c=.glue.o) $(EXTRA_OBJS)
83 LINTS = $(C_SRCS:.c=.ln)
152 .SUFFIXES: .rc .res .spec .spec.c .spec.o .glue.c $(SUFFIXES)
155 $(CC) -c $(ALLCFLAGS) -o $*.o $<
158 $(CC) -c $(ALLCFLAGS) @GCC_NO_BUILTIN@ -o $*.spec.o $<
167 $(WRC) $(WRCFLAGS) $(WRCEXTRA) $(DIVINCL) $<
170 $(WRC) $(WRCFLAGS) $(WRCEXTRA) $(DIVINCL) -nh $<
173 $(WRC) $(WRCFLAGS) $(WRCEXTRA) $(DIVINCL) -r $<
176 $(WRC) $(WRCFLAGS) $(WRCEXTRA) -b $<
179 $(WRC) $(WRCFLAGS) $(WRCEXTRA) -bnh $<
182 $(BUILD) @BUILDFLAGS@ -o $@ -spec $<
185 $(BUILD) @BUILDFLAGS@ -o $@ -glue $<
188 $(LINT) -c $(ALLLINTFLAGS) $< || ( $(RM) $@ && exit 1 )
190 .PHONY: all install uninstall clean distclean depend dummy
192 # 'all' target first in case the enclosing Makefile didn't define any target
196 # Rule to rebuild the resource compiler
199 cd $(TOPOBJDIR)/tools/wrc && $(MAKE) wrc@PROGEXT@
201 # Rule to rebuild the 'makedep' program
203 $(MAKEDEP) check_makedep:
204 cd $(TOPOBJDIR)/tools && $(MAKE) makedep@PROGEXT@
206 # Rule to rebuild the 'build' program
209 cd $(TOPOBJDIR)/tools && $(MAKE) build@PROGEXT@
211 # Rule for main module
213 $(MODULE).o: $(OBJS) Makefile.in $(TOPSRCDIR)/Make.rules.in
214 $(LDCOMBINE) $(OBJS) -o $(MODULE).o
218 Makefile: Makefile.in $(TOPSRCDIR)/configure
219 @echo Makefile is older than $?, please rerun $(TOPSRCDIR)/configure
222 # Rules for auto documentation
225 for i in $(C_SRCS); do $(C2MAN) -L -o $(TOPOBJDIR)/documentation/man3w -S3w $(DIVINCL) -D__WINE__ $(MANSPECS) $$i; done
228 for i in $(C_SRCS); do $(C2MAN) -L -o $(TOPOBJDIR)/documentation/html -Th -iwindows.h $(DIVINCL) -D__WINE__ $(MANSPECS) $$i; done
232 $(MODULE).ln : $(LINTS)
233 if test "$(LINTS)" ; \
235 $(LINT) $(ALLLINTFLAGS) -o$(MODULE) $(LINTS) ; \
236 $(MV) llib-l$(MODULE).ln $(MODULE).ln ; \
238 $(LINT) $(ALLLINTFLAGS) -C$(MODULE) /dev/null ; \
243 # Rules for Windows API checking
246 $(WINAPI_CHECK) $(WINAPI_CHECK_FLAGS) $(WINAPI_CHECK_EXTRA_FLAGS) .
248 # Rules for dependencies
250 $(SUBDIRS:%=%/__depend__): $(MAKEDEP) dummy
251 cd `dirname $@` && $(MAKE) depend
253 depend: $(MAKEDEP) $(C_SRCS) $(RC_SRCS) $(EXTRA_SRCS) $(SUBDIRS:%=%/__depend__)
254 $(MAKEDEP) $(DIVINCL) -C$(SRCDIR) $(C_SRCS) $(RC_SRCS) $(EXTRA_SRCS)
258 $(SUBDIRS:%=%/__clean__): dummy
259 cd `dirname $@` && $(MAKE) clean
261 $(EXTRASUBDIRS:%=%/__clean__): dummy
262 -cd `dirname $@` && $(RM) $(CLEAN_FILES)
264 clean:: $(SUBDIRS:%=%/__clean__) $(EXTRASUBDIRS:%=%/__clean__)
265 $(RM) $(CLEAN_FILES) $(GEN_ASM_SRCS) $(RC_SRCS:.rc=.s) $(RC_SRCS:.rc=.h) $(PROGRAMS)
269 $(SPEC_SRCS:.spec=.spec.c): $(BUILD) $(TOPSRCDIR)/include/builtin16.h $(TOPSRCDIR)/include/builtin32.h
271 $(GLUE:.c=.glue.c): $(BUILD) $(TOPSRCDIR)/include/builtin16.h $(TOPSRCDIR)/include/builtin32.h
273 $(RC_SRCS:.rc=.s): $(WRC)
280 # End of global rules