~ubuntu-branches/ubuntu/utopic/gtk2hs/utopic

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
Gtk2Hs: A GUI Library for Haskell based on Gtk+

http://haskell.org/gtk2hs/

The library currently wraps most functions from the Gtk+ 2.8 libraries.
Furthermore there is support for cairo, cairo svg loader, pango, the libglade
UI loader, the Gtk+ OpenGL extension, the SourceView widget, the GConf
configuration system, and the Mozilla rendering engine embedded in a widget.

The GHC Haskell compiler, version 6.0 or greater, is required.
Gtk2Hs is known to compile on Linux, Windows, OSX, FreeBSD, and Solaris.

These instruuctions are about building Gtk2Hs from source. If you would rather
install a binary (pre-compiled) package, please check the Gtk2Hs web site.

Building
--------

This section assumes that you are building a source distribution (.tar.gz).
If you are building on Windows, read "Building on Windows" first. If you
are using the darcs version, please read "Building from darcs".

The following assumes that the sources are in ~/gtk2hs.

1. Run the configure script.
----------------------------

The configure script has several useful options, particularly:

--with-hc=<path to your ghc>
  Uses the specified GHC for compilation and for installation of the package.

--with-hcflags=<path to your ghc>
  If you find that you need to pass any special flags to the Haskell compiler
  then use this option to specify them. This overrides the default flags which
  is just "-O" to compile using optimisations. Use -O0 for a quicker build.

--enable-profiling
  Build profiling versions of all the libraries in addition to the normal ones.

--disable-split-objs
  By default the libraries are built using GHC's 'split-objs' feature. This
  makes for considerably smaller binaries since it allows the linker to
  include only the functions needed. However split-objs doesn't work on every
  platform so if you get linker errors then you can can try disabling it.
  Building the Gtk2Hs libs with split-objs turned on is considerably
  slower and uses more memory so you may prefer to turn it off.

--with-user-pkgconf
  Instead of registering Gtk2Hs with GHC's global package file, register in the
  user's one instead. This is useful if you want to install to your own user
  space rather than system wide.

--enable-docs
  This builds reference documentation in html format. These are also available
  from the website but you may prefer to keep a local copy. You will need
  haddock version 0.7 or later to build the documentation.

--enable-PACKAGE      {- substitute package name for PACKAGE -}
--disable-PACKAGE
  Gtk2Hs contains bindings to some libraries that are not part of Gtk+ but
  closely related. This option forces a particular package to be built or
  not built. The default is to autodetect if a given package is installed
  (except in --packager-mode where the default is --disable-PACKAGE for all
  packages). At the time of writing the possible values for PACKAGE are:

  libglade : A library to load XML user interface descriptions that were
 	generated by the Glade user interface builder.

  gconf : A library to store configuration data in a Gnome-compatible way.

  sourceview : An enhancement of the TextView-widget of Gtk+. It adds features
	useful for editing source code, e.g. syntax highlighting.

  firefox / seamonkey / xulrunner / mozilla : A widget that renders HTML.

  cairo : A library for rendering vector graphics.

  svg : SVG file rendering for cairo.

  opengl : Bindings for the Gtk OpenGL extension

--disable-deprecated
  There are many Gtk+ APIs that have been deprecated as new versions of Gtk+
  have come out. This option makes sure that no deprecated APIs are used. You
  might want to use this option to make sure that you are not using deprecated
  APIs in your new programs.

--with-pkgconf=<path to a local .conf file>
  Instead of registering Gtk2Hs with GHC's global package file, use a specific
  file. If this file doesn't exit, it is created.

--without-pkgreg
  This option disables registering the packages with GHC at all. This
  is useful to people building on one machine but wanting to install on
  another, e.g. people packaging Gtk2Hs for use with a package management
  system.

--enable-packager-mode
  Enables --without-pkgreg and does not build any optional packages unless
  these are specified with --enable-PACKAGE. On Windows it also does some
  other stuff that helps with building an installer.


If you want to do a quick build use:

~/gtk2hs:$ ./configure --with-hcflags=-O0 --disable-split-objs

If you want to install into your home directory rather than system-wide use:

~/gtk2hs:$ ./configure --prefix=$HOME --with-user-pkgconf

2. Building the sources.

In the following "make" stands for GNU make. If your system has a program
called "gmake" then "make" is probably not GNU make. In this case use "gmake".

To build the sources you issue:

~/gtk2hs:$ make


3. Install the libraries.
-------------------------

If you are installing system-wide then use:

~/gtk2hs:$ sudo make install

or if you use the 'su' command rather than 'sudo':

~/gtk2hs:$ su
~/gtk2hs:# make install

If you configured to install into your home directory then just say:

~/gtk2hs:$ make install


4. Compiling a program.
-----------------------

To get started, you can compile and run one of the programs that reside in
the demo/ directory in the gtk2hs source directory. For example:

~/gtk2hs/demo/hello:$ make

which has the same effect as typing

~/gtk2hs/demo/hello:$ ghc --make World.hs -o helloworld

The program should pop up a dialog box when you say

~/gtk2hs/demo/hello:$ ./helloworld


5. Documentation
----------------

The documentation is avaliable on the website. You can also build the
documentation locally. You say

~/gtk2hs:$ ./configure --enable-docs


6. Deinstallation
-----------------

So long as you do not delete the source tree you can easily uninstall
everything that gtk2hs installed by saying

~/gtk2hs:$ make uninstall

in the root of the source tree. This will properly remove the package from
GHC and remove any installed file.

Alteratively, if you do not keep the source tree around then you can
uninstall by unregistering the packages with ghc-pkg and deleting all the
installed files. Assuming that you installed in the default location
(ie did not specify --prefix= during ./configure) then that would mean
doing the following:

# for pkg in glib gtk cairo glade gtkglext svgcairo gconf sourceview mozembed soegtk; \
> do ghc-pkg unregister $pkg; done
# rm -rf /usr/local/lib/gtk2hs/
# rm -rf /usr/local/share/doc/gtk2hs/  #if you installed the docs


Building on Windows
--------------------

Install MSYS and MinGW. Download a build of Gtk+, you will need the "dev"
version which includes all the header files and libraries. Make sure that GHC
and that pkg-config.exe can find all your Gtk+ libraries. The configure script
should complain if this is not the case.


Building from darcs
-------------------

Building the latest sources from the darcs repository is normally straight
forward. In fact, since Gtk2Hs is only a wrapper around Gtk+, the development
version is usually not as "unstable" as it is for most software projects.

Building the development version proceeds as normal building, except that you
need to run "autoreconf" first. You will need sufficiently new versions of the
automake/autoconf toolsuite installed. (automake 1.8.x, autoconf 2.59)

Note that dependencies are generated only in a clean tree. Hence, if the
import structure of files change, the build might fail due to missing
dependencies. The easy way out is "make clean; make", the faster way is
to delete the lib*.deps files in each subdirectory.



Please report problems to the Gtk2hs mailing list
<gtk2hs-users@lists.sourceforge.net>.

The Gtk2Hs team.