OSDN Git Service

Checking Java availability is improved
[molby/Molby.git] / how_to_build
1 --------------------------------------------------------
2   How to build Molby
3   Version 0.6.5
4   Toshi Nagata
5 --------------------------------------------------------
6
7 Building Molby is somewhat complicated because you need static libraries of wxWidgets and Ruby (and CLAPACK in Windows). The procedures are described below for each platform.
8 In the following, $MOLBY represents the Molby source directory, which should reside within a directory like $HOME/Development or something like that.
9
10 (1) Mac OS X
11
12 (i) Xcode, gfortran
13
14 Install Xcode, if you have not done so yet. The Xcode project included in the source distribution is for Xcode 3.0 and later, thus you need Mac OS 10.5.
15
16 To build AmberTools, you need to have gfortran installed. The author uses a binary build available at the "R for Mac OS X" website (http://r.research.att.com/tools/, gfortran-4.2.3.dmg).
17
18 We need static linking of libgfortran.a. For that purpose, the following modification should be done after installation of gfortran.
19
20 % cd /usr/local/lib
21 % sudo cp libgfortran.a libgfortran-static.a  #  Copy as a different name
22 % sudo strip -S libgfortran-static.a  #  Remove the symbols
23 % sudo ranlib libgfortran-static.a
24
25 The last two lines are necessary to avoid linker warnings saying "Can't find atom for N_GSYM stabs."
26
27 (ii) wxWidgets
28
29 Get wxWidgets-3.0.0 from the wxWidgets official page in sourceforge.net (http://sourceforge.net/projects/wxwindows/files/). Newer versions may work, but they are not tested.
30
31 Unpack wxWidgets-3.0.0.tar.gz. Move the resulting directory wxWidgets-3.0.0 to $MOLBY/../.
32
33 Build wxWidgets. The commands will be as follows. Take care of the configure options.
34 $ cd $MOLBY/../wxWidgets-3.0.0
35 $ mkdir osx-build
36 $ cd osx-build
37 $ ../configure --with-macosx-sdk=/Developer/SDKs/MacOSX10.5.sdk --with-macosx-version-min=10.5 --enable-universal_binary=ppc,i386 --disable-shared --with-opengl --enable-monolithic
38 $ make
39 (It will take quite long. You do not need to do "sudo make install".)
40
41 (iii) Ruby
42
43 Get ruby-2.0.0-p353.tar.gz, unpack it, and move the resulting directory ruby-2.0.0-p353 to $MOLBY/../.
44 $ cd $MOLBY/../ruby-2.0.0-p353
45 $ CFLAGS='-isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -O2' ./configure --prefix=$PWD/osx-build --with-arch=i386,ppc --disable-shared --with-ext=date --disable-install-rdoc --with-static-linked-ext
46 $ make && make install
47 $ cp enc/libenc.a enc/libtrans.a osx-build/lib  #  We need this for encoding support
48
49 The osx-build directory contains lib (which contains libruby-static.a) and include (which contains include files). (There are also bin and share directories, but these are not used for building Molby.)
50 $ make clean  #  Remove configure files and intermediates; the osx-build directory remains intact
51
52 ---- Old description (ruby 1.8.7) ----
53 Get ruby-1.8.7-p160.tar.gz from the Molby source distribution site. Unpack it, and move the resulting directory ruby-1.8.7-p160 to $MOLBY/../. Rename it to ruby-1.8.7-static (or make a symbolic link).
54 $ cd $MOLBY/..
55 $ mv somewhere/ruby-1.8.7-p160.tar.gz ./
56 $ tar xvzf ruby-1.8.7-p160.tar.gz
57 $ ln -s ruby-1.8.7-p160 ruby-1.8.7-static
58
59 If you want to place ruby-1.8.7-static in another place (and/or another name) than $MOLBY/../, you will need to change the build settings in Xcode.
60
61 Patch the Ruby source.
62 $ cd $MOLBY/../ruby-1.8.7-static
63 $ patch --backup -p1 < $MOLBY/ruby-1.8.7-p160-tn.patch
64 ($MOLBY is the location of the Molby source.)
65
66 Build Ruby with --disable-shared option.
67 $ CFLAGS='-isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -arch i386 -arch ppc -O2' ./configure --disable-shared --disable-thread
68 $ make
69 ---- end old description (ruby 1.8.7) ----
70
71 (iv) FFTW
72
73 Get fftw-3.3.2.tar.gz, unpack it, and move the resulting directory fftw-3.3.2 to $MOLBY/../. $ cd $MOLBY/../fftw-3.3.2
74 $ ./configure --prefix=$PWD/osx-build --disable-fortran CFLAGS="-isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -arch i386 -O2"
75 $ make && make install  #  sudo is not necessary
76 $ ./configure --prefix=$PWD/osx-ppc-build --disable-fortran CFLAGS="-isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -arch ppc -O2"
77 $ make && make install  #  sudo is not necessary
78 $ cd osx-build/lib
79 $ mv libfftw3.a libfftw3.i386.a
80 $ lipo -create libfftw3.i386.a ../../osx-ppc-build/lib/libfftw3.a -output libfftw3.a
81 ranlib libfftw3.a
82
83 (v) Build on Xcode
84
85 Open xcode-build/Molby.xcodeproj, and build. Note that there are two configurations, Debug and Release. In the "Release" build, the Ruby scripts update_version.rb and Documents/makedoc.rb are executed before compilation; update_version.rb modifies the version strings in the source files (by looking up the file Version), and makedoc.rb creates the HTML docments in the doc directory.
86
87 (2) Windows
88
89 The Windows binary is built by using tdm-gcc/msys. If you use VC++ or Cygwin, you need to help yourself. I use Windows only occasionally, so there may be errors and misunderstandings in the following descriptions. Feedback is welcome!
90
91 (i) MinGW, MSYS, gfortran
92
93 Install msys and tdm-gcc. The author uses msys-1.0.11, tdm-gcc-4.7.1-2, and gcc-4.7.1-tdm-1-fortran.tar.lzma.
94 Read instructions carefully in installing tdm-gcc. 
95 In installing msys-1.0.11, please make sure findutils is installed. Otherwise, find.exe of Windows is invoked from make and cause strange errors.
96
97 (ii) wxWidgets
98
99 Get wxWidgets-3.0.0 from the wxWidgets official page in sourceforge.net (http://sourceforge.net/projects/wxwindows/files/). Newer versions may work, but they are not tested.
100
101 Unpack wxWidgets-3.0.0.tar.gz. Move the resulting directory wxWidgets-3.0.0 to $MOLBY/../.
102
103 Build wxWidgets. The commands will be as follows. Take care of the configure options.
104 $ cd $MOLBY/../wxWidgets-3.0.0
105 $ mkdir msw-build
106 $ cd msw-build
107 $ ../configure --with-msw --with-opengl --disable-shared --with-libjpeg=builtin --with-zlib=builtin --enable-monolithic
108 $ make
109 (It will take quite long. You do not need to do "sudo make install".)
110
111 (iii) Ruby
112
113 Get ruby-2.0.0-p353.tar.gz, unpack it, and move the resulting directory ruby-2.0.0-p353 to $MOLBY/../.
114 $ cd $MOLBY/../ruby-2.0.0-p353
115
116 If you use gcc 4.6 or later, comment out the following line in cygwin/GNUmakefile.in
117 #  DLLWRAP += -mno-cygwin
118 (gcc 4.x deprecates the -mno-cygwin option, and from 4.6 it causes 'unrecognized option' error.)
119
120 $ ./configure --prefix=$PWD/msw-build --disable-shared --with-ext=date --disable-install-rdoc --with-static-linked-ext
121 $ make && make install
122 $ cp enc/libenc.a enc/libtrans.a msw-build/lib  #  We need this for encoding support
123
124 The msw-build directory contains lib (which contains libmsvcrt-ruby200-static.a and libmsvcrt-rubuy200.a) and include (which contains include files). (There are also bin and share directories, but these are not used for building Molby.)
125 $ make clean  #  Remove configure files and intermediates; the msw-build directory remains intact
126
127 --- Old description (ruby 1.8.7) ---
128 Get ruby-1.8.7-p160.tar.gz from the Molby source distribution site. Unpack it, and move the resulting directory ruby-1.8.7-p160 to $HOME. Rename it to ruby-1.8.7-static.
129 $ cd $HOME
130 $ mv somewhere/ruby-1.8.7-p160.tar.gz ./
131 $ tar xvzf ruby-1.8.7-p160.tar.gz
132 $ mv ruby-1.8.7-p160 ruby-1.8.7-static
133
134 Patch the Ruby source.
135 $ cd $HOME/ruby-1.8.7-static
136 $ patch --backup -p1 < $MOLBY/ruby-1.8.7-p160-tn.patch
137 ($MOLBY is the location of the Molby source.)
138
139 Build Ruby with --disable-shared option.
140 $ ./configure --disable-shared --disable-thread
141 $ make
142
143 (iv) CLAPACK
144
145 Get clapack-3.1.1.1.tar.gz from the CLAPACK official site (http://www.netlib.org/clapack/) and unpack it. (clapack-3.2.1 may cause trouble because it uses symbolic links.)
146 $ cd $MOLBY/..
147 $ mv somewhere/clapack-3.1.1.1.tgz ./
148 $ tar xvzf clapack-3.1.1.1.tgz
149
150 Patch the clapack source.
151 $ patch -p0 <$MOLBY/clapack-3.1.1.1-mingw.patch
152
153 Build CLAPACK.
154 $ cd CLAPACK-3.1.1.1
155 $ make
156
157 In my case, uninit.c caused an error. It turned out that float.h in GCC needed modification. In c:/tdm-gcc-32-471/lib/gcc/mingw32/4.7.1/include/float.h, a line "#include_next <float.h>" was inserted just before the last "#endif".
158
159 Modify libf2c.a, so that the 'main' entry does not interfere the main program.
160 $ cd F2CLIBS
161 $ cp libf2c.a libf2c_nomain.a
162 $ ar d libf2c_nomain.a main.o
163 $ cd ..
164
165 Copy the library and header files to CLAPACK-3.1.1.1/lib
166 $ mkdir lib
167 $ cp F2CLIBS/libf2c_nomain.a lib
168 $ cp blasMinGW.a lib/libblasMinGW.a
169 $ cp lapackMinGW.a lib/liblapackMinGW.a
170
171 (v) FFTW
172
173 Get fftw-3.3.2.tar.gz and unpack it. Move the resulting directory fftw-3.3.2 to $MOLBY/../. $ ./configure --prefix=$PWD/msw-build --disable-fortran CFLAGS="-O2"
174 $ make
175 $ make install  #  sudo is not necessary
176
177 (vi) Inno Setup 5
178
179 Install Inno Setup 5 (http://www.jrsoftware.org/isinfo.php). This is necessary to create the Molby Installer.
180
181 (vii) Build
182
183 Now you can start building Molby! Go to the project directory and do make.
184 $ cd somewhere/Molby/msw-build
185 $ make
186 $ make setup  #  To make the installer
187
188
189 2010.1.21.
190 2010.1.31. Added notice on AmberTools1.3
191 2010.4.29. Update description for MinGW/MSYS
192 2011.8.3.  Added notice on static linking of libgfortran for Mac
193 2012.11.23. Added notice on FFTW
194
195 Toshi Nagata