make-emacs 4.4 KB

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