This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Hint: How to install gcc on Solaris (easiest way possible - I think)


Dunno - I wrote this apnote below for internal consumption; maybe
you might find it useful. It's designed to facilitate the FIRST program
a newbie Solaris person ever compiled. All paths are internal.
I did it just to see if I could. I don't even have a UNIX workstation, 
just a PC - I did the same on the PC.
jjg

****************************************************************************
How to install & test GNU tools on a Sun Solaris Workstation in 15 minutes.

Tools installed & tested are gcc, make, & gzip (scores of tools available):

A 10-step cut-and-paste walk-thru  by John Gianni,   version 1.03,  8/29/99

Adapted from:              http://www.zdjournals.com/sun/9908/sun9981.htm
&                          http://www.sunfreeware.com/
See also:                  http://www.gnu.org/
Alternative ftp site:      ftp://nce.sun.ca/pub/freeware/
Alternative compiled site: http://sourceware.cygnus.com/

Special thanks to Patrick Pastore for testing & debugging suggestions.
****************************************************************************
Note: You may _already_ have a C compiler (cc perhaps?) on your system.
      An instant locate-exactly will find out in a second, e.g, 
      unix%   rsh cds9200 locatex gcc make cc sh
              (Compare results of 'locatex' with normal 'locate' results.)

I _think_ MITS provides the FLEXLM license for cc from Sun:
     unix% cd /net/iss/scripts/ 

I _think_ MITS also puts (some?) GNU stuff on new machines by default:
     unix% netscape http://cdsinfo?-mits+513672

If not...

Here is a good example for a person's first GNU tools installation on Sun, 
which makes use of Sun's 'package installation tools' to ease installation.

(Since most of the 15 min. is spent downloading, you should note that MITS 
has kindly provided easy-to-use GNU installers at /net/iss/scripts/.)

Note: GCC used to stand for the GNU C Compiler, but since the compiler now
      supports several other languages aside from C, it now stands for the 
      GNU Compiler Collection.   
============================================================================
Cut-&-paste 10-step Sun Solaris 2.5 "installing basic GNU tools" walk-thru:
============================================================================
SETUP:   Make sure you have a /usr/local/bin directory (GNU defaults):
         unix%  su root
         unix#  ls /usr/local/bin
                If it doesn't exist:
                      unix%  mkdir /usr/local/bin 
                Else, check and see if gzip, gcc, & gmake already exist:
                      unix# /usr/local/bin/gzip -V (or /bin/gzip -V)
                      If this reports a version earlier than gzip 1.2.4:
                        unix#  mv gzip   gzip.`date   | awk '{print $6$2$3}'`
                        unix#  mv gunzip gunzip.`date | awk '{print $6$2$3}'`
                      unix# /usr/local/bin/gcc -V
                      If this reports a version earlier than 2.8.1:
                        unix#  mv gcc    gcc.`date   | awk '{print $6$2$3}'`
                      unix# /usr/local/bin/gmake -V
                      If this reports a version earlier than 3.77:
                        unix#  mv gmake  gmake.`date   | awk '{print $6$2$3}'`
         unix#  exit
----------------------------------------------------------------------------
STEP 1:  Point your web browser to the Sun Freeware site:
         unix%  netscape http://www.sunfreeware.com &

         Note: It is tremendously easier to install Solaris GNU software 
               from this Sun site, vs from the GNU site (due to pkgadd).
               (For newbies, we're talkin' minutes, vs hours (or forever).)

         Note: An alternative, non web site is:
               unix%  ftp nce.sun.ca
----------------------------------------------------------------------------
STEP 2:  Make sure your PATH points to "/usr/local/bin":
         unix%  echo $path | grep " /usr/local/bin "
                If it's not in your path, add it to your path.
----------------------------------------------------------------------------
STEP 3:  Create any temporary download directory:
         unix%  mkdir /tmp/download
----------------------------------------------------------------------------
STEP 4:  Download "gzip" (gzip-1.2.4a) for your platform into /tmp/download:
         a) At the www.sunfreeware.com site, select your processor & OS:
            [SPARC/Solaris 2.5]
         b) Then, select the latest "gzip" package for your processor & OS:
            [gzip-1.2.4]
         c) Save the file to /tmp/download:
            [gzip-1_2.4                      432,128 bytes]
         Hint: The most consistent way to download, IMHO, is to right-click 
               on the link & "Save As..." (that's how I did it for this note).
         Note: Otherwise, depending on your Netscape setup, it may save the 
               gzipped file, or, Netscape may automatically unzip it for you.
         Note: Your version & file size may differ depending on both
               your OS and the current version of GNU code available.

         Alternative download (without using a web browser):
            unix%  ftp nce.sun.ca
          login>   anonymous                  (always use anonymous login)
       password>   john@                      (use _your_ login please!)
            ftp>   cd /pub/freeware/sparc/2.5 (use your OS version, if avail.)
            ftp>   !mkdir /tmp/download       (create the local directory)
            ftp>   lcd /tmp/download          (set the local directory
default)
            ftp>   binary                     (set binary-mode for downloads)
            ftp>   ls gzip*                   (determine available versions)
            ftp>   prompt                     (turn off y/n questions for
mget)
            ftp>   mget gzip*                 (multiple-get whatever you want)
            ftp>   quit                       (quit out of ftp)
----------------------------------------------------------------------------
STEP 5:  Install & test GNU "gzip":
         a) Confirm the file type of the downloaded, unzipped file:
            unix%  file /tmp/download/gzip*
                   This should report something like:
                        gzip-1.2.4:     ascii text  
            unix%  head /tmp/download/gzip*
                   This should report something like:
                        # PaCkAgE DaTaStReAm
                        FSFgzip 1 928
                        # end of header
                        NAME=GZIP
                        ARCH=Solaris 2.5
                        VERSION=1.2.4
                        CATEGORY=application
                        VENDOR=The Free Software Foundation
                        EMAIL=Jean-loup Gailly <jloup@chorus.fr>
                        etc.
         b) Install gzip into /usr/local/bin:
            unix%  rlogin localhost -l root (optional if you're already root)
            unix#  cd /tmp/download
            unix#  /usr/sbin/pkgadd -d /tmp/download/gzip* 
                   Assent to all defaults.
                   (It will ask you which packages to install; and, 
                   it will ask you if it can create a /opt/FSFgzip directory.)
                   Note: the directory name depends on the version, e.g., 
                         it may ask to create "/opt/FSFgcc".
         c) Test the installation:
            unix#  /usr/sbin/pkgchk -d gzip* GNUgzip
                   Note: The capital letters depend on the version downloaded.
                         For example, it may say "...<FSFgzip> was
successful." 
                         You'd then need to run:
                         unix#  /usr/sbin/pkgchk -d gzip* FSFgzip
----------------------------------------------------------------------------
STEP 6:  Download the "make" version for your platform into /tmp/download:
         a) At the www.sunfreeware.com site, select your processor & OS:
            [SPARC/Solaris 2.5]
         b) Then, select the latest "gzip" package for that processor & OS:
            [make-3.77]
         c) Save the file to /tmp/download:
            [make-3_77-sol25-sparc-local.gz  388,836 bytes]
         Hint: The most consistent way to download, IMHO, is to right-click 
               on the link & "Save As..." (that's how I did it for this note).
         Note: Otherwise, depending on your Netscape setup, it may save the 
               gzipped file, or, Netscape may automatically unzip it for you.
         Note: Your version & file size may differ depending on both
               your OS and the current version of GNU code available.

         Alternative download (without using a web browser):
            unix%  ftp nce.sun.ca
          login>   anonymous                  (always use anonymous login)
       password>   john@                      (use _your_ login please!)
            ftp>   cd /pub/freeware/sparc/2.5 (use your OS version, if avail.)
            ftp>   !mkdir /tmp/download       (create the local directory)
            ftp>   lcd /tmp/download          (set the local directory
default)
            ftp>   binary                     (set binary-mode for downloads)
            ftp>   ls make*                   (determine available versions)
            ftp>   prompt                     (turn off y/n questions for
mget)
            ftp>   mget make*                 (multiple-get whatever you want)
            ftp>   quit                       (quit out of ftp)
----------------------------------------------------------------------------
STEP 7:  Install & test GNU "make":
         a) Confirm it; unzip it; and confirm the results:
            unix%  file /tmp/download/make*
                   This should report something like:
                     "make-3.77-sol25-sparc-local.gz: 
                      gzip compressed data - deflate method, 
                      original file name"
            unix%  gzip -d make*
                   This creates the ASCII package
"make-3_77-sol25-sparc-local".
                   Note: This serves as your step 10 'test' of gzip :)
            unix%  head /tmp/download/make*
                   This should report something like:
                        # PaCkAgE DaTaStReAm
                        GNUmake 1 2764
                        # end of header
                        NAME=make
                        ARCH=sparc
                        VERSION=3.77
                        CATEGORY=application
                        VENDOR=Free Software Foundation
                        EMAIL=steve@smc.vnet.net 
                        etc.
         b) Install make into /usr/local/bin:
            unix%  rlogin localhost -l root (optional if you're already root)
            unix#  cd /tmp/download
            unix#  /usr/sbin/pkgadd -d make* 
                   Assent to the questions, such that, when done, you see:
                   "Installation of <GNUmake> was successful."
                   Note: The capital letters depend on the version downloaded.
                         For example, it may say "...<FSFmake> was
successful." 
                         You'd then need to run:
                         unix#  /usr/sbin/pkgchk -d make* FSFmake
         c) Test the installation:
            unix#  /usr/sbin/pkgchk -d make* GNUmake
                   When done, this should report the 3 lines:
                      ## Checking control scripts.
                      ## Checking package objects.
                      ## Checking is complete.
         d) Rename GNU 'make' to differentiate it from Sun Solaris 'make':
            unix#  mv /usr/local/bin/make /usr/local/bin/gmake
----------------------------------------------------------------------------
STEP 8:  Download the GNU C-compiler (gcc):
         a) At the www.sunfreeware.com site, select your processor & OS:
            [SPARC/Solaris 2.5]
         b) Then, select the latest "gcc" package for that processor & OS:
            [gcc-2.8.1]
         c) Save the file to /tmp/download:
            [gcc-2_8_1-local.gz            8,889,454 bytes]
         Hint: The most consistent way to download, IMHO, is to right-click 
               on the link & "Save As..." (that's how I did it for this note).
         Note: Otherwise, depending on your Netscape setup, it may save the 
               gzipped file, or, Netscape may automatically unzip it for you.
         Note: Your version & file size may differ depending on both
               your OS and the current version of GNU code available.

         Alternative download (without using a web browser):
            unix%  ftp nce.sun.ca
          login>   anonymous                  (always use anonymous login)
       password>   john@                      (use _your_ login please!)
            ftp>   cd /pub/freeware/sparc/2.5 (use your OS version, if avail.)
            ftp>   !mkdir /tmp/download       (create the local directory)
            ftp>   lcd /tmp/download          (set the local directory
default)
            ftp>   binary                     (set binary-mode for downloads)
            ftp>   ls gcc*                    (determine available versions)
            ftp>   prompt                     (turn off y/n questions for
mget)
            ftp>   mget gcc-2.8.1-local.gz    (multiple-get whatever you want)
            ftp>   quit                       (quit out of ftp)
----------------------------------------------------------------------------
STEP 9:  Confirm, install & test "gcc":
         a) Confirm & unzip it:
            unix%  file /tmp/download/gcc*
                   This should report something like:
                       "gcc-2.95-sol25-sparc-local.gz:
                        gzip compressed data - deflate method, 
                        original file name"
            unix%  gzip -d gcc*
                   This will create the ASCII package file "gcc-2_8_1-local".
            unix%  head /tmp/download/gcc*
                   This should report something like:
                        # PaCkAgE DaTaStReAm
                        SMCgcc 1 117495
                        # end of header
                        NAME=gcc
                        ARCH=sparc
                        VERSION=2.95
                        CATEGORY=application
                        VENDOR=Free Software Foundation
                        EMAIL=steve@smc.vnet.net
                        etc.
         b) Install gcc into /usr/local/bin:
            unix%  rlogin localhost -l root (optional if you're already root)
            unix#  cd /tmp/download
            unix#  /usr/sbin/pkgadd -d gcc* 
                   Assent to all questions; when done, it should say:
                   "Installation of <GNUgcc> was successful."
                   Note: The capital letters depend on the version downloaded.
                         For example, it may say "...<FSFgcc> was
successful." 
                         You'd then need to run:
                         unix#  /usr/sbin/pkgchk -d gcc* FSFgcc
         c) Test the installation:
            unix#  /usr/sbin/pkgchk -d gcc* GNUgcc
----------------------------------------------------------------------------
STEP 10: Test all three executables (in reverse order) on a simple program:
         a) Test GNU "gcc" on a simple C src program:
            unix%  mkdir /tmp/test
            unix%  vi /tmp/test/hello.c
                     ----< cut here for hello.c  >----
                     #include <stdio.h>
                     main()
                     {
                          printf("Hello world.\n");
                          return 0;
                     }                         
                     ----< cut here for hello.c  >----
            unix%  rehash
            unix%  gcc /tmp/test/hello.c -o /tmp/test/hello.exe
            unix%  /tmp/test/hello.exe
                   This should report: "Hello world."

         b) Test GNU "gmake" using a simple Makefile:
            unix%  vi /tmp/test/Makefile
                     ----< cut here for Makefile >----
                    # Simple Makefile
                    # Choose GNU C-compiler:
                    CC= gcc 
                    # Set debugging flags:
                    CFLAGS= -g  
                    # Set optimization:
                    CFLAGS= -O2 
                     ----< cut here for Makefile >----
            Q: Does anyone have a better simple Makefile example?
            A: ???

            unix%  cd /tmp/test
            unix%  gmake hello
                   SHOULD REPORT:    gcc  -O2     hello.c   -o hello  
                   And should create: hello
            unix%  ./hello
                   SHOULD REPORT:    "Hello world."
                   Note: For a good Cadence DFII Makefile example, look at:
                `cds_root cds_root`/tools/dfII/pvt/etc/packages/Makefile.obj

         c) Test GNU "gzip" and "gunzip" on those results:
            unix%  gzip hello.c Makefile
                   This should compress them to hello.c.gz & Makefile.gz
            unix%  rm hello hello.exe
                   Now all you have is the compressed testcases.
            unix%  gunzip hello.c.gz Makefile.gz
                   This should bring you back to your original environment
                   for further tests.
****************************************************************************
End of:
How to install GNU tools on Sun Solaris in 10 fast cut-&-paste steps.
****************************************************************************




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]