OSDN Git Service

Embed ruby 2.0 instead of 1.8.7
[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
46 $ make && make install
47
48 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.)
49 $ make clean  #  Remove configure files and intermediates
50
51 ---- Old description (ruby 1.8.7) ----
52 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).
53 $ cd $MOLBY/..
54 $ mv somewhere/ruby-1.8.7-p160.tar.gz ./
55 $ tar xvzf ruby-1.8.7-p160.tar.gz
56 $ ln -s ruby-1.8.7-p160 ruby-1.8.7-static
57
58 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.
59
60 Patch the Ruby source.
61 $ cd $MOLBY/../ruby-1.8.7-static
62 $ patch --backup -p1 < $MOLBY/ruby-1.8.7-p160-tn.patch
63 ($MOLBY is the location of the Molby source.)
64
65 Build Ruby with --disable-shared option.
66 $ CFLAGS='-isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -arch i386 -arch ppc -O2' ./configure --disable-shared --disable-thread
67 $ make
68 ---- end old description (ruby 1.8.7) ----
69
70 (iv) FFTW
71
72 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
73 $ ./configure --prefix=$PWD/osx-build --disable-fortran CFLAGS="-isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -arch i386 -O2"
74 $ make && make install  #  sudo is not necessary
75 $ ./configure --prefix=$PWD/osx-ppc-build --disable-fortran CFLAGS="-isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -arch ppc -O2"
76 $ make && make install  #  sudo is not necessary
77 $ cd osx-build/lib
78 $ mv libfftw3.a libfftw3.i386.a
79 $ lipo -create libfftw3.i386.a ../../osx-ppc-build/lib/libfftw3.a -output libfftw3.a
80 ranlib libfftw3.a
81
82 (v) Build on Xcode
83
84 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.
85
86 (2) Windows
87
88 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!
89
90 (i) MinGW, MSYS, gfortran
91
92 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.
93 Read instructions carefully in installing tdm-gcc. 
94 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.
95
96 (ii) wxWidgets
97
98 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.
99
100 Unpack wxWidgets-3.0.0.tar.gz. Move the resulting directory wxWidgets-3.0.0 to $MOLBY/../.
101
102 Build wxWidgets. The commands will be as follows. Take care of the configure options.
103 $ cd $MOLBY/../wxWidgets-3.0.0
104 $ mkdir msw-build
105 $ cd msw-build
106 $ ../configure --with-msw --with-opengl --disable-shared --with-libjpeg=builtin --with-zlib=builtin --enable-monolithic
107 $ make
108 (It will take quite long. You do not need to do "sudo make install".)
109
110 (iii) Ruby
111
112 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.
113 $ cd $HOME
114 $ mv somewhere/ruby-1.8.7-p160.tar.gz ./
115 $ tar xvzf ruby-1.8.7-p160.tar.gz
116 $ mv ruby-1.8.7-p160 ruby-1.8.7-static
117
118 Patch the Ruby source.
119 $ cd $HOME/ruby-1.8.7-static
120 $ patch --backup -p1 < $MOLBY/ruby-1.8.7-p160-tn.patch
121 ($MOLBY is the location of the Molby source.)
122
123 Build Ruby with --disable-shared option.
124 $ ./configure --disable-shared --disable-thread
125 $ make
126
127 (iv) CLAPACK
128
129 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.)
130 $ cd $MOLBY/..
131 $ mv somewhere/clapack-3.1.1.1.tgz ./
132 $ tar xvzf clapack-3.1.1.1.tgz
133
134 Patch the clapack source.
135 $ patch -p0 <$MOLBY/clapack-3.1.1.1-mingw.patch
136
137 Build CLAPACK.
138 $ cd CLAPACK-3.1.1.1
139 $ make
140
141 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".
142
143 Modify libf2c.a, so that the 'main' entry does not interfere the main program.
144 $ cd F2CLIBS
145 $ cp libf2c.a libf2c_nomain.a
146 $ ar d libf2c_nomain.a main.o
147 $ cd ..
148
149 Copy the library and header files to CLAPACK-3.1.1.1/lib
150 $ mkdir lib
151 $ cp F2CLIBS/libf2c_nomain.a lib
152 $ cp blasMinGW.a lib/libblasMinGW.a
153 $ cp lapackMinGW.a lib/liblapackMinGW.a
154
155 (v) FFTW
156
157 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"
158 $ make
159 $ make install  #  sudo is not necessary
160
161 (vi) Inno Setup 5
162
163 Install Inno Setup 5 (http://www.jrsoftware.org/isinfo.php). This is necessary to create the Molby Installer.
164
165 (vii) Build
166
167 Now you can start building Molby! Go to the project directory and do make.
168 $ cd somewhere/Molby/msw-build
169 $ make
170 $ make setup  #  To make the installer
171
172
173 2010.1.21.
174 2010.1.31. Added notice on AmberTools1.3
175 2010.4.29. Update description for MinGW/MSYS
176 2011.8.3.  Added notice on static linking of libgfortran for Mac
177 2012.11.23. Added notice on FFTW
178
179 Toshi Nagata