.\" $NetBSD$ .\" .\" This file contains parts of NetBSD's bsd.README file .\" .\" Copyright (c) 2009-2020 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 "Jan 21, 2021" "" "" .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 There are only a few top-level makefiles: .BR mkc.init.mk ", " mkc.mk ", " mkc.configure.mk ", " mkc.minitest.mk . Everything else .RB ( mkc_imp.*.mk " files)" is included implicitely. Do not use .B mkc_imp.*.mk files directly! If you do, I cannot guarantee backward compatibility. .B mkc.configure.mk is included automatically by .BR mkc.mk , but can be included explicitely. .B mkc.minitest.mk provides a trivial support for regression tests and should be included explicitely. Usually mk-c makefiles consist of variables assignments and inclusion of .B mkc.mk in the and. One can also use .BR mkc.prog.mk ", " mkc.lib.mk ", " mkc.files.mk ", " mkc.subdir.mk " and " mkc.subprj.mk instead of .BR mkc.mk . The latter activates .B mkc.lib.mk if variable LIB is set, .B mkc.prog.mk if variables PROG or PROGS are set, .B mkc.subprj.mk if variable SUBPRJ is set, .B mkc.subdir.mk if variable SUBDIR is set, and .B mkc.files.mk otherwise. .B .P To get system-wide configuration parameters, .B mkc.init.mk loads "${MAKECONF}" file if it exists. Otherwise, it loads /etc/mkcmake.conf if it exists. If neither ${MAKECONF} nor /etc/mkcmake.conf exist, it tries to load /etc/mk.conf file. If "${SRCTOP}/Makefile.common" file exists it is also included by all subprojects. Unless SRCTOP variable is set, "../Makefile.inc" is also included if exists. These files may define any of the variables described below. Compiler-specific defaults are also loaded from "~/.mkcmake" or system directories. This compiler-specific defaults are determined at build time or with the help of .B mkc_compiler_settings utility. .P 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" Mk-configure provides the following targets: .IP all build everything. .IP clean clean temporary files and directories with the 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 installdirs create target directories. .IP install install programs, libraries, files, include files, manual pages etc. to the target directories with the help of ${INSTALL} program. .IP uninstall remove installed files with the help of ${UNINSTALL} command. .IP configure check for MKC_ERR_MSG variable and fails if it set printing an error message .IP depend create .depend_${.CURDIR:T} 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. .VE .IP mkgen .RB See " mkc_imp.foreign_autotools.mk" . .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/files for the sample. .P .B NOTE: Commands associated with targets .IR all ", " install ", " clean ", " cleandir ", " depend ", " test ", " installdirs ", " uninstall ", " configure " and " filelist in Makefile override the standard behaviour. .P .B NOTE: All targets in this list have .IR pre\_* ", " do\_* " and " post\_* counterparts. See ALLTARGETS for details. .SS "mkc.init.mk" This file is included by .BR mkc.mk " and " mkc.configure.mk automatically but can be used by users directly. .B mkc.init.mk uses the following variables. .IP AFLAGS Options to ${CC} when compiling or linking .s or .S assembly source files. [] .\" .IP ADDR2LINE .\" Path to addr2line. [addr2line] .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 BINDIR Target directory for utilities. .RI < "Iu Mu" > .RI [ ${PREFIX}/bin ] .IP BMAKE_REQD Minimal required version of .BR bmake . If it is older, .B mkcmake exits with error. .RI < "Im" > .IP BZIP2 bzip2 copression tool. .RI < Iu > .RI [ bzip2 ] .IP CC C compiler. .RI < Iu > .RI [ cc ] .IP CC_PREFIX Prefix command for ${CC}, for example, distcc or ccache. .RI < Iu > .RI [ "" ] .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 armcc ARM 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" > .RI [ no ] .IP CC_VERSION C compiler version. .RI < "I" > .IP CCSTD Add C language standard command line option to the compiler. Supported options: .IR c89 ", " gnu89 " (C89 with GNU extensions), " c99 ", " gnu99 \ " (C99 with GNU extensions), " c11 ", " gnu11 " (C89 with GNU extensions), " \ c17 ", " gnu17 " (C17 with GNU extensions)." If compiler is not known for mk-configure or does not support appropriate option, no additional options are applied. .RI < M > .RI [ "" ] .IP CFLAGS Additional flags to the compiler when creating C objects. .RI < "IM" > .IP CFLAGS0 The same as CFLAGS but CFLAGS0 is passed to the compiler before CFLAGS. Normally, CFLAGS0 should be modified in makefiles and should not be set from environment by user. .RI < "M" > .IP CFLAGS.check Same as CFLAGS but every option is checked whether it is a valid one for C compiler. Double underline in the flag is considered as a single space character. .RI < M > .RI [ unset ] .IP "CFLAGS.dflt., CXXFLAGS.dflt." 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 "CFLAGS.warns.., CXXFLAGS.warns.." 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_ Similar to CFLAGS but for project ${PROJECTNAME}. .RI < "U" > .IP CFLAGS_ Similar to CFLAGS but for the specified source file. Basename of the source file is used. .RI < "Mu" > .IP CLEANDIRS_CMD Command for removing directories used by targets "clean" and "cleandir". .RI < Iu > .RI [ "${RM} -rf" ] .IP CLEANFILES_CMD Command for removing files used by targets "clean" and "cleandir". .RI < Iu > .RI [ "${RM} -f" ] .IP COPTS Additional flags to the compiler when creating C objects. .RI < "U" > .IP COPTS_ Similar to COPTS but for project ${PROJECTNAME}. .RI < "U" > .IP CPP C Pre-Processor. .RI < Iu > .RI [ cpp ] .IP CPPFLAGS Additional flags to the C/C++ pre-processor. .RI < "Iu" > .IP CPPFLAGS0 The same as CPPFLAGS but CPPFLAGS0 is passed to the compiler before CPPFLAGS. Normally, CPPFLAGS0 should be modified in makefiles and should not be set from environment by user. .RI < "M" > .IP CPPFLAGS_ Similar to CPPFLAGS but for project ${PROJECTNAME}. .RI < "U" > .IP CPPFLAGS_ Similar to CPPFLAGS but for the specified source file. Basename of the source file is used. .RI < "Mu" > .IP CXX C++ compiler. .RI < Iu > .RI [ c++ ] .IP CXX_PREFIX Prefix command for ${CXX}, for example, distcc or ccache. .RI < Iu > .RI [ "" ] .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 CXX_VERSION C++ compiler version. .RI < "I" > .IP CXXFLAGS Additional flags to the compiler when creating C++ objects. .RI < "Iu" > .RI [ "" ] .IP CXXFLAGS0 The same as CXXFLAGS but CXXFLAGS0 is passed to the compiler before CXXFLAGS. Normally, CXXFLAGS0 should be modified in makefiles and should not be set from environment by user. .RI < "M" > .IP CXXFLAGS.check Same as CXXFLAGS but every option is checked whether it is a valid one for C++ compiler. .RI < M > .RI [ unset ] .IP CXXFLAGS_ Similar to CXXFLAGS but for project ${PROJECTNAME}. .RI < "U" > .IP CXXFLAGS_ Similar to CXXFLAGS but for the specified source file. Basename of the source file is used. .RI < "Mu" > .IP CXXOPTS Additional flags to the compiler when creating C++ objects. .RI < "U" > .IP CXXOPTS_ Similar to CXXOPTS but for project ${PROJECTNAME}. .RI < "U" > .IP CXXSTD Add C++ language standard command line option to the compiler and linker. Supported options: .IR c++98 ", " gnu++98 " (C++98 with GNU extensions), " .IR c++11 ", " gnu++11 " (C++11 with GNU extensions), " .IR c++14 ", " gnu++14 " (C++14 with GNU extensions), " .IR c++17 ", " gnu++17 " (C++17 with GNU extensions)" If compiler is not known for mk-configure or does not support appropriate option, no additional options are applied. .RI < M > .RI [ "" ] .IP DATADIR Target directory for architecture-independent text files. .RI < "Iu" > .RI [ ${PREFIX}/share ] .IP DESTDIR Installation prefix. .RI < "U" > .RI [ "" ] .IP GZIP gzip copression tool. .RI < Iu > .RI [ gzip ] .IP INCSDIR Target directory for header files. .RI < "Iu" > .RI [ ${PREFIX}/include ] .IP INFODIR Target directory for .info files. .RI < "Iu" > .RI [ ${PREFIX}/info ] .IP INSTALL install(1) command. .RI < Iu > .RI [ install " or " mkc_install ] .IP INSTALL_FLAGS Flags passed to ${INSTALL} program. .RI < Iu > .RI [ "-c" ] .IP LD Linker. .RI < Iu > .RI [ ld ] .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 LEX Lexical analyzer. .RI < Iu > .RI [ lex ] .IP LEXLIB Object file for lex. .RI < Iu > .RI [ -ll ] .IP LFLAGS Options to ${LEX}. .RI < Iu > .RI [ "" ] .IP LIBDIR Target directory for libraries. .RI < "Iu" > .RI [ ${PREFIX}/lib ] .IP LIBEXECDIR Target directory for system utilities. .RI < "Iu" > .RI [ ${PREFIX}/libexec ] .IP LN ln(1) tool. .RI < Iu > .RI [ ln ] .IP LN_S Tool equivalent to ln -s. .RI < Iu > .RI [ "${LN} -s" ] .IP LORDER List dependencies for object files. .RI < Iu > .RI [ lorder ] .IP LPREFIX Symbol prefix for ${LEX} (see -P option in lex(1)). .RI < Iu > .RI [ yy ] .RI < Iu > .RI [ yy ] .IP MAKE bmake(1). .RI [ bmake " or " make " on NetBSD]" .IP MAKEDEPEND makedepend(1) tool. .RI < Iu > .IP MKC_ERR_MSG If set, keep an error message. .RI < "I M" > .RI [ "" ] .IP MKC_REQD Minimal required version of .BR mk-configure . If required version is not found, .I mkcmake fails. This variable should be set before .B mkc.init.mk is included, directly or indirectly. .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 /etc/mk.conf: ... .ifdef MKC_VERSION COPTS?= -O2 -Werror SHRTOUT= yes .endif # MKC_VERSION .VE .RI < "I" > .IP MKCOMPILERSETTINGS At build time mk-configure detects some compilers capabilities and saves them to system-wide .I mkc_imp.cc_${CC_TYPE}-${CC_VERSION}.mk (for C compiler) and .I mkc_imp.cxx_${CXX_TYPE}-${CXX_VERSION}.mk (for C++ compiler) files. At run time mk-configure loads these files if necessary. If they are absent, that is, if you use compilers unknown to mk-configure, it exits with error. If order to fix this, you have to run .B mkc_compiler_setting(1) utility manually. This utility generates similar files in .IR ${HOME}/.mkcmake " directory." However, if .B MKCOMPILERSETTINGS variable is set to .IR yes , .B mkc_compiler_setting(1) is run automaticlly and mk-configure loads the generated files. .RI < Iu > .RI [ no ] .IP MKDEP mkdep(1) tool. .RI < Iu > .IP MKDIR mkdir(1) tool. .RI < Iu > .RI [ mkdir ] .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 NM List symbols from object files. .RI < Iu > .RI [ nm ] .IP OBJCOPY Copy and translate object files. .RI < Iu > .RI [ objcopy ] .IP OBJDUMP Display information from object files. .RI < Iu > .RI [ objdump ] .IP OBJTOP Top-level object directory which defaults to ${.OBJDIR} if ${.MAKE.LEVEL} is 0. .RI < I > .IP PREFIX Target directory. .RI < "U" > .RI [ /usr/local ] .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 /etc/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 RANLIB Generate index to archive. .RI < Iu > .RI [ ranlib ] .IP RM rm(1) tool. .RI < Iu > .RI [ rm ] .IP SBINDIR Target directory for administration utilities. .RI < "Iu" > .RI [ ${PREFIX}/sbin ] .IP SHAREDSTATEDIR Target directory for modifiable architecture-independent data files. .RI < "Iu" > .RI [ ${PREFIX}/com ] .IP SHRTOUT If not "no", output messages about compiling, linking and creating libraries are shortened and formatted. .RI < "Iu" > .RI [ no ] .IP SIZE List section sizes and total size. .RI < Iu > .RI [ size ] .IP SRC_PATHADD List of directories added to .IR .PATH . .RI < Im > .RI [ "" ] .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 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 SYSCONFDIR Target directory for configuration files. .RI < "Iu" > .RI [ ${PREFIX}/etc ] .IP TAR tar archiver. .RI < Iu > .RI [ tar ] .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 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" > .IP VARDIR Target directory for modifiable single-machine data files. .RI < "Iu" > .RI [ ${PREFIX}/var ] .IP WARNERR If "yes", force warnings to be reported as errors. At the moment this is supported for GCC, clang, 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 YACC LALR(1) parser generator. .RI < Iu > .RI [ yacc ] .IP YFLAGS Options to ${YACC}. .RI < Iu > .RI [ "" ] .IP YHEADER If defined, add "-d" to YFLAGS, and add dependencies from .y to .h and .c, and add .h to CLEANFILES. .IP YPREFIX If defined, add "-p ${YPREFIX}" to YFLAGS. .IP ZIP zip copression tool. .RI < Iu > .RI [ zip ] .SS "mkc.files.mk" The include file .B mkc.files.mk handles the FILES variable and is included from .BR mkc.lib.mk " and " mkc.prog.mk . List of supported variables: .IP CLEANDIRDIRS Additional directories to remove (recursively) for the .IR cleandir target. .RI < "I M" > .IP CLEANDIRFILES Additional files to remove for the .IR cleandir target. .RI < "I M" > .IP CLEANDIRS Additional directories to remove (recursively) for the .IR clean " and " cleandir targets. .RI < "I M" > .IP CLEANFILES Additional files to remove for the .IR clean " and " cleandir targets. .RI < "I M" > .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_ The location to install the specific file . .RI < "Mu" > .IP FILESGRP File group. If .B bmake is run with root privileges, it defaults to .RI < "Mu" > .IP FILESGRP_ File group of the specific file . .RI < "Mu" > .I ${BINGRP} or to .I "`id -g`" otherwise. .RI < "Mu" > .IP FILESMODE File mode. .RI < "Mu" > .RI [ ${NONBINMODE} ] .IP FILESMODE_ File mode of the specific file . .RI < "Mu" > .IP FILESNAME Optional name to install each file as. .RI < "Mu" > .IP FILESNAME_ Optional name to install as. .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_ File owner of the specific file . .RI < "Mu" > .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 DPINCDIRS See LIBDEPS in section .BR mk.subprj.mk . .IP DPLDADD See LIBDEPS in section .BR mk.subprj.mk . .IP DPLIBDIRS See LIBDEPS in section .BR mk.subprj.mk . .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 ] .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 LDADD0 The same as LDADD but LDFLAGS0 and LDADD0 are passed to the linker before LDFLAGS and LDADD. .RI < "M" > .IP LDADD_ 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 LDFLAGS0 The same as LDFLAGS but LDFLAGS0 and LDADD0 are passed to the linker before LDFLAGS and LDADD. Normally, LDFLAGS0 and LDADD0 should be modified in makefiles and should not be set from environment by user. .RI < "M" > .IP LDFLAGS_ Similar to LDFLAGS but for project ${PROJECTNAME}. .IP MKPIE If "yes", create Position Independent Executable (PIE), otherwise create a regular executable. .RI < "Mu" > .RI [ no ] .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 PROG The name of the program to build. .IP PROGNAME The name that the above program will be installed as, if different from ${PROG}. .RI < "M" > .IP PROGS The names of the programs to build. If neither PROG nor PROGS is not supplied, nothing is built. .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. List of source files to build the program .I prog listed in .IR PROGS . If SRCS. is not defined, it's assumed to be prog.c. .RI < "M" > .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 ] .PP .B mkc.prog.mk includes .B mkc.files.mk and therefore supports all variables supported by it. .PP The order of options passed to the C compiler: .BR CPPFLAGS0 ", " CPPFLAGS ", " CPPFLAGS_ ", " CFLAGS.ssp ", " CFLAGS.pie ", " CFLAGS.warns ", " CFLAGS ", " CFLAGS_ ", " CFLAGS.pic " (for shared objects), " COPTS ", " COPTS_ .PP The order of options passed to the C++ compiler: .BR CPPFLAGS0 ", " CPPFLAGS ", " CPPFLAGS_ ", " CXXFLAGS.ssp ", " CXXFLAGS.pie ", " CXXFLAGS.warns ", " CXXFLAGS ", " CXXFLAGS_ ", " CXXFLAGS.pic " (for shared objects), " COPTS ", " COPTS_ .SS "mkc.lib.mk" The include file .B mkc.lib.mk has support for building a static and dynanic library or DLL. .B mkc.lib.mk uses the following variables: .IP DPINCDIRS See LIBDEPS in section .BR mk.subprj.mk . .IP DPLDADD See LIBDEPS in section .BR mk.subprj.mk . .IP DPLIBDIRS See LIBDEPS in section .BR mk.subprj.mk . .IP EXPORT_SYMBOLS Only symbols listed in a specified file (one symbol per line) are exported. Empty lines and comments started with # symbol are ignored. This variable has no effect on some platforms. By default all symbols are exported. .RI < "M" > [] .IP "LDADD LDADD_" Additional objects. See .B mkc.prog.mk .IP "LDFLAGS LDFLAGS_" Additional linker flags. See .B mkc.prog.mk .IP LIB The name of the library to build. .RI < "M" > .IP LIBDIR See .IR "Common variables " and " mkc.files.mk" sections. .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 LIBOWN Library owner. If .B bmake is run by an unprivileged user, it defaults to .IR "`id -u`" . .RI < "Iu" > .IP MAN The manual pages to be installed (use a .1 - .9 suffix). .RI < "M" > .IP MKDLL If "yes", build and install the dynamically loaded library (.so) instead of shared library. If "only", do not make static library. .RI < "M" > .RI [ no ] .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 SHLIBMODE Shared library mode. .RI < "Iu" > .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 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" > .PP Static libraries are .BR ranlib 'd when made. .B mkc.lib.mk includes .B mkc.files.mk and therefore supports all its variables as well. After creaion of libraries .I ${.CURDIR:T}.done file is created and used for handling inter-project .RB "(See " LIBDEPS " variable)" dependencies. .PP The order of options passed to the C and C++ compilers are the same as in .BR mkc.prog.mk . .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 " where is any directory listed in the variable SUBPRJ. The following targets are also provided: - where is either of the following: all, clean, cleandir, depend, installdirs, install, uninstall and filelist. Also provided are: targets nodeps-- and subdir--. Difference between - and nodeps-- is that .B "mkcmake -" runs the specified for and all its dependencies while .B "mkcmake nodeps--" -- only for . A target subdir-- is a synonym for nodeps-- See .I examples/hello_dictd subdirectory for the sample of use. .P .B mkc.subprj.mk provides the following variables: .IP ALLTARGETS A list of targets for which pre\_*, do_* and post\_* counterparts exist, for example, pre\_all, do\_all and post\_all. pre\_* target runs before do\_* target which in turn runs before post\_*. Unless action is provided for do\_* targets they implement the standard behaviour of .BR mk-configure . No action is provided for targets pre\_* and post\_*, so they are for user's extensions. The standard behaviour for ${ALLTARGETS} may also be extended by adding new prerequisites to targets do\_*. .IP COMPATLIB Subproject's basename for compatibility library. If this variable is set, MKC_SOURCE_FUNCLIBS and FEATURES do not change SRCS for subprojects other than ${COMPATLIB}. .RI < M > .RI [ "" ] .IP EXPORT_VARNAMES List of variables to export before running make for subdirectories. .RI < "Mu" > .RI [ MKC_CACHEDIR SRCTOP OBJTOP STATICLIBS COMPATLIB ] .IP INTERNALLIBS A list of subprojects (basenames) with internal libraries. These libraries are static and not installed by target "install". .RI < M > .RI [ "" ] .IP LIBDEPS A list of library dependencies. Each token is a colon-separated pair. Its first component is a library subproject (dependency), the second one is the subproject for library or executable. The value of this variable is automatically added to SUBPRJ. Library dependencies listed in LIBDEPS automatically change CPPFLAGS0, LDFLAGS0 and LDADD0 of approptiate subprojects. .RI < "M" > Suppose, we have pair in LIBDEPS, also suppose that variable .B library is set to "library" subdirectory and variable .B program is set to "program" subdirectory. ${SRCDIR_library}/linkme.mk file is automatically included from ${SRCDIR_program}/Makefile if it exists. In this file .RI "DPLDADD [" "${library:T:S/^lib//}" "]," .RI "DPLIBDIRS [" "${OBJDIR_${library:S,/,_,g}}" "] and" .RI "DPINCDIRS [" "${SRCDIR_${library:S,/,_,g}} ${OBJDIR_${library:S,/,_,g}}" "]," may be set to non-default values. These three variables then changes LDADD0, LDFLAGS0 and CPPFLAGS0 respectively in subproject "program". The dependency graph specified by variable LIBDEPS is available to all subproject via environment. .IP MKRELOBJDIR If "yes", object directories .RI ${OBJTOP}/ dir are used. Unlike MAKEOBJDIRPREFIX object directories do not contain top-level ${.CURDIR} in paths. .RI < "Iu" > .RI [ no ] .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 NOEXPORT_VARNAMES List of variables excluded from EXPORT_VARNAMES. .RI < "Mu" > .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_ Value of ${.OBJDIR} inside .I dir subdirectory. Slash symbols inside are replaced with underlines. In addition, OBJDIR_ variable is set to ${OBJDIR_} if ${SHORTPRJNAME} is "yes". .IP SHORTPRJNAME If "yes", special targets with last component of the subprojects are provided. .RI < "Im" > .RI [ yes ] .IP SRCDIR_ Value of ${.CURDIR} inside .I dir subdirectory. Slash symbols inside are replaced with underlines. In addition, SRCDIR_ variable is set to ${SRCDIR_} if ${SHORTPRJNAME} is "yes". .IP STATICLIBS A list of subprojects (basenames) with static libraries. If dependency is mentioned in this variable, the suffix _pic is automatically added for PIE-executables or shared libraries that depend on this library. This variable is automatically passed to subprojects via environment. .RI < Mu > .RI [ "" ] .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 SUBPRJSRCTOP This variables contains ${.CURDIR} directory and is passed to subprojects. .RI < "I" > .RI [ ${.CURDIR} ] .IP TARGETS A list of recursive targets. "Recursive" means that the target will be called for all subproject recursively (See .BR mkc.subprj.mk " and " mkc.subdir.mk ). .RI < "Im" > .RI [ all ", " install ", " installdirs ", " uninstall ", " clean ", " .IR cleandir ", " depends ", " test ", " configure ", " filelist ", " obj ] By setting this variable in the Makefile one can add new targets for special purposes, for example, static code analysis, partial builds etc. .P .B mkc.subprj.mk provides the following targets: .IP " and " is a subdirectory listed in SUBDIR or SUBPRJ. This target is equivalent to all-. means the last component of the directory and is created if ${SHORTPRJNAME} is "yes". .IP - Runs the specified for the specified . The target - is provided if ${SHORTPRJNAME} is "yes". .IP "subdir-- and nodeps--" Runs the specified for the specified without dependencies. Targets subdir-- and nodeps-- are provided if ${SHORTPRJNAME} is "yes". .IP print_deps Outputs the dependency graph on targets in tsort(1) format taking NODEPS and NOSUBDIR variables into account. .SS "mkc.subdir.mk" The include file .B mkc.subdir.mk 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 " where .I "" 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 itself includes .BR mkc.init.mk ", then " mkc.conf.mk , and finally internal include file which updates .BR CPPFLAGS ", " CFLAGS ", " LDADD " and " SRCS . .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" and "cleandir". .IP MKC_CACHEDIR Directory where intermediate and cache files are created. It defaults to ${.OBJDIR}. By default MKC_CACHEDIR variable is exported for subprojects. As a result cache files for subprojects are created in the top-level directory. If cache directory doesn't exist, it is created automatically. .IP MKC_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 ", " prog_gmake Find flex, bison, GNU awk, GNU m4 or GNU make respectively by analysing program's help and/or version messages. If found, BUILTIN.prog_ is set to the path, otherwise it is set to empty string. Note that .I gawk may be found as .IR awk , .I bison as .IR yacc , .I gm4 as .IR m4 , .I flex as .IR lex " and" .I gmake as .IR make . .TP .BR prog_mkdep ", " prog_nbmkdep Find traditional BSD mkdep(1) or recent NetBSD version of it respectively. .TP .B endianness BUILTIN.endianness variable is set to either .IR little ", " big " or " unknown depending on a hardware. .RE .IP MKC_CHECK_CC_OPTS A list of C compiler options to check. If ${CC} -c support the specified option, variable HAVE_CC_OPT. is set to 1 and 0 otherwise. Double underline in the option is considered as a single space character. .VS Ex. MKC_CHECK_CC_OPTS = -Wall -errwarn=%all --param__ssp-buffer-size=1 Res. HAVE_CC_OPT.-Wall=1 HAVE_CC_OPT.-errwarn_%all=0 HAVE_CC_OPT.--param__ssp-buffer-size_1=1 .VE .IP MKC_CHECK_CCLD_OPTS Same as MKC_CHECK_CC_OPTS except that option "-c" is not passed to the compiler, so, executable is created. As a result HAVE_CCLD_OPT. is set to 1 or 0. .IP MKC_CHECK_CUSTOM A list of custom checks (list of names). MKC_CUSTOM_FN. is a "C" or "C++" source filename or an executable program for your custom check, e.g., filename.c, filename.cc, subdir/filename.cxx, filename.C, filename.cpp or subdir/executable_script. .B mk-configure tries to compile or run the specified file and sets CUSTOM. variable to 1, 0 or other value. If MKC_CUSTOM_FN. is unset, it defaults to custom_check_name.c. Also -DCUSTOM_=1 is added to CPPFLAGS if the specified check succeeded unless MKC_NOAUTO is set to 1 and MKC_CUSTOM_NOAUTO. is set to "yes". Here is uppercase for . If MKC_CUSTOM_LINK. is "yes", then C or C++ source file is compiled and linked into executable. Also, CPPFLAGS, CFLAGS, CXXFLAGS, LDFLAGS, LDADD, MKC_CUSTOM_CPPFLAGS., MKC_CUSTOM_CFLAGS., MKC_CUSTOM_CXXFLAGS., MKC_CUSTOM_LDFLAGS. and MKC_CUSTOM_LDADD. flags are passed to the compiler. Normally cache file name contains unless MKC_CUSTOM_CACHE. is set to something else. .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_CHECK_CXX_OPTS Same as MKC_CHECK_CC_OPTS but for C++ compiler. As a result HAVE_CXX_OPT. is set to 1 or 0. .IP MKC_CHECK_CXXLD_OPTS Same as MKC_CHECK_CCLD_OPTS but for C++ compiler. As a result HAVE_CXXLD_OPT. is set to 1 or 0. .IP MKC_CHECK_DEFINES List of define:header to check.
part is optional. As a result of the check bmake's variable HAVE_DEFINE..
(or HAVE_DEFINE.) is set to either 0 or 1. .br
: tr|./|__|g .br Also -DHAVE_DEFINE__
=1 or -DHAVE_DEFINE_=1 is added to CPPFLAGS if the specified define was detected unless MKC_NOAUTO is set to 1. .br
: tr|a-z./|A-Z__|g .br : 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_CHECK_FUNCLIBS List of : pairs to check, part is optional. If is present, presense of in libc is also checked automatically. As a result of the check bmake's variable HAVE_FUNCLIB.. (or HAVE_FUNCLIB.) is set to either 0 or 1. If is found in but not in libc or is "main" and is found in , "-l" is automatically added to LDADD unless : 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_CHECK_FUNCS List of :
to check.
part is optional. Here means the number of arguments. As a result of the check bmake's variable HAVE_FUNC..
(or HAVE_FUNC.) is set to either 0 or 1. .br
: tr|./|__|g .br Also -DHAVE_FUNC__
=(0 or 1) (or -DHAVE_FUNC_=(0 or 1)) is added to CPPFLAGS if the specified function was detected unless MKC_NOAUTO is set to 1. If MKC_FUNC_OR_DEFINE. is "yes", equivalent define leads to the same results. .br
: tr|a-z./|A-Z__|g .VS Ex: MKC_CHECK_FUNCS2 += fgetln:stdio.h MKC_CHECK_FUNCS6 += pselect:sys/select.h MKC_CHECK_FUNCS1 += htobe32:sys/endian.h MKC_FUNC_OR_DEFINE.htobe32 += yes Res: HAVE_FUNC2.fgetln.stdio_h = 1 HAVE_FUNC6.pselect.sys_select_h = 1 HAVE_FUNC1.htobe32.sys_endian_h=1 CFLAGS += -DHAVE_FUNC2_FGETLN_STDIO_H=1 \\ += -DHAVE_FUNC6_PSELECT_SYS_SELECT_H=1 \\ += -DHAVE_FUNC1_HTOBE32_SYS_ENDIAN_H .VE .IP MKC_CHECK_HEADER_FILES Same as .B MKC_CHECK_HEADERS but .I $CC -E is used for checking instead of .IR "$CC -c" . Also, HAVE_HEADER_FILE.
variables and HAVE_HEADER_FILE
defines are set. .IP MKC_CHECK_HEADERS List of headers to check with the help of .IR "$CC -c" . As a result of the check bmake's variable .B HAVE_HEADER.
is set to either 0 or 1. .br
: tr|./|__|g .br Also -DHAVE_HEADER_
=(0 or 1) is added to CPPFLAGS unless MKC_NOAUTO is set to 1. .br
: 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_CHECK_MEMBERS List of .:
to check.
part is optional. As a result of the check bmake's variable HAVE_MEMBER._.
(or HAVE_MEMBER._) is set to either 0 or 1 depending on the result. .br
: tr|./|__|g .br Also -DHAVE_MEMBER___
=1 (or -DHAVE_MEMBER__=1) is added to CPPFLAGS if the specified member was found in appropriate type unless MKC_NOAUTO is set to 1. .br
: tr|a-z./|A-Z__|g .br : tr|a-z./|A-Z__|g .br : 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_CHECK_PROGS List of s to check. As a result of the check bmake's variable HAVE_PROG. is set to either 1 (true) or 0 (false). Also PROG. 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. is set to, e.g, , then HAVE_PROG. and PROG. are set. MKC_PROG.id. also changes cache file names. .IP MKC_CHECK_PROTOTYPES A list of checks (list of names) for C function prototypes. MKC_PROTOTYPE_FUNC. is a C function prototype. MKC_PROTOTYPE_HEADERS. is a list of headers separated by space or comma. mk-configure verifies that the specified prototype is correct and if so, HAVE_PROTOTYPE. bmake variable is set to 1 and -DHAVE_PROTOTYPE_=1 is added to CPPFLAGS unless MKC_NOAUTO is set to 1. Otherwise, HAVE_PROTOTYPE. variable is set to 0. .VS Ex. MKC_CHECK_PROTOTYPES = posix_iconv const_iconv MKC_PROTOTYPE_FUNC.posix_iconv = \ size_t iconv(iconv_t,char**,size_t*,char**,size_t*) MKC_PROTOTYPE_FUNC.const_iconv = \ size_t iconv(iconv_t,const char**,size_t*,char**,size_t*) MKC_PROTOTYPE_HEADERS.posix_iconv = iconv.h MKC_PROTOTYPE_HEADERS.const_iconv = iconv.h Res. HAVE_PROTOTYPE.posix_iconv=0 HAVE_PROTOTYPE.const_iconv=1 CFLAGS += -DHAVE_PROTOTYPE_CONST_ICONV=1 .VE .IP MKC_CHECK_SIZEOF List of :
to check.
part is optional. As a result of the check bmake's variable SIZEOF..
(or SIZEOF.) is set to the data type size or string "failed". .br : tr|*-|P_|g .br
: tr|/.|__|g .br Also -DSIZEOF__
= (or -DSIZEOF_=) is added to CPPFLAGS if sizeof() check was successful unless MKC_NOAUTO is set to 1 .br : tr|a-z*-|A-ZP_|g .br
: 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_CHECK_TYPES List of type:header to check.
part is optional. As a result of the check bmake's variable HAVE_TYPE..
(or HAVE_TYPE.) is set to either 0 or 1. .br
: tr|./|__|g Also -DHAVE_TYPE__
=1 (or -DHAVE_TYPE_=1) is added to CPPFLAGS if the specified type was detected unless MKC_NOAUTO is set to 1. .br
: tr|a-z./|A-Z__|g .br : 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_CHECK_VARS List of variable:header to check.
part is optional. As a result of the check bmake's variable HAVE_DEFINE..
(or HAVE_DEFINE.) is set to either 0 or 1 .br
: tr|./|__|g .br Also -DHAVE_DEFINE__
=1 (or -DHAVE_DEFINE_=1) is added to CPPFLAGS if the specified variable was detected unless MKC_NOAUTO is set to 1. .br
: 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_COMMON_DEFINES List of defines always passed to compiler in MKC_CHECK_{DEFINES,VARS,FUNCS,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. 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_COMMON_HEADERS List of header files always #include'd to the test .c file in MKC_CHECK_{DEFINES,VARS,FUNCS,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_CUSTOM_DIR Directory with custom checks source files. See MKC_CHECK_CUSTOM. It defaults to ${.CURDIR}. .IP MKC_DELETE_TMPFILES If set to 1, temporary files are removed. .IP MKC_FEATURES This is a list of "features" required by project. In general, a feature is something that has problems with portability. This may be a function name or header missing on some platforms, for example. What developer needs to do is to add FEATURENAME to MKC_FEATURES variable and add #include where it is needed. Internally, system requiremets are checked in the automatically included mkc_imp.f_FEATURENAME.mk file and all required actions (includes, define checks etc.) are made in mkc_FEATURENAME.h header file. Currently the following features are provided: .RS .TP .B arc4random This feature provides arc4random(3), arc4random_buf(3) and arc4random_uniform(3) functions available in BSDs. If these functions are absent on your system, install libbsd library. .TP .B bswap This feature provides bswap16(3), bswap32(3) and bswap64(3) functions available in *BSD. .TP .B dprintf This feature provides dprintf(3). .TP .B efun This feature provides esetfunc(3), efopen(3), ecalloc(3), emalloc(3), erealloc(3), ereallocarr(3), estrdup(3), estrndup(3), estrlcpy(3), estrlcat(3), easprintf(3), estrtoi(3), estrtou(3) and evasprintf(3) functions from NetBSD. .TP .B err This feature provides err(3), errx(3), verr(3) and verrx(3) BSD-isms. .TP .B errc This feature provides errc(3) and verrc(3) BSD-isms. .TP .B fgetln This feature provides fgetln(3) BSD-ism. .TP .B fparseln This feature provides fparseln(3) BSD-ism. .TP .B fts This feature provides fts_open(3), fts_read(3) etc. functions available on BSDs and Linux. If it is absent on your system, you have to install libfts (both headers and library). libfts is a part of musl project. .TP .B getdelim This feature provides getdelim(3) from POSIX. .TP .B getline This feature corresponds to getline(3) function which is a part of POSIX2008 unavailable on some systems. mkc_imp.f_getline.mk checks whether getline declaration is available in stdio.h and implementation is available in libc. If not, getline.c provided by mk-configure is added to SRCS and declaration is provided in mkc_getline.h header. .TP .B humanize_number This feature provides humanize_number(3) function from NetBSD. .TP .B libdl This feature checks whether libdl library is available and dlopen(3) is declared in dlfcn.h. If yes, -ldl is added to LDADD. mkc_libdl.h provides declarations for dlopen(3), dlsym(3), dlclose(3) etc. .TP .B libl Adds -ll or -lfl to LDADD depending on which one is available. One can use this feature instead of LIBLEX variable. .TP .B libm This feature checks whether libm is available and if yes, adds -lm to LDADD. Most UNIX-like systems have libm but Haiku, for example, does not. mkc_imp.f_libm.mk checks whether libm library is available and if yes, -lm is added to LDADD. .TP .B macro This feature provides the following macro stolen from NetBSD. .I __aligned(x) defined as .I "__attribute__((aligned(x)))" if supported by compiler, .I __always_inline defined as .I "__attribute__((always_inline))" if supported by compiler, .I __arraycount(a) defined as .I "(sizeof(__a)/sizeof(__a[0]))", .I __constfunc defined as .I "__attribute__((const))" if supported by compiler, .I __dead defined as .I "__attribute__((noreturn))" if supported by compiler, .IR "MIN(a,b)" " and " "MAX(a,b)," .I __pure defined as .I "__attribute__((pure))" if supported by compiler, .I "__printflike(n,m)" defined as .I "__attribute__((format (printf, n, m)))" if supported by compiler. .TP .B posix_getopt It is well-known that glibc getopt(3) does not conform to POSIX by default. This feature provides POSIX-ly correct getopt. .TP .B progname This feature provides getprogname(3) and setprogname(3) functions available in *BSD. .TP .B pwdgrp This feature provides user_from_uid(3), uid_from_user(3), group_from_gid(3), gid_from_group(3) functions from *BSD. .TP .B raise_default_signal This feature provides function raise_default_signal(3) from NetBSD. .TP .B "RB SPLAY" BSD systems provide sys/tree.h header where RB_* and SPLAY_* macroses are defined for red-black tree and splay. These features check whether sys/tree.h and appropriate macroses are available. If yes, mkc_RB.h and mkc_SPLAY.h include system-wide sys/tree.h, otherwise NetBSD version of sys/tree.h provided by mk-configure is included. .TP .B reallocarr This feature provides reallocarr(3) function from NetBSD. .TP .B reallocarray This feature provides reallocarray(3) function from OpenBSD. .TP .B shquote This feature provides shquote(3) function from NetBSD. .TP .B "SLIST SIMPLEQ STAILQ LIST TAILQ CIRCLEQ" BSD systems provide sys/queue.h header where SLIST_* etc. macroses are defined for lists and queues. These features check whether sys/queue.h and appropriate macroses are available. If yes, mkc_SLIST.h and others include system-wide sys/queue.h, otherwise NetBSD version of sys/queue.h provided by mk-configure is included. .TP .B strlcat This feature corresponds to strlcat(3) function available on almost all systems except glibc-based Linux-es. mkc_imp.f_strlcat.mk checks whether strlcat declaration is available in string.h and implementation is available in libc. If not, strlcat.c provided by mk-configure is added to SRCS and declaration is provided in mkc_strlcat.h header. .TP .B strlcpy Similar to strlcat. .TP .B strndup This feature provides strndup(3) from POSIX. .TP .B strsep This features provides strsep(3) and stresep(3) functions. .TP .B strtoi This feature provides strtoi(3) function introduced in NetBSD. .TP .B strtou This feature provides strtoi(3) function introduced in NetBSD. .TP .B vis This feature provides vis(3), nvis(3), svis(3), snvis(3), strvis(3), strnvis(3), strsvis(3), strsnvis(3), strvisx(3), strnvisx(3), strenvisx(3), strsvisx(3), strsnvisx(3), strsenvisx(3), strunvis(3), strnunvis(3), strunvisx(3), strnunvisx(3) and unvis(3) from NetBSD. .TP .B warn This feature provides warn(3), warnx(3), vwarn(3) and vwarnx(3) BSD-isms. .RE .IP MKC_NOAUTO See MKC_CHECK_{HEADERS,FUNCLIBS,FUNCS,VARS,DEFINES,SIZEOF}. .IP MKC_NOAUTO_FUNCLIBS See MKC_CHECK_FUNCLIBS .IP MKC_NOCACHE All results are cached unless MKC_NOCACHE variable is set non-empty value .IP MKC_REQUIRE_BUILTINS The same as MKC_CHECK_BUILTINS, but failure is treated as a fatal error (See .B configure target). .IP MKC_REQUIRE_CUSTOM The same as MKC_CHECK_CUSTOM, but failure is treated as a fatal error (See .B configure target). 0 and empty value of CUSTOM.xxx means failure. .IP MKC_REQUIRE_DEFINES The same as MKC_CHECK_DEFINES, but absense of the define is treated as a fatal error (See .B configure target). .IP MKC_REQUIRE_FUNCLIBS The same as MKC_CHECK_FUNCLIBS, but absense of funclib is treated as a fatal error (See .B configure target). .IP MKC_REQUIRE_FUNCS The same as MKC_CHECK_FUNCS, but absense of the function declaration is treated as a fatal error (See .B configure target). .IP MKC_REQUIRE_HEADER_FILES The same as MKC_CHECK_HEADER_FILES, but absense of header is treated as a fatal error (See .B configure target). .IP MKC_REQUIRE_HEADERS The same as MKC_CHECK_HEADERS, but absense of header is treated as a fatal error (See .B configure target). .IP MKC_REQUIRE_MEMBERS The same as MKC_CHECK_MEMBERS, but absense of the member is treated as a fatal error (See .B configure target). .IP MKC_REQUIRE_PROGS The same as MKC_CHECK_PROGS, but absense of program is treated as a fatal error (See .B configure target). .IP MKC_REQUIRE_PROTOTYPES The same as MKC_CHECK_PROTOTYPES, but incorrect prototype is treated as a fatal error (See .B configure target). .IP MKC_REQUIRE_TYPES The same as MKC_CHECK_TYPES, but absense of the type declaration is treated as a fatal error (See .B configure target). .IP MKC_REQUIRE_VARS The same as MKC_CHECK_VARS, but absense of the variable declaration is treated as a fatal error (See .B configure target). .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_SOURCE_DIR, MKC_SOURCE_DIR." Directory with sources for MKC_SOURCE_FUNCLIBS. If MKC_SOURCE_DIR. is unset, MKC_SOURCE_DIR is used that defaults to ${.CURDIR}. .VS Ex: MKC_SOURCE_FUNCLIBS += getline MKC_SOURCE_DIR.getline.c = ${.CURDIR}/../missing Res: SRCS+= ${.CURDIR}/../missing/getline.c HAVE_FUNCLIB.getline= 0 .VE .IP MKC_SOURCE_FUNCLIBS The same as MKC_CHECK_FUNCLIBS, but if is absent both in the specified 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 .SS mkc.conf.mk The same as .BR mkc.configure.mk " but " mkc.init.mk is not included by .B mkc.conf.mk in the beginning, and .BR CFLAGS ", " CPPFLAGS ", " LDADD " and " SRCS varibales are not modified. Instead, internal variables .BR MKC_CFLAGS ", " MKC_CPPFLAGS ", " MKC_LDADD " and " MKC_SRCS contain all changes and will be applied later. One can use this module for implementing your own "features" similar to .BR MKC_FEATURES . .SS mkc_imp.scripts.mk It 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 SCRIPTSDIR Target directory for scripts. .RI < "Iu" > .RI [ ${BINDIR} ] .IP SCRIPTSDIR_