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