Merge from trunk.
[bpt/emacs.git] / nt / INSTALL.MSYS
1 Building and Installing Emacs on MS-Windows
2 using the MSYS and MinGW tools
3
4 Copyright (C) 2013 Free Software Foundation, Inc.
5 See the end of the file for license conditions.
6
7 * For the brave (a.k.a. "impatient"):
8
9 For those who have a working MSYS/MinGW development environment and
10 are comfortable with running Posix configure scripts, here are the
11 concise instructions for configuring and building the native Windows
12 binary of Emacs with these tools.
13
14 Do not use this recipe with Cygwin. For building on Cygwin, use the
15 normal installation instructions, ../INSTALL.
16
17 Do not use these instructions if you don't have MSYS installed; for
18 that, see the file INSTALL in this directory.
19
20 0. Start the MSYS Bash window. Everything else below is done from
21 that window's Bash prompt.
22
23 0a. If you are building from the development trunk (as opposed to a
24 release tarball), produce the configure script, by typing from
25 the top-level Emacs source directory:
26
27 ./autogen.sh
28
29 1. If you want to build Emacs outside of the source tree
30 (recommended), create the build directory and chdir there.
31
32 2. Invoke the MSYS-specific configure script:
33
34 - If you are building outside the source tree:
35
36 /PATH/TO/EMACS/SOURCE/TREE/nt/msysconfig.sh --prefix=PREFIX ...
37
38 - If you are building in-place, i.e. inside the source tree:
39
40 ./nt/msysconfig.sh --prefix=PREFIX ...
41
42 It is always preferable to use --prefix to configure Emacs for
43 some specific location of its installed tree; the default
44 /usr/local is not suitable for Windows.
45
46 You can pass other options to the configure script. Here's a
47 typical example (for an in-place debug build):
48
49 CPPFLAGS='-DGLYPH_DEBUG=1' CFLAGS='-O0 -g3' ./nt/msysconfig.sh --prefix=d:/usr/emacs --enable-checking
50
51 3. After the configure script finishes, it should display the
52 resulting configuration. After that, type
53
54 make
55
56 Use "make -j N" if your MSYS Make supports parallel execution;
57 the build will take significantly less time in that case. Here N
58 is the number of simultaneous parallel jobs; use the number of
59 the cores on your system.
60
61 4. Install the produced binaries:
62
63 make install
64
65 If you want the installation tree to go to a place that is
66 different from the one specified by --prefix, say
67
68 make install prefix=/where/ever/you/want
69
70 That's it!
71
72 If these short instructions somehow fail, read the rest of this
73 file.
74
75 * Installing MinGW and MSYS
76
77 Make sure you carefully read the following two sections in their
78 entirety and install/configure the various packages as instructed.
79 A correct installation makes all the rest almost trivial; a botched
80 installation will likely make you miserable for quite some time.
81
82 ** Installing MinGW
83
84 You will need to install the MinGW port of GCC and Binutils, and the
85 MinGW runtime and Windows API distributions, to compile Emacs. You
86 can find these on the MinGW download/Base page:
87
88 https://sourceforge.net/projects/mingw/files/MinGW/Base/
89
90 In general, install the latest stable versions of the following
91 MinGW packages from that page: gcc, binutils, mingw-rt, w32api. You
92 only need the 'bin' and the 'dll' tarballs of each of the above.
93
94 A nice GUI installer, called mingw-get, is available for those who
95 don't like to mess with manual installations. You can download it
96 from here:
97
98 https://sourceforge.net/projects/mingw/files/Installer/mingw-get/
99
100 (This installer only supports packages downloaded from the MinGW
101 site; for the rest you will still need the manual method.)
102
103 MinGW and MSYS packages are distributed as .tar.lzma compressed
104 archives. If you like to install the packages manually, then we
105 recommend to use the Windows port of the 'bsdtar' program to unpack
106 the tarballs. 'bsdtar' is available as part of the 'libarchive'
107 package from here:
108
109 http://sourceforge.net/projects/ezwinports/files/
110
111 The recommended place to install these packages is a single tree
112 starting from some directory on a drive other than the system drive
113 C:. A typical example would be D:\usr, with D:\usr\bin holding the
114 binaries and DLLs (should be added to your Path environment
115 variable), D:\usr\include holding the include files, D:\usr\lib
116 holding the static and import libraries, D:\share holding docs,
117 message catalogs, and package-specific subdirectories, etc.
118
119 Having all the headers and libraries in a single place will greatly
120 reduce the number of -I and -L flags you will have to pass to the
121 configure script (see below), as these files will be right where the
122 compiler expects them.
123
124 We specifically do NOT recommend installing packages below
125 "C:\Program Files" or "C:\Program Files (x86)". These directories
126 are protected on versions of Windows from Vista and on, and you will
127 have difficulties updating and maintaining your installation later,
128 due to UAC elevation prompts, file virtualization, etc. You *have*
129 been warned!
130
131 Additional MinGW packages are required/recommended, especially if
132 you are building from the Bazaar repository:
133
134 . Texinfo (needed to produce the Info manuals when building from bzr)
135
136 Available from http://sourceforge.net/projects/ezwinports/files/.
137
138 . gzip (needed to compress files during "make install")
139
140 Available from http://gnuwin32.sourceforge.net/packages/gzip.htm.
141
142 . pkg-config (needed for building with some optional image libraries)
143
144 Available from http://www.gtk.org/download/win32.php
145
146 Each package might list other packages as prerequisites on its
147 download page (under "Runtime requirements"); download those as
148 well. (Using the GUI installer mingw-get will fetch those
149 prerequisites automatically for you.) A missing prerequisite will
150 manifest itself by the program failing to run and presenting a
151 pop-up dialog that states the missing or incompatible DLL; be sure
152 to find and install these missing DLLs.
153
154 Once you think you have MinGW installed, test the installation by
155 building a trivial "hello, world!" program, and make sure that it
156 builds without any error messages and the binary works when run.
157
158 ** Installing MSYS
159
160 You will also need a reasonably full MSYS installation. MSYS is an
161 environment needed to run the Posix configure scripts and the
162 resulting Makefile's, in order to produce native Windows binaries
163 using the MinGW compiler and runtime libraries. Here's the list of
164 MSYS packages that are required:
165
166 . All the packages from the MSYS Base distribution, listed here:
167
168 https://sourceforge.net/projects/mingw/files/MSYS/Base/
169
170 . Additional packages listed below, from the MSYS Extension
171 distribution here:
172
173 https://sourceforge.net/projects/mingw/files/MSYS/Extension/
174
175 - flex
176 - bison
177 - m4
178 - perl
179 - mktemp
180
181 These should only be needed if you intend to build development
182 versions of Emacs from the Bazaar repository.
183
184 . Additional packages (needed only if building from the Bazaar
185 repository): Automake and Autoconf. They are available from
186 here:
187
188 http://sourceforge.net/projects/ezwinports/files/automake-1.11.6-msys-bin.zip/download
189 http://sourceforge.net/projects/ezwinports/files/autoconf-2.65-msys-bin.zip/download
190
191 If/when you are confident in your MinGW/MSYS installation, and want
192 to speed up the builds, we recommend installing a pre-release
193 version of Make from here:
194
195 https://sourceforge.net/projects/mingwbuilds/files/external-binary-packages/
196
197 These are snapshot builds of many packages, but you only need
198 make.exe from there. The advantage of this make.exe is that it
199 supports parallel builds, so you can use "make -j N" to considerably
200 speed up your builds
201
202 For each of these packages, install the 'bin' and 'dll' tarballs of
203 their latest stable releases. If there's an 'ext' tarball (e.g.,
204 msysCORE and Coreutils have it), download and install those as well.
205
206 Each package might list other packages as prerequisites on its
207 download page (under "Runtime requirements"); download those as
208 well. (Using the GUI installer mingw-get will fetch those
209 prerequisites automatically for you.) A missing prerequisite will
210 manifest itself by the program failing to run and presenting a
211 pop-up dialog that states the missing or incompatible DLL; be sure
212 to find and install these missing DLLs.
213
214 MSYS packages should be installed in a separate tree from MinGW.
215 For example, use D:\MSYS or D:\usr\MSYS as the top-level directory
216 from which you unpack all of the MSYS packages.
217
218 Do NOT add the MSYS bin directory to your Windows Path! Only the
219 MinGW bin directory should be on Path. When you install MSYS, it
220 creates a shortcut on your desktop that invokes the MSYS Bash shell
221 in a Command Prompt window; that shell is already set up so that the
222 MSYS bin directory is on PATH ahead of any other directory. Thus,
223 Bash will find MSYS executables first, which is exactly what you
224 need.
225
226 At this point, you are ready to build Emacs in its basic
227 configuration. If you want to build it with image support, read
228 about the optional image libraries near the end of this document.
229
230 * Generating the configure script.
231
232 If you are building a release or pretest tarball, skip this section,
233 because the configure script is already present in the tarball.
234
235 To build a development snapshot from the Emacs Bazaar repository,
236 you will first need to generate the configure script and a few other
237 auto-generated files. (If this step, described below, somehow
238 fails, you can use the files in the autogen/ directory instead, but
239 they might be outdated, and, most importantly, you are well advised
240 not to disregard any failures in your local build procedures, as
241 these are likely to be symptoms of incorrect installation that will
242 bite you down the road.)
243
244 To generate the configure script, type this at the MSYS Bash prompt
245 from the top-level directory of the Emacs tree:
246
247 ./autogen.sh
248
249 If successful, this command should produce the following output:
250
251 $ ./autogen.sh
252 Checking whether you have the necessary tools...
253 (Read INSTALL.BZR for more details on building Emacs)
254
255 Checking for autoconf (need at least version 2.65)...
256 ok
257 Checking for automake (need at least version 1.11)...
258 ok
259 Your system has the required tools, running autoreconf...
260 You can now run `./configure'.
261
262 * Configuring Emacs for MinGW:
263
264 Now it's time to run the configure script. You can do that either
265 from a separate build directory that is outside of the Emacs source
266 tree (recommended), or from inside the source tree. The former is
267 recommended because it allows you to have several different builds,
268 e.g., an optimized build and an unoptimized one, of the same
269 revision of the source tree; the source tree will be left in its
270 pristine state, without any build products.
271
272 You invoke the configure script like this:
273
274 /PATH/TO/EMACS/SOURCE/TREE/nt/msysconfig.sh --prefix=PREFIX ...
275
276 or, if you are building in-place, i.e. inside the source tree:
277
278 ./nt/msysconfig.sh --prefix=PREFIX ...
279
280 Here PREFIX is the place where you eventually want to install Emacs
281 once built, e.g. d:/usr.
282
283 You can pass additional options to the configure script, for the
284 full list type
285
286 ./nt/msysconfig.sh --help
287
288 As explained in the help text, you may need to tell the script what
289 are the optional flags to invoke the compiler. This is needed if
290 some of your headers and libraries, e.g., those belonging to
291 optional image libraries, are installed in places where the compiler
292 normally doesn't look for them. (Remember that advice above to
293 avoid such situations? here's is where you will start paying for
294 disregarding that recommendation.) For example, if you have libpng
295 headers in C:\emacs\libs\libpng-1.2.37-lib\include and jpeg library
296 headers in C:\emacs\libs\jpeg-6b-4-lib\include, you will need to say
297 something like this:
298
299 CPPFLAGS='-Ic:/emacs/libs/libpng-1.2.37-lib/include -Ic:/emacs/libs/jpeg-6b-4-lib/include' ./nt/msysconfig.sh --prefix=PREFIX
300
301 which is quite a mouth-full, especially if you have more directories
302 to specify... Perhaps you may wish to revisit your installation
303 decisions now.
304
305 A few frequently used options are needed when you want to produce an
306 unoptimized binary with runtime checks enabled:
307
308 CPPFLAGS='-DGLYPH_DEBUG=1' CFLAGS='-O0 -g3' ./nt/msysconfig.sh --prefix=PREFIX --enable-checking
309
310 Once invoked, the configure script will run for some time, and, if
311 successful, will eventually produce a summary of the configuration
312 like this:
313
314 Configured for `i686-pc-mingw32'.
315
316 Where should the build process find the source code? /path/to/emacs/sources
317 What compiler should emacs be built with? gcc -std=gnu99 -O0 -g3
318 Should Emacs use the GNU version of malloc? yes
319 Should Emacs use a relocating allocator for buffers? yes
320 Should Emacs use mmap(2) for buffer allocation? no
321 What window system should Emacs use? w32
322 What toolkit should Emacs use? none
323 Where do we find X Windows header files? NONE
324 Where do we find X Windows libraries? NONE
325 Does Emacs use -lXaw3d? no
326 Does Emacs use -lXpm? yes
327 Does Emacs use -ljpeg? yes
328 Does Emacs use -ltiff? yes
329 Does Emacs use a gif library? yes
330 Does Emacs use -lpng? yes
331 Does Emacs use -lrsvg-2? no
332 Does Emacs use imagemagick? no
333 Does Emacs use -lgpm? no
334 Does Emacs use -ldbus? no
335 Does Emacs use -lgconf? no
336 Does Emacs use GSettings? no
337 Does Emacs use -lselinux? no
338 Does Emacs use -lgnutls? yes
339 Does Emacs use -lxml2? yes
340 Does Emacs use -lfreetype? no
341 Does Emacs use -lm17n-flt? no
342 Does Emacs use -lotf? no
343 Does Emacs use -lxft? no
344 Does Emacs use toolkit scroll bars? yes
345
346 You are almost there, hand on.
347
348 If the output is significantly different, or if configure finishes
349 prematurely and displays some error message, you should examine the
350 configuration log in config.log and find the reason for the failure.
351
352 Once you succeeded in configuring Emacs, and just want to rebuild it
353 after updating your local repository from the main repository, you
354 don't need to re-run the configure script manually, unless you want
355 to change the configure-time options. Just typing "make" will
356 re-run configure if necessary with the exact same options you
357 specified originally, and then go on to invoking Make, described
358 below.
359
360 * Running Make.
361
362 This is simple: just type "make" and sit back, watching the fun.
363
364 If you installed a snapshot build of Make, the build will be much
365 faster if you type "make -j N" instead, where N is the number of
366 independent processing units on your machine. E.g., on a core i7
367 system try using N of 6 or even 8.
368
369 When Make finishes, you can install the produced binaries:
370
371 make install
372
373 or, if you want the installed tree to go in a place different from
374 the configured one, type
375
376 make install prefix=WHEREVER
377
378 Congrats! You have built and installed your own Emacs!
379
380 * Make targets
381
382 The following make targets may be used by users building the source
383 distribution, or users who have checked out of Bazaar after
384 an initial bootstrapping.
385
386 make
387 Builds Emacs from the available sources and pre-compiled lisp files.
388
389 make install
390 Installs the built programs and the auxiliary files.
391
392 make clean
393 Removes object and executable files produced by the build process in
394 the current configuration. After "make clean", you can rebuild with
395 the same configuration using make. useful when you want to be sure
396 that all of the products are built from coherent sources.
397
398 make distclean
399 In addition to the files removed by make clean, this also removes
400 Makefiles and other generated files to get back to the state of a
401 freshly unpacked source distribution. After make distclean, it is
402 necessary to run the configure script followed by "make", in order
403 to rebuild.
404
405 The following targets are intended only for use with the Bazaar sources.
406
407 make bootstrap
408 Removes all the auto-generated files and all the *.elc byte-compiled
409 files, and builds Emacs from scratch. Useful when some change in
410 basic Emacs functionality makes byte compilation of updated files
411 fail.
412
413 make maintainer-clean
414 Removes everything that can be recreated, including compiled Lisp
415 files, to get back to the state of a fresh Bazaar tree. After make
416 maintainer-clean, it is necessary to run configure and "make" or
417 "make bootstrap" to rebuild. Occasionally it may be necessary to
418 run this target after an update.
419
420 * Optional image library support
421
422 In addition to its "native" image formats (pbm and xbm), Emacs can
423 handle other image types: xpm, tiff, gif, png, jpeg and experimental
424 support for svg.
425
426 To build Emacs with support for them, the corresponding headers must
427 be in the include path when the configure script is run. This is be
428 set up using the CPPFLAGS and CFLAGS variable specified on the
429 configure command line. The configure script will report whether it
430 was able to detect the headers. If the results of this testing
431 appear to be incorrect, please look for details in the file
432 config.log: it will show the failed test programs and compiler error
433 messages that should explain what is wrong. (Usually, any such
434 failures happen because some headers are missing due to bad
435 packaging of the image support libraries.)
436
437 Note that any file path passed to the compiler or linker must use
438 forward slashes, or double each backslash, as that is how Bash
439 works.
440
441 If the configure script finds the necessary headers, but they are
442 for some reason incompatible, or if you want to omit support for
443 some image library that is installed on your system for some other
444 reason, use the --without-PACKAGE option to configure, such as
445 --without-gif to omit GIF, --without-tiff to omit TIFF, etc.
446 Passing the --help option to the configure script displays all of
447 the supported --without-PACKAGE options.
448
449 To use the external image support, the DLLs implementing the
450 functionality must be found when Emacs first needs them, either on the
451 PATH, or in the same directory as emacs.exe. Failure to find a
452 library is not an error; the associated image format will simply be
453 unavailable. Note that once Emacs has determined that a library can
454 not be found, there's no way to force it to try again, other than
455 restarting. See the variable `dynamic-library-alist' to configure the
456 expected names of the libraries.
457
458 Some image libraries have dependencies on one another, or on zlib.
459 For example, tiff support depends on the jpeg library. If you did not
460 compile the libraries yourself, you must make sure that any dependency
461 is in the PATH or otherwise accessible and that the binaries are
462 compatible (for example, that they were built with the same compiler).
463
464 Binaries for the image libraries (among many others) can be found at
465 the GnuWin32 project. PNG, JPEG and TIFF libraries are also
466 included with GTK, which is installed along with other Free Software
467 that requires it. Note specifically that, due to some packaging
468 snafus in the GnuWin32-supplied image libraries, you will need to
469 download _source_ packages for some of the libraries in order to get
470 the header files necessary for building Emacs with image support.
471
472 For PNG images, we recommend to use versions 1.4.x and later of
473 libpng, because previous versions had security issues. You can find
474 precompiled libraries and headers on the GTK download page for
475 Windows (http://www.gtk.org/download/win32.php).
476
477 Versions 1.4.0 and later of libpng are binary incompatible with
478 earlier versions, so Emacs will only look for libpng libraries which
479 are compatible with the version it was compiled against. That
480 version is given by the value of the Lisp variable `libpng-version';
481 e.g., 10403 means version 1.4.3. The variable `dynamic-library-alist'
482 is automatically set to name only those DLL names that are known to
483 be compatible with the version given by `libpng-version'. If PNG
484 support does not work for you even though you have the support DLL
485 installed, check the name of the installed DLL against
486 `dynamic-library-alist' and the value of `libpng-version', and
487 download compatible DLLs if needed.
488
489 * Optional GnuTLS support
490
491 If the configure script finds the gnutls/gnutls.h file in the
492 include path, Emacs is built with GnuTLS support by default; to
493 avoid that you can pass the argument --without-gnutls.
494
495 In order to support GnuTLS at runtime, a GnuTLS-enabled Emacs must
496 be able to find the relevant DLLs during startup; failure to do so
497 is not an error, but GnuTLS won't be available to the running
498 session.
499
500 You can get pre-built binaries (including any required DLL and the
501 header files) at http://sourceforge.net/projects/ezwinports/files/.
502
503 * Optional libxml2 support
504
505 If the configure script finds the libxml/HTMLparser.h file in the
506 include path, Emacs is built with libxml2 support by default; to
507 avoid that you can pass the argument --without-libxml2.
508
509 In order to support libxml2 at runtime, a libxml2-enabled Emacs must
510 be able to find the relevant DLLs during startup; failure to do so
511 is not an error, but libxml2 features won't be available to the
512 running session.
513
514 One place where you can get pre-built Windows binaries of libxml2
515 (including any required DLL and the header files) is here:
516
517 http://sourceforge.net/projects/ezwinports/files/
518
519 For runtime support of libxml2, you will also need to install the
520 libiconv "development" tarball, because the libiconv headers need to
521 be available to the compiler when you compile with libxml2 support.
522 A MinGW port of libiconv can be found on the MinGW site:
523
524 http://sourceforge.net/projects/mingw/files/MinGW/Base/libiconv/
525
526 You need the libiconv-X.Y.Z-N-mingw32-dev.tar.lzma tarball from that
527 site.
528
529 * Experimental SVG support
530
531 SVG support is currently experimental, and not built by default.
532 Specify --with-rsvg and ensure you have all the dependencies in your
533 include path. Unless you have built a minimalist librsvg yourself
534 (untested), librsvg depends on a significant chunk of GTK+ to build,
535 plus a few Gnome libraries, libxml2, libbz2 and zlib at runtime. The
536 easiest way to obtain the dependencies required for building is to
537 download a pre-bundled GTK+ development environment for Windows.
538
539 To use librsvg at runtime, ensure that librsvg and its dependencies
540 are on your PATH. If you didn't build librsvg yourself, you will
541 need to check with where you downloaded it from for the
542 dependencies, as there are different build options. If it is a
543 short list, then it most likely only lists the immediate
544 dependencies of librsvg, but the dependencies themselves have
545 dependencies - so don't download individual libraries from GTK+,
546 download and install the whole thing. If you think you've got all
547 the dependencies and SVG support is still not working, check your
548 PATH for other libraries that shadow the ones you downloaded.
549 Libraries of the same name from different sources may not be
550 compatible, this problem was encountered with libbzip2 from GnuWin32
551 with libcroco from gnome.org.
552
553 If you can see etc/images/splash.svg, then you have managed to get
554 SVG support working. Congratulations for making it through DLL hell
555 to this point. You'll probably find that some SVG images crash
556 Emacs. Problems have been observed in some images that contain
557 text, they seem to be a problem in the Windows port of Pango, or
558 maybe a problem with the way Cairo or librsvg is using it that
559 doesn't show up on other platforms.
560
561 \f
562 This file is part of GNU Emacs.
563
564 GNU Emacs is free software: you can redistribute it and/or modify
565 it under the terms of the GNU General Public License as published by
566 the Free Software Foundation, either version 3 of the License, or
567 (at your option) any later version.
568
569 GNU Emacs is distributed in the hope that it will be useful,
570 but WITHOUT ANY WARRANTY; without even the implied warranty of
571 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
572 GNU General Public License for more details.
573
574 You should have received a copy of the GNU General Public License
575 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.