egcs needs a system.h?

H.J. Lu hjl@lucon.org
Thu Feb 12 19:36:00 GMT 1998


> 
> 
> 	Sorry to be so thick :-), but I still don't see the problem.
> Would you please help me understand without having me go off and try a
> build != host cross build?

Any binaries generated during the stage 0 and executed during the
stage 0 are for the build machine. Some binaries may have
2 copies, one for the host machine and the other for the
build machine. They have to be compiled twice. It is very tricky.
It took me a while to get it working. Read gcc/build-make may
help a little bit.

> 
> Eg, currently calls.c in the top level directory includes <stdio.h>.
> If I instead have calls.c include "system.h" and system.h includes
> <stdio.h> there is no difference in the end result, right?
> 
> 	And if all these includes are in one file, when you come up
> with a solution to your build != host problem (whatever it is), you
> only have to fix it in one file.  So isn't this a step in the right
> direction?
> 

Here is my old patch.

-- 
H.J. Lu (hjl@gnu.org)
---
Fri Aug 15 17:47:14 1997  H.J. Lu  (hjl@gnu.ai.mit.edu)

	* configure.in (--with-auto-config.h): New argument. Create
	auto-config.h and exit.
	(build-auto-config.h): Create it if the build machine is not
	the same as the host machine.
	(hconfig.h): Include build-auto-config.h if the build machine
	is not the same as the host machine. Otherwise include
	auto-config.h.

Index: configure.in
===================================================================
RCS file: /home/work/cvs/gnu/gcc/configure.in,v
retrieving revision 1.1.1.16
diff -u -r1.1.1.16 configure.in
--- configure.in	1998/01/09 20:45:30	1.1.1.16
+++ configure.in	1998/01/20 21:05:22
@@ -32,6 +32,12 @@
 
 # Check for additional parameters
 
+# Generate auto-config.h only.
+AC_ARG_WITH(auto-config-h,
+[  --with-auto-config-h        generate auto-config.h only.],
+auto_config_h_only=yes,
+auto_config_h_only=no)
+
 # With GNU ld
 AC_ARG_WITH(gnu-ld,
 [  --with-gnu-ld           arrange to work with GNU ld.],
@@ -2838,6 +2870,20 @@
 	done
 done
 
+if [[ -f hconfig.h ]]
+then
+  rm -f hconfig.h.tmp
+  if [[ x$build != x$host ]]
+  then
+    echo "#include \"build-auto-config.h\"" > hconfig.h.tmp  
+  else
+    echo "#include \"auto-config.h\"" > hconfig.h.tmp  
+  fi
+  cat hconfig.h >> hconfig.h.tmp
+  rm -f hconfig.h
+  mv hconfig.h.tmp hconfig.h
+fi
+
 # Truncate the target if necessary
 if [[ x$host_truncate_target != x ]]; then
 	target=`echo $target | sed -e 's/\(..............\).*/\1/'`
@@ -3269,3 +3315,22 @@
 cross_overrides='${cross_overrides}'
 build_overrides='${build_overrides}'
 ])
+
+# We need to create auto-config.h for the build machine if it is not the
+# same as host.
+if [[ $auto_config_h_only != yes -a x$build != x$host ]]
+then
+	tempdir=build.$$
+	rm -rf $tempdir
+	mkdir $tempdir
+	cd $tempdir
+	case ${srcdir} in
+	/*) realsrcdir=${srcdir};;
+	*) realsrcdir=../${srcdir};;
+	esac
+	CC=${BUILD_CC-cc} ${realsrcdir}/configure --with-auto-config-h \
+		--target=$target --host=$host --build=$build
+	mv auto-config.h ../build-auto-config.h
+	cd ..
+	rm -rf $tempdir
+fi



More information about the Gcc mailing list