1dnl Wget-specific Autoconf macros.
2dnl Copyright (C) 1995-2011, 2018-2021 Free Software Foundation, Inc.
3
4dnl This program is free software; you can redistribute it and/or modify
5dnl it under the terms of the GNU General Public License as published by
6dnl the Free Software Foundation; either version 3 of the License, or
7dnl (at your option) any later version.
8
9dnl This program is distributed in the hope that it will be useful,
10dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
11dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12dnl GNU General Public License for more details.
13
14dnl You should have received a copy of the GNU General Public License
15dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17dnl Additional permission under GNU GPL version 3 section 7
18
19dnl If you modify this program, or any covered work, by linking or
20dnl combining it with the OpenSSL project's OpenSSL library (or a
21dnl modified version of that library), containing parts covered by the
22dnl terms of the OpenSSL or SSLeay licenses, the Free Software Foundation
23dnl grants you additional permission to convey the resulting work.
24dnl Corresponding Source for a non-source form of such a combination
25dnl shall include the source code for the parts of OpenSSL used as well
26dnl as that of the covered work.
27
28dnl ************************************************************
29dnl START OF IPv6 AUTOCONFIGURATION SUPPORT MACROS
30dnl ************************************************************
31
32AC_DEFUN([TYPE_STRUCT_SOCKADDR_IN6],[
33  wget_have_sockaddr_in6=
34  AC_CHECK_TYPES([struct sockaddr_in6],[
35    wget_have_sockaddr_in6=yes
36  ],[
37    wget_have_sockaddr_in6=no
38  ],[
39#include <sys/types.h>
40#ifdef HAVE_SYS_SOCKET_H
41#include <sys/socket.h>
42#endif
43#ifdef HAVE_NETINET_IN_H
44#include <netinet/in.h>
45#endif
46#ifdef HAVE_WINSOCK2_H
47#include <winsock2.h>
48#endif
49#ifdef HAVE_WS2TCPIP_H
50#include <ws2tcpip.h>
51#endif
52  ])
53
54  if test "X$wget_have_sockaddr_in6" = "Xyes"; then :
55    $1
56  else :
57    $2
58  fi
59])
60
61
62AC_DEFUN([MEMBER_SIN6_SCOPE_ID],[
63  AC_REQUIRE([TYPE_STRUCT_SOCKADDR_IN6])
64
65  wget_member_sin6_scope_id=
66  if test "X$wget_have_sockaddr_in6" = "Xyes"; then
67    AC_CHECK_MEMBER([struct sockaddr_in6.sin6_scope_id],[
68      wget_member_sin6_scope_id=yes
69    ],[
70      wget_member_sin6_scope_id=no
71    ],[
72#include <sys/types.h>
73#ifdef HAVE_SYS_SOCKET_H
74#include <sys/socket.h>
75#endif
76#ifdef HAVE_NETINET_IN_H
77#include <netinet/in.h>
78#endif
79#ifdef HAVE_WINSOCK2_H
80#include <winsock2.h>
81#endif
82#ifdef HAVE_WS2TCPIP_H
83#include <ws2tcpip.h>
84#endif
85    ])
86  fi
87
88  if test "X$wget_member_sin6_scope_id" = "Xyes"; then
89    AC_DEFINE([HAVE_SOCKADDR_IN6_SCOPE_ID], 1,
90      [Define if struct sockaddr_in6 has the sin6_scope_id member])
91    $1
92  else :
93    $2
94  fi
95])
96
97
98AC_DEFUN([PROTO_INET6],[
99  AC_CACHE_CHECK([for INET6 protocol support], [wget_cv_proto_inet6],[
100    AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
101#include <sys/types.h>
102#ifdef HAVE_SYS_SOCKET_H
103#include <sys/socket.h>
104#endif
105#ifdef HAVE_NETINET_IN_H
106#include <netinet/in.h>
107#endif
108#ifdef HAVE_WINSOCK2_H
109#include <winsock2.h>
110#endif
111#ifdef HAVE_WS2TCPIP_H
112#include <ws2tcpip.h>
113#endif
114#ifndef PF_INET6
115#error Missing PF_INET6
116#endif
117#ifndef AF_INET6
118#error Missing AF_INET6
119#endif
120    ]])],[
121      wget_cv_proto_inet6=yes
122    ],[
123      wget_cv_proto_inet6=no
124    ])
125  ])
126
127  if test "X$wget_cv_proto_inet6" = "Xyes"; then :
128    $1
129  else :
130    $2
131  fi
132])
133
134
135AC_DEFUN([WGET_STRUCT_SOCKADDR_STORAGE],[
136  AC_CHECK_TYPES([struct sockaddr_storage],[], [], [
137#include <sys/types.h>
138#ifdef HAVE_SYS_SOCKET_H
139#include <sys/socket.h>
140#endif
141#ifdef HAVE_WINSOCK2_H
142#include <winsock2.h>
143#endif
144])
145])
146
147dnl ************************************************************
148dnl END OF IPv6 AUTOCONFIGURATION SUPPORT MACROS
149dnl ************************************************************
150
151dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
152dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
153AC_DEFUN([AM_PATH_PROG_WITH_TEST],
154[# Extract the first word of "$2", so it can be a program name with args.
155set dummy $2; ac_word=[$]2
156AC_MSG_CHECKING([for $ac_word])
157AC_CACHE_VAL(ac_cv_path_$1,
158[case "[$]$1" in
159  /*)
160  ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
161  ;;
162  *)
163  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:"
164  for ac_dir in ifelse([$5], , $PATH, [$5]); do
165    test -z "$ac_dir" && ac_dir=.
166    if test -f $ac_dir/$ac_word; then
167      if [$3]; then
168	ac_cv_path_$1="$ac_dir/$ac_word"
169	break
170      fi
171    fi
172  done
173  IFS="$ac_save_ifs"
174dnl If no 4th arg is given, leave the cache variable unset,
175dnl so AC_PATH_PROGS will keep looking.
176ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
177])dnl
178  ;;
179esac])dnl
180$1="$ac_cv_path_$1"
181if test -n "[$]$1"; then
182  AC_MSG_RESULT([$]$1)
183else
184  AC_MSG_RESULT(no)
185fi
186AC_SUBST($1)dnl
187])
188
189