forked from gnustep/libobjc2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
INSTALL
124 lines (96 loc) · 4.85 KB
/
INSTALL
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
Installing the GNUstep Objective-C Runtime
==========================================
This file describes how to configure, install, and package the Objective-C
runtime. Note that although this runtime should build with gcc, it is strongly
recommended that you compile it with clang and clang++ as your [Objective-]C and
[Objective-]C++ compilers.
Basic Building
--------------
The runtime uses cmake to build. CMake performs configuration and generates
things that can be used by other programs that actually perform the building.
I recommend that you use Ninja for building if you are compiling regularly, but
these instructions will use Make to avoid the need for an extra dependency.
After checking out the code, build as follows:
$ mkdir Build
$ cd Build
$ cmake ..
-- { Lots of cmake output }
-- Build files have been written to: /build_path/libobjc/Build
$ make -j8
{ lots of make output }
[100%]...
$ sudo -E make install
This will build the runtime with the default options for your platform, which
may or may not be what you want, but hopefully are. You can see the list of
configurable options, and short explanations of each one, with this command
from the build directory:
$ ccmake .
This will also allow you to make changes. If you prefer a GUI, then there is
almost certainly a CMake GUI for your platform, but documenting them all is
beyond the scope of this quick guide.
If you have gcc and clang both installed, then cmake currently defaults to
selecting gcc. You should override this by adding `-DCMAKE_C_COMPILER=clang
-DCMAKE_CXX_COMPILER=clang` to your Objective-C flags.
You will probably also need to add
'-DCMAKE_ASM_COMPILER=clang -DCMAKE_ASM_FLAGS=-c -DTESTS=OFF'
Running the Tests
-----------------
By default, a load of test cases will be built. If you are compiling with gcc,
you probably want to turn them off: most of them will fail, and a lot won't
even compile. At present, they all should pass with clang 3.3 and most with
clang 3.2. If you have built the tests, you can run them with the test target,
like this:
$ make test
...
100% tests passed, 0 tests failed out of 28
Total Test time (real) = 4.23 sec
If your compiler can't build the tests, or you are building a package and don't
want to bother running the tests then add `-DTESTS=OFF` to your `cmake` command
line.
C++ Runtime Integration
-----------------------
The runtime will attempt to link against the C++ runtime library, if it is
available as a shared library on your platform. The two supported
implementations are libcxxrt (shipped with FreeBSD and written by the author of
this Objective-C runtime) and libsupc++ from the GNU project. If these are
available, then you will get a single libobjc.so, which links to either
libcxxrt or libsupc++. This linkage is required so that we can interoperate
with C++ exceptions, in particular catching Objective-C objects thrown from
Objective-C libraries in Objective-C++ `catch` blocks.
On most GNU/Linux systems, libstdc++ is statically linked to libsupc++. In
this configuration, we provide a separate libobjcxx.so, which avoids the need
for the Objective-C runtime to depend on the STL implementation just to be able
to interoperate with C++ exceptions.
Installation Location
---------------------
There are two ways of installing the runtime. It can either be treated as a
system library or a GNUstep library. It is recommended for packagers to use
the former, but people building GNUstep systems to do the latter.
If the build system detects the presence of the `gnustep-config` utility, it
will default to a GNUstep install, in the installation domain specified by this
utility. You can explicitly specify the installation domain by setting the
`GNUSTEP_INSTALL_TYPE` property to either `LOCAL`, `SYSTEM`, `NETWORK`, or
`NONE`. If you select `NONE` then the library will be installed in the
standard system location for libraries. This is configured by setting the
`CMAKE_INSTALL_PREFIX` variable, and typically defaults to either `/usr/` or
`/usr/local`.
LLVM Optimisations
------------------
The library comes with an LLVM plugin that provides a number of optimisations
that are specific to code compiled for this runtime. This is built by default
if the LLVM CMake modules are found. To disable building these optimisations,
run cmake with the `-DLLVM_OPTS=OFF` flag.
Packaging
---------
The build system support CPack, and so can build RPM and DEB packages out of
the box. Select the packaging system by setting the `CPACK_GENERATOR` property
and then build with the package target. For example, to build a .deb:
$ mkdir Deb
$ cd Deb
$ cmake .. -DCPACK_GENERATOR=DEB
$ make -j8
$ make package
Note that you almost certainly want to set CMAKE_BUILD_TYPE to Release when
packaging. Debug builds are slower and will print extra messages to help with
development. This is useful when writing Objective-C code, but not as useful
for end users.