f32aaff14ced050f36c36a428522871d486543bb
[reactos.git] / reactos / Makefile
1 # Accepted environment variables:
2 #
3 # ROS_INTERMEDIATE
4 # This variable controls where to put intermediate files. Intermediate
5 # files are generated files that are needed to generate the final
6 # output files. Examples of intermediate files include *.o, *.a, and
7 # *.coff. N.B. Don't put a path separator at the end. The variable
8 # defaults to .\obj-i386.
9 #
10 # ROS_OUTPUT
11 # This variable controls where to put output files. Output files are
12 # generated files that makes up the result of the build process.
13 # Examples of output files include *.exe, *.dll, and *.sys. N.B. Don't
14 # put a path separator at the end. The variable defaults to .\output-i386.
15 #
16
17 .PHONY: all
18 .PHONY: clean
19 all: makefile.auto
20
21 ifeq ($(HOST),)
22 ifeq ($(word 1,$(shell gcc -dumpmachine)),mingw32)
23 HOST=mingw32-windows
24 else
25 HOST=mingw32-linux
26 endif
27 endif
28
29 # Default to half-verbose mode
30 ifeq ($(VERBOSE),no)
31 Q = @
32 HALFVERBOSEECHO = no
33 else
34 ifeq ($(VERBOSE),yes)
35 Q =
36 HALFVERBOSEECHO = no
37 else
38 Q = @
39 HALFVERBOSEECHO = yes
40 endif
41 endif
42 ifeq ($(HALFVERBOSEECHO),yes)
43 ECHO_INVOKE =@echo [INVOKE] $<
44 ECHO_PCH =@echo [PCH] $@
45 ECHO_CC =@echo [CC] $<
46 ECHO_GAS =@echo [GAS] $<
47 ECHO_NASM =@echo [NASM] $<
48 ECHO_AR =@echo [AR] $@
49 ECHO_WINEBLD=@echo [WINEBLD] $@
50 ECHO_WRC =@echo [WRC] $@
51 ECHO_BIN2RES=@echo [BIN2RES] $<
52 ECHO_DLLTOOL=@echo [DLLTOOL] $@
53 ECHO_LD =@echo [LD] $@
54 ECHO_RBUILD =@echo [RBUILD] $@
55 ECHO_RSYM =@echo [RSYM] $@
56 ECHO_NCI =@echo [NCI] $@
57 ECHO_CABMAN =@echo [CABMAN] $<
58 ECHO_CDMAKE =@echo [CDMAKE] $@
59 ECHO_TEST =@echo [TEST] $@
60 else
61 ECHO_INVOKE =
62 ECHO_PCH =
63 ECHO_CC =
64 ECHO_GAS =
65 ECHO_NASM =
66 ECHO_AR =
67 ECHO_WINEBLD=
68 ECHO_WRC =
69 ECHO_BIN2RES=
70 ECHO_DLLTOOL=
71 ECHO_LD =
72 ECHO_RBUILD =
73 ECHO_RSYM =
74 ECHO_NCI =
75 ECHO_CABMAN =
76 ECHO_CDMAKE =
77 ECHO_TEST =
78 endif
79
80
81 host_gcc = $(Q)gcc
82 host_gpp = $(Q)g++
83 host_ld = $(Q)ld
84 host_ar = $(Q)ar
85 host_objcopy = $(Q)objcopy
86 ifeq ($(HOST),mingw32-linux)
87 EXEPREFIX = ./
88 EXEPOSTFIX =
89 SEP = /
90 nmkdir = $(Q)mkdir -p
91 gcc = $(Q)mingw32-gcc
92 gpp = $(Q)mingw32-g++
93 ld = $(Q)mingw32-ld
94 ar = $(Q)mingw32-ar
95 objcopy = $(Q)mingw32-objcopy
96 dlltool = $(Q)mingw32-dlltool
97 windres = $(Q)mingw32-windres
98 rm = rm -f
99 cp = $(Q)cp
100 NUL = /dev/null
101 else # mingw32-windows
102 EXEPREFIX =
103 EXEPOSTFIX = .exe
104 ROS_EMPTY =
105 SEP = \$(ROS_EMPTY)
106 nmkdir = $(Q)mkdir
107 gcc = $(Q)gcc
108 gpp = $(Q)g++
109 ld = $(Q)ld
110 ar = $(Q)ar
111 objcopy = $(Q)objcopy
112 dlltool = $(Q)dlltool
113 windres = $(Q)windres
114 rm = del /f /q
115 cp = $(Q)copy /y
116 NUL = NUL
117 endif
118
119 ifneq ($(ROS_INTERMEDIATE),)
120 INTERMEDIATE = .$(SEP)$(ROS_INTERMEDIATE)$(SEP)
121 INTERMEDIATE_NO_SLASH := $(ROS_INTERMEDIATE)
122 else
123 INTERMEDIATE = obj-i386$(SEP)
124 INTERMEDIATE_NO_SLASH = obj-i386
125 endif
126
127 ifneq ($(ROS_OUTPUT),)
128 OUTPUT = $(ROS_OUTPUT)$(SEP)
129 OUTPUT_NO_SLASH = $(ROS_OUTPUT)
130 else
131 OUTPUT = obj-i386$(SEP)
132 OUTPUT_NO_SLASH = obj-i386
133 endif
134
135 mkdir = $(Q)$(INTERMEDIATE)rmkdir
136
137 $(INTERMEDIATE_NO_SLASH):
138 ${nmkdir} $(INTERMEDIATE_NO_SLASH)
139
140 NTOSKRNL_MC = .$(SEP)ntoskrnl$(SEP)ntoskrnl.mc
141 KERNEL32_MC = .$(SEP)lib$(SEP)kernel32$(SEP)kernel32.mc
142 BUILDNO_H = .$(SEP)include$(SEP)reactos$(SEP)buildno.h
143 BUGCODES_H = .$(SEP)include$(SEP)reactos$(SEP)bugcodes.h
144 BUGCODES_RC = .$(SEP)ntoskrnl$(SEP)bugcodes.rc
145 ERRCODES_H = .$(SEP)include$(SEP)reactos$(SEP)errcodes.h
146 ERRCODES_RC = .$(SEP)lib$(SEP)kernel32$(SEP)errcodes.rc
147
148 include tools/tools.mak
149 -include makefile.auto
150
151 PREAUTO := \
152 $(BUILDNO_H) \
153 $(BUGCODES_H) \
154 $(BUGCODES_RC) \
155 $(ERRCODES_H) \
156 $(ERRCODES_RC) \
157 $(NCI_SERVICE_FILES)
158
159 makefile.auto: $(RMKDIR_TARGET) $(BIN2RES_TARGET) $(WINEBUILD_TARGET) $(RBUILD_TARGET) $(PREAUTO) $(XMLBUILDFILES)
160 $(ECHO_RBUILD)
161 $(Q)tools$(SEP)rbuild$(SEP)rbuild$(EXEPOSTFIX) mingw
162
163
164 $(BUGCODES_H) $(BUGCODES_RC): $(WMC_TARGET) $(NTOSKRNL_MC)
165 $(WMC_TARGET) -i -H $(BUGCODES_H) -o $(BUGCODES_RC) $(NTOSKRNL_MC)
166
167 $(ERRCODES_H) $(ERRCODES_RC): $(WMC_TARGET) $(KERNEL32_MC)
168 $(WMC_TARGET) -i -H $(ERRCODES_H) -o $(ERRCODES_RC) $(KERNEL32_MC)
169
170 .PHONY: makefile_auto_clean
171 makefile_auto_clean:
172 -@$(rm) makefile.auto $(PREAUTO) 2>$(NUL)
173
174 .PHONY: clean
175 clean: makefile_auto_clean