]> git.proxmox.com Git - ceph.git/blame - ceph/src/jaegertracing/thrift/contrib/fb303/acinclude.m4
buildsys: switch source download to quincy
[ceph.git] / ceph / src / jaegertracing / thrift / contrib / fb303 / acinclude.m4
CommitLineData
f67539c2
TL
1dnl Copyright (C) 2009 Facebook
2dnl Copying and distribution of this file, with or without modification,
3dnl are permitted in any medium without royalty provided the copyright
4dnl notice and this notice are preserved.
5
6AC_DEFUN([FB_INITIALIZE],
7[
8AM_INIT_AUTOMAKE([ foreign 1.9.5 no-define ])
9if test "x$1" = "xlocalinstall"; then
10wdir=`pwd`
11# To use $wdir undef quote.
12#
13##########
14AC_PREFIX_DEFAULT([`pwd`/install])
15echo
16fi
17AC_PROG_CC
18AC_PROG_CXX
19AC_PROG_RANLIB(RANLIB, ranlib)
20AC_PATH_PROGS(BASH, bash)
21AC_PATH_PROGS(PERL, perl)
22AC_PATH_PROGS(PYTHON, python)
23AC_PATH_PROGS(AR, ar)
24AC_PATH_PROGS(ANT, ant)
25PRODUCT_MK=""
26])
27
28AC_DEFUN([FB_WITH_EXTERNAL_PATH],
29[
30cdir=`pwd`
31AC_MSG_CHECKING([Checking EXTERNAL_PATH set to])
32AC_ARG_WITH([externalpath],
33 [ --with-externalpath=DIR User specified path to external facebook components.],
34 [
35 if test "x${EXTERNAL_PATH}" != "x"; then
36 echo ""
37 echo "ERROR: You have already set EXTERNAL_PATH in your environment"
38 echo "Cannot override it using --with-externalpath. Unset EXTERNAL_PATH to use this option"
39 exit 1
40 fi
41 EXTERNAL_PATH=$withval
42 ],
43 [
44 if test "x${EXTERNAL_PATH}" = "x"; then
45 EXTERNAL_PATH=$1
46 fi
47 ]
48)
49if test "x${EXTERNAL_PATH}" = "x"; then
50 export EXTERNAL_PATH="$cdir/external"
51 GLOBAL_HEADER_MK="include ${EXTERNAL_PATH}/global_header.mk"
52 GLOBAL_FOOTER_MK="include ${EXTERNAL_PATH}/global_footer.mk"
53else
54 export EXTERNAL_PATH
55 GLOBAL_HEADER_MK="include ${EXTERNAL_PATH}/global_header.mk"
56 GLOBAL_FOOTER_MK="include ${EXTERNAL_PATH}/global_footer.mk"
57fi
58AC_MSG_RESULT($EXTERNAL_PATH)
59if test ! -d ${EXTERNAL_PATH}; then
60 echo ""
61 echo "ERROR: EXTERNAL_PATH set to an nonexistent directory ${EXTERNAL_PATH}"
62 exit 1
63fi
64AC_SUBST(EXTERNAL_PATH)
65AC_SUBST(GLOBAL_HEADER_MK)
66AC_SUBST(GLOBAL_FOOTER_MK)
67])
68
69# Set option to enable shared mode. Set DEBUG and OPT for use in Makefile.am.
70AC_DEFUN([FB_ENABLE_DEFAULT_OPT_BUILD],
71[
72AC_MSG_CHECKING([whether to enable optimized build])
73AC_ARG_ENABLE([opt],
74 [ --disable-opt Set up debug mode.],
75 [
76 ENABLED_OPT=$enableval
77 ],
78 [
79 ENABLED_OPT="yes"
80 ]
81)
82if test "$ENABLED_OPT" = "yes"
83then
84 CFLAGS="-Wall -O3"
85 CXXFLAGS="-Wall -O3"
86else
87 CFLAGS="-Wall -g"
88 CXXFLAGS="-Wall -g"
89fi
90AC_MSG_RESULT($ENABLED_OPT)
91AM_CONDITIONAL([OPT], [test "$ENABLED_OPT" = yes])
92AM_CONDITIONAL([DEBUG], [test "$ENABLED_OPT" = no])
93])
94
95# Set option to enable debug mode. Set DEBUG and OPT for use in Makefile.am.
96AC_DEFUN([FB_ENABLE_DEFAULT_DEBUG_BUILD],
97[
98AC_MSG_CHECKING([whether to enable debug build])
99AC_ARG_ENABLE([debug],
100 [ --disable-debug Set up opt mode.],
101 [
102 ENABLED_DEBUG=$enableval
103 ],
104 [
105 ENABLED_DEBUG="yes"
106 ]
107)
108if test "$ENABLED_DEBUG" = "yes"
109then
110 CFLAGS="-Wall -g"
111 CXXFLAGS="-Wall -g"
112else
113 CFLAGS="-Wall -O3"
114 CXXFLAGS="-Wall -O3"
115fi
116AC_MSG_RESULT($ENABLED_DEBUG)
117AM_CONDITIONAL([DEBUG], [test "$ENABLED_DEBUG" = yes])
118AM_CONDITIONAL([OPT], [test "$ENABLED_DEBUG" = no])
119])
120
121# Set option to enable static libs.
122AC_DEFUN([FB_ENABLE_DEFAULT_STATIC],
123[
124SHARED=""
125STATIC=""
126AC_MSG_CHECKING([whether to enable static mode])
127AC_ARG_ENABLE([static],
128 [ --disable-static Set up shared mode.],
129 [
130 ENABLED_STATIC=$enableval
131 ],
132 [
133 ENABLED_STATIC="yes"
134 ]
135)
136if test "$ENABLED_STATIC" = "yes"
137then
138 LTYPE=".a"
139else
140 LTYPE=".so"
141 SHARED_CXXFLAGS="-fPIC"
142 SHARED_CFLAGS="-fPIC"
143 SHARED_LDFLAGS="-shared -fPIC"
144 AC_SUBST(SHARED_CXXFLAGS)
145 AC_SUBST(SHARED_CFLAGS)
146 AC_SUBST(SHARED_LDFLAGS)
147fi
148AC_MSG_RESULT($ENABLED_STATIC)
149AC_SUBST(LTYPE)
150AM_CONDITIONAL([STATIC], [test "$ENABLED_STATIC" = yes])
151AM_CONDITIONAL([SHARED], [test "$ENABLED_STATIC" = no])
152])
153
154# Set option to enable shared libs.
155AC_DEFUN([FB_ENABLE_DEFAULT_SHARED],
156[
157SHARED=""
158STATIC=""
159AC_MSG_CHECKING([whether to enable shared mode])
160AC_ARG_ENABLE([shared],
161 [ --disable-shared Set up static mode.],
162 [
163 ENABLED_SHARED=$enableval
164 ],
165 [
166 ENABLED_SHARED="yes"
167 ]
168)
169if test "$ENABLED_SHARED" = "yes"
170then
171 LTYPE=".so"
172 SHARED_CXXFLAGS="-fPIC"
173 SHARED_CFLAGS="-fPIC"
174 SHARED_LDFLAGS="-shared -fPIC"
175 AC_SUBST(SHARED_CXXFLAGS)
176 AC_SUBST(SHARED_CFLAGS)
177 AC_SUBST(SHARED_LDFLAGS)
178else
179 LTYPE=".a"
180fi
181AC_MSG_RESULT($ENABLED_SHARED)
182AC_SUBST(LTYPE)
183AM_CONDITIONAL([SHARED], [test "$ENABLED_SHARED" = yes])
184AM_CONDITIONAL([STATIC], [test "$ENABLED_SHARED" = no])
185])
186
187# Generates define flags and conditionals as specified by user.
188# This gets enabled *only* if user selects --enable-<FEATURE> otion.
189AC_DEFUN([FB_ENABLE_FEATURE],
190[
191ENABLE=""
192flag="$1"
193value="$3"
194AC_MSG_CHECKING([whether to enable $1])
195AC_ARG_ENABLE([$2],
196 [ --enable-$2 Enable $2.],
197 [
198 ENABLE=$enableval
199 ],
200 [
201 ENABLE="no"
202 ]
203)
204AM_CONDITIONAL([$1], [test "$ENABLE" = yes])
205if test "$ENABLE" = "yes"
206then
207 if test "x${value}" = "x"
208 then
209 AC_DEFINE([$1])
210 else
211 AC_DEFINE_UNQUOTED([$1], [$value])
212 fi
213fi
214AC_MSG_RESULT($ENABLE)
215])
216
217
218# can also use eval $2=$withval;AC_SUBST($2)
219AC_DEFUN([FB_WITH_PATH],
220[
221USRFLAG=""
222USRFLAG=$1
223AC_MSG_CHECKING([Checking $1 set to])
224AC_ARG_WITH([$2],
225 [ --with-$2=DIR User specified path.],
226 [
227 LOC=$withval
228 eval $USRFLAG=$withval
229 ],
230 [
231 LOC=$3
232 eval $USRFLAG=$3
233 ]
234)
235AC_SUBST([$1])
236AC_MSG_RESULT($LOC)
237])
238
239AC_DEFUN([FB_SET_FLAG_VALUE],
240[
241SETFLAG=""
242AC_MSG_CHECKING([Checking $1 set to])
243SETFLAG=$1
244eval $SETFLAG=\"$2\"
245AC_SUBST([$SETFLAG])
246AC_MSG_RESULT($2)
247])
248
249# NOTES
250# if using if else bourne stmt you must have more than a macro in it.
251# EX1 is not correct. EX2 is correct
252# EX1: if test "$XX" = "yes"; then
253# AC_SUBST(xx)
254# fi
255# EX2: if test "$XX" = "yes"; then
256# xx="foo"
257# AC_SUBST(xx)
258# fi