# 4.7. Micro-HOWTO: Compiling KDE 1.1.1 on SGI Irix 6.x

Chris Berry posted the following updated micro-HOWTO (edited for layout) to comp.windows.x.kde.

This is a (blatant) modification of the original Micro-HOWTO posted by Chris Sterritt. This is valid for KDE-1.1.1 running on Irix 6.5. I haven't attempted it on other platforms. There are some items of contention: I get many, many warnings about Qt definitions being preempted, about libkdecore definitions being preempted, etc. (So many definitions have been preempted I could have written a dictionary), the i18n stuff doesn't work (while it did in v1.0) and kikbd chokes in konsole (it works fine otherwise). Any comments or questions can be directed to berry@ieeecs.concordia.ca. I will also keep a copy of this HOWTO on my personal web-page: http://alcor.concordia.ca/~c_berry/.

Also, if this isn't your cup of tea, I have uploaded binaries of kde-1.1.1 and egcs-1.1.2 to ftp://ftp.cmc.ec.gc.ca/pub/hbc/sgi/. KDE has been compiled with shared libraries, so if you don't have libstdc++.so.2.9.0 I would suggest downloading the egcs binary as well. Please also download and _read_ the README in the directory, as it contains important installion information.

Finally, neither I nor Environment Canada accept any responsibility vis a vis the worthiness of these instructions. They have worked for me. If they work for you, that's good, if they don't work, I can't help you, neither can anybody at EC. Note that several things don't work the way they are supposed to work. If you find a way around these problems, let someone else know. I personally won't be able to test any fixs after August 20, 1999 as I will be returning to school (and using SunOS).

Enjoy!

1. Install Qt 1.42 or higher.

2. I am installing KDE as me (not root) so I have a KDEDIR environmental var which is set to something other than /usr/local/ or whatever is the default. So I'll mention it below, but you may not have to. Also, SGI has a 'jpeg' and a 'png' library, but they're out of date or otherwise wrong. So you'll have to track down the libpng and libz sources (jpeg comes in kdesupport); I found them as source RPMs in one of the RedHat FTP mirrors.

3. Get egcs 1.1.1 or later and compile it with '-fsquangle' support on. This is because SGI's assembler can't handle the huge object names produced by normal g++, and gas doesn't evidently work yet for SGIs. You'll have to build gcc's libraries using this binary as well. Make sure your PATH gets this compiler only (if you have another gcc installed somewhere). When I do a 'g++ -v' I get:

        gcc version egcs-2.91.60 19981201 (egcs-1.1.1 release)

4. Do a

        setenv LDFLAGS " "

   because the 'configure' scripts insist on trying 'g++ -s' when compiling a test program, which always fails on the SGIs.

5. Unpack 'kdesupport' and enter its directory. Run its configure with "--prefix" if you need to:

        ./configure --prefix=$KDEDIR --x-includes=/usr/include/X11 \
        --x-libraries=/usr/lib32 --with-qt-includes=/opt/kde-1.1.1 \
        --with-qt-libs=/opt/kde-1.1.1 --enable-shared

   Modify this to reflect your reality. In my case, I have Qt stuck in the same dir as KDE, so I had to explicitly name the includes and libs dir. Sometimes the configure will still not see the Qt includes dir. Source your .login file to correct this (You did set up your .login file as the instructions in the Qt installation asked?).

6. Run the script (which I'll include below) as follows:

        find . -name Makefile -exec ../FixMakesSq {} \;

   This fixes all the compile lines so that all the 'replicated' libraries (jpeg and png) are replaced with full paths so they won't be linked with the SGI ones. Note: In the original HOWTO, -fsquangle was added to each makefile. This caused compilation errors. I found that it was really only needed in one makefile. It will be noted below.

   Here's the FixMakesSq script:

        #!/bin/perl -ni.bak

        if ((/-lpng/) || (/-ljpeg/))
        {
            if (/^(.*)-lpng(.*)$/)
            {
                $b4 = $1;
                $af = $2;
                print "$b4 /path/to/KDE/libs/libpng.a $af\n";
            }
            if (/^(.*)-ljpeg(.*)$/)
            {
                $b4 = $1;
                $af = $2;
                print "$b4 /path/to/KDE/libs/libjpeg.a $af\n";
            }
        }

        #NOTE!! Uncomment this section if you want to add
        #-D_LANGUAGE_C_PLUS_PLUS to all
        #makefiles.  I personally have not tried this, but it should not break
        #anything.
        # Alternately, add the flag in the places noted below.

        #elsif (/cxxflags\s*=(.*)$/i)
        #{
        #    print "CXXFLAGS =  -D_LANGUAGE_C_PLUS_PLUS $1\n";
        #}
        else
        {
            print;
        }

   Do:

        gmake
        gmake install

7. Go to the 'libz' source directory, do:

        ./configure --prefix=$KDEDIR
        gmake
        gmake install

8. Go to the 'libpng' source directory, do:

        ./configure --prefix=$KDEDIR
        gmake
        gmake install

9. Unpack 'kdelibs' and enter its directory. Note the '--enable-new-stuff' argument to ./configure (this might not be needed, but nothing complains if you use it):

        ./configure --prefix=$KDEDIR --x-includes=/usr/include/X11 \
        --x-libraries=/usr/lib32 --with-qt-includes=/opt/kde-1.1.1 \
        --with-qt-libs=/opt/kde-1.1.1 --enable-shared --enable-new-stuff
        find . -name Makefile -exec ../FixMakesSq {} \;

10. Find 'kprocctrl.cpp', and fix the Makefile in that directory. Only if you did not uncomment the section that accomplishes this in the FixMakesSq script, add '-D_LANGUAGE_C_PLUS_PLUS' to the CXXFLAGS line. This makes it get the right definition for signal functions (has an 'int' arg).

11. Find 'addressbook.cc', and fix the Makefile in that directory. Add '-fsquangle' to the CXXFLAGS line. This makes it able to handle the huge name that's going to pop out.

         gmake
         gmake install

12. Unpack 'kdebase' and enter its directory. Do:

         ./configure --prefix=$KDEDIR  --x-includes=/usr/include/X11 \
         --x-libraries=/usr/lib32 --with-qt-includes=/opt/kde-1.1.1 \
         --with-qt-libs=/opt/kde-1.1.1 --enable-shared
         find . -name Makefile -exec ../FixMakesSq {} \;

13. Fix 'memory_sgi.cpp' (do a find from 'kdebase' directory). I just #ifdef'd out the contents of the whole function... it doesn't compile on my machine, and I never open that part of KPanel anyway :-).

14. Fix 'TEShell.C' (in kdebase-1.1.1/konsole/src/ directory). It is the operation for getting a pty for the new Konsole. Alas, it was not written with Irix in mind, and needs to be patched with the diff included below:

         *** TEShell.C   Mon Apr 12 00:12:37 1999
         --- /users/dor/aspg/ber/data/kdedown/kdebase-1.1.1/konsole/src/TEShell.C
         Wed Jul 14 15:15:35 1999
         ***************
         *** 169,174 ****
         --- 169,177 ----
             pid_t pid = waitpid(-1,&status,WNOHANG);
             Shell* sh = shells.find(pid);
             if (sh) { shells.remove(pid); sh->doneShell(status); }
         + #if defined(sgi)
         +   signal(SIGCHLD,catchChild);
         + #endif
           }

           void Shell::doneShell(int status)
         ***************
         *** 234,239 ****
         --- 237,252 ----
                 }
               }
             }
         + #endif
         +
         + #if defined(sgi) /* Irix */
         +
         +   needGrantPty = FALSE;
         +   char* line;
         +   line = _getpty(&ptyfd, O_RDWR|O_NDELAY, 0600, 0);
         +   strcpy(ptynam,"/dev/ptc");
         +   strcpy(ttynam,line);
         +
           #endif

             if (ptyfd < 0) // Linux, FIXME: Trouble on other systems?

         gmake
         gmake install

15. Unpack 'kdeutils'.

         ./configure --prefix=$KDEDIR  --x-includes=/usr/include/X11 \
         --x-libraries=/usr/lib32 --with-qt-includes=/opt/kde-1.1.1 \
         --with-qt-libs=/opt/kde-1.1.1 --enable-shared
         find . -name Makefile -exec ../FixMakesSq {} \;

16. Find 'kcalc_core.cpp' and fix its Makefile like you did for 'kprocctrl.cpp' above.

         gmake
         gmake install

17. Unpack 'kdegames', 'kdegraphics', and 'kdetoys' and for each one, enter its directory and do:

         ./configure --prefix=$KDEDIR  --x-includes=/usr/include/X11 \
         --x-libraries=/usr/lib32 --with-qt-includes=/opt/kde-1.1.1 \
         --with-qt-libs=/opt/kde-1.1.1 --enable-shared \
         find . -name Makefile -exec ../FixMakesSq {} \;
         gmake
         gmake install

18. This step is optional for KDE-1.1. I don't think it is necessary for KDE-1.1.1. Knotes has never crashed on me. I have left it here for completeness . Find where the knotes directory is. Go there, do a 'make clean', then change the CXXFLAGS in its Makefile. The CXXFLAGS line has '-O2', change that to '-g'. Then do a 'make' and 'make install'. The reason for this is that I found knotes crashed within a few minutes of it starting up; however, when I recompiled it with '-g' (i.e., debugging support) instead of '-O2' (optimization) it ran fine. Go figure :-).

And that's it. You should now be able to run KDE.