Skip to content

Commit af2a05d

Browse files
committed
Add new autoconf macro for adding brew directories to flags
1 parent 5b7c440 commit af2a05d

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

M2/configure.ac

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,25 @@ AC_SUBST(SIZEOF_INT_P,$ac_cv_sizeof_int_p)
352352
AC_CHECK_SIZEOF([long])
353353
AC_SUBST(SIZEOF_LONG,$ac_cv_sizeof_long)
354354

355+
dnl Check for Homebrew packages
356+
357+
AC_CHECK_PROGS([BREW], [brew], [false])
358+
359+
dnl BREW_ADD_FLAG([FORMULA], [DIR], [FLAG], [PREFIX])
360+
dnl adds PREFIX$(brew --prefix FORMULA)/DIR (if it exists) to FLAG
361+
AC_DEFUN([BREW_ADD_FLAG],
362+
[AS_IF([test "x$BREW" = xbrew -a -d $($BREW --prefix $1)/$2],
363+
[$3="$$3 $4$($BREW --prefix $1)/$2"])])
364+
365+
dnl BREW_ADD_FLAGS([FORMULA])
366+
dnl adds -L$(brew --prefix FORMULA)/lib to LDFLAGS and
367+
dnl -I$(brew --prefix FORMULA)/include to CPPFLAGS
368+
AC_DEFUN([BREW_ADD_FLAGS],
369+
[BREW_ADD_FLAG([$1], [lib], [LDFLAGS], [-L])
370+
BREW_ADD_FLAG([$1], [include], [CPPFLAGS], [-I])])
371+
372+
BREW_ADD_FLAGS
373+
355374
AC_CHECK_HEADERS(sys/ioctl.h termios.h sys/mman.h sys/socket.h netdb.h netinet/in.h arpa/inet.h sys/time.h time.h sys/wait.h sys/resource.h io.h linux/personality.h stddef.h elf.h execinfo.h syscall.h math.h pthread.h assert.h alloca.h malloc.h dlfcn.h)
356375
AC_CHECK_HEADERS(winsock2.h) dnl used with ws2_32.dll under mingw64
357376
dnl winsock2.h should be included before including windows.h
@@ -577,6 +596,7 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([
577596
dnl Check for openmp and fail if it cannot be found.
578597
dnl This is required for building the library csdp and good for building the library normaliz
579598
AC_LANG(C++)
599+
BREW_ADD_FLAGS([libomp]) # keg-only
580600
AC_OPENMP
581601
if test "$ac_cv_prog_cxx_openmp" = unsupported
582602
then AC_MSG_ERROR([OpenMP does not work, use a compiler that supports OpenMP])
@@ -1238,7 +1258,8 @@ fi
12381258
AC_LANG(C)
12391259
AC_SEARCH_LIBS(tgoto,curses tinfo ncurses,,AC_MSG_ERROR([[not found: library containing symbol tgoto; tried libcurses, libncurses, and libtinfo)]]))
12401260
if test $BUILD_readline = no
1241-
then AC_CHECK_HEADER(readline/readline.h,,BUILD_readline=yes)
1261+
then BREW_ADD_FLAGS([readline]) # keg-only
1262+
AC_CHECK_HEADER(readline/readline.h,,BUILD_readline=yes)
12421263
fi
12431264
if test $BUILD_readline = no
12441265
then AC_SEARCH_LIBS(rl_set_prompt,readline,,BUILD_readline=yes)

0 commit comments

Comments
 (0)