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