diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Makefile | 21 | ||||
-rw-r--r-- | scripts/mk-configure.7.in | 1805 | ||||
-rw-r--r-- | scripts/mkc_check_common.sh | 95 | ||||
-rwxr-xr-x | scripts/mkc_check_compiler | 69 | ||||
-rwxr-xr-x | scripts/mkc_check_custom | 180 | ||||
-rw-r--r-- | scripts/mkc_check_custom.1 | 100 | ||||
-rwxr-xr-x | scripts/mkc_check_decl | 236 | ||||
-rw-r--r-- | scripts/mkc_check_decl.1 | 85 | ||||
-rwxr-xr-x | scripts/mkc_check_funclib | 119 | ||||
-rw-r--r-- | scripts/mkc_check_funclib.1 | 76 | ||||
-rwxr-xr-x | scripts/mkc_check_header | 85 | ||||
-rw-r--r-- | scripts/mkc_check_header.1 | 66 | ||||
-rwxr-xr-x | scripts/mkc_check_prog | 91 | ||||
-rw-r--r-- | scripts/mkc_check_prog.1 | 69 | ||||
-rwxr-xr-x | scripts/mkc_check_sizeof | 108 | ||||
-rw-r--r-- | scripts/mkc_check_sizeof.1 | 72 | ||||
-rwxr-xr-x | scripts/mkc_check_version.in | 39 | ||||
-rwxr-xr-x | scripts/mkc_install | 189 | ||||
-rwxr-xr-x | scripts/mkc_which | 41 | ||||
-rw-r--r-- | scripts/mkcmake.1 | 48 | ||||
-rw-r--r-- | scripts/mkcmake.in | 5 |
21 files changed, 3599 insertions, 0 deletions
diff --git a/scripts/Makefile b/scripts/Makefile new file mode 100644 index 0000000..c651993 --- /dev/null +++ b/scripts/Makefile @@ -0,0 +1,21 @@ +FILES = mkc_check_common.sh +INFILES = mk-configure.7 +FILESDIR = ${BINDIR} + +SCRIPTS = mkc_check_funclib mkc_check_header \ + mkc_check_sizeof mkc_check_decl \ + mkc_check_prog mkc_check_custom \ + mkc_which mkc_check_compiler \ + mkc_install ${INSCRIPTS} +INSCRIPTS += mkc_check_version mkcmake + +MAN = mkc_check_funclib.1 mkc_check_header.1 \ + mkc_check_sizeof.1 mkc_check_decl.1 \ + mkc_check_prog.1 mkc_check_custom.1 \ + mk-configure.7 mkcmake.1 + +SYMLINKS = mkc.subprj.mk ${MKFILESDIR}/mkc.subprjs.mk +SYMLINKS += mkc_imp.pkg-config.mk ${MKFILESDIR}/mkc.pkg-config.mk +SYMLINKS += mkc_imp.intexts.mk ${MKFILESDIR}/mkc.intexts.mk + +.include <mkc.mk> diff --git a/scripts/mk-configure.7.in b/scripts/mk-configure.7.in new file mode 100644 index 0000000..7b0e4bc --- /dev/null +++ b/scripts/mk-configure.7.in @@ -0,0 +1,1805 @@ +.\" $NetBSD$ +.\" +.\" This file contains parts of NetBSD's bsd.README file +.\" +.\" Copyright (c) 2009-2010 by Aleksey Cheusov (vle@gmx.net) +.\" Absolutely no warranty. +.\" +.\" ------------------------------------------------------------------ +.de VS \" Verbatim Start +.sp +.ft CW +.nf +.ne \\$1 +.. +.de VE \" Verbatim End +.ft R +.fi +.sp +.. +.\" ------------------------------------------------------------------ +.TH MK-CONFIGURE 7 "Dec 1, 2013" "" "" +.SH NAME +mk-configure \- lightweight replacement for GNU autotools +.SH DESCRIPTION +.B mk-configure +is a collection of include files for bmake (portable version of +NetBSD make) and a number of executables. It is intended to simplify +crossplatform development and software building. +.P +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" +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. +In triangle brackets -- typical way of use, where +.I I +means "Initialized by mk-configure", +.I Iu +means "Initialized by mk-configure but may be overriden by user", +.I Im +means "Initialized by mk-configure but may be set in Makefile", +.I U +means "Usually set by user", +.I M +means "May be set or changed in project's Makefile" and +.I Mu +means "May be set in project's Makefile but may be initialized or overriden by user". +.SS "Targets" +.BR mkc.prog.mk ", " mkc.lib.mk ", " mkc.files.mk ", " mkc.subdir.mk ", and " mkc.subprj.mk +include files provide the following targets: +.IP all +build everything. +.IP clean +clean temporary files and directories created while building with a help of +${CLEANFILES_CMD} and ${CLEANDIRS_CMD} commands. +.IP cleandir +remove all of the files removed by the target clean, as +well as cache files created by +.BR mkc.configure.mk . +.IP distclean +synonym for target "cleandir". +.IP installdirs +create target directories. +.IP install +install programs, libraries, files, include files, manual pages etc. +to the target directories with a help of ${INSTALL} program. +.IP uninstall +remove installed files with a help of ${UNINSTALL} command. +.IP errorcheck +check for MKC_ERR_MSG variable and fails if it set printing +an error message +.IP depend +create .depend file containing list of dependencies (see mkdep(1)). +.IP filelist +output a list of destination files of the project, one per line, e.g. +.VS + /usr/local/bin/hello + /usr/local/man/man1/hello.1 +.VE +.IP "obj" +if MKOBJDIR is "yes", creates object directories (${.OBJDIR}) according +to MAKEOBJDIR and MAKEOBJPREFIX variables. Current umask is used for +this. +.IP "bin_tar, bin_targz, bin_tarbz2, bin_zip, bin_deb" +build software, install it to a temporary directory (using DESTDIR) +and create .tar/.tar.gz/.tar.bz2/.zip/.deb archive +containing all installed files. +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 +.IR all ", " install ", " clean ", " cleandir ", " depend ", " test ", " installdirs ", " uninstall ", " errorcheck " and " filelist +in Makefile override the standard behaviour. +.SS "Common variables" +The following variables control how various files are compiled/built. +.IP AR +Create, modify, and extract from archives. +.RI < Iu > +.RI [ ar ] +.IP ARFLAGS +Options to ${AR}. +.RI < Iu > +.RI [ rl ] +.IP AS +Assembler. +.RI < Iu > +.RI [ as ] +.IP AFLAGS +Options to ${CC} when compiling or linking .s or .S +assembly source files. [] +.\" .IP ADDR2LINE +.\" Path to addr2line. [addr2line] +.IP CC +C compiler. +.RI < Iu > +.RI [ cc ] +.IP CC_PREFIX +Prefix command for ${CC}, for example, distcc or ccache. +.RI < Iu > +.RI [ "" ] +.IP CFLAGS +Additional flags to the compiler when creating C objects. +.RI < "IM" > +.IP CFLAGS_<project> +Similar to CFLAGS but for project ${PROJECTNAME}. +.RI < "U" > +.IP CLEANFILES_CMD +Command for removing files used by targets "clean" and "cleandir". +.RI < Iu > +.RI [ "${RM} -f" ] +.IP CLEANDIRS_CMD +Command for removing directories used by targets "clean" and "cleandir". +.RI < Iu > +.RI [ "${RM} -rf" ] +.IP COPTS +Additional flags to the compiler when creating C objects. +.RI < "U" > +.IP COPTS_<project> +Similar to COPTS but for project ${PROJECTNAME}. +.RI < "U" > +.IP CXX +C++ compiler. +.RI < Iu > +.RI [ c++ ] +.IP CXX_PREFIX +Prefix command for ${CXX}, for example, distcc or ccache. +.RI < Iu > +.RI [ "" ] +.IP CXXFLAGS +Additional flags to the compiler when creating C++ objects. +.RI < "Iu" > +.RI [ ${CFLAGS} ] +.IP CXXFLAGS_<project> +Similar to CXXFLAGS but for project ${PROJECTNAME}. +.RI < "U" > +.IP CPP +C Pre-Processor. +.RI < Iu > +.RI [ cpp ] +.IP CPPFLAGS +Additional flags to the C pre-processor. +.RI < "Iu" > +.IP CPPFLAGS_<project> +Similar to CPPFLAGS but for project ${PROJECTNAME}. +.RI < "U" > +.IP FC +Fortran compiler. +.RI < Iu > +.RI [ f77 ] +.IP FFLAGS +Options to {$FC}. +.RI < Iu > +.RI [ -O ] +.IP FFLAGS_<project> +Similar to FFLAGS but for project +.IR ${PROJECTNAME} . +.RI < "U" > +.IP INSTALL +install(1) command. +.RI < Iu > +.RI [ install " or " mkc_install ] +.IP LEX +Lexical analyzer. +.RI < Iu > +.RI [ lex ] +.IP LFLAGS +Options to ${LEX}. +.RI < Iu > +.RI [ "" ] +.IP LN +ln(1) tool. +.RI < Iu > +.RI [ ln ] +.IP LN_S +Tool equivalent to ln -s. +.RI < Iu > +.RI [ "${LN} -s" ] +.IP LPREFIX +Symbol prefix for ${LEX} (see -P option in lex(1)). +.RI < Iu > +.RI [ yy ] +.RI < Iu > +.RI [ yy ] +.IP LEXLIB +Object file for lex. +.RI < Iu > +.RI [ -ll ] +.IP LD +Linker. +.RI < Iu > +.RI [ ld ] +.IP LORDER +List dependencies for object files. +.RI < Iu > +.RI [ lorder ] +.IP MAKE +bmake(1). +.RI [ bmake " or " make " on NetBSD]" +.IP MAKEDEPEND +makedepend(1) tool. +.RI < Iu > +.IP MKDIR +mkdir(1) tool. +.RI < Iu > +.RI [ mkdir ] +.IP MKDEP +mkdep(1) tool. +.RI < Iu > +.IP NM +List symbols from object files. +.RI < Iu > +.RI [ nm ] +.IP PC +Pascal compiler. +.RI < Iu > +.RI [ pc ] +.IP PFLAGS +Options to ${PC}. +.RI < Iu > +.RI [ "" ] +.\" .IP OBJC +.\" Objective C compiler. [${CC}] +.\" .IP OBJCFLAGS +.\" Options to ${OBJC}. [${CFLAGS}] +.IP OBJCOPY +Copy and translate object files. +.RI < Iu > +.RI [ objcopy ] +.IP OBJDUMP +Display information from object files. +.RI < Iu > +.RI [ objdump ] +.IP RANLIB +Generate index to archive. +.RI < Iu > +.RI [ ranlib ] +.IP RM +rm(1) tool. +.RI < Iu > +.RI [ rm ] +.IP SIZE +List section sizes and total size. +.RI < Iu > +.RI [ size ] +.IP STRIP +Discard symbols from object files. +.RI < Iu > +.RI [ strip ] +.IP STRIPFLAG +The flag passed to the install program to cause the binary +to be stripped. +.RI < Iu > +.IP TSORT +Topological sort of a directed graph. +.RI < Iu > +.RI [ "tsort -q" ] +.IP UNINSTALL +Command for removing files used by target "uninstall". +.RI < Iu > +.RI [ "${RM} -f" ] +.IP YACC +LALR(1) parser generator. +.RI < Iu > +.RI [ yacc ] +.IP TAR +tar archiver. +.RI < Iu > +.RI [ tar ] +.IP GZIP +gzip copression tool. +.RI < Iu > +.RI [ gzip ] +.IP BZIP2 +bzip2 copression tool. +.RI < Iu > +.RI [ bzip2 ] +.IP ZIP +zip copression tool. +.RI < Iu > +.RI [ zip ] +.IP YFLAGS +Options to ${YACC}. +.RI < Iu > +.RI [ "" ] +.IP YHEADER +If defined, add "-d" to YFLAGS, and add dependencies +from <file>.y to <file>.h and <file>.c, and add +<foo>.h to CLEANFILES. +.IP YPREFIX +If defined, add "-p ${YPREFIX}" to YFLAGS. +.IP WARNERR +If "yes", force warnings to be reported as errors. +At the moment this is supported for GCC, Intel C/C++ and Sun's C/C++ compilers. +.RI < "Iu" > +.RI [ yes " if WARNS=4, " no " otherwise ]" +.IP WARNS +Crank up warning options; the distinct levels are (the higher the +more strict): +.VS + WARNS=0 + WARNS=1 + WARNS=2 + WARNS=3 + WARNS=4 +.VE +At the moment WARNS is supported for GCC and HP-UX C/C++ only. +WARNS=0 means disabling all warnings if such feature is provided by compiler +and mk-configure. +.RI < Mu > +.RI [ 0 ] +.IP PREFIX +Target directory. +.RI < "U" > +.RI [ /usr/local ] +.IP BINDIR +Target directory for utilities. +.RI < "Iu Mu" > +.RI [ ${PREFIX}/bin ] +.IP SBINDIR +Target directory for administration utilities. +.RI < "Iu" > +.RI [ ${PREFIX}/sbin ] +.IP LIBDIR +Target directory for libraries. +.RI < "Iu" > +.RI [ ${PREFIX}/lib ] +.IP LIBEXECDIR +Target directory for system utilities. +.RI < "Iu" > +.RI [ ${PREFIX}/libexec ] +.IP DATADIR +Target directory for architecture-independent text files. +.RI < "Iu" > +.RI [ ${PREFIX}/share ] +.IP SYSCONFDIR +Target directory for configuration files. +.RI < "Iu" > +.RI [ ${PREFIX}/etc ] +.IP INFODIR +Target directory for .info files. +.RI < "Iu" > +.RI [ ${PREFIX}/info ] +.IP DESTDIR +Installation prefix. +.RI < "U" > +.RI [ "" ] +.IP MKC_ERR_MSG +If set, keep an error message. +.RI < "I M" > +.RI [ "" ] +.IP MKINSTALL +If not "yes", build everything but do not install. This option is useful +for e.g. internal libraries. +.RI < "Mu" > +.RI [ yes ] +.IP MKINSTALLDIRS +If "yes", install target directories (target +.IR installdirs ) +before installing files (target +.IR install ). +.RI < "Iu" > +.RI [ yes ] +.IP MKOBJDIR +If "yes", the target "obj" creates object directories, if "auto", +object directories are created automatically. Otherwise object +directories are not created. +.RI < "Iu" > +.RI [ auto ] +.IP BMAKE_REQD +Minimal required version of +.BR bmake . +If it is older, +.B mkcmake +exits with error. +.RI < "Im" > +.IP MKC_REQD +Minimal required version of +.BR mk-configure . +If required version is not found, +the target +.I errorcheck +fails. +.RI < "M" > +.IP MKC_VERSION +Version of +.IR mk-configure . +This variable is always set to non-empty value when mkc.*.mk include files are used, +so you can use it to initialize mk-c variables in mk.conf. For example: +.VS +@sysconfdir@/mk.conf: + ... + .ifdef MKC_VERSION + COPTS?= -O2 -Werror + SHRTOUT= yes + .endif # MKC_VERSION +.VE +.RI < "I" > +.IP PROJECTNAME +The name of a project. By default it is set to ${PROG}, ${LIB} or ${.CURDIR:T}. +For a top-level project using either mkc.subdir.mk or mkc.subprj.mk +it makes sense to set this variable explicitely in project's Makefile. +This variable is initialized before including mk.conf, so you can use it +to change build options, e.g. during development process. +.VS +@sysconfdir@/mk.conf: + ... + .ifdef MKC_VERSION + ... + .if ${PROJECTNAME} == "foo" + SHRTOUT= yes + PROG.gcc= /usr/bin/gcc + CC_TYPE= gcc + COPTS= -O0 -g + .endif + .endif # MKC_VERSION +.VE +.RI < "Im" > +.IP CC_TYPE +C compiler type. This variable is set by +.B mk-configure +and can be overriden by user. It can get the following values: +.VS +Value Description +---------------------- +gcc GNU C/C++ compiler +pcc Portable C compiler +icc Intel C/C++ compiler +msc Microsoft C/C++ compiler +hpc HP-UX C/C++ compiler +sunpro SUNWspro C/C++ compiler +ibmc IBM C/C++ compiler (Visual Age for C/C++?) +bcc Borland C/C++ compiler +watcom Watcom C/C++ compiler +como COMO C/C++ compiler +decc DEC C +mipspro MIPSpro C compiler +.VE +.RI < "Iu" > +.IP CXX_TYPE +C++ compiler type. This variable is set by +.B mk-configure +and can be overriden by user. It can get the same values as CC_TYPE variable. +.RI < "Iu" > +.IP LD_TYPE +Linker type. This variable is set by +.B mk-configure +and can be overriden by user. It can get the following values: +.VS +Value Description +---------------------- +aixld AIX linker +darwinld Darwin linker (MacOS-X) +gnuld GNU linker +hpld HP-UX linker +interixld Interix linker +scold SCO linker +sunld SunOS linker +osf1ld OSF1 linker (Tru64) +irixld IRIX linker +.VE +.RI < "Iu" > +.IP SHRTOUT +If not "no", output messages about compiling, linking and creating libraries +are shortened and formatted. +.RI < "Iu" > +.RI [ no ] +.IP "CFLAGS.warns.<cctype>.<warn-level>, CXXFLAGS.warns.<cxxtype>.<warn-level>" +These variables are set by mk-configure and enable warning messages +for C or C++ compilers according to their types (CC_TYPE and CXX_TYPE) +and warning level (WARNS). +.RI < "Iu" > +.IP "CFLAGS.dflt.<cctype>, CXXFLAGS.dflt.<cxxtype>" +Additional flags passed to +C or C++ compilers according to their types (CC_TYPE and CXX_TYPE). +.RI < "Iu" > +.IP "CFLAGS.pic, CXXFLAGS.pic" +Options for C and C++ compilers for generating position independent +code. On some platforms it makes sense to override these variables +(initialized by mk-configure) for better performance, for example, +one may use -fpic instead of -fPIC with GNU C/C++ compilers. +See SHLIB_MAJOR, MKPIE etc. variables for more information. +.RI < "Iu" > +.IP "CFLAGS.pie, CXXFLAGS.pie" +Options for C and C++ compilers for generating position independent +executables. On some platforms it makes sense to override these variables +(initialized by mk-configure) for better performance, for example, +one may use -fpic instead of -fPIC with GNU C/C++ compilers. +See MKPIE variable for more information. +.RI < "Iu" > +.IP "CFLAGS.ssp, CXXFLAGS.ssp" +Options for C and C++ compilers for generating stack protection code. +See USE_SSP variable for more information. +.RI < "Iu" > +.IP USE_SSP +If "yes", enables stack protection code, which detects stack overflows +and aborts the program. This enhances security but imposes some +performance penalty. +.RI < "U" > +.RI [ no ] +.IP SRCTOP +Top-level project's directory which +defaults to ${.CURDIR} if ${.MAKE.LEVEL} is 0. +If set, "../Makefile.inc" +is not included. Also, the following command +.br + mkcmake -C subproject target +.br +will be translated to +.br + cd ${SRCTOP}; mkcmake target-subproject +.RI < Iu > +.IP OBJTOP +Top-level object directory which +defaults to ${.OBJDIR} if ${.MAKE.LEVEL} is 0. +.RI < I > +.SS "mkc.init.mk" +This file sets most important mk-configure variables, for example, +OPSYS, PREFIX, CC_TYPE etc. and is included automatically by +.BR mkc.files.mk ", " mkc.lib.mk ", " mkc.prog.mk ", " mkc.subdir.mk " and " mkc.subprj.mk +.SS "mkc.files.mk" +The include file +.B mkc.files.mk +handles the FILES variables and is included +from +.BR mkc.lib.mk " and " mkc.prog.mk . +.B mkc_imp.files.mk +List of supported variables: +.IP FILES +The list of files to install. +.\" .IP CONFIGFILES Similar semantics to FILES, except that the files +.\" are installed by the `configinstall' target, +.\" not the `install' target. +.\" The FILES* variables documented below also apply. +.RI < "M" > +.IP FILESDIR +The location to install the files. +.RI < "Mu" > +.RI [ ${PREFIX}/bin ] +.IP FILESDIR_<fn> +The location to install the specific file <fn>. +.RI < "Mu" > +.IP FILESOWN +File owner. If +.B bmake +is run with root privileges, it defaults to +.I ${BINOWN} +or to +.I "`id -u`" +otherwise. +.RI < "Mu" > +.IP FILESOWN_<fn> +File owner of the specific file <fn>. +.RI < "Mu" > +.IP FILESGRP +File group. If +.B bmake +is run with root privileges, it defaults to +.RI < "Mu" > +.I ${BINGRP} +or to +.I "`id -g`" +otherwise. +.RI < "Mu" > +.IP FILESGRP_<fn> +File group of the specific file <fn>. +.RI < "Mu" > +.IP FILESMODE +File mode. +.RI < "Mu" > +.RI [ ${NONBINMODE} ] +.IP FILESMODE_<fn> +File mode of the specific file <fn>. +.RI < "Mu" > +.IP FILESNAME +Optional name to install each file as. +.RI < "Mu" > +.IP FILESNAME_<fn> +Optional name to install <fn> as. +.RI < "Mu" > +.IP CLEANFILES +Additional files to remove for the +.IR clean ", " cleandir " and " distclean +targets. +.RI < "I M" > +.IP DISTCLEANFILES +Additional files to remove for the +.IR cleandir " and " distclean +targets. +.RI < "I M" > +.IP CLEANDIRS +Additional directories to remove (recursively) for the +.IR clean ", " cleandir " and " distclean +targets. +.RI < "I M" > +.IP DISTCLEANDIRS +Additional directories to remove (recursively) for the +.IR cleandir " and " distclean +targets. +.RI < "I M" > +.\" .IP FILESBUILD_<fn> A value different from "no" will add the file + \" to the list of +.\" targets to be built by `realall'. Users of that variable +.\" should provide a target to build the file. +.\" .IP BUILDSYMLINKS List of two word items: +.\" lnsrc lntgt +.\" For each lnsrc item, create a symlink named lntgt. +.\" The lntgt symlinks are removed by the cleandir target. +.\" .IP UUDECODE_FILES List of files which are stored as <file>.uue in + \" the source +.\" tree. Each one will be decoded with ${TOOL_UUDECODE}. +.\" The source files have a `.uue' suffix, the generated files do +.\" not. +.\" .IP UUDECODE_FILES_RENAME_<fn> +.\" Rename the output from the decode to the provided name. +.\" *NOTE: These files are simply decoded, with no install or other +.\" rule applying implicitly except being added to the clean +.\" target. +.SS "mkc.prog.mk" +The include file +.B mkc.prog.mk +handles building program from one or +more source files, along with their manual pages. It has a limited +number of suffixes. +List of supported variables: +.IP PROG +The name of the program to build. +.IP PROGS +The names of the programs to build. If neither PROG nor PROGS +is not supplied, nothing is built. +.\" .IP PROG_CXX +.\" If defined, the name of the program to build. Also +.\" causes mkc.prog.mk to link the program with the C++ +.\" compiler rather than the C compiler. PROG_CXX overrides +.\" the value of PROG if PROG is also set. +.RI < "M" > +.IP PROGNAME +The name that the above program will be installed as, if +different from ${PROG}. +.RI < "M" > +.IP SRCS +List of source files to build the program. If SRCS is not + defined, it's assumed to be ${PROG}.c. +.RI < "M" > +.IP SRCS.<prog> +List of source files to build the program +.I prog +listed in +.IR PROGS . +If SRCS.<prog> is not defined, it's assumed to be prog.c. +.RI < "M" > +.IP LDADD +Additional objects. Usually used for libraries. +For example, to link with the compatibility and utility +libraries, use: +.VS + LDADD+= -lutil -lcompat +.VE +.RI < "U" > +.IP LDADD_<project> +Similar to LDADD but for project ${PROJECTNAME}. +.IP LDFLAGS +Additional linker flags. Often used for specifying library directories. +.VS + LDFLAGS+= -L/opt/company/software/lib +.VE +.RI < "Mu I" > +.IP LDFLAGS_<project> +Similar to LDFLAGS but for project ${PROJECTNAME}. +.IP "BINDIR, BINMODE, BINOWN and BINGRP" +See +.IR "Common variables " and " mkc.files.mk" +sections. +.IP MKSHARE +If "no", act as "MKHTML=no MKINFO=no MKCATPAGES=no MKMAN=no". +I.e, don't build catman pages, man pages, info +documentation,... +.RI < "Iu" > +.RI [ yes ] +.IP MKPIE +If "yes", create Position Independent Executable (PIE), otherwise +create a regular executable. +.RI < "Mu" > +.RI [ no ] +.IP USE_RELRO +If "yes", enables a technique to harden the data sections of an ELF +binary/process. For security reasons it makes sense to set it to YES, it +may slow down application startup, though. +.RI < "Iu" > +.RI [ no ] +.IP EXPORT_DYNAMIC +If "yes", add all symbols to the dynamic symbol table, that is make +all symbols visible from dynamic objects at run time (e.g. dlopen-ed +objects), otherwise only symbols referenced by some object file will +be exported. +.RI < "M" > +.RI [ no ] +.PP +.B mkc.prog.mk +includes +.B mkc.files.mk +and therefore supports all variables supported by it. +.SS "mkc.lib.mk" +The include file +.B mkc.lib.mk +has support for building a static or dynanic library. It has a +limited number of suffixes. +.B mkc.lib.mk +uses the following variables: +.IP LIB +The name of the library to build. +.RI < "M" > +.IP LIBDIR +See +.IR "Common variables " and " mkc.files.mk" +sections. +.IP SHLIB_MAJOR +Major shared library number. If unset, shared library is not built. +.RI < "M" > +.IP SHLIB_MINOR +Minor shared library number. +.RI < "M" > +.RI [ 0 ] +.IP SHLIB_TEENY +Minor shared library number. +.RI < "M" > +.RI [ "" ] +.IP LIBOWN +Library owner. If +.B bmake +is run by an unprivileged user, it defaults to +.IR "`id -u`" . +.RI < "Iu" > +.IP LIBGRP +Library group. If +.B bmake +is run by an unprivileged user, it defaults to +.IR "`id -g`" . +.RI < "Iu" > +.IP LIBMODE +Library mode. +.RI < "Iu" > +.RI [ ${NONBINMODE} ] +.IP SHLIBMODE +Shared library mode. +.RI < "Iu" > +.IP "LDADD LDADD_<project>" +Additional objects. See +.B mkc.prog.mk +.IP "LDFLAGS LDFLAGS_<project>" +Additional linker flags. See +.B mkc.prog.mk +.IP MAN +The manual pages to be installed (use a .1 - .9 suffix). +.RI < "M" > +.IP SRCS +List of source files to build the library. Suffix types + .s, .c, and .f are supported. Note, .s files are preferred + to .c files of the same name. +.RI < "M" > +.\" (This is not the default for +.\" versions of make.) +.\" LIBDPLIBS A list of the tuples: +.\" libname path-to-srcdir-of-libname +.\" For each tuple; +.\" * LIBDO.libname contains the .OBJDIR of the library +.\" `libname', and if it is not set it is determined +.\" from the srcdir and added to MAKEOVERRIDES (the +.\" latter is to allow for build time optimization). +.\" * LDADD gets -L${LIBDO.libname} -llibname added. +.\" * DPADD gets ${LIBDO.libname}/liblibname.so or +.\" ${LIBDO.libname}/liblibname.a added. +.\" This variable may be used for individual libraries, as +.\" well as in parent directories to cache common libraries +.\" as a build-time optimization. +.\" +.\" The include file <bsd.lib.mk> includes the file named "../Makefile.inc" +.\" if it exists, as well as the include file <bsd.man.mk>. +.\" +.\" It has rules for building profiled objects; profiled libraries are +.\" built by default. +.IP LDCOMPILER +If "yes", ${CC} is used for linking instead of ${LD}. +For C++ sources ${CXX} is used for linking. +.RI < "Iu" > +.RI [ yes ] +.IP MKSHLIB +If not "no", build and install shared library provided that SHLIB_MAJOR is defined. +.RI < "IMu" > +.RI [ yes ] +(for MACHINE_ARCHs that support it) +.IP MKSTATICLIB +If not "no", build and install static library. +.RI < "IMu" > +.RI [ yes ] +.IP MKPICLIB +If not "no", build and install *_pic.a library. +.RI < "IMu" > +.RI [ no ] +.IP MKPROFILELIB +If "no", don't build or install the profiling (*_p.a) libraries. +.RI < "Iu" > +.RI [ no ] +.IP MKDLL +If "yes", build and install the dynamically loaded library (<lib>.so) +instead of shared library. If "only", do not make static library. +.RI < "M" > +.RI [ no ] +.IP EXPORT_SYMBOLS +Only symbols listed in a specified file (one symbol per line) are +exported. This variable has no effect on some platforms. By default +all symbols are exported. +.RI < "M" > +[] +.\" .IP "COPTS.lib<lib> OBJCCOPTS.lib<lib> LDADD.lib<lib> CPPFLAGS.lib<lib> CXXFLAGS.lib<lib>" +.\" These provide a way to specify additions to the associated +.\" variables in a way that applies only to a particular +.\" library. <lib> corresponds to a LIB variable. +.\" For example, if COPTS.libfoobar is +.\" set to "-g", "-g" will be added to COPTS only when compiling +.\" the "libfoobar" library. +.PP +Libraries are ranlib'd when made. +.B mkc.lib.mk +includes +.B mkc.files.mk +and therefore supports all variables supported by it. +.SS "mkc.subprj.mk" +The include file +.B mkc.subprj.mk +handles subprojects (subdirectories) +organized as a dependency graph. +It provides all targets provided by +.BR mkc.prog.mk . +Variable SUBPRJ contains a list of pairs +.I depdir:dir +which mean that subproject +.I dir +depends on +.IR depdir. +.B mkcmake all +command will build all subprojects listed in SUBPRJ in a correct +order (starting with subprojects having no dependencies and so on). +There is also a target which allows the command +.I "bmake <subdir>" +where +<subdir> +is any directory listed in +the variable SUBPRJ. +The following targets are also provided: +<target>-<subdir> +where +<target> +is either of the following: +all, clean, cleandir, depend, installdirs, install, uninstall and filelist. +Also provided are: targets +nodeps-<target>-<subdir> and subdir-<target>-<subdir>. +Difference between +<target>-<subdir> +and +nodeps-<target>-<subdir> +is that +.B "mkcmake <target>-<subdir>" +runs the specified +<target> +for +<subdir> +and all its dependencies while +.B "mkcmake nodeps-<target>-<subdir>" +-- only for +<subdir>. A target subdir-<target>-<subdir> is a synonym for nodeps-<target>-<subdir> +See +.I examples/hello_dictd +subdirectory for the sample of use. +.IP SUBPRJ +List of subprojects (subdirectories) and dependencies. If the +subdirectory doesn't exist the subproject becomes "virtual" and may be +used to group several subprojects into a new virtual one. +.RI < "M" > +.IP SUBPRJ_DFLT +List of projects built and installed by default. +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 +List of variables excluded from EXPORT_VARNAMES. +.RI < "Mu" > +.RI [ "" ] +.IP NODEPS +This variable specifies a list of patterns that describes edges from dependency +graph in +.IR targdep-prjdep : targ-prj +or +.IR targ-prj : targ +formats to be excluded from dependency graph. +.RI < "M" > +.RI [] +.IP NOSUBDIR +If for some reason you want to exclude some subdirectories from build, +list them in this variable. +.RI < "U" > +.RI [ "" ] +.IP OBJDIR_<dir> +Value of ${.OBJDIR} inside +.I dir +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 TARGETS +List of recursive targets supported by the project and all its subprojects. +.RI < "Im" > +.RI [ all ", " install ", " installdirs ", " uninstall ", " clean ", " +.IR cleandir ", " depends ", " test ", " errorcheck ", " filelist ] +By setting this variable in the Makefile one can add new targets for special +purposes, for example, static code analysis, partial builds etc. +.IP SHORTPRJNAME +If "yes", special targets with last component of the subprojects are provided. +.RI < "Im" > +.RI [ yes ] +.IP MKRELOBJDIR +If "yes", object directories +.RI ${TOPOBJ}/ dir +are used. Unlike MAKEOBJDIRPREFIX object directories do not contain +top-level ${.CURDIR} in paths. +.RI < "Iu" > +.RI [ no ] +.SS "mkc.subdir.mk" +The include file +.B mkc.subdir.mk +contains the default targets for building +subdirectories. +It provides the same targets as +.BR mkc.prog.mk . +For all of +the directories listed in the variable SUBDIR, the specified directory +will be visited and the target made. There is also a default target which +allows the command +.I "bmake <subdir>" +where +.I "<subdir>" + is any directory listed in +the variable SUBDIR. +As a special case, the use of a token .WAIT +as an entry in SUBDIR acts +as a synchronization barrier when multiple make jobs are run; subdirs +before the .WAIT +must complete before any subdirs after .WAIT are +started. See +.B bmake(1) +for some caveats on use of .WAIT and other +special sources. SUBDIR variable is provided as well as all variables provided +by mkc.subprj.mk except SUBPRJ. +.IP SUBDIR +List of subdirectories +.RI < "M" > +.B mkc.subprj.mk +.SS "mkc.configure.mk" +.B mkc.configure.mk +is an auxiliary include file for checking platform's features +like headers, function or variable declarations, function implementation +in a particular libraries, data types sizes etc. +This include file is included by +.BR mkc.prog.mk " and " mkc.lib.mk +automatically +but in some cases it makes sense to include it explicitly. +.B mkc.configure.mk +supports the following variables. +.IP MKCHECKS +If "no", none of the checks are performed. It is set to "yes" unless target +is "clean", "cleandir or distclean". +.IP MKC_CHECK_HEADERS +List of headers to be checked. +As a result of the check bmake's variable +.B HAVE_HEADER.<header> +is set to +either 0 or 1. +.br +<header>: tr|./|__|g +.br +Also -DHAVE_HEADER_<HEADER>=(0 or 1) +is added to CFLAGS unless MKC_NOAUTO is set to 1. +.br +<HEADER>: tr|a-z./|A-Z__|g +.VS + Ex: MKC_CHECK_HEADERS += sys/time.h fcntl.h execinfo.h + Res: HAVE_HEADER.sys_time_h = 1 + HAVE_HEADER.fcntl_h = 1 + HAVE_HEADER.execinfo_h = 1 + CFLAGS += -DHAVE_HEADER_SYS_TIME_H=1 -DHAVE_HEADER_FCNTL=1 +.VE +.IP MKC_REQUIRE_HEADERS +The same as MKC_CHECK_HEADERS, but absense of header is +treated as a fatal error (See +.B errorcheck +target. +.IP MKC_CHECK_FUNCLIBS +List of <function>:<library> pairs to be checked, +<library> part is optional. If <library> is present, +presense of <function> in libc is also checked automatically. + +As a result of the check bmake's variable +HAVE_FUNCLIB.<function>.<library> (or HAVE_FUNCLIB.<function>) +is set to either 0 or 1. + +By default, if <function> is found in <library> but not in libc, +"-l<library>" is automatically added to LDADD unless +<function>:<library> is listed in MKC_NOAUTO_FUNCLIBS or +MKC_NOAUTO_FUNCLIBS is equal to 1 or +MKC_NOAUTO is set to 1 +.VS + Ex: MKC_CHECK_FUNCLIBS += strlcat fgetln getline getopt_long + MKC_CHECK_FUNCLIBS += crypt:crypt dlopen:dl nanosleep:rt + MKC_CHECK_FUNCLIBS += ftime:compat gettimeofday + MKC_NOAUTO_FUNCLIBS += ftime:compat + Res: HAVE_FUNCLIB.strlcat = 1 + HAVE_FUNCLIB.fgetln = 1 + HAVE_FUNCLIB.getline = 0 + HAVE_FUNCLIB.getopt_long = 1 + HAVE_FUNCLIB.crypt = 0 + HAVE_FUNCLIB.crypt.crypt = 1 + HAVE_FUNCLIB.dlopen = 1 + HAVE_FUNCLIB.dlopen.dl = 0 + HAVE_FUNCLIB.nanosleep = 1 + HAVE_FUNCLIB.nanosleep.rt = 1 + HAVE_FUNCLIB.ftime = 0 + HAVE_FUNCLIB.ftime.compat = 1 + HAVE_FUNCLIB.gettimeofday = 1 + LDADD += -lcrypt +.VE +.IP MKC_REQUIRE_FUNCLIBS +The same as MKC_CHECK_FUNCLIBS, but absense of funclib is +treated as a fatal error (See +.B errorcheck +target. +.IP MKC_SOURCE_FUNCLIBS +The same as MKC_CHECK_FUNCLIBS, but if <function> is absent +both in the specified <library> and in libc, function.c is +added to SRCS unless MKC_NOAUTO=1. +.VS + Ex: MKC_SOURCE_FUNCLIBS+= getline + Res: SRCS+= getline.c + HAVE_FUNCLIB.getline= 0 +.VE +.IP MKC_CHECK_DEFINES +List of define:header to check. <header> part is optional. + +As a result of the check bmake's variable +HAVE_DEFINE.<define>.<header> (or HAVE_DEFINE.<define>) +is set to either 0 or 1. +.br +<header>: tr|./|__|g +.br +Also -DHAVE_DEFINE_<DEFINE>_<HEADER>=1 +or -DHAVE_DEFINE_<DEFINE>=1 +is added to CFLAGS if the specified define was detected +unless MKC_NOAUTO is set to 1. +.br +<HEADER>: tr|a-z./|A-Z__|g +.br +<DEFINE>: tr|a-z|A-Z|g +.VS + Ex: MKC_CHECK_DEFINES += RTLD_LAZY:dlfcn.h __GNUC__ _MSC_VER_ + Res: HAVE_DEFINE.RTLD_LAZY.dlfcn_h = 1 + HAVE_DEFINE.__GNUC__ = 1 + HAVE_DEFINE._MSC_VER_ = 0 + CFLAGS += -DHAVE_DEFINE_RTLD_LAZY_DLFCN_H=1 \\ + -DHAVE_DEFINE___GNUC__=1 +.VE +.IP MKC_REQUIRE_DEFINES +The same as MKC_CHECK_DEFINES, but absense of the define is +treated as a fatal error (See +.B errorcheck +target. +.IP MKC_CHECK_TYPES +List of type:header to check. <header> part is optional. + +As a result of the check bmake's variable +HAVE_TYPE.<type>.<header> (or HAVE_TYPE.<type>) +is set to either 0 or 1. +.br +<header>: tr|./|__|g + +Also -DHAVE_TYPE_<TYPE>_<HEADER>=1 (or -DHAVE_TYPE_<TYPE>=1) +is added to CFLAGS if the specified type was detected +unless MKC_NOAUTO is set to 1. +.br +<HEADER>: tr|a-z./|A-Z__|g +.br +<TYPE>: tr|a-z|A-Z|g +.VS + Ex: MKC_CHECK_TYPES += size_t:string.h + Res: HAVE_TYPE.size_t.string_h = 1 + CFLAGS += -DHAVE_TYPE_SIZE_T_STRING_H=1 +.VE +.IP MKC_REQUIRE_TYPES +The same as MKC_CHECK_TYPES, but absense of the type declaration is +treated as a fatal error (See +.B errorcheck +target. +.IP MKC_CHECK_VARS +List of variable:header to check. <header> part is optional. + +As a result of the check bmake's variable +HAVE_DEFINE.<variable>.<header> (or HAVE_DEFINE.<variable>) +is set to either 0 or 1 +.br +<header>: tr|./|__|g +.br +Also -DHAVE_DEFINE_<VARIABLE>_<HEADER>=1 +(or -DHAVE_DEFINE_<VARIABLE>=1) +is added to CFLAGS if the specified variable was detected +unless MKC_NOAUTO is set to 1. +.br +<HEADER>: tr|a-z./|A-Z__|g +.VS + Ex: MKC_CHECK_VARS += sys_errlist:errno.h + Res: HAVE_VAR.sys_errlist.errno_h = 1 + CFLAGS += -DHAVE_VAR_SYS_ERRLIST_ERRNO_H +.VE +.IP MKC_REQUIRE_VARS +The same as MKC_CHECK_VARS, but absense of the variable declaration is +treated as a fatal error (See +.B errorcheck +target. +.IP MKC_CHECK_MEMBERS +List of <type>.<member>:<header> to check. +<header> part is optional. + +As a result of the check bmake's variable +HAVE_MEMBER.<type>_<member>.<header> +(or HAVE_MEMBER.<type>_<member>) +is set to either 0 or 1 depending on the result. +.br +<header>: tr|./|__|g +.br +Also -DHAVE_MEMBER_<TYPE>_<MEMBER>_<HEADER>=1 +(or -DHAVE_MEMBER_<TYPE>_<MEMBER>=1) +is added to CFLAGS if the specified member was found in +appropriate type +unless MKC_NOAUTO is set to 1. +.br +<HEADER>: tr|a-z./|A-Z__|g +.br +<TYPE>: tr|a-z./|A-Z__|g +.br +<MEMBER>: tr|a-z./|A-Z__|g +.VS + Ex: MKC_CHECK_VARS += struct-ifreq.ifr_ifrn.ifrn_name:net/if.h + MKC_CHECK_VARS += struct-tm.tm_isdst:time.h + Res: HAVE_MEMBER.struct_ifreq_ifr_ifrn_ifrn_name.net_if_h=1 + HAVE_MEMBER.struct_tm_tm_isdst.time_h=1 + CFLAGS += -DHAVE_MEMBER_STRUCT_IFREQ_IFR_IFRN_IFRN_NAME_NET_IF_H=1 + CFLAGS += -DHAVE_MEMBER_STRUCT_TM_TM_ISDST_TIME_H=1 +.VE +.IP MKC_REQUIRE_MEMBERS +The same as MKC_CHECK_MEMBERS, but absense of the member is +treated as a fatal error (See +.B errorcheck +target. +.IP MKC_CHECK_FUNCS<N> +List of <func>:<header> to be check. <header> part is optional. + +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. +.br +<header>: tr|./|__|g +.br +Also -DHAVE_FUNC<N>_<FUNC>_<HEADER>=(0 or 1) +(or -DHAVE_FUNC<N>_<FUNC>=(0 or 1)) +is added to CFLAGS if the specified function was detected +unless MKC_NOAUTO is set to 1. +.br +<HEADER>: tr|a-z./|A-Z__|g +.VS + Ex: MKC_CHECK_FUNCS2 += fgetln:stdio.h + MKC_CHECK_FUNCS6 += pselect:sys/select.h + Res: HAVE_FUNC2.fgetln.stdio_h = 1 + HAVE_FUNC6.pselect.sys.select_h = 1 + CFLAGS += -DHAVE_FUNC2_FGETLN_STDIO_H=1 \\ + += -DHAVE_FUNC6_PSELECT_SYS_SELECT_H=1 +.VE +.IP MKC_REQUIRE_FUNCS<N> +The same as MKC_CHECK_FUNCS<N>, but absense of the function declaration is +treated as a fatal error (See +.B errorcheck +target. +.IP MKC_CHECK_CUSTOM +A list of custom checks (list of names). +MKC_CUSTOM_FN.<custom_check_name> is a +"C", "C++" or "Fortran" source filename or an executable program +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. +If MKC_CUSTOM_FN.<custom_check_name> is unset, it +defaults to custom_check_name.c + +Also -DCUSTOM_<CUSTOM_CHECK_NAME>=1 +is added to CFLAGS if the specified check succeeded +unless MKC_NOAUTO is set to 1. +.br +<CUSTOM_CHECK_NAME>: tr|a-z|A-Z|g +.VS + Ex. MKC_CHECK_CUSTOM+= nested_funcs + MKC_CUSTOM_FN.nested_funcs= nested_funcs.c + MKC_CUSTOM_FN.script_check= checks/script_check + Res. CUSTOM.nested_funcs= 1 + CUSTOM.script_check= 0 + CFLAGS+= -DCUSTOM_NESTED_FUNCS=1 +.VE +Note that script for the check should be an executable file. +.IP MKC_REQUIRE_CUSTOM +The same as MKC_CHECK_CUSTOM, but failure is +treated as a fatal error (See +.B errorcheck +target. 0 and empty value of CUSTOM.xxx means failure. +.IP MKC_CUSTOM_DIR +Directory with custom checks source files. +See MKC_CHECK_CUSTOM. It defaults to ${.CURDIR}. +.IP MKC_CHECK_BUILTINS +.B mk-configure +provides a number of built-in custom checks, that is, source files +to compile or scripts to run in order to check for something. +Checks listed in MKC_CHECK_BUILTINS will be run. +.RS +Avalable values: +.TP +.BR prog_flex ", " prog_bison ", " prog_gawk ", " prog_gm4 +Find flex, bison, GNU awk or GNU m4 by analysing program's help and/or +version messages. If found, BUILTIN.prog_<progname> is set to a path, +otherwise it is set to an empty string. Note that +.I gawk +may be found as +.IR awk , +.I bison +as +.IR yacc , +.I gm4 +as +.IR m4 +and +.I flex +as +.IR lex . +.TP +.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 +.IR little ", " big " or " unknown +depending on a hardware. +.RE +.IP MKC_CHECK_PROGS +List of <progname>s to check. +As a result of the check bmake's variable +HAVE_PROG.<progname> is set to either 1 (true) or 0 (false). +Also PROG.<progname> is set to a full path of a program +or to an empty string. +.VS + Ex: MKC_CHECK_PROGS += lua ruby gawk runawk + Res: HAVE_PROG.lua = 1 + PROG.lua = /usr/pkg/bin/lua + HAVE_PROG.ruby = 0 + HAVE_PROG.gawk = 1 + PROG.gawk = /usr/bin/gawk + HAVE_PROG.runawk = 1 + PROG.runawk = /usr/pkg/bin/runawk +.VE +If MKC_PROG.id.<progname> is set to, e.g, <prog_id>, +then HAVE_PROG.<prog_id> and PROG.<prog_id> are set. +MKC_PROG.id.<progname> also changes cache file names. +.IP MKC_REQUIRE_PROGS +The same as MKC_CHECK_PROGS, but absense of program is +treated as a fatal error (See +.B errorcheck +target). +.IP MKC_CHECK_SIZEOF +List of <type>:<header> to check. <header> part is optional. + +As a result of the check bmake's variable +SIZEOF.<type>.<header> (or SIZEOF.<type>) +is set to the data type size or string "failed". +.br +<type>: tr|*-|P_|g +.br +<header>: tr|/.|__|g +.br +Also -DSIZEOF_<TYPE>_<HEADER>=<failed|1|2|...> +(or -DSIZEOF_<TYPE>=<failed|1|2|...>) +is added to CFLAGS +if sizeof() check was successful +unless MKC_NOAUTO is set to 1 +.br +<TYPE>: tr|a-z*-|A-ZP_|g +.br +<HEADER>: tr|a-z/.|A-Z__|g +.br +.VS + Ex: MKC_CHECK_SIZEOF += void* + MKC_CHECK_SIZEOF += long-long off_t:sys/types.h + Res: SIZEOF.voidP = 4 + SIZEOF.long_long = 4 + SIZEOF.off_t.sys_types_h = 8 + CFLAGS += -DSIZEOF_VOIDP=4 \\ + -DSIZEOF_LONG_LONG=4 \\ + -DSIZEOF_OFF_T_SYS_TYPES_H=8 +.VE +.IP MKC_NOAUTO_FUNCLIBS +See MKC_CHECK_FUNCLIBS +.IP MKC_NOAUTO +See MKC_CHECK_{HEADERS,FUNCLIBS,FUNCS,VARS,DEFINES,SIZEOF}. +.IP MKC_COMMON_HEADERS +List of header files always #include'd to the test .c file +in MKC_CHECK_{DEFINES,VARS,FUNCS<N>,SIZEOF} checks. +The default value is an empty list. +.VS + Ex: MKC_COMMON_HEADERS += unistd.h stdlib stdio.h string.h + MKC_CHECK_SIZEOF += offs_t size_t ssize_t +.VE +.IP MKC_COMMON_DEFINES +List of defines always passed to compiler +in MKC_CHECK_{DEFINES,VARS,FUNCS<N>,SIZEOF} checks. +.VS + Ex: MKC_COMMON_DEFINES += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 # Linux + MKC_COMMON_DEFINES += -D_ALL_SOURCE # Interix +.VE +.IP MKC_COMMON_DEFINES.<OPSYS> +The same as MKC_COMMON_DEFINES but only for OPSYS (uname -s). +.VS + Ex: MKC_COMMON_DEFINES.Linux += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 + MKC_COMMON_DEFINES.Interix += -D_ALL_SOURCE +.VE +.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/...). +.IP MKC_SHOW_CACHED +Setting it to 0 will hide +.VS + Checking ... (cached) ... +.VE +messages, that is, messages about fetching results from cache files. +.IP MKC_DELETE_TMPFILES +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 +is internal include file which is included from +.BR mkc.prog.mk ", " mkc.lib.mk " and " mkc.files.mk . +Do not use it directly! +It provides installing and uninstalling the scripts. +The following variables are provided: +.IP SCRIPTS +A list of interpreter scripts (written in shell, awk, lua etc). +These are installed like programs. +.RI < "M" > +.IP SCRIPTSNAME +The name that the above program will be installed as, if +different from ${SCRIPTS}. +.RI < "Mu" > +.IP SCRIPTSNAME_<script> +Optional name to install <script> as. If <script> has a form +<subdir>/<filename>, SCRIPTSNAME_<subdir>_<filename> is used. +.RI < "Mu" > +.IP SCRIPTSDIR +Target directory for scripts. +.RI < "Iu" > +.RI [ ${BINDIR} ] +.IP SCRIPTSDIR_<script> +Optional directory to install <script> to. If <script> has a form +<subdir>/<filename>, SCRIPTSDIR_<subdir>_<filename> is used. +.RI < "Mu" > +.IP SCRIPTSOWN +Script files owner. +.RI < "Iu" > +.RI [ ${BINOWN} ] +.IP SCRIPTSGRP +Script file group. +.RI < "Iu" > +.RI [ ${BINGRP} ] +.IP SCRIPTSMODE +Script file mode. +.RI < "Iu" > +.RI [ ${BINMODE} ] +.SS "mkc_imp.lua.mk" +.B mkc_imp.lua.mk +is internal include file which is included from +.BR mkc.prog.mk " and " mkc.lib.mk . +Do not use it directly. +It provides support for Lua programming language, i.e. building and installing +Lua- and/or C-based modules. +The following variables are provided: +.IP LUA_MODULES +List of Lua modules to build and install. +Dot in the module name separates a dirname from basename. That is, +actual .lua file names are made of LUA_MODULES with dots replaced with undeline symbol. +At installation time dots are replaced with slash. For example, if +LUA_MODULES=socket.foo, then socket_foo.lua will be installed to +${LUA_LMODDIR}/socket/foo.lua +.RI < "M" > +.\" .IP LUA_SRCS.<mod> +.\" Sources for each module +.\" .RI [ ${mod:S/./_/g}.lua ] +.\" .RI < M > +.IP LUA_LMODULES +Deprecated. Filenames of Lua modules. Use +.I LUA_MODULES +instead. +.RI < "M" > +.IP LUA_CMODULE +Compiled Lua module written in, e.g., C or C++. +Dot in the module name separates a dirname from basename. That is, +actual .c file names are made of LUA_MODULES with dots replaced with undeline symbol. +At installation time dots are replaced with slash. For example, if +LUA_CMODULES=socket.foo, then socket_foo.c will be used for compiling a module and +will be installed to ${LUA_CMODDIR}/socket/foo.so. +.RI < "M" > +.IP SRCS +List of source files to build the LUA_CMODULE. +SRCS defaults to +.IR ${LUA_CMODULE:S|.|_|g}.c . +.RI < "M" > +.IP LUA_LMODDIR +Directory for Lua modules written in Lua. It is assigned +with a help of +.I "pkg-config --variable=INSTALL_LMOD lua" +command and can be overriden by user. +.RI < "Iu" > +.IP LUA_CMODDIR +Directory for compiled Lua modules written in, e.g., C or C++. +It is assigned with a help of +.I "pkg-config --variable=INSTALL_CMOD lua" +command and can be overriden by user. +.RI < "Iu" > +.SS "mkc_imp.intexts.mk" +.B mkc_imp.intexts.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. +It provides conversion of <fn>.in files to <fn> by +expanding the following @@ patterns: +.\" .TS +.\" tab(:), center, box; +.\" c | c +.\" l | l. +.\" Pattern:Result +.\" _ +.\" @prefix@:${PREFIX} +.\" @bindir@:${BINDIR} +.\" @mandir@:${MANDIR} +.\" @sbindir@:${SBINDIR} +.\" @libdir@:${LIBDIR} +.\" @libexecdir@:${LIBEXECDIR} +.\" @datadir@:${DATADIR} +.\" @sysconfdir@:${SYSCONFDIR} +.\" @incsdir@:${INCSDIR} +.\" .TE +.ne 11 +.VS + Pattern Result +---------------------- +@prefix@ ${PREFIX} +@bindir@ ${BINDIR} +@mandir@ ${MANDIR} +@sbindir@ ${SBINDIR} +@libdir@ ${LIBDIR} +@libexecdir@ ${LIBEXECDIR} +@datadir@ ${DATADIR} +@sysconfdir@ ${SYSCONFDIR} +@incsdir@ ${INCSDIR} +.VE +The following variables are provided: +.IP INFILES +List of files to generate. +.RI < "M" > +.IP INSCRIPTS +List of scripts to generate. +.RI < "M" > +.IP INTEXTS_REPLS +List of Pattern/Replacement pairs separated by space, e.g. +.VS + INTEXTS_REPLS+= version ${VERSION} + INTEXTS_REPLS+= author_email ${AUTHOR_EMAIL} +.VE +.RI < "M" > +.IP INTEXTS_SED +List of additional +.B sed(1) +expressions for expanding, e.g. +.VS + INTEXTS_SED+= -e 's,@version@,${VERSION},g' +.VE +.RI < "M" > +.SS "mkc_imp.info.mk" +.B mkc_imp.info.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! +This module provides creation of .info files from .txi, .texi and .texinfo sources +and provides the following variables: +.IP MKINFO +If "no", don't build or install Info documentation from +Texinfo source files. +.RI < "Iu" > +.RI [ yes ] +.IP TEXINFO +List of Texinfo source files. Info documentation will +consist of single files with the extension replaced by .info. +.RI < "M" > +.IP INFOFLAGS +Flags to pass to makeinfo. [] +.RI < "Iu" > +.SS "mkc_imp.man.mk" +.B mkc_imp.man.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! +This module provides installation of manual pages and creation of catpages +and HTML pages and provides the following variables: +.IP MANDIR +Target directory for man pages. +.RI < "Iu" > +.RI [ ${PREFIX}/man ] +.IP USETBL +If not "no", preprocess man pages using +.B tbl(1) +while generating cat pages. +.RI < "IM" > +.RI [ no ] +.IP MANZ +If not "no", compress manual pages at installation time. +.RI < "Iu" > +.RI [ no ] +.IP MAN +Manual pages (should end in .1 - .9). If no MAN variable is +defined, "MAN=${PROG}.1" is assumed if it exists. +.RI < "M" > +.IP MKMAN +If "no", don't build or install the man pages, +and also acts as "MKCATPAGES=no MKHTML=no". +.RI < "Iu" > +.RI [ yes ] +.IP MKCATPAGES +If "no", don't build or install the catman pages. +.RI < "Iu" > +.RI [ no ] +.IP MKHTML +If "no", don't build or install the HTML man pages. +.RI < "Iu" > +.RI [ no ] +.IP HTMLDIR +Target directory for html pages generated from man pages. +.RI < "Iu" > +.RI [ ${MANDIR} ] +.IP MLINKS +List of manual page links (using a .1 - .9 suffix). The +linked-to file must come first, the linked file second, +and there may be multiple pairs. The files are hard-linked. +.RI < "M" > +.SS "mkc_imp.links.mk" +.B mkc_imp.links.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! This module provides creation of hard and symbolic +links and provides the following variables: +.IP LINKS +The list of binary links; should be full pathnames, the +linked-to file coming first, followed by the linked +file. The files are hard-linked. For example, to link +${BINDIR}/gzip and ${BINDIR}/gunzip, use: +.VS + LINKS= ${DESTDIR}/bin/gzip ${DESTDIR}${BINDIR}/gunzip +.VE +.RI < "M" > +.IP SYMLINKS +The list of symbolic links; should be full pathnames. +Syntax is identical to LINKS. Note that DESTDIR is not +automatically included in the link. +.RI < "M" > +.SS "mkc_imp.inc.mk" +.B mkc_imp.inc.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! +This module provides installation of header files and provides +the following variables: +.IP INCSDIR +Target directory for includes. +.RI < "Iu" > +.RI [ ${PREFIX}/include ] +.IP INCS +The list of include files. +.RI < "M" > +.IP INCSNAME +Target name of the include file, if only one; same as +FILESNAME, but for include files. +.RI < "M" > +.IP INCSNAME_<file> +The name file <file> should be installed as, if not <file>, +same as FILESNAME_<file>, but for include files. +.RI < "Mu" > +.IP INCSSRCDIR +Source directory for include files. This variable have an influence on +CPPFLAGS (-I${INCSSRCDIR} is added) and on an installation of include files +(paths in ${INCS} are relative to ${INCSSRCDIR}). +.RI < "M" > +.RI [ . ] +.SS "mkc.minitest.mk" +.B mkc.minitest.mk +is an auxiliary include file that implement simple framework for unit +tests. Idea: application provides the target test_output and +expect.out file that contains ideal output. "bmake test" runs "bmake +test_output" and compare generated output with expect.out. +.IP TEST_PREREQS +Prerequisites for target "test". +.RI < "Iu" > +.RI [ all ] +.SS "mkc_imp.pkg-config.mk" +.B mkc_imp.pkg-config.mk +is internal include file which is included from +.BR mkc.prog.mk " and " mkc.lib.mk . +Do not use it directly! +This module supports dependencies controlled by +.B pkg-config +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. +.RI < "M" > +.IP PKG_CONFIG.exists.<lib> +If "1", <lib> exists, "0" otherwise. +Inside <lib> <=, >=, =, < and > and replaced with +_le_, _ge_, _eq_, _lt_ and _gt_ respectively. +.RI < "Iu" > +.IP PKG_CONFIG_VARS.<lib> +List of variables to check for library <lib>. +.RI < "M" > +.IP PKG_CONFIG.var.<lib>.<var> +Variable value (pkg-config --variable=<var> <lib>). +.RI < "Iu" > +.IP PCNAME.<lib> +On some systems several versions of the same library may be installed +to differet directories (for example liblua for Lua 5.1 and 5.2). +In order to avoid conflicts between them pc name is changed +(for example, lua5.1 and lua5.2 instead of lua). +This variable is a map from library name to pc name. +.RI < "Iu" > +.RI [ ${lib} ] +.SS "mkc_imp.pod.mk" +.B mkc_imp.pod.mk +is internal include file which is included from +.BR mkc.prog.mk " and " mkc.lib.mk . +Do not use it directly! +It provides support for POD (Plain Old Documentation) markup language, +i.e. convertion of POD documents to MAN pages +(suffix rules: .pod.1, ... , .pod.9) and HTMLs +(.pod.html). +The following variables are provided: +.IP POD2MAN +Path to POD to MAN conversion utility +.RI < "Iu" > +.RI [ pod2man ]. +.IP POD2MAN_FLAGS +Flags passed to ${POD2MAN} +.RI < "Iu" > +.RI [ "-r '' -n '${.TARGET:T:R}' -c ''" ]. +.IP POD2HTML +Path to POD to HTML conversion utility +.RI < "Iu" > +.RI [ pod2html ]. +.IP POD2HTML_FLAGS +Flags passed to ${POD2HTML} +.RI < "Iu" > +.RI [ "" ]. +.SS "mkc_imp.dep.mk" +.B mkc_imp.dep.mk +is internal include file which is included from +.BR mkc.prog.mk " and " mkc.lib.mk . +Do not use it directly! This include file contains the default +targets for building .depend files. It creates .d files from entries +in SRCS and DPSRCS that are C, C++, or Objective C source files, and +builds .depend from the .d files. All other files in SRCS and all of +DPSRCS will be used as dependencies for the .d files. +The following variables are provided: +.IP SRCS +The same as in +.B mkc.prog.mk +and +.BR mkc.lib.mk . +.IP DPSRCS +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. +.IP SYSROOT +Root directory for headers and libraries. +If set, the following variables +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 TOOLCHAIN_DIR +Directory that contains cross-toolchain. +.RI < "U" > +.RI [ "${TOOLDIR}/bin" ]. +.IP TOOLCHAIN_PREFIX +See SYSROOT. +.RI < "U" > +.RI [ "${MACHINE_GNU_PLATFORM}-" ]. +.SH "ENVIRONMENT VARIABLES" +.IP MAKECONF +Path to mk.conf file .include-ed by mkc.*.mk files +.SH "FILES" +.IP @sysconfdir@/mk.conf + .include-ed by mkc.*.mk if exists +.IP /etc/mk.conf + .include-ed by mkc.*.mk if exists +.SH "BUGS" +Target +.IR errorcheck " (" configure ")" +doesn't support parallel builds. In order to build project in parallel, +run it like the following +.VS + mkcmake errorcheck + mkcmake -j4 all +.VE +.SH "SEE ALSO" +.BR mkc_check_header (1), +.BR mkc_check_prog (1), +.BR mkc_check_decl (1), +.BR mkc_check_funclib (1), +.BR mkc_check_sizeof (1), +.BR mkc_check_custom (1), +.BR bmake (1), +.BR mkdep (1), +.SH AUTHOR +Aleksey Cheusov <vle@gmx.net> diff --git a/scripts/mkc_check_common.sh b/scripts/mkc_check_common.sh new file mode 100644 index 0000000..8daff04 --- /dev/null +++ b/scripts/mkc_check_common.sh @@ -0,0 +1,95 @@ +# Copyright (c) 2009-2010 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +# include file, not executable +# common variables and functions for mkc_check_xxx executables + +if test "$pathpart" = ''; then + echo "You've found a bug, please contact the author" 1>&2 + exit 1 +fi + +MKC_CACHEDIR=${MKC_CACHEDIR:-.} +CC=${CC:-cc} + +tmpc=$MKC_CACHEDIR/_mkc_${pathpart}${MKC_NOCACHE}.c +tmpo=$MKC_CACHEDIR/_mkc_${pathpart}${MKC_NOCACHE}.o +tmperr=$MKC_CACHEDIR/_mkc_${pathpart}${MKC_NOCACHE}.err +tmpexe=$MKC_CACHEDIR/_mkc_${pathpart}${MKC_NOCACHE}.exe +cache=$MKC_CACHEDIR/_mkc_${pathpart}${MKC_NOCACHE}.res + +printme (){ + if test "$MKC_VERBOSE" != 1; then + return + fi + + if test "$MKC_SHOW_CACHED" = 1 || test -z "$cached"; then + printf "$@" + fi +} + +cleanup (){ + rm -f "$tmpexe" "$tmpo" + if test "$MKC_DELETE_TMPFILES" = 1; then + if test "$KEEP_SOURCE" != 1; then + rm -f "$tmpc" + fi + + rm -f "$tmperr" + fi +} + +cleanup_all (){ + MKC_DELETE_TMPFILES=1 + KEEP_SOURCE=0 + rm -f "$cache" + cleanup +} + +check_and_cache (){ + # $1 - message + # $2 - cache file name + # $@ - args... + + _msg="$1" + _cache="$2" + shift; shift + + if test "$MKC_NOCACHE" != 1 && test -f "$_cache"; then + cached=1 + printme '%s' "$_msg... (cached) " 1>&2 + ret=`cat "$cache"` + else + printme '%s' "$_msg... " 1>&2 + + # test itself + ret=`check_itself "$@" 2>"$tmperr"` + if test "$MKC_NOCACHE" = 1; then + rm -f $tmpc $tmpo $tmpexe $tmperr + else + echo "$ret" > "$_cache" + fi + fi +} + +find_n_match (){ + # $1 - progname + # $2 - opts + # $3 - regexp for matching + __prog=`which $1 2>/dev/null` + + if test -n "$__prog" && + "$__prog" $2 2>/dev/null < /dev/null | + grep -i "$3" > /dev/null + then + echo "$__prog" + exit 0 + fi +} + +if test -n "$delcache"; then + cleanup_all + exit 0 +fi diff --git a/scripts/mkc_check_compiler b/scripts/mkc_check_compiler new file mode 100755 index 0000000..2945f24 --- /dev/null +++ b/scripts/mkc_check_compiler @@ -0,0 +1,69 @@ +#!/bin/sh + +############################################################ +# Copyright (c) 2009-2010 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +set -e + +LC_ALL=C +export LC_ALL + +: ${TMPDIR:=/tmp} + +tmpfile="$TMPDIR/mk-c.$$.c" +trap 'rm -f "$tmpfile"' 0 + +################################################## + +pathpart=compiler_type +if test "$1" = -x; then + pathpart=cxx_type + CC="$CXX" + export CC +fi + +################################################## +checks=' + __clang__ clang + __ICC icc +__INTEL_COMPILER icc + __PCC__ pcc + __GNUC__ gcc + _MSC_VER msc + __HP_aCC hpc + __HP_cc hpc + __SUNPRO_C sunpro + __SUNPRO_CC sunpro + __IBMCPP__ ibmc + __IBMC__ ibmc + __BORLANDC__ bcc + __WATCOMC__ watcom + __COMO__ como + __DECC decc + __DECCXX decc +_COMPILER_VERSION mipspro +' + +check_itself (){ + awk ' +BEGIN { + printf "#" + for (i=1; i < ARGC; ++i){ + printf "if defined(%s)\ncompiler %s\n#el", ARGV [i], ARGV [i+1] + } + printf "se\ncompiler unknown\n#endif\n" +}' $checks >"$tmpfile" + $CC -E "$tmpfile" | + awk 'BEGIN { ret="unknown"} $1 == "compiler" {ret=$2; exit} END {print ret}' +} + +. mkc_check_common.sh + +check_and_cache "checking for compiler type" "$cache" + +printme '%s\n' "$ret" 1>&2 + +echo "$ret" diff --git a/scripts/mkc_check_custom b/scripts/mkc_check_custom new file mode 100755 index 0000000..5213d29 --- /dev/null +++ b/scripts/mkc_check_custom @@ -0,0 +1,180 @@ +#!/bin/sh + +############################################################ +# Copyright (c) 2009-2010 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +set -e + +LC_ALL=C +export LC_ALL + +################################################## +# options +usage (){ + cat <<'EOF' +mkc_check_custom - tries to compile source file specified by user, + optionally builds and runs an application, and + returns the result (1 - build succeded, 0 - build failed, + other value returned by built application) + +Usage: + mkc_check_custom [OPTIONS] source_file + mkc_check_custom [OPTIONS] cmd [args...] + +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 + `basename <source_file>` without extension + -m A part of verbose message, defaults to -n args + -s exit status of executable will be check + -d delete cache files +Examples: + mkc_check_custom my_custom_test.c + mkc_check_custom -r mmap_works_perfectly.c +EOF +} + +if test $# -eq 0; then + usage + exit 1 +fi +if test "_$1" = '_-h'; then + usage + exit 0 +fi + +while test $# -ne 0; do + case "$1" in + -r) + runit=1;; + -p) + pref="$2" + shift;; + -n) + basefn="$2" + shift;; + -m) + msg="$2" + shift;; + -s) + check_status=1;; + -d) + delcache=1;; + -*) + echo "Bad option $1" 1>&2 + exit 1;; + *) + break; + esac + shift +done + +if test $# -lt 1; then + usage + exit 1 +fi + +################################################## +# initializing +if test -z "$basefn"; then + basefn=`basename $1 | sed 's|[.][^.]*$||'` +fi +pathpart="${pref-custom}_$basefn" + +. mkc_check_common.sh + +src_or_exe="$1" + +shquote (){ + __cmd=`printf '%s\n' "$1" | sed "s|'|'\\\\\''|g"` + printf "%s\n" "'$__cmd'" +} + +for i in "$@"; do + cmd="$cmd "`shquote "$1"` + shift +done + +################################################## +# functions + +compile (){ + if $CC -c -o "$tmpo" $CPPFLAGS $CFLAGS "$src_or_exe" 2>"$tmperr"; then + echo 1 + else + echo 0 + fi +} + +check_itself (){ + if test -x "$src_or_exe"; then + if test -n "$check_status"; then + set +e # workaround for buggy FreeBSD shell + if eval "$cmd"; then + echo 1 + else + echo 0 + fi + set -e # workaround for buggy FreeBSD shell + else + eval "$cmd" + fi + return 0 + else + case "$src_or_exe" in + *.c) + compiler="$CC" + flags="-c -o $tmpo $CFLAGS $CPPFLAGS $src_or_exe";; + *.cc|*.C|*.cxx|*.cpp) + compiler="$CXX" + flags="-c -o $tmpo $CXXFLAGS $CPPFLAGS $src_or_exe";; + *.f) + compiler="$FC" + flags="-c -o $tmpo $FFLAGS $src_or_exe";; + *) + echo 'Bad filename for custom check. What to do?' 1>&2 + return 1 + esac + fi + + if test -z "$compiler"; then + echo "Bad compiler for $src_or_exe. What to do?" 1>&2 + return 1 + fi + + if $compiler $flags; then + echo 1 + else + echo 0 + fi +} + +################################################## +# test +msg=${msg-"custom test $basefn"} +check_and_cache "checking for ${msg}" "$cache" + +################################################## +# clean-ups + +KEEP_SOURCE=1 # do not delete user's source file! +cleanup + +################################################## +# finishing + +case "$ret" in + 1) + printme '1 (yes)\n' 1>&2;; + 0) + printme '0 (no)\n' 1>&2;; + *) + printme '%s\n' "$ret" 1>&2;; +esac + +echo $ret diff --git a/scripts/mkc_check_custom.1 b/scripts/mkc_check_custom.1 new file mode 100644 index 0000000..6ea2845 --- /dev/null +++ b/scripts/mkc_check_custom.1 @@ -0,0 +1,100 @@ +.\" $NetBSD$ +.\" +.\" Copyright (c) 2009-2010 by Aleksey Cheusov (vle@gmx.net) +.\" Absolutely no warranty. +.\" +.\" ------------------------------------------------------------------ +.de VS \" Verbatim Start +.ft CW +.nf +.ne \\$1 +.. +.de VE \" Verbatim End +.ft R +.fi +.. +.\" ------------------------------------------------------------------ +.TH MKC_CHECK_CUSTOM 1 "Nov 22, 2009" "" "" +.SH NAME +mkc_check_custom \- run user's custom checks. +.SH SYNOPSIS +.BI mkc_check_custom " [-r] <file>" +.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, +.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 +extension. '.c' corresponds to +.I ${CC} +(C language), '.cc', '.cxx', '.C' and '.cpp' correspond to +.I ${CXX} +(C++ language), '.f' -- to +.I ${FC} +(Fortran). +.SH OPTIONS +.TP +.B "-h" +display help message +.SH ENVIRONMENT +.TP +.B CC +C compiler +.TP +.B CXX +C++ compiler +.TP +.B FC +Fortran compiler +.TP +.B CPPFLAGS +Preprocessor flags for C and C++ +.TP +.B CFLAGS +Compilation flags for C +.TP +.B CXXFLAGS +Compilation flags for C++ +.TP +.B FFLAGS +Compilation flags for Fortran +.TP +.B MKC_VERBOSE +If set to 1, verbose messages are output to stderr. +.TP +.B MKC_SHOW_CACHED +If set to 1 and MKC_VERBOSE is set to 1, cached results +are output to stderr. +.TP +.B MKC_CACHEDIR +Directory where temporary and cache files are created. +If unset they are created in a current directory. +.TP +.B MKC_NOCACHE +All results are cached unless MKC_NOCACHE variable is set +to 1. +.TP +.B MKC_DELETE_TMPFILES +If set to 1, temporary files are removed. +.SH EXAMPLES +.VS + mkc_check_custom alloca_in_stdlib.c + mkc_check_custom custom_checks/cxx_foo_test.cc + mkc_check_custom /full/path/to/yacc_need_liby +.VE +.SH AUTHOR +Aleksey Cheusov <vle@gmx.net> diff --git a/scripts/mkc_check_decl b/scripts/mkc_check_decl new file mode 100755 index 0000000..e0cb8ea --- /dev/null +++ b/scripts/mkc_check_decl @@ -0,0 +1,236 @@ +#!/bin/sh + +############################################################ +# Copyright (c) 2009-2010 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +set -e + +LC_ALL=C +export LC_ALL + +if test -d /usr/xpg4/bin; then + # We cannot work with Solaris' default usercrap + PATH=/usr/xpg4/bin:$PATH + export PATH +fi + +################################################## +# options +usage (){ + cat <<EOF +mkc_check_decl detects presense of define, variable, function or type +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" + +OPTIONS: + -h display this help + -d delete cache files + +Examples: + mkc_check_decl define __GNUC__ + mkc_check_decl define RTLD_LAZY dlfcn.h + mkc_check_decl variable sys_errlist errno.h + mkc_check_decl variable __malloc_hook malloc.h + mkc_check_decl func3 poll poll.h + mkc_check_decl func2 fgetln stdio.h + mkc_check_decl type mbstate_t wchar.h + 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 +EOF +} + +if test $# -eq 0; then + usage + exit 1 +fi +if test "_$1" = '_-h'; then + usage + exit 0 +fi +if test "_$1" = '_-d'; then + delcache=1 + shift +fi + +################################################## +# initializing + +decltype=`echo $1 | sed -e 's/[0-9]//g'` +argscnt=`echo $1 | sed 's/[^0-9]//g'` +shift + +declwhat=`echo $1 | sed 's/-/ /'` +shift + +if test "$decltype" = type; then + pathpart=`echo ${decltype}_${declwhat}_$* | tr '/. ' '__~'` +else + pathpart=`echo $decltype$argscnt $declwhat $* | tr '/. ' '___'` +fi + +. mkc_check_common.sh + +################################################## +# functions + +get_includes (){ + for i in $MKC_COMMON_HEADERS "$@"; do + echo "#include <$i>" + done +} + +############################## +compile (){ + if $CC -c -o "$tmpo" $CPPFLAGS $CFLAGS "$tmpc" 2>"$tmperr" + then + return 0 + else + return 1 + fi +} + +############################## +is_define (){ + get_includes "$@" > "$tmpc" + + cat >> "$tmpc" <<EOF +#if defined($declwhat) +int main () +{ + return 0; +} +#else +.error "$declwhat is not a define" +#endif +EOF + + # + compile +} + +############################## +is_variable (){ + get_includes "$@" > "$tmpc" + + cat >> "$tmpc" <<EOF +int main () +{ + return sizeof (($declwhat)) && (&$declwhat != 0); +} +EOF + # + compile +} + +############################## +has_size (){ + get_includes "$@" > "$tmpc" + + cat >> "$tmpc" <<EOF +int main () +{ + return sizeof ($declwhat); +} +EOF + + # + compile +} + +is_type (){ + has_size "$@" || return 1 + is_variable "$@" && return 1 + return 0 +} + +############################## +is_func (){ + get_includes "$@" > "$tmpc" + + cat >> "$tmpc" <<EOF +void func (void) +{ + if (${declwhat}) return; + ${declwhat} ( +EOF + + awk -v N="$argscnt" ' +BEGIN { + for (i=0; i < N; ++i){ + if (i) + printf "," + printf "0" + } +} +' >> "$tmpc" + + printf ');\n}\n' >> "$tmpc" + + # + compile +} + +############################## +is_member (){ + get_includes "$@" > "$tmpc" + + type_t=`echo $declwhat | sed 's/[.].*$//'` + member=`echo $declwhat | sed 's/^[^.]*[.]//'` + + cat >> "$tmpc" <<EOF +int main () +{ + $type_t var; + return sizeof (var.$member); +} +EOF + + # + compile +} + +################################################## +# test + +for i in "$@"; do + incs_msg="$incs_msg $i" +done + +if test -n "$incs_msg"; then + incs_msg=" ($incs_msg )" +fi + +check_itself (){ + if is_${decltype} "$@" + then + echo 1 + else + echo 0 + fi +} + +check_and_cache "checking for $decltype ${declwhat}${incs_msg}" "$cache" "$@" + +################################################## +# clean-ups + +cleanup + +################################################## +# finishing + +if test "$ret" -eq 1; then + printme 'yes\n' 1>&2 +else + printme 'no\n' 1>&2 +fi + +echo $ret diff --git a/scripts/mkc_check_decl.1 b/scripts/mkc_check_decl.1 new file mode 100644 index 0000000..bc1866e --- /dev/null +++ b/scripts/mkc_check_decl.1 @@ -0,0 +1,85 @@ +.\" $NetBSD$ +.\" +.\" Copyright (c) 2009-2010 by Aleksey Cheusov (vle@gmx.net) +.\" Absolutely no warranty. +.\" +.\" ------------------------------------------------------------------ +.de VS \" Verbatim Start +.ft CW +.nf +.ne \\$1 +.. +.de VE \" Verbatim End +.ft R +.fi +.. +.\" ------------------------------------------------------------------ +.TH MKC_CHECK_DECL 1 "Mar 15, 2009" "" "" +.SH NAME +mkc_check_decl \- checks for define, function, variable or type. +.SH SYNOPSIS +.BI mkc_check_decl " <check_type> <what> [includes...]" +.br +.BI mkc_check_decl " -h" +.SH DESCRIPTION +.I check_type +is either +.IR " define" , " variable" , " func[0-9]" , " type " or " member" . +Depending on its value +.B mkc_check_decl +checks for define, variable, function with specified number +of arguments, type or a member of structure +in a specified header files +.I includes +by compiling a test program. +As a result it prints either 1 (success) or 0 (failure) to stdout. +.SH OPTIONS +.TP +.B "-h" +display help message +.SH ENVIRONMENT +.TP +.B CC +Compiler. By default +.I cc +is used. +.TP +.B CPPFLAGS, CFLAGS +Options passed to the compiler, for example -I for additional directories +that contain header files. +.TP +.B MKC_VERBOSE +If set to 1, verbose messages are output to stderr. +.TP +.B MKC_SHOW_CACHED +If set to 1 and MKC_VERBOSE is set to 1, cached results +are output to stderr. +.TP +.B MKC_COMMON_HEADERS +List of header files to add to .c test program. +.TP +.B MKC_CACHEDIR +Directory where temporary and cache files are created. +If unset they are created in a current directory. +.TP +.B MKC_NOCACHE +All results are cached unless MKC_NOCACHE variable is set +to 1. +.TP +.B MKC_DELETE_TMPFILES +If set to 1, temporary files are removed. +.SH EXAMPLES +.VS + mkc_check_decl define __GNUC__ + mkc_check_decl define RTLD_LAZY dlfcn.h + mkc_check_decl variable sys_errlist errno.h + mkc_check_decl variable __malloc_hook malloc.h + mkc_check_decl func3 poll poll.h + mkc_check_decl func2 fgetln stdio.h + mkc_check_decl type mbstate_t wchar.h + 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 +.VE +.SH AUTHOR +Aleksey Cheusov <vle@gmx.net> diff --git a/scripts/mkc_check_funclib b/scripts/mkc_check_funclib new file mode 100755 index 0000000..6b3ba4b --- /dev/null +++ b/scripts/mkc_check_funclib @@ -0,0 +1,119 @@ +#!/bin/sh + +############################################################ +# Copyright (c) 2009-2010 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +set -e + +LC_ALL=C +export LC_ALL + +################################################## +# options +usage (){ + cat <<EOF +mkc_check_funclib detects presense of function in a library +by compiling and linking a test program. + +Usage: mkc_check_funclib [OPTIONS] function [libraries...] + +OPTIONS: + -h display this help + -d delete cache files + +Examples: + mkc_check_funclib dlopen dl + mkc_check_funclib dlopen + mkc_check_funclib strlcpy + mkc_check_funclib select socket +EOF +} + +if test $# -eq 0; then + usage + exit 1 +fi +if test "_$1" = '_-h'; then + usage + exit 0 +fi +if test "_$1" = '_-d'; then + delcache=1 + shift +fi + +################################################## +# initializing + +pathpart=funclib_`echo $* | tr '/. ' ___` + +funcname=$1 +shift + +. mkc_check_common.sh + +for i in "$@"; do + LDADD="$LDADD -l$i" + libs_msg="$libs_msg -l$i" +done + +if test -n "$libs_msg"; then + libs_msg=" ($libs_msg )" +fi + +################################################## +# test + +check_itself (){ + # preparations + if test "$funcname" = main; then + fname=__fake__ + else + fname="$funcname" + fi + + cat > "$tmpc" <<EOF +static void __fake__ () {} + +void $fname (); + +int main () +{ + $fname (); + return 0; +} +EOF + + # test itself + if $CC -o "$tmpexe" "$tmpc" $LDFLAGS $LDADD 2>"$tmperr"; then + echo 1 + else + # SunPro may leave object files in current directory. + # We need not this garbage. Also we cannot use smart shell + # expansions because of crappy Solaris' /bin/sh. + tmpbase=`basename "$tmpc" | sed 's/[.][^.]*$//'` + rm -f ${tmpbase}.o + echo 0 + fi +} + +check_and_cache "checking for function ${funcname}${libs_msg}" "$cache" "$@" + +################################################## +# clean-ups + +cleanup + +################################################## +# finishing + +if test "$ret" -eq 1; then + printme 'yes\n' 1>&2 +else + printme 'no\n' 1>&2 +fi + +echo $ret diff --git a/scripts/mkc_check_funclib.1 b/scripts/mkc_check_funclib.1 new file mode 100644 index 0000000..edf4f1a --- /dev/null +++ b/scripts/mkc_check_funclib.1 @@ -0,0 +1,76 @@ +.\" $NetBSD$ +.\" +.\" Copyright (c) 2009-2010 by Aleksey Cheusov (vle@gmx.net) +.\" Absolutely no warranty. +.\" +.\" ------------------------------------------------------------------ +.de VS \" Verbatim Start +.ft CW +.nf +.ne \\$1 +.. +.de VE \" Verbatim End +.ft R +.fi +.. +.\" ------------------------------------------------------------------ +.TH MKC_CHECK_FUNCLIB 1 "Mar 15, 2009" "" "" +.SH NAME +mkc_check_funclib \- detects presense of function in a library. +.SH SYNOPSIS +.BI mkc_check_funclib " <functionname>" " [libraries...]" +.br +.BI mkc_check_funclib " -h" +.SH DESCRIPTION +.B mkc_check_funclib +detects presense of function in a library +by compiling and linking a test program. +As a result it prints either 1 (true) or 0 (false) to stdout. +.SH OPTIONS +.TP +.B "-h" +display help message +.SH ENVIRONMENT +.TP +.B CC +Compiler. By default +.I cc +is used. +.TP +.B CPPFLAGS, CFLAGS +Options passed to the compiler, for example -I for additional directories +that contain header files. +.TP +.B LDFLAGS +Options passed to the linker (compiler, set by CC variable), for example, +-L/usr/local/lib +.TP +.B LDADD +Extra libraries, for example, -lm. +.TP +.B MKC_VERBOSE +If set to 1, verbose messages are output to stderr. +.TP +.B MKC_SHOW_CACHED +If set to 1 and MKC_VERBOSE is set to 1, cached results +are output to stderr. +.TP +.B MKC_CACHEDIR +Directory where temporary and cache files are created. +If unset they are created in a current directory. +.TP +.B MKC_NOCACHE +All results are cached unless MKC_NOCACHE variable is set +to 1. +.TP +.B MKC_DELETE_TMPFILES +If set to 1, temporary files are removed. +.SH EXAMPLES +.VS + mkc_check_funclib dlopen dl + mkc_check_funclib dlopen + mkc_check_funclib strlcpy + mkc_check_funclib select socket +.VE +.SH AUTHOR +Aleksey Cheusov <vle@gmx.net> diff --git a/scripts/mkc_check_header b/scripts/mkc_check_header new file mode 100755 index 0000000..9398c3a --- /dev/null +++ b/scripts/mkc_check_header @@ -0,0 +1,85 @@ +#!/bin/sh + +############################################################ +# Copyright (c) 2009-2010 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +set -e + +LC_ALL=C +export LC_ALL + +################################################## +# options +usage (){ + cat <<EOF +mkc_check_header detects presense of header file +by compiling a test program. + +Usage: mkc_check_header [OPTIONS] header.h + +Examples: + mkc_check_header stdint.h + mkc_check_header getopt.h +EOF +} + +if test $# -eq 0; then + usage + exit 1 +fi +if test "_$1" = '_-h'; then + usage + exit 0 +fi +if test "_$1" = '_-d'; then + delcache=1 + shift +fi + +################################################## +# initializing + +pathpart=header_`echo $1 | tr /. __` + +. mkc_check_common.sh + +################################################## +# test + +check_itself (){ + cat > "$tmpc" <<EOF +#include <$1> +int main () +{ + return 0; +} +EOF + + if $CC -c -o "${tmpo}" $CPPFLAGS $CFLAGS "${tmpc}" 2>"${tmperr}" + then + echo 1 + else + echo 0 + fi +} + +check_and_cache "checking for header $1" "$cache" "$@" + +################################################## +# clean-ups + +cleanup + +################################################## +# finishing + +if test "$ret" -eq 1; then + printme 'yes\n' 1>&2 +else + printme 'no\n' 1>&2 +fi + +echo $ret diff --git a/scripts/mkc_check_header.1 b/scripts/mkc_check_header.1 new file mode 100644 index 0000000..bd8bab7 --- /dev/null +++ b/scripts/mkc_check_header.1 @@ -0,0 +1,66 @@ +.\" $NetBSD$ +.\" +.\" Copyright (c) 2009-2010 by Aleksey Cheusov (vle@gmx.net) +.\" Absolutely no warranty. +.\" +.\" ------------------------------------------------------------------ +.de VS \" Verbatim Start +.ft CW +.nf +.ne \\$1 +.. +.de VE \" Verbatim End +.ft R +.fi +.. +.\" ------------------------------------------------------------------ +.TH MKC_CHECK_HEADER 1 "Mar 15, 2009" "" "" +.SH NAME +mkc_check_header \- detects presense of header file. +.SH SYNOPSIS +.BI mkc_check_header " <header>" +.br +.BI mkc_check_header " -h" +.SH DESCRIPTION +.B mkc_check_header +detects presense of header file by compiling a test program. +As a result it prints either 1 (true) or 0 (false) to stdout. +.SH OPTIONS +.TP +.B "-h" +display help message +.SH ENVIRONMENT +.TP +.B CC +Compiler. By default +.I cc +is used. +.TP +.B CPPFLAGS, CFLAGS +Options passed to the compiler, for example -I for additional directories +that contain header files. +.TP +.B MKC_VERBOSE +If set to 1, verbose messages are output to stderr. +.TP +.B MKC_SHOW_CACHED +If set to 1 and MKC_VERBOSE is set to 1, cached results +are output to stderr. +.TP +.B MKC_CACHEDIR +Directory where temporary and cache files are created. +If unset they are created in a current directory. +.TP +.B MKC_NOCACHE +All results are cached unless MKC_NOCACHE variable is set +to 1. +.TP +.B MKC_DELETE_TMPFILES +If set to 1, temporary files are removed. +.SH EXAMPLES +.VS + mkc_check_header stdint.h + mkc_check_header getopt.h +.VE +.SH AUTHOR +Aleksey Cheusov <vle@gmx.net> diff --git a/scripts/mkc_check_prog b/scripts/mkc_check_prog new file mode 100755 index 0000000..bf4a58e --- /dev/null +++ b/scripts/mkc_check_prog @@ -0,0 +1,91 @@ +#!/bin/sh + +############################################################ +# Copyright (c) 2009-2010 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +set -e + +LC_ALL=C +export LC_ALL + +################################################## +# options +usage (){ + cat <<EOF +mkc_check_prog detects presense of program file. + +Usage: mkc_check_prog [OPTION] progname + +OPTIONS: + -h display this screen + -i <progid> program id, a part of _mkc_* cache file + -d delete cache files +Examples: + mkc_check_prog -h + mkc_check_prog lua + mkc_check_prog gawk + mkc_check_prog -i gxx g++ +EOF +} + +while test $# -ne 0; do + case "$1" in + -h) + usage + exit 0;; + -i) + pathpart=prog_$2 + shift;; + -d) + delcache=1;; + --) + shift + break;; + -*) + echo "Unknown option $1" 1>&2 + exit 1;; + *) + break;; + esac + shift +done + +if test $# -ne 1; then + usage + exit 1 +fi + +################################################## +# initializing + +pathpart=${pathpart-prog_`echo $1 | tr /. __`} + +. mkc_check_common.sh + +################################################## +# test + +check_itself (){ + mkc_which -x "$1" 2>"${tmperr}" +} + +check_and_cache "checking for program $1" "$cache" "$1" + +################################################## +# clean-ups + +cleanup + +################################################## +# finishing + +if test -n "$ret"; then + printme "$ret\n" 1>&2 +else + printme 'NOT FOUND\n' 1>&2 +fi + +echo $ret diff --git a/scripts/mkc_check_prog.1 b/scripts/mkc_check_prog.1 new file mode 100644 index 0000000..979897a --- /dev/null +++ b/scripts/mkc_check_prog.1 @@ -0,0 +1,69 @@ +.\" $NetBSD$ +.\" +.\" Copyright (c) 2009-2010 by Aleksey Cheusov (vle@gmx.net) +.\" Absolutely no warranty. +.\" +.\" ------------------------------------------------------------------ +.de VS \" Verbatim Start +.ft CW +.nf +.ne \\$1 +.. +.de VE \" Verbatim End +.ft R +.fi +.. +.\" ------------------------------------------------------------------ +.TH MKC_CHECK_PROG 1 "Aug 29, 2009" "" "" +.SH NAME +mkc_check_prog \- detects presense of header file. +.SH SYNOPSIS +.BI mkc_check_prog " <progname>" +.br +.BI mkc_check_prog " -h" +.SH DESCRIPTION +.B mkc_check_prog +takes a name and looks for the file with that name which would be +executable. Executable is searched for along the user's PATH. +If appropriate executable is found, a path to it is printed. +Otherwise, an error message is printed and +.B mkc_check_prog +exits with error. +.SH OPTIONS +.TP +.B "-h" +Display help message. +.TP +.BI -i " progid" +.I progid +will be used as a part of _mkc_* cache file name. +.SH ENVIRONMENT +.TP +.B PATH +List of colon-separated directories. +.TP +.B MKC_VERBOSE +If set to 1, verbose messages are output to stderr. +.TP +.B MKC_SHOW_CACHED +If set to 1 and MKC_VERBOSE is set to 1, cached results +are output to stderr. +.TP +.B MKC_CACHEDIR +Directory where temporary and cache files are created. +If unset they are created in a current directory. +.TP +.B MKC_NOCACHE +All results are cached unless MKC_NOCACHE variable is set +to 1. +.TP +.B MKC_DELETE_TMPFILES +If set to 1, temporary files are removed. +.SH EXAMPLES +.VS + mkc_check_prog gawk + mkc_check_prog c++ + mkc_check_prog lua +.VE +.SH AUTHOR +Aleksey Cheusov <vle@gmx.net> diff --git a/scripts/mkc_check_sizeof b/scripts/mkc_check_sizeof new file mode 100755 index 0000000..5b35387 --- /dev/null +++ b/scripts/mkc_check_sizeof @@ -0,0 +1,108 @@ +#!/bin/sh + +############################################################ +# Copyright (c) 2009-2010 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +set -e + +LC_ALL=C +export LC_ALL + +################################################## +# options +usage (){ + cat <<EOF +mkc_check_sizeof detects sizeof(type) +by compiling a test program. +mkc_check_sizeof doesn't run a generated executable +and therefore is ready for cross-compiling. + +Usage: mkc_check_sizeof type [headers...] + +Examples: + mkc_check_sizeof 'void*' + mkc_check_sizeof long-long + mkc_check_sizeof size_t stdlib.h +EOF +} + +if test $# -eq 0; then + usage + exit 1 +fi +if test "_$1" = '_-h'; then + usage + exit 0 +fi + +################################################## +# initializing + +type=`echo $1 | tr ' -' ' '` +pathpart=sizeof_`echo $type | tr '* ' 'P~'` +shift + +. mkc_check_common.sh + +################################################## +# test + +try_it (){ + # succeedes if size is bad + # $1 - test size + # $2.. - #includes + sz=$1 + shift + + for f in $MKC_COMMON_HEADERS "$@"; do + echo "#include <$f>" + done > "$tmpc" + cat >> "$tmpc" <<EOF +int main () +{ + switch (0){ + case sizeof ($type): break; + case $sz: break; + } + return 0; +} +EOF + + if $CC -c -o "${tmpo}" $CPPFLAGS $CFLAGS "${tmpc}" 2>"${tmperr}"; then + return 0 + else + return 1 + fi +} + +check_itself (){ + if try_it 2147483647 "$@" + then + for sz in 4 8 2 1 16 12 3 5 6 7 9 10 11 13 14 15; do + if try_it $sz "$@" + then + : + else + echo $sz + return + fi + done + fi + echo failed +} + +check_and_cache "checking for sizeof ${type}" "$cache" "$@" + +################################################## +# clean-ups + +cleanup + +################################################## +# finishing + +printme "$ret\n" 1>&2 +echo $ret diff --git a/scripts/mkc_check_sizeof.1 b/scripts/mkc_check_sizeof.1 new file mode 100644 index 0000000..81b6136 --- /dev/null +++ b/scripts/mkc_check_sizeof.1 @@ -0,0 +1,72 @@ +.\" $NetBSD$ +.\" +.\" Copyright (c) 2009-2010 by Aleksey Cheusov (vle@gmx.net) +.\" Absolutely no warranty. +.\" +.\" ------------------------------------------------------------------ +.de VS \" Verbatim Start +.ft CW +.nf +.ne \\$1 +.. +.de VE \" Verbatim End +.ft R +.fi +.. +.\" ------------------------------------------------------------------ +.TH MKC_CHECK_SIZEOF 1 "Mar 15, 2009" "" "" +.SH NAME +mkc_check_sizeof \- detects a sizeof(type). +.SH SYNOPSIS +.BI mkc_check_sizeof " type [headers...]" +.br +.BI mkc_check_sizeof " -h" +.SH DESCRIPTION +.B mkc_check_sizeof +detects sizeof( +.I type +) by compiling a test program. +mkc_check_sizeof doesn't run a generated executable +and therefore is ready for using a cross-compiler. +.I headers +are #include-d. +.SH OPTIONS +.TP +.B "-h" +display help message +.SH ENVIRONMENT +.TP +.B CC +Compiler. By default +.I cc +is used. +.TP +.B CPPFLAGS, CFLAGS +Options passed to the compiler, for example -I for additional directories +that contain header files. +.TP +.B MKC_VERBOSE +If set to 1, verbose messages are output to stderr. +.TP +.B MKC_SHOW_CACHED +If set to 1 and MKC_VERBOSE is set to 1, cached results +are output to stderr. +.TP +.B MKC_CACHEDIR +Directory where temporary and cache files are created. +If unset they are created in a current directory. +.TP +.B MKC_NOCACHE +All results are cached unless MKC_NOCACHE variable is set +to 1. +.TP +.B MKC_DELETE_TMPFILES +If set to 1, temporary files are removed. +.SH EXAMPLES +.VS + mkc_check_sizeof 'void*' + mkc_check_sizeof long-long + mkc_check_sizeof size_t stdlib.h +.VE +.SH AUTHOR +Aleksey Cheusov <vle@gmx.net> diff --git a/scripts/mkc_check_version.in b/scripts/mkc_check_version.in new file mode 100755 index 0000000..79ca154 --- /dev/null +++ b/scripts/mkc_check_version.in @@ -0,0 +1,39 @@ +#!@AWK@ -f + +############################################################ +# Copyright (c) 2009-2010 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +# +# usage: _mkc_check_version <reqd> <version> +# example: _mkc_check_version 0.9.0 0.10.0 +# + +BEGIN { + reqd = ARGV [1] + ver = ARGV [2] + + cnt= split(reqd, arr_reqd, /[.]/) + if (cnt != 3){ + print "Invalid MKC_REQD " reqd > "/dev/stderr" + print 0 + exit 0 + } + + cnt= split(ver, arr_ver, /[.]/) + if (cnt != 3){ + print "Invalid MKC_VERSION " ver > "/dev/stderr" + print 0 + exit 0 + } + + ver = sprintf("%04d.%04d.%04d", + arr_ver [1]+0, arr_ver [2]+0, arr_ver [3]+0) + reqd = sprintf("%04d.%04d.%04d", + arr_reqd [1]+0, arr_reqd [2]+0, arr_reqd [3]+0) + + print (reqd <= ver) + exit 0 +} diff --git a/scripts/mkc_install b/scripts/mkc_install new file mode 100755 index 0000000..913753b --- /dev/null +++ b/scripts/mkc_install @@ -0,0 +1,189 @@ +#!/bin/sh +# +# install - install a program, script, or datafile +# This comes from X11R5 (mit/util/scripts/install.sh). +# +# Copyright 1991 by the Massachusetts Institute of Technology +# Copyright 2013 by Aleksey Cheusov <vle@gmx.net> +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of M.I.T. not be used in advertising or +# publicity pertaining to distribution of the software without specific, +# written prior permission. M.I.T. makes no representations about the +# suitability of this software for any purpose. It is provided "as is" +# without express or implied warranty. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. It can only install one file at a time, a restriction +# shared with many OS's install programs. + + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +instcmd="$mvprog" +chmodcmd="$chmodprog 0755" +chowncmd="" +chgrpcmd="" +stripcmd="" +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src="" +dst="" +dir_arg="" + +while [ x"$1" != x ]; do + case $1 in + -c) instcmd="$cpprog" + shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + -s) stripcmd="$stripprog" + shift + continue;; + + *) if [ x"$src" = x ]; then + src=$1 + else + dst=$1 + fi + shift + continue;; + esac +done + +if [ x"$src" = x ]; then + echo "install: no input file specified" + exit 1 +else + true +fi + +if [ x"$dir_arg" != x ]; then + dst=$src + + if [ -d $dst ]; then + instcmd=: + chmodcmd="" + else + instcmd="$mkdirprog -p" + fi +else + +# Waiting for this to be detected by the "$instcmd $src $dsttmp" command +# might cause directories to be created, which would be especially bad +# if $src (and thus $dsttmp) contains '*'. + + if [ -f $src -o -d $src ]; then + true + else + echo "install: $src does not exist" + exit 1 + fi + + if [ x"$dst" = x ]; then + echo "install: no destination specified" + exit 1 + else + true + fi + +# If destination is a directory, append the input filename; if your system +# does not like double slashes in filenames, you may need to add some logic + + if [ -d $dst ]; then + dst="$dst"/`basename $src` + else + true + fi +fi + +## +dstdir=`dirname $dst` + +if [ x"$dir_arg" != x ]; then + $doit $instcmd $dst && + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi +else +# Make sure that the destination directory exists. + if [ ! -d "$dstdir" ]; then + $mkdirprog -p "$dstdir" 2>/dev/null + fi + +# No renaming of the final executable + dstfile=`basename $dst` + +# Make a temp file name in the proper directory. + + dsttmp=$dstdir/#inst.$$# + +# Move or copy the file name to the temp name + + $doit $instcmd $src $dsttmp && + + trap "rm -f ${dsttmp}" 0 && + +# and set any options; do chmod last to preserve setuid bits + +# If any of these fail, we abort the whole thing. If we want to +# ignore errors from any of these, just make sure not to ignore +# errors from the above "$doit $instcmd $src $dsttmp" command. + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && + +# Now rename the file to the real destination. + + $doit $rmcmd -f $dstdir/$dstfile && + $doit $mvcmd $dsttmp $dstdir/$dstfile + +fi && + + +exit 0 diff --git a/scripts/mkc_which b/scripts/mkc_which new file mode 100755 index 0000000..9b764a4 --- /dev/null +++ b/scripts/mkc_which @@ -0,0 +1,41 @@ +#!/bin/sh + +############################################################ +# Copyright (c) 2009-2012 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +# Portable replacement for which(1) + +if test "$1" = "-x"; then + failure=0 + shift +else + failure=1 +fi + +if test $# -ne 1; then + cat <<EOF +usage: mkc_which [-x] program + -x -- exit status is always 0 +EOF + exit 1 +fi + +if echo "$1" | grep '^/' > /dev/null; then + if test -x "$1"; then + echo $1 + exit 0 + fi +else + for i in `echo $PATH|tr : ' '`; do + if test -x "$i/$1" -a -f "$i/$1"; then + echo $i/$1 + exit 0 + fi + done +fi + +echo "Cannot find $1" >&2 +exit $failure diff --git a/scripts/mkcmake.1 b/scripts/mkcmake.1 new file mode 100644 index 0000000..5757e77 --- /dev/null +++ b/scripts/mkcmake.1 @@ -0,0 +1,48 @@ +.\" $NetBSD$ +.\" +.\" Copyright (c) 2010 by Aleksey Cheusov (vle@gmx.net) +.\" Absolutely no warranty. +.\" +.\" ------------------------------------------------------------------ +.de VB \" Verbatim Begin +.ft CW +.nf +.ne \\$1 +.. +.de VE \" Verbatim End +.ft R +.fi +.. +.\" ------------------------------------------------------------------ +.TH MKCMAKE 1 "August 10, 2012" "" "" +.SH NAME +mkcmake \- wrapper for bmake using mk-configure's Mk files and sys.mk +.SH SYNOPSIS +.BI mkcmake " [bmake options]" +.SH DESCRIPTION +.B mkcmake +is a trivial wrapper for NetBSD make +.RB ( bmake ) +that uses +mk-configure's Mk files and sys.mk. +In all other aspects it is full equivalent of +.BR bmake . +.SH OPTIONS +See +.BR bmake . +.SH EXAMPLES +.VB +mkcmake +mkcmake all +mkcmake -f makefile cleandir +.VE +.SH ENVIRONMENT VARIABLES +.IP MKC_BMAKE +Path to +.BR bmake +overriding compile-time default. +.SH SEE ALSO +.BR bmake(1) , +.BR mk-configure(7) +.SH AUTHOR +Aleksey Cheusov <vle@gmx.net> diff --git a/scripts/mkcmake.in b/scripts/mkcmake.in new file mode 100644 index 0000000..b2d3fe7 --- /dev/null +++ b/scripts/mkcmake.in @@ -0,0 +1,5 @@ +#!/bin/sh + +BMAKE=${MKC_BMAKE-@BMAKE@} + +$BMAKE -m @mkfilesdir@ "$@" |