Cleanup cfengine3-mode so complete-symbol works again.
[emacs.git] / admin / make-emacs
blob58295c9607a4e149547041f0fae99a305e49b446
1 #! /usr/bin/perl
2 # Build Emacs with various options for profiling, debugging,
3 # with and without warnings enabled etc.
5 # Copyright (C) 2001-2013 Free Software Foundation, Inc.
7 # This file is part of GNU Emacs.
9 # GNU Emacs is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
14 # GNU Emacs is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23 require 5;
24 use Getopt::Long;
25 use File::Basename;
26 use Cwd;
28 # Default CVS sandbox directory. Only used when called from outside
29 # of the sandbox.
31 $root = $ENV{"EMACS_ROOT"};
32 $root = "/gd/gnu/emacs" unless $root;
34 # Default make command.
36 $make = $ENV{"EMACS_MAKE"};
37 $make = "gmake" unless $make;
39 $rc = GetOptions ("help" => \$help,
40 "enable-checking" => \$enable_checking,
41 "no-warn" => \$no_warn,
42 "check-marked" => \$check_marked,
43 "all" => \$all,
44 "no-optim" => \$no_optim,
45 "check-lisp-type" => \$check_lisp_type,
46 "gprof" => \$profile,
47 "malloc-check" => \$malloc_check,
48 "no-mcheck" => \$no_mcheck,
49 "alias" => \$aliasing,
50 "boot" => \$boot,
51 "wall" => \$wall,
52 "gcc3" => \$gcc3,
53 "trace-selection" => \$trace_selection,
54 "trace-move" => \$trace_move,
55 "stabs" => \$use_stabs,
56 "optim" => \$optim);
58 if ($rc == 0 || $help)
60 print <<USAGE;
61 make-emacs [options] ...
63 Build Emacs.
65 --help show this help
66 --all make clean versionclean first
67 --boot make bootstrap, log to boot.log
68 --enable-checking ENABLE_CHECKING=1
69 --no-warn disable warnings
70 --check-marked GC_CHECK_MARKED_OBJECTS=1
71 --optim no debug defines
72 --gprof make Emacs for profiling
73 --check-lisp-type define CHECK_LISP_OBJECT_TYPE
74 --malloc-check define GC_MALLOC_CHECK
75 --no-mcheck don't define GC_MCHECK
76 --wall compile with -Wall
77 --gcc3 use GCC 3.0 (30% slower compilation, slower code)
78 --trace-selection print traces in xselect.c
79 --trace-move print traces for move_it* functions
80 --stabs use -gstabs instead -g
82 Default is to compile with warnings, with -DGC_MCHECK=1, and
83 with -DGLYPH_DEBUG=1.
85 USAGE
86 exit 1;
89 # Chdir to the top-level directory of the tree. If not in a tree
90 # containing Emacs, use the default.
92 while (! -f "src/emacs.c" && cwd () ne "/")
94 chdir "..";
97 chdir $root if cwd () eq "/";
98 chdir "./src";
99 print "Build in ", cwd (), "\n";
101 # If first arg is `all' or if `--all' specified, ensure a clean
102 # build.
104 if (@ARGV && $ARGV[0] eq "all")
106 $all = 1;
107 shift @ARGV;
110 system ("$make clean versionclean") if $all;
112 if ($wall)
114 $warn = "-Wall";
116 elsif (!$no_warn)
118 $warn = "-Wpointer-arith -Wchar-subscripts -Wformat -Wimplicit-int";
119 $warn = "$warn -Wreturn-type -Wswitch -Wuninitialized";
122 $defs = "-DGLYPH_DEBUG=1" unless $optim;
123 $defs = "$defs -DGC_CHECK_MARKED_OBJECTS=1" if $check_marked;
124 $defs = "$defs -DENABLE_CHECKING=1" if $enable_checking;
126 if ($profile)
128 $opts = "-pg";
129 $defs = "$defs -DPROFILING=1";
131 else
133 if ($use_stabs)
135 $opts = "-gstabs";
137 else
139 $opts = "-g";
143 $defs = "$defs -DCHECK_LISP_OBJECT_TYPE" if $check_lisp_type;
144 $defs = "$defs -DGC_MALLOC_CHECK=1 -DGC_PROTECT_MALLOC_STATE=1" if $malloc_check;
145 $defs = "$defs -DGC_MCHECK=1" unless $no_mcheck;
147 $defs = "$defs -DTRACE_SELECTION" if $trace_selection;
148 $defs = "$defs -DDEBUG_TRACE_MOVE" if $trace_move;
150 # arch=pentium leads to slightly faster code than without.
151 $opts = "$opts -march=pentiumpro";
153 if ($optim)
155 $opts = "$opts -pipe -O3";
157 elsif ($no_optim)
159 $opts = "$opts -pipe -fno-inline";
161 else
163 $opts = "$opts -O -pipe -fno-inline";
166 $opts = "$opts -fstrict-aliasing" if $aliasing;
168 $opts = "$opts $defs" if $defs;
169 $opts = "$opts $warn" if $warn;
171 $cc = "/usr/bin/gcc";
172 $cc = "/gd/local/bin/gcc" if $gcc3;
174 if ($boot)
176 chdir "..";
177 system "mv boot.log boot.log.old" if -f "boot.log";
178 exit system "script boot.log $make CC=\"$cc\" CFLAGS=\"$opts\" bootstrap";
181 exit system "$make CC=\"$cc\" CFLAGS=\"$opts\" @ARGV";
183 # Local Variables:
184 # mode: cperl
185 # End: