]> git.lyx.org Git - lyx.git/blob - development/Win32/packaging/build_lyxwin.sh
This commit is a big rework of the FontLoader/FontMetrics interaction. Only Qt4 for...
[lyx.git] / development / Win32 / packaging / build_lyxwin.sh
1 #! /bin/sh
2
3 # This script aims to do everything necessary to automate the building
4 # of a LyX/Win package.
5
6 # Invocation:
7 # sh build_lyxwin.sh "1.3.6-pre23"
8 # The string will be shown in the "About LyX" dialog.
9
10 # Notes:
11 # It uses the MSYS environment and MinGW compiler.
12
13 # It asks whether the Qt and LyX cvs trees are up to date.
14 # It asks whether the Qt library has been compiled.
15 # It checks that qt-mt3.dll and mingw10.dll exist.
16 # It compiles the dv2dt and dt2dv utilites.
17 # It compiles and installs LyX.
18
19 # Once all this is done, you're ready to "package" LyX.
20 # See the README for details.
21
22 # The script compiles the .dll version of the Qt libraries. Linking of LyX
23 # against this will, therefore, take "some time".
24
25 # You may need to change these four variables.
26 MINGW_DIR="/j/MinGW"
27 QT_DIR="${HOME}"/Qt/3x-msys
28
29 # Everything from here on down should be OK "as is".
30 LYX_DIR="../../.."
31 PACKAGING_DIR="$LYX_DIR/development/Win32/packaging"
32 DTL_DIR="$PACKAGING_DIR/dtl"
33
34 ASPELL_INSTALL_DIR="c:/Aspell"
35 LYX_ASPELL_DIR="/c/Aspell" # the Autotools don't like "C:/" syntax.
36 LYX_RELATIVE_BUILDDIR=build
37 LYX_INSTALL_DIR=installprefix
38
39 # These are all installed in the final LyX package
40 QT_DLL="${QT_DIR}/bin/qt-mt3.dll"
41 MINGW_DLL="${MINGW_DIR}/bin/mingwm10.dll"
42
43 DT2DV="${DTL_DIR}/dt2dv.exe"
44 DV2DT="${DTL_DIR}/dv2dt.exe"
45
46 # Change this to 'mv -f' when you are confident that
47 # the various sed scripts are working correctly.
48 MV='mv -f'
49
50 check_dirs_exist()
51 {
52     for dir in "$QT_DIR" "$LYX_DIR" "$DTL_DIR"
53     do
54       test -d "$dir" || {
55           echo "$dir does not exist" >&2
56           exit 1
57       }
58     done
59 }
60
61
62 query_qt()
63 {
64     echo "Please ensure that the Qt and LyX cvs trees are up to date"
65     echo "and that the Qt library is compiled and ready to go."
66     echo "Press any key to continue"
67     read ans
68 }
69
70
71 check_files_exist()
72 {
73     # Check that the dlls exist
74     for file in "${QT_DLL}" "${MINGW_DLL}"
75     do
76       test -r "${file}" || {
77           echo "$file does not exist" >&2
78           exit 1
79       }
80     done
81 }
82
83
84 build_dtl()
85 {
86     # dt2dv and dv2dt
87     (
88         cd "$DTL_DIR" || {
89             echo "Unable to cd $DTL_DIR" >&2
90             exit 1
91         }
92
93         make || {
94             echo "Failed to make $DTL_DIR" >&2
95             exit 1
96         }
97     )
98
99     for file in "${DT2DV}" "${DV2DT}"
100     do
101       test -x "$file" || {
102           echo "${file} does not exist or is not executable" >&2
103           exit 1
104       }
105     done
106 }
107
108
109 modify_version_C()
110 {
111         VERSION_C="src/version.C"
112         test -r "${VERSION_C}" || {
113             echo "Unable to find ${VERSION_C}"
114             return
115         }
116         test "${LYX_VERSION_STR}" == "" && return
117
118         sed '/char const \* lyx_version = /s/"[^"]*"/"'${LYX_VERSION_STR}'"/' \
119             ${VERSION_C} > tmp.$$
120         diff -u ${VERSION_C} tmp.$$
121         ${MV} tmp.$$ ${VERSION_C}
122 }
123
124
125 run_automake()
126 {
127     (
128         cd "${LYX_DIR}" || {
129             echo "Unable to cd ${LYX_DIR}" >&2
130             exit 1
131         }
132
133         # Check the line endings of configure.ac
134         # The configure script will be unable to create config.h if it
135         # contains Win32-style line endings.
136         sed 's/\r$//' configure.ac > configure.ac.$$
137         cmp -s configure.ac configure.ac.$$ && {
138             rm -f configure.ac.$$
139         } || {
140             mv -f configure.ac.$$ configure.ac
141             cat <<EOF >&2
142 configure.ac has Win32-style line endings. Corrected
143 Please use the Cygwin flavours of the autotools to
144 run autogen.sh
145 EOF
146             exit 1
147         }
148
149 #       ./autogen.sh || {
150 #           echo "autogen.sh failed" >&2
151 #           exit 1
152 #       }
153     )
154 }
155
156
157 build_lyx()
158 {
159     (
160         cd "${LYX_DIR}" || {
161             echo "Unable to cd ${LYX_DIR}" >&2
162             exit 1
163         }
164
165         BUILDDIR="${LYX_RELATIVE_BUILDDIR}"
166         test ! -d "${BUILDDIR}" && {
167             mkdir "${BUILDDIR}" || \
168                 Error "Unable to create build dir, ${BUILDDIR}."
169         }
170
171         CONFIGURE="../configure --without-x --with-included-gettext --with-extra-prefix='${LYX_ASPELL_DIR}' --with-frontend=qt QTDIR='$QT_DIR' --disable-maintainer-mode --disable-debug --enable-optimization --disable-pch --disable-concept-checks --disable-stdlib-debug"
172
173         echo "${CONFIGURE}"
174         cd "${BUILDDIR}"
175         echo "${PWD}"
176         eval "${CONFIGURE}" || {
177             echo "Failed to configure LyX" >&2
178             exit 1
179         }
180
181         # Modify the "lyx_version" string in build/src/version.C
182         modify_version_C
183
184         # Build LyX
185         make || {
186             echo "Failed to make $LYX_DIR" >&2
187             exit 1
188         }
189     )
190 }
191
192
193 install_lyx()
194 {
195     (
196         BUILDDIR="${LYX_RELATIVE_BUILDDIR}"
197         cd "${LYX_DIR}/${BUILDDIR}" || {
198             echo "Unable to cd ${LYX_DIR}/${BUILDDIR}" >&2
199             exit 1
200         }
201
202         rm -fr "$LYX_INSTALL_DIR" || {
203             echo "Failed to remove $LYX_INSTALL_DIR prior to installing LyX" >&2
204             exit 1
205         }
206
207         make install || {
208             echo "Failed to install" >&2
209             exit 1
210         }
211     )
212 }
213
214 LYX_VERSION_STR=""
215 test $# -ne 0 && LYX_VERSION_STR=$1
216
217 check_dirs_exist || exit 1
218 query_qt || exit 1
219 check_files_exist || exit 1
220 build_dtl || exit 1
221 run_automake || exit 1
222 build_lyx || exit 1
223 install_lyx || exit 1
224 # The end