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