1dnl Aircrack-ng
2dnl
3dnl Copyright (C) 2017 Joseph Benden <joe@benden.us>
4dnl
5dnl Autotool support was written by: Joseph Benden <joe@benden.us>
6dnl
7dnl This program is free software; you can redistribute it and/or modify
8dnl it under the terms of the GNU General Public License as published by
9dnl the Free Software Foundation; either version 2 of the License, or
10dnl (at your option) any later version.
11dnl
12dnl This program is distributed in the hope that it will be useful,
13dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
14dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15dnl GNU General Public License for more details.
16dnl
17dnl You should have received a copy of the GNU General Public License
18dnl along with this program; if not, write to the Free Software
19dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20dnl
21dnl In addition, as a special exception, the copyright holders give
22dnl permission to link the code of portions of this program with the
23dnl OpenSSL library under certain conditions as described in each
24dnl individual source file, and distribute linked combinations
25dnl including the two.
26dnl
27dnl You must obey the GNU General Public License in all respects
28dnl for all of the code used other than OpenSSL.
29dnl
30dnl If you modify file(s) with this exception, you may extend this
31dnl exception to your dnl version of the file(s), but you are not obligated
32dnl to do so.
33dnl
34dnl If you dnl do not wish to do so, delete this exception statement from your
35dnl version.
36dnl
37dnl If you delete this exception statement from all source files in the
38dnl program, then also delete it here.
39
40AC_DEFUN([AIRCRACK_NG_MAC],[
41AX_REQUIRE_DEFINED([AC_CHECK_HEADER])[]dnl
42AX_REQUIRE_DEFINED([AC_CHECK_FILE])[]dnl
43
44AC_ARG_WITH(xcode,
45    [AS_HELP_STRING([--with-xcode], [enable XCode support])])
46
47case "$host_os" in
48    DARWIN*|MACOS*|darwin*|macos*)
49    	dnl
50        dnl Homebrew
51        dnl
52		AC_ARG_VAR([BREW],[Use this brew for macOS dependencies.])
53		dnl Allow env override but do not be fooled by 'BREW=t'.
54		test t = "$BREW" && unset BREW
55		AC_CHECK_PROG([BREW], [brew], [$as_dir/$ac_word$ac_exec_ext], [], [$BREW_PATH$PATH_SEPARATOR$PATH$PATH_SEPARATOR/bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR/usr/local/bin])
56		AS_IF([test "x$BREW" = "x"],[
57			AC_MSG_WARN([Homebrew not found])
58			BREW_FOUND=no
59		], [
60			BREW_FOUND=yes
61		])
62
63		if test "x$BREW_FOUND" = xyes; then
64			CFLAGS="$CFLAGS -I$(brew --prefix openssl)/include"
65			CXXFLAGS="$CXXFLAGS -I$(brew --prefix openssl)/include"
66			CPPFLAGS="$CPPFLAGS -I$(brew --prefix openssl)/include"
67			LDFLAGS="$LDFLAGS -L$(brew --prefix openssl)/lib"
68		fi
69
70        AC_CHECK_FILE(/usr/local/Homebrew, [ CPPFLAGS="$CPPFLAGS -I/usr/local/include" ])
71
72        dnl MacPorts
73        AC_CHECK_FILE(/opt/local/include, [
74            CPPFLAGS="$CPPFLAGS -I/opt/local/include -I../.."
75            OSX_ALT_FLAGS=true
76            AC_CHECK_FILE(/opt/local/lib, [
77                LDFLAGS="$LDFLAGS -L/opt/local/lib"
78            ], [
79                AC_MSG_ERROR([MacPorts installation seems broken, have includes but no libs.])
80            ])
81        ])
82
83        dnl XCode
84        case $with_xcode in
85            yes | "")
86                AC_CHECK_FILE(/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-migrator/sdk/MacOSX.sdk/usr/include, [
87                    CPPFLAGS="$CPPFLAGS -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-migrator/sdk/MacOSX.sdk/usr/include/ -D_XCODE -I../.."
88                    OSX_ALT_FLAGS=true
89                ])
90                ;;
91        esac
92        ;;
93esac
94])
95