make-emacs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. #! /usr/bin/perl
  2. # Build Emacs with various options for profiling, debugging,
  3. # with and without warnings enabled etc.
  4. # Copyright (C) 2001-2012 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 Getopt::Long;
  18. use File::Basename;
  19. use Cwd;
  20. # Default CVS sandbox directory. Only used when called from outside
  21. # of the sandbox.
  22. $root = $ENV{"EMACS_ROOT"};
  23. $root = "/gd/gnu/emacs" unless $root;
  24. # Default make command.
  25. $make = $ENV{"EMACS_MAKE"};
  26. $make = "gmake" unless $make;
  27. $rc = GetOptions ("help" => \$help,
  28. "enable-checking" => \$enable_checking,
  29. "no-warn" => \$no_warn,
  30. "check-marked" => \$check_marked,
  31. "all" => \$all,
  32. "no-optim" => \$no_optim,
  33. "union-type" => \$union_type,
  34. "gprof" => \$profile,
  35. "malloc-check" => \$malloc_check,
  36. "no-mcheck" => \$no_mcheck,
  37. "alias" => \$aliasing,
  38. "boot" => \$boot,
  39. "wall" => \$wall,
  40. "gcc3" => \$gcc3,
  41. "trace-selection" => \$trace_selection,
  42. "trace-move" => \$trace_move,
  43. "stabs" => \$use_stabs,
  44. "optim" => \$optim);
  45. if ($rc == 0 || $help)
  46. {
  47. print <<USAGE;
  48. make-emacs [options] ...
  49. Build Emacs.
  50. --help show this help
  51. --all make clean versionclean first
  52. --boot make bootstrap, log to boot.log
  53. --enable-checking ENABLE_CHECKING=1
  54. --no-warn disable warnings
  55. --check-marked GC_CHECK_MARKED_OBJECTS=1
  56. --optim no debug defines
  57. --gprof make Emacs for profiling
  58. --union-type define USE_LISP_UNION_TYPE (bad for GDB)
  59. --malloc-check define GC_MALLOC_CHECK
  60. --no-mcheck don't define GC_MCHECK
  61. --wall compile with -Wall
  62. --gcc3 use GCC 3.0 (30% slower compilation, slower code)
  63. --trace-selection print traces in xselect.c
  64. --trace-move print traces for move_it* functions
  65. --stabs use -gstabs instead -g
  66. Default is to compile with warnings, with -DGC_MCHECK=1, and
  67. with -DGLYPH_DEBUG=1.
  68. USAGE
  69. exit 1;
  70. }
  71. # Chdir to the top-level directory of the tree. If not in a tree
  72. # containing Emacs, use the default.
  73. while (! -f "src/emacs.c" && cwd () ne "/")
  74. {
  75. chdir "..";
  76. }
  77. chdir $root if cwd () eq "/";
  78. chdir "./src";
  79. print "Build in ", cwd (), "\n";
  80. # If first arg is `all' or if `--all' specified, ensure a clean
  81. # build.
  82. if (@ARGV && $ARGV[0] eq "all")
  83. {
  84. $all = 1;
  85. shift @ARGV;
  86. }
  87. system ("$make clean versionclean") if $all;
  88. if ($wall)
  89. {
  90. $warn = "-Wall";
  91. }
  92. elsif (!$no_warn)
  93. {
  94. $warn = "-Wpointer-arith -Wchar-subscripts -Wformat -Wimplicit-int";
  95. $warn = "$warn -Wreturn-type -Wswitch -Wuninitialized";
  96. }
  97. $defs = "-DGLYPH_DEBUG=1" unless $optim;
  98. $defs = "$defs -DGC_CHECK_MARKED_OBJECTS=1" if $check_marked;
  99. $defs = "$defs -DENABLE_CHECKING=1" if $enable_checking;
  100. if ($profile)
  101. {
  102. $opts = "-pg";
  103. $defs = "$defs -DPROFILING=1";
  104. }
  105. else
  106. {
  107. if ($use_stabs)
  108. {
  109. $opts = "-gstabs";
  110. }
  111. else
  112. {
  113. $opts = "-g";
  114. }
  115. }
  116. $defs = "$defs -DUSE_LISP_UNION_TYPE" if $union_type;
  117. $defs = "$defs -DGC_MALLOC_CHECK=1 -DGC_PROTECT_MALLOC_STATE=1" if $malloc_check;
  118. $defs = "$defs -DGC_MCHECK=1" unless $no_mcheck;
  119. $defs = "$defs -DTRACE_SELECTION" if $trace_selection;
  120. $defs = "$defs -DDEBUG_TRACE_MOVE" if $trace_move;
  121. # arch=pentium leads to slightly faster code than without.
  122. $opts = "$opts -march=pentiumpro";
  123. if ($optim)
  124. {
  125. $opts = "$opts -pipe -O3";
  126. }
  127. elsif ($no_optim)
  128. {
  129. $opts = "$opts -pipe -fno-inline";
  130. }
  131. else
  132. {
  133. $opts = "$opts -O -pipe -fno-inline";
  134. }
  135. $opts = "$opts -fstrict-aliasing" if $aliasing;
  136. $opts = "$opts $defs" if $defs;
  137. $opts = "$opts $warn" if $warn;
  138. $cc = "/usr/bin/gcc";
  139. $cc = "/gd/local/bin/gcc" if $gcc3;
  140. if ($boot)
  141. {
  142. chdir "..";
  143. system "mv boot.log boot.log.old" if -f "boot.log";
  144. exit system "script boot.log $make CC=\"$cc\" CFLAGS=\"$opts\" bootstrap";
  145. }
  146. exit system "$make CC=\"$cc\" CFLAGS=\"$opts\" @ARGV";
  147. # Local Variables:
  148. # mode: cperl
  149. # End: