| 1 |
Ddoc |
|---|
| 2 |
|
|---|
| 3 |
$(D_S dmd - $(WINDOWS Windows)$(LINUX Linux)$(OSX Mac OS X)$(FREEBSD FreeBSD) D Compiler, |
|---|
| 4 |
|
|---|
| 5 |
$(UL |
|---|
| 6 |
$(WINDOWS $(LI dmd for $(LINK2 dmd-linux.html, Linux))) |
|---|
| 7 |
$(WINDOWS $(LI dmd for $(LINK2 dmd-osx.html, OSX))) |
|---|
| 8 |
$(WINDOWS $(LI dmd for $(LINK2 dmd-freebsd.html, FreeBSD))) |
|---|
| 9 |
$(LINUX $(LI dmd for $(LINK2 dmd-windows.html, Windows))) |
|---|
| 10 |
$(LINUX $(LI dmd for $(LINK2 dmd-osx.html, OSX))) |
|---|
| 11 |
$(LINUX $(LI dmd for $(LINK2 dmd-freebsd.html, FreeBSD))) |
|---|
| 12 |
$(OSX $(LI dmd for $(LINK2 dmd-windows.html, Windows))) |
|---|
| 13 |
$(OSX $(LI dmd for $(LINK2 dmd-linux.html, Linux))) |
|---|
| 14 |
$(OSX $(LI dmd for $(LINK2 dmd-freebsd.html, FreeBSD))) |
|---|
| 15 |
$(FREEBSD $(LI dmd for $(LINK2 dmd-windows.html, Windows))) |
|---|
| 16 |
$(FREEBSD $(LI dmd for $(LINK2 dmd-linux.html, Linux))) |
|---|
| 17 |
$(FREEBSD $(LI dmd for $(LINK2 dmd-osx.html, OSX))) |
|---|
| 18 |
$(LI $(LINK2 #requirements, Requirements and Downloads)) |
|---|
| 19 |
$(LI $(LINK2 #files, Files)) |
|---|
| 20 |
$(LI $(LINK2 #installation, Installation)) |
|---|
| 21 |
$(WINDOWS $(LI $(LINK2 #example, Example))) |
|---|
| 22 |
$(LI $(LINK2 #switches, Compiler Arguments and Switches)) |
|---|
| 23 |
$(LI $(LINK2 #linking, Linking)) |
|---|
| 24 |
$(LI $(LINK2 #environment, Environment Variables)) |
|---|
| 25 |
$(WINDOWS $(LI $(LINK2 #sc_ini, sc.ini Initialization File))) |
|---|
| 26 |
$(UNIX $(LI $(DMD_CONF) Initialization File)) |
|---|
| 27 |
$(WINDOWS $(LI $(LINK2 #problems, Common Installation Problems))) |
|---|
| 28 |
$(LI $(LINK2 #differences, Differences between Windows and Linux versions)) |
|---|
| 29 |
$(LI $(LINK2 #interface_files, D Interface Files)) |
|---|
| 30 |
$(LI $(LINK2 #library, Building Libraries)) |
|---|
| 31 |
$(LI $(LINK2 #compiling_dmd, Compiling dmd)) |
|---|
| 32 |
$(LI $(LINK2 #compiling_phobos, Compiling Phobos)) |
|---|
| 33 |
) |
|---|
| 34 |
|
|---|
| 35 |
<h2>$(LNAME2 requirements, Requirements and Downloads)</h2> |
|---|
| 36 |
|
|---|
| 37 |
$(OL |
|---|
| 38 |
$(LI $(LINK2 http://www.digitalmars.com/d/download.html, Download D Compiler)) |
|---|
| 39 |
|
|---|
| 40 |
$(WINDOWS |
|---|
| 41 |
$(LI 32 bit Windows (Win32) operating system, such as Windows XP) |
|---|
| 42 |
|
|---|
| 43 |
$(LI Download |
|---|
| 44 |
<a href="http://ftp.digitalmars.com/dmc.zip" title="download dmc.zip"> |
|---|
| 45 |
dmc.zip (C and C++ compiler)</a> for Win32 |
|---|
| 46 |
(not required, but it complements dmd for Windows) |
|---|
| 47 |
) |
|---|
| 48 |
) |
|---|
| 49 |
$(LINUX |
|---|
| 50 |
$(LI 32 bit x86 Linux operating system (will work on 64 bit Linux)) |
|---|
| 51 |
|
|---|
| 52 |
$(LI Gnu C compiler (gcc)) |
|---|
| 53 |
) |
|---|
| 54 |
$(OSX |
|---|
| 55 |
$(LI 32 bit x86 Mac OSX operating system) |
|---|
| 56 |
|
|---|
| 57 |
$(LI Gnu C compiler (gcc)) |
|---|
| 58 |
) |
|---|
| 59 |
$(FREEBSD |
|---|
| 60 |
$(LI 32 bit x86 FreeBSD 7.1 operating system) |
|---|
| 61 |
|
|---|
| 62 |
$(LI Gnu C compiler (gcc)) |
|---|
| 63 |
) |
|---|
| 64 |
) |
|---|
| 65 |
|
|---|
| 66 |
<h2>$(LNAME2 files, Files)</h2> |
|---|
| 67 |
|
|---|
| 68 |
$(DL |
|---|
| 69 |
|
|---|
| 70 |
$(DT $(TT $(DMDDIR)$(SEP)src$(SEP)phobos$(SEP)) |
|---|
| 71 |
$(DD D runtime library source) |
|---|
| 72 |
) |
|---|
| 73 |
|
|---|
| 74 |
$(DT $(TT $(DMDDIR)$(SEP)src$(SEP)dmd$(SEP)) |
|---|
| 75 |
$(DD D compiler front end source under dual (GPL and Artistic) license) |
|---|
| 76 |
) |
|---|
| 77 |
|
|---|
| 78 |
$(DT $(TT $(DMDDIR)$(SEP)html$(SEP)d$(SEP)) |
|---|
| 79 |
$(DD Documentation) |
|---|
| 80 |
) |
|---|
| 81 |
|
|---|
| 82 |
$(DT $(TT $(DMDDIR)$(SEP)samples$(SEP)d$(SEP)) |
|---|
| 83 |
$(DD Sample D programs) |
|---|
| 84 |
) |
|---|
| 85 |
$(WINDOWS |
|---|
| 86 |
$(DT $(TT $(DMDDIR)\windows\bin\dmd.exe) |
|---|
| 87 |
$(DD D compiler executable) |
|---|
| 88 |
) |
|---|
| 89 |
|
|---|
| 90 |
$(DT $(TT $(DMDDIR)\windows\bin\$(LINK2 http://www.digitalmars.com/ctg/shell.html, shell.exe)) |
|---|
| 91 |
$(DD Simple command line shell) |
|---|
| 92 |
) |
|---|
| 93 |
|
|---|
| 94 |
$(DT $(TT $(DMDDIR)\windows\bin\sc.ini) |
|---|
| 95 |
$(DD Global compiler settings) |
|---|
| 96 |
) |
|---|
| 97 |
|
|---|
| 98 |
$(DT $(TT $(DMDDIR)\windows\lib\$(LIB)) |
|---|
| 99 |
$(DD D runtime library) |
|---|
| 100 |
) |
|---|
| 101 |
) |
|---|
| 102 |
$(LINUX |
|---|
| 103 |
$(DT $(TT $(DMDDIR)/linux/bin/dmd) |
|---|
| 104 |
$(DD D compiler executable) |
|---|
| 105 |
) |
|---|
| 106 |
|
|---|
| 107 |
$(DT $(TT $(DMDDIR)/linux/bin/$(DUMPOBJ)) |
|---|
| 108 |
$(DD Elf file dumper) |
|---|
| 109 |
) |
|---|
| 110 |
|
|---|
| 111 |
$(DT $(TT $(DMDDIR)/linux/bin/$(OBJ2ASM)) |
|---|
| 112 |
$(DD Elf file disassembler) |
|---|
| 113 |
) |
|---|
| 114 |
|
|---|
| 115 |
$(DT $(TT $(DMDDIR)/linux/bin/$(SHELL)) |
|---|
| 116 |
$(DD Simple command line shell) |
|---|
| 117 |
) |
|---|
| 118 |
|
|---|
| 119 |
$(DT $(TT $(DMDDIR)/linux/bin/$(DMD_CONF)) |
|---|
| 120 |
$(DD Global compiler settings (copy to $(TT /etc/dmd.conf))) |
|---|
| 121 |
) |
|---|
| 122 |
|
|---|
| 123 |
$(DT $(TT $(DMDDIR)/linux/lib/$(LIB)) |
|---|
| 124 |
$(DD D runtime library (copy to $(TT /usr/lib/$(LIB)))) |
|---|
| 125 |
) |
|---|
| 126 |
) |
|---|
| 127 |
$(FREEBSD |
|---|
| 128 |
$(DT $(TT $(DMDDIR)/freebsd/bin/dmd) |
|---|
| 129 |
$(DD D compiler executable) |
|---|
| 130 |
) |
|---|
| 131 |
|
|---|
| 132 |
$(DT $(TT $(DMDDIR)/freebsd/bin/$(DUMPOBJ)) |
|---|
| 133 |
$(DD Elf file dumper) |
|---|
| 134 |
) |
|---|
| 135 |
|
|---|
| 136 |
$(DT $(TT $(DMDDIR)/freebsd/bin/$(OBJ2ASM)) |
|---|
| 137 |
$(DD Elf file disassembler) |
|---|
| 138 |
) |
|---|
| 139 |
|
|---|
| 140 |
$(DT $(TT $(DMDDIR)/freebsd/bin/$(SHELL)) |
|---|
| 141 |
$(DD Simple command line shell) |
|---|
| 142 |
) |
|---|
| 143 |
|
|---|
| 144 |
$(DT $(TT $(DMDDIR)/freebsd/bin/$(DMD_CONF)) |
|---|
| 145 |
$(DD Global compiler settings (copy to $(TT /etc/dmd.conf))) |
|---|
| 146 |
) |
|---|
| 147 |
|
|---|
| 148 |
$(DT $(TT $(DMDDIR)/freebsd/lib/$(LIB)) |
|---|
| 149 |
$(DD D runtime library (copy to $(TT /usr/lib/$(LIB)))) |
|---|
| 150 |
) |
|---|
| 151 |
) |
|---|
| 152 |
$(OSX |
|---|
| 153 |
$(DT $(TT $(DMDDIR)/osx/bin/dmd) |
|---|
| 154 |
$(DD D compiler executable) |
|---|
| 155 |
) |
|---|
| 156 |
|
|---|
| 157 |
$(DT $(TT $(DMDDIR)/osx/bin/$(DUMPOBJ)) |
|---|
| 158 |
$(DD Mach-O file dumper) |
|---|
| 159 |
) |
|---|
| 160 |
|
|---|
| 161 |
$(DT $(TT $(DMDDIR)/osx/bin/$(OBJ2ASM)) |
|---|
| 162 |
$(DD Mach-O file disassembler) |
|---|
| 163 |
) |
|---|
| 164 |
|
|---|
| 165 |
$(DT $(TT $(DMDDIR)/osx/bin/$(SHELL)) |
|---|
| 166 |
$(DD Simple command line shell) |
|---|
| 167 |
) |
|---|
| 168 |
|
|---|
| 169 |
$(DT $(TT $(DMDDIR)/osx/bin/$(DMD_CONF)) |
|---|
| 170 |
$(DD Global compiler settings (copy to $(TT /etc/dmd.conf))) |
|---|
| 171 |
) |
|---|
| 172 |
|
|---|
| 173 |
$(DT $(TT $(DMDDIR)/osx/lib/$(LIB)) |
|---|
| 174 |
$(DD D runtime library (copy to $(TT /usr/lib/$(LIB)))) |
|---|
| 175 |
) |
|---|
| 176 |
) |
|---|
| 177 |
|
|---|
| 178 |
) |
|---|
| 179 |
|
|---|
| 180 |
<h2>$(LNAME2 installation, Installation)</h2> |
|---|
| 181 |
|
|---|
| 182 |
$(WINDOWS |
|---|
| 183 |
$(P Open a console window (for Windows XP this is done by |
|---|
| 184 |
clicking on [Start][Command Prompt]). |
|---|
| 185 |
All the tools are command line tools, which means |
|---|
| 186 |
they are run from a console window. |
|---|
| 187 |
Switch to the root directory. |
|---|
| 188 |
Unzip the files in the root directory. |
|---|
| 189 |
$(TT dmd.zip) will create |
|---|
| 190 |
a $(TT $(DMDDIR)) directory with all the files in it. |
|---|
| 191 |
$(TT dmc.zip) will create |
|---|
| 192 |
a $(TT \dm) directory with all the files in it. |
|---|
| 193 |
) |
|---|
| 194 |
|
|---|
| 195 |
$(P A typical session might look like:) |
|---|
| 196 |
|
|---|
| 197 |
$(CONSOLE |
|---|
| 198 |
C:\Documents and Settings\Your Name>cd \ |
|---|
| 199 |
C:\>unzip dmd.zip |
|---|
| 200 |
C:\>unzip dmc.zip |
|---|
| 201 |
) |
|---|
| 202 |
) |
|---|
| 203 |
$(LINUX |
|---|
| 204 |
$(LI Unzip the archive into your home directory. |
|---|
| 205 |
It will create |
|---|
| 206 |
a $(TT ~/dmd) directory with all the files in it. |
|---|
| 207 |
All the tools are command line tools, which means |
|---|
| 208 |
they are run from a console window.) |
|---|
| 209 |
|
|---|
| 210 |
$(LI Copy $(TT $(DMD_CONF)) to $(TT /etc): |
|---|
| 211 |
|
|---|
| 212 |
$(CONSOLE |
|---|
| 213 |
cp $(DMDDIR)/linux/bin/$(DMD_CONF) /etc |
|---|
| 214 |
) |
|---|
| 215 |
) |
|---|
| 216 |
|
|---|
| 217 |
$(LI Put $(TT $(DMDDIR)/linux/bin) on your $(B PATH), |
|---|
| 218 |
or copy the linux executables |
|---|
| 219 |
to $(TT /usr/local/bin)) |
|---|
| 220 |
|
|---|
| 221 |
$(LI Copy the library to $(TT /usr/lib): |
|---|
| 222 |
|
|---|
| 223 |
$(CONSOLE |
|---|
| 224 |
cp $(DMDDIR)/linux/lib/$(LIB) /usr/lib |
|---|
| 225 |
) |
|---|
| 226 |
) |
|---|
| 227 |
) |
|---|
| 228 |
$(FREEBSD |
|---|
| 229 |
$(LI Unzip the archive into your home directory. |
|---|
| 230 |
It will create |
|---|
| 231 |
a $(TT ~/dmd) directory with all the files in it. |
|---|
| 232 |
All the tools are command line tools, which means |
|---|
| 233 |
they are run from a console window.) |
|---|
| 234 |
|
|---|
| 235 |
$(LI Copy $(TT $(DMD_CONF)) to $(TT /etc): |
|---|
| 236 |
|
|---|
| 237 |
$(CONSOLE |
|---|
| 238 |
cp $(DMDDIR)/freebsd/bin/dmd.conf /etc |
|---|
| 239 |
) |
|---|
| 240 |
) |
|---|
| 241 |
|
|---|
| 242 |
$(LI Put $(TT $(DMDDIR)/freebsd/bin) on your $(B PATH), |
|---|
| 243 |
or copy the FreeBSD executables |
|---|
| 244 |
to $(TT /usr/local/bin)) |
|---|
| 245 |
|
|---|
| 246 |
$(LI Copy the library to $(TT /usr/lib): |
|---|
| 247 |
|
|---|
| 248 |
$(CONSOLE |
|---|
| 249 |
cp $(DMDDIR)/freebsd/lib/$(LIB) /usr/lib |
|---|
| 250 |
) |
|---|
| 251 |
) |
|---|
| 252 |
) |
|---|
| 253 |
$(OSX |
|---|
| 254 |
$(LI Put the dmd zip file into your home directory, |
|---|
| 255 |
and unzip it: |
|---|
| 256 |
|
|---|
| 257 |
$(CONSOLE |
|---|
| 258 |
unzip dmd.$(I VERSION).zip |
|---|
| 259 |
) |
|---|
| 260 |
where $(I VERSION) is the particular version of the zip file. |
|---|
| 261 |
) |
|---|
| 262 |
|
|---|
| 263 |
$(LI It will create |
|---|
| 264 |
a $(TT ~/$(DMDDIR)) directory with all the files in it. |
|---|
| 265 |
All the tools are command line tools, which means |
|---|
| 266 |
they are run from a console window.) |
|---|
| 267 |
|
|---|
| 268 |
$(LI Verify that this works by creating $(TT hello.d) in your home directory |
|---|
| 269 |
with these contents: |
|---|
| 270 |
--- |
|---|
| 271 |
import std.stdio; |
|---|
| 272 |
|
|---|
| 273 |
void main() { |
|---|
| 274 |
writeln("hello world!"); |
|---|
| 275 |
} |
|---|
| 276 |
--- |
|---|
| 277 |
and compile and run it with: |
|---|
| 278 |
$(CONSOLE |
|---|
| 279 |
$(DMDDIR)/osx/bin/dmd hello |
|---|
| 280 |
./hello |
|---|
| 281 |
) |
|---|
| 282 |
and it should print: |
|---|
| 283 |
$(CONSOLE |
|---|
| 284 |
hello world! |
|---|
| 285 |
) |
|---|
| 286 |
) |
|---|
| 287 |
|
|---|
| 288 |
$(LI To install a global copy:) |
|---|
| 289 |
|
|---|
| 290 |
$(LI Copy binaries to $(TT /usr/local/bin): |
|---|
| 291 |
|
|---|
| 292 |
$(CONSOLE |
|---|
| 293 |
sudo cp $(DMDDIR)/osx/bin/{dmd,$(DUMPOBJ),$(OBJ2ASM),$(SHELL)$(V2 ,rdmd)} /usr/local/bin |
|---|
| 294 |
sudo cp $(DMDDIR)/osx/bin/dmdx.conf /usr/local/bin/$(DMD_CONF) |
|---|
| 295 |
) |
|---|
| 296 |
) |
|---|
| 297 |
|
|---|
| 298 |
$(LI Copy the library to $(TT /usr/lib): |
|---|
| 299 |
|
|---|
| 300 |
$(CONSOLE |
|---|
| 301 |
sudo cp $(DMDDIR)/osx/lib/$(LIB) /usr/lib |
|---|
| 302 |
) |
|---|
| 303 |
) |
|---|
| 304 |
) |
|---|
| 305 |
|
|---|
| 306 |
$(LINUX |
|---|
| 307 |
<h3>Installing dmd on 64 bit Linux</h3> |
|---|
| 308 |
|
|---|
| 309 |
$(P Since dmd is a 32 bit compiler, the 32 bit gnu libraries must be installed:) |
|---|
| 310 |
|
|---|
| 311 |
$(CONSOLE |
|---|
| 312 |
sudo apt-get install gcc-multilib g++-multilib libc6-i386 libc6-dev-i386 |
|---|
| 313 |
) |
|---|
| 314 |
|
|---|
| 315 |
$(P The $(TT ia32-libs) package has more 32 bit libraries, and may |
|---|
| 316 |
optionally also be installed:) |
|---|
| 317 |
|
|---|
| 318 |
$(CONSOLE |
|---|
| 319 |
sudo apt-get install ia32-libs |
|---|
| 320 |
) |
|---|
| 321 |
|
|---|
| 322 |
$(P If you are using the .deb package for one-click install, it may |
|---|
| 323 |
give you an error about it being only for i386. To force it to install: |
|---|
| 324 |
) |
|---|
| 325 |
|
|---|
| 326 |
$(CONSOLE |
|---|
| 327 |
sudo dpkg -i --force-architecture dmd_X.XXX-0_i386.deb |
|---|
| 328 |
) |
|---|
| 329 |
|
|---|
| 330 |
$(P where X.XXX is the version number of the package. |
|---|
| 331 |
) |
|---|
| 332 |
|
|---|
| 333 |
) |
|---|
| 334 |
|
|---|
| 335 |
$(WINDOWS |
|---|
| 336 |
<h2>Example</h2> |
|---|
| 337 |
|
|---|
| 338 |
$(P Run:) |
|---|
| 339 |
|
|---|
| 340 |
$(CONSOLE |
|---|
| 341 |
$(DMDDIR)$(SEP)$(OS)$(SEP)bin$(SEP)$(SHELL) all.sh |
|---|
| 342 |
) |
|---|
| 343 |
|
|---|
| 344 |
$(P in the $(TT $(DMDDIR)$(SEP)samples$(SEP)d) directory for several small examples.) |
|---|
| 345 |
) |
|---|
| 346 |
|
|---|
| 347 |
|
|---|
| 348 |
<h2>$(LNAME2 switches, Compiler Arguments and Switches)</h2> |
|---|
| 349 |
|
|---|
| 350 |
$(DL |
|---|
| 351 |
$(DT $(B dmd) $(I files)... -$(I switches)... |
|---|
| 352 |
$(DD ) |
|---|
| 353 |
) |
|---|
| 354 |
|
|---|
| 355 |
$(DT $(I files)... |
|---|
| 356 |
$(DD |
|---|
| 357 |
$(TABLE2 File Extensions, |
|---|
| 358 |
$(TR |
|---|
| 359 |
$(TH Extension) |
|---|
| 360 |
$(TH File Type) |
|---|
| 361 |
) |
|---|
| 362 |
$(TR |
|---|
| 363 |
$(TD $(I none)) |
|---|
| 364 |
$(TD D source files) |
|---|
| 365 |
) |
|---|
| 366 |
$(TR |
|---|
| 367 |
$(TD $(B .d)) |
|---|
| 368 |
$(TD D source files) |
|---|
| 369 |
) |
|---|
| 370 |
$(TR |
|---|
| 371 |
$(TD $(B .dd)) |
|---|
| 372 |
$(TD $(LINK2 ddoc.html, Ddoc) source files) |
|---|
| 373 |
) |
|---|
| 374 |
$(TR |
|---|
| 375 |
$(TD $(B .di)) |
|---|
| 376 |
$(TD $(LINK2 #interface_files, D interface files)) |
|---|
| 377 |
) |
|---|
| 378 |
$(TR |
|---|
| 379 |
$(TD $(B .$(OBJEXT))) |
|---|
| 380 |
$(TD Object files to link in) |
|---|
| 381 |
) |
|---|
| 382 |
$(TR |
|---|
| 383 |
$(TD $(B .$(LIBEXT))) |
|---|
| 384 |
$(TD Object code libraries to search) |
|---|
| 385 |
) |
|---|
| 386 |
$(WINDOWS |
|---|
| 387 |
$(TR |
|---|
| 388 |
$(TD $(B .exe)) |
|---|
| 389 |
$(TD Output executable file) |
|---|
| 390 |
) |
|---|
| 391 |
$(TR |
|---|
| 392 |
$(TD $(B .def)) |
|---|
| 393 |
$(TD $(LINK2 http://www.digitalmars.com/ctg/ctgDefFiles.html, module definition file)) |
|---|
| 394 |
) |
|---|
| 395 |
$(TR |
|---|
| 396 |
$(TD $(B .res)) |
|---|
| 397 |
$(TD resource file) |
|---|
| 398 |
) |
|---|
| 399 |
) |
|---|
| 400 |
) |
|---|
| 401 |
) |
|---|
| 402 |
) |
|---|
| 403 |
|
|---|
| 404 |
$(SWITCH $(B @)$(I cmdfile), |
|---|
| 405 |
If $(I cmdfile) is an environment variable, |
|---|
| 406 |
read the compiler arguments and switches from |
|---|
| 407 |
the value of that variable. |
|---|
| 408 |
Otherwise, read compiler arguments and switches from |
|---|
| 409 |
the text file $(I cmdfile) |
|---|
| 410 |
) |
|---|
| 411 |
|
|---|
| 412 |
$(SWITCH $(B -c), |
|---|
| 413 |
compile only, do not link |
|---|
| 414 |
) |
|---|
| 415 |
|
|---|
| 416 |
$(SWITCH $(B -cov), |
|---|
| 417 |
instrument for $(LINK2 code_coverage.html, code coverage analysis) |
|---|
| 418 |
) |
|---|
| 419 |
|
|---|
| 420 |
$(SWITCH $(B -D), |
|---|
| 421 |
generate $(LINK2 ddoc.html, documentation) from source |
|---|
| 422 |
) |
|---|
| 423 |
|
|---|
| 424 |
$(SWITCH $(B -Dd)$(I docdir), |
|---|
| 425 |
write documentation file to $(I docdir) directory |
|---|
| 426 |
) |
|---|
| 427 |
|
|---|
| 428 |
$(SWITCH $(B -Df)$(I filename), |
|---|
| 429 |
write documentation file to $(I filename) |
|---|
| 430 |
) |
|---|
| 431 |
|
|---|
| 432 |
$(SWITCH $(B -d), |
|---|
| 433 |
allow deprecated features |
|---|
| 434 |
) |
|---|
| 435 |
$(SWITCH $(B -debug), |
|---|
| 436 |
compile in $(LINK2 version.html#debug, debug) code |
|---|
| 437 |
) |
|---|
| 438 |
$(SWITCH $(B -debug=)$(I level), |
|---|
| 439 |
compile in $(LINK2 version.html#debug, debug level) <= $(I level) |
|---|
| 440 |
) |
|---|
| 441 |
$(SWITCH $(B -debug=)$(I ident), |
|---|
| 442 |
compile in $(LINK2 version.html#debug, debug identifier) $(I ident) |
|---|
| 443 |
) |
|---|
| 444 |
|
|---|
| 445 |
$(SWITCH $(B -debuglib=)$(I libname), |
|---|
| 446 |
link in $(I libname) as the default library when |
|---|
| 447 |
compiling for symbolic debugging instead of $(B $(LIB)) |
|---|
| 448 |
) |
|---|
| 449 |
$(SWITCH $(B -defaultlib=)$(I libname), |
|---|
| 450 |
link in $(I libname) as the default library when |
|---|
| 451 |
not compiling for symbolic debugging instead of $(B $(LIB)) |
|---|
| 452 |
) |
|---|
| 453 |
$(SWITCH $(B -deps=)$(I filename), |
|---|
| 454 |
write module dependencies as text to $(I filename) |
|---|
| 455 |
) |
|---|
| 456 |
|
|---|
| 457 |
$(OSX |
|---|
| 458 |
$(SWITCH $(B -dylib), |
|---|
| 459 |
generate dylib library |
|---|
| 460 |
) |
|---|
| 461 |
) |
|---|
| 462 |
$(UNIX |
|---|
| 463 |
$(SWITCH $(B -fPIC), |
|---|
| 464 |
generate Position Independent Code (which is used |
|---|
| 465 |
for building shared libraries). |
|---|
| 466 |
$(OSX This is always on for OSX.) |
|---|
| 467 |
) |
|---|
| 468 |
) |
|---|
| 469 |
|
|---|
| 470 |
$(SWITCH $(B -g), |
|---|
| 471 |
$(WINDOWS |
|---|
| 472 |
add CodeView 4 symbolic debug info with |
|---|
| 473 |
$(LINK2 abi.html#codeview, D extensions) |
|---|
| 474 |
for debuggers such as |
|---|
| 475 |
$(LINK2 http://ddbg.mainia.de/releases.html, Ddbg) |
|---|
| 476 |
) |
|---|
| 477 |
$(UNIX |
|---|
| 478 |
add Dwarf symbolic debug info with |
|---|
| 479 |
$(LINK2 abi.html#dwarf, D extensions) |
|---|
| 480 |
for debuggers $(LINUX such as |
|---|
| 481 |
$(LINK2 http://www.zerobugs.org/, ZeroBUGS)) |
|---|
| 482 |
) |
|---|
| 483 |
) |
|---|
| 484 |
|
|---|
| 485 |
$(SWITCH $(B -gc), |
|---|
| 486 |
$(WINDOWS |
|---|
| 487 |
add CodeView 4 symbolic debug info in C format |
|---|
| 488 |
for debuggers such as |
|---|
| 489 |
$(TT $(DMDDIR)\bin\windbg) |
|---|
| 490 |
) |
|---|
| 491 |
$(UNIX |
|---|
| 492 |
add Dwarf symbolic debug info in C format |
|---|
| 493 |
for debuggers such as |
|---|
| 494 |
$(TT gdb) |
|---|
| 495 |
) |
|---|
| 496 |
) |
|---|
| 497 |
|
|---|
| 498 |
$(SWITCH $(B -H), |
|---|
| 499 |
generate $(LINK2 #interface_files, D interface file) |
|---|
| 500 |
) |
|---|
| 501 |
|
|---|
| 502 |
$(SWITCH $(B -Hd)$(I dir), |
|---|
| 503 |
write D interface file to $(I dir) directory |
|---|
| 504 |
) |
|---|
| 505 |
|
|---|
| 506 |
$(SWITCH $(B -Hf)$(I filename), |
|---|
| 507 |
write D interface file to $(I filename) |
|---|
| 508 |
) |
|---|
| 509 |
|
|---|
| 510 |
$(SWITCH $(B --help), |
|---|
| 511 |
print brief help to console |
|---|
| 512 |
) |
|---|
| 513 |
|
|---|
| 514 |
$(SWITCH $(B -inline), |
|---|
| 515 |
inline expand functions at the discretion of the compiler. |
|---|
| 516 |
This can improve performance, at the expense of making |
|---|
| 517 |
it more difficult to use a debugger on it. |
|---|
| 518 |
) |
|---|
| 519 |
|
|---|
| 520 |
$(SWITCH $(B -I)$(I path), |
|---|
| 521 |
where to look for |
|---|
| 522 |
$(LINK2 module.html#ImportDeclaration, imports). |
|---|
| 523 |
$(I path) is a ; separated |
|---|
| 524 |
list of paths. Multiple $(B -I)'s can be used, and the paths |
|---|
| 525 |
are searched in the same order. |
|---|
| 526 |
) |
|---|
| 527 |
|
|---|
| 528 |
$(SWITCH $(B -ignore), |
|---|
| 529 |
ignore unsupported pragmas |
|---|
| 530 |
) |
|---|
| 531 |
|
|---|
| 532 |
$(SWITCH $(B -J)$(I path), |
|---|
| 533 |
where to look for files for |
|---|
| 534 |
$(LINK2 expression.html#ImportExpression, $(I ImportExpression))s. |
|---|
| 535 |
This switch is required in order to use $(I ImportExpression)s. |
|---|
| 536 |
$(I path) is a ; separated |
|---|
| 537 |
list of paths. Multiple $(B -J)'s can be used, and the paths |
|---|
| 538 |
are searched in the same order. |
|---|
| 539 |
) |
|---|
| 540 |
|
|---|
| 541 |
$(SWITCH $(B -L)$(I linkerflag), |
|---|
| 542 |
pass $(I linkerflag) to the |
|---|
| 543 |
$(WINDOWS $(LINK2 http://www.digitalmars.com/ctg/optlink.html, linker)) |
|---|
| 544 |
$(UNIX linker), for example, |
|---|
| 545 |
$(WINDOWS $(TT -L/ma/li))$(UNIX $(TT -L-M)) |
|---|
| 546 |
) |
|---|
| 547 |
|
|---|
| 548 |
$(SWITCH $(B -lib), |
|---|
| 549 |
generate library file as output instead of object file(s). |
|---|
| 550 |
All compiled source files, as well as object files and library |
|---|
| 551 |
files specified on the command line, are inserted into |
|---|
| 552 |
the output library. |
|---|
| 553 |
Compiled source modules may be partitioned into several object |
|---|
| 554 |
modules to improve granularity. |
|---|
| 555 |
The name of the library is taken from the name of the first |
|---|
| 556 |
source module to be compiled. This can be overridden with |
|---|
| 557 |
the $(B -of) switch. |
|---|
| 558 |
) |
|---|
| 559 |
|
|---|
| 560 |
$(SWITCH $(B -man), |
|---|
| 561 |
$(WINDOWS |
|---|
| 562 |
open default browser on this page |
|---|
| 563 |
) |
|---|
| 564 |
$(LINUX |
|---|
| 565 |
open browser specified by the $(B BROWSER) |
|---|
| 566 |
environment variable on this page. If $(B BROWSER) is |
|---|
| 567 |
undefined, $(B x-www-browser) is assumed. |
|---|
| 568 |
) |
|---|
| 569 |
$(FREEBSD |
|---|
| 570 |
open browser specified by the $(B BROWSER) |
|---|
| 571 |
environment variable on this page. If $(B BROWSER) is |
|---|
| 572 |
undefined, $(B x-www-browser) is assumed. |
|---|
| 573 |
) |
|---|
| 574 |
$(OSX |
|---|
| 575 |
open browser specified by the $(B BROWSER) |
|---|
| 576 |
environment variable on this page. If $(B BROWSER) is |
|---|
| 577 |
undefined, $(B Safari) is assumed. |
|---|
| 578 |
) |
|---|
| 579 |
) |
|---|
| 580 |
|
|---|
| 581 |
$(V2 |
|---|
| 582 |
$(SWITCH $(B -noboundscheck), |
|---|
| 583 |
turns off all array bounds checking, even for safe functions |
|---|
| 584 |
) |
|---|
| 585 |
) |
|---|
| 586 |
$(WINDOWS |
|---|
| 587 |
$(SWITCH $(B -nofloat), |
|---|
| 588 |
Prevents emission of $(B __fltused) reference in |
|---|
| 589 |
object files, even if floating point code is present. |
|---|
| 590 |
Useful for library code. |
|---|
| 591 |
) |
|---|
| 592 |
) |
|---|
| 593 |
|
|---|
| 594 |
$(SWITCH $(B -O), |
|---|
| 595 |
Optimize generated code. For fastest executables, compile |
|---|
| 596 |
with the $(B -O -release -inline) switches together. |
|---|
| 597 |
) |
|---|
| 598 |
|
|---|
| 599 |
$(SWITCH $(B -o-), |
|---|
| 600 |
Suppress generation of object file. Useful in |
|---|
| 601 |
conjuction with $(B -D) or $(B -H) flags. |
|---|
| 602 |
) |
|---|
| 603 |
|
|---|
| 604 |
$(SWITCH $(B -od)$(I objdir), |
|---|
| 605 |
$(DD write object files relative to directory $(I objdir) |
|---|
| 606 |
instead of to the current directory) |
|---|
| 607 |
) |
|---|
| 608 |
$(SWITCH $(B -of)$(I filename), |
|---|
| 609 |
Set output file name to $(I filename) in the output |
|---|
| 610 |
directory. The output file can be an object file, |
|---|
| 611 |
executable file, or library file depending on the other |
|---|
| 612 |
switches. |
|---|
| 613 |
) |
|---|
| 614 |
$(SWITCH $(B -op), |
|---|
| 615 |
normally the path for $(B .d) source files is stripped |
|---|
| 616 |
off when generating an object file name. $(B -op) will leave |
|---|
| 617 |
it on. |
|---|
| 618 |
) |
|---|
| 619 |
$(SWITCH $(B -profile), |
|---|
| 620 |
$(LINK2 http://www.digitalmars.com/ctg/trace.html, profile) |
|---|
| 621 |
the runtime performance |
|---|
| 622 |
of the generated code |
|---|
| 623 |
) |
|---|
| 624 |
$(SWITCH $(B -quiet), |
|---|
| 625 |
suppress non-essential compiler messages |
|---|
| 626 |
) |
|---|
| 627 |
$(SWITCH $(B -release), |
|---|
| 628 |
$(V1 compile release version, which means not generating |
|---|
| 629 |
code for contracts, asserts and array bounds checking) |
|---|
| 630 |
$(V2 compile release version, which means not generating |
|---|
| 631 |
code for contracts and asserts. Array bounds checking |
|---|
| 632 |
is not done for system and trusted functions.) |
|---|
| 633 |
) |
|---|
| 634 |
$(SWITCH $(B -run) $(I srcfile args...) |
|---|
| 635 |
compile, link, and run the program $(I srcfile) with the |
|---|
| 636 |
rest of the |
|---|
| 637 |
command line, $(I args...), as the arguments to the program. |
|---|
| 638 |
No .$(OBJEXT) or executable file is left behind. |
|---|
| 639 |
) |
|---|
| 640 |
$(COMMENT |
|---|
| 641 |
$(SWITCH $(B -safe), |
|---|
| 642 |
Statically checks the modules being compiled to ensure they |
|---|
| 643 |
conform to the $(LINK2 safed.html, safe memory model). |
|---|
| 644 |
) |
|---|
| 645 |
) |
|---|
| 646 |
$(SWITCH $(B -unittest), |
|---|
| 647 |
compile in $(LINK2 unittest.html, unittest) code, turns on asserts, and sets the |
|---|
| 648 |
$(TT unittest) $(LINK2 version.html#PredefinedVersions, version identifier) |
|---|
| 649 |
) |
|---|
| 650 |
$(SWITCH $(B -v), |
|---|
| 651 |
verbose |
|---|
| 652 |
) |
|---|
| 653 |
$(V2 |
|---|
| 654 |
$(SWITCH $(B -vtls), |
|---|
| 655 |
print informational messages identifying variables defaulting |
|---|
| 656 |
to thread local storage. Handy for migrating to shared model. |
|---|
| 657 |
) |
|---|
| 658 |
) |
|---|
| 659 |
$(SWITCH $(B -version=)$(I level), |
|---|
| 660 |
compile in $(LINK2 version.html#version, version level) >= $(I level) |
|---|
| 661 |
) |
|---|
| 662 |
$(SWITCH $(B -version=)$(I ident), |
|---|
| 663 |
compile in $(LINK2 version.html#version, version identifier) $(I ident) |
|---|
| 664 |
) |
|---|
| 665 |
$(SWITCH $(B -w), |
|---|
| 666 |
enable $(LINK2 warnings.html, warnings) |
|---|
| 667 |
) |
|---|
| 668 |
$(SWITCH $(B -wi), |
|---|
| 669 |
enable $(LINK2 warnings.html, informational warnings (i.e. compilation |
|---|
| 670 |
still proceeds normally)) |
|---|
| 671 |
) |
|---|
| 672 |
) |
|---|
| 673 |
|
|---|
| 674 |
$(WINDOWS |
|---|
| 675 |
$(P Empty switches, i.e. "", are ignored.) |
|---|
| 676 |
) |
|---|
| 677 |
|
|---|
| 678 |
<h2>$(LNAME2 linking, Linking)</h2> |
|---|
| 679 |
|
|---|
| 680 |
$(P Linking is done directly by the $(B dmd) compiler after a successful |
|---|
| 681 |
compile. To prevent $(B dmd) from running the linker, use the |
|---|
| 682 |
$(B -c) switch. |
|---|
| 683 |
) |
|---|
| 684 |
|
|---|
| 685 |
$(WINDOWS |
|---|
| 686 |
$(P The programs must be linked with the D runtime library $(B phobos.lib), |
|---|
| 687 |
followed by the C runtime library $(B snn.lib). |
|---|
| 688 |
This is done automatically as long as the directories for the |
|---|
| 689 |
libraries are on the LIB environment variable path. A typical |
|---|
| 690 |
way to set LIB would be: |
|---|
| 691 |
) |
|---|
| 692 |
|
|---|
| 693 |
$(CONSOLE |
|---|
| 694 |
set LIB=$(DMDDIR)\lib;\dm\lib |
|---|
| 695 |
) |
|---|
| 696 |
|
|---|
| 697 |
$(P If the $(B dmd) command is used to both compile and link |
|---|
| 698 |
to an executable, it will make certain optimizations that are |
|---|
| 699 |
valid only for Windows executable files. Do not use the resulting |
|---|
| 700 |
.obj files in a DLL. |
|---|
| 701 |
To compile modules into .obj files that can be used in an exe or |
|---|
| 702 |
DLL, compile with $(B -c). |
|---|
| 703 |
) |
|---|
| 704 |
|
|---|
| 705 |
$(P Linking is done using the |
|---|
| 706 |
$(LINK2 http://www.digitalmars.com/ctg/optlink.html, optlink) linker. |
|---|
| 707 |
) |
|---|
| 708 |
) |
|---|
| 709 |
$(UNIX |
|---|
| 710 |
$(P The actual linking is done by running $(B gcc). |
|---|
| 711 |
This ensures compatibility with modules compiled with $(B gcc). |
|---|
| 712 |
) |
|---|
| 713 |
) |
|---|
| 714 |
|
|---|
| 715 |
<h2>$(LNAME2 environment, Environment Variables)</h2> |
|---|
| 716 |
|
|---|
| 717 |
$(P The D compiler dmd uses the following environment variables: |
|---|
| 718 |
) |
|---|
| 719 |
|
|---|
| 720 |
$(DL |
|---|
| 721 |
|
|---|
| 722 |
$(WINDOWS |
|---|
| 723 |
<dt>$(B DFLAGS) |
|---|
| 724 |
<dd>The value of $(B DFLAGS) is treated as if it were appended to the |
|---|
| 725 |
command line to $(B dmd.exe). |
|---|
| 726 |
|
|---|
| 727 |
<dt>$(B LIB) |
|---|
| 728 |
<dd>The linker uses $(B LIB) to search for library files. For D, it will |
|---|
| 729 |
normally be set to: |
|---|
| 730 |
|
|---|
| 731 |
$(CONSOLE |
|---|
| 732 |
set LIB=$(DMDDIR)\lib;\dm\lib |
|---|
| 733 |
) |
|---|
| 734 |
|
|---|
| 735 |
<dt>$(B LINKCMD) |
|---|
| 736 |
<dd> $(B dmd) normally runs the linker by looking for $(B link.exe) |
|---|
| 737 |
along the $(B PATH). To use a specific linker instead, set the |
|---|
| 738 |
$(B LINKCMD) environment variable to it. For example: |
|---|
| 739 |
|
|---|
| 740 |
$(CONSOLE |
|---|
| 741 |
set LINKCMD=\dmd\windows\bin\link |
|---|
| 742 |
) |
|---|
| 743 |
|
|---|
| 744 |
<dt>$(B PATH) |
|---|
| 745 |
<dd>If the linker is not found in the same directory as $(B dmd.exe) |
|---|
| 746 |
is in, the $(B PATH) is searched for it. |
|---|
| 747 |
$(B Note:) other linkers named |
|---|
| 748 |
$(B link.exe) will likely not work. |
|---|
| 749 |
Make sure the Digital Mars $(B link.exe) |
|---|
| 750 |
is found first in the $(B PATH) before other $(B link.exe)'s, |
|---|
| 751 |
or use $(B LINKCMD) to specifically identify which linker |
|---|
| 752 |
to use. |
|---|
| 753 |
) |
|---|
| 754 |
$(UNIX |
|---|
| 755 |
<dt>$(B CC) |
|---|
| 756 |
<dd> $(B dmd) normally runs the linker by looking for $(B gcc) |
|---|
| 757 |
along the $(B PATH). To use a specific linker instead, set the |
|---|
| 758 |
$(B CC) environment variable to it. For example: |
|---|
| 759 |
|
|---|
| 760 |
$(CONSOLE |
|---|
| 761 |
set CC=gcc |
|---|
| 762 |
) |
|---|
| 763 |
$(DT $(B BROWSER) |
|---|
| 764 |
$(DD This sets the browser used to open the manual page with |
|---|
| 765 |
the $(B -man) switch. It defaults to $(TT x-www-browser). |
|---|
| 766 |
) |
|---|
| 767 |
) |
|---|
| 768 |
|
|---|
| 769 |
<dt>$(B DFLAGS) |
|---|
| 770 |
<dd>The value of $(B DFLAGS) is treated as if it were appended to the |
|---|
| 771 |
command line to $(B dmd). |
|---|
| 772 |
) |
|---|
| 773 |
) |
|---|
| 774 |
|
|---|
| 775 |
$(WINDOWS |
|---|
| 776 |
<h2>$(LNAME2 sc_ini, sc.ini Initialization File)</h2> |
|---|
| 777 |
|
|---|
| 778 |
$(P $(B dmd) will look for the initialization file $(B sc.ini) in the |
|---|
| 779 |
following sequence of directories: |
|---|
| 780 |
) |
|---|
| 781 |
|
|---|
| 782 |
$(OL |
|---|
| 783 |
$(LI current working directory) |
|---|
| 784 |
$(LI directory specified by the $(B HOME) environment variable) |
|---|
| 785 |
$(LI directory $(B dmd.exe) resides in) |
|---|
| 786 |
) |
|---|
| 787 |
|
|---|
| 788 |
$(P If found, environment variable |
|---|
| 789 |
settings in the file will override any existing settings. |
|---|
| 790 |
This is handy to make $(B dmd) independent of programs with |
|---|
| 791 |
conflicting use of environment variables. |
|---|
| 792 |
) |
|---|
| 793 |
|
|---|
| 794 |
<h3>Initialization File Format</h3> |
|---|
| 795 |
|
|---|
| 796 |
$(P Comments are lines that begin with $(TT ;) and are ignored. |
|---|
| 797 |
) |
|---|
| 798 |
|
|---|
| 799 |
$(P Environment variables follow the $(TT [Environment]) section |
|---|
| 800 |
heading, in $(I NAME)=$(I value) pairs. |
|---|
| 801 |
The $(I NAME)s are treated as upper case. |
|---|
| 802 |
Comments are lines that start with ;. |
|---|
| 803 |
For example: |
|---|
| 804 |
) |
|---|
| 805 |
|
|---|
| 806 |
$(SCINI |
|---|
| 807 |
; sc.ini file for dmd |
|---|
| 808 |
; Names enclosed by %% are searched for in the existing environment |
|---|
| 809 |
; and inserted. The special name %@P% is replaced with the path |
|---|
| 810 |
; to this file. |
|---|
| 811 |
[Environment] |
|---|
| 812 |
LIB="%@P%\..\lib";\dm\lib |
|---|
| 813 |
$(V1 DFLAGS="-I%@P%\..\src\phobos") |
|---|
| 814 |
$(V2 DFLAGS="-I%@P%\..\src\phobos" "-I%@P%\..\src\druntime\import") |
|---|
| 815 |
LINKCMD="%@P%\..\..\dm\bin" |
|---|
| 816 |
DDOCFILE=mysettings.ddoc |
|---|
| 817 |
) |
|---|
| 818 |
|
|---|
| 819 |
<h3>Location Independence of sc.ini</h3> |
|---|
| 820 |
|
|---|
| 821 |
$(P The $(B %@P%) is replaced with the path to $(TT sc.ini). |
|---|
| 822 |
Thus, if the fully qualified file name $(TT sc.ini) is |
|---|
| 823 |
$(TT c:$(DMDDIR)\bin\sc.ini), then $(B %@P%) will be replaced with |
|---|
| 824 |
$(TT c:$(DMDDIR)\bin), and the above $(TT sc.ini) will be |
|---|
| 825 |
interpreted as: |
|---|
| 826 |
) |
|---|
| 827 |
|
|---|
| 828 |
$(SCINI |
|---|
| 829 |
[Environment] |
|---|
| 830 |
LIB="c:$(DMDDIR)\bin\..\lib";\dm\lib |
|---|
| 831 |
$(V1 DFLAGS="-Ic:$(DMDDIR)\bin\..\src\phobos") |
|---|
| 832 |
$(V2 DFLAGS="-Ic:$(DMDDIR)\bin\..\src\phobos" "-Ic:$(DMDDIR)\bin\..\src\druntime\import") |
|---|
| 833 |
LINKCMD="c:$(DMDDIR)\bin\..\..\dm\bin" |
|---|
| 834 |
DDOCFILE=mysettings.ddoc |
|---|
| 835 |
) |
|---|
| 836 |
|
|---|
| 837 |
$(P This enables your dmd setup to be moved around without having |
|---|
| 838 |
to re-edit $(TT sc.ini). |
|---|
| 839 |
) |
|---|
| 840 |
|
|---|
| 841 |
) |
|---|
| 842 |
$(UNIX |
|---|
| 843 |
<h2>$(LNAME2 dmd_conf, dmd.conf Initialization File)</h2> |
|---|
| 844 |
|
|---|
| 845 |
$(P The dmd file $(TT dmd.conf) is the same as $(TT sc.ini) |
|---|
| 846 |
for Windows, it's just that the file has a different name, |
|---|
| 847 |
enabling a setup common to both Windows and this system to be created |
|---|
| 848 |
without having to re-edit the file.) |
|---|
| 849 |
|
|---|
| 850 |
$(P $(B dmd) will look for the initialization file $(TT dmd.conf) in the |
|---|
| 851 |
following sequence of directories:) |
|---|
| 852 |
|
|---|
| 853 |
$(OL |
|---|
| 854 |
$(LI current working directory) |
|---|
| 855 |
$(LI directory specified by the $(B HOME) environment variable) |
|---|
| 856 |
$(LI directory $(B dmd) resides in) |
|---|
| 857 |
$(LI $(TT /etc/)) |
|---|
| 858 |
) |
|---|
| 859 |
|
|---|
| 860 |
$(P If found, environment variable |
|---|
| 861 |
settings in the file will override any existing settings. |
|---|
| 862 |
This is handy to make $(B dmd) independent of programs with |
|---|
| 863 |
conflicting use of environment variables. |
|---|
| 864 |
) |
|---|
| 865 |
|
|---|
| 866 |
$(P Environment variables follow the $(TT [Environment]) section |
|---|
| 867 |
heading, in $(I NAME)=$(I value) pairs. |
|---|
| 868 |
The $(I NAME)s are treated as upper case. |
|---|
| 869 |
Comments are lines that start with ;. |
|---|
| 870 |
For example: |
|---|
| 871 |
) |
|---|
| 872 |
|
|---|
| 873 |
$(SCINI |
|---|
| 874 |
; dmd.conf file for dmd |
|---|
| 875 |
; Names enclosed by %% are searched for in the existing environment |
|---|
| 876 |
; and inserted. The special name %@P% is replaced with the path |
|---|
| 877 |
; to this file. |
|---|
| 878 |
[Environment] |
|---|
| 879 |
$(V1 DFLAGS=-I%@P%/../src/phobos) |
|---|
| 880 |
$(V2 DFLAGS=-I%@P%/../src/phobos -I%@P%/../src/druntime/import) |
|---|
| 881 |
) |
|---|
| 882 |
) |
|---|
| 883 |
|
|---|
| 884 |
$(WINDOWS |
|---|
| 885 |
<h2>$(LNAME2 problems, Common Installation Problems)</h2> |
|---|
| 886 |
|
|---|
| 887 |
$(UL |
|---|
| 888 |
$(LI Using Cygwin's $(B unzip) utility has been known to cause |
|---|
| 889 |
strange problems. |
|---|
| 890 |
) |
|---|
| 891 |
$(LI Running the compiler under Cygwin's command shell has |
|---|
| 892 |
been also known to cause problems. Try getting it to work |
|---|
| 893 |
under the regular Windows shell $(B cmd.exe) before trying Cygwin's. |
|---|
| 894 |
) |
|---|
| 895 |
$(LI Installing $(B dmd) and $(B dmc) into directory paths with spaces |
|---|
| 896 |
in them causes problems. |
|---|
| 897 |
) |
|---|
| 898 |
) |
|---|
| 899 |
) |
|---|
| 900 |
|
|---|
| 901 |
<hr> |
|---|
| 902 |
<h2>$(LNAME2 differences, Differences between Windows and Linux versions)</h2> |
|---|
| 903 |
|
|---|
| 904 |
$(UL |
|---|
| 905 |
$(LI String literals are read-only under Linux. |
|---|
| 906 |
Attempting to write to them |
|---|
| 907 |
will cause a segment violation.) |
|---|
| 908 |
) |
|---|
| 909 |
<hr> |
|---|
| 910 |
<h2>$(LNAME2 interface_files, D Interface Files)</h2> |
|---|
| 911 |
|
|---|
| 912 |
$(P When an import declaration is processed in a D source file, |
|---|
| 913 |
the compiler searches for the D source file corresponding to |
|---|
| 914 |
the import, and processes that source file to extract the |
|---|
| 915 |
information needed from it. Alternatively, the compiler can |
|---|
| 916 |
instead look for a corresponding $(I D interface file). |
|---|
| 917 |
A D interface file contains only what an import of the module |
|---|
| 918 |
needs, rather than the whole implementation of that module. |
|---|
| 919 |
) |
|---|
| 920 |
|
|---|
| 921 |
$(P The advantages of using a D interface file for imports rather |
|---|
| 922 |
than a D source file are: |
|---|
| 923 |
) |
|---|
| 924 |
|
|---|
| 925 |
$(UL |
|---|
| 926 |
$(LI D interface files are often significantly smaller and much |
|---|
| 927 |
faster to process than the corresponding D source file.) |
|---|
| 928 |
$(LI They can be used to hide the source code, for example, |
|---|
| 929 |
one can ship an object code library along with D interface files |
|---|
| 930 |
rather than the complete source code.) |
|---|
| 931 |
) |
|---|
| 932 |
|
|---|
| 933 |
$(P D interface files can be created by the compiler from a |
|---|
| 934 |
D source file by using the $(B -H) switch to the compiler. |
|---|
| 935 |
D interface files have the $(B .di) file extension. |
|---|
| 936 |
When the compiler resolves an import declaration, it first looks |
|---|
| 937 |
for a $(B .di) D interface file, then it looks for a D source |
|---|
| 938 |
file. |
|---|
| 939 |
) |
|---|
| 940 |
|
|---|
| 941 |
$(P D interface files bear some analogous similarities to C++ |
|---|
| 942 |
header files. But they are not required in the way that C++ |
|---|
| 943 |
header files are, and they are not part of the D language. |
|---|
| 944 |
They are a feature of the compiler, and serve only as an optimization |
|---|
| 945 |
of the build process. |
|---|
| 946 |
) |
|---|
| 947 |
|
|---|
| 948 |
<h2>$(LNAME2 executable, Building Executables)</h2> |
|---|
| 949 |
|
|---|
| 950 |
$(P $(B dmd) can build an executable much faster if as many of the |
|---|
| 951 |
source files as possible are put on the command line.) |
|---|
| 952 |
|
|---|
| 953 |
$(P Another advantage to putting multiple source files on the same |
|---|
| 954 |
invocation of $(B dmd) is that $(B dmd) will be able to do some level |
|---|
| 955 |
of cross-module optimizations, such as function inlining across modules. |
|---|
| 956 |
) |
|---|
| 957 |
|
|---|
| 958 |
<h2>$(LNAME2 library, Building Libraries)</h2> |
|---|
| 959 |
|
|---|
| 960 |
$(P There are three ways to build a library. For example, |
|---|
| 961 |
given $(TT foo.d) and $(TT bar.d) which are to be compiled, and existing |
|---|
| 962 |
object file $(TT bar.$(OBJEXT)) and existing library |
|---|
| 963 |
$(TT def.$(LIBEXT)) which are |
|---|
| 964 |
all to be combined into a library $(TT foo.$(LIBEXT)):) |
|---|
| 965 |
|
|---|
| 966 |
$(OL |
|---|
| 967 |
$(LI Compile modules separately and then run the librarian on them: |
|---|
| 968 |
$(WINDOWS |
|---|
| 969 |
$(CONSOLE |
|---|
| 970 |
dmd -c foo.d |
|---|
| 971 |
dmd -c bar.d |
|---|
| 972 |
$(LINK2 http://www.digitalmars.com/ctg/lib.html, lib) -c -p32 foo.lib foo.obj bar.obj abc.obj def.lib |
|---|
| 973 |
del foo.obj bar.obj |
|---|
| 974 |
) |
|---|
| 975 |
) |
|---|
| 976 |
$(UNIX |
|---|
| 977 |
$(CONSOLE |
|---|
| 978 |
dmd -c foo.d |
|---|
| 979 |
dmd -c bar.d |
|---|
| 980 |
rm -f foo.a |
|---|
| 981 |
ar -r foo.a foo.o bar.o abc.o def.a |
|---|
| 982 |
rm foo.o bar.o |
|---|
| 983 |
) |
|---|
| 984 |
) |
|---|
| 985 |
This option is typical when using a makefile to avoid compiling |
|---|
| 986 |
modules that have already been compiled. |
|---|
| 987 |
) |
|---|
| 988 |
$(LI Compile modules together and then run the librarian on them: |
|---|
| 989 |
$(WINDOWS |
|---|
| 990 |
$(CONSOLE |
|---|
| 991 |
dmd -c foo.d bar.d |
|---|
| 992 |
$(LINK2 http://www.digitalmars.com/ctg/lib.html, lib) -c -p32 foo.lib foo.obj bar.obj abc.obj def.lib |
|---|
| 993 |
del foo.obj bar.obj |
|---|
| 994 |
) |
|---|
| 995 |
) |
|---|
| 996 |
$(UNIX |
|---|
| 997 |
$(CONSOLE |
|---|
| 998 |
dmd -c foo.d bar.d |
|---|
| 999 |
rm -f foo.a |
|---|
| 1000 |
ar -r foo.a foo.o bar.o abc.o def.a |
|---|
| 1001 |
rm foo.o bar.o |
|---|
| 1002 |
) |
|---|
| 1003 |
) |
|---|
| 1004 |
) |
|---|
| 1005 |
$(LI Use $(B dmd) to compile and build library in one operation: |
|---|
| 1006 |
$(CONSOLE |
|---|
| 1007 |
dmd -lib foo.d bar.d abc.$(OBJEXT) def.$(LIBEXT) |
|---|
| 1008 |
) |
|---|
| 1009 |
No object files are written to disk, it's all done in memory. |
|---|
| 1010 |
Using $(B -lib) also has the advantage that modules may be compiled |
|---|
| 1011 |
into multiple object files rather than exactly one per module. |
|---|
| 1012 |
This improves granularity of the library without having to break |
|---|
| 1013 |
up the modules. |
|---|
| 1014 |
) |
|---|
| 1015 |
) |
|---|
| 1016 |
|
|---|
| 1017 |
<h2>$(LNAME2 compiling_dmd, Compiling dmd)</h2> |
|---|
| 1018 |
|
|---|
| 1019 |
$(P Complete source code is provided to build the compiler. |
|---|
| 1020 |
Follow these steps:) |
|---|
| 1021 |
|
|---|
| 1022 |
$(WINDOWS |
|---|
| 1023 |
$(CONSOLE |
|---|
| 1024 |
cd $(DMDDIR)\src\dmd |
|---|
| 1025 |
make -f win32.mak |
|---|
| 1026 |
) |
|---|
| 1027 |
) |
|---|
| 1028 |
$(UNIX |
|---|
| 1029 |
$(CONSOLE |
|---|
| 1030 |
cd ~/$(DMDDIR)/src/dmd |
|---|
| 1031 |
make -f $(OS).mak |
|---|
| 1032 |
) |
|---|
| 1033 |
) |
|---|
| 1034 |
|
|---|
| 1035 |
<h2>$(LNAME2 compiling_phobos, Compiling Phobos)</h2> |
|---|
| 1036 |
|
|---|
| 1037 |
$(P Complete source code is provided to build Phobos, the D runtime library. |
|---|
| 1038 |
Follow these steps:) |
|---|
| 1039 |
|
|---|
| 1040 |
$(V1 |
|---|
| 1041 |
$(WINDOWS |
|---|
| 1042 |
$(CONSOLE |
|---|
| 1043 |
cd $(DMDDIR)\src\phobos |
|---|
| 1044 |
make -f win32.mak DMD=$(DMDDIR)\$(OS)\bin\dmd |
|---|
| 1045 |
) |
|---|
| 1046 |
) |
|---|
| 1047 |
$(UNIX |
|---|
| 1048 |
$(CONSOLE |
|---|
| 1049 |
cd ~/$(DMDDIR)/src/phobos |
|---|
| 1050 |
make -f $(OS).mak DMD=~/$(DMDDIR)/$(OS)/bin/dmd |
|---|
| 1051 |
) |
|---|
| 1052 |
) |
|---|
| 1053 |
) |
|---|
| 1054 |
$(V2 |
|---|
| 1055 |
$(WINDOWS |
|---|
| 1056 |
$(CONSOLE |
|---|
| 1057 |
cd $(DMDDIR)\src\druntime |
|---|
| 1058 |
make -f win32.mak DMD=$(DMDDIR)\$(OS)\bin\dmd |
|---|
| 1059 |
cd ..\phobos |
|---|
| 1060 |
make -f win32.mak DMD=$(DMDDIR)\$(OS)\bin\dmd |
|---|
| 1061 |
) |
|---|
| 1062 |
) |
|---|
| 1063 |
$(UNIX |
|---|
| 1064 |
$(CONSOLE |
|---|
| 1065 |
cd ~/$(DMDDIR)/src/druntime |
|---|
| 1066 |
make -f posix.mak DMD=~/$(DMDDIR)/$(OS)/bin/dmd |
|---|
| 1067 |
cd ../phobos |
|---|
| 1068 |
make -f $(OS).mak DMD=~/$(DMDDIR)/$(OS)/bin/dmd |
|---|
| 1069 |
) |
|---|
| 1070 |
) |
|---|
| 1071 |
) |
|---|
| 1072 |
|
|---|
| 1073 |
) |
|---|
| 1074 |
|
|---|
| 1075 |
Macros: |
|---|
| 1076 |
TITLE=DMD Compiler for $(WINDOWS Windows)$(LINUX Linux)$(OSX OSX)$(FREEBSD FreeBSD) |
|---|
| 1077 |
WIKI=DCompiler |
|---|
| 1078 |
LIB=$(WINDOWS phobos.lib)$(UNIX $(V1 libphobos.a)$(V2 libphobos2.a)) |
|---|
| 1079 |
DMD_CONF=$(LINK2 #dmd_conf, dmd.conf) |
|---|
| 1080 |
SWITCH=$(DT $1)$(DD $+) |
|---|