Convert consecutive FSF copyright years to ranges.
[bpt/emacs.git] / admin / make-emacs
CommitLineData
30b50b5c 1#! /usr/bin/perl
9ad5de0c
GM
2# Build Emacs with various options for profiling, debugging,
3# with and without warnings enabled etc.
30b50b5c 4
73b0cd50 5# Copyright (C) 2001-2011
4e6835db 6# Free Software Foundation, Inc.
9ad5de0c 7
30b50b5c 8# This file is part of GNU Emacs.
9ad5de0c
GM
9
10# GNU Emacs is free software: you can redistribute it and/or modify
30b50b5c 11# it under the terms of the GNU General Public License as published by
9ad5de0c
GM
12# the Free Software Foundation, either version 3 of the License, or
13# (at your option) any later version.
14
30b50b5c
GM
15# GNU Emacs is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18# GNU General Public License for more details.
9ad5de0c 19
30b50b5c 20# You should have received a copy of the GNU General Public License
9ad5de0c 21# along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
30b50b5c 22
30b50b5c
GM
23
24require 5;
25use Getopt::Long;
26use File::Basename;
27use Cwd;
28
29# Default CVS sandbox directory. Only used when called from outside
30# of the sandbox.
31
32$root = $ENV{"EMACS_ROOT"};
33$root = "/gd/gnu/emacs" unless $root;
34
35# Default make command.
36
37$make = $ENV{"EMACS_MAKE"};
38$make = "gmake" unless $make;
39
40$rc = GetOptions ("help" => \$help,
41 "enable-checking" => \$enable_checking,
42 "no-warn" => \$no_warn,
43 "check-marked" => \$check_marked,
44 "all" => \$all,
45 "no-optim" => \$no_optim,
46 "union-type" => \$union_type,
47 "gprof" => \$profile,
48 "malloc-check" => \$malloc_check,
49 "no-mcheck" => \$no_mcheck,
50 "alias" => \$aliasing,
f2164e31 51 "boot" => \$boot,
30b50b5c
GM
52 "wall" => \$wall,
53 "gcc3" => \$gcc3,
54 "trace-selection" => \$trace_selection,
ebbaf4e3 55 "trace-move" => \$trace_move,
30b50b5c
GM
56 "stabs" => \$use_stabs,
57 "optim" => \$optim);
58
59if ($rc == 0 || $help)
60 {
61 print <<USAGE;
62make-emacs [options] ...
63
64Build Emacs.
65
66 --help show this help
67 --all make clean versionclean first
91c829f7 68 --boot make bootstrap, log to boot.log
943756ea 69 --enable-checking ENABLE_CHECKING=1
30b50b5c
GM
70 --no-warn disable warnings
71 --check-marked GC_CHECK_MARKED_OBJECTS=1
72 --optim no debug defines
73 --gprof make Emacs for profiling
74 --union-type define USE_LISP_UNION_TYPE (bad for GDB)
75 --malloc-check define GC_MALLOC_CHECK
76 --no-mcheck dont define GC_MCHECK
77 --wall compile with -Wall
78 --gcc3 use GCC 3.0 (30% slower compilation, slower code)
79 --trace-selection print traces in xselect.c
ebbaf4e3 80 --trace-move print traces for move_it* functions
30b50b5c
GM
81 --stabs use -gstabs instead -g
82
83Default is to compile with warnings, with -DGC_MCHECK=1, and
84with -DGLYPH_DEBUG=1.
85
86USAGE
87 exit 1;
88 }
89
90# Chdir to the top-level directory of the tree. If not in a tree
91# containing Emacs, use the default.
92
93while (! -f "src/emacs.c" && cwd () ne "/")
94 {
95 chdir "..";
96 }
97
98chdir $root if cwd () eq "/";
99chdir "./src";
100print "Build in ", cwd (), "\n";
101
102# If first arg is `all' or if `--all' specified, ensure a clean
103# build.
104
105if (@ARGV && $ARGV[0] eq "all")
106 {
107 $all = 1;
108 shift @ARGV;
109 }
110
111system ("$make clean versionclean") if $all;
112
177c0ea7 113if ($wall)
30b50b5c
GM
114 {
115 $warn = "-Wall";
116 }
117elsif (!$no_warn)
118 {
119 $warn = "-Wpointer-arith -Wchar-subscripts -Wformat -Wimplicit-int";
120 $warn = "$warn -Wreturn-type -Wswitch -Wuninitialized";
121 }
122
123$defs = "-DGLYPH_DEBUG=1" unless $optim;
124$defs = "$defs -DGC_CHECK_MARKED_OBJECTS=1" if $check_marked;
125$defs = "$defs -DENABLE_CHECKING=1" if $enable_checking;
126
177c0ea7 127if ($profile)
30b50b5c
GM
128 {
129 $opts = "-pg";
130 $defs = "$defs -DPROFILING=1";
131 }
132else
133 {
177c0ea7 134 if ($use_stabs)
30b50b5c
GM
135 {
136 $opts = "-gstabs";
137 }
138 else
139 {
140 $opts = "-g";
141 }
142 }
143
144$defs = "$defs -DUSE_LISP_UNION_TYPE" if $union_type;
145$defs = "$defs -DGC_MALLOC_CHECK=1 -DGC_PROTECT_MALLOC_STATE=1" if $malloc_check;
146$defs = "$defs -DGC_MCHECK=1" unless $no_mcheck;
147
148$defs = "$defs -DTRACE_SELECTION" if $trace_selection;
ebbaf4e3 149$defs = "$defs -DDEBUG_TRACE_MOVE" if $trace_move;
30b50b5c
GM
150
151# arch=pentium leads to slightly faster code than without.
152$opts = "$opts -march=pentiumpro";
153
154if ($optim)
155 {
156 $opts = "$opts -pipe -O3";
157 }
158elsif ($no_optim)
159 {
160 $opts = "$opts -pipe -fno-inline";
161 }
162else
163 {
164 $opts = "$opts -O -pipe -fno-inline";
165 }
166
167$opts = "$opts -fstrict-aliasing" if $aliasing;
168
169$opts = "$opts $defs" if $defs;
170$opts = "$opts $warn" if $warn;
171
172$cc = "/usr/bin/gcc";
173$cc = "/gd/local/bin/gcc" if $gcc3;
174
f2164e31
GM
175if ($boot)
176 {
177 chdir "..";
178 system "mv boot.log boot.log.old" if -f "boot.log";
179 exit system "script boot.log $make CC=\"$cc\" CFLAGS=\"$opts\" bootstrap";
180 }
181
30b50b5c
GM
182exit system "$make CC=\"$cc\" CFLAGS=\"$opts\" @ARGV";
183
184# Local Variables:
185# mode: cperl
186# End:
ab5796a9 187