============================
  Build xxdiff for MAC OSX
============================

:Author: Martin Blais <blais@furius.ca>
:Date: 2005-06-03
:Abstract:

   Notes on how to build xxdiff for MAC OSX. 
   I don't own an Apple computer yet, so I haven't done any of this myself.

.. contents::
..
    1  From Trevor Harmon (2006-05-31)
    2  Alexandre Feblot (2005-06-03)
    3  Building under Mac OS X w/ XFree86 port (old)
      3.1  Notes on Mac OSX from Rolf Boelens (old)


From Trevor Harmon (2006-05-31)
-------------------------------

  From: Trevor Harmon <trevor@vocaro.com>	
  To: Martin Blais <blais@furius.ca>
  Date: May 31, 2006 7:43 PM
  Subject: xxdiff for Mac

  Hi,

  I haven't started looking at a Qt4 port for xxdiff, but I did figure
  out how to make it run natively on the Mac under Qt3 "out-of-the-
  box". All that's needed is the patch I've attached for xxdiff.pro
  (made against the 955 revision).

  With the patch applied, here's how I built xxdiff on the Mac:

  1. Install qt3, qt3mac, and flex-devel using Fink

  2. Create a file called ~/.xxdiffrc and add the following line::

       Style: "Macintosh (Aqua)"

  3. Go to the Terminal and run the following commands::

       export PATH="/sw/lib/flex/bin:$PATH"
       export CPPFLAGS="-I/sw/lib/flex/include"
       export LDFLAGS="-L/sw/lib/flex/lib"

     This will cause flex 2.5.33 to be used instead of the built-in flex
     2.5.4.

  4. In the same Terminal, run the following commands::

       export QTDIR=/sw/lib/qt3mac
       export QMAKESPEC=macx-g++
       export PATH="$QTDIR/bin:$PATH"

     This will cause the Mac version of Qt to be used.

  5. Switch to the xxdiff/src directory and run::

       make -f Makefile.bootstrap makefile
       make

  6. You can now run xxdiff by specifying the absolute path to bin/
     xxdiff.app/Contents/MacOS/xxdiff

     Note that with this patch, the xxdiff.app directory in ports/macosx is no
     longer necessary. It's generated automatically during the build
     process. (Also, the __MACOSX directory should be removed, too.)

  One other note: Even though the steps above generate an application
  package for xxdiff, it can't be used directly. That is, you can only
  run xxdiff by specifying the executable on the command line; double-
  clicking on the app icon doesn't work. That's because if xxdiff is
  run with no parameters, it immediately exits. Have you ever thought
  about changing this? For instance, perhaps if no parameters are
  given, xxdiff could prompt for the locations of the files/
  directories. That would allow xxdiff to be used more easily in GUI
  environments.

  Trevor


Alexandre Feblot (2005-06-03)
-----------------------------


                            How-To build xxdiff on Mac OSX with
native Aqua.

- Build a Mac OSX Native Qt 3 (I used 3.3.4) with gcc-3.3 (does not
compile yet with gcc 4.0; Qt 3.3.5 should)

- Tweak the tmake mac config to use gcc-3.3 and to remove the no-
exception flag
  (file tmake-1.13/lib/macx-g++/tmake.conf)
     - TMAKE_CC = gcc-3.3
    - TMAKE_CFLAGS =  -pipe            (-fno-exceptions removed from
here)
    - TMAKE_CXX = c++-3.3
    - TMAKE_LINK = c++-3.3
    - TMAKE_LINK_SHLIB = c++-3.3

- Generate the makefile. Compile.
  No problem exept some double defined warnings, which I'll consider
OK, as they also appear in the Qt examples.

- Create the bundle:
    xxdiff.app/
    xxdiff.app/Contents
    xxdiff.app/Contents/Info.plist
    xxdiff.app/Contents/MacOS
    xxdiff.app/Contents/MacOS/xxdiff
    xxdiff.app/Contents/PkgInfo
    xxdiff.app//Resources    (not necessary)
    xxdiff.app//Resources/xxdiff.icns    (not necessary: an icon for
the bundle appearence)

    PkgInfo only contains 8 characters: APPL????

    Info.plist is an XML property file:
        <?xml version="1.0" encoding="UTF-8"?>
        <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//
EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
        <plist version="1.0">
        <dict>
                <key>CFBundleDocumentTypes</key>
                <array>
                        <dict>
                                <key>CFBundleTypeExtensions</key>
                                <array>
                                        <string>*</string>
                                </array>
                                <key>CFBundleTypeOSTypes</key>
                                <array>
                                        <string>****</string>
                                        <string>fold</string>
                                </array>
                                <key>CFBundleTypeRole</key>
                                <string>Editor</string>
                        </dict>
                </array>
                <key>CFBundleExecutable</key>
                <string>xxdiff</string>
                <key>CFBundleGetInfoString</key>
                <string>Created by Qt/QMake</string>
                <key>CFBundleIconFile</key>
                <string>xxdiff.icns</string>
                <key>CFBundlePackageType</key>
                <string>APPL</string>
                <key>CFBundleSignature</key>
                <string>ttxt</string>
                <key>NOTE</key>
                <string>Please, do NOT change this file -- It was
generated by Qt/QMake.</string>
        </dict>
        </plist>

- Copy the xxdiff executable in the bundle MacOS directory

- Use xxdiff as usual on the command line, but specify an absolute
path (or Qt will complain about this).
  adding ~/bin/xxdiff.app/Contents/MacOS to the $PATH does not work
  I just made an alias for this:
     alias xxdiff='~/bin/xxdiff.app/Contents/MacOS/xxdiff'

- Define the Aqua style in the .xxdiffrc
  Style: "Macintosh (Aqua)"




Building under Mac OS X w/ XFree86 port (old)
---------------------------------------------

The relevant part within the makefile is under macx-g++

- Info on the Mac XFree86 port: http://apple.com/macosx/x11/

- Info on the OpenDarwin ports: http://opendarwin.org/projects/darwinports/


Notes on Mac OSX from Rolf Boelens (old)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

::

  Dear Martin,

  A few years ago you helped me out on setting up xxdiff on Mac OSX 10.2 with
  X11/xfree.  I moved now to OSX 10.3 with a newer machine and recompiled
  xxdiff-2.9.2 and the latest xxdiff-3.0.2.  Since I like the program a lot, I
  wanted to have it up and running again.

  I used the latest OSX 10.3.2 and latest Developer Tools XCode 1.1 from Apple,
  plus the Apple X11 release.

  I will summarize what I had to adapt, it is really minor:

  A. Commented out in xxdiff.pro the macx-g++ flags, since tmake does not
     understand them and fails::

       ...
       #macx-g++:TMAKE_CXXFLAGS += -D__GNU_LIBRARY__
       #macx-g++:TMAKE_CXXFLAGS -= -fno-exceptions
       ...

     The needed changes in Makefile can also be made later.

  B. To make the Makefile::

       % tmake xxdiff.pro -o Makefile

  C. Needed changes in Makefile, use ``CXXFLAGS = -fexceptions``::
        ...
        CXXFLAGS=       -fexceptions -pipe -Wall -W -O3 -DNO_DEBUG
        -DQT_THREAD_SUPPORT
        ...

  No other OSX specific c++ flags are needed anymore.

  I added my own notes for testing both xxdiff versions.
  I will try to post it at the sourceforge site as well, for your releif.

  With best regards, Rolf
