]> git.pld-linux.org Git - packages/icu.git/blob - icu-config
- updated to 4.4.1 (note: sonames changed)
[packages/icu.git] / icu-config
1 #!/bin/sh
2 ## -*-sh-*-
3 #set -x
4 # BEGIN of icu-config-top
5 #******************************************************************************
6 #   Copyright (C) 1999-2004, International Business Machines
7 #   Corporation and others.  All Rights Reserved.
8 #******************************************************************************
9 # This script is designed to aid configuration of ICU.
10 # rpath links a library search path right into the binaries.
11
12
13 ### END of icu-config-top
14
15 ## Zero out prefix.
16 exec_prefix=`pkg-config --variable=exec_prefix icu`
17 execprefix=$exec_prefix
18 prefix=`pkg-config --variable=prefix icu`
19
20
21 loaddefs()
22 {
23 LDLIBRARYPATH_ENVVAR="LD_LIBRARY_PATH"
24 bindir=`pkg-config --variable=bindir icu`
25 sbindir=`pkg-config --variable=sbindir icu`
26 libdir=`pkg-config --variable=libdir icu`
27 sysconfdir=`pkg-config --variable=sysconfdir icu`
28 mandir=`pkg-config --variable=mandir icu`
29 datadir=`pkg-config --variable=datadir icu`
30 pkglibdir=`pkg-config --variable=pkglibdir icu`
31 ICULIBS_COMMON_LIB_NAME=`pkg-config --variable=ICULIBS_COMMON_LIB_NAME icu`
32 UNICODE_VERSION=`pkg-config --variable=UNICODE_VERSION icu`
33 VERSION=`pkg-config --modversion icu`
34 SO=`pkg-config --variable=SO icu`
35
36 ## -*-sh-*-
37 ## BEGIN of icu-config-bottom.
38 ## Copyright (c) 2002-2004, International Business Machines Corporation and
39 ## others. All Rights Reserved.
40
41 ICUUC_FILE=${libdir}/${ICULIBS_COMMON_LIB_NAME}
42     
43 #  echo ENABLE RPATH $ENABLE_RPATH and RPATHLDFLAGS=${RPATH_LDFLAGS}
44 if [ "x$PKGDATA_MODE" = "x" ]; then
45     PKGDATA_MODE=dll
46 fi
47
48 }
49
50 ## The actual code of icu-config goes here.
51
52 ME=`basename $0`
53
54 allflags()
55 {
56     echo "  --bindir               Print binary directory path (bin)"
57     echo "  --cc                   Print C compiler used [CC]"
58     echo "  --cflags               Print C compiler flags [CFLAGS]"
59     echo "  --cflags-dynamic       Print additional C flags for"
60     echo "                             building shared libraries."
61     echo "  --cppflags             Print C Preprocessor flags [CPPFLAGS]"
62     echo "  --cppflags-dynamic     Print additional C Preprocessor flags for"
63     echo "                             building shared libraries."
64     echo "  --cppflags-searchpath  Print only -I include directives  (-Iinclude)"
65     echo "  --cxx                  Print C++ compiler used [CXX]"
66     echo "  --cxxflags             Print C++ compiler flags [CXXFLAGS]"
67     echo "  --cxxflags-dynamic     Print additional C++ flags for"
68     echo "                             building shared libraries."
69     echo "  --detect-prefix        Attempt to detect prefix based on PATH"
70     echo "  --exec-prefix          Print prefix for executables (/bin)"
71     echo "  --exists               Return with 0 status if ICU exists else fail"
72     echo "  --help, -?, --usage    Print this message"
73     echo "  --icudata              Print shortname of ICU data file (icudt21l)"
74     echo "  --icudata-install-dir  Print path to install data to - use as --install option to pkgdata(1)"
75     echo "  --icudata-mode         Print default ICU pkgdata mode (dll) - use as --mode option to pkgdata(1)."
76     echo "  --icudatadir           Print path to packaged archive data. Can set as [ICU_DATA]"
77     echo "  --invoke               Print commands to invoke an ICU program"
78     echo "  --invoke=<prog>        Print commands to invoke an ICU program named <prog> (ex: genrb)" 
79     echo "  --ldflags              Print -L search path and -l libraries to link with ICU [LDFLAGS].  This is for the data, uc (common), and i18n libraries only.  "
80     echo "  --ldflags-layout       Print ICU layout engine link directive. Use in addition to --ldflags"
81     echo "  --ldflags-libsonly     Same as --ldflags, but only the -l directives"
82     echo "  --ldflags-searchpath   Print only -L (search path) directive"
83     echo "  --ldflags-system       Print only system libs ICU links with (-lpthread, -lm)"
84     echo "  --ldflags-icuio        Print ICU icuio link directive. Use in addition to --ldflags "
85     echo "  --ldflags-obsolete     Print ICU obsolete link directive. Use in addition to --ldflags. (requires icuapps/obsolete to be built and installed.) "
86     echo "  --mandir               Print manpage (man) path"
87     echo "  --prefix               Print PREFIX to icu install (/usr/local)"
88     echo "  --prefix=XXX           Set prefix to XXX for remainder of command"
89     echo "  --sbindir              Print system binary path (sbin) "
90     echo "  --shared-datadir       Print shared data (share) path. This is NOT the ICU data dir."
91     echo "  --shlib-c              Print the command to compile and build C shared libraries with ICU"
92     echo "  --shlib-cc             Print the command to compile and build C++ shared libraries with ICU"
93     echo "  --sysconfdir           Print system config (etc) path"
94     echo "  --unicode-version      Print version of Unicode data used in ICU ($UNICODE_VERSION)"
95     echo "  --version              Print ICU version ($VERSION)"
96     echo "  --incfile              Print path to Makefile.inc (for -O option of pkgdata)"
97         echo "  --incpkgdatafile       Print path to pkgdata.inc (for -O option of pkgdata)"
98 }
99
100 ## Print the normal usage message
101 shortusage()
102 {
103     echo "usage: ${ME} " `allflags | cut -c-25 | sed -e 's%.*%[ & ]%'`
104 }
105
106
107 usage()
108 {
109     echo "${ME}: icu-config: ICU configuration helper script"
110     echo
111     echo "The most commonly used options will be --cflags, --cxxflags, --cppflags, and --ldflags."
112     echo 'Example (in make):   CPFLAGS=$(shell icu-config --cppflags)'
113     echo '                     LDFLAGS=$(shell icu-config --ldflags)'
114     echo "                     (etc).."
115     echo
116     echo "Usage:"
117     allflags
118
119     echo 
120     echo " [Brackets] show MAKE variable equivalents,  (parenthesis) show example output"
121     echo
122     echo "Copyright (c) 2002, International Business Machines Corporation and others. All Rights Reserved."
123 }
124
125 ## Check the sanity of current variables
126 sanity()
127 {
128     if [ ! -f ${ICUUC_FILE} ];
129     then
130         echo "### $ME: Can't find ${ICUUC_FILE} - ICU prefix is wrong."  1>&2
131         echo "###      Try the --prefix= or --exec-prefix= options " 1>&2
132         echo "###      or --detect-prefix"
133         echo "### $ME: Exitting." 1>&2
134         exit 2
135     fi
136 }
137
138 ## Main starts here.
139
140 if [ $# -lt 1 ]; then
141     shortusage
142     exit 1
143 fi
144
145
146 # Load our variables from autoconf
147 # ALWAYS load twice because of dependencies
148 loaddefs
149 loaddefs
150 sanity
151
152 while [ $# -gt 0 ];
153 do
154     arg="$1"
155     var=`echo $arg | sed -e 's/^[^=]*=//'`
156 #    echo "### processing $arg" 1>&2
157     case "$arg" in
158
159         # undocumented.
160         --debug)
161             set -x
162             ;;
163
164         --so)
165             echo $SO
166             ;;
167
168         --bindir)
169             echo $bindir
170             ;;
171
172         --libdir)
173             echo $libdir
174             ;;
175
176         --exists)
177             sanity
178             ;;
179
180         --sbindir)
181             echo $sbindir
182             ;;
183
184         --invoke=*)
185             QUOT="'"
186             CMD="${var}"
187
188             # If it's not a locally executable command (1st choice) then 
189             # search for it in the ICU directories. 
190             if [ ! -x ${CMD} ]; then
191                 if [ -x ${bindir}/${var} ]; then
192                     CMD="${bindir}/${var}"
193                 fi
194                 if [ -x ${sbindir}/${var} ]; then
195                     CMD="${sbindir}/${var}"
196                 fi
197             fi
198
199             echo "env ${QUOT}${LDLIBRARYPATH_ENVVAR}=${libdir}:"'${'"${LDLIBRARYPATH_ENVVAR}"'}'${QUOT} ${CMD}
200             ;;
201
202         --invoke)
203             QUOT="'"
204             echo "env ${QUOT}${LDLIBRARYPATH_ENVVAR}=${libdir}:"'${'"${LDLIBRARYPATH_ENVVAR}"'}'${QUOT}
205             ;;
206
207         --cflags)
208             pkg-config --variable=CFLAGS icu
209             ;;
210             
211         --cc)
212             echo cc
213             ;;
214             
215         --cxx)
216             echo c++
217             ;;
218
219         --cxxflags)
220             pkg-config --variable=CXXFLAGS icu
221             ;;
222
223         --cppflags)
224             # Don't echo the -I. - it's unneeded.
225             CPPFLAGS=`pkg-config --variable=CPPFLAGS icu`
226             echo $CPPFLAGS | sed -e 's/-I. //'
227             ;;
228
229         --cppflags-searchpath)
230             echo -I${prefix}/include
231             ;;
232
233         --cppflags-dynamic)
234             pkg-config --variable=SHAREDLIBCPPFLAGS icu
235             ;;
236
237         --cxxflags-dynamic)
238             pkg-config --variable=SHAREDLIBCXXFLAGS icu
239             ;;
240
241         --cflags-dynamic)
242             pkg-config --variable=SHAREDLIBCFLAGS icu
243             ;;
244
245         --ldflags-system)
246             pkg-config --variable=ICULIBS_SYSTEMLIBS icu
247             ;;
248
249         --ldflags)
250             pkg-config --libs icu
251 # $RPATH_LDFLAGS
252             ;;
253
254         --ldflags-libsonly)
255             pkg-config --variable=ICULIBS_LIBSONLY icu
256             ;;
257
258         --ldflags-icuio)
259             pkg-config --variable=ICULIBS_ICUIO icu
260             ;;
261
262         --ldflags-obsolete)
263             pkg-config --variable=ICULIBS_OBSOLETE icu
264             ;;
265
266         --ldflags-toolutil)
267             pkg-config --variable=ICULIBS_TOOLUTIL icu
268             ;;
269
270         --ldflags-layout)
271             pkg-config --variable=ICULIBS_LAYOUT icu
272             ;;
273
274         --ldflags-searchpath)
275             echo -L${libdir}
276             ;;
277
278         --detect-prefix)
279             HERE=`echo $0 | sed -e "s/$ME//g"`
280             if [ -f $HERE/../lib/${ICULIBS_COMMON_LIB_NAME} ]; then
281                 prefix=$HERE/..
282                 echo "## Using --prefix=${prefix}" 1>&2
283             fi
284             loaddefs
285             loaddefs
286             sanity
287             ;;
288
289         --exec-prefix)
290             echo $exec_prefix
291             ;;
292
293         --prefix)
294             echo $prefix
295             ;;
296
297         --prefix=*)
298             prefix=$var
299             loaddefs
300             loaddefs
301             sanity
302             ;;
303
304         --sysconfdir)
305             echo $sysconfdir
306             ;;
307
308         --mandir)
309             echo $mandir
310             ;;
311
312         --shared-datadir)
313             echo $datadir
314             ;;
315
316         --incfile)
317             echo $pkglibdir/Makefile.inc
318             ;;
319
320         --incpkgdatafile)
321                 echo $pkglibdir/pkgdata.inc
322                 ;;
323
324         --icudata)
325             pkg-config --variable=ICUDATA_NAME icu
326             ;;
327
328         --icudata-mode)
329             echo $PKGDATA_MODE
330             ;;
331
332         --icudata-install-dir)
333             pkg-config --variable=ICUPKGDATA_DIR icu
334             ;;
335             
336         --icudatadir)
337             pkg-config --variable=ICUDATA_DIR icu
338             ;;
339
340         --shlib-c)
341             pkg-config --variable=SHLIB_c icu
342             ;;
343
344         --shlib-cc)
345             pkg-config --variable=SHLIB_cc icu
346             ;;
347
348         --version)
349             echo $VERSION
350             ;;
351
352         --unicode-version)
353             echo $UNICODE_VERSION
354             ;;
355
356         --help)
357             usage
358             exit 0
359             ;;
360
361         --usage)
362             usage
363             exit 0
364             ;;
365
366 #       --enable-rpath=*)
367 #           ENABLE_RPATH=$var
368 #           loaddefs
369 #           ;;
370
371         -?)
372             usage
373             exit 0
374             ;;
375
376         *)
377             echo ${ME}: ERROR Unknown Option $arg 1>&2
378             echo 1>&2
379             shortusage 1>&2
380             echo "### $ME: Exitting." 1>&2
381             exit 1;
382             ;;
383     esac
384     shift
385 done
386
387 # Check once before we quit (will check last used prefix)
388 sanity
389 ## END of icu-config-bottom
390
391 exit 0
392
This page took 0.060795 seconds and 3 git commands to generate.