add explicit freetype2 linking
[charfbuzz.git] / make
blobd786a7162742b83e67d6039f51d97c6e34d39768
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
119 CMDLINE_APPEND="
120 extra_cflags
121 extra_cxxflags
122 host_cppflags
125 CMDLINE_SET="
126 $PATHS_LIST
127 slib_cc
128 slib_ccld
129 alib_ar
130 disable-glib
133 #path defaults
134 prefix_default='/usr/local'
135 incdir_default='$prefix/include'
136 libdir_default='$prefix/lib'
138 #command lin set defaults
139 #for your information: harbuzz C API is shit when enabling c90 pedantic compilation
140 slib_cc_default='gcc -Wall -Wextra -Wno-missing-field-initializers -c -fPIC -O2 -std=c90'
141 slib_ccld_default="gcc -shared -Wl,-soname=$slib_soname"
142 alib_ar_default='ar rucs'
143 ln_s_default='ln -sf'
144 disable_glib_default=no
146 set_default $PATHS_LIST
147 set_default alib_ar 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 --slib-cc=CC use C compiler command line CC for shared lib object[$slib_cc_default]
172 --slib-ccld=CCLD use linker command line LD for shared lib [$slib_ccld_default]
173 --alib-ar=AR use archive command line AR to create the static library archive [$alib_ar_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 #-------------------------------------------------------------------------------
203 CPPFLAGS="-I./ -I$src_path \
204 $(pkg-config --cflags freetype2) \
207 if test x$disable_glib = xno; then
208 CPPFLAGS="$CPPFLAGS -DHAVE_GLIB \
209 $(pkg-config --cflags glib-2.0) \
212 #-------------------------------------------------------------------------------
214 #generate the version header file
215 sed -e "
216 s/@HB_VERSION_MAJOR@/$major/
217 s/@HB_VERSION_MINOR@/$minor/
218 s/@HB_VERSION_MICRO@/$micro/
219 s/@HB_VERSION@/$major.$minor.$micro/
220 " $src_path/hb-version.h.in >hb-version.h
222 #evaluate the final paths (depth of one)
223 eval "e_incdir=$incdir"
224 eval "e_libdir=$libdir"
226 #generate the pkg-config file
227 sed -e "
228 s:%prefix%:$prefix:
229 s:%exec_prefix%:$prefix:
230 s:%libdir%:$e_libdir:
231 s:%includedir%:$e_incdir:
232 s:%VERSION%:$major.$minor.$micro:
233 " $src_path/harfbuzz.pc.in >harfbuzz.pc
235 #compile source files, build a list of objet files
236 for src_file in $srcs
238 obj=${src_file%.c}
239 obj=${obj}.o
240 echo "SLIB_CC $src_file"
241 $slib_cc $CPPFLAGS -o "$obj" "$src_path/$src_file"
242 objs="$obj $objs"
243 done
245 #link the shared lib
246 echo "SLIB_CCLD $slib_file_name"
247 echo $objs
248 mkdir -p "fake_root/$e_libdir"
249 $slib_ccld -o "fake_root/$e_libdir/$slib_file_name" $objs $(pkg-config --libs freetype2)
251 #install the other files in the fake root
252 ln -sf "$slib_file_name" "fake_root/$e_libdir/$slib_soname"
253 ln -sf "$slib_soname" "fake_root/$e_libdir/libharfbuzz.so"
255 # create the library archive
256 echo "ALIB_AR libharfbuzz.a"
257 $alib_ar fake_root$e_libdir/libharfbuzz.a $objs
259 mkdir -p "fake_root/$e_libdir/pkgconfig"
260 cp -f harfbuzz.pc fake_root/$e_libdir/pkgconfig/harfbuzz.pc
262 mkdir -p "fake_root/$e_incdir/harfbuzz"
263 for hdr in $api_hdrs
265 cp -f $src_path/$hdr "fake_root/$e_incdir/harfbuzz/$hdr"
266 cp -f hb-version.h "fake_root/$e_incdir/harfbuzz/"
267 done