From 1233298563ffb1d2b72a7caecd0c6c4e275100eb Mon Sep 17 00:00:00 2001
From: xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>
Date: Sat, 19 Apr 2008 08:29:17 +0000
Subject: [PATCH] Compilo C, preprocesseur, assembleur sont determines par
 configure et mis dans Makefile.config

git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@622 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
---
 caml/Driver.ml       | 10 ++++++----
 configure            |  5 +++++
 extraction/Makefile  |  6 +++++-
 runtime/Makefile     |  3 +--
 test/c/Makefile      |  5 +++--
 test/cminor/Makefile |  8 +++++---
 6 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/caml/Driver.ml b/caml/Driver.ml
index 09c4622a4..659422e98 100644
--- a/caml/Driver.ml
+++ b/caml/Driver.ml
@@ -98,7 +98,8 @@ module Cil2CsyntaxTranslator = Cil2Csyntax.Make(TypeSpecifierTranslator)
 
 let preprocess ifile ofile =
   let cmd =
-    sprintf "gcc -arch ppc -D__COMPCERT__ -I%s %s -E %s > %s"
+    sprintf "%s -D__COMPCERT__ -I%s %s %s > %s"
+      Configuration.prepro
       !stdlib_path
       (quote_options !prepro_options)
       ifile ofile in
@@ -190,8 +191,8 @@ let compile_cminor_file ifile ofile =
 
 let assemble ifile ofile =
   let cmd =
-    sprintf "gcc -arch ppc -c -o %s %s"
-      ofile ifile in
+    sprintf "%s -o %s %s"
+      Configuration.asm ofile ifile in
   let retcode = command cmd in
   if not !option_dasm then safe_remove ifile;
   if retcode <> 0 then begin
@@ -204,7 +205,8 @@ let assemble ifile ofile =
 
 let linker exe_name files =
   let cmd =
-    sprintf "gcc -arch ppc -o %s %s -L%s -lcompcert"
+    sprintf "%s -o %s %s -L%s -lcompcert"
+      Configuration.linker
       (Filename.quote exe_name)
       (quote_options files)
       !stdlib_path in
diff --git a/configure b/configure
index 7214a3110..bd1b7bbf6 100755
--- a/configure
+++ b/configure
@@ -40,6 +40,11 @@ cat > Makefile.config <<EOF
 PREFIX=$prefix
 BINDIR=$bindir
 LIBDIR=$libdir
+CC=gcc -arch ppc
+CPREPRO=gcc -arch ppc -U__GNUC__ -E
+CASM=gcc -arch ppc -c
+CLINKER=gcc -arch ppc
+LIBMATH=
 EOF
 
 # Extract and configure Cil
diff --git a/extraction/Makefile b/extraction/Makefile
index 5729642c2..54933cc0a 100644
--- a/extraction/Makefile
+++ b/extraction/Makefile
@@ -103,7 +103,11 @@ clean::
 	rm -f ../caml/CMlexer.ml
 
 ../caml/Configuration.ml: ../Makefile.config
-	echo 'let stdlib_path = "$(LIBDIR)"' > ../caml/Configuration.ml
+	(echo 'let stdlib_path = "$(LIBDIR)"'; \
+         echo 'let prepro = "$(CPREPRO)"'; \
+         echo 'let asm = "$(CASM)"'; \
+         echo 'let linker = "$(CLINKER)"') \
+        > ../caml/Configuration.ml
 
 beforedepend:: ../caml/Configuration.ml
 clean::
diff --git a/runtime/Makefile b/runtime/Makefile
index 9a3f621f6..5f1ddc60b 100644
--- a/runtime/Makefile
+++ b/runtime/Makefile
@@ -1,7 +1,6 @@
 include ../Makefile.config
 
-CFLAGS=-arch ppc -O1 -g -Wall
-#CFLAGS=-O1 -g -Wall
+CFLAGS=-O1 -g -Wall
 OBJS=stdio.o calloc.o
 LIB=libcompcert.a
 INCLUDES=stdio.h
diff --git a/test/c/Makefile b/test/c/Makefile
index 43b7b1555..c6cd92890 100644
--- a/test/c/Makefile
+++ b/test/c/Makefile
@@ -1,10 +1,11 @@
+include ../../Makefile.config
+
 CCOMP=../../ccomp
 CCOMPFLAGS=-stdlib ../../runtime -dclight -dasm
 
-CC=gcc -arch ppc
 CFLAGS=-O1 -Wall
 
-LIBS=
+LIBS=$(LIBMATH)
 
 TIME=xtime -o /dev/null -mintime 1.0     # Xavier's hack
 #TIME=time >/dev/null                    # Otherwise
diff --git a/test/cminor/Makefile b/test/cminor/Makefile
index 1d0af21a6..887d1a981 100644
--- a/test/cminor/Makefile
+++ b/test/cminor/Makefile
@@ -1,9 +1,11 @@
+include ../../Makefile.config
+
 CCOMP=../../ccomp
 FLAGS=-S
 CPP=cpp -P
-CC=gcc
-CFLAGS=-arch ppc -g
-ASFLAGS=-arch ppc
+AS=$(CASM)
+CFLAGS=-g
+ASFLAGS=
 VPATH=../harness ../lib
 
 PROGS=fib integr qsort fft sha1 aes almabench manyargs lists \
-- 
GitLab