3 # This script aims to do averything necessary to automate the building
4 # of a LyX/Win package.
7 # sh build_lyxwin.sh "1.3.6-pre23"
8 # The string will be shown in the "About LyX" dialog.
10 # This script is written as a bunch of subroutines. You'll probably
11 # only need to build a couple of the packages (dtl, aspell) once.
12 # Thereafter, the invocation of these subroutines can be commented out.
13 # (See the end of the script.)
16 # It uses the MinGW/MinSYS environment and compiler.
18 # It asks whether the Qt and LyX cvs trees are up to date.
19 # It asks whether the Qt library has been compiled.
20 # It checks that qt-mt3.dll, libiconv-2.dll,
21 # mingw10.dll and clean_dvi.py exist.
22 # It compiles the dv2dt and dt2dv utilites.
23 # It compiles and installs the Aspell library.
24 # It compiles and installs LyX.
25 # It copies the dv2dt and dt2dv utilites, the .dlls and
26 # clean_dvi.py to the lyx package.
27 # It modifies the Resources/lyx/configure script to
28 # ensure that the generated .dvi file is usable.
30 # Once all this is done, you're ready to "package" LyX.
31 # See the README for details.
33 # The script compiles the .dll version of the Qt libraries. Linking of lyx
34 # against this will, therefore, take "some time".
36 # It compiles the static version of the Aspell libraries because no
37 # .dll version exists.
39 # You may need to change these four variables.
42 ASPELL_DIR="${HOME}"/aspell-0.50.5
43 # A space-separated string of directories
44 # ASPELL_DICT_DIRS="${HOME}/aspell-en-0.50-2 ${HOME}/aspell-de-0.50-2 "
45 ASPELL_DICT_DIRS="${HOME}/aspell-en-0.50-2"
47 # Everything from here on down should be OK "as is".
49 PACKAGING_DIR="$LYX_DIR/development/Win32/packaging"
50 DTL_DIR="$PACKAGING_DIR/dtl"
51 CLEAN_DVI_DIR="$PACKAGING_DIR"
53 ASPELL_INSTALL_DIR="c:/Aspell"
54 LYX_ASPELL_DIR="/c/Aspell" # the Autotools don't like "C:/" syntax.
55 LYX_RELATIVE_BUILDDIR=build
56 LYX_INSTALL_DIR=installprefix
58 # These are all installed in the final LyX package
59 QT_DLL="${QT_DIR}/bin/qt-mt3.dll"
60 LIBICONV_DLL="${MINGW_DIR}/bin/libiconv-2.dll"
61 MINGW_DLL="${MINGW_DIR}/bin/mingwm10.dll"
63 DT2DV="${DTL_DIR}/dt2dv.exe"
64 DV2DT="${DTL_DIR}/dv2dt.exe"
65 CLEAN_DVI_PY="${CLEAN_DVI_DIR}/clean_dvi.py"
67 # Change this to 'mv -f' when you are confident that
68 # the various sed scripts are working correctly.
73 for dir in "$QT_DIR" "$ASPELL_DIR" "$LYX_DIR" "$DTL_DIR"
76 echo "$dir does not exist" >&2
85 echo "Please ensure that the Qt and LyX cvs trees are up to date"
86 echo "and that the Qt library is compiled and ready to go."
87 echo "Press any key to continue"
94 # Check that the dlls and clean_dvi.py exist
95 for file in "${QT_DLL}" "${LIBICONV_DLL}" "${MINGW_DLL}" "${CLEAN_DVI_PY}"
97 test -r "${file}" || {
98 echo "$file does not exist" >&2
110 echo "Unable to cd $DTL_DIR" >&2
115 echo "Failed to make $DTL_DIR" >&2
120 for file in "${DT2DV}" "${DV2DT}"
123 echo "${file} does not exist or is not executable" >&2
134 cd "$ASPELL_DIR" || {
135 echo "Unable to cd $ASPELL_DIR" >&2
139 ./configure --enable-static --disable-shared --prefix="${ASPELL_INSTALL_DIR}" --sysconfdir="${ASPELL_INSTALL_DIR}" --enable-docdir="${ASPELL_INSTALL_DIR}/doc" --datadir="${ASPELL_INSTALL_DIR}/data" --enable-pkgdatadir="${ASPELL_INSTALL_DIR}/data" --enable-dict-dir="${ASPELL_INSTALL_DIR}/dict" --enable-win32-relocatable || {
140 echo "Failed to configure $ASPELL_DIR" >&2
144 # We have to clean up two of the generated Makefiles.
146 MAKEFILE=examples/Makefile
148 # Replace "CC = gcc" with "CC = g++"
149 s/^ *\(CC *= *\)gcc *$/\1g++/
150 # Remove trailing "/" from the -I directory.
151 s@^ *\(INCLUDES *= *-I\${top_srcdir}/interfaces/cc\)/ *$@\1@
152 ' "${MAKEFILE}" > "${TMP}"
153 cmp -s "${MAKEFILE}" "${TMP}" && {
154 echo "${MAKEFILE} is unchanged" 2>&1
156 diff -u "${MAKEFILE}" "${TMP}"
157 ${MV} "${TMP}" "${MAKEFILE}"
161 MAKEFILE=prog/Makefile
163 # Remove trailing "/" from the -I directories.
164 /^ *INCLUDES *= *-I\${top_srcdir}\/common/{
170 s@/ *\(\\ *\n\)@ \1@g
171 }' "${MAKEFILE}" > "${TMP}"
172 cmp -s "${MAKEFILE}" "${TMP}" && {
173 echo "${MAKEFILE} is unchanged" 2>&1
175 diff -u "${MAKEFILE}" "${TMP}"
176 ${MV} "${TMP}" "${MAKEFILE}"
181 echo "Failed to make $ASPELL_DIR" >&2
185 rm -fr "$ASPELL_INSTALL_DIR" || {
186 echo "Failed to remove $ASPELL_INSTALL_DIR prior to installing Aspell" >&2
191 echo "Failed to install $ASPELL_DIR" >&2
201 PATH="${LYX_ASPELL_DIR}:$PATH"
204 for dir in $ASPELL_DICT_DIRS
219 VERSION_C="src/version.C"
220 test -r "${VERSION_C}" || {
221 echo "Unable to find ${VERSION_C}"
224 test "${LYX_VERSION_STR}" == "" && return
226 sed '/char const \* lyx_version = /s/"[^"]*"/"'${LYX_VERSION_STR}'"/' \
227 ${VERSION_C} > tmp.$$
228 diff -u ${VERSION_C} tmp.$$
229 ${MV} tmp.$$ ${VERSION_C}
237 echo "Unable to cd ${LYX_DIR}" >&2
241 # Check the line endings of configure.ac
242 # The configure script will be unable to create config.h if it
243 # contains Win32-style line endings.
246 $//' config/configure.ac > configure.ac.$$
247 cmp -s config/configure.ac configure.ac.$$ && {
248 rm -f configure.ac.$$
250 mv -f configure.ac.$$ config/configure.ac
251 echo 'configure.ac has Win32-style line endings. Corrected' >&2
255 echo "autogen.sh failed" >&2
259 BUILDDIR="${LYX_RELATIVE_BUILDDIR}"
260 test ! -d "${BUILDDIR}" && {
261 mkdir "${BUILDDIR}" || \
262 Error "Unable to create build dir, ${BUILDDIR}."
265 CONFIGURE="../configure --without-x --with-included-gettext --with-extra-prefix='${LYX_ASPELL_DIR}' --with-frontend=qt QTDIR='$QT_DIR'"
270 eval "${CONFIGURE}" || {
271 echo "Failed to configure LyX" >&2
275 # Modify the "lyx_version" string in build/src/version.C
280 echo "Failed to make $LYX_DIR" >&2
290 BUILDDIR="${LYX_RELATIVE_BUILDDIR}"
291 cd "${LYX_DIR}/${BUILDDIR}" || {
292 echo "Unable to cd ${LYX_DIR}/${BUILDDIR}" >&2
296 rm -fr "$LYX_INSTALL_DIR" || {
297 echo "Failed to remove $LYX_INSTALL_DIR prior to installing LyX" >&2
302 echo "Failed to install" >&2
309 test $# -ne 0 && LYX_VERSION_STR=$1
311 check_dirs_exist || exit 1
313 check_files_exist || exit 1
315 build_aspell || exit 1
316 build_aspell_dicts || exit 1
318 install_lyx || exit 1