Merged in autoconf branch.  This provides configuration via the autoconf
system.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7014 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Archive/ArchiveReader.cpp b/lib/Archive/ArchiveReader.cpp
index 450fd04..f631f2d 100644
--- a/lib/Archive/ArchiveReader.cpp
+++ b/lib/Archive/ArchiveReader.cpp
@@ -11,9 +11,9 @@
 
 #include "llvm/Bytecode/Reader.h"
 #include "llvm/Module.h"
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <fcntl.h>
+#include "Config/sys/stat.h"
+#include "Config/sys/mman.h"
+#include "Config/fcntl.h"
 
 namespace {
   struct ar_hdr {
diff --git a/lib/AsmParser/Lexer.l b/lib/AsmParser/Lexer.l
index e124d24..983e667 100644
--- a/lib/AsmParser/Lexer.l
+++ b/lib/AsmParser/Lexer.l
@@ -23,7 +23,7 @@
 #include <list>
 #include "llvmAsmParser.h"
 #include <ctype.h>
-#include <stdlib.h>
+#include "Config/stdlib.h"
 
 #define RET_TOK(type, Enum, sym) \
   llvmAsmlval.type = Instruction::Enum; return sym
diff --git a/lib/AsmParser/Makefile b/lib/AsmParser/Makefile
index 0503b04..22e4357 100644
--- a/lib/AsmParser/Makefile
+++ b/lib/AsmParser/Makefile
@@ -5,3 +5,9 @@
 
 include $(LEVEL)/Makefile.common
 
+#
+# Make the source code file for the lexer depend upon the header file generated
+# by the Bison parser.  This prevents the generation of dependencies from
+# being performed until after the header file has been created.
+#
+Lexer.cpp: llvmAsmParser.h
diff --git a/lib/Bytecode/Archive/ArchiveReader.cpp b/lib/Bytecode/Archive/ArchiveReader.cpp
index 450fd04..f631f2d 100644
--- a/lib/Bytecode/Archive/ArchiveReader.cpp
+++ b/lib/Bytecode/Archive/ArchiveReader.cpp
@@ -11,9 +11,9 @@
 
 #include "llvm/Bytecode/Reader.h"
 #include "llvm/Module.h"
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <fcntl.h>
+#include "Config/sys/stat.h"
+#include "Config/sys/mman.h"
+#include "Config/fcntl.h"
 
 namespace {
   struct ar_hdr {
diff --git a/lib/Bytecode/Reader/ArchiveReader.cpp b/lib/Bytecode/Reader/ArchiveReader.cpp
index 450fd04..f631f2d 100644
--- a/lib/Bytecode/Reader/ArchiveReader.cpp
+++ b/lib/Bytecode/Reader/ArchiveReader.cpp
@@ -11,9 +11,9 @@
 
 #include "llvm/Bytecode/Reader.h"
 #include "llvm/Module.h"
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <fcntl.h>
+#include "Config/sys/stat.h"
+#include "Config/sys/mman.h"
+#include "Config/fcntl.h"
 
 namespace {
   struct ar_hdr {
diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp
index 1a7e3d5..42ba5d9 100644
--- a/lib/Bytecode/Reader/Reader.cpp
+++ b/lib/Bytecode/Reader/Reader.cpp
@@ -11,17 +11,17 @@
 //===----------------------------------------------------------------------===//
 
 #include "ReaderInternals.h"
+#include "Config/sys/mman.h"
 #include "llvm/Bytecode/Reader.h"
 #include "llvm/Bytecode/Format.h"
 #include "llvm/Module.h"
 #include "llvm/Constants.h"
 #include "llvm/iPHINode.h"
 #include "llvm/iOther.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <fcntl.h>
-#include <unistd.h>
+#include "Config/sys/types.h"
+#include "Config/sys/stat.h"
+#include "Config/fcntl.h"
+#include "Config/unistd.h"
 #include <algorithm>
 
 bool BytecodeParser::getTypeSlot(const Type *Ty, unsigned &Slot) {
diff --git a/lib/Bytecode/Writer/Writer.cpp b/lib/Bytecode/Writer/Writer.cpp
index ad13eef..f8d9489 100644
--- a/lib/Bytecode/Writer/Writer.cpp
+++ b/lib/Bytecode/Writer/Writer.cpp
@@ -26,7 +26,7 @@
 #include "llvm/DerivedTypes.h"
 #include "Support/STLExtras.h"
 #include "Support/Statistic.h"
-#include <string.h>
+#include "Config/string.h"
 #include <algorithm>
 
 static RegisterPass<WriteBytecodePass> X("emitbytecode", "Bytecode Writer");
diff --git a/lib/CodeGen/InstrSelection/InstrForest.cpp b/lib/CodeGen/InstrSelection/InstrForest.cpp
index ea2ccad..ceaefd8 100644
--- a/lib/CodeGen/InstrSelection/InstrForest.cpp
+++ b/lib/CodeGen/InstrSelection/InstrForest.cpp
@@ -21,6 +21,7 @@
 #include "llvm/Type.h"
 #include "llvm/CodeGen/MachineInstr.h"
 #include "Support/STLExtras.h"
+#include "Config/alloca.h"
 
 //------------------------------------------------------------------------ 
 // class InstrTreeNode
diff --git a/lib/CodeGen/MachineFunction.cpp b/lib/CodeGen/MachineFunction.cpp
index 57b34fa..83567a4 100644
--- a/lib/CodeGen/MachineFunction.cpp
+++ b/lib/CodeGen/MachineFunction.cpp
@@ -19,7 +19,7 @@
 #include "llvm/Function.h"
 #include "llvm/iOther.h"
 #include "llvm/Pass.h"
-#include <limits.h>
+#include "Config/limits.h"
 
 const int INVALID_FRAME_OFFSET = INT_MAX; // std::numeric_limits<int>::max();
 
diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp
index 1750b58..532f8fd 100644
--- a/lib/ExecutionEngine/ExecutionEngine.cpp
+++ b/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -12,7 +12,7 @@
 #include "llvm/Module.h"
 #include "llvm/Target/TargetData.h"
 #include "Support/Statistic.h"
-#include <dlfcn.h>
+#include "Config/dlfcn.h"
 
 Statistic<> NumInitBytes("lli", "Number of bytes of global vars initialized");
 
diff --git a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
index 941160c..b171aff 100644
--- a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
+++ b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
@@ -17,10 +17,10 @@
 #include "llvm/SymbolTable.h"
 #include "llvm/Target/TargetData.h"
 #include <map>
-#include <dlfcn.h>
-#include <link.h>
+#include "Config/dlfcn.h"
+#include "Config/link.h"
 #include <cmath>
-#include <stdio.h>
+#include "Config/stdio.h"
 using std::vector;
 
 typedef GenericValue (*ExFunc)(FunctionType *, const vector<GenericValue> &);
diff --git a/lib/ExecutionEngine/JIT/Intercept.cpp b/lib/ExecutionEngine/JIT/Intercept.cpp
index 36eca30..ba49bbd 100644
--- a/lib/ExecutionEngine/JIT/Intercept.cpp
+++ b/lib/ExecutionEngine/JIT/Intercept.cpp
@@ -9,7 +9,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "VM.h"
-#include <dlfcn.h>    // dlsym access
+#include "Config/dlfcn.h"    // dlsym access
 #include <iostream>
 
 // AtExitList - List of functions registered with the at_exit function
diff --git a/lib/ExecutionEngine/JIT/JITEmitter.cpp b/lib/ExecutionEngine/JIT/JITEmitter.cpp
index 4ef78a5..506da11 100644
--- a/lib/ExecutionEngine/JIT/JITEmitter.cpp
+++ b/lib/ExecutionEngine/JIT/JITEmitter.cpp
@@ -6,6 +6,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "VM.h"
+#include "Config/sys/mman.h"
 #include "llvm/CodeGen/MachineCodeEmitter.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineConstantPool.h"
@@ -82,7 +83,7 @@
   static unsigned long Counter = 0;
   pa = mmap((void*)(0x140000000UL+Counter), pageSize*NumPages,
             PROT_READ|PROT_WRITE|PROT_EXEC,
-            MAP_PRIVATE|MAP_ANON|MAP_FIXED, -1, 0); /* fd = -1 */
+            MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED, -1, 0); /* fd = -1 */
   Counter += pageSize*NumPages;
 #else
   std::cerr << "This architecture is not supported by the JIT\n";
diff --git a/lib/ExecutionEngine/Makefile b/lib/ExecutionEngine/Makefile
index 6ee2d3f..d74adf9 100644
--- a/lib/ExecutionEngine/Makefile
+++ b/lib/ExecutionEngine/Makefile
@@ -3,7 +3,7 @@
 PARALLEL_DIRS = Interpreter JIT
 
 # Get the config name...
-include $(LEVEL)/Makefile.$(shell uname)
+include $(LEVEL)/Makefile.config
 
 # Generic JIT libraries
 JITLIBS   = lli-jit codegen
diff --git a/lib/Makefile b/lib/Makefile
index 73caa73..8364f3c 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -1,6 +1,8 @@
 LEVEL = ..
 
-PARALLEL_DIRS = VMCore Analysis Transforms AsmParser Bytecode Support CodeGen Target CWriter Reoptimizer
+PARALLEL_DIRS = VMCore Analysis Transforms AsmParser Bytecode Support CodeGen Target CWriter
+
+OPTIONAL_DIRS = Reoptimizer
 
 include $(LEVEL)/Makefile.common
 
diff --git a/lib/Support/PluginLoader.cpp b/lib/Support/PluginLoader.cpp
index dce923a..b973b16 100644
--- a/lib/Support/PluginLoader.cpp
+++ b/lib/Support/PluginLoader.cpp
@@ -11,8 +11,8 @@
 //===----------------------------------------------------------------------===//
 
 #include "Support/CommandLine.h"
-#include <dlfcn.h>
-#include <link.h>
+#include "Config/dlfcn.h"
+#include "Config/link.h"
 #include <iostream>
 
 namespace {
diff --git a/lib/Support/Signals.cpp b/lib/Support/Signals.cpp
index 503d3a6..b3ad9c4 100644
--- a/lib/Support/Signals.cpp
+++ b/lib/Support/Signals.cpp
@@ -32,7 +32,7 @@
 
 
 // SignalHandler - The signal handler that runs...
-static void SignalHandler(int Sig) {
+static RETSIGTYPE SignalHandler(int Sig) {
   while (!FilesToRemove.empty()) {
     std::remove(FilesToRemove.back().c_str());
     FilesToRemove.pop_back();
diff --git a/lib/Support/SystemUtils.cpp b/lib/Support/SystemUtils.cpp
index 51f3d18..97e1306 100644
--- a/lib/Support/SystemUtils.cpp
+++ b/lib/Support/SystemUtils.cpp
@@ -10,12 +10,12 @@
 #include <fstream>
 #include <iostream>
 #include <cstdlib>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <errno.h>
+#include "Config/sys/types.h"
+#include "Config/sys/stat.h"
+#include "Config/fcntl.h"
+#include "Config/sys/wait.h"
+#include "Config/unistd.h"
+#include "Config/errno.h"
 
 /// removeFile - Delete the specified file
 ///
diff --git a/lib/Support/Timer.cpp b/lib/Support/Timer.cpp
index 96b63f1..79d4c1c 100644
--- a/lib/Support/Timer.cpp
+++ b/lib/Support/Timer.cpp
@@ -4,15 +4,16 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "Config/malloc.h"
+
 #include "Support/Timer.h"
 #include "Support/CommandLine.h"
-#include <sys/resource.h>
-#include <sys/time.h>
-#include <unistd.h>
-#ifndef __FreeBSD__
-#include <malloc.h>
-#endif // __FreeBSD__
-#include <stdio.h>
+
+#include "Config/sys/resource.h"
+#include "Config/sys/time.h"
+#include "Config/unistd.h"
+#include "Config/malloc.h"
+#include "Config/stdio.h"
 #include <iostream>
 #include <algorithm>
 #include <functional>
@@ -21,10 +22,12 @@
 std::string LibSupportInfoOutputFilename;
 
 namespace {
+#ifdef HAVE_MALLINFO
   cl::opt<bool>
   TrackSpace("track-memory", cl::desc("Enable -time-passes memory "
                                       "tracking (this may be slow)"),
              cl::Hidden);
+#endif
 
   cl::opt<std::string, true>
   InfoOutputFilename("info-output-file",
@@ -76,12 +79,12 @@
 }
 
 static long getMemUsage() {
-#ifndef __FreeBSD__
+#ifdef HAVE_MALLINFO
   if (TrackSpace) {
     struct mallinfo MI = mallinfo();
     return MI.uordblks/*+MI.hblkhd*/;
   }
-#endif // __FreeBSD__
+#endif
   return 0;
 }
 
diff --git a/lib/Target/SparcV9/InstrSelection/InstrForest.cpp b/lib/Target/SparcV9/InstrSelection/InstrForest.cpp
index ea2ccad..ceaefd8 100644
--- a/lib/Target/SparcV9/InstrSelection/InstrForest.cpp
+++ b/lib/Target/SparcV9/InstrSelection/InstrForest.cpp
@@ -21,6 +21,7 @@
 #include "llvm/Type.h"
 #include "llvm/CodeGen/MachineInstr.h"
 #include "Support/STLExtras.h"
+#include "Config/alloca.h"
 
 //------------------------------------------------------------------------ 
 // class InstrTreeNode
diff --git a/lib/Target/SparcV9/Makefile b/lib/Target/SparcV9/Makefile
index c51362e..2ecca3c 100644
--- a/lib/Target/SparcV9/Makefile
+++ b/lib/Target/SparcV9/Makefile
@@ -14,20 +14,29 @@
 Debug/Sparc.burm.cpp: Debug/Sparc.burm Debug/.dir
 	$(RunBurg) $< -o $@
 
-$(BUILD_OBJ_DIR)/Debug/Sparc.burm.o: Debug/Sparc.burm.cpp
+$(BUILD_OBJ_DIR)/Debug/Sparc.burm.lo: Debug/Sparc.burm.cpp
 	$(CompileG) $< -o $@
 
-$(BUILD_OBJ_DIR)/Release/Sparc.burm.o: Debug/Sparc.burm.cpp
+$(BUILD_OBJ_DIR)/Release/Sparc.burm.lo: Debug/Sparc.burm.cpp
 	$(CompileO) $< -o $@
 
-$(BUILD_OBJ_DIR)/Profile/Sparc.burm.o: Debug/Sparc.burm.cpp
+$(BUILD_OBJ_DIR)/Profile/Sparc.burm.lo: Debug/Sparc.burm.cpp
 	$(CompileP) $< -o $@
 
+#$(BUILD_OBJ_DIR)/Debug/Sparc.burm.o: Debug/Sparc.burm.cpp
+#	$(CompileG) $< -o $@
+
+#$(BUILD_OBJ_DIR)/Release/Sparc.burm.o: Debug/Sparc.burm.cpp
+#	$(CompileO) $< -o $@
+
+#$(BUILD_OBJ_DIR)/Profile/Sparc.burm.o: Debug/Sparc.burm.cpp
+#	$(CompileP) $< -o $@
+
 Debug/Sparc.burg.in1 : Sparc.burg.in Debug/.dir
-	$(CXX) -E -I$(LEVEL)/include $(DEBUG_FLAG) -x c++ $< | sed '/^# /d' | sed 's/Ydefine/#define/' > $@
+	$(CXX) -E -I$(LEVEL)/include $(DEBUG_FLAG) -x c++ $< | ${SED} '/^# /d' | ${SED} 's/Ydefine/#define/' > $@
 
 Debug/Sparc.burm : Debug/Sparc.burg.in1
-	$(CXX) -E -I$(LEVEL)/include $(DEBUG_FLAG) -x c++ $< | sed '/^# /d' | sed 's/Xinclude/#include/g' | sed 's/Xdefine/#define/g' > $@
+	$(CXX) -E -I$(LEVEL)/include $(DEBUG_FLAG) -x c++ $< | ${SED} '/^# /d' | ${SED} 's/Xinclude/#include/g' | ${SED} 's/Xdefine/#define/g' > $@
 
 $(BUILD_OBJ_DIR)/Depend/Sparc.burm.d: $(BUILD_OBJ_DIR)/Depend/.dir
 	touch $@
@@ -35,8 +44,8 @@
 SparcV9CodeEmitter.cpp: SparcV9CodeEmitter.inc
 
 SparcV9CodeEmitter.inc: SparcV9.td SparcV9_F2.td SparcV9_F3.td SparcV9_F4.td SparcV9_Reg.td $(TBLGEN)
-	@echo "TableGen-erating $@"
+	@${ECHO} "TableGen-erating $@"
 	cpp -P SparcV9.td | $(TBLGEN) -gen-emitter -o $@
 
 clean::
-	rm -f SparcV9CodeEmitter.inc
+	${RM} -f SparcV9CodeEmitter.inc
diff --git a/lib/Target/SparcV9/SparcV9InstrInfo.cpp b/lib/Target/SparcV9/SparcV9InstrInfo.cpp
index 25d4627..4fea658 100644
--- a/lib/Target/SparcV9/SparcV9InstrInfo.cpp
+++ b/lib/Target/SparcV9/SparcV9InstrInfo.cpp
@@ -13,7 +13,7 @@
 #include "llvm/Function.h"
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
-#include <stdlib.h>
+#include "Config/stdlib.h"
 
 static const uint32_t MAXLO   = (1 << 10) - 1; // set bits set by %lo(*)
 static const uint32_t MAXSIMM = (1 << 12) - 1; // set bits in simm13 field of OR
diff --git a/lib/Target/SparcV9/SparcV9Internals.h b/lib/Target/SparcV9/SparcV9Internals.h
index a180cb6..5c14ae6 100644
--- a/lib/Target/SparcV9/SparcV9Internals.h
+++ b/lib/Target/SparcV9/SparcV9Internals.h
@@ -17,7 +17,7 @@
 #include "llvm/Target/TargetOptInfo.h"
 #include "llvm/Type.h"
 #include "SparcRegClassInfo.h"
-#include <sys/types.h>
+#include "Config/sys/types.h"
 
 class LiveRange;
 class UltraSparc;
diff --git a/lib/Target/X86/X86CodeEmitter.cpp b/lib/Target/X86/X86CodeEmitter.cpp
index bfb4aaa..c6df598 100644
--- a/lib/Target/X86/X86CodeEmitter.cpp
+++ b/lib/Target/X86/X86CodeEmitter.cpp
@@ -13,7 +13,7 @@
 #include "llvm/CodeGen/MachineInstr.h"
 #include "llvm/Value.h"
 #include "Support/Statistic.h"
-#include "Support/Alloca.h"
+#include "Config/alloca.h"
 
 namespace {
   Statistic<>
diff --git a/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp b/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp
index 16b07f7..9ba8731 100644
--- a/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp
+++ b/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp
@@ -16,7 +16,7 @@
 #include "llvm/iOperators.h"
 #include "llvm/iPHINode.h"
 #include "llvm/Module.h"
-#include <stdio.h>
+#include "Config/stdio.h"
 
 #define INSERT_LOAD_COUNT
 #define INSERT_STORE
diff --git a/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp b/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp
index 138f582..c874147 100644
--- a/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp
+++ b/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp
@@ -34,7 +34,7 @@
 #include "llvm/Module.h"
 #include "Graph.h"
 #include <fstream>
-#include <stdio.h>
+#include "Config/stdio.h"
 using std::vector;
 
 struct ProfilePaths : public FunctionPass {
diff --git a/lib/VMCore/Pass.cpp b/lib/VMCore/Pass.cpp
index 04299e9..ec193de 100644
--- a/lib/VMCore/Pass.cpp
+++ b/lib/VMCore/Pass.cpp
@@ -11,10 +11,10 @@
 #include "llvm/Module.h"
 #include "Support/STLExtras.h"
 #include "Support/TypeInfo.h"
-#include <stdio.h>
-#include <sys/resource.h>
-#include <sys/time.h>
-#include <unistd.h>
+#include "Config/stdio.h"
+#include "Config/sys/resource.h"
+#include "Config/sys/time.h"
+#include "Config/unistd.h"
 #include <set>
 
 // IncludeFile - Stub function used to help linking out.