1 dnl Copyright (C) 2009 Facebook
2 dnl Copying and distribution of this file, with or without modification,
3 dnl are permitted in any medium without royalty provided the copyright
4 dnl notice and this notice are preserved.
6 AC_DEFUN([FB_INITIALIZE],
8 AM_INIT_AUTOMAKE([ foreign 1.9.5 no-define ])
9 if test "x$1" = "xlocalinstall"; then
11 # To use $wdir undef quote.
14 AC_PREFIX_DEFAULT([`pwd`/install])
19 AC_PROG_RANLIB(RANLIB, ranlib)
20 AC_PATH_PROGS(BASH, bash)
21 AC_PATH_PROGS(PERL, perl)
22 AC_PATH_PROGS(PYTHON, python)
24 AC_PATH_PROGS(ANT, ant)
28 AC_DEFUN([FB_WITH_EXTERNAL_PATH],
31 AC_MSG_CHECKING([Checking EXTERNAL_PATH set to])
32 AC_ARG_WITH([externalpath],
33 [ --with-externalpath=DIR User specified path to external facebook components.],
35 if test "x${EXTERNAL_PATH}" != "x"; then
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"
41 EXTERNAL_PATH=$withval
44 if test "x${EXTERNAL_PATH}" = "x"; then
49 if 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"
55 GLOBAL_HEADER_MK="include ${EXTERNAL_PATH}/global_header.mk"
56 GLOBAL_FOOTER_MK="include ${EXTERNAL_PATH}/global_footer.mk"
58 AC_MSG_RESULT($EXTERNAL_PATH)
59 if test ! -d ${EXTERNAL_PATH}; then
61 echo "ERROR: EXTERNAL_PATH set to an nonexistent directory ${EXTERNAL_PATH}"
64 AC_SUBST(EXTERNAL_PATH)
65 AC_SUBST(GLOBAL_HEADER_MK)
66 AC_SUBST(GLOBAL_FOOTER_MK)
69 # Set option to enable shared mode. Set DEBUG and OPT for use in Makefile.am.
70 AC_DEFUN([FB_ENABLE_DEFAULT_OPT_BUILD],
72 AC_MSG_CHECKING([whether to enable optimized build])
74 [ --disable-opt Set up debug mode.],
76 ENABLED_OPT=$enableval
82 if test "$ENABLED_OPT" = "yes"
90 AC_MSG_RESULT($ENABLED_OPT)
91 AM_CONDITIONAL([OPT], [test "$ENABLED_OPT" = yes])
92 AM_CONDITIONAL([DEBUG], [test "$ENABLED_OPT" = no])
95 # Set option to enable debug mode. Set DEBUG and OPT for use in Makefile.am.
96 AC_DEFUN([FB_ENABLE_DEFAULT_DEBUG_BUILD],
98 AC_MSG_CHECKING([whether to enable debug build])
99 AC_ARG_ENABLE([debug],
100 [ --disable-debug Set up opt mode.],
102 ENABLED_DEBUG=$enableval
108 if test "$ENABLED_DEBUG" = "yes"
116 AC_MSG_RESULT($ENABLED_DEBUG)
117 AM_CONDITIONAL([DEBUG], [test "$ENABLED_DEBUG" = yes])
118 AM_CONDITIONAL([OPT], [test "$ENABLED_DEBUG" = no])
121 # Set option to enable static libs.
122 AC_DEFUN([FB_ENABLE_DEFAULT_STATIC],
126 AC_MSG_CHECKING([whether to enable static mode])
127 AC_ARG_ENABLE([static],
128 [ --disable-static Set up shared mode.],
130 ENABLED_STATIC=$enableval
136 if test "$ENABLED_STATIC" = "yes"
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)
148 AC_MSG_RESULT($ENABLED_STATIC)
150 AM_CONDITIONAL([STATIC], [test "$ENABLED_STATIC" = yes])
151 AM_CONDITIONAL([SHARED], [test "$ENABLED_STATIC" = no])
154 # Set option to enable shared libs.
155 AC_DEFUN([FB_ENABLE_DEFAULT_SHARED],
159 AC_MSG_CHECKING([whether to enable shared mode])
160 AC_ARG_ENABLE([shared],
161 [ --disable-shared Set up static mode.],
163 ENABLED_SHARED=$enableval
169 if test "$ENABLED_SHARED" = "yes"
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)
181 AC_MSG_RESULT($ENABLED_SHARED)
183 AM_CONDITIONAL([SHARED], [test "$ENABLED_SHARED" = yes])
184 AM_CONDITIONAL([STATIC], [test "$ENABLED_SHARED" = no])
187 # Generates define flags and conditionals as specified by user.
188 # This gets enabled *only* if user selects --enable-<FEATURE> otion.
189 AC_DEFUN([FB_ENABLE_FEATURE],
194 AC_MSG_CHECKING([whether to enable $1])
196 [ --enable-$2 Enable $2.],
204 AM_CONDITIONAL([$1], [test "$ENABLE" = yes])
205 if test "$ENABLE" = "yes"
207 if test "x${value}" = "x"
211 AC_DEFINE_UNQUOTED([$1], [$value])
214 AC_MSG_RESULT($ENABLE)
218 # can also use eval $2=$withval;AC_SUBST($2)
219 AC_DEFUN([FB_WITH_PATH],
223 AC_MSG_CHECKING([Checking $1 set to])
225 [ --with-$2=DIR User specified path.],
228 eval $USRFLAG=$withval
239 AC_DEFUN([FB_SET_FLAG_VALUE],
242 AC_MSG_CHECKING([Checking $1 set to])
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
255 # EX2: if test "$XX" = "yes"; then