[ Welcome | Crossroad | Humanae | Computer stuff ]
Gnu C installation from source code on HP-UX
If you're in a hurry and need a C-compiler as fast as possible
you should take a look at the
"easy" GNU C installation.
Update: gcc version 2.7.2.3 is now availabe.
January 9, 1997 I started installing Gnu C compiler
on one of our HP-UX machine's.
This is how I did it.
Disk space
We need approx. 105 MB free disk space to perform
unzip and compile the Gnu C compiler.
Plus 11 MB where it is to be installed.
Log on to the machine as "root".
I started with creating a new disk volume (200 MB) mounted on
/mnt/tmp/.
Download
Connect to Sunet or
hpux.csc.liv.ac.uk
with http or ftp.
Or
Software Porting And Archive Centre for HP-UX in Canada or
Software Porting And Archive Centre for HP-UX at Utah, USA
(found via
HP Software Depot).
On "hpux.csc.liv.ac.uk" change directory to hpux/Gnu/gcc-2.7.2.1/
where the following files are:
gcc-2.7.2.1-sa-10.10.depot.Z
gcc-2.7.2.1-sa-10.10.depot.gz
gcc-2.7.2.1-sa-9.05.upd.Z
gcc-2.7.2.1-sa-9.05.upd.gz
gcc-2.7.2.1-sd-10.10.depot.Z
gcc-2.7.2.1-sd-10.10.depot.gz
gcc-2.7.2.1-sd-9.05.upd.Z
gcc-2.7.2.1-sd-9.05.upd.gz
gcc-2.7.2.1-ss-10.10.tar.Z
gcc-2.7.2.1-ss-10.10.tar.gz
gcc-2.7.2.1-ss-9.05.tar.Z
gcc-2.7.2.1-ss-9.05.tar.gz
gcc-2.7.2.1.README
gcc-2.7.2.1.README.html
gcc-2.7.2.1.man.gz
gcc-2.7.2.1.man.html
Make sure you're in binary mode
ftp> bin
200 Type set to I.
And turn interactive mode off
ftp> prompt
Interactive mode off.
I have a Gnu Zip so I select to download the file
gcc-2.7.2.1-ss-10.10.tar.gz
If you don't have Gnu Zip pick the ".Z" file.
ftp> get gcc-2.7.2.1-ss-10.10.tar.gz
Also get the Gnu sed, binutils and libg++ while connected.
Gnu sed
You must install Gnu sed first, as the default sed is broken.
> cd sed-2.05
> ./configure --prefix=/opt/sed
> make
> make install
Add "/opt/sed/bin:" first in the file /etc/PATH. Log out and back
in to make the PATH change take effect
Unzip, untar & configure GNU C
> gunzip gcc-2.7.2.1-ss-10.10.tar.gz | tar xf -
> cd gcc-2.7.2.1
> ./configure --prefix=/opt/gcc
This appears to be a hppa1.1-hp-hpux10.01 system.
Using `./config/pa/pa.c' to output insns.
Using `./config/pa/pa.md' as machine description file.
Using `./config/pa/pa1-hpux9.h' as target machine macro file.
Using `./config/pa/xm-pahpux.h' as host machine macro file.
Merged pa/x-pa-hpux.
Merged pa/t-pa.
Merged c++ fragment(s).
Created `./Makefile'.
Merged pa/x-pa-hpux.
Merged pa/t-pa.
Created `cp/Makefile'.
Links are now set up to build a native compiler for hppa1.1-hp-hpux10.01.
A stage1 compiler
(Remove the "-g" flag in the Makefile if you want less Warning messages).
Next step is to create a "simple" c-compiler (no C++ or Objective C at this point):
> make LANGUAGE=c
Now make executables (xgcc) from object-files in current
directory and move this compiler down to a directory "stage1":
> make stage1
Here you might get some message
"mv ... no such direcroty ...
*** Error exit code 1 (ignored)"
Just Ignore it and proceed.
stage2
Recompile the compiler with "itself", using the "xgcc" compiler
in the /stage1 directory. This is called making the stage2 compiler:
> make CC="stage1/xgcc -Bstage1/" CFLAGS="-g -O2" LANGUAGE=c
Ignore warnings and proceed.
Now make executables (xgcc) from object-files in current
directory and move this compiler to a directory "stage2":
> make stage2
stage3
And now make the stage3 compiler with the stage2
compiler and compare the two results:
(If this is the "final" compiler we're making we should
include all desired compilers in the LANGUAGE-LIST, in this
case "c c++")
> make CC="stage2/xgcc -Bstage2/" CFLAGS="-g -O2" LANGUAGE="c c++"
(We could go on make stage4 and so on if we wanted).
In the INSTALL documentation file it says:
"... on some systems ... always appear different ..."
HP might be such a system:
> make compare
Installation
And finally install the compiler. 11 MB free disk space is needed on the
disk volume you're installing it on. In my case volume /opt since it was installed
in /opt/gcc:
> make install CC="stage2/xgcc -Bstage2/" CFLAGS="-O" LANGUAGES="c c++"
or if we want objective C:
> make install CC="stage2/xgcc -Bstage2/" CFLAGS="-O" LANGUAGES="c c++ objective-c"
If problems occur with makeinfo like ...
sh: makeinfo: not found.
*** Error exit code 127
Stop.
... edit the Makefile and remove the text "install-info" on the row:
install-normal: install-common $(INSTALL_HEADERS) $(INSTALL_LIBGCC) \
install-libobjc install-man install-info lang.install-normal install-driver
Try the "make install" above again.
Extra
In my case the Gnu C is now installed in /opt/gcc.
Still logged on as "root" I had to change mode on the directory
/opt/gcc/lib/gcc-lib/hppa1.1-hp-hpux10.01/2.7.2.1/include
and all files & directories below.
This might not be necessary for you, depending on your "umask".
> cd /opt/gcc/lib/gcc-lib/hppa1.1-hp-hpux10.01/2.7.2.1/
( version 2.7.2.3 on HP-UX 10.20
> cd /opt/gcc/lib/gcc-lib/hppa1.0-hp-hpux10.20/2.7.2.3 )
> chmod -R o+r include ; find include -type d -exec chmod o+x {} \;
Finally add the following to /etc/PATH:
:/opt/gcc/bin
and to /etc/MANPATH:
:/opt/gcc/man
Or to /etc/profile:
# Gnu C
PATH=$PATH:/opt/gcc/bin
export PATH
MANPATH=$MANPATH:/opt/gcc/man
export MANPATH
And for c-shell in the file /etc/csh.login:
# Gnu C
set path=($path /opt/gcc/bin)
set MANPATH=($MANPATH /opt/gcc/man)
Log out and back in again to make changes take effect.
Gnu binutils
NOTE! It is possible to install the precompiled binutils
as described in the easy
Gnu C installation. If you do, then don't forget to recompile
the Gnu C once more as described below.
Get the file
binutils-2.7-ss-10.10.tar.gz
(or binutils-2.8.1.tar.gz see bison below)
(4,5 MB & 20 MB unzip'ed).
Make & install binutils:
> cd /mnt/tmp
> gunzip binutils-2.7-ss-10.10.tar.gz
> tar xf binutils-2.7-ss-10.10.tar
> cd binutils-2.7
> CC=gcc ./configure --prefix=/opt/binutils
> make CC=gcc
> make install
# vi /etc/PATH
Add "/opt/binutils/bin:" first of all.
# vi /etc/MANPATH
Add ":/opt/binutils/man"
Log out and back in again.
After we got the binutils installed we now recompile the Gnu C
once more. This will give us a Gnu C built with Gnu as, ar etc.
> cd /mnt/tmp/gcc-2.7.2.3
> ./configure --with-gnu-as --with-gnu-ld --prefix=/opt/gcc
> make CC="stage2/xgcc -Bstage2/" CFLAGS="-O2" LANGUAGE="c c++"
> make stage3
> make CC="stage3/xgcc -Bstage3/" CFLAGS="-O2" LANGUAGE="c c++"
If problems occured earlier with makeinfo while running "make install ..."
( sh: makeinfo: not found. )
edit the Makefile and remove the text "install-info" as above.
> make install CC="stage3/xgcc -Bstage3/" CFLAGS="-O" LANGUAGE="c c++"
Now it is possible to start use the Gnu C compiler.
To be able to use Gnu C++ we need to install C++ libraries
though.
C++ libraries
To be able to compile C++ programs you must have the "libg++".
And to be able to compileGnu libg++ we must have Gnu as (gas)
installed and first in the PATH. Gnu as is included in binutils
so if you have installed binutils as described above that OK.
Get the libg++-2.7.2.tar.gz
> gunzip libg++-2.7.2.tar.gz
> tar xf libg++-2.7.2.tar
> cd libg++-2.7.2
Gnu C requires that libraries are installed in the same directory as itself,
so set "prefix=/opt/gcc":
> ./configure --prefix=/opt/gcc
> make
> make install
You can now test the compiler if you wish as described in the
"easy" GNU C installation.
Not yet tested
We can also install "binutils" before Gnu C
and after installing binutils configure, compile
& install Gnu C.
HP: "It is highly recommended that you use the Gnu assembler with Gnu C.
It is available in the binutils package. Obtain and install binutils
before attempting to build gcc."
n this case configure GNU C with the following flags:
> ./configure --with-gnu-as --with-gnu-ld --prefix=/opt/gcc
bison
To be able to compile binutils 2.8.1 we need bison and something more ....
I never got it working.
Get the file gunzip bison-1.25-ss-10.10.tar.gz
> gunzip bison-1.25-ss-10.10.tar.gz
> tar xf bison-1.25-ss-10.10.tar
> cd bison-1.2
> ./configure --prefix=/opt/bison
> CC=gcc make
> make install
# vi /etc/PATH
Add ":/opt/bison/bin".
# vi /etc/MANPATH
Add ":/opt/bison/man"
Log out and in again.