Initial commit
[charfbuzz.git] / make
blobedd2b6231f135de68611fe7ad3f9882a0fe51e57
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=20
12 slib_file_name=libharfbuzz.so.${major}.${minor}.${micro}
13 slib_soname=libharfbuzz.so.${major}
15 api_hdrs='
16 hb.h
17 hb-blob.h
18 hb-buffer.h
19 hb-common.h
20 hb-deprecated.h
21 hb-face.h
22 hb-font.h
23 hb-set.h
24 hb-shape.h
25 hb-shape-plan.h
26 hb-unicode.h
27 hb-ft.h
28 hb-graphite2.h
29 hb-coretext.h
30 hb-uniscribe.h
31 hb-icu.h
32 hb-glib.h
33 hb-gobject.h
34 hb-gobject-structs.h
35 hb-ot.h
36 hb-ot-layout.h
37 hb-ot-tag.h
38 hb-version.h
41 srcs='
42 hb-blob.c
43 hb-buffer.c
44 hb-common.c
45 hb-face.c
46 hb-fallback-shape.c
47 hb-font.c
48 hb-ft.c
49 hb-glib.c
50 hb-open-file.c
51 hb-ot-layout.c
52 hb-ot-tag.c
53 hb-shape.c
54 hb-shape-plan.c
55 hb-shaper.c
56 hb-unicode.c
57 hb-utf-private.c
60 clean_do(){
61 rm -f ${slib_file_name}
62 for src_file in ${srcs}
64 rm -f ${src_file/\.c/.o}
65 done
66 rm -f harfbuzz.pc hb-version.h
67 exit 0
70 install_do(){
71 eval prefix=${prefix}
72 eval libdir=${libdir}
73 eval incdir=${incdir}
75 ${slib_install} ${slib_file_name} ${destdir}${sysroot}${libdir}/${slib_file_name}
76 ${ln_s} ${destdir}${sysroot}${libdir}/${slib_file_name} ${destdir}${sysroot}${libdir}/${slib_soname}
77 ${ln_s} ${destdir}${sysroot}${libdir}/${slib_file_name} ${destdir}${sysroot}${libdir}/libharfbuzz.so
78 ${file_install} harfbuzz.pc ${destdir}${sysroot}${libdir}/pkgconfig/harfbuzz.pc
79 for hdr in ${api_hdrs}
81 ${file_install} ${source_path}/${hdr} ${destdir}${sysroot}${incdir}/harfbuzz/${hdr}
82 done
83 exit 0
86 ################################################################################
88 # find source path
89 if test -f make; then
90 source_path=.
91 else
92 source_path=$(cd $(dirname "$0"); pwd)
93 echo "$source_path" | grep -q '[[:blank:]]' &&
94 die "Out of tree builds are impossible with whitespace in source path."
95 test -e "$source_path/config.h" &&
96 die "Out of tree builds are impossible with config.h in source dir."
99 is_in(){
100 value=$1
101 shift
102 for var in $*; do
103 [ $var = $value ] && return 0
104 done
105 return 1
108 append(){
109 var=$1
110 shift
111 eval "$var=\"\$$var $*\""
114 die_unknown(){
115 echo "Unknown option \"$1\"."
116 echo "See $0 --help for available options."
117 exit 1
120 set_default(){
121 for opt; do
122 eval : \${$opt:=\$${opt}_default}
123 done
126 PATHS_LIST='
127 prefix
128 incdir
129 libdir
130 prefix
131 sysroot
132 destdir
135 CMDLINE_APPEND="
136 extra_cflags
137 extra_cxxflags
138 host_cppflags
141 CMDLINE_SET="
142 ${PATHS_LIST}
143 slib_cc
144 slib_ld
147 # path defaults
148 prefix_default="/usr/local"
149 incdir_default='${prefix}/include'
150 libdir_default='${prefix}/lib'
152 #command lin set defaults
153 #slib_cc_default='gcc -Wall -Wextra -Wno-missing-field-initializers -c -fPIC -fpic -Ofast -std=c99'
154 slib_cc_default="gcc -Wall -Wextra -Wno-missing-field-initializers -c -fPIC -fpic -g -std=c99"
155 slib_ld_default="gcc -shared -Wl,-soname=${LIB_SONAME}"
156 slib_install_default='install -D --mode=755'
157 file_install_default='install -D --mode=644'
158 ln_s_default='ln --symbolic --force'
160 set_default ${PATHS_LIST}
161 set_default slib_cc slib_ld
162 set_default slib_install file_install ln_s
164 show_help(){
165 cat <<EOF
166 Usage: make [options] [operations]
168 Operations: [default is to build the shared library]:
169 clean clean build products
170 install install build products
173 Options: [defaults in brackets after descriptions]
175 Help options:
176 --help print this message
179 Standard options:
180 --prefix=PREFIX install in PREFIX [$prefix_default]
181 --libdir=DIR install libs in DIR [PREFIX/lib]
182 --incdir=DIR install includes in DIR [PREFIX/include]
184 Advanced options (experts only):
185 --sysroot=PATH root of cross-build tree
186 --destdir=PATH installation root dir override
187 --slib-cc=CC use C compiler command line CC for shared lib object[$slib_cc_default]
188 --slib-ld=LD use linker command line LD for shared lib [$slib_ld_default]
190 exit 0
193 for opt do
194 optval="${opt#*=}"
195 case "$opt" in
196 clean) clean_do
198 install) install_do
200 --help|-h) show_help
203 optname="${opt%%=*}"
204 optname="${optname#--}"
205 optname=$(echo "$optname" | sed 's/-/_/g')
206 if is_in $optname $CMDLINE_SET; then
207 eval $optname='$optval'
208 elif is_in $optname $CMDLINE_APPEND; then
209 append $optname "$optval"
210 else
211 die_unknown $opt
214 esac
215 done
217 #for pkgconfig to pickup the right package files
218 export PKG_CONFIG_SYSROOT_DIR=${sysroot}
220 #CPPFLAGS=-I./ -I${source_path} -DHAVE_OT -DHAVE_GLIB
221 CPPFLAGS="-I./ -I${source_path} -DHAVE_GLIB \
222 $(pkg-config --cflags freetype2) \
223 $(pkg-config --cflags glib-2.0)
226 #generate the version header file
227 sed -e "
228 s/@HB_VERSION_MAJOR@/${major})/
229 s/@HB_VERSION_MINOR@/${minor}/
230 s/@HB_VERSION_MICRO@/${micro}/
231 s/@HB_VERSION@/${major}.${minor}.${micro}/
232 " ${source_path}/hb-version.h.in >hb-version.h
234 #generate the pkgconfig file
235 sed -e "
236 s:%prefix%:${prefix}:
237 s:%exec_prefix%:${prefix}:
238 s:%libdir%:${libdir}:
239 s:%includedir%:${incdir}:
240 s:%VERSION%:${major}.${minor}.${micro}:
241 " ${source_path}/harfbuzz.pc.in >harfbuzz.pc
243 #compile source files, build a list of objet files
244 for src_file in ${srcs}
246 obj=${src_file/\.c/.o}
247 echo "SLIB_CC ${src_file}"
248 ${slib_cc} ${CPPFLAGS} -o ${obj} ${source_path}/${src_file}
249 objs="${obj} ${objs}"
250 done
252 #link the shared lib
253 echo "SLIB_LD ${slib_file_name}"
254 echo ${objs}
255 ${slib_ld} -o ${slib_file_name} ${objs}