f14bd0c9a615477df2cbe19bd3e6c669f58907de
[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 # check for versions of make that don't have features we need...
110 # the function "eval" is only available in 3.80+, which happens to be the minimum
111 # version that has the features we use...
112 # THIS CHECK IS BORROWED FROM THE "GMSL" PROJECT, AND IS COVERED BY THE GPL LICENSE
113 # YOU CAN FIND OUT MORE ABOUT GMSL - A VERY COOL PROJECT - AT:
114 # http://gmsl.sourceforge.net/
115
116 __gmsl_have_eval :=
117 __gmsl_ignore := $(eval __gmsl_have_eval := T)
118
119 ifndef __gmsl_have_eval
120 $(error ReactOS's makefiles use GNU Make 3.80+ features, you have $(MAKE_VERSION), you MUST UPGRADE in order to build ReactOS - Sorry)
121 endif
122 # END of code borrowed from GMSL ( http://gmsl.sourceforge.net/ )
123
124 .PHONY: all
125 .PHONY: clean
126 all: makefile.auto
127
128
129 .SUFFIXES:
130
131 ifeq ($(HOST),)
132 ifeq ($(word 1,$(shell gcc -dumpmachine)),mingw32)
133 ifeq ($(findstring msys,$(shell sh --version 2>nul)),msys)
134 export OSTYPE = msys
135 HOST=mingw32-linux
136 else
137 HOST=mingw32-windows
138 endif
139 else
140 HOST=mingw32-linux
141 endif
142 endif
143
144 # Default to half-verbose mode
145 ifeq ($(VERBOSE),no)
146 Q = @
147 HALFVERBOSEECHO = no
148 BUILDNO_QUIET = -q
149 else
150 ifeq ($(VERBOSE),full)
151 Q =
152 HALFVERBOSEECHO = no
153 BUILDNO_QUIET =
154 else
155 Q = @
156 HALFVERBOSEECHO = yes
157 BUILDNO_QUIET = -q
158 endif
159 endif
160 ifeq ($(HOST),mingw32-linux)
161 QUOTE = "
162 else
163 QUOTE =
164 endif
165 ifeq ($(HALFVERBOSEECHO),yes)
166 ECHO_CP =@echo $(QUOTE)[COPY] $@$(QUOTE)
167 ECHO_MKDIR =@echo $(QUOTE)[MKDIR] $@$(QUOTE)
168 ECHO_BUILDNO =@echo $(QUOTE)[BUILDNO] $@$(QUOTE)
169 ECHO_INVOKE =@echo $(QUOTE)[INVOKE] $<$(QUOTE)
170 ECHO_PCH =@echo $(QUOTE)[PCH] $@$(QUOTE)
171 ECHO_CC =@echo $(QUOTE)[CC] $<$(QUOTE)
172 ECHO_GAS =@echo $(QUOTE)[GAS] $<$(QUOTE)
173 ECHO_NASM =@echo $(QUOTE)[NASM] $<$(QUOTE)
174 ECHO_AR =@echo $(QUOTE)[AR] $@$(QUOTE)
175 ECHO_WINEBLD =@echo $(QUOTE)[WINEBLD] $@$(QUOTE)
176 ECHO_WRC =@echo $(QUOTE)[WRC] $@$(QUOTE)
177 ECHO_WIDL =@echo $(QUOTE)[WIDL] $@$(QUOTE)
178 ECHO_BIN2RES =@echo $(QUOTE)[BIN2RES] $<$(QUOTE)
179 ECHO_DLLTOOL =@echo $(QUOTE)[DLLTOOL] $@$(QUOTE)
180 ECHO_LD =@echo $(QUOTE)[LD] $@$(QUOTE)
181 ECHO_NM =@echo $(QUOTE)[NM] $@$(QUOTE)
182 ECHO_OBJDUMP =@echo $(QUOTE)[OBJDUMP] $@$(QUOTE)
183 ECHO_RBUILD =@echo $(QUOTE)[RBUILD] $@$(QUOTE)
184 ECHO_RSYM =@echo $(QUOTE)[RSYM] $@$(QUOTE)
185 ECHO_WMC =@echo $(QUOTE)[WMC] $@$(QUOTE)
186 ECHO_NCI =@echo $(QUOTE)[NCI] $@$(QUOTE)
187 ECHO_CABMAN =@echo $(QUOTE)[CABMAN] $<$(QUOTE)
188 ECHO_CDMAKE =@echo $(QUOTE)[CDMAKE] $@$(QUOTE)
189 ECHO_MKHIVE =@echo $(QUOTE)[MKHIVE] $@$(QUOTE)
190 ECHO_REGTESTS=@echo $(QUOTE)[REGTESTS] $@$(QUOTE)
191 ECHO_TEST =@echo $(QUOTE)[TEST] $@$(QUOTE)
192 ECHO_GENDIB =@echo $(QUOTE)[GENDIB] $@$(QUOTE)
193 else
194 ECHO_CP =
195 ECHO_MKDIR =
196 ECHO_BUILDNO =
197 ECHO_INVOKE =
198 ECHO_PCH =
199 ECHO_CC =
200 ECHO_GAS =
201 ECHO_NASM =
202 ECHO_AR =
203 ECHO_WINEBLD =
204 ECHO_WRC =
205 ECHO_WIDL =
206 ECHO_BIN2RES =
207 ECHO_DLLTOOL =
208 ECHO_LD =
209 ECHO_NM =
210 ECHO_OBJDUMP =
211 ECHO_RBUILD =
212 ECHO_RSYM =
213 ECHO_WMC =
214 ECHO_NCI =
215 ECHO_CABMAN =
216 ECHO_CDMAKE =
217 ECHO_MKHIVE =
218 ECHO_REGTESTS=
219 ECHO_TEST =
220 ECHO_GENDIB =
221 endif
222
223
224 host_gcc = $(Q)gcc
225 host_gpp = $(Q)g++
226 host_ld = $(Q)ld
227 host_ar = $(Q)ar
228 host_objcopy = $(Q)objcopy
229 ifeq ($(HOST),mingw32-linux)
230 export EXEPREFIX = ./
231 ifeq ($(OSTYPE),msys)
232 export EXEPOSTFIX = .exe
233 else
234 export EXEPOSTFIX =
235 endif
236 export SEP = /
237 mkdir = -$(Q)mkdir -p
238 gcc = $(Q)$(PREFIX)-gcc
239 gpp = $(Q)$(PREFIX)-g++
240 ld = $(Q)$(PREFIX)-ld
241 nm = $(Q)$(PREFIX)-nm
242 objdump = $(Q)$(PREFIX)-objdump
243 ar = $(Q)$(PREFIX)-ar
244 objcopy = $(Q)$(PREFIX)-objcopy
245 dlltool = $(Q)$(PREFIX)-dlltool
246 windres = $(Q)$(PREFIX)-windres
247 rm = $(Q)rm -f
248 cp = $(Q)cp
249 NUL = /dev/null
250 else # mingw32-windows
251 ifeq ($(OSTYPE),msys)
252 HOST=mingw32-linux
253 export EXEPREFIX = ./
254 export EXEPOSTFIX = .exe
255 export SEP = /
256 mkdir = -$(Q)mkdir -p
257 gcc = $(Q)gcc
258 gpp = $(Q)g++
259 ld = $(Q)ld
260 nm = $(Q)nm
261 objdump = $(Q)objdump
262 ar = $(Q)ar
263 objcopy = $(Q)objcopy
264 dlltool = $(Q)dlltool
265 windres = $(Q)windres
266 rm = $(Q)rm -f
267 cp = $(Q)cp
268 NUL = /dev/null
269 else
270 export EXEPREFIX =
271 export EXEPOSTFIX = .exe
272 ROS_EMPTY =
273 export SEP = \$(ROS_EMPTY)
274 mkdir = -$(Q)mkdir
275 gcc = $(Q)gcc
276 gpp = $(Q)g++
277 ld = $(Q)ld
278 nm = $(Q)nm
279 objdump = $(Q)objdump
280 ar = $(Q)ar
281 objcopy = $(Q)objcopy
282 dlltool = $(Q)dlltool
283 windres = $(Q)windres
284 rm = $(Q)del /f /q
285 cp = $(Q)copy /y
286 NUL = NUL
287 endif
288 endif
289
290 ifneq ($(ROS_INTERMEDIATE),)
291 INTERMEDIATE := $(ROS_INTERMEDIATE)
292 else
293 INTERMEDIATE := obj-i386
294 endif
295 INTERMEDIATE_ := $(INTERMEDIATE)$(SEP)
296
297 ifneq ($(ROS_OUTPUT),)
298 OUTPUT := $(ROS_OUTPUT)
299 else
300 OUTPUT := output-i386
301 endif
302 OUTPUT_ := $(OUTPUT)$(SEP)
303
304 ifneq ($(ROS_TEMPORARY),)
305 TEMPORARY := $(ROS_TEMPORARY)
306 else
307 TEMPORARY :=
308 endif
309 TEMPORARY_ := $(TEMPORARY)$(SEP)
310
311 ifneq ($(ROS_INSTALL),)
312 INSTALL := $(ROS_INSTALL)
313 else
314 INSTALL := reactos
315 endif
316 INSTALL_ := $(INSTALL)$(SEP)
317
318 $(INTERMEDIATE):
319 ${mkdir} $@
320
321 ifneq ($(INTERMEDIATE),$(OUTPUT))
322 $(OUTPUT):
323 ${mkdir} $@
324 endif
325
326
327 NTOSKRNL_MC = ntoskrnl$(SEP)ntoskrnl.mc
328 KERNEL32_MC = lib$(SEP)kernel32$(SEP)kernel32.mc
329 BUILDNO_H = include$(SEP)reactos$(SEP)buildno.h
330 BUGCODES_H = include$(SEP)reactos$(SEP)bugcodes.h
331 BUGCODES_RC = ntoskrnl$(SEP)bugcodes.rc
332 ERRCODES_H = include$(SEP)reactos$(SEP)errcodes.h
333 ERRCODES_RC = lib$(SEP)kernel32$(SEP)errcodes.rc
334
335 include lib/lib.mak
336 include tools/tools.mak
337 include boot/freeldr/bootsect/bootsect.mak
338 -include makefile.auto
339
340 PREAUTO := \
341 $(BIN2C_TARGET) \
342 $(BIN2RES_TARGET) \
343 $(BUILDNO_H) \
344 $(BUGCODES_H) \
345 $(BUGCODES_RC) \
346 $(ERRCODES_H) \
347 $(ERRCODES_RC) \
348 $(NCI_SERVICE_FILES) \
349 $(GENDIB_DIB_FILES)
350
351 makefile.auto: $(RBUILD_TARGET) $(PREAUTO) $(XMLBUILDFILES)
352 $(ECHO_RBUILD)
353 $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) mingw
354
355 .PHONY: msvc
356 msvc: $(RBUILD_TARGET)
357 $(ECHO_RBUILD)
358 $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) msvc
359
360 $(BUGCODES_H) $(BUGCODES_RC): $(WMC_TARGET) $(NTOSKRNL_MC)
361 $(ECHO_WMC)
362 $(Q)$(WMC_TARGET) -i -H $(BUGCODES_H) -o $(BUGCODES_RC) $(NTOSKRNL_MC)
363
364 $(ERRCODES_H) $(ERRCODES_RC): $(WMC_TARGET) $(KERNEL32_MC)
365 $(ECHO_WMC)
366 $(Q)$(WMC_TARGET) -i -H $(ERRCODES_H) -o $(ERRCODES_RC) $(KERNEL32_MC)
367
368 .PHONY: msvc6
369 msvc6: $(RBUILD_TARGET)
370 $(ECHO_RBUILD)
371 $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -vs6.00 msvc
372
373 .PHONY: msvc7
374 msvc7: $(RBUILD_TARGET)
375 $(ECHO_RBUILD)
376 $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -vs7.00 msvc
377
378 .PHONY: msvc71
379 msvc71: $(RBUILD_TARGET)
380 $(ECHO_RBUILD)
381 $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -vs7.10 msvc
382
383 .PHONY: msvc8
384 msvc8: $(RBUILD_TARGET)
385 $(ECHO_RBUILD)
386 $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) -vs8.00 msvc
387
388 .PHONY: makefile_auto_clean
389 makefile_auto_clean:
390 -@$(rm) makefile.auto $(PREAUTO) 2>$(NUL)
391
392 .PHONY: clean
393 clean: makefile_auto_clean
394
395 .PHONY: depends
396 depends:
397 @-$(rm) makefile.auto
398 @$(MAKE) $(filter-out depends, $(MAKECMDGOALS))