summaryrefslogtreecommitdiff
path: root/source4/heimdal/cf
diff options
context:
space:
mode:
Diffstat (limited to 'source4/heimdal/cf')
-rw-r--r--source4/heimdal/cf/check-var.m427
-rw-r--r--source4/heimdal/cf/find-func-no-libs.m49
-rw-r--r--source4/heimdal/cf/find-func-no-libs2.m463
-rw-r--r--source4/heimdal/cf/find-func.m49
-rw-r--r--source4/heimdal/cf/make-proto.pl351
-rw-r--r--source4/heimdal/cf/resolv.m4109
6 files changed, 568 insertions, 0 deletions
diff --git a/source4/heimdal/cf/check-var.m4 b/source4/heimdal/cf/check-var.m4
new file mode 100644
index 0000000000..f81f3524c1
--- /dev/null
+++ b/source4/heimdal/cf/check-var.m4
@@ -0,0 +1,27 @@
+dnl $Id$
+dnl
+dnl rk_CHECK_VAR(variable, includes)
+AC_DEFUN([rk_CHECK_VAR], [
+AC_MSG_CHECKING(for $1)
+AC_CACHE_VAL(ac_cv_var_$1, [
+m4_ifval([$2],[
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[$2
+ void * foo(void) { return &$1; }]],[[foo()]])],
+ [ac_cv_var_$1=yes],[ac_cv_var_$1=no])])
+if test "$ac_cv_var_$1" != yes ; then
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern int $1;
+int foo(void) { return $1; }]],[[foo()]])],
+ [ac_cv_var_$1=yes],[ac_cv_var_$1=no])
+fi
+])
+ac_foo=`eval echo \\$ac_cv_var_$1`
+AC_MSG_RESULT($ac_foo)
+if test "$ac_foo" = yes; then
+ AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]$1), 1,
+ [Define if you have the `]$1[' variable.])
+ m4_ifval([$2], AC_CHECK_DECLS([$1],[],[],[$2]))
+fi
+])
+
+AC_WARNING_ENABLE([obsolete])
+AU_DEFUN([AC_CHECK_VAR], [rk_CHECK_VAR([$2], [$1])], [foo])
diff --git a/source4/heimdal/cf/find-func-no-libs.m4 b/source4/heimdal/cf/find-func-no-libs.m4
new file mode 100644
index 0000000000..f3413409f6
--- /dev/null
+++ b/source4/heimdal/cf/find-func-no-libs.m4
@@ -0,0 +1,9 @@
+dnl $Id$
+dnl
+dnl
+dnl Look for function in any of the specified libraries
+dnl
+
+dnl AC_FIND_FUNC_NO_LIBS(func, libraries, includes, arguments, extra libs, extra args)
+AC_DEFUN([AC_FIND_FUNC_NO_LIBS], [
+AC_FIND_FUNC_NO_LIBS2([$1], ["" $2], [$3], [$4], [$5], [$6])])
diff --git a/source4/heimdal/cf/find-func-no-libs2.m4 b/source4/heimdal/cf/find-func-no-libs2.m4
new file mode 100644
index 0000000000..692001c103
--- /dev/null
+++ b/source4/heimdal/cf/find-func-no-libs2.m4
@@ -0,0 +1,63 @@
+dnl $Id$
+dnl
+dnl
+dnl Look for function in any of the specified libraries
+dnl
+
+dnl AC_FIND_FUNC_NO_LIBS2(func, libraries, includes, arguments, extra libs, extra args)
+AC_DEFUN([AC_FIND_FUNC_NO_LIBS2], [
+
+AC_MSG_CHECKING([for $1])
+AC_CACHE_VAL(ac_cv_funclib_$1,
+[
+if eval "test \"\$ac_cv_func_$1\" != yes" ; then
+ ac_save_LIBS="$LIBS"
+ for ac_lib in $2; do
+ case "$ac_lib" in
+ "") ;;
+ yes) ac_lib="" ;;
+ no) continue ;;
+ -l*) ;;
+ *) ac_lib="-l$ac_lib" ;;
+ esac
+ LIBS="$6 $ac_lib $5 $ac_save_LIBS"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[$3]],[[$1($4)]])],[eval "if test -n \"$ac_lib\";then ac_cv_funclib_$1=$ac_lib; else ac_cv_funclib_$1=yes; fi";break])
+ done
+ eval "ac_cv_funclib_$1=\${ac_cv_funclib_$1-no}"
+ LIBS="$ac_save_LIBS"
+fi
+])
+
+eval "ac_res=\$ac_cv_funclib_$1"
+
+if false; then
+ AC_CHECK_FUNCS($1)
+dnl AC_CHECK_LIBS($2, foo)
+fi
+# $1
+eval "ac_tr_func=HAVE_[]upcase($1)"
+eval "ac_tr_lib=HAVE_LIB[]upcase($ac_res | sed -e 's/-l//')"
+eval "LIB_$1=$ac_res"
+
+case "$ac_res" in
+ yes)
+ eval "ac_cv_func_$1=yes"
+ eval "LIB_$1="
+ AC_DEFINE_UNQUOTED($ac_tr_func)
+ AC_MSG_RESULT([yes])
+ ;;
+ no)
+ eval "ac_cv_func_$1=no"
+ eval "LIB_$1="
+ AC_MSG_RESULT([no])
+ ;;
+ *)
+ eval "ac_cv_func_$1=yes"
+ eval "ac_cv_lib_`echo "$ac_res" | sed 's/-l//'`=yes"
+ AC_DEFINE_UNQUOTED($ac_tr_func)
+ AC_DEFINE_UNQUOTED($ac_tr_lib)
+ AC_MSG_RESULT([yes, in $ac_res])
+ ;;
+esac
+AC_SUBST(LIB_$1)
+])
diff --git a/source4/heimdal/cf/find-func.m4 b/source4/heimdal/cf/find-func.m4
new file mode 100644
index 0000000000..865772a700
--- /dev/null
+++ b/source4/heimdal/cf/find-func.m4
@@ -0,0 +1,9 @@
+dnl $Id$
+dnl
+dnl AC_FIND_FUNC(func, libraries, includes, arguments)
+AC_DEFUN([AC_FIND_FUNC], [
+AC_FIND_FUNC_NO_LIBS([$1], [$2], [$3], [$4])
+if test -n "$LIB_$1"; then
+ LIBS="$LIB_$1 $LIBS"
+fi
+])
diff --git a/source4/heimdal/cf/make-proto.pl b/source4/heimdal/cf/make-proto.pl
new file mode 100644
index 0000000000..b89ef79067
--- /dev/null
+++ b/source4/heimdal/cf/make-proto.pl
@@ -0,0 +1,351 @@
+# Make prototypes from .c files
+# $Id$
+
+##use Getopt::Std;
+require 'getopts.pl';
+
+my $comment = 0;
+my $if_0 = 0;
+my $brace = 0;
+my $line = "";
+my $debug = 0;
+my $oproto = 1;
+my $private_func_re = "^_";
+
+do Getopts('x:m:o:p:dqE:R:P:') || die "foo";
+
+if($opt_d) {
+ $debug = 1;
+}
+
+if($opt_q) {
+ $oproto = 0;
+}
+
+if($opt_R) {
+ $private_func_re = $opt_R;
+}
+%flags = (
+ 'multiline-proto' => 1,
+ 'header' => 1,
+ 'function-blocking' => 0,
+ 'gnuc-attribute' => 1,
+ 'cxx' => 1
+ );
+if($opt_m) {
+ foreach $i (split(/,/, $opt_m)) {
+ if($i eq "roken") {
+ $flags{"multiline-proto"} = 0;
+ $flags{"header"} = 0;
+ $flags{"function-blocking"} = 0;
+ $flags{"gnuc-attribute"} = 0;
+ $flags{"cxx"} = 0;
+ } else {
+ if(substr($i, 0, 3) eq "no-") {
+ $flags{substr($i, 3)} = 0;
+ } else {
+ $flags{$i} = 1;
+ }
+ }
+ }
+}
+
+if($opt_x) {
+ open(EXP, $opt_x);
+ while(<EXP>) {
+ chomp;
+ s/\#.*//g;
+ s/\s+/ /g;
+ if(/^([a-zA-Z0-9_]+)\s?(.*)$/) {
+ $exported{$1} = $2;
+ } else {
+ print $_, "\n";
+ }
+ }
+ close EXP;
+}
+
+while(<>) {
+ print $brace, " ", $_ if($debug);
+
+ # Handle C comments
+ s@/\*.*\*/@@;
+ s@//.*/@@;
+ if ( s@/\*.*@@) { $comment = 1;
+ } elsif ($comment && s@.*\*/@@) { $comment = 0;
+ } elsif ($comment) { next; }
+
+ if(/^\#if 0/) {
+ $if_0 = 1;
+ }
+ if($if_0 && /^\#endif/) {
+ $if_0 = 0;
+ }
+ if($if_0) { next }
+ if(/^\s*\#/) {
+ next;
+ }
+ if(/^\s*$/) {
+ $line = "";
+ next;
+ }
+ if(/\{/){
+ if (!/\}/) {
+ $brace++;
+ }
+ $_ = $line;
+ while(s/\*\//\ca/){
+ s/\/\*(.|\n)*\ca//;
+ }
+ s/^\s*//;
+ s/\s*$//;
+ s/\s+/ /g;
+ if($_ =~ /\)$/){
+ if(!/^static/ && !/^PRIVATE/){
+ if(/(.*)(__attribute__\s?\(.*\))/) {
+ $attr = $2;
+ $_ = $1;
+ } else {
+ $attr = "";
+ }
+ # remove outer ()
+ s/\s*\(/</;
+ s/\)\s?$/>/;
+ # remove , within ()
+ while(s/\(([^()]*),(.*)\)/($1\$$2)/g){}
+ s/\<\s*void\s*\>/<>/;
+ # remove parameter names
+ if($opt_P eq "remove") {
+ s/(\s*)([a-zA-Z0-9_]+)([,>])/$3/g;
+ s/\s+\*/*/g;
+ s/\(\*(\s*)([a-zA-Z0-9_]+)\)/(*)/g;
+ } elsif($opt_P eq "comment") {
+ s/([a-zA-Z0-9_]+)([,>])/\/\*$1\*\/$2/g;
+ s/\(\*([a-zA-Z0-9_]+)\)/(*\/\*$1\*\/)/g;
+ }
+ s/\<\>/<void>/;
+ # add newlines before parameters
+ if($flags{"multiline-proto"}) {
+ s/,\s*/,\n\t/g;
+ } else {
+ s/,\s*/, /g;
+ }
+ # fix removed ,
+ s/\$/,/g;
+ # match function name
+ /([a-zA-Z0-9_]+)\s*\</;
+ $f = $1;
+ if($oproto) {
+ $LP = "__P((";
+ $RP = "))";
+ } else {
+ $LP = "(";
+ $RP = ")";
+ }
+ # only add newline if more than one parameter
+ if($flags{"multiline-proto"} && /,/){
+ s/\</ $LP\n\t/;
+ }else{
+ s/\</ $LP/;
+ }
+ s/\>/$RP/;
+ # insert newline before function name
+ if($flags{"multiline-proto"}) {
+ s/(.*)\s([a-zA-Z0-9_]+ \Q$LP\E)/$1\n$2/;
+ }
+ if($attr ne "") {
+ $_ .= "\n $attr";
+ }
+ $_ = $_ . ";";
+ $funcs{$f} = $_;
+ }
+ }
+ $line = "";
+ }
+ if(/\}/){
+ $brace--;
+ }
+ if(/^\}/){
+ $brace = 0;
+ }
+ if($brace == 0) {
+ $line = $line . " " . $_;
+ }
+}
+
+sub foo {
+ local ($arg) = @_;
+ $_ = $arg;
+ s/.*\/([^\/]*)/$1/;
+ s/[^a-zA-Z0-9]/_/g;
+ "__" . $_ . "__";
+}
+
+if($opt_o) {
+ open(OUT, ">$opt_o");
+ $block = &foo($opt_o);
+} else {
+ $block = "__public_h__";
+}
+
+if($opt_p) {
+ open(PRIV, ">$opt_p");
+ $private = &foo($opt_p);
+} else {
+ $private = "__private_h__";
+}
+
+$public_h = "";
+$private_h = "";
+
+$public_h_header .= "/* This is a generated file */
+#ifndef $block
+#define $block
+
+";
+if ($oproto) {
+ $public_h_header .= "#ifdef __STDC__
+#include <stdarg.h>
+#ifndef __P
+#define __P(x) x
+#endif
+#else
+#ifndef __P
+#define __P(x) ()
+#endif
+#endif
+
+";
+} else {
+ $public_h_header .= "#include <stdarg.h>
+
+";
+}
+$public_h_trailer = "";
+
+$private_h_header = "/* This is a generated file */
+#ifndef $private
+#define $private
+
+";
+if($oproto) {
+ $private_h_header .= "#ifdef __STDC__
+#include <stdarg.h>
+#ifndef __P
+#define __P(x) x
+#endif
+#else
+#ifndef __P
+#define __P(x) ()
+#endif
+#endif
+
+";
+} else {
+ $private_h_header .= "#include <stdarg.h>
+
+";
+}
+$private_h_trailer = "";
+
+foreach(sort keys %funcs){
+ if(/^(main)$/) { next }
+ if(!defined($exported{$_}) && /$private_func_re/) {
+ $private_h .= $funcs{$_} . "\n\n";
+ if($funcs{$_} =~ /__attribute__/) {
+ $private_attribute_seen = 1;
+ }
+ } else {
+ if($flags{"function-blocking"}) {
+ $fupper = uc $_;
+ if($exported{$_} =~ /proto/) {
+ $public_h .= "#if !defined(HAVE_$fupper) || defined(NEED_${fupper}_PROTO)\n";
+ } else {
+ $public_h .= "#ifndef HAVE_$fupper\n";
+ }
+ }
+ $public_h .= $funcs{$_} . "\n";
+ if($funcs{$_} =~ /__attribute__/) {
+ $public_attribute_seen = 1;
+ }
+ if($flags{"function-blocking"}) {
+ $public_h .= "#endif\n";
+ }
+ $public_h .= "\n";
+ }
+}
+
+if($flags{"gnuc-attribute"}) {
+ if ($public_attribute_seen) {
+ $public_h_header .= "#if !defined(__GNUC__) && !defined(__attribute__)
+#define __attribute__(x)
+#endif
+
+";
+ }
+
+ if ($private_attribute_seen) {
+ $private_h_header .= "#if !defined(__GNUC__) && !defined(__attribute__)
+#define __attribute__(x)
+#endif
+
+";
+ }
+}
+if($flags{"cxx"}) {
+ $public_h_header .= "#ifdef __cplusplus
+extern \"C\" {
+#endif
+
+";
+ $public_h_trailer .= "#ifdef __cplusplus
+}
+#endif
+
+";
+
+}
+if ($opt_E) {
+ $public_h_header .= "#ifndef $opt_E
+#if defined(_WIN32)
+#define ${opt_E}_FUNCTION _stdcall __declspec(dllimport)
+#define ${opt_E}_VARIABLE __declspec(dllimport)
+#else
+#define ${opt_E}_FUNCTION
+#define ${opt_E}_VARIABLE
+#endif
+#endif
+
+";
+
+ $private_h_header .= "#ifndef $opt_E
+#if defined(_WIN32)
+#define ${opt_E}_FUNCTION _stdcall __declspec(dllimport)
+#define ${opt_E}_VARIABLE __declspec(dllimport)
+#else
+#define ${opt_E}_FUNCTION
+#define ${opt_E}_VARIABLE
+#endif
+#endif
+
+";
+}
+
+if ($public_h ne "" && $flags{"header"}) {
+ $public_h = $public_h_header . $public_h .
+ $public_h_trailer . "#endif /* $block */\n";
+}
+if ($private_h ne "" && $flags{"header"}) {
+ $private_h = $private_h_header . $private_h .
+ $private_h_trailer . "#endif /* $private */\n";
+}
+
+if($opt_o) {
+ print OUT $public_h;
+}
+if($opt_p) {
+ print PRIV $private_h;
+}
+
+close OUT;
+close PRIV;
diff --git a/source4/heimdal/cf/resolv.m4 b/source4/heimdal/cf/resolv.m4
new file mode 100644
index 0000000000..b4045094d8
--- /dev/null
+++ b/source4/heimdal/cf/resolv.m4
@@ -0,0 +1,109 @@
+dnl stuff used by DNS resolv code in roken
+dnl
+dnl $Id$
+dnl
+
+AC_DEFUN([rk_RESOLV],[
+
+AC_CHECK_HEADERS([arpa/nameser.h])
+
+AC_CHECK_HEADERS(resolv.h, , , [AC_INCLUDES_DEFAULT
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#ifdef HAVE_ARPA_NAMESER_H
+#include <arpa/nameser.h>
+#endif
+])
+
+AC_FIND_FUNC(res_search, resolv,
+[
+#include <stdio.h>
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#ifdef HAVE_ARPA_NAMESER_H
+#include <arpa/nameser.h>
+#endif
+#ifdef HAVE_RESOLV_H
+#include <resolv.h>
+#endif
+],
+[0,0,0,0,0])
+
+AC_FIND_FUNC(res_nsearch, resolv,
+[
+#include <stdio.h>
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#ifdef HAVE_ARPA_NAMESER_H
+#include <arpa/nameser.h>
+#endif
+#ifdef HAVE_RESOLV_H
+#include <resolv.h>
+#endif
+],
+[0,0,0,0,0,0])
+
+AC_FIND_FUNC(res_ndestroy, resolv,
+[
+#include <stdio.h>
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#ifdef HAVE_ARPA_NAMESER_H
+#include <arpa/nameser.h>
+#endif
+#ifdef HAVE_RESOLV_H
+#include <resolv.h>
+#endif
+],
+[0])
+
+AC_FIND_FUNC(dn_expand, resolv,
+[
+#include <stdio.h>
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#ifdef HAVE_ARPA_NAMESER_H
+#include <arpa/nameser.h>
+#endif
+#ifdef HAVE_RESOLV_H
+#include <resolv.h>
+#endif
+],
+[0,0,0,0,0])
+
+rk_CHECK_VAR(_res,
+[#include <stdio.h>
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#ifdef HAVE_ARPA_NAMESER_H
+#include <arpa/nameser.h>
+#endif
+#ifdef HAVE_RESOLV_H
+#include <resolv.h>
+#endif])
+
+])