option for glib code
[charfbuzz.git] / make
blob462c2413f2609b0833a970365c7e8d39fa3fb7c4
1 #!/bin/sh
3 # stolen from ffmpeg configure like a pig
5 # Prevent locale nonsense from breaking basic text processing.
6 LC_ALL=C
7 export LC_ALL
9 major=0
10 minor=9
11 micro=30
12 slib_file_name=libharfbuzz.so.$major.$minor.$micro
13 slib_soname=libharfbuzz.so.$major
15 api_hdrs='
16 hb-blob.h
17 hb-buffer.h
18 hb-common.h
19 hb-coretext.h
20 hb-deprecated.h
21 hb-face.h
22 hb-font.h
23 hb-ft.h
24 hb-glib.h
25 hb-gobject.h
26 hb-gobject-structs.h
27 hb-graphite2.h
28 hb.h
29 hb-icu.h
30 hb-ot-font.h
31 hb-ot.h
32 hb-ot-layout.h
33 hb-ot-shape.h
34 hb-ot-tag.h
35 hb-set.h
36 hb-shape.h
37 hb-shape-plan.h
38 hb-unicode.h
39 hb-uniscribe.h
42 srcs='
43 hb-blob.c
44 hb-buffer.c
45 hb-common.c
46 hb-face.c
47 hb-fallback-shape.c
48 hb-font.c
49 hb-ft.c
50 hb-glib.c
51 hb-open-file.c
52 hb-ot-layout.c
53 hb-ot-tag.c
54 hb-shape.c
55 hb-shape-plan.c
56 hb-shaper.c
57 hb-unicode.c
58 hb-utf-private.c
61 clean_do(){
62 rm -Rf fake_root
63 for src_file in $srcs
65 o_file=${src_file%.c}
66 o_file=${o_file}.o
67 rm -f "$o_file"
68 done
69 rm -f harfbuzz.pc hb-version.h
70 exit 0
73 ################################################################################
75 # find source path
76 if test -f make; then
77 src_path=.
78 else
79 src_path=$(cd $(dirname "$0"); pwd)
80 echo "$src_path" | grep -q '[[:blank:]]' &&
81 die "Out of tree builds are impossible with whitespace in source path."
82 test -e "$src_path/config.h" &&
83 die "Out of tree builds are impossible with config.h in source dir."
86 is_in(){
87 value=$1
88 shift
89 for var in $*; do
90 [ $var = $value ] && return 0
91 done
92 return 1
95 append(){
96 var=$1
97 shift
98 eval "$var=\"\$$var $*\""
101 die_unknown(){
102 echo "Unknown option \"$1\"."
103 echo "See $0 --help for available options."
104 exit 1
107 set_default(){
108 for opt; do
109 eval : \${$opt:=\$${opt}_default}
110 done
113 PATHS_LIST='
114 prefix
115 incdir
116 libdir
117 pkg-config-sysroot
120 CMDLINE_APPEND="
121 extra_cflags
122 extra_cxxflags
123 host_cppflags
126 CMDLINE_SET="
127 $PATHS_LIST
128 slib_cc
129 slib_ccld
130 disable-glib
133 #path defaults
134 prefix_default='/usr/local'
135 incdir_default='$prefix/include'
136 libdir_default='$prefix/lib'
137 pkg_config_sysroot=''
139 #command lin set defaults
140 #for your information: harbuzz C API is shit when enabling c90 pedantic compilation
141 slib_cc_default='gcc -Wall -Wextra -Wno-missing-field-initializers -c -fpic -O0 -std=c90'
142 slib_ccld_default="gcc -shared -Wl,-soname=$slib_soname"
143 ln_s_default='ln -sf'
144 disable_glib_default=no
146 set_default $PATHS_LIST
147 set_default slib_cc slib_ccld disable_glib
149 show_help(){
150 cat <<EOF
151 Usage: make [options] [operations]
153 Operations: [default is to build the shared library]:
154 clean clean build products
157 Options: [defaults in brackets after descriptions]
159 Help options:
160 --help print this message
162 Features:
163 --disable-glib disable glib support [glib support is enabled]
165 Path options for pkg-config file:
166 --prefix=PREFIX install in PREFIX [$prefix_default]
167 --libdir=DIR install libs in DIR [$incdir_default]
168 --incdir=DIR install includes in DIR [$libdir_default]
170 Advanced options (experts only):
171 --pkg-config-sysroot=SYSROOT if you need to tell pkg-config that you cross-compile
172 --slib-cc=CC use C compiler command line CC for shared lib object[$slib_cc_default]
173 --slib-ccld=CCLD use linker command line LD for shared lib [$slib_ccld_default]
175 exit 0
178 for opt do
179 optval="${opt#*=}"
180 case "$opt" in
181 clean) clean_do
183 --help|-h) show_help
185 --disable-glib) disable_glib=yes
188 optname="${opt%%=*}"
189 optname="${optname#--}"
190 optname=$(echo "$optname" | sed 's/-/_/g')
191 if is_in $optname $CMDLINE_SET; then
192 eval $optname='$optval'
193 elif is_in $optname $CMDLINE_APPEND; then
194 append $optname "$optval"
195 else
196 die_unknown $opt
199 esac
200 done
202 #for pkgconfig to pickup the right package files
203 if test -n "$pkg_config_sysroot"; then
204 export PKG_CONFIG_SYSROOT_DIR=$pkg_config_sysroot
207 #-------------------------------------------------------------------------------
208 CPPFLAGS="-I./ -I$src_path \
209 $(pkg-config --cflags freetype2) \
212 if test x$disable_glib = xno; then
213 CPPFLAGS="$CPPFLAGS -DHAVE_GLIB \
214 $(pkg-config --cflags glib-2.0) \
217 #-------------------------------------------------------------------------------
219 #generate the version header file
220 sed -e "
221 s/@HB_VERSION_MAJOR@/$major/
222 s/@HB_VERSION_MINOR@/$minor/
223 s/@HB_VERSION_MICRO@/$micro/
224 s/@HB_VERSION@/$major.$minor.$micro/
225 " $src_path/hb-version.h.in >hb-version.h
227 #evaluate the final paths (depth of one)
228 eval "e_incdir=$incdir"
229 eval "e_libdir=$libdir"
231 #generate the pkg-config file
232 sed -e "
233 s:%prefix%:$prefix:
234 s:%exec_prefix%:$prefix:
235 s:%libdir%:$e_libdir:
236 s:%includedir%:$e_incdir:
237 s:%VERSION%:$major.$minor.$micro:
238 " $src_path/harfbuzz.pc.in >harfbuzz.pc
240 #compile source files, build a list of objet files
241 for src_file in $srcs
243 obj=${src_file%.c}
244 obj=${obj}.o
245 echo "SLIB_CC $src_file"
246 $slib_cc $CPPFLAGS -o "$obj" "$src_path/$src_file"
247 objs="$obj $objs"
248 done
250 #link the shared lib
251 echo "SLIB_CCLD $slib_file_name"
252 echo $objs
253 mkdir -p "fake_root/$e_libdir"
254 $slib_ccld -o "fake_root/$e_libdir/$slib_file_name" $objs
256 #install the other files in the fake root
257 ln -sf "$slib_file_name" "fake_root/$e_libdir/$slib_soname"
258 ln -sf "$slib_soname" "fake_root/$e_libdir/libharfbuzz.so"
260 mkdir -p "fake_root/$e_libdir/pkgconfig"
261 cp -f harfbuzz.pc fake_root/$e_libdir/pkgconfig/harfbuzz.pc
263 mkdir -p "fake_root/$e_incdir/harfbuzz"
264 for hdr in $api_hdrs
266 cp -f $src_path/$hdr "fake_root/$e_incdir/harfbuzz/$hdr"
267 cp -f hb-version.h "fake_root/$e_incdir/harfbuzz/"
268 done