Subject: Re: Crosscompile
From: [email-masked] ("Mikey")

8 Mar 1997 14:31:25 -0800
Approved: [email-masked]
Distribution: cygnus
Message-ID: <[email-masked]>
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="----=_NextPart_000_01BC2BBC.347BB5E0"
Content-Transfer-Encoding: 7bit
Original-To: "Gerhard Wesp" <[email-masked]>
Original-Cc: "cygnus" <[email-masked]>
X-MSMail-Priority: Normal
X-Priority: 3
X-Mailer: Microsoft Internet Mail 4.70.1155
Original-Sender: [email-masked]

This is a multi-part message in MIME format.

------=_NextPart_000_01BC2BBC.347BB5E0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Attached are the shell scripts I wrote to use cygwin32 as a cross
linux/win95 compiler.

I tried to keep down disk space usage under both systems, so I used the
installed libs on my win95 system for the linux cross.

You'll have to edit the scripts to tell them where your cygwin32 source
tree lives, and where your vfat drives are mounted.

To use it this way, all system libraries must be in either
.../cygnus-2.7.2-961023/
or H-i386-cygwin32/i386-cygwin32/lib, so I moved them all to H-...

ditto for the include files.

Unless you want to set up a linux cygnus libg++ you need a link in
/usr/include to your win32 include/g++ to compile c++ programs, the script
names this g++win32, and you have to remember to switch back and forth :^(,
or you could use -I

Your filesystems MUST! be mounted -b under cygwin32 before untaring the
header files under 95/NT to use the headers from all.tgz

Since linux/vfat dosen't understand cygwin32 symbolic links libc.a must be
copied to libg.a if you are using -g. ditto for curses/ncurses.

You might want to try it with, and without the %[cpp_cpu] in the linux
specs file, maybe it's just something wierd on my system.

typical command line

make CC=i386-cygwin32-gcc PATH=/usr/i386-cygwin32/bin:$PATH

This hasn't been tested extensivly, but I used the built compiler to
rebuild the libraries, and dll, and they seem to work. see SB.libs

----------
> From: Gerhard Wesp <[email-masked]>
> To: [email-masked]
> Subject: Crosscompile
> Date: Thursday, March 06, 1997 2:00 AM
> 
>  Hi all,
> 
>  I'm in the position of having to develop a piece of software which
should
> should work on UNIX as well as Win95. The code uses sockets, i.e. I
> have to use wsock32.dll. 
> 
>  I have Linux and Win95 on my PC, and I don't like rebooting into Windows
> and recompiling there everytime I change a bit of the code, so I was 
> wondering if it was possible to use gcc on Linux as a crosscompiler.
> 
>  I tried the win32-{gcc,binutils,...} packages of Debian, but they don't
> really work (especially there are problems with include files). Moreover,
> they seem a bit outdated and basically come without documentation.
> 
>  What steps would be necessary
> to use gcc as a crosscompiler?  Since the CPU is the same on Linux
> and on Win95, shouldn't it be sufficient to use just a specialized
> assembler and linker to create .obj's and then .exe's? Would it be
> possible to use the header files from e.g. M$ Visual C 4.00 with gcc?
> 
>  Any hints are deeply appreciated!
> 
> -Gerhard
> -
> For help on using this list, send a message to
> "[email-masked]" with one line of text: "help".
------=_NextPart_000_01BC2BBC.347BB5E0
Content-Type: application/octet-stream; name="SB.cross"
Content-Transfer-Encoding: quoted-printable
Content-Description: SB.cross (CROSS File)
Content-Disposition: attachment; filename="SB.cross"

#!/bin/sh=0A=
#this is a bash shell script to make a linux/cygwin32 cross compiler=0A=
#it is designed to hopefully :^) minimize disk space usage, and=0A=
#maximize the speed of the resulting cross-compiler=0A=
set -a #export all variables=0A=
=0A=
#echo change the following variables to fit your setup=0A=
=0A=
CROSS_PREFIX=3D/dos/c/usr=0A=
CWD=3D`pwd`=0A=
GXXINCLUDE=3D$CROSS_PREFIX/include/g++=0A=
MY_HOST_COMPILER=3Di586-unknown-linux=0A=
CC=3Dgcc=0A=
CPPNAME=3D"gcc -E"=0A=
SRC_DIR=3D$CROSS_PREFIX/src/cygwin32=0A=
CYG_VER=3Dcygnus-2.7.2-961023=0A=
=0A=
if [ ! -f $SRC_DIR/CYGNUS ];then=0A=
 echo "please show me the source Luke :^)"=0A=
 exit 1;=0A=
fi=0A=
=0A=
# first make sure only the necessary dirs get built=0A=
[ -d $SRC_DIR/znobuild ] || mkdir -p $SRC_DIR/znobuild=0A=
if [ -d $SRC_DIR/byacc ];then=0A=
  pushd $SRC_DIR=0A=
  mv -f bash byacc dejagnu diff dosrel expect fileutils findutils flex =
gawk \=0A=
    gdb gprof grep grez gzip less libg++ libgloss libio librx libstdc++ =
m4 \=0A=
    make mmalloc ncurses newlib patch readline release sed send-pr \=0A=
    shellutils sim tar tcl texinfo textutils time tk utils winsup =
xiberty \=0A=
    znobuild/=0A=
  popd=0A=
fi =0A=
=0A=
if [ x"$TMP" =3D x ];then=0A=
  [ -d /tmp ] || mkdir /tmp=0A=
  TMP=3D/tmp;=0A=
fi=0A=
=0A=
cd $TMP=0A=
mkdir -p cx32o tmp/usr=0A=
=0A=
if [ ! -f $SRC_DIR/binutils/Makefile.in.* ];then=0A=
	patch -p0 -d $SRC_DIR/binutils/ < $CWD/ar_obj.dif;=0A=
fi=0A=
if [ ! -f $SRC_DIR/gas/Makefile.in.* ];then=0A=
	patch -p0 -d $SRC_DIR/gas/ < $CWD/gas.dif;=0A=
fi=0A=
 =0A=
cd cx32o=0A=
=0A=
if [ ! -f config.status ];then=0A=
    $SRC_DIR/configure --prefix=3D/usr\=0A=
      --enable-commonbfdlib --enable-shared\=0A=
      --host=3D$MY_HOST_COMPILER\=0A=
      --target=3Di386-cygwin32 -v =0A=
fi=0A=
=0A=
make CFLAGS=3D"-O3 -m486 -malign-jumps=3D2 -malign-functions=3D2 =
-malign-loops=3D2 -fno-strength-reduce" LDFLAGS=3D-s=0A=
=0A=
make CFLAGS=3D"-O3 -m486 -malign-jumps=3D2 -malign-functions=3D2 =
-malign-loops=3D2 -fno-strength-reduce" LDFLAGS=3D-s -C binutils/ =
ar_with_ranlib objcopy_with_strip=0A=
=0A=
make prefix=3D$TMP/tmp/usr install=0A=
=0A=
#this causes a bad invocation of cpp at least for me :^) so get rid of =
it.=0A=
=0A=
sed s/%\\[cpp_cpu\\]// < gcc/specs > =
$TMP/tmp/usr/lib/gcc-lib/i386-cygwin32/$CYG_VER/specs=0A=
=0A=
cd ../tmp/usr/bin=0A=
rm protoize unprotoize=0A=
ln -sf i386-cygwin32-ar i386-cygwin32-ranlib=0A=
ln -sf i386-cygwin32-objcopy i386-cygwin32-strip=0A=
ln -sf i386-cygwin32-g++ i386-cygwin32-c++=0A=
strip *=0A=
cd ../lib=0A=
rm -fr *.a ../man ../info=0A=
strip * =0A=
cd ../include=0A=
ln -sf GXXINCLUDE g++cygwin32=0A=
cd ../i386-cygwin32/bin=0A=
rmdir ../install-tools #how this got here I have no idea :)=0A=
ln -sf ../../bin/i386-cygwin32-ar ranlib=0A=
ln -sf ../../bin/i386-cygwin32-ar ar=0A=
ln -sf ../../bin/i386-cygwin32-gcc gcc=0A=
ln -sf ../../bin/i386-cygwin32-as as=0A=
ln -sf ../../bin/i386-cygwin32-dlltool dlltool=0A=
ln -sf ../../bin/i386-cygwin32-ld ld=0A=
ln -sf ../../bin/i386-cygwin32-nm nm=0A=
ln -sf ../../bin/i386-cygwin32-objcopy strip=0A=
# for when you have to reset path in the Makefile to use all cross =
tools=0A=
ln -sf ../../bin/i386-cygwin32-g++ g++=0A=
ln -sf ../../bin/i386-cygwin32-g++ c++=0A=
ln -sf ../../bin/i386-cygwin32-c++filt c++filt=0A=
ln -sf ../../bin/i386-cygwin32-gasp gasp=0A=
ln -sf ../../bin/i386-cygwin32-objcopy objcopy=0A=
ln -sf ../../bin/i386-cygwin32-objdump objdump=0A=
ln -sf ../../bin/i386-cygwin32-size size=0A=
ln -sf ../../bin/i386-cygwin32-strings strings=0A=
rm -fr ../include ../lib=0A=
cd ..=0A=
ln -s $CROSS_PREFIX/H-i386-cygwin32/i386-cygwin32/include include=0A=
ln -s $CROSS_PREFIX/H-i386-cygwin32/i386-cygwin32/lib lib=0A=
cd ../lib/gcc-lib/i386-cygwin32/$CYG_VER/=0A=
strip c* ld=0A=
rm -fr include=0A=
ln -s =
$CROSS_PREFIX/H-i386-cygwin32/lib/gcc-lib/i386-cygwin32/$CYG_VER/include =
include=0A=
=0A=
cd $TMP/tmp=0A=
makepkg cx32.tgz;mv cx32.tgz .. # or put your binary package maker =
here=0A=
cd $TMP=0A=
=0A=
if [ x"$1" =3D x--cleanup ];then=0A=
	rm -fr $TMP/tmp $TMP/cx32o;=0A=
        pushd $SRC_DIR=0A=
	mv -f znobuild/* .=0A=
	rmdir znobuild=0A=
	popd=0A=
fi=0A=
=0A=

------=_NextPart_000_01BC2BBC.347BB5E0
Content-Type: application/octet-stream; name="SB.libs"
Content-Transfer-Encoding: quoted-printable
Content-Description: SB.libs (LIBS File)
Content-Disposition: attachment; filename="SB.libs"

#!/bin/sh=0A=
#this is a bash shell script to make a the cygwin32 libraries from =
linux=0A=
#it is designed to hopefully :^) minimize disk space usage, by =
installing=0A=
#the new libraries to your vfat drive where the native cygwin32 compiler =
lives=0A=
set -axv #export all variables=0A=
=0A=
#echo change the following variables to fit your setup=0A=
=0A=
CROSS_PREFIX=3Ddos/c/usr/H-i386-cygwin32 # !! NO slash here=0A=
SRC_DIR=3D/dos/c/usr/src/cygwin32=0A=
=0A=
if [ ! -f $SRC_DIR/CYGNUS ];then=0A=
 echo "please show me the source Luke :^)"=0A=
 exit 1;=0A=
fi=0A=
=0A=
if [ ! -d /$CROSS_PREFIX ];then=0A=
 echo "please show me the destination Luke :^)"=0A=
fi=0A=
=0A=
if [ x"$TMP" =3D x ];then=0A=
  [ -d /tmp ] || mkdir /tmp=0A=
  TMP=3D/tmp;=0A=
fi=0A=
=0A=
cd $TMP=0A=
mkdir -p lx32o tmp/$CROSS_PREFIX/=0A=
=0A=
cd lx32o=0A=
=0A=
#make sure only the necesary dirs get built=0A=
[ -d $SRC_DIR/znobuild ] || mkdir -p $SRC_DIR/znobuild=0A=
if [ -d $SRC_DIR/byacc ];then=0A=
  pushd $SRC_DIR=0A=
  mv -f bash binutils byacc dejagnu diff dosrel expect fileutils\=0A=
    findutils flex gas gawk gcc gdb gprof grep grez gzip ld less \=0A=
    m4 make ncurses patch release sed send-pr \=0A=
    shellutils sim tar tcl texinfo textutils time tk utils xiberty \=0A=
    znobuild/=0A=
  popd=0A=
fi=0A=
=0A=
[ -f config.status ] || CC=3D"gcc -b i386-cygwin32 -V =
cygnus-2.7.2-961023"\=0A=
 CXX=3D"gcc -b i386-cygwin32 -V cygnus-2.7.2-961023"\=0A=
 PATH=3D/usr/i386-cygwin32/bin:$PATH $SRC_DIR/configure =
--prefix=3D/usr\=0A=
 --srcdir=3D$SRC_DIR --host=3Di586-unknown-linux =
--target=3Di386-cygwin32 -v=0A=
=0A=
make CFLAGS=3D"-O -g" LDFLAGS=3D=0A=
=0A=
make prefix=3D$TMP/tmp/$CROSS_PREFIX install=0A=
=0A=
=0A=
cd $TMP/tmp/$CROSS_PREFIX/i386-cygwin32/lib=0A=
mv cygwin.dll ../../bin=0A=
ln -sf libc.a libg.a #this will fail on vfat but might remind us=0A=
mv libstdc++.a libg++.a libiberty.a libc.a libg.a libm.a ../../lib=0A=
i386-cygwin32-strip --strip-debug *.a #since these are mostly just dll =
stubs=0A=
=0A=
cd ../../lib=0A=
mv libi386-cygwin32-bfd.a libbfd.a=0A=
mv libi386-cygwin32-opcodes.a libopcodes.a=0A=
mv *.a ../i386-cygwin32/lib/=0A=
=0A=
cd ../bin=0A=
for file in cygwin ps mount umount kill;do=0A=
  mv i386-cygwin32-$file $file.exe;=0A=
done=0A=
strip *.exe=0A=
mv ../include ../man ../etc ../..=0A=
=0A=
cd ../../include=0A=
=0A=
mv *.h readline ../H-i386-cygwin32/i386-cygwin32/include/=0A=
=0A=
if [ "1" =3D "0" ];then #ncurses really dosen't like being built =
cross=0A=
=0A=
cd $TMP/lx32o=0A=
[ -d ncurses ] || mkdir ncurses=0A=
cd ncurses=0A=
[ -f config.status ] || CC=3D"gcc -b i386-cygwin32 -V =
cygnus-2.7.2-961023 -I/usr/i386-cygwin32/include "\=0A=
 CXX=3D"gcc -b i386-cygwin32 -V cygnus-2.7.2-961023 =
-I/usr/i386-cygwin32/include -I/dos/c/usr/include/g++"\=0A=
 PATH=3D/usr/i386-cygwin32/bin:$PATH $SRC_DIR/ncurses/configure =
--prefix=3D/usr\=0A=
 --target=3Di386-cygwin32 --enable-getcap --enable-termcap \=0A=
 --program-suffix=3D.exe --enable-symlinks -v=0A=
make includedir=3D/usr/i386-cygwin32/include=0A=
=0A=
make LDFLAGS=3D prefix=3D$TMP/tmp/$CROSS_PREFIX/.. install=0A=
=0A=
fi=0A=
=0A=
cd $TMP/tmp=0A=
makepkg lx32.tgz;mv lx32.tgz .. # or put your binary package maker =
here=0A=
cd $TMP=0A=
=0A=
if [ x"$1" =3D x--cleanup ];then=0A=
	rm -fr $TMP/tmp $TMP/lx32o;=0A=
        pushd $SRC_DIR=0A=
        mv -f znobuild/* .=0A=
        rmdir znobuild=0A=
        popd=0A=
fi=0A=
=0A=
=0A=
=0A=
=0A=
=0A=

------=_NextPart_000_01BC2BBC.347BB5E0
Content-Type: application/octet-stream; name="Ar_obj.dif"
Content-Transfer-Encoding: quoted-printable
Content-Description: Ar_obj.dif (DIF File)
Content-Disposition: attachment; filename="Ar_obj.dif"

--- Makefile.in	1997/03/06 00:54:31	1.1=0A=
+++ Makefile.in	1997/03/06 01:01:16=0A=
@@ -308,15 +308,15 @@=0A=
 =0A=
 # Alternatively, you can install ranlib.sh as ranlib.=0A=
 =0A=
-ar_with_ranlib: $(ADDL_DEPS) ar.o maybe-ranlib.o=0A=
-	$(HLDENV) $(CC) $(HLDFLAGS) $(CFLAGS) $(LDFLAGS) -o $(AR_PROG) ar.o =
maybe-ranlib.o $(ADDL_LIBS) $(EXTRALIBS)=0A=
+ar_with_ranlib: $(ADDL_DEPS) ar.o arparse.o arlex.o maybe-ranlib.o =
arsup.o=0A=
+	$(HLDENV) $(CC) $(HLDFLAGS) $(CFLAGS) $(LDFLAGS) -o $(AR_PROG) ar.o =
arparse.o arlex.o maybe-ranlib.o arsup.o $(ADDL_LIBS) $(EXTRALIBS)=0A=
 	-rm -f $(RANLIB_PROG)=0A=
 	-ln $(AR_PROG) $(RANLIB_PROG)=0A=
 =0A=
 # objcopy and strip in one binary that uses argv[0] to decide its =
action.=0A=
 =0A=
-objcopy_with_strip: $(ADDL_DEPS) objcopy.o maybe-strip.o=0A=
-	$(HLDENV) $(CC) $(HLDFLAGS) $(CFLAGS) $(LDFLAGS) -o $(OBJCOPY_PROG) =
objcopy.o maybe-strip.o $(ADDL_LIBS) $(EXTRALIBS)=0A=
+objcopy_with_strip: $(ADDL_DEPS) objcopy.o maybe-strip.o =
$(WRITE_DEBUG_OBJS)=0A=
+	$(HLDENV) $(CC) $(HLDFLAGS) $(CFLAGS) $(LDFLAGS) -o $(OBJCOPY_PROG) =
objcopy.o maybe-strip.o $(WRITE_DEBUG_OBJS) $(ADDL_LIBS) $(EXTRALIBS)=0A=
 	-rm -f $(STRIP_PROG)=0A=
 	-ln $(OBJCOPY_PROG) $(STRIP_PROG)=0A=
 =0A=

------=_NextPart_000_01BC2BBC.347BB5E0
Content-Type: application/octet-stream; name="Gas.dif"
Content-Transfer-Encoding: quoted-printable
Content-Description: Gas.dif (DIF File)
Content-Disposition: attachment; filename="Gas.dif"

--- Makefile.in	1997/03/06 00:27:41	1.1=0A=
+++ Makefile.in	1997/03/06 00:21:58=0A=
@@ -231,9 +231,9 @@=0A=
 =0A=
 # How to link with both our special library facilities=0A=
 # and the system's installed libraries.=0A=
-=0A=
+LIBIBERTY =3D ../libiberty/libiberty.a=0A=
 LIBDEPS =3D @OPCODES_DEP@ @BFDDEP@ $(LOCAL_LOADLIBES) =
.../libiberty/libiberty.a=0A=
-LIBS =3D @OPCODES_LIB@ @BFDLIB@ $(LOCAL_LOADLIBES) =
.../libiberty/libiberty.a=0A=
+LIBS =3D @OPCODES_LIB@ @BFDLIB@ $(LOCAL_LOADLIBES) $(LIBIBERTY)=0A=
 =0A=
 # Specify the directories to be searched for header files.=0A=
 # Both . and srcdir are used, in that order,=0A=
@@ -262,7 +262,7 @@=0A=
 	listing.h bignum.h $(srcdir)/../include/libiberty.h=0A=
 =0A=
 gasp.new: $(GASPOBJS) ../libiberty/libiberty.a=0A=
-	$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o gasp.new $(GASPOBJS) =
.../libiberty/libiberty.a $(LOADLIBES)=0A=
+	$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o gasp.new $(GASPOBJS) $(LIBS) =
$(LOADLIBES)=0A=
 =0A=
 installcheck:=0A=
 	@echo No installcheck target is available yet for the GNU =
assembler.=0A=

------=_NextPart_000_01BC2BBC.347BB5E0--

-
For help on using this list, send a message to
"[email-masked]" with one line of text: "help".