summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAndrew Shadura <andrew@shadura.me>2015-07-25 14:44:37 +0200
committerAndrew Shadura <andrew@shadura.me>2015-07-25 14:44:37 +0200
commit6ec061aabc159e3f37591e92fa1df407cdca6246 (patch)
tree25e11a31b402c65581e0b342c3afb6d405a83206 /scripts
parentaba913436a8521abe405a04ed71388989e1d646f (diff)
Imported Upstream version 0.26.0
Diffstat (limited to 'scripts')
-rw-r--r--scripts/mk-configure.7.in235
-rw-r--r--scripts/mkc_check_common.sh8
-rwxr-xr-xscripts/mkc_check_custom6
-rw-r--r--scripts/mkc_check_custom.158
-rwxr-xr-xscripts/mkc_check_decl59
-rw-r--r--scripts/mkc_check_decl.18
-rwxr-xr-xscripts/mkc_check_funclib2
7 files changed, 280 insertions, 96 deletions
diff --git a/scripts/mk-configure.7.in b/scripts/mk-configure.7.in
index 7b0e4bc..316d6ae 100644
--- a/scripts/mk-configure.7.in
+++ b/scripts/mk-configure.7.in
@@ -2,7 +2,7 @@
.\"
.\" This file contains parts of NetBSD's bsd.README file
.\"
-.\" Copyright (c) 2009-2010 by Aleksey Cheusov (vle@gmx.net)
+.\" Copyright (c) 2009-2014 by Aleksey Cheusov (vle@gmx.net)
.\" Absolutely no warranty.
.\"
.\" ------------------------------------------------------------------
@@ -31,7 +31,9 @@ To get system-specific configuration parameters, mkc.*.mk include
files try to include the file specified by the "MAKECONF"
variable. If MAKECONF is not set, or no such file exists, the system
make configuration file, @sysconfdir@/mk.conf or /etc/mk.conf, is
-included. Unless SRCTOP variable is set, "../Makefile.inc"
+included. If "${SRCTOP}/Makefile.common" file exists it is also included
+by all subprojects.
+Unless SRCTOP variable is set, "../Makefile.inc"
is also included if exists.
These files may define any of the variables described
below. Below in square brackets the default value for variables are specified.
@@ -54,7 +56,7 @@ include files provide the following targets:
.IP all
build everything.
.IP clean
-clean temporary files and directories created while building with a help of
+clean temporary files and directories with a help of
${CLEANFILES_CMD} and ${CLEANDIRS_CMD} commands.
.IP cleandir
remove all of the files removed by the target clean, as
@@ -92,32 +94,6 @@ The target
.I bin_deb
expects debian control files in DEBIAN subdirectory, see examples/hello_files
for the sample.
-.IP "<subdir> and <subdir:T>"
-<subdir> is a subdirectory listed in SUBDIR or SUBPRJ.
-This target is equivalent to all-<subdir> and is provided by
-.BR mkc.subdir.mk " and " mkc.subprj.mk
-only. For details see
-.BR mkc.subdir.mk " or " mkc.subprj.mk
-sections below. <subdir:T> means the last component of the directory.
-This target is created if ${SHORTPRJNAME} is "yes".
-.IP <target>-<subdir>
-runs the specified <target> for the specified <subdir>.
-This target is provided by
-.BR mkc.subdir.mk " and " mkc.subprj.mk
-only. For details see
-.BR mkc.subdir.mk " or " mkc.subprj.mk
-sections below. The target <target>-<subdir:T> is also provided
-if ${SHORTPRJNAME} is "yes".
-.IP "subdir-<target>-<subdir> and nodeps-<target>-<subdir>"
-runs the specified <target> for the specified <subdir> without dependencies.
-These targets are provided by
-.BR mkc.subprj.mk
-only. For details see
-.BR mkc.subprj.mk
-section below.
-Targets subdir-<target>-<subdir:T>
-and nodeps-<target>-<subdir:T> are also provided
-if ${SHORTPRJNAME} is "yes".
.P
.B NOTE:
Commands associated with targets
@@ -294,6 +270,11 @@ rm(1) tool.
List section sizes and total size.
.RI < Iu >
.RI [ size ]
+.IP SRC_PATHADD
+List of directories added to
+.IR .PATH .
+.RI < Im >
+.RI [ "" ]
.IP STRIP
Discard symbols from object files.
.RI < Iu >
@@ -710,6 +691,9 @@ libraries, use:
.RI < "U" >
.IP LDADD_<project>
Similar to LDADD but for project ${PROJECTNAME}.
+.IP LDADD0
+The same as LDADD but LDFLAGS0 and LDADD0 are passed to the linker before LDFLAGS and LDADD.
+.RI < "M" >
.IP LDFLAGS
Additional linker flags. Often used for specifying library directories.
.VS
@@ -718,6 +702,11 @@ Additional linker flags. Often used for specifying library directories.
.RI < "Mu I" >
.IP LDFLAGS_<project>
Similar to LDFLAGS but for project ${PROJECTNAME}.
+.IP LDFLAGS0
+The same as LDFLAGS but LDFLAGS0 and LDADD0 are passed to the linker before LDFLAGS and LDADD.
+Normally LDFLAGS0 and LDADD0 should be modified in makefiles and should not
+be set from environment by user.
+.RI < "M" >
.IP "BINDIR, BINMODE, BINOWN and BINGRP"
See
.IR "Common variables " and " mkc.files.mk"
@@ -923,6 +912,9 @@ and all its dependencies while
See
.I examples/hello_dictd
subdirectory for the sample of use.
+.P
+.B mkc.subprj.mk
+provides the following variables:
.IP SUBPRJ
List of subprojects (subdirectories) and dependencies. If the
subdirectory doesn't exist the subproject becomes "virtual" and may be
@@ -934,8 +926,6 @@ The default is all projects listed in SUBPRJ.
.RI < "IMu" >
.IP EXPORT_VARNAMES
List of variables to export before running make for subdirectories.
-By default MKC_CACHEDIR variable is exported. As a result cache files
-for subprojects are created in a top-level directory.
.RI < "Mu" >
.RI [ MKC_CACHEDIR ]
.IP NOEXPORT_VARNAMES
@@ -962,6 +952,12 @@ Value of ${.OBJDIR} inside
subdirectory. Slash symbols inside <dir> are replaced with underlines.
In addition, OBJDIR_<dir:T> variable is set to ${OBJDIR_<dir>}
if ${SHORTPRJNAME} is "yes".
+.IP SRCDIR_<dir>
+Value of ${.CURDIR} inside
+.I dir
+subdirectory. Slash symbols inside <dir> are replaced with underlines.
+In addition, SRCDIR_<dir:T> variable is set to ${SRCDIR_<dir>}
+if ${SHORTPRJNAME} is "yes".
.IP TARGETS
List of recursive targets supported by the project and all its subprojects.
.RI < "Im" >
@@ -980,6 +976,26 @@ are used. Unlike MAKEOBJDIRPREFIX object directories do not contain
top-level ${.CURDIR} in paths.
.RI < "Iu" >
.RI [ no ]
+.P
+.B mkc.subprj.mk
+provides the following targets:
+.IP "<subdir> and <subdir:T>"
+<subdir> is a subdirectory listed in SUBDIR or SUBPRJ.
+This target is equivalent to all-<subdir>.
+<subdir:T> means the last component of the directory
+and is created if ${SHORTPRJNAME} is "yes".
+.IP <target>-<subdir>
+Runs the specified <target> for the specified <subdir>.
+The target <target>-<subdir:T> is provided
+if ${SHORTPRJNAME} is "yes".
+.IP "subdir-<target>-<subdir> and nodeps-<target>-<subdir>"
+Runs the specified <target> for the specified <subdir> without dependencies.
+Targets subdir-<target>-<subdir:T>
+and nodeps-<target>-<subdir:T> are provided
+if ${SHORTPRJNAME} is "yes".
+.IP print_deps
+Outputs the dependency graph on targets in tsort(1) format
+taking NODEPS and NOSUBDIR variables into account.
.SS "mkc.subdir.mk"
The include file
.B mkc.subdir.mk
@@ -1097,6 +1113,15 @@ added to SRCS unless MKC_NOAUTO=1.
Res: SRCS+= getline.c
HAVE_FUNCLIB.getline= 0
.VE
+.IP "MKC_SOURCE_DIR, MKC_SOURCE_DIR.<source>"
+Directory with sources for MKC_SOURCE_FUNCLIBS. If MKC_SOURCE_DIR.<source> is unset,
+MKC_SOURCE_DIR is used that defaults to ${.CURDIR}.
+.VS
+ Ex: MKC_SOURCE_FUNCLIBS += getline
+ MKC_SOURCE_DIR.getline.c = ${.CURDIR}/../missing
+ Res: SRCS+= ${.CURDIR}/../missing/getline.c
+ HAVE_FUNCLIB.getline= 0
+.VE
.IP MKC_CHECK_DEFINES
List of define:header to check. <header> part is optional.
@@ -1215,7 +1240,7 @@ treated as a fatal error (See
target.
.IP MKC_CHECK_FUNCS<N>
List of <func>:<header> to be check. <header> part is optional.
-
+Here <N> means the number of arguments.
As a result of the check bmake's variable
HAVE_FUNC<N>.<func>.<header> (or HAVE_FUNC<N>.<func>)
is set to either 0 or 1.
@@ -1248,7 +1273,6 @@ MKC_CUSTOM_FN.<custom_check_name> is a
for your custom check,
e.g., filename.c, filename.cc, subdir/filename.cxx, filename.C,
filename.cpp, mychecks/filename.f or subdir/executable_script.
-
.B mk-configure
tries to compile or run the specified file and sets
CUSTOM.<custom_check_name> variable to 1, 0 or other value.
@@ -1306,8 +1330,8 @@ as
.BR prog_mkdep ", " prog_nbmkdep
Find traditional BSD mkdep(1) or recent NetBSD version of it respectively.
.TP
-.B endianess
-BUILTIN.endianess variable is set to either
+.B endianness
+BUILTIN.endianness variable is set to either
.IR little ", " big " or " unknown
depending on a hardware.
.RE
@@ -1366,6 +1390,33 @@ unless MKC_NOAUTO is set to 1
-DSIZEOF_LONG_LONG=4 \\
-DSIZEOF_OFF_T_SYS_TYPES_H=8
.VE
+.IP MKC_CHECK_PROTOTYPES
+A list of checks (list of names) for C function prototypes.
+MKC_PROTOTYPE_FUNC.<name> is a C function prototype.
+MKC_PROTOTYPE_HEADERS.<name> is a list of headers to #include.
+mk-configure verifies that the specified prototype is correct and if
+so, HAVE_PROTOTYPE.<name> bmake variable is set to 1 and
+-DHAVE_PROTOTYPE_<NAME>=1 is added to CFLAGS unless MKC_NOAUTO is set to 1.
+Otherwise, HAVE_PROTOTYPE.<name> variable is set to 0.
+.VS
+Ex.
+ MKC_CHECK_PROTOTYPES = posix_iconv const_iconv
+ MKC_PROTOTYPE_FUNC.posix_iconv = \
+ size_t iconv(iconv_t,char**,size_t*,char**,size_t*)
+ MKC_PROTOTYPE_FUNC.const_iconv = \
+ size_t iconv(iconv_t,const char**,size_t*,char**,size_t*)
+ MKC_PROTOTYPE_HEADERS.posix_iconv = iconv.h
+ MKC_PROTOTYPE_HEADERS.const_iconv = iconv.h
+Res.
+ HAVE_PROTOTYPE.posix_iconv=0
+ HAVE_PROTOTYPE.const_iconv=1
+ CFLAGS += -DHAVE_PROTOTYPE_CONST_ICONV=1
+.VE
+.IP MKC_REQUIRE_PROTOTYPES
+The same as MKC_CHECK_PROTOTYPES, but incorrect prototype is
+treated as a fatal error (See
+.B errorcheck
+target.
.IP MKC_NOAUTO_FUNCLIBS
See MKC_CHECK_FUNCLIBS
.IP MKC_NOAUTO
@@ -1394,11 +1445,10 @@ The same as MKC_COMMON_DEFINES but only for OPSYS (uname -s).
.IP MKC_CACHEDIR
Directory where intermediate and cache files are created.
It defaults to ${.OBJDIR}.
-.\" Setting this variable to something common for huge amount of
-.\" projects can save lots of time/energy wasted on unnecessary
-.\" rechecking. Idea: to use hash from options passed to compiler
-.\" for calculating the cache directory
-.\" ( remove -Wxxx etc. + sort + uniq + crc32/md5/...).
+By default MKC_CACHEDIR variable is exported for subprojects.
+As a result cache files
+for subprojects are created in the top-level directory.
+If cache directory doesn't exist, it is created automatically.
.IP MKC_SHOW_CACHED
Setting it to 0 will hide
.VS
@@ -1410,8 +1460,66 @@ If set to 1, temporary files are removed.
.IP MKC_NOCACHE
All results are cached unless MKC_NOCACHE variable is set
non-empty value
-.SS "mkc_imp.scripts.mk"
-.B mkc_imp.scripts.mk
+.IP MKC_FEATURES
+This is a list of "features" required by project. In general, a feature
+is something that has problems with portability. This may be a
+function name or header missing on some platforms, for example.
+What developer
+needs to do is to add FEATURENAME to MKC_FEATURES variable and add
+#include <mkc_FEATURENAME.h> where it is needed. Internally, system
+requiremets are checked in the automatically included
+mkc_imp.f_FEATURENAME.mk
+file and all required actions (includes, define checks etc.)
+are made in mkc_FEATURENAME.h header file.
+Currently the following features are provided:
+.RS
+.TP
+.B strlcat
+This feature corresponds to strlcat(3) function available on almost
+all systems except glibc-based Linux-es. mkc_imp.f_strlcat.mk checks
+whether strlcat declaration is available in string.h and
+implementation is available in libc. If not, strlcat.c provided by
+mk-configure is added to SRCS and declaration is provided in
+mkc_strlcat.h header.
+.TP
+.B strlcpy
+The same as strlcat.
+.TP
+.B getline
+This feature corresponds to getline(3) function which is a part of POSIX2008
+unavailable on some
+systems. mkc_imp.f_getline.mk checks
+whether getline declaration is available in stdio.h and
+implementation is available in libc. If not, getline.c provided by
+mk-configure is added to SRCS and declaration is provided in
+mkc_getline.h header.
+.TP
+.B libm
+This feature checks whether libm is available and if yes, adds -lm to
+LDADD. Most UNIX-like systems have libm but Haiku, for example, does
+not. mkc_imp.f_libm.mk checks whether libm library is available and if yes,
+-lm is added to LDADD.
+.TP
+.B libdl
+This feature checks whether libdl library is available and dlopen(3)
+is declared in dlfcn.h. If yes, -ldl is added to LDADD. mkc_libdl.h
+provides declarations for dlopen(3), dlsym(3), dlclose(3) etc.
+.TP
+.B "RB SPLAY"
+BSD systems provide sys/tree.h header where RB_* and SPLAY_* macroses
+are defined for red-black tree and splay. These features check whether
+sys/tree.h and appropriate macroses are available. If yes, mkc_RB.h
+and mkc_SPLAY.h include system-wide sys/tree.h, otherwise NetBSD
+version of sys/tree.h provided by mk-configure is included.
+.TP
+.B "SLIST SIMPLEQ STAILQ LIST TAILQ CIRCLEQ"
+BSD systems provide sys/queue.h header where SLIST_* etc. macroses are
+defined for lists and queues. These features check whether sys/queue.h
+and appropriate macroses are available. If yes, mkc_SLIST.h and others
+include system-wide sys/queue.h, otherwise NetBSD version of
+sys/queue.h provided by mk-configure is included.
+.RE
+.SS mkc_imp.scripts.mk
is internal include file which is included from
.BR mkc.prog.mk ", " mkc.lib.mk " and " mkc.files.mk .
Do not use it directly!
@@ -1526,15 +1634,15 @@ expanding the following @@ patterns:
.VS
Pattern Result
----------------------
-@prefix@ ${PREFIX}
-@bindir@ ${BINDIR}
-@mandir@ ${MANDIR}
-@sbindir@ ${SBINDIR}
-@libdir@ ${LIBDIR}
-@libexecdir@ ${LIBEXECDIR}
-@datadir@ ${DATADIR}
-@sysconfdir@ ${SYSCONFDIR}
-@incsdir@ ${INCSDIR}
+.RI @ "" "prefix@ ${PREFIX}"
+.RI @ "" "bindir@ ${BINDIR}"
+.RI @ "" "mandir@ ${MANDIR}"
+.RI @ "" "sbindir@ ${SBINDIR}"
+.RI @ "" "libdir@ ${LIBDIR}"
+.RI @ "" "libexecdir@ ${LIBEXECDIR}"
+.RI @ "" "datadir@ ${DATADIR}"
+.RI @ "" "sysconfdir@ ${SYSCONFDIR}"
+.RI @ "" "incsdir@ ${INCSDIR}"
.VE
The following variables are provided:
.IP INFILES
@@ -1692,9 +1800,22 @@ This module supports dependencies controlled by
program. As a result CPPFLAGS and LDADD variables are modified according
to "pkg-config --cflags ..." and "pkg-config --libs ...".
The following variables are provided:
-.IP PKG_CONFIG_DEPS
-List of dependency libraries. Spaces around <=, >=, =, < and > are not allowed.
+.IP MKC_CHECK_PKGCONFIG
+List of libraries to check, for example, glib-2.0>=2.1.
+Spaces around <=, >=, =, < and > are not allowed.
+As a result of the check bmake's variable
+PKG_CONFIG.exists.<lib> is set to 1 for success or 0 for failure.
+Unless MKC_NOAUTO is set to 1 -DHAVE_PKGCONFIG_<LIB>=1
+is also added to CFLAGS if <lib> was found. <LIB> is tr/a-z+.-/A-ZP__/ of <lib>.
+.RI < "M" >
+.IP MKC_REQUIRE_PKGCONFIG
+The same as MKC_REQUIRE_PKGCONFIG, but absense of library is
+treated as a fatal error (See
+.B errorcheck
+target.
.RI < "M" >
+.IP PKG_CONFIG_DEPS
+Synonym for MKC_REQUIRE_PKGCONFIG. Deprecated.
.IP PKG_CONFIG.exists.<lib>
If "1", <lib> exists, "0" otherwise.
Inside <lib> <=, >=, =, < and > and replaced with
@@ -1759,7 +1880,11 @@ and
List of source files which are needed for generating
dependencies, but are not needed in ${SRCS}.
.SH "CROSS COMPILATION"
-The following variables are used for compiling software using cross-rools.
+The following variables are used for compiling software using cross-tools.
+.IP MACHINE_GNU_PLATFORM
+See TOOLCHAIN_PREFIX.
+.IP OPSYS_TARGET
+OPSYS for target OS.
.IP SYSROOT
Root directory for headers and libraries.
If set, the following variables
@@ -1767,6 +1892,8 @@ are set to ${TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}<toolname>: AR, AS, CXX, CPP, CC,
INSTALL, LD, NM, OBJCOPY, OBJDUMP, RANLIB, SIZE and STRIP.
.RI < "U" >
.RI [ "" ].
+.IP TOOLDIR
+See TOOLCHAIN_DIR.
.IP TOOLCHAIN_DIR
Directory that contains cross-toolchain.
.RI < "U" >
diff --git a/scripts/mkc_check_common.sh b/scripts/mkc_check_common.sh
index 8daff04..1196446 100644
--- a/scripts/mkc_check_common.sh
+++ b/scripts/mkc_check_common.sh
@@ -1,4 +1,4 @@
-# Copyright (c) 2009-2010 by Aleksey Cheusov
+# Copyright (c) 2009-2014 by Aleksey Cheusov
#
# See LICENSE file in the distribution.
############################################################
@@ -14,6 +14,12 @@ fi
MKC_CACHEDIR=${MKC_CACHEDIR:-.}
CC=${CC:-cc}
+if test -x "$MKC_CACHEDIR"; then
+ :
+else
+ mkdir -p "$MKC_CACHEDIR"
+fi
+
tmpc=$MKC_CACHEDIR/_mkc_${pathpart}${MKC_NOCACHE}.c
tmpo=$MKC_CACHEDIR/_mkc_${pathpart}${MKC_NOCACHE}.o
tmperr=$MKC_CACHEDIR/_mkc_${pathpart}${MKC_NOCACHE}.err
diff --git a/scripts/mkc_check_custom b/scripts/mkc_check_custom
index 5213d29..46f751c 100755
--- a/scripts/mkc_check_custom
+++ b/scripts/mkc_check_custom
@@ -27,10 +27,10 @@ Usage:
OPTIONS:
-h display this help
-r build application and run it
- -p a part of cache filename, defaults to "custom"
- -n a part of cache filename, defaults to
+ -p text prefix for cache filename, defaults to "custom"
+ -n text a part of cache filename, defaults to
`basename <source_file>` without extension
- -m A part of verbose message, defaults to -n args
+ -m text A part of verbose message, defaults to -n args
-s exit status of executable will be check
-d delete cache files
Examples:
diff --git a/scripts/mkc_check_custom.1 b/scripts/mkc_check_custom.1
index 6ea2845..8655577 100644
--- a/scripts/mkc_check_custom.1
+++ b/scripts/mkc_check_custom.1
@@ -18,27 +18,24 @@
.SH NAME
mkc_check_custom \- run user's custom checks.
.SH SYNOPSIS
-.BI mkc_check_custom " [-r] <file>"
+.BI mkc_check_custom " [-r] sourcefile"
+.br
+.BI mkc_check_custom " cmd [args...]"
.br
.BI mkc_check_custom " -h"
.SH DESCRIPTION
-.B mkc_check_custom
-takes a
-.I file
-and tries to compile or runs it. If
-.I file
-is an executable file,
-.B mkc_check_custom
-runs it and outputs 1 if it succeeded or 0 otherwise.
If
-.I file
-is not executable,
+.I cmd
+is executable
.B mkc_check_custom
-tries to compile and (if
-.I -r
-applied ) run a generated executable. Again, if compilation/run succeeded,
-1 is output, otherwise -- 0. What type of compiler to use depend on
-.I file
+runs
+.IR "cmd args" .
+Otherwise it tries to compile
+.IR sourcefile
+and output 1 if compilation succeeded and 0 otherwise.
+If -r option was applied it runs a compiled program.
+What type of compiler to use depends on
+.I sourcefile
extension. '.c' corresponds to
.I ${CC}
(C language), '.cc', '.cxx', '.C' and '.cpp' correspond to
@@ -49,7 +46,34 @@ extension. '.c' corresponds to
.SH OPTIONS
.TP
.B "-h"
-display help message
+Display help message.
+.TP
+.B "-r"
+Run executable compiled from
+.IR sourcefile .
+.TP
+.BI "-p " text
+Prefix of the generated cache file. The default is "custom".
+.TP
+.BI "-n " text
+Name part of the generated cache file.
+.br
+The default is `basename <sourcefile>`.
+.TP
+.BI "-m " text
+Message
+.B mkc_check_custom
+outputs.
+.br
+The default is "custom test sourcefile_or_cmd".
+.TP
+.BI -s
+.B mkc_check_custom
+outputs an exit status of
+.IR "cmd args" .
+.TP
+.BI -d
+Delete cache files.
.SH ENVIRONMENT
.TP
.B CC
diff --git a/scripts/mkc_check_decl b/scripts/mkc_check_decl
index e0cb8ea..ea2a962 100755
--- a/scripts/mkc_check_decl
+++ b/scripts/mkc_check_decl
@@ -1,7 +1,7 @@
#!/bin/sh
############################################################
-# Copyright (c) 2009-2010 by Aleksey Cheusov
+# Copyright (c) 2009-2014 by Aleksey Cheusov
#
# See LICENSE file in the distribution.
############################################################
@@ -27,7 +27,7 @@ in system header files by compiling a test program.
Usage:
mkc_check_decl [OPTIONS] <CHECKTYPE> <what> [includes...]
where CHECKTYPE is either of the following: "define", "variable",
-"func[0-9]", "type" or "member"
+"func[0-9]", "type", "member" or "prototype".
OPTIONS:
-h display this help
@@ -44,6 +44,8 @@ Examples:
mkc_check_decl type long-long
mkc_check_decl member tm.tm_isdst time.h
mkc_check_decl member ifreq.ifr_addr.sa_len net/if.h
+ mkc_check_decl prototype 'int connect(int __fd, const struct sockaddr * __addr, socklen_t __len)' sys/socket.h
+ mkc_check_decl prototype 'int connect(int __fd, struct sockaddr * __addr, socklen_t __len)' sys/socket.h
EOF
}
@@ -63,18 +65,26 @@ fi
##################################################
# initializing
-decltype=`echo $1 | sed -e 's/[0-9]//g'`
-argscnt=`echo $1 | sed 's/[^0-9]//g'`
+decltype=`echo "$1" | sed -e 's/[0-9]//g'`
+argscnt=`echo "$1" | sed 's/[^0-9]//g'`
shift
-declwhat=`echo $1 | sed 's/-/ /'`
+declwhat=`echo "$1" | awk '{gsub(/-/, " "); gsub(/ +[(]/, "("); $1=$1; print}'`
shift
-if test "$decltype" = type; then
- pathpart=`echo ${decltype}_${declwhat}_$* | tr '/. ' '__~'`
-else
- pathpart=`echo $decltype$argscnt $declwhat $* | tr '/. ' '___'`
-fi
+typemsg="$decltype $declwhat"
+case "$decltype" in
+ type)
+ pathpart=`echo "${decltype}_${declwhat}_$*" | tr '/. ' '__~'`
+ ;;
+ prototype)
+ pathpart=`echo "${decltype}_${declwhat}_$*" | tr '/(). *' '____~8'`
+ funcname=`echo "$declwhat" | sed 's,^.* \([^ ]*\)[(].*$,\1,'`
+ ;;
+ *)
+ pathpart=`echo "$decltype$argscnt $declwhat" $* | tr '/. ' '___'`
+ ;;
+esac
. mkc_check_common.sh
@@ -108,7 +118,7 @@ int main ()
return 0;
}
#else
-.error "$declwhat is not a define"
+#error "$declwhat is not a define"
#endif
EOF
@@ -179,6 +189,23 @@ BEGIN {
}
##############################
+is_prototype (){
+ get_includes "$@" > "$tmpc"
+
+ cat >> "$tmpc" <<EOF
+${declwhat};
+void func (void)
+{
+ if (${funcname}) return;
+}
+EOF
+
+ #
+ compile
+}
+
+
+##############################
is_member (){
get_includes "$@" > "$tmpc"
@@ -200,12 +227,8 @@ EOF
##################################################
# test
-for i in "$@"; do
- incs_msg="$incs_msg $i"
-done
-
-if test -n "$incs_msg"; then
- incs_msg=" ($incs_msg )"
+if test $# -gt 0; then
+ incs_msg=" ( $* )"
fi
check_itself (){
@@ -217,7 +240,7 @@ check_itself (){
fi
}
-check_and_cache "checking for $decltype ${declwhat}${incs_msg}" "$cache" "$@"
+check_and_cache "checking for ${typemsg}${incs_msg}" "$cache" "$@"
##################################################
# clean-ups
diff --git a/scripts/mkc_check_decl.1 b/scripts/mkc_check_decl.1
index bc1866e..f3434bb 100644
--- a/scripts/mkc_check_decl.1
+++ b/scripts/mkc_check_decl.1
@@ -16,7 +16,8 @@
.\" ------------------------------------------------------------------
.TH MKC_CHECK_DECL 1 "Mar 15, 2009" "" ""
.SH NAME
-mkc_check_decl \- checks for define, function, variable or type.
+mkc_check_decl \- checks for define, function, variable, type or
+function prototype.
.SH SYNOPSIS
.BI mkc_check_decl " <check_type> <what> [includes...]"
.br
@@ -24,7 +25,8 @@ mkc_check_decl \- checks for define, function, variable or type.
.SH DESCRIPTION
.I check_type
is either
-.IR " define" , " variable" , " func[0-9]" , " type " or " member" .
+.IR " define" , " variable" , " func[0-9]" , " type" , " member " or
+.IR " prototype" .
Depending on its value
.B mkc_check_decl
checks for define, variable, function with specified number
@@ -80,6 +82,8 @@ If set to 1, temporary files are removed.
mkc_check_decl type long-long
mkc_check_decl member tm.tm_isdst time.h
mkc_check_decl member ifreq.ifr_addr.sa_len net/if.h
+ mkc_check_decl prototype 'int connect(int __fd, const struct sockaddr * __addr, socklen_t __len)' sys/socket.h
+ mkc_check_decl prototype 'int connect(int __fd, struct sockaddr * __addr, socklen_t __len)' sys/socket.h
.VE
.SH AUTHOR
Aleksey Cheusov <vle@gmx.net>
diff --git a/scripts/mkc_check_funclib b/scripts/mkc_check_funclib
index 6b3ba4b..0bfd771 100755
--- a/scripts/mkc_check_funclib
+++ b/scripts/mkc_check_funclib
@@ -100,7 +100,7 @@ EOF
fi
}
-check_and_cache "checking for function ${funcname}${libs_msg}" "$cache" "$@"
+check_and_cache "checking for function implementation ${funcname}${libs_msg}" "$cache" "$@"
##################################################
# clean-ups