Include protection for <unistd.h>, <sys/types.h> and <sys/stat.h>.
[wine.git] / Make.rules.in
blob40c840d1c07c35c62f113eccff7a284b39fedf26
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 # EXTRA_SRCS   : extra source files for make depend
17 # EXTRA_OBJS   : extra object files
18 # IMPORTS      : dlls to import
19 # DELAYIMPORTS : dlls to import in delayed mode
20 # SUBDIRS      : subdirectories that contain a Makefile
21 # EXTRASUBDIRS : subdirectories that do not contain a Makefile
22 # INSTALLSUBDIRS : subdirectories to run make install/uninstall into
24 # First some useful definitions
26 SHELL     = /bin/sh
27 CC        = @CC@
28 CPP       = @CPP@
29 CFLAGS    = @CFLAGS@ $(EXTRACFLAGS)
30 OPTIONS   = @OPTIONS@ -D_REENTRANT
31 X_CFLAGS  = @X_CFLAGS@
32 X_LIBS    = @X_LIBS@
33 XLIB      = @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@
34 LIBS      = @LIBS@
35 YACC      = @YACC@
36 LEX       = @LEX@
37 LEXLIB    = @LEXLIB@
38 EXEEXT    = @EXEEXT@
39 OBJEXT    = @OBJEXT@
40 LIBEXT    = @LIBEXT@
41 DLLEXT    = @DLLEXT@
42 LDSHARED  = @LDSHARED@
43 DLLWRAP   = @DLLWRAP@
44 DLLWRAPFLAGS = --add-stdcall-alias
45 AR        = @AR@ rc
46 RANLIB    = @RANLIB@
47 STRIP     = @STRIP@
48 WINDRES   = @WINDRES@
49 LN        = @LN@
50 LN_S      = @LN_S@
51 TOOLSDIR  = @TOOLSDIR@
52 DIVINCL   = -I$(SRCDIR) -I. -I$(TOPSRCDIR)/include -I$(TOPOBJDIR)/include $(EXTRAINCL)
53 ALLCFLAGS = $(DIVINCL) $(CFLAGS) $(DEFS) $(OPTIONS) $(X_CFLAGS)
54 LD        = @LD@
55 LDFLAGS   = @LDFLAGS@
56 LDCOMBINE = $(LD) -r
57 RM        = rm -f
58 MV        = mv
59 C2MAN     = @C2MAN@
60 MANSPECS  = -w $(TOPSRCDIR)/dlls/gdi/gdi32.spec \
61             -w $(TOPSRCDIR)/dlls/user/user32.spec \
62             -w $(TOPSRCDIR)/dlls/comctl32/comctl32.spec \
63             -w $(TOPSRCDIR)/dlls/commdlg/comdlg32.spec \
64             -w $(TOPSRCDIR)/dlls/kernel/kernel32.spec
65 LINT      = @LINT@
66 LINTFLAGS = @LINTFLAGS@
67 ALLLINTFLAGS = $(LINTFLAGS) $(DEFS) $(OPTIONS) $(DIVINCL)
68 MKINSTALLDIRS= $(TOPSRCDIR)/tools/mkinstalldirs
69 WINAPI_CHECK = $(TOPSRCDIR)/tools/winapi_check/winapi_check
70 WINEWRAPPER  = $(TOPSRCDIR)/tools/winewrapper
71 RUNTEST      = $(TOPSRCDIR)/programs/winetest/runtest
72 WINEBUILD    = $(TOOLSDIR)/tools/winebuild/winebuild
73 MAKEDEP      = $(TOOLSDIR)/tools/makedep
74 WRC          = $(TOOLSDIR)/tools/wrc/wrc
75 WMC          = $(TOOLSDIR)/tools/wmc/wmc
76 LDPATH    = @LDPATH@
77 DLLDIR    = $(TOPOBJDIR)/dlls
78 LIBWINE   = -L$(TOPOBJDIR)/library -lwine
79 LIBTSX11  = -L$(TOPOBJDIR)/tsx11 -lwine_tsx11
80 LIBUNICODE= -L$(TOPOBJDIR)/unicode -lwine_unicode
81 LIBUUID   = -L$(TOPOBJDIR)/ole -lwine_uuid
83 @SET_MAKE@
85 # Installation infos
87 INSTALL         = @INSTALL@ $(INSTALL_FLAGS)
88 INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(INSTALL_PROGRAM_FLAGS)
89 INSTALL_SCRIPT  = @INSTALL_SCRIPT@ $(INSTALL_SCRIPT_FLAGS)
90 INSTALL_DATA    = @INSTALL_DATA@ $(INSTALL_DATA_FLAGS)
91 prefix          = @prefix@
92 exec_prefix     = @exec_prefix@
93 bindir          = @bindir@
94 libdir          = @libdir@
95 datadir         = @datadir@
96 infodir         = @infodir@
97 mandir          = @mandir@
98 sysconfdir      = @sysconfdir@
99 includedir      = @includedir@/wine
100 dlldir          = @libdir@/wine
101 prog_manext     = 1
102 conf_manext     = 5
103 CLEAN_FILES     = *.o *.a *.so *.ln *.$(LIBEXT) \\\#*\\\# *~ *% .\\\#* *.bak *.orig *.rej \
104                   *.flc *.spec.c *.spec.def *.glue.c *.dbg.c y.tab.c y.tab.h @LEX_OUTPUT_ROOT@.c core
106 OBJS = $(C_SRCS:.c=.o) $(GEN_C_SRCS:.c=.o) $(GEN_ASM_SRCS:.s=.o) $(ASM_SRCS:.S=.o) $(EXTRA_OBJS)
108 RCOBJS = $(RC_SRCS:.rc=.res.o)
109 LINTS  = $(C_SRCS:.c=.ln)
111 # Implicit rules
113 .SUFFIXES: .mc .rc .mc.rc .res .res.o .spec .spec.c .spec.def .pl .ok
115 .c.o:
116         $(CC) -c $(ALLCFLAGS) -o $@ $<
118 .s.o:
119         $(AS) -o $@ $<
121 .S.o:
122         $(CC) -c -o $@ $<
124 .mc.mc.rc:
125         $(LDPATH) $(WMC) -i -H /dev/null -o $@ $<
127 .rc.res:
128         $(LDPATH) $(WRC) $(WRCFLAGS) $(DIVINCL) -o $@ -r $<
130 .res.res.o:
131         $(WINDRES) -i $< -o $@
133 .spec.spec.c:
134         $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -M $(MODULE) -spec $<
136 .spec.spec.def:
137         $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -def $<
139 .c.ln:
140         $(LINT) -c $(ALLLINTFLAGS) $< || ( $(RM) $@ && exit 1 )
142 .c.ok:
143         $(RUNTEST) $(RUNTESTFLAGS) $< && touch $@
145 .pl.ok:
146         $(RUNTEST) $(RUNTESTFLAGS) $< && touch $@
148 # 'all' target first in case the enclosing Makefile didn't define any target
150 all: Makefile
152 filter:
153         @$(TOPSRCDIR)/tools/winapi/make_filter --make $(MAKE) all
155 .PHONY: all filter
157 # Rule for main module debug channels
159 $(MODULE).dbg.c: $(C_SRCS) $(WINEBUILD)
160         $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -debug -C$(SRCDIR) $(C_SRCS)
162 # Rule for 16-bit glue
164 $(MODULE).glue.c: $(C_SRCS) $(WINEBUILD)
165         $(LDPATH) $(WINEBUILD) $(DEFS) -o $@ -glue -C$(SRCDIR) $(C_SRCS)
167 # Rule to rebuild the tools
169 $(MAKEDEP) $(WINEBUILD) $(WMC) $(WRC):
170         cd $(TOOLSDIR)/tools && $(MAKE) `basename $@`
172 # Rules for makefile
174 Makefile: Makefile.in $(TOPSRCDIR)/configure
175         @echo Makefile is older than $?, please rerun $(TOPSRCDIR)/configure
176         @exit 1
178 # Rules for auto documentation
180 $(SUBDIRS:%=%/__man__): dummy
181         cd `dirname $@` && $(MAKE) man
183 man: $(C_SRCS) $(SUBDIRS:%=%/__man__)
184         if [ -n "$(C_SRCS)" ]; then $(MKINSTALLDIRS) $(TOPOBJDIR)/documentation/man3w; for i in $(C_SRCS); do $(C2MAN) -L -o $(TOPOBJDIR)/documentation/man3w -S3w $(DIVINCL) -D__WINE__ $(MANSPECS) $$i; done; fi
186 $(SUBDIRS:%=%/__doc_html__): dummy
187         cd `dirname $@` && $(MAKE) doc-html
189 doc-html: $(C_SRCS) $(SUBDIRS:%=%/__doc_html__)
190         if [ -n "$(C_SRCS)" ]; then $(MKINSTALLDIRS) $(TOPOBJDIR)/documentation/html; for i in $(C_SRCS); do $(C2MAN) -L -o $(TOPOBJDIR)/documentation/html -Th -iwindows.h  $(DIVINCL) -D__WINE__ $(MANSPECS) $$i; done; fi
192 .PHONY: man doc-html $(SUBDIRS:%=%/__man__) $(SUBDIRS:%=%/__doc_html__)
194 # Rule for linting
196 $(MODULE).ln : $(LINTS)
197         if test "$(LINTS)" ; \
198         then \
199                 $(LINT) $(ALLLINTFLAGS) -o$(MODULE) $(LINTS) ; \
200                 $(MV) llib-l$(MODULE).ln $(MODULE).ln ; \
201         else \
202                 $(LINT) $(ALLLINTFLAGS) -C$(MODULE) /dev/null ; \
203         fi
205 lint:: $(MODULE).ln
207 # Rules for Windows API checking
209 winapi_check:: dummy
210         $(WINAPI_CHECK) $(WINAPI_CHECK_FLAGS) $(WINAPI_CHECK_EXTRA_FLAGS) .
212 .PHONY: winapi_check
214 # Rules for dependencies
216 $(SUBDIRS:%=%/__depend__): $(MAKEDEP) dummy
217         cd `dirname $@` && $(MAKE) depend
219 depend: $(MAKEDEP) $(SUBDIRS:%=%/__depend__)
220         $(MAKEDEP) $(DIVINCL) -C$(SRCDIR) $(C_SRCS) $(RC_SRCS) $(RC_SRCS16) $(MC_SRCS) $(EXTRA_SRCS)
222 .PHONY: depend $(SUBDIRS:%=%/__depend__)
224 # Rules for cleaning
226 $(SUBDIRS:%=%/__clean__): dummy
227         cd `dirname $@` && $(MAKE) clean
229 $(SUBDIRS:%=%/__testclean__): dummy
230         cd `dirname $@` && $(MAKE) testclean
232 $(EXTRASUBDIRS:%=%/__clean__): dummy
233         -cd `dirname $@` && $(RM) $(CLEAN_FILES)
235 testclean:: $(SUBDIRS:%=%/__testclean__)
237 clean:: $(SUBDIRS:%=%/__clean__) $(EXTRASUBDIRS:%=%/__clean__)
238         $(RM) $(CLEAN_FILES) $(GEN_C_SRCS) $(GEN_ASM_SRCS) $(RC_SRCS:.rc=.res) $(RC_SRCS16:.rc=.res) $(MC_SRCS:.mc=.mc.rc) $(PROGRAMS)
240 .PHONY: clean testclean $(SUBDIRS:%=%/__clean__) $(SUBDIRS:%=%/__testclean__) $(EXTRASUBDIRS:%=%/__clean__)
242 # Rules for installing
244 $(INSTALLSUBDIRS:%=%/__install__): dummy
245         cd `dirname $@` && $(MAKE) install
247 $(INSTALLSUBDIRS:%=%/__uninstall__): dummy
248         cd `dirname $@` && $(MAKE) uninstall
250 install:: $(INSTALLSUBDIRS:%=%/__install__)
252 uninstall:: $(INSTALLSUBDIRS:%=%/__uninstall__)
254 .PHONY: install uninstall $(INSTALLSUBDIRS:%=%/__install__) $(INSTALLSUBDIRS:%=%/__uninstall__)
256 # Rules for checking that no imports are missing
258 $(SUBDIRS:%=%/__checklink__): dummy
259         @cd `dirname $@` && $(MAKE) checklink
261 .PHONY: checklink $(SUBDIRS:%=%/__checklink__)
263 # Rules for testing
265 $(SUBDIRS:%=%/__test__): dummy
266         @cd `dirname $@` && $(MAKE) test
268 .PHONY: check test $(SUBDIRS:%=%/__test__)
270 # Misc. rules
272 $(SPEC_SRCS:.spec=.spec.c): $(WINEBUILD)
274 $(RC_SRCS:.rc=.res): $(WRC)
276 $(RC_SRCS16:.rc=.res): $(WRC)
278 $(MC_SRCS:.mc=.mc.rc): $(WMC)
280 $(SUBDIRS): dummy
281         @cd $@ && $(MAKE)
283 dummy:
285 .PHONY: dummy $(SUBDIRS)
287 # End of global rules