aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorHeikki Lindholm <holin@iki.fi>2008-05-28 20:57:47 +0000
committerHeikki Lindholm <holin@iki.fi>2008-05-28 20:57:47 +0000
commit4b82e4acf52e64e211d61fb05f42172917c934b0 (patch)
tree70be072041a74f43eb24e9a815f69db367573f3f /contrib
parent6d2dcc1c433177dcbd15f1ccf53f0ca88d461ef2 (diff)
downloadlibextractor-4b82e4acf52e64e211d61fb05f42172917c934b0.tar.gz
libextractor-4b82e4acf52e64e211d61fb05f42172917c934b0.zip
add OS X framework build script
Diffstat (limited to 'contrib')
-rw-r--r--contrib/macosx/English.lproj/InfoPlist.stringsbin0 -> 148 bytes
-rw-r--r--contrib/macosx/Info.plist.in28
-rwxr-xr-xcontrib/macosx/build-osx-framework.sh543
3 files changed, 571 insertions, 0 deletions
diff --git a/contrib/macosx/English.lproj/InfoPlist.strings b/contrib/macosx/English.lproj/InfoPlist.strings
new file mode 100644
index 0000000..8da7fce
--- /dev/null
+++ b/contrib/macosx/English.lproj/InfoPlist.strings
Binary files differ
diff --git a/contrib/macosx/Info.plist.in b/contrib/macosx/Info.plist.in
new file mode 100644
index 0000000..b7b242e
--- /dev/null
+++ b/contrib/macosx/Info.plist.in
@@ -0,0 +1,28 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>CFBundleDevelopmentRegion</key>
6 <string>English</string>
7 <key>CFBundleExecutable</key>
8 <string>Extractor</string>
9 <key>CFBundleName</key>
10 <string>Extractor</string>
11 <key>CFBundleGetInfoString</key>
12 <string>@PACKAGE_STRING@, Copyright 2002-2008 Vidyut Samanta and Christian Grothoff</string>
13 <key>CFBundleIconFile</key>
14 <string></string>
15 <key>CFBundleIdentifier</key>
16 <string>org.gnunet.libextractor</string>
17 <key>CFBundleInfoDictionaryVersion</key>
18 <string>6.0</string>
19 <key>CFBundlePackageType</key>
20 <string>FMWK</string>
21 <key>CFBundleShortVersionString</key>
22 <string>@PACKAGE_VERSION@-0</string>
23 <key>CFBundleSignature</key>
24 <string>????</string>
25 <key>CFBundleVersion</key>
26 <string>Extractor @PACKAGE_VERSION@-0</string>
27</dict>
28</plist>
diff --git a/contrib/macosx/build-osx-framework.sh b/contrib/macosx/build-osx-framework.sh
new file mode 100755
index 0000000..1472193
--- /dev/null
+++ b/contrib/macosx/build-osx-framework.sh
@@ -0,0 +1,543 @@
1#!/bin/bash
2
3#
4# A script to build Extractor.framework for Mac OS X
5#
6# Copyright (C) 2008 Heikki Lindholm
7#
8# - 64-bit archs won't build on Mac OS X 10.4 (too many missing deps)
9#
10# TODO:
11# - find a cleaner libtool workaround
12# - error checking
13#
14
15SDK=MacOSX10.4u.sdk
16ORIG_SDK=/Developer/SDKs/${SDK}
17FW_NAME=Extractor.framework
18FW_BASE_DIR=/tmp/${FW_NAME}
19BUILD_DIR=/tmp/Extractor-build
20FINAL_FW_BASE_DIR="${BUILD_DIR}/${FW_NAME}"
21SDK_PATH="${BUILD_DIR}/${SDK}"
22OPT_FLAGS="-O2 -g"
23
24BUILD_ARCHS_LIST="ppc i386"
25export MACOSX_DEPLOYMENT_TARGET=10.4
26
27PKGCONFIG_URL=http://pkgconfig.freedesktop.org/releases
28PKGCONFIG_NAME=pkg-config-0.23
29LIBTOOL_URL=ftp://ftp.gnu.org/gnu/libtool
30LIBTOOL_NAME=libtool-2.2.4
31GETTEXT_URL=ftp://ftp.gnu.org/gnu/gettext
32GETTEXT_NAME=gettext-0.16.1
33LIBOGG_URL=http://downloads.xiph.org/releases/ogg
34LIBOGG_NAME=libogg-1.1.3
35LIBVORBIS_URL=http://downloads.xiph.org/releases/vorbis
36LIBVORBIS_NAME=libvorbis-1.1.2
37LIBFLAC_URL=http://switch.dl.sourceforge.net/sourceforge/flac
38LIBFLAC_NAME=flac-1.2.1
39LIBMPEG2_URL=http://libmpeg2.sourceforge.net/files
40LIBMPEG2_NAME=mpeg2dec-0.4.1
41
42export PATH=/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin:${BUILD_DIR}/toolchain/bin
43
44#
45# Fetch necessary packages
46#
47
48# $1 = package name
49# $2 = base url
50fetch_package()
51{
52 cd contrib
53 if [ ! -e "$1.tar.gz" ]
54 then
55 echo "fetching $1..."
56 curl -O --url "$2/$1.tar.gz"
57 fi
58 if [ ! -e "$1.tar.gz" ]
59 then
60 echo "Could not fetch package: $1"
61 exit 1
62 fi
63 cd ..
64}
65
66fetch_all_packages()
67{
68 fetch_package "${PKGCONFIG_NAME}" "${PKGCONFIG_URL}"
69# fetch_package "${LIBTOOL_NAME}" "${LIBTOOL_URL}"
70 fetch_package "${GETTEXT_NAME}" "${GETTEXT_URL}"
71 fetch_package "${LIBOGG_NAME}" "${LIBOGG_URL}"
72 fetch_package "${LIBVORBIS_NAME}" "${LIBVORBIS_URL}"
73 fetch_package "${LIBFLAC_NAME}" "${LIBFLAC_URL}"
74 fetch_package "${LIBMPEG2_NAME}" "${LIBMPEG2_URL}"
75}
76
77#
78# build native tools needed for building other packages
79#
80build_toolchain()
81{
82 if [ ! -e "${BUILD_DIR}/toolchain/bin/dictionary-builder" ]
83 then
84 ./configure --prefix="${BUILD_DIR}/toolchain" \
85 --disable-gsf \
86 --disable-gnome
87 make install
88 cp src/plugins/printable/dictionary-builder \
89 "${BUILD_DIR}/toolchain/bin"
90 make clean
91 fi
92
93 if [ ! -e "${BUILD_DIR}/toolchain/bin/msgfmt" ]
94 then
95 cd contrib
96
97 tar xzf "${GETTEXT_NAME}.tar.gz"
98 cd "${GETTEXT_NAME}"
99 ./configure --prefix="${BUILD_DIR}/toolchain" \
100 --disable-java \
101 --disable-native-java \
102 --without-emacs
103 make install
104 cd ..
105 rm -rf "${GETTEXT_NAME}"
106
107 cd ..
108 fi
109
110 if [ ! -e "${BUILD_DIR}/toolchain/bin/pkg-config" ]
111 then
112 cd contrib
113
114 tar xzf "${PKGCONFIG_NAME}.tar.gz"
115 cd "${PKGCONFIG_NAME}"
116 ./configure --prefix="${BUILD_DIR}/toolchain"
117 make install
118 cd ..
119 rm -rf "${PKGCONFIG_NAME}"
120
121 cd ..
122 fi
123
124# if [ ! -e "${BUILD_DIR}/toolchain/bin/libtool" ]
125# then
126# cd contrib
127
128# tar xzf "${LIBTOOL_NAME}.tar.gz"
129# cd "${LIBTOOL_NAME}"
130 # Make libfool unable to find ANY .la files, because they
131 # invariably cause linking havoc with sysroot although
132 # they really shouldn't
133# cp libltdl/config/ltmain.sh libltdl/config/ltmain.sh.orig
134 # ugh, for the love of...
135# chmod +w libltdl/config/ltmain.sh
136 # XXX works for the tested version only
137# cat libltdl/config/ltmain.sh.orig | \
138# sed "s/found=yes/found=no/g" > libltdl/config/ltmain.sh
139# ./configure --prefix="${BUILD_DIR}/toolchain"
140# make install
141# cd ..
142# rm -rf "${LIBTOOL_NAME}"
143# fi
144}
145
146#
147# prepare SDK
148#
149prepare_sdk()
150{
151 if [ ! -e "${BUILD_DIR}" ]
152 then
153 mkdir -p "${BUILD_DIR}"
154 fi
155
156 if [ ! -e "${SDK_PATH}" ]
157 then
158 cp -ipPR "${ORIG_SDK}" "${BUILD_DIR}"
159 fi
160
161 if [ ! -e "${SDK_PATH}" ]
162 then
163 echo "error preparing sdk"
164 exit 1
165 fi
166}
167
168prepare_package()
169{
170 prepare_retval=0
171 if [ ! -e "${BUILD_DIR}/built-$1-${ARCH_NAME}" ]
172 then
173 cd contrib
174 if [ ! -e "$1" ]
175 then
176 if ! ( tar xzf "$1.tar.gz" )
177 then
178 echo "error extracting $1"
179 prepare_retval=1
180 fi
181 fi
182 cd ..
183 if [ $prepare_retval -eq 1 ]
184 then
185 exit 1
186 fi
187 fi
188}
189
190# $1 = package name
191# $2 = configure options
192build_package()
193{
194 build_retval=0
195 if [ ! -e "${BUILD_DIR}/built-$1-${ARCH_NAME}" ]
196 then
197 echo "building $1 for ${ARCH_NAME}..."
198 cd contrib
199 cd "$1"
200 CC="${ARCH_CC}"
201 CXX="${ARCH_CXX}"
202 CPPFLAGS="${ARCH_CPPFLAGS}"
203 CFLAGS="${OPT_FLAGS} -no-cpp-precomp ${ARCH_CFLAGS}"
204 CXXFLAGS="${CFLAGS}"
205 LDFLAGS="${ARCH_LDFLAGS}"
206 if ! ( ./configure CC="${CC}" \
207 CXX="${CXX}" \
208 CPPFLAGS="${CPPFLAGS}" \
209 CFLAGS="${CFLAGS}" \
210 CXXFLAGS="${CXXFLAGS}" \
211 LDFLAGS="${LDFLAGS}" \
212 $2 && \
213 make DESTDIR="${SDK_PATH}" install && \
214 touch "${BUILD_DIR}/built-$1-${ARCH_NAME}" )
215 then
216 echo "error building $1 for ${ARCH_NAME}"
217 build_retval=1
218 fi
219 cd ..
220 rm -rf "$1"
221 rm -v `find "${SDK_PATH}" -name "*.la"`
222 unset CC
223 unset CXX
224 unset CPPFLAGS
225 unset CFLAGS
226 unset CXXFLAGS
227 unset LDFLAGS
228 cd ..
229 if [ $build_retval -eq 1 ]
230 then
231 exit 1
232 fi
233 fi
234}
235
236#
237# build dependencies
238#
239build_dependencies()
240{
241 ARCH_CC="gcc -arch ${ARCH_NAME}"
242 ARCH_CXX="g++ -arch ${ARCH_NAME}"
243 ARCH_CPPFLAGS="-I${SDK_PATH}/${FW_DIR}/include -isysroot ${SDK_PATH}"
244 ARCH_CFLAGS="-arch ${ARCH_NAME} -isysroot ${SDK_PATH}"
245 ARCH_LDFLAGS="-L${SDK_PATH}/${FW_DIR}/lib -arch ${ARCH_NAME} -isysroot ${SDK_PATH} -Wl,-syslibroot,${SDK_PATH}"
246
247# prepare_package "${GETTEXT_NAME}"
248# build_package "${GETTEXT_NAME}" \
249# "${ARCH_HOSTSETTING} \
250# --prefix="${FW_DIR}" \
251# --enable-shared \
252# --disable-java \
253# --disable-native-java \
254# --without-emacs \
255# --with-libiconv-prefix=${SDK_PATH}/usr"
256
257 prepare_package "${LIBOGG_NAME}"
258 build_package "${LIBOGG_NAME}" \
259 "${ARCH_HOSTSETTING} \
260 --prefix="${FW_DIR}" \
261 --disable-shared \
262 --enable-static"
263
264 prepare_package "${LIBVORBIS_NAME}"
265 build_package "${LIBVORBIS_NAME}" \
266 "${ARCH_HOSTSETTING} \
267 --prefix="${FW_DIR}" \
268 --disable-shared \
269 --enable-static \
270 --disable-oggtest"
271
272 prepare_package "${LIBFLAC_NAME}"
273 build_package "${LIBFLAC_NAME}" \
274 "${ARCH_HOSTSETTING} \
275 --prefix="${FW_DIR}" \
276 --disable-shared \
277 --enable-static \
278 --disable-asm-optimizations \
279 --disable-cpplibs \
280 --disable-oggtest \
281 --with-libiconv-prefix=${SDK_PATH}/usr"
282
283 prepare_package "${LIBMPEG2_NAME}"
284 build_package "${LIBMPEG2_NAME}" \
285 "${ARCH_HOSTSETTING} \
286 --prefix="${FW_DIR}" \
287 --disable-shared \
288 --enable-static"
289
290}
291
292#
293# build libextractor
294#
295build_extractor()
296{
297 build_retval=0
298 if [ ! -e "${BUILD_DIR}/built-Extractor-${ARCH_NAME}" ]
299 then
300 echo "building libextractor for ${ARCH_NAME}..."
301 ARCH_CC="gcc -arch ${ARCH_NAME} -isysroot ${SDK_PATH}"
302 ARCH_CXX="g++ -arch ${ARCH_NAME} -isysroot ${SDK_PATH}"
303 ARCH_CPPFLAGS="-isysroot ${SDK_PATH} -I${SDK_PATH}/${FW_DIR}/include"
304 ARCH_CFLAGS="-arch ${ARCH_NAME} -isysroot ${SDK_PATH}"
305 ARCH_LDFLAGS="-arch ${ARCH_NAME} -isysroot ${SDK_PATH} -Wl,-syslibroot,${SDK_PATH} -L${FW_DIR}/lib"
306 CFLAGS="${OPT_FLAGS} -no-cpp-precomp ${ARCH_CFLAGS}"
307 CPPFLAGS="${ARCH_CPPFLAGS}"
308 CXXFLAGS="${CFLAGS}"
309 LDFLAGS="${ARCH_LDFLAGS}"
310 if ! ( ./configure CC="${ARCH_CC}" \
311 CXX="${ARCH_CXX}" \
312 CPPFLAGS="${CPPFLAGS}" \
313 CFLAGS="${CFLAGS}" \
314 CXXFLAGS="${CXXFLAGS}" \
315 LDFLAGS="${LDFLAGS}" \
316 "${ARCH_HOSTSETTING}" \
317 --prefix="${FW_DIR}" \
318 --enable-shared \
319 --disable-gsf \
320 --disable-gnome \
321 --with-libiconv-prefix=${SDK_PATH}/usr )
322 then
323 build_retval=1
324 fi
325 # XXX unbelievably fragile!!!
326 cp ./libtool ./libtool.tmp
327 cat ./libtool.tmp | \
328 sed "s/found=yes/found=no/g;" | \
329 sed "s|eval depdepl=\"\$tmp\/lib\$tmp_libs.dylib\"|if test \"x\$tmp\" = \"x\/usr\/lib\" ; then\\
330eval depdepl=\"${SDK_PATH}\/\$tmp\/lib\$tmp_libs.dylib\"\\
331else\\
332eval depdepl=\"\$tmp\/lib\$tmp_libs.dylib\"\\
333fi|g" > ./libtool
334 rm ./libtool.tmp
335 #rm libtool
336 #ln -s "${BUILD_DIR}/toolchain/bin/libtool" ./libtool
337 #cp -Pp libtool libtool.orig
338 #cat libtool.orig | sed "s|sys_lib_search_path_spec=\"[^\"]*\"|sys_lib_search_path_spec=\"${SDK_PATH}/usr/lib\"|g" > libtool
339 # use native dictionary-builder instead of the cross-built one
340 find ./ -type f -name "Makefile" | \
341 xargs perl -pi -w -e "s#./dictionary-builder #${BUILD_DIR}/toolchain/bin/dictionary-builder #g;"
342 if ! ( make DESTDIR="${SDK_PATH}" install && \
343 touch "${BUILD_DIR}/built-Extractor-${ARCH_NAME}" )
344 then
345 build_retval=1
346 fi
347 unset CPPFLAGS
348 unset CFLAGS
349 unset CXXFLAGS
350 unset LDFLAGS
351 if [ $build_retval -eq 1 ]
352 then
353 exit 1
354 fi
355 fi
356}
357
358finalize_arch_build()
359{
360 if [ ! -e "${SDK_PATH}/${FW_BASE_DIR}-${ARCH_NAME}" ]
361 then
362 mv "${SDK_PATH}/${FW_BASE_DIR}" "${SDK_PATH}/${FW_BASE_DIR}-${ARCH_NAME}"
363 fi
364}
365
366create_directory_for()
367{
368 dst_dir=$(dirname "$1")
369 if [ ! -e "${dst_dir}" ]
370 then
371 echo "MKDIR ${dst_dir}"
372 if ! ( mkdir -p "${dst_dir}" )
373 then
374 echo "failed to create directory: ${dst_dir}"
375 exit 1
376 fi
377 fi
378}
379
380install_executable_to_framework()
381{
382 src_name="$1"
383 src_files=""
384 dst_file="${FINAL_FW_DIR}/${src_name}"
385 for arch in $BUILD_ARCHS_LIST
386 do
387 tmpfile="${SDK_PATH}/${FW_BASE_DIR}-${arch}/${FW_VERSION_DIR}/${src_name}"
388 if [ -h "${tmpfile}" ]
389 then
390 install_file_to_framework $1
391 elif [ -f "${tmpfile}" ]
392 then
393 src_files="${tmpfile} ${src_files}"
394 else
395 echo "no such file: ${tmpfile}"
396 exit 1
397 fi
398 done
399 if [ "x${src_files}" != "x" ]
400 then
401 create_directory_for "${dst_file}"
402 if [ ! -e "${dst_file}" ] && [ ! -h "${dst_file}" ]
403 then
404 echo "LIPO ${dst_file}"
405 lipo -create -o "${dst_file}" ${src_files}
406 fi
407 fi
408}
409
410install_file_to_framework()
411{
412 src_name="$1"
413 for arch in $BUILD_ARCHS_LIST
414 do
415 src_file="${SDK_PATH}/${FW_BASE_DIR}-${arch}/${FW_VERSION_DIR}/${src_name}"
416 dst_file="${FINAL_FW_DIR}/${src_name}"
417 create_directory_for "${dst_file}"
418 if [ ! -e "${dst_file}" ] && [ ! -h "${dst_file}" ]
419 then
420 if [ -h "${src_file}" ]
421 then
422 echo "CP ${dst_file}"
423 cp -PpR "${src_file}" "${dst_file}"
424 elif [ -f "${src_file}" ]
425 then
426 echo "INSTALL ${dst_file}"
427 install "${src_file}" "${dst_file}"
428 else
429 echo "no such file: ${src_file}"
430 exit 1
431 fi
432 else
433 if [ -f "${src_file}" ] && [ -f "${dst_file}" ]
434 then
435 diff "${src_file}" "${dst_file}"
436 fi
437 fi
438 done
439}
440
441copy_file_to_framework()
442{
443 src_file="$1"
444 dst_file="${FINAL_FW_DIR}/$2"
445 if [ ! -e "$dst_file" ]
446 then
447 create_directory_for "$dst_file"
448 install "$src_file" "$dst_file"
449 fi
450}
451
452make_framework_link()
453{
454 link_target="$1"
455 link_name="$2"
456 orig_dir=$(pwd)
457 cd "${FINAL_FW_DIR}"
458 echo "LN $link_name"
459 ln -sf "$link_target" "$link_name"
460 cd "${orig_dir}"
461}
462
463make_framework_version_links()
464{
465 orig_dir=$(pwd)
466 cd "${FINAL_FW_BASE_DIR}/Versions"
467 ln -sf "${FW_VERSION}" "Current"
468 cd "${FINAL_FW_BASE_DIR}"
469 ln -sf "Versions/Current/Headers" "Headers"
470 ln -sf "Versions/Current/Extractor" "Extractor"
471 ln -sf "Versions/Current/PlugIns" "PlugIns"
472 ln -sf "Versions/Current/Resources" "Resources"
473 cd "${orig_dir}"
474}
475
476FW_VERSION=`grep "LIB_VERSION_CURRENT=[0123456789]*" ./configure | cut -d= -f2`
477FW_VERSION_DIR="Versions/${FW_VERSION}"
478FW_DIR="${FW_BASE_DIR}/${FW_VERSION_DIR}"
479FINAL_FW_DIR="${FINAL_FW_BASE_DIR}/${FW_VERSION_DIR}"
480export PKG_CONFIG_PATH=${FW_DIR}/lib/pkgconfig
481ORIG_DIR=$(pwd)
482
483# prepare build env
484fetch_all_packages
485prepare_sdk
486build_toolchain
487
488# build deps and libextractor for all archs
489for arch in $BUILD_ARCHS_LIST
490do
491 ARCH_NAME=$arch
492 case "$arch" in
493 "ppc")
494 ARCH_HOSTSETTING="--host=powerpc-apple-darwin8"
495 ;;
496 "ppc64")
497 ARCH_HOSTSETTING="--host=powerpc64-apple-darwin8"
498 ;;
499 "i386")
500 ARCH_HOSTSETTING="--host=i686-apple-darwin8"
501 ;;
502 "x86_64")
503 ARCH_HOSTSETTING="--host=x86_64-apple-darwin8"
504 ;;
505 *)
506 echo "unknown architecture ${arch}"
507 exit 1
508 ;;
509 esac
510 build_dependencies
511 build_extractor
512 finalize_arch_build
513done
514
515# build framework structure
516first_arch=$(echo "$BUILD_ARCHS_LIST" | cut -d ' ' -f 1)
517cd "${SDK_PATH}/${FW_BASE_DIR}-${first_arch}/${FW_VERSION_DIR}"
518install_executable_to_framework 'bin/extract'
519for tfn in lib/libextractor*dylib
520do
521 install_executable_to_framework "$tfn"
522done
523for tfn in lib/libextractor/libextractor*so
524do
525 install_executable_to_framework "$tfn"
526done
527install_file_to_framework 'include/extractor.h'
528install_file_to_framework 'share/man/man1/extract.1'
529install_file_to_framework 'share/man/man3/libextractor.3'
530for tfn in $(find ./share/locale -name 'libextractor*')
531do
532 install_file_to_framework "$tfn"
533done
534cd "${ORIG_DIR}"
535copy_file_to_framework "./contrib/macosx/Info.plist" "Resources/Info.plist"
536copy_file_to_framework "./contrib/macosx/English.lproj/InfoPlist.strings" "Resources/English.lproj/InfoPlist.strings"
537make_framework_link "lib/libextractor.dylib" "Extractor"
538make_framework_link "lib" "Libraries"
539make_framework_link "lib/libextractor" "PlugIns"
540make_framework_link "include" "Headers"
541make_framework_version_links
542
543echo "done."