automatically detect msys without generating ugly error message on non-msys system
[reactos.git] / reactos / Makefile
1 # Well-known targets:
2 #
3 # all (default target)
4 # This target builds all of ReactOS.
5 #
6 # module
7 # These targets builds a single module. Replace module with the name of
8 # the module you want to build.
9 #
10 # bootcd
11 # This target builds an ISO (ReactOS.iso) from which ReactOS can be booted
12 # and installed.
13 #
14 # livecd
15 # This target builds an ISO (ReactOS-Live.iso) from which ReactOS can be
16 # booted, but not installed.
17 #
18 # install
19 # This target installs all of ReactOS to a location specified by the
20 # ROS_INSTALL environment variable.
21 #
22 # module_install
23 # These targets installs a single module to a location specified by the
24 # ROS_INSTALL environment variable. Replace module with the name of the
25 # module you want to install.
26 #
27 # clean
28 # This target cleans (deletes) all files that are generated when building
29 # ReactOS.
30 #
31 # module_clean
32 # These targets cleans (deletes) files that are generated when building a
33 # single module. Replace module with the name of the module you want to
34 # clean.
35 #
36 # depends
37 # This target does a complete dependency check of the ReactOS codebase.
38 # This can require several minutes to complete. If you only need to check
39 # dependencies for a single or few modules then you can use the
40 # module_depends targets instead. This target can also repair a damaged or
41 # missing makefile.auto if needed.
42 #
43 # module_depends
44 # These targets do a dependency check of individual modules. Replace module
45 # with the name of the module for which you want to check dependencies.
46 # This is faster than the depends target which does a complete dependency
47 # check of the ReactOS codebase.
48 #
49 #
50 # Accepted environment variables:
51 #
52 # ROS_PREFIX
53 # This variable specifies the prefix of the MinGW installation. On Windows
54 # a prefix is usually not needed, but on linux it is usually "mingw32". If
55 # not present and no executable named "gcc" can be found, then the prefix is
56 # assumed to be "mingw32". If your gcc is named i386-mingw32-gcc then set
57 # ROS_PREFIX to i386-mingw32. Don't include the dash (-) before gcc.
58 #
59 # ROS_INTERMEDIATE
60 # This variable controls where to put intermediate files. Intermediate
61 # files are generated files that are needed to generate the final
62 # output files. Examples of intermediate files include *.o, *.a, and
63 # *.coff. N.B. Don't put a path separator at the end. The variable
64 # defaults to .\obj-i386.
65 #
66 # ROS_OUTPUT
67 # This variable controls where to put output files. Output files are
68 # generated files that makes up the result of the build process.
69 # Examples of output files include *.exe, *.dll, and *.sys. N.B. Don't
70 # put a path separator at the end. The variable defaults to .\output-i386.
71 #
72 # ROS_TEMPORARY
73 # This variable controls where to put temporary files. Temporary files
74 # are (usually small) generated files that are needed to generate the
75 # intermediate or final output files. Examples of temporary files include
76 # *.rci (preprocessed .rc files for wrc), *.tmp, and *.exp. N.B. Don't put
77 # a path separator at the end. The variable defaults to the current
78 # directory.
79 #
80 # ROS_INSTALL
81 # This variable controls where to install output files to when using
82 # 'make install'. N.B. Don't put a path separator at the end. The variable
83 # defaults to .\reactos.
84 #
85 # ROS_BUILDMAP
86 # This variable controls if map files are to be generated for executable
87 # output files. Map files have the extension .map. The value can be either
88 # full (to build map files with assembly code), yes (to build map files
89 # without source code) or no (to not build any map files). The variable
90 # defaults to no.
91 #
92 # ROS_BUILDNOSTRIP
93 # This variable controls if non-symbol-stripped versions are to be built
94 # of executable output files. Non-symbol-stripped executable output files
95 # have .nostrip added to the filename just before the extension. The value
96 # can be either yes (to build non-symbol-stripped versions of executable
97 # output files) or no (to not build non-symbol-stripped versions of
98 # executable output files). The variable defaults to no.
99 #
100 # ROS_RBUILDFLAGS
101 # Pass parameters to rbuild.
102 # -v Be verbose.
103 # -c Clean as you go. Delete generated files as soon as they are not needed anymore.
104 # -dd Disable automatic dependencies.
105 # -dm{module} Check only automatic dependencies for this module.
106 # -mi Let make handle creation of install directories. Rbuild will not generate the directories.
107 # -ps Generate proxy makefiles in source tree instead of the output tree.
108
109 .PHONY: all
110 .PHONY: clean
111 all: makefile.auto
112
113
114 .SUFFIXES:
115
116 ifeq ($(HOST),)
117 ifeq ($(word 1,$(shell gcc -dumpmachine)),mingw32)
118 ifeq ($(findstring msys,$(shell sh --version 2>nul)),msys)
119 export OSTYPE = msys
120 HOST=mingw32-linux
121 else
122 HOST=mingw32-windows
123 endif
124 else
125 HOST=mingw32-linux
126 endif
127 endif
128
129 # Default to half-verbose mode
130 ifeq ($(VERBOSE),no)
131 Q = @
132 HALFVERBOSEECHO = no
133 BUILDNO_QUIET = -q
134 else
135 ifeq ($(VERBOSE),full)
136 Q =
137 HALFVERBOSEECHO = no
138 BUILDNO_QUIET =
139 else
140 Q = @
141 HALFVERBOSEECHO = yes
142 BUILDNO_QUIET = -q
143 endif
144 endif
145 ifeq ($(HOST),mingw32-linux)
146 QUOTE = "
147 else
148 QUOTE =
149 endif
150 ifeq ($(HALFVERBOSEECHO),yes)
151 ECHO_CP =@echo $(QUOTE)[COPY] $@$(QUOTE)
152 ECHO_MKDIR =@echo $(QUOTE)[MKDIR] $@$(QUOTE)
153 ECHO_BUILDNO =@echo $(QUOTE)[BUILDNO] $@$(QUOTE)
154 ECHO_INVOKE =@echo $(QUOTE)[INVOKE] $<$(QUOTE)
155 ECHO_PCH =@echo $(QUOTE)[PCH] $@$(QUOTE)
156 ECHO_CC =@echo $(QUOTE)[CC] $<$(QUOTE)
157 ECHO_GAS =@echo $(QUOTE)[GAS] $<$(QUOTE)
158 ECHO_NASM =@echo $(QUOTE)[NASM] $<$(QUOTE)
159 ECHO_AR =@echo $(QUOTE)[AR] $@$(QUOTE)
160 ECHO_WINEBLD =@echo $(QUOTE)[WINEBLD] $@$(QUOTE)
161 ECHO_WRC =@echo $(QUOTE)[WRC] $@$(QUOTE)
162 ECHO_WIDL =@echo $(QUOTE)[WIDL] $@$(QUOTE)
163 ECHO_BIN2RES =@echo $(QUOTE)[BIN2RES] $<$(QUOTE)
164 ECHO_DLLTOOL =@echo $(QUOTE)[DLLTOOL] $@$(QUOTE)
165 ECHO_LD =@echo $(QUOTE)[LD] $@$(QUOTE)
166 ECHO_NM =@echo $(QUOTE)[NM] $@$(QUOTE)
167 ECHO_OBJDUMP =@echo $(QUOTE)[OBJDUMP] $@$(QUOTE)
168 ECHO_RBUILD =@echo $(QUOTE)[RBUILD] $@$(QUOTE)
169 ECHO_RSYM =@echo $(QUOTE)[RSYM] $@$(QUOTE)
170 ECHO_WMC =@echo $(QUOTE)[WMC] $@$(QUOTE)
171 ECHO_NCI =@echo $(QUOTE)[NCI] $@$(QUOTE)
172 ECHO_CABMAN =@echo $(QUOTE)[CABMAN] $<$(QUOTE)
173 ECHO_CDMAKE =@echo $(QUOTE)[CDMAKE] $@$(QUOTE)
174 ECHO_MKHIVE =@echo $(QUOTE)[MKHIVE] $@$(QUOTE)
175 ECHO_REGTESTS=@echo $(QUOTE)[REGTESTS] $@$(QUOTE)
176 ECHO_TEST =@echo $(QUOTE)[TEST] $@$(QUOTE)
177 ECHO_GENDIB =@echo $(QUOTE)[GENDIB] $@$(QUOTE)
178 else
179 ECHO_CP =
180 ECHO_MKDIR =
181 ECHO_BUILDNO =
182 ECHO_INVOKE =
183 ECHO_PCH =
184 ECHO_CC =
185 ECHO_GAS =
186 ECHO_NASM =
187 ECHO_AR =
188 ECHO_WINEBLD =
189 ECHO_WRC =
190 ECHO_WIDL =
191 ECHO_BIN2RES =
192 ECHO_DLLTOOL =
193 ECHO_LD =
194 ECHO_NM =
195 ECHO_OBJDUMP =
196 ECHO_RBUILD =
197 ECHO_RSYM =
198 ECHO_WMC =
199 ECHO_NCI =
200 ECHO_CABMAN =
201 ECHO_CDMAKE =
202 ECHO_MKHIVE =
203 ECHO_REGTESTS=
204 ECHO_TEST =
205 ECHO_GENDIB =
206 endif
207
208
209 host_gcc = $(Q)gcc
210 host_gpp = $(Q)g++
211 host_ld = $(Q)ld
212 host_ar = $(Q)ar
213 host_objcopy = $(Q)objcopy
214 ifeq ($(HOST),mingw32-linux)
215 export EXEPREFIX = ./
216 ifeq ($(OSTYPE),msys)
217 export EXEPOSTFIX = .exe
218 else
219 export EXEPOSTFIX =
220 endif
221 export SEP = /
222 mkdir = -$(Q)mkdir -p
223 gcc = $(Q)$(PREFIX)-gcc
224 gpp = $(Q)$(PREFIX)-g++
225 ld = $(Q)$(PREFIX)-ld
226 nm = $(Q)$(PREFIX)-nm
227 objdump = $(Q)$(PREFIX)-objdump
228 ar = $(Q)$(PREFIX)-ar
229 objcopy = $(Q)$(PREFIX)-objcopy
230 dlltool = $(Q)$(PREFIX)-dlltool
231 windres = $(Q)$(PREFIX)-windres
232 rm = $(Q)rm -f
233 cp = $(Q)cp
234 NUL = /dev/null
235 else # mingw32-windows
236 ifeq ($(OSTYPE),msys)
237 HOST=mingw32-linux
238 export EXEPREFIX = ./
239 export EXEPOSTFIX = .exe
240 export SEP = /
241 mkdir = -$(Q)mkdir -p
242 gcc = $(Q)gcc
243 gpp = $(Q)g++
244 ld = $(Q)ld
245 nm = $(Q)nm
246 objdump = $(Q)objdump
247 ar = $(Q)ar
248 objcopy = $(Q)objcopy
249 dlltool = $(Q)dlltool
250 windres = $(Q)windres
251 rm = $(Q)rm -f
252 cp = $(Q)cp
253 NUL = /dev/null
254 else
255 export EXEPREFIX =
256 export EXEPOSTFIX = .exe
257 ROS_EMPTY =
258 export SEP = \$(ROS_EMPTY)
259 mkdir = -$(Q)mkdir
260 gcc = $(Q)gcc
261 gpp = $(Q)g++
262 ld = $(Q)ld
263 nm = $(Q)nm
264 objdump = $(Q)objdump
265 ar = $(Q)ar
266 objcopy = $(Q)objcopy
267 dlltool = $(Q)dlltool
268 windres = $(Q)windres
269 rm = $(Q)del /f /q
270 cp = $(Q)copy /y
271 NUL = NUL
272 endif
273 endif
274
275 ifneq ($(ROS_INTERMEDIATE),)
276 INTERMEDIATE := $(ROS_INTERMEDIATE)
277 else
278 INTERMEDIATE := obj-i386
279 endif
280 INTERMEDIATE_ := $(INTERMEDIATE)$(SEP)
281
282 ifneq ($(ROS_OUTPUT),)
283 OUTPUT := $(ROS_OUTPUT)
284 else
285 OUTPUT := output-i386
286 endif
287 OUTPUT_ := $(OUTPUT)$(SEP)
288
289 ifneq ($(ROS_TEMPORARY),)
290 TEMPORARY := $(ROS_TEMPORARY)
291 else
292 TEMPORARY :=
293 endif
294 TEMPORARY_ := $(TEMPORARY)$(SEP)
295
296 ifneq ($(ROS_INSTALL),)
297 INSTALL := $(ROS_INSTALL)
298 else
299 INSTALL := reactos
300 endif
301 INSTALL_ := $(INSTALL)$(SEP)
302
303 $(INTERMEDIATE):
304 ${mkdir} $@
305
306 ifneq ($(INTERMEDIATE),$(OUTPUT))
307 $(OUTPUT):
308 ${mkdir} $@
309 endif
310
311
312 NTOSKRNL_MC = ntoskrnl$(SEP)ntoskrnl.mc
313 KERNEL32_MC = lib$(SEP)kernel32$(SEP)kernel32.mc
314 BUILDNO_H = include$(SEP)reactos$(SEP)buildno.h
315 BUGCODES_H = include$(SEP)reactos$(SEP)bugcodes.h
316 BUGCODES_RC = ntoskrnl$(SEP)bugcodes.rc
317 ERRCODES_H = include$(SEP)reactos$(SEP)errcodes.h
318 ERRCODES_RC = lib$(SEP)kernel32$(SEP)errcodes.rc
319
320 include lib/lib.mak
321 include tools/tools.mak
322 include boot/freeldr/bootsect/bootsect.mak
323 -include makefile.auto
324
325 PREAUTO := \
326 $(BIN2C_TARGET) \
327 $(BIN2RES_TARGET) \
328 $(BUILDNO_H) \
329 $(BUGCODES_H) \
330 $(BUGCODES_RC) \
331 $(ERRCODES_H) \
332 $(ERRCODES_RC) \
333 $(NCI_SERVICE_FILES) \
334 $(GENDIB_DIB_FILES)
335
336 makefile.auto: $(RBUILD_TARGET) $(PREAUTO) $(XMLBUILDFILES)
337 $(ECHO_RBUILD)
338 $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) mingw
339
340 .PHONY: msvc
341 msvc: $(RBUILD_TARGET)
342 $(ECHO_RBUILD)
343 $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) msvc
344
345 $(BUGCODES_H) $(BUGCODES_RC): $(WMC_TARGET) $(NTOSKRNL_MC)
346 $(ECHO_WMC)
347 $(Q)$(WMC_TARGET) -i -H $(BUGCODES_H) -o $(BUGCODES_RC) $(NTOSKRNL_MC)
348
349 $(ERRCODES_H) $(ERRCODES_RC): $(WMC_TARGET) $(KERNEL32_MC)
350 $(ECHO_WMC)
351 $(Q)$(WMC_TARGET) -i -H $(ERRCODES_H) -o $(ERRCODES_RC) $(KERNEL32_MC)
352
353 .PHONY: msvc6
354 msvc6: $(RBUILD_TARGET)
355 $(ECHO_RBUILD)
356 $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -vs6.00 msvc
357
358 .PHONY: msvc7
359 msvc7: $(RBUILD_TARGET)
360 $(ECHO_RBUILD)
361 $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -vs7.00 msvc
362
363 .PHONY: msvc71
364 msvc71: $(RBUILD_TARGET)
365 $(ECHO_RBUILD)
366 $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -vs7.10 msvc
367
368 .PHONY: msvc8
369 msvc8: $(RBUILD_TARGET)
370 $(ECHO_RBUILD)
371 $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -vs8.00 msvc
372
373 .PHONY: makefile_auto_clean
374 makefile_auto_clean:
375 -@$(rm) makefile.auto $(PREAUTO) 2>$(NUL)
376
377 .PHONY: clean
378 clean: makefile_auto_clean
379
380 .PHONY: depends
381 depends:
382 @-$(rm) makefile.auto
383 @$(MAKE) $(filter-out depends, $(MAKECMDGOALS))