diff options
author | Andrew Shadura <andrewsh@debian.org> | 2014-09-14 17:41:43 +0200 |
---|---|---|
committer | Andrew Shadura <andrewsh@debian.org> | 2014-09-14 17:41:43 +0200 |
commit | a4d537d587e2e061c2e8e30bcf865da2fed12cd6 (patch) | |
tree | 18b1263e3a507d785fbde6a8a09e6e019ff986a8 |
mk-configure (0.28.0-1) unstable; urgency=medium
* New upstream release.
* Drop an old patch and a custom sys.mk.
# imported from the archive
639 files changed, 26869 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..eae5079 --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +# Copyright (c) 2014 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +.MAIN: all +.DEFAULT: + @unset ROOT_GROUP; ${MAKE} ${MAKEFLAGS} -m ${.CURDIR}/mk -m ${.CURDIR}/features -f main.mk ${.TARGET} diff --git a/Makefile.inc b/Makefile.inc new file mode 100644 index 0000000..38d9be8 --- /dev/null +++ b/Makefile.inc @@ -0,0 +1,29 @@ +VERSION = 0.28.0 + +BIRTHDATE = 2009-02-21 + +MKFILESDIR ?= ${PREFIX}/share/mkc-mk +DOCDIR ?= ${PREFIX}/share/doc/mk-configure +BUILTINSDIR ?= ${PREFIX}/share/mk-configure/builtins +FEATURESDIR ?= ${PREFIX}/share/mk-configure/features + +INTEXTS_REPLS += version ${VERSION} +INTEXTS_REPLS += AWK ${PROG.awk} +INTEXTS_REPLS += BMAKE ${BMAKE} +INTEXTS_REPLS += mkfilesdir ${MKFILESDIR} +INTEXTS_REPLS += syscustomdir ${BUILTINSDIR} +INTEXTS_REPLS += mkc_libexecdir ${LIBEXECDIR} + +.if exists(/usr/xpg4/bin/awk) +# Solaris' /usr/bin/awk is completely broken, +# /usr/xpg4/bin/awk sucks too but sucks less. +PROG.awk ?= /usr/xpg4/bin/awk +.else +MKC_REQUIRE_PROGS += awk +.endif + +BMAKE ?= bmake +PS2PDF ?= ps2pdf +DOT ?= dot +DVIPS ?= dvips +LATEX ?= latex @@ -0,0 +1,414 @@ +------------------------------------------------------------------------- +WHAT IS MK-CONFIGURE? + +mk-configure is a lightweight replacement for GNU autotools, written +in and for bmake (portable version of NetBSD make) and UNIX tools +(shell, awk etc.). FreeBSD and OpenBSD make are not good. They are +incompatible with NetBSD bmake. GNU make is not good too. + +mk-configure provides a number of include files written in bmake and a +number of standalone programs that should be installed to user's host +for building a software. + +mk-configure features: + + - An easy way for building standalone executables, static and shared + libraries written in C, C++, Fortran, Pascal and Objective C; .cat + and .html files from man pages; .info pages from texinfo sources + etc. LEX, YACC are also supported. Support for other languages are + planned. + + - Installing and uninstalling executables, libraries, scripts, + documentation files and others. DESTDIR support is also provided. + + - Integrated autoconf-like support for finding #include files, + libraries and function implementation, function definitions, + defines, types, struct members etc. + + - A number of built-in checks for, e.g., system endianness, GNU bison + or GNU flex programs and many others. + + - Automatic dependency analysis built-in for C, C++ and Fortran (not + implemented yet, will be available soon). + + - Extensibility by writing bmake include files. + + - Support for regression tests (see mkc.minitest.mk for the sample). + + - mk-configure is small and easy. It is definitely much easier for + use than GNU autotools, many people think that it is also easier + than other competing projects like CMake, scons and others. + +------------------------------------------------------------------------- +WHAT MK-CONFIGURE IS NOT + + - mk-configure is not a replacement for traditional make(1) + + - mk-configure is not a silver bullet ;-) + +------------------------------------------------------------------------- +GOALS OF THE PROJECT + + - No code generation! Library approach is used instead. Instead of + generating tons of unreadable blobs mk-configure uses bmake include + files (bmake's libraries) and external executables to make its job. + Developers should distribute source code only, not blobs. + + - Single top level command for building a program ("mkcmake"). + Instead of running and learning + autoconf/automake/aclocal/autoreconf/config.status/autoheader and + many other tools, and the way they interact with each other, you + should learn only ONE tool, bmake (mkcmake is a trivial wrapper + over bmake). + + - No bloat. At this time mk-configure consists of far less than 10000 + lines of code (excluding examples and regression tests). Compare + this number with autotools sources and you'll see a difference. + + - Simplicity for both developers and users. The only file developers + should be aware of during development is 'Makefile'. Users just + run 'env <options> mkcmake all <options>' to build a software. The + same for developers -- for building a software, just run 'mkcmake'. + + - Portability. At the moment the following systems and compilers are + supported: + + - NetBSD. Tested on NetBSD-5.0/x86 and NetBSD-2.0/alpha and later + versions with gcc, pcc and clang. + + - FreeBSD. Tested on FreeBSD-6.2/x86, 7.1/spark64, 7.1/x86 and + later versions with gcc. + + - OpenBSD. Tested on OpenBSD-3.8/x86, 4.5/x86 and later versions + with gcc. + + - DragonFlyBSD. Tested on DragonFly-2.4.1-RELEASE/x86 and later + versions with gcc. + + - MirOS BSD. Tested on MirBSD-10/x86 and later versions with gcc. + + - Linux. Tested on Linux/{x86,x86-64} with gcc, icc and SunStudio. + + - Solaris. Tested on Solaris-{10,11}/x86 and Solaris-10/spark64 + with SunStudio-11, SunStudio-12 and gcc. + + - Darwin (MacOS-X). Tested on Darwin-8.11.0/ppc (MacOS-X Tiger) + and later version with native gcc and clang. + + - Interix. Tested on Interix-3.5/x86 with gcc. + + - QNX. Tested on QNX-6.3/x86 with gcc. + + - OSF1. Tested on Tru64-5.1/alpha with gcc and DEC C compiler. + + - HP-UX. Tested on HP-UX-11.0/hppa with gcc. + + - Partial support for AIX and their native + compilers. Support is not complete because I have no access to + "big iron" :-( . + + If you don't see your favorite system/compiler here and want to + help me to improve mk-configure, feel free to contact me. + mk-configure needs your help! ;-) + + - Declarative approach in writing Makefiles. Instead of specifying + _HOW_ to build your software, you should specify source files, + files to build and (optionally) build options, e.g. LDCOMPILER=yes + meaning that ${CC} or ${C++} compiler should be used as a linker + instead of ${LD}. Small/medium size projects may have no rules in + Makefiles at all. Most useful things are already implemented in + mk-configure include files including implementation for targets + all, install, uninstall as well as support for building the shared + libraries, installation to ${DESTDIR} etc. Usually, Makefile contain + only variable assignments, .include-s and .if/.for directives. + + - No heavy dependencies like Python or Perl. + +------------------------------------------------------------------------- +HOW TO USE MK-CONFIGURE? + + Developers: + - Install bmake (and optionally sys.mk) to your system. + - Install mk-configure to your system. + - Develop your software using bmake and mkc.*.mk include files + provided by mk-configure. + - Run 'mkcmake' or 'mkcmake all' for building your program. + (mkcmake is a trivial wrapper over bmake). + You don't need autoconf/autoheader/automake/aclocal/config.guess/ + /autoreconf/config.status/config.sub and blah-blah-blah + + BMAKE is magic enough ;-) + + Users and software packagers: + - Install bmake (and optionally sys.mk) to your system. + - Install mk-configure to your system. + - Run mkcmake for building a software and pass to it + the building options, e.g. + + env CC=pcc CFLAGS='-O0 -g' PREFIX=/opt/software \ + mkcmake all install + + There is no need for "configure" script and analogs. + + BMAKE is magic enough ;-) + +------------------------------------------------------------------------- +WHAT'S WRONG WITH GNU AUTOTOOLS (IN SHORT)? + + 1) Autotools are toooooo big and toooooo complex. I fear most free + and open source developers do not understand how to use autotools + in a proper way to make software REALLY portable. + + 2) configure script generated by autoconf is too big. Trivial + configure.ac results in hundreds of kilobytes of unreadable textual + blobs. What the hell? + + 3) The goal of autotools was to make building software easier. But + this goal makes development painful. Autotools is a hell for + development/developers. Too much of top-level commands: automake, + autoconf, aclocal, autoheader... All its functionality can be + implemented using one top-level command -- mkcmake. Autotools is + also a well known source of headaches for users and software + packagers. + + 4) In theory, configure script generated by autoconf is portable + because it is written in portable shell. In practice this is not + always true. Users often need to update autoconf for regenerating + an upstream configure scripts. They also often need to patch a + configure and Makefile blobs. + + 5) autoconf doesn't support efficient results caching from different + projects. In theory this can make building thousands of projects + (e.g. software packages in OS distributions) dramatically faster. + + 6) "configure" script generated by autoconf are too slow even on + modern hardware and systems having fast fork(2) system call + (notably *BSD and Linux). + + 7) Many (most?) real-life configure.ac break the cross-compiling. + + 8) In my view autotools (automake and autoconf) are BADLY designed. + Personally, I dislike code generation for software build because it + is extremely ugly approach even if the generated code is claimed to + be "portable". Nowadays it is not a problem to install any kind of + software building tools and use them more efficiently. + +------------------------------------------------------------------------- +WHAT MK-CONFIGURE CONSISTS OF? + +- mkc.{files,lib,prog,subprj,subdir}.mk files. + + These include files are responsible for building, installing and + uninstalling applications, static and shared libraries, scripts, + text files, man and info pages, hard and soft links etc... + + NOTE FOR *BSD USERS: unlike well known Mk files from *BSD + systems mkc.*.mk files provide the following features (this list + is not complete, see mk-configure.7 for details). + + - PREFIX, BINDIR, MANDIR etc. variables default to directories + under /usr/local. By default the same variables in bsd.*.mk + files are set to directories under /usr. The reason is that they + are used mainly for maintaining *BSD's own code while + mk-configure is targeted to all UNIX-like systems, not only *BSD. + + - BINOWN, BINGRP, MANOWN etc. variables are set to 'id -u' and + 'id -g' if mkcmake(1) is run under an unprivileged user. + By default bsd.*.mk use root:wheel by default. + + - A target 'install' installs include files, info pages and + others not installed by default by bsd.*.mk files. + It also creates target directories by default + (see target 'installdirs' and MKINSTALLDIRS variable). + + - A target 'installdirs' creates all required destination + directories. bsd.*.mk files do not create them at all. + + - A target 'uninstall' removes all installed files from + destination directories. bsd.*.mk files do not provide + this functionality. + + - A target 'test' of mkc.subdir.mk (by default) runs a "test" + target for each subdirectory listed in SUBDIR. Other mkc.*.mk + files provide "test" target too but does nothing by default. + If you want to test your application, define your own "test" + target in application's Makefile. + + - DPLIBDIRS variable, if set, contains a list of directories of + the libraries your project depends on. If this variable is + set, LDFLAGS is modified accordingly. See examples/ projects. + + - "cleandir" and "distclean" targets that remove all temporary + files and mk-configure.mk's cache files. + + - support for texinfo/info files. There is no need to .include + a special include files such as <bsd.info.mk> file. + + - mkc.subprj.mk is a powerful replacement + for traditional bsd.subdir.mk. + + - Tons of other additions and improvements. + +- mkc.intexts.in + + Given a list of files in INFILES or INSCRIPTS mkc.intexts.mk + generates them from appropriate *.in file replacing @prefix@, + @sysconfdir@, @libdir@, @bindir@, @sbindir@, @datadir@ etc. with + real ${PREFIX}, ${SYSCONFDIR} etc. See examples/ subdirectory for + the samples. + +- mkc.configure.mk is a replacement for GNU autoconf. Its + functionality is large enough to describe here. In short, it allows + to check for presence of header files, function or variable + declarations, presence of function in a particular library, defines, + sizeof of data types and other useful things. Read the documentation + in mk-configure.7 and see examples/ subdirectory for the samples of + use. + +- Standalone full-functional + mkc_check_{funclib,header,sizeof,decl,prog,custom,compiler} and + other programs that can be used without mkcmake and without mkc.*.mk + files. Read appropriate man pages. + +------------------------------------------------------------------------- +DOCUMENTATION: + + - Presentation about mk-configure (basic ideas and simple samples of use). + See INSTALLATION section for build instructions. + + - Instead of screenshots :-) I've prepared a lot of examples under + examples/ subdirectory. + + - Documentation for mk include files is in mk-configure(7). + + - doc/NOTES contains a number of useful recipes. + + - Most programs (mkc_check_{decl,header,funclib,sizeof,prog,custom}) + have -h option and manual pages. + + - Read the FAQ document. It may be helpful. + + - Real life projects based on mk-configure: + - Most of my projects use mk-configure. + https://github.com/cheusov + - AWK interpreter from NetBSD cvs tree, + ported to Darwin, Solaris, Linux and other BSD. + http://mova.org/~cheusov/pub/mk-configure/nbawk/ + +------------------------------------------------------------------------- +IS MK-CONFIGURE STABLE? + +Basic functionality of "mk-configure" is stable +but it is not feature-complete yet, see TODO file for details. + +------------------------------------------------------------------------- +INSTALLATION: + + 1) Install bmake(1). + Sources are available here. + + ftp://ftp.NetBSD.org/pub/NetBSD/misc/sjg/ + http://www.crufty.net/help/sjg/bmake.html + + NOTE: Some versions of bmake (shipped with NetBSD-5.1, for + example) contains bugs which are critical for mk-configure. + Please make sure you install stable version of bmake and + 'bmake test' succeeds (see section 3 below). + + 2) Install NetBSD version of mkdep(1). + Sources are available here. + + https://code.google.com/p/bmkdep/ + + Traditional BSD mkdep(1) is also good but NetBSD version is just better. + + 3) Download mk-configure source from either + http://mova.org/~cheusov/pub/mk-configure or + http://sourceforge.net/projects/mk-configure and unpack tarball. + + # cd mk-configure-X.Y.Z/ + + # export PREFIX=/usr/local (the default) + or + # export PREFIX=/usr SYSCONFDIR=/etc + + # emacs sys.mk # if needed + + # bmake all + + Of course, you can change PREFIX, SYSCONFDIR, BINDIR etc. + to whatever you want. PREFIX defaults to /usr/local. + + 4) + # bmake test # For testing mk-configure, this step is optional. + # Note that testing requires lex(1), yacc(1), + # pkg-config(1), glib2 library and other things + # that are not mandatory for using mk-configure + # and may be not available on your system. + # If "bmake test" fails on your platform, please let + # me know. If for some reason you want to exclude some + # regression tests (they are in "tests" and "examples" + # subdirectories), you may list them in NOSUBDIR variable, + # e.g. + # NOSUBDIR='hello_glib2 hello_lua lua_dirs' bmake test + + 5) + # bmake install + or + # env DESTDIR=/tmp/temproot bmake install + + 6) You can also build a simple presentation by running either of the + following commands: + + bmake all-presentation + + NOTE: I'd recommend to use the latest stable version of bmake. Old + bmake may not work, e.g., /usr/bin/make shipped with NetBSD-2.0 is + not supported. pmake-1.111 (an ancient version of NetBSD make) + found in some Linux distributions does't work too. + + NOTE: In order to work properly bmake needs sys.mk file that defines + default variable values and suffix rules. mk-configure doesn't + need it, but bmake always tries to load this file. The problem + is that different Mk-files libraries may conflict due to common + sys.mk. This is why mk-c's own mk files are installed to its own + directory (${PREFIX}/share/mkc-mk by default) and the same for + empty sys.mk file. + + 6) Usage + + For use of mk-configure for real-life development you may need the + following programs: C/C++/Fortran/Pascal/Objective-C compilers, + linker, yacc/bison, lex/flex, ar, as, ln, nroff, pod2man, + pod2html, ranlib, mkdep, tar, gzip, bzip2, cpp, install, lorder, + nm, tsort, pkg-config, zip and others. Of course you'll + need awk, sed, grep and some other POSIX tools too. + +------------------------------------------------------------------------- +MK-CONFIGURE BINARY PACKAGE + + Binary packages for mk-configure are available in the following systems: + - NetBSD pkgsrc (devel/mk-configure). + - FreeBSD ports (devel/mk-configure) + - Debian/Ubuntu Linux (mk-configure) + - AltLinux (mk-configure) + - RHEL (mk-configure in repoforge repository) + +------------------------------------------------------------------------- +FEEDBACK + +Send all your suggestions, bug reports etc. +to Aleksey Cheusov <vle@gmx.net> or register them at project's site +http://sourceforge.net/projects/mk-configure/ + +For free e-mail subscription for mk-configure releases, visit +http://freshmeat.net/projects/mk-configure/ +page. + +For pull requests, use github +http://github.com/cheusov/mk-configure/ + +Feel free to notify me about spelling errors in the documentation. +English is not my first language. + +------------------------------------------------------------------------- diff --git a/_mkc_prog_awk.err b/_mkc_prog_awk.err new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/_mkc_prog_awk.err diff --git a/_mkc_prog_awk.res b/_mkc_prog_awk.res new file mode 100644 index 0000000..36178d1 --- /dev/null +++ b/_mkc_prog_awk.res @@ -0,0 +1 @@ +/usr/bin/awk diff --git a/builtins/Makefile b/builtins/Makefile new file mode 100644 index 0000000..0b350bc --- /dev/null +++ b/builtins/Makefile @@ -0,0 +1,5 @@ +SCRIPTS = endianness prog_bison prog_flex prog_gawk prog_gm4 prog_gmake + +SCRIPTSDIR = ${BUILTINSDIR} + +.include <mkc.mk> diff --git a/builtins/endianness b/builtins/endianness new file mode 100755 index 0000000..fb7d76e --- /dev/null +++ b/builtins/endianness @@ -0,0 +1,62 @@ +#!/bin/sh + +############################################################ +# Copyright (c) 2009 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +set -e + +LC_ALL=C +export LC_ALL + +################################################## + +pathpart=endianness +. mkc_check_common.sh + +trap "rm -f $tmpc $tmpo" 0 + +CFLAGS="$CFLAGS -D_GNU_SOURCE -D_ALL_SOURCE" + +check_me (){ + cat > "$tmpc" <<EOF +$3 + +int main (int argc, char **argv) +{ + #if $1 == $2 + return 0; +#else + error +#endif +} +EOF + if $CC -o "$tmpo" -c $CFLAGS $CPPFLAGS "$tmpc" 2>/dev/null; then + return 0 + else + return 1 + fi +} + +if check_me BYTE_ORDER LITTLE_ENDIAN ' +#include <sys/types.h> +#include <sys/param.h> +'; +then + echo little + exit 0 +fi + +if check_me BYTE_ORDER BIG_ENDIAN ' +#include <sys/types.h> +#include <sys/param.h> +'; +then + echo big + exit 0 +fi + +echo unknown +exit 0 diff --git a/builtins/prog_bison b/builtins/prog_bison new file mode 100755 index 0000000..dd7867f --- /dev/null +++ b/builtins/prog_bison @@ -0,0 +1,17 @@ +#!/bin/sh + +############################################################ +# Copyright (c) 2009 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +LC_ALL=C +export LC_ALL + +pathpart=' ' # fake +. mkc_check_common.sh + +find_n_match bison --version 'bison' + +echo '' diff --git a/builtins/prog_flex b/builtins/prog_flex new file mode 100755 index 0000000..d8cc5a8 --- /dev/null +++ b/builtins/prog_flex @@ -0,0 +1,18 @@ +#!/bin/sh + +############################################################ +# Copyright (c) 2009 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +LC_ALL=C +export LC_ALL + +pathpart=' ' # fake +. mkc_check_common.sh + +find_n_match flex --version 'flex' +find_n_match lex --version 'flex' + +echo '' diff --git a/builtins/prog_gawk b/builtins/prog_gawk new file mode 100755 index 0000000..d0403a7 --- /dev/null +++ b/builtins/prog_gawk @@ -0,0 +1,19 @@ +#!/bin/sh + +############################################################ +# Copyright (c) 2009 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +LC_ALL=C +export LC_ALL + +pathpart=' ' # fake +. mkc_check_common.sh + +find_n_match gawk --version 'gnu awk' +find_n_match nawk --version 'gnu awk' +find_n_match awk --version 'gnu awk' + +echo '' diff --git a/builtins/prog_gm4 b/builtins/prog_gm4 new file mode 100755 index 0000000..e82dc55 --- /dev/null +++ b/builtins/prog_gm4 @@ -0,0 +1,18 @@ +#!/bin/sh + +############################################################ +# Copyright (c) 2009 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +LC_ALL=C +export LC_ALL + +pathpart=' ' # fake +. mkc_check_common.sh + +find_n_match gm4 --version 'gnu m4' +find_n_match m4 --version 'gnu m4' + +echo '' diff --git a/builtins/prog_gmake b/builtins/prog_gmake new file mode 100755 index 0000000..b942600 --- /dev/null +++ b/builtins/prog_gmake @@ -0,0 +1,18 @@ +#!/bin/sh + +############################################################ +# Copyright (c) 2014 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +LC_ALL=C +export LC_ALL + +pathpart=' ' # fake +. mkc_check_common.sh + +find_n_match make --version 'gnu make' +find_n_match gmake --version 'gnu make' + +echo '' diff --git a/builtins/prog_mkdep b/builtins/prog_mkdep new file mode 100755 index 0000000..c2e1b94 --- /dev/null +++ b/builtins/prog_mkdep @@ -0,0 +1,39 @@ +#!/bin/sh + +############################################################ +# Copyright (c) 2013 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +LC_ALL=C +export LC_ALL + +extra_args="$*" + +pathpart='custom_nbmkdep' +. mkc_check_common.sh + +trap "rm -f $tmpc $tmpo" 0 + +cat > "$tmpc" <<'EOF' +#include <stdio.h> +EOF + +if test -n "$MKDEP_CC"; then + CC="$MKDEP_CC" + export CC +fi + +check_mkdep (){ + "$1" -f "$tmpo" $extra_args -I . -I `pwd` "$tmpc" +} + +for i in bmkdep nbmkdep mkdep; do + if test -z "`check_mkdep $i 2>&1 > /dev/null`"; then + mkc_which $i + exit 0 + fi +done + +echo '' diff --git a/builtins/prog_nbmkdep b/builtins/prog_nbmkdep new file mode 100755 index 0000000..aad3716 --- /dev/null +++ b/builtins/prog_nbmkdep @@ -0,0 +1,16 @@ +#!/bin/sh + +############################################################ +# Copyright (c) 2013 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +# workround for crappylaris +if test -z "$CRAPPYLIS" -a -x /usr/xpg4/bin/sh; then + CRAPPYLIS=1 + export CRAPPYLIS + exec /usr/xpg4/bin/sh "$0" "$@" +fi + +${0%%/prog_nbmkdep}/prog_mkdep -- diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..cfb95d4 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,53 @@ +mk-configure (0.28.0-1) unstable; urgency=medium + + * New upstream release. + * Drop an old patch and a custom sys.mk. + + -- Andrew Shadura <andrewsh@debian.org> Sun, 14 Sep 2014 17:41:43 +0200 + +mk-configure (0.27.0-1) unstable; urgency=medium + + * New upstream release. + + -- Andrew Shadura <andrewsh@debian.org> Fri, 22 Aug 2014 19:10:20 +0200 + +mk-configure (0.26.0-2) unstable; urgency=low + + * Fix pkg-config checks (Closes: #741837). + + -- Andrew Shadura <andrewsh@debian.org> Sun, 16 Mar 2014 15:29:25 +0100 + +mk-configure (0.26.0-1) unstable; urgency=low + + * New upstream release. + * Update watch file. + * Ship presentation.pdf. + * Recommend pkg-config. + + -- Andrew Shadura <andrewsh@debian.org> Tue, 18 Feb 2014 22:05:01 +0100 + +mk-configure (0.25.0-1) unstable; urgency=low + + * New upstream release. + * Drop old patches. + * Use bmake's .ALLTARGETS feature to check for Makefile targets presence. + + -- Andrew Shadura <andrewsh@debian.org> Sun, 05 Jan 2014 22:42:41 +0100 + +mk-configure (0.24.0-3) unstable; urgency=low + + * Fix the clean-up of MKC_SOURCE_FUNCLIBS. + + -- Andrew Shadura <andrewsh@debian.org> Fri, 15 Nov 2013 17:39:37 +0100 + +mk-configure (0.24.0-2) unstable; urgency=low + + * Fix the Debhelper addon. + + -- Andrew Shadura <andrewsh@debian.org> Fri, 15 Nov 2013 15:44:39 +0100 + +mk-configure (0.24.0-1) unstable; urgency=low + + * Initial release. + + -- Andrew Shadura <andrewsh@debian.org> Thu, 15 Aug 2013 01:02:03 +0200 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +9 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..d8e0cc1 --- /dev/null +++ b/debian/control @@ -0,0 +1,17 @@ +Source: mk-configure +Section: devel +Priority: optional +Maintainer: Andrew Shadura <andrewsh@debian.org> +Build-Depends: debhelper (>= 9), bmake (>= 20131001), + graphviz, latex-beamer, texlive-latex-extra, texlive-fonts-recommended, ghostscript +Standards-Version: 3.9.5 + +Package: mk-configure +Architecture: all +Depends: bmake, ${misc:Depends} +Recommends: pkgconf | pkg-config +Description: lightweight replacement for GNU autotools + mk-configure is a lightweight easy-to-use replacement for GNU autotools, + written in bmake (portable version of NetBSD make) and POSIX tools (shell, + awk etc). + diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..7b61bfb --- /dev/null +++ b/debian/copyright @@ -0,0 +1,220 @@ +This package was downloaded from https://github.com/cheusov/mk-configure/ + +Upstream Author: Aleksey Cheusov <vle@gmx.net> + +License: BSD (see below) + +Debian packaging in (c) 2013—2013 Andrew Shadura <andrewsh@debian.org> +and is licensed under the following license: + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the + distribution. + +THIS SOFTWARE IS PROVIDED BY THE DEBIAN PROJECT AND +CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +###################################################################### + +Different parts of mk-configure have different copyright holders. +All used licences are listed here. +See individual files for details. + +###################################################################### + +Copyright (c) 2009-2014 by Aleksey Cheusov + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the + distribution. + +THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND +CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +###################################################################### + +Copyright (c) 1988, 1989, 1993 + The Regents of the University of California. All rights reserved. +Copyright (c) 1988, 1989 by Adam de Boor +Copyright (c) 1989 by Berkeley Softworks + + +This code is derived from software contributed to Berkeley +by Adam de Boor. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. Neither the name of the University nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +###################################################################### + +Copyright (c) 1994-2009 The NetBSD Foundation, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND +CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +###################################################################### + +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. + +###################################################################### + +Files examples/hello_strlcpy/strlcpy.c and features/strl*/* are licensed as follows: + +Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND TODD C. MILLER DISCLAIMS ALL +WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER BE LIABLE +FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +###################################################################### + +Files: features/netbsd_sys_tree.h +Copyright: 2002 Niels Provos <provos@citi.umich.edu> +License: BSD-2 + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + . + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +###################################################################### + +Files: features/netbsd_sys_queue.h +Copyright: 1991, 1993 The Regents of the University of California. All rights reserved. +License: BSD-3 + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the University nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + . + THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + diff --git a/debian/docs b/debian/docs new file mode 100644 index 0000000..7c922dd --- /dev/null +++ b/debian/docs @@ -0,0 +1,5 @@ +doc/FAQ +doc/NEWS +README +doc/TODO +presentation/presentation.pdf diff --git a/debian/examples b/debian/examples new file mode 100644 index 0000000..e39721e --- /dev/null +++ b/debian/examples @@ -0,0 +1 @@ +examples/* diff --git a/debian/install b/debian/install new file mode 100644 index 0000000..56bab38 --- /dev/null +++ b/debian/install @@ -0,0 +1 @@ +debian/*.pm usr/share/perl5/Debian/Debhelper/Buildsystem/ diff --git a/debian/mkcmake.pm b/debian/mkcmake.pm new file mode 100644 index 0000000..3c1e83c --- /dev/null +++ b/debian/mkcmake.pm @@ -0,0 +1,99 @@ +# A debhelper build system class for handling simple mk-configure-based projects. +# +# Copyright: © 2008 Joey Hess +# © 2008-2009 Modestas Vainius +# License: GPL-2+ + +package Debian::Debhelper::Buildsystem::mkcmake; + +use strict; +use Debian::Debhelper::Dh_Lib qw(compat escape_shell clean_jobserver_makeflags dpkg_architecture_value); +use base 'Debian::Debhelper::Buildsystem::makefile'; + +sub DESCRIPTION { + "mk-configure" +} + +sub exists_make_target { + my ($this, $target) = @_; + + # Use -V .ALLTARGETS to get the list of targets; -n is + # needed to avoid executing anything + my @opts=("-n", "-V", ".ALLTARGETS"); + my $buildpath = $this->get_buildpath(); + unshift @opts, "-C", $buildpath if $buildpath ne "."; + open(SAVEDERR, ">&STDERR"); + open(STDERR, ">/dev/null"); + open(MAKE, "-|", $this->{makecmd}, @opts); + my $output=<MAKE>; + chomp $output; + close MAKE; + open(STDERR, ">&SAVEDERR"); + return defined $output && grep(/^$target$/, split(" ",$output)); +} + +# Currently, we don't want parallel build with bmake. +sub do_make { + my $this=shift; + + # Avoid possible warnings about unavailable jobserver, + # and force make to start a new jobserver. + clean_jobserver_makeflags(); + + my @opts; + my $prefix = "/usr"; + push @opts, "PREFIX=${prefix}"; + push @opts, "MANDIR=${prefix}/share/man"; + push @opts, "INFODIR=${prefix}/share/info"; + push @opts, "SYSCONFDIR=/etc"; + my $multiarch=dpkg_architecture_value("DEB_HOST_MULTIARCH"); + if (! compat(8)) { + if (defined $multiarch) { + push @opts, "LIBDIR=${prefix}/lib/$multiarch"; + push @opts, "LIBEXECDIR=${prefix}/lib/$multiarch"; + } + else { + push @opts, "LIBEXECDIR=${prefix}/lib"; + } + } + else { + push @opts, "LIBEXECDIR=${prefix}/lib/" . sourcepackage(); + } + + $this->doit_in_builddir($this->{makecmd}, @opts, @_); +} + +sub check_auto_buildable { + my $this=shift; + my ($step)=@_; + + if (-e $this->get_buildpath("makefile") || + -e $this->get_buildpath("Makefile")) + { + my $ret = ($this->SUPER::check_auto_buildable(@_)); + + open (MAKEFILE, "makefile") || open (MAKEFILE, "Makefile") || + return 0; + + while (<MAKEFILE>) { + chomp; + if (/^\.?\s*include\s+<mkc/) { + close MAKEFILE; + $ret++; + return $ret; + } + } + close MAKEFILE; + return $ret; + } + return 0; +} + +sub new { + my $class=shift; + my $this=$class->SUPER::new(@_); + $this->{makecmd} = "mkcmake"; + return $this; +} + +1 diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..a681599 --- /dev/null +++ b/debian/rules @@ -0,0 +1,21 @@ +#!/usr/bin/make -f + +export PREFIX := /usr +export SYSCONFDIR := /etc +export MANDIR := $(PREFIX)/share/man +export MKFILESDIR := $(PREFIX)/share/mk-configure/mk + +%: + dh $@ --buildsystem=bmake + +override_dh_auto_clean: + -dh_auto_clean + bmake cleandir-presentation + +override_dh_auto_build: + dh_auto_build + bmake pdf + +override_dh_auto_test: + +.PHONY: override_dh_auto_test diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/debian/watch b/debian/watch new file mode 100644 index 0000000..e87cb89 --- /dev/null +++ b/debian/watch @@ -0,0 +1,5 @@ +# Compulsory line, this is a version 3 file +version=3 + +http://mova.org/~cheusov/pub/mk-configure/mk-configure-(\d.*).tar.gz + @@ -0,0 +1,247 @@ +---------------------------------------------------------------------- +Q: It looks like you are reimplenting the wheel. There are lots of + alternatives to GNU autoconf, e.g. CMake, scons, waf, + PMK (pre make kit) and others. + +A: mk-configure has different design and goals. Just to note a few: + simplicity for developers, Keep It Small and Simple, STOP CODE + GENERATION!, bmake is magic enough, using POSIX shell and POSIX for + implementing basic checks, and some others. If you like these + principles maybe you'll find mk-configure interesting. In this case + try to use it and help me to improve it. Any kind of feedback is + welcome, I don't ask you to send me patches ;-) + Otherwise just ignore it, why bother. + +---------------------------------------------------------------------- +Q: Using POSIX shell and POSIX utils for implementing a build system + sounds terrible to me. Why not to use more powerful languages like + Perl, Python, Ruby and others? + +A: Python, Ruby and Perl are very big. I don't want to depend on such + a big tools. I also don't like when backward compatibility is + broken with new releases of program language. Finally I dislike + Perl and Python for their stupid syntax. Ruby is much better but it + is also very big and the language is not very stable. + +---------------------------------------------------------------------- +Q: Perl/Python/Ruby are available on almost every OS that ever existed + even on Windows and Symbian. Why you limit mk-configure to POSIX + compatible operating systems? + +A: First, I don't use Windows and don't care about it. Second, if you + want to write software both for UNIX-like OSes and Windows there + are no problems. You can use Interix, Cygwin or any other POSIX + subsystem for Windows to build your software. By the way, + cross-compilation is one of my priorities. So, there is no problem + in cross-compiling your software for embedded platforms, Windows or + any other OS your software supports. + +---------------------------------------------------------------------- +Q: You say that portability is one of the main goal of your + mk-configure (build automation software MUST be portable. Right?). + At the same time you say you use POSIX shell and POSIX tools. + My experience says me that it is just not possible to write + something REALLY portable in shell/awk/sed etc. + +A: I know very well how broken POSIX tools may be on some OSes and + hardware platforms. At the moment mk-configure supports the + following platforms: NetBSD, Linux, FreeBSD, DragonFlyBSD, Darwin, + HP-UX, Tru64, QNX, OpenBSD, Interix, Cygwin, MirOS BSD and Solaris. + If you find a bug please let me know. Also note that + mk-configure has lots of regression tests. + I don't make releases without testing on all platforms + available to me. + +---------------------------------------------------------------------- +Q: You just didn't read autobook and don't know how to use GNU + autotools properly. Your criticism is inadequate. First, read the + documentation! + +A: The question is not about me personally. Try to maintain software + packages in BSD/Linux/... distributions and you'll understand that + LOTS of FOSS developers actually do not understand how to use GNU + autotools properly. I believe this is because autotools's + complexity has grown beyond all reasonable levels. + +---------------------------------------------------------------------- +Q: bmake? What is it? Is it for NetBSD only? + +A: bmake is a portable version of NetBSD make that supports at least + the following operating systems and POSIX environments (besides + NetBSD of course): FreeBSD, DragonFlyBSD, OpenBSD, Linux, Solaris, + AIX, HP-UX, QNX, A/UX, OSF/1, Darwin, Interix, UnixWare and IRIX. + +---------------------------------------------------------------------- +Q: NetBSD make? Then why not to support FreeBSD/OpenBSD makes? + +A: OpenBSD and FreeBSD make(1)s are different and NetBSD make + is more powerful. More over, NetBSD and Free/OpenBSD make(1)s are + incompatible in some aspects. + +---------------------------------------------------------------------- +Q: Learning yet another make doesn't look like a good idea to me. + Nobody will use your mk-configure because it requires learning + bmake. + +A: First, bmake is easy. Learning it doesn't require too much time. + bmake is MUCH simplier than e.g. Python (see scons). I also + assume that every UNIX programmer knows the basic make + concepts. Second, software building rules are usually rather simple + and therefore you need not be an expert in bmake for writing Makefiles. + If building rules for your project are extremely complex, maybe the + problem is with your project, try to simplify it ;-) + Moreover, mk-configure provides several examples in + examples/ subdirectory. I hope they simplify learning mk-configure + significantly. + +---------------------------------------------------------------------- +Q: Yet another build automation software makes a packager's life + harder. + +A: Not a big problem. First, packagers are specialists. They should + learn new things every time ;-) . Adding support for + mk-configure into your packaging system should not be a problem. + Have a look at pkgsrc (www.pkgsrc.org) for examples. Makefiles + for projects based on GNU autotools require the line + + GNU_CONFIGURE = yes + + Projects based on CMake need the following line + + USE_CMAKE = yes + + Projects using mk-files require + + USE_BSD_MAKEFILE = yes + + I think this is easy. If your packaging system doesn't allow the + similar functionality, improve it ;-) + +---------------------------------------------------------------------- +Q: Why NetBSD bmake was chosen? Why not "standard" GNU make? Today + Linux has MUCH more developers than FreeBSD/OpenBSD/Solaris and of + course NetBSD. Most programmers using Linux use GNU make. Without + support of Linux developers your project is dead. + +A: NetBSD make was chosen for the following reasons: 1) when I started + mk-configure I could not find good analogs for mk-files written for + GNU make; 2) in my view bmake is simpler and more convenient for use + than GNU make; 3) I hate gmake's foreach/eval/call construct, bmake's + .for/.endfor is MUCH more convenient and easier to use; 4) gmake + starts finding includes starting from CWD, this is terrible, bmake + starts searching for "includes" starting from the including + makefile's directory. Note that mk-configure and mk-files widely use + the .for/.endfor construct. + + Theoretically it is possible to implement a full analog for + mk-configure based on GNU make instead of bmake but I have no + time to do that. If you want to, let me know. + +---------------------------------------------------------------------- +Q: It's time to bury ALL make-like programs. + Use modern make replacements, Luke. + +A: It's true that make-like programs have some limitations. + But none of them seem critical to me. + I'm quite happy with traditional makes (NetBSD make and GNU make). + +---------------------------------------------------------------------- +Q: You propose setting build options through environment and + bmake's options instead of ./configure --option=xxx. + Are you serious? + +A: Yes, I don't see significant difference between setting paths and + build options via --options and command line arguments and + environment. The only thing lost is that autoconf's ./configure + checks for correctness of the given options but I don't think this + is a significant advantage. On the other hand using environment + variables for setting build options has its own advantages for + the development. You can set them ONCE in a shell session and + that's enough. Alternatively (and even better) you can add + + .sinclude "my_local_settings.mk" + + to Makefile and write your settings down to that file. Then + your local build options will take effect every time you run + mkcmake. Easy? + + If you don't like .sinclude you can use + + bmake -f my_local_settings.mk -f Makefile + + command. Interactive shell's aliases and functions might help to make + things even easier. + +---------------------------------------------------------------------- +Q: It's known that libxxx has different places in different Linux + distributions. Can mk-configure find it automatically? + +A: No. Software build tools MUST NOT have an artificial + intelligence inside. If you need libxxx tell mk-configure correct + CPPFLAGS (-I/headers/here) and LDFLAGS (-L/libraries/here). + This is how it works. mk-configure will not search for includes + in /usr/local, /opt/sfw or anywhere unless you ask it to do so + explicitely. + +---------------------------------------------------------------------- +Q: As far as I can see your mk-configure doesn't support ALL features + supported by GNU autotools and some other competitors. + +A: If you see this tell me what type of functionality you are talking + about. If I find it helpful I'll implement it in future + releases of mk-configure. + +---------------------------------------------------------------------- +Q: How about GUI for "configuration" stage? + +A: Most often today's users use software from their system in a + prebuilt form. I don't think software packagers need a GUI. On the + other hand, if you need a GUI, nothing prevents you from creating it. + +---------------------------------------------------------------------- +Q: GNU autotools provides two-phase project builds and this is a good + idea. mk-configure lacks support for it. + +A: I personally don't like two-phase ideology. I see one phase + "build the software taking into account my platform's features". + If you want to check for errors first, run + + bmake errorcheck + +---------------------------------------------------------------------- +Q: Does mk-configure support caching? + +A: If you mean caching of the platform features, my answer is YES. + Look at _mkc_* files and documentation for MKC_CACHEDIR variable. + If you mean caching of object files, then NO. This is not + mk-configure's task. For this use distcc(1) or similar tools. + +---------------------------------------------------------------------- +Q: mk-configure lacks support for Qt/KDE etc. + +A: Software is developed step-by-step. If you need something, let me + know. I'll implement missing features in future releases of + mk-configure. + +---------------------------------------------------------------------- +Q: mk-configure lacks support for my favourite + programming language XXX. + +A: First, let me know about it. Second, nobody prevents you from + creating rules for your language directly in Makefile or in your + own (local to your project) include files. + +---------------------------------------------------------------------- +Q: How about integration of mk-configure to Eclipse or... + +A: I don't use such IDEs but I agree it whould be nice to have such + support. + +---------------------------------------------------------------------- +Q: It looks like mk-configure is suitable for small-sized projects + but is not ready for huge ones. + +A: Suppose you are right. How about the fact that 99% of all FOSS + projects are small or medium in size? ;-) + +---------------------------------------------------------------------- diff --git a/doc/LICENSE b/doc/LICENSE new file mode 100644 index 0000000..b55bbb2 --- /dev/null +++ b/doc/LICENSE @@ -0,0 +1,129 @@ +Different parts of mk-configure have different copyright holders. +All used licences are listed here. +See individual files for details. + +###################################################################### + +Copyright (c) 2009-2014 by Aleksey Cheusov + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the + distribution. + +THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND +CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +###################################################################### + +Copyright (c) 1988, 1989, 1993 + The Regents of the University of California. All rights reserved. +Copyright (c) 1988, 1989 by Adam de Boor +Copyright (c) 1989 by Berkeley Softworks + + +This code is derived from software contributed to Berkeley +by Adam de Boor. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. Neither the name of the University nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +###################################################################### + +Copyright (c) 1994-2009 The NetBSD Foundation, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND +CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +###################################################################### + +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. + +###################################################################### + +File examples/hello_strlcpy/strlcpy.c is licensed as follows: + +Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND TODD C. MILLER DISCLAIMS ALL +WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER BE LIABLE +FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/doc/Makefile b/doc/Makefile new file mode 100644 index 0000000..96a2fca --- /dev/null +++ b/doc/Makefile @@ -0,0 +1,4 @@ +FILES = ../README NEWS TODO LICENSE FAQ NOTES +FILESDIR = ${DOCDIR} + +.include <mkc.mk> diff --git a/doc/NEWS b/doc/NEWS new file mode 100644 index 0000000..7ebad3a --- /dev/null +++ b/doc/NEWS @@ -0,0 +1,1178 @@ +====================================================================== +Version 0.28.0, by Aleksey Cheusov, Sun, 14 Sep 2014 14:52:34 +0300 + + LIBDEPS, STATICLIBS, DPLDADD, DPLIBDIRS and DPINCDIRS variables were + introduced. With their help one can specify library dependencies in + the top-level Makefile. Users are also able to build some libraries + statically even if they were designed to be a dynamic libraries. + + New variable FOREIGN was introduced. With its help one can embed + autotools-based projects (as a subproject) to mk-configure-based once. + See mkc_imp.foreign_autotools.mk section in man page for details. + + Support for Darwin was fixed. Nowadays it uses clang. + + New features were introduced: + - "progname" for setprogname(3) and getprogname(3) BSDisms; + - "err" for err(3), errx(3), verr(3) and verrx(3) BSDisms; + - "warn" for warn(3), warnx(3), vwarn(3) and vwarnx(3) BSD-isms; + - "fgetln" for fgetln(3) BSD-ism; + + Support for Haiku was fixed. It does not support hard links + and uses LIBRARY_PATH. + + LDCOMPILER variable was removed. + Compiler is always used for linking. + + New builtin "prog_gmake" was introduced which search GNU make. + + INTERNALLIBS variable was introduced. With its help one can + implement libraries common for several subprojects. + + COMPATLIB variable was introduced. It is ideal solution for + portability code. + + MKC_FEATURES: all objects are removed by target "clean" + + Target "errorcheck" was added to ALLTARGETS. Therefore it also have + pre_, do_, post_ counterparts. + + VARDIR, SHAREDSTATEDIR, SUBPRJSRCTOP, CPPFLAGS0 variables were introduced. + + MKC_SOURCE_FUNCSLIBS: .o{s,p} objects are also removed by target "clean" + + Hardcoded /etc/mk.conf is not included anymore. New mk-configure + specific configuration file @sysconfdir@/mk-c.conf was introduced. + + Additions to doc/NOTES + + .depends is added to DISTCLEANDIRS only for non-empty SRCS + + mkc_imp.intexts.mk: new error type for odd tokens in INTEXTS_REPLS + + MKDEP_CC is shquoted when passed to mkdep(1) as CC. + + Code clean-ups, more regression tests. + + This release was sucessfully tested on the following platforms. + NetBSD-6.1/x86_64/gcc-4.5, FreeBSD-9.0/i386/gcc-4.2, + OpenBSD-4.9/i386/gcc-4.2, DragonFlyBSD-3.4/x86_64/gcc-4.7, + Darwin-14.0/x86_64/clang-600.0.53, SunOS-5.11/i86pc/gcc-4.7, + SunOS-5.10/sparc/{gcc-4.8,SunStudio-12.3}, diverse + Linux-es/{gcc,icc-12.1,SunStudio-12.3}, Haiku/gcc-4.8. + +====================================================================== +Version 0.27.0, by Aleksey Cheusov, Sun, 13 Jul 2014 17:03:12 +0300 + + Fix pkg-config support (github issue #8). + Thanks to Andrew Shadura for the report. + + Fix support for mixed C/C++ projects. + + Fixes for Interix and Cygwin where users and groups may have spaces. + Thanks to Michael Crogan for the report. + + Fix in mkc_imp.f_SLIST.mk (we have to restore original MKC_NOAUTO) + + mkc.lib.mk: + - MKPIE=yes also turns on PIC + + pre_*, do_* and post_* targets were introduced. ALLTARGETS was + introduced which lists all targets with pre_/do_/post_ + counterparts. + + examples/hello_superfs: + - new interesting feature proposed by Michael Crogan + + As makedepend(1) is broken on Linux, {b}mkdep(1) is used for + generating .depend by default. + + mkc_install: + - new option -l for symlinking + - fixes for files and directories with spaces + +====================================================================== +Version 0.26.0, by Aleksey Cheusov, Mon, 3 Feb 2014 00:32:51 +0300 + + "Features" framework was implemented (variable MKC_FEATURES). In + general, a feature is something that has problems with + portability. This may be a function name or header missing on some + platforms, for example. What developer needs to do is to add + FEATURENAME to MKC_FEATURES variable and add #include + <mkc_FEATURENAME.h> where it is needed. Internally, system + requiremets are checked in the automatically included + mkc_imp.f_FEATURENAME.mk file and all required actions (includes, + define checks etc.) are made in mkc_FEATURENAME.h header file. + Currently the following features are provided: strlcat, strlcpy, + getline, libm, libdl, RB, SPLAY, SLIST, SIMPLEQ, STAILQ, LIST, TAILQ + and CIRCLEQ. Original idea was stolen from pkgsrc. + + mkc_imp.pkg-config.mk: + - New variables MKC_CHECK_PKGCONFIG and MKC_REQUIRE_PKGCONFIG were + introduced. They work just like other MKC_{CHECK,REQUIRE}_* + variables from mkc.configure.mk. Thanks to Andrew Shadura for + pushing me to this direction. + + mkc.configure.mk: + - MKC_{CHECK,REQUIRE}_PROTOTYPES were introduced. With their help + mk-configure is able to check C function prototypes. This + feature was proposed by Andrew Shadura. + + If ${MKC_CACHEDIR} does not exit, it is automatically created. + + ${SRCTOP}/Makefile.common is included by all subprojects if it + exists. It can be used as a replacement or addition for + ../Makefile.inc. + + Valiables SRCDIR_<dir>, SRC_PATHADD, MKC_SOURCE_DIR, LDFLAGS0 and + LDADD0 were introduced. + + Wrongly named builtin 'endianess' was renamed to 'endianness'. + Thanks to Andew Shadura for the report and fix! + + mk-configure itself is now 2-level project. + This allows me to run an arbitrary regression test like the following + bmake test-examples/hello_world + Hurray! :-) + + mkc.subprj.mk: + - Now it works correctly if NOSUBDIR is not empty. + Also, NOSUBDIR affects NODEPS and therefore the dependency graph. + - New target "print-deps" that outputs the dependency graph was + introduced. + + -O is added to CFLAGS if USE_FORT==yes, seen on Linux/ppc64/gcc + + Documentation: clean-ups, grammar fixes, minor improvements. + + Fix. Some @@ patterns in mk-configure.7 should not be replaced with + directories. Thanks to Andrew Shadura for the report! + + This release was successfully tested on the following platforms: + NetBSD-6.1/amd64, FreeBSD-8.3/amd64, OpenBSD-{4.9,5.3}/x86, + DragonFlyBSD-3.4/x86, Linux/{x86,amd64}, SunOS-5.10/sparc, + SunOS-5.11/x86. + +====================================================================== +Version 0.25.0, by Aleksey Cheusov, Wed, 1 Jan 2014 19:28:55 +0300 + + Build infrastructure for mk-c itself was completely reimplemented. + Now it looks much better and is more flexible for further extensions. + + NetBSD version of mkdep(1), traditional BSD mkdep(1) or + makedepend(1) is needed at build time. + + LDCOMPILER defaults to "yes". + + Variable TARGETS is now visible to users and is documented. It + contains all recursive targets and may be used for adding user's + functionality to mk-c. + + FIX: Parallel installation ("mkcmake install -jN") now works + correctly. "installdirs" is activated before "install". Report by + Michael Crogan. + + During build object directories are created automatically by default + when MAKEOBJDIR or MAKEOBJDIRPREFIX are set. New recursive target + "obj" and variable MKOBJDIRS were introduced. + Report by Michael Crogan. + + New variable MKRELOBJDIR was introduced. With its help one can + create object directories relative to top-level object directory + (like MAKEOBJDIRPREFIX but without top-level ${.CURDIR} in paths). + Thanks to Michael Crogan. + + target "depend": + - FIX. Original implementation relied on NetBSD version of + mkdep(1). So, it didn't work on Linux, FreeBSD and others with + original BSD mkdep(1). Type of mkdep(1) is detected at + mk-configure build time. Report by Michael Crogan. + + New variables LN, LN_S, MKDIR, RM, CLEANFILES_CMD, CLEANDIRS_CMD, + UNINSTALL, MAKEDEPEND, OBJTOP, CC_PREFIX, CXX_PREFIX were + introduced. + + New variable NODEPS was introduced. With its help one can cut off + the dependency graph for particular targets. + + New variable BMAKE_REQD was introduced. + + New variable SRCTOP was introduced. With its help + "mkcmake -C subdir target" may work just like "mkcmake target-subdir". + + New variables CFLAGS.dflt.${CC_TYPE} and CXXFLAGS.dflt.${CXX_TYPE} + were introduced. They default to -Qunused-arguments + for clang and clang++. + + mkc.init.mk can be invoked by users directly for setting all + required variables and further checks (CC_TYPE, LD_TYPE, OPSYS etc.). + + mkc_imp.links.mk: + - This module was reimplemented from scratch. + Bug with parallel installation (LINKS and MLINKS) was fixed. + + mkc.minitest.mk: + - new variable TEST_PREREQS was introduced. + + mkc_imp.inc.mk: fix for ${INCS} installation problem happened when + headers are built in ${.OBJDIR}. Report by Jan Smydke. + + mkc_imp.info.mk: + - fix for MKINSTALL=no. "installdirs" unexpectedly created target + directories. + + mkc.configure.mk: + - fix issue with MKC_CHECK_CUSTOM when ${.OBJDIR} != ${.CURDIR} + - MKC_CHECK_PROGS: PROG.<prog> is set even if full path was + specified. In addition existence and executability of the + specified file is always checked. + - fix for MKC_SOURCE_FUNCLIBS. Not all objects were cleaned + correctly by target "clean". Now objects are added to CLEANFILES + unconditionally. + - negative results for MKC_REQUIRE_* are not cached. This gives + users ability to fix the problem by changing the environment + and try again. + - MKC_CHECK_BUILTINS. Additional builtin checks were added: + "prog_mkdep" and "prog_nbmkdep" for original BSD mkdep(1) and + NetBSD version of mkdep(1) respectively. + + mkc_imp.intexts.mk fixes: + - Targets "clean" and "cleandir" do not fail anymore if INTEXTS_REPLS + contains empty variables. + - Target "all" works correctly if INFILES or INSCRIPTS contain + files with directories. + + mkc.sub{dir,prj}.mk: + - ${MAKEFLAGS} is passed to recursive ${MAKE}s. + - {nodeps-,subdir-,}dir:T are also targets, that is, one can also + use the last component of subdirectory as_a_part_of/as_a_whole + target. If you want to disable this, set SHORTPRJNAME to "no". + + mkc_imp.subdir.mk was reimplemented using mkc_imp.subprj.mk + + mkc_imp.dep.mk: + - documentation for this module was added. + - support for SHRTOUT=yes + - new variable DPSRCS was introduced + - MKDEP_SUFFIXES also contains .os and .op. Report by Michael Crogan. + - Target "clean" does not remove .depend and .d files. + Target "cleandir" does. NetBSD mk files work the same way. + Report by Michael Crogan. + + MKPIE/SHLIB_*: + - s/-KPIC/-xcode=pic32/ for SunStudio compilers + + MKSSP=yes: + - Support for IBM XL Compiler was added (not tested due to lack of such iron) + - Support for Intel C/C++ Compiler was added + + Documentation fixes, updates and improvements. A lot of new + examples/. A lot of new regression tests. + + Tools: + Long option --help was removed from all utilities + - mkc_install: + - fix for problem with parallel "installdirs" (race condition). + - Options -t and -b were removed. + - mkc_check_prog: option -i is documented in man page + - mkc_check_compiler: workarounds for buggy SunStudio C++ + compiler ("CC -E -" exits with error). + + All test are run with MKCATPAGES=no by default. + + myprojects.pdf: pipestatus also uses mk-configure. + +====================================================================== +Version 0.24.0, by Aleksey Cheusov, Fri, 8 Mar 2013 13:18:00 +0300 + + mkc.sub{dir,prj}.mk: + - support for subprojects containing / symbol was added. In + OBJDIR_<dir> variable slashes are replaced with underlines. + In addition OBJDIR_<dir:T> variable is set. + - now also run the target "errorcheck" + - now work correctly with non-empty MAKEOBJDIR + and MAKEOBJDIRPREFIX. + + Minor improvements in examples/*/linkme.mk + + DPLIBS is deprecated, use LDADD instead. + + ${MKC_SOURCE_FUNCLIBS}.o is added to CLEANFILES if it is set. + + Minor fixes in mkc_imp.lua.mk (LUA_MODULES vs. LUA_LMODULES). + + Some improvements and fixes in man page and FAQ. + Thanks to Jeremy Reed, Min Sik Kim and Jan Smydke. + +====================================================================== +Version 0.23.0, by Aleksey Cheusov, Sun, 22 Jul 2012 14:06:06 +0300 + + mkc.subprj.mk: + - Support for "virtual" subproject was added. Subprojects listed + in SUBPRJ and SUBPRJS_DFLT are not necessarily associated with + a subdirectory. See examples/hello_superfs for example. + Virtual subproject is a way to group several subprojects into + new one. + + New variables were introduced: COPTS_<proj> OBJCOPTS_<proj> + LDADD_<proj> LDFLAGS_<proj> CPPFLAGS_<proj> CXXFLAGS_<proj>. + See the manual page for details. + + Fix: OBJDIR_<subdir> variables now always contain full paths. + + Fix in mkc_which(1). Now it differs directories and regular files. + + Minor fixes in regression tests for EXPORT_SYMBOLS. + + mkc.lib.mk: + - SHLIB_MINOR unconditionally defaults to 0 + + More slides in .pdf presentation: + - cross-compilation + - EXPORT_SYMBOLS + + Fixes for Pascal support + + Minor fixes in the man page + +====================================================================== +Version 0.22.0, by Aleksey Cheusov, Fri, 9 Mar 2012 20:26:34 +0300 + + Improvements in cross-compilation. The following variables were + introduced: TOOLDIR, SYSROOT, TOOLCHAIN_PREFIX and + MACHINE_GNU_PLATFORM. + + PROGS variable was introduced (sf.net bug #3445658). + + Support for Lua submodules was added (e.g. net.socket.lua -> + net/socket.lua). New variable LUA_MODULES was introduced for this + purpose. + + MKPIE (Position Independent Executables), USE_SSP (Stack Smashing + Protection), USE_FORT and USE_RELRO variables were introduced for + security reasons. + + Variable OBJDIR_<dir> was introduced. + + mkc.subdir.mk and mkc.subprj.mk: Commands associated with targets + "all", "install", "clean", "cleandir", "depend", "test", + "installdirs", "uninstall", "errorcheck" and "filelist" in Makefile + override the standard behaviour. + + MKC_REQUIRE_HEADERS, MKC_REQUIRE_DEFINES, MKC_REQUIRE_TYPES, + MKC_REQUIRE_VARS, MKC_REQUIRE_MEMBERS, MKC_REQUIRE_FUNCS<n> and + MKC_REQUIRE_CUSTOM do not change CFLAGS. + + mkc.subdir.mk and mkc.subprj.mk: "cleandir" target takes into + account CLEANFILES, CLEANDIRS, DISTCLEANFILES and DISTCLEANDIRS + variables (removes files). + + PCNAME.<lib> variable was introduced in mkc_imp.pkg-config.mk, this + is a map from library name to pcname (.pc). + + Improvements for SHRTOUT. + + New variable OBJCOPY was introduced. + + Update of the presentation. + + Fix in manual page (sf.net bug #3441610). + + New regression tests (examples). + +====================================================================== +Version 0.21.2, by Aleksey Cheusov, Sat, 22 Oct 2011 01:50:05 +0300 + + mkc_check_compiler has been reimplemented. This fixes problems + on system with /bin/sh == bash (affected versions: 0.21.1) + and makes it drammatically faster. + +====================================================================== +Version 0.21.1, by Aleksey Cheusov, Tue, 13 Sep 2011 11:28:26 +0300 + + Target "errorcheck" ("configure") cannot work in parallel. + + Fix bug appeared in parallel builds (make -j). + Thanks to Alexander Nasonov. + + Support for IRIX64 and Haiku was implemented. + + PDF presentation update + + Minor clean-ups + +====================================================================== +Version 0.21.0, by Aleksey Cheusov, Sun, 24 Oct 2010 17:47:19 +0300 + + Support for clang compiler was implemented. + + Documentation and presentation were updated. There are new projects + using mk-configure. + + mkc_install is always used for installing mk-configure. + This simplifies an installation process on non-BSD platforms. + + WARNS variable: support for icc was added. + + New variable LEXLIB library responsible for -ll/-lfl was introduced. + See examples/hello_calc2. + + mkc_check_compiler: in order to differentiate icc from gcc, a check + for Intel C/C++ compiler is run first. + + New target "filelist" that outputs a list of files for the whole + project was introduced. + + Makefile: mk-configure's mk files are unconditionally installed to + its own directory in order to avoid potential conflicts with + system-wide sys.mk on BSD platforms. + + mkc.configure.mk: HAVE_FUNCLIB.main is always set to 1. + mkc_check_funclibs is not run for checking presense of function + "main" in libc. + + New variable MKCHECKS was introduced. + + Useless rule ".sh:" was removed. + +====================================================================== +Version 0.20.0, by Aleksey Cheusov, Sun, 19 Sep 2010 21:46:25 +0300 + + New variable PROJECTNAME, see the manual page. + + New variable EXPORT_DYNAMIC for making all symbols in executable + visible to linked or dlopen'ed libraries. It is supported on *BSD, + Linux, SunOS, QNX, Interix, OSF1, HP-UX. + + New variable CFLAGS.pic. See the manual page. + + EXPORT_SYMBOLS: On systems using GNU ld, i.e. *BSD, Linux, QNX + etc. 'ld --version-script' is used in order to specify a list of + exported symbols instead of --retain-symbols-file + + Lua support: + - Lua support didn't work properly if only one of LUA_LMODULES or + LUA_CMODULE were specified. Now it is fixed. + - New regression test examples/hello_lua2. + - Force building Lua modules with .so extension. + + Darwin: + - support for EXPORT_SYMBOLS was added + - DLLs (MKDLL=yes) are built as bundles and have .bundle extension + + /usr/bin/install is used as INSTALL only on *BSD platforms. On all + others mkc_install is used. + + Interix: + - 775:664 permissions are used only for +Administrator user. + - "installdirs" target creates directories with 775 permission if + needed. + + OSF1: + - better handling the so_location files. + + mkc_imp.arch.mk: + - PROJECTNAME variable is used for creating archives and .deb + package. + +====================================================================== +Version 0.19.0, by Aleksey Cheusov, Fri, 3 Sep 2010 23:19:44 +0300 + + FIX: LPREFIX, YPREFIX and YHEADER now works as + documented. Regression test for them is added. + + As of this release target "install" creates target directories by + default, i.e. it envokes target "installdirs" before installing + files. For disabling this behaviour, you may set MKINSTALLDIRS + variable to "no". + + mkc.lib.mk: + - New variable EXPORT_SYMBOLS for exporting (in shared object + library) only specified symbols. At the moment the following + platforms support this: Solaris and those using GNU ld, + that is *BSD and Linux. + - "ld -h" is enabled on Solaris. + + mkc.subdir.mk and mkc.subprj.mk: + - Two new variables: EXPORT_VARNAMES and NOEXPORT_VARNAMES for + exporting variables before building subprojects. By default + MKC_CACHEDIR is exported. As a result _mkc_* cache files will + be placed in one directory for all subprojects. + - New variable NOSUBDIR for excluding specified subprojects from + build. Useful side effect: by using this variable you may + disable some regression tests while running "bmake test". + - Makefile.rec file if present is included by ALL subprojects + recursively. See tests/rec_makefiles. + + mkc.subprj.mk: + - New target subdir-<trg>-<subdir>, synonym for + nodeps-<trg>-<subdir>. + + mkc.configure.mk: + - MKC_CHECK_PROGS: mkc_check_progs is not called if path to + program is absolute. + + mk-configure.7 shows in <> typical place where variables shall be used. + + On Solaris LD=/usr/ccs/bin/ld by default. + On OSF1 LD=/usr/bin/ld by default. + On QNX mkc_install is used as install program by default. + + mkc_check_custom: + - FIXED: ambiguous arguments of command "test" (seen on QNX) + + regression tests: + - New test examples/hello_plugins replacing + examples/hello_dlopen and examples/hello_dll + - New test examples/hello_calc + +====================================================================== +Version 0.18.0, by Aleksey Cheusov, Tue, 27 Jul 2010 21:06:56 +0300 + + Several new variables are introduced: + - LUA_LMODDIR and LUA_CMODDIR - installation directories + for Lua modules written in Lua and C. + - MKC_VERSION is now documented. + - MLINKS now works just like in NetBSD. + - CFLAGS.warns.<cctype>.<warn-level> and + CXXFLAGS.warns.<cctype>.<warn-level> are now documented. + Feel free to set them in sys.mk before installation. + - WARNERR for forcing warnings to be reported as errors. + + New targets are introduced: bin_tar, bin_targz, bin_tarbz2, + bin_zip and bin_deb for creating archive files or .deb + package containing an installation image (Ex: + examples/hello_files). This also introduces new variables: TAR, + GZIP, BZIP2 and ZIP. + + Documentation: + - Just a few notes about cross-compilation in mk-configure.7 + - New slides, fixes and improvements in doc/presentation.pdf + - README: feel free to edit sys.mk before installation + - README: a few notes about tools used for development. + + Support for POD (Plain Old Documentation) is added + (.pod.1, ..., .pod.9 and .pod.html suffix rules). + New variables for this: POD2MAN, POD2MAN_FLAGS, POD2HTML + and POD2HTML_FLAGS. Ex: examples/hello_xxzip + + ../Makefile.inc is included automatically if exists just like + in NetBSD. Ex: hello_superfs. + + .ORDER: installdirs install. This should fix -j<N> problem. + Thanks to FreeBSD buys, + swell.k at gmail.com and Mikolaj Golub + + WARNS: add support for HP-UX C/C++ + + all:${FILES} ${MAN} etc. for the case when FILES are generated. + Thanks to Jan Smydke. + + New examples (regression tests): hello_superfs, hello_xxzip. + +====================================================================== +Version 0.17.0, by Aleksey Cheusov, Tue, 22 Jun 2010 23:44:08 +0300 + + mkc_imp.pkg-config.mk: + - FIXED: double applying -L, -l and -I options got from pkg-config. + Solution: .unset PKG_CONFIG_DEPS + - Additional checks for INSTALL_{C,L}MOD pkg-config variables, + they must be defined. + + CC_TYPE, CXX_TYPE and LD_TYPE variables are a part of mk-c's API, + now they are documented. + + mkcmake: + - MKC_BMAKE environment variable is introduced. See mkcmake.1 + + Documentation for /etc/mk.conf, @sysconfdir@/mk.conf and MAKECONF. + + doc/presentation.pdf: New slides and updates + + FAQ: updates + + mkc_imp.lua.mk: + - Check for lua.h header if other checks succeeded. + + mkc_imp.lib.mk: + - MKDLL is also case-insensitive. + + Makefile: + - make shipped with NetBSD-5 does not have option -C, + so I remove it. + +====================================================================== +Version 0.16.0, by Aleksey Cheusov, Sat, 12 Jun 2010 15:06:10 +0300 + + Support for Lua programming language. See documentation for + mkc_imp.lua.mk in mk-configure(7). + + mkc.pkg-config.mk: + - Significant improvements! For details see + mk-configure(7) manual page and examples/hello_glib2 example. + New supported variables: PKG_CONFIG.exists.<lib>, PKG_CONFIG_VARS.<lib> + and PKG_CONFIG.var.<lib>.<var>. + - becomes internal include file and therefore + renamed to mkc_imp.pkg-config.mk. Symlink mkc.pkg-config.mk is + provided for backward compatibility. mkc_imp.pkg-config.mk is + included by mkc.prog.mk and mkc.lib.mk. + + mkc.intexts.mk: + - becomes internal include file and therefore + renamed to mkc_imp.intexts.mk. + Symlink mkc.intexts.mk is provided for backward compatibility. + It is included from mkc.prog.mk, mkc.lib.mk and mkc.files.mk. + - New variable INTEXTS_REPLS. See mk-configure(7). + + mkc.lib.mk: + - includes mkc_imp.intexts.mk + - supports SCRIPTS* variables (includes newly created mkc_imp.scripts.mk) + - New variable MKDLL for creating dinamically loaded libraries (<lib>.so). + + mkc_imp.subprj.mk: + - New variable SUBPRJ_DFLT. See mk-configure(7). + + mkc.*.mk try to open ${MAKECONF}, @sysconfdir@/mk.conf and /etc/mk.conf. + This is now documented. + + mk-configure.7 is reorganized. Several internal include files + document their own variables. Further improvements of man page are + needed. + + All boolean variables becomes case-insensitive. + That is "no", "No", "NO" and "nO" are equal. + The same for "yes", "Yes"... + + mkc_check_custom(1): + - New options: -p, -n, -m and -s. + + Minor fixes and clean-ups in .mk files, tools and regression tests. + + New regression tests and examples. + +====================================================================== +Version 0.15.1, by Aleksey Cheusov, Fri, 28 May 2010 22:39:36 +0300 + + FIX: in version 0.15.0 mkc.subprjs.mk was added, but it was not + installed because I forgot to add it to Makefile. Now it is + installed just like all other *.mk files. + + FIX: 'all : errorcheck' is not for bsd.subdir.mk and bsd.subprj.mk + + mkc.subprjs.mk has been renamed to mkc.subprj.mk. + mkc.subprjs.mk is installed as a symlink. + +====================================================================== +Version 0.15.0, by Aleksey Cheusov, Tue, 25 May 2010 22:52:28 +0300 + + New presentation for mk-configure is in doc/ subdirectory. + + New top-level include file "mkc.subprjs.mk", more powerful + replacement for mkc.subdir.mk. It handles subprojects organized as a + dependency graph. + + New variables are added: MKPICLIB, MKSHLIB, MKSTATICLIB and + MKPROFILELIB for building PIC, shared, static and profile libraries. + See mk-configure.7 for details. + + MKPIC, MKPROFILE and MKPICINSTALL variables are removed. Use + MKPICLIB, MKSHLIB, MKPROFILELIB and MKINSTALL variables instead. + + Implementation for variable "WARNS" (currently only for gcc). + + New variable "SHRTOUT". If it is not "no", shortened formatted + messages are output about compiling, linking etc. + + Manual page for mkcmake(1). + + Target "depend" is added for generating .depend file. + + Minor fixes in mkc_check_funclib. + + Support for Cygwin is added (no support for shared libraries yet). + + Clean-ups in target "clean". + + More regression tests and examples. + + Minor fix in mkc_imp.subdir.mk: do not run "installdirs" if MKINSTALL=no. + + Internal target "error-check" is renamed to "errorcheck". + +====================================================================== +Version 0.14.0, by Aleksey Cheusov, Sun, 31 Jan 2010 16:37:21 +0200 + + Support for OSF1. Tested on Tru64-5.1/alpha with gcc and DEC C + compiler. + + Support for HP-UX. Tested on HP-UX-11.0/hppa with gcc. + + Support for DragonFlyBSD. Tested on DragonFlyBSD-2.4.1/x86 with gcc. + + Support for MirOS BSD. Tested on MirBSD-10/x86 with gcc. + + SHLIBMODE variable is introduced which sets a shared library mode. + + FIX: mkc.subdir.mk now takes into account MKINSTALL variable. + Thanks to Mikolaj Golub for pointing out. + + FIX: targets "installdirs" and "uninstall" now takes into account + MKINSTALL variable. + + fix in mkc.minitest.mk: HP-UX's diff doesn't have -u flag, so I + remove it. + + fix in mkc_imp.platform.sys.mk: CC/CXX type should be detected AFTER + setting CC/CXX variables. + + mkc_check_compiler: + - support for DEC C compiler (OSF1/Tru64) + - minor fixes. + + More regression tests. + +====================================================================== +Version 0.13.0, by Aleksey Cheusov, Sun, 27 Dec 2009 17:06:06 +0200 + + CC, CXX and LD types are automatically detected and options passed + to them (e.g. options for generating a position independent code or + options for building a shared library) depend on this type. + At the moment the following systems and compilers are supported: + + - NetBSD. Tested under NetBSD-5.0/x86 and NetBSD-2.0/alpha with + gcc and pcc (Portable C compiler). + + - FreeBSD. Tested under FreeBSD-6.2/x86, 7.1/spark64 and 7.1/x86 + with gcc. + + - OpenBSD. Tested under OpenBSD-3.8/x86 and 4.5/x86 with gcc. + + - Solaris. Tested under Solaris-10/x86 and Solaris-10/spark64 + with sunpro-11, sunpro-12 and gcc. + + - Darwin (MacOS-X). Tested under Darwin-8.11.0/ppc (MacOS-X + Tiger) with native gcc. + + - Interix. Tested under Interix-3.5/x86 with gcc. + + - QNX. Tested under QNX-6.3/x86 with gcc. + + - Partial support for AIX, HP-UX and Tru64 and their native + compilers and linkers. Support is not complete because I have + no access to "big iron". Any help? ;-) + + If you don't see your favourite system/compiler here and want to + help me to improve mk-configure, feel free to contact + me. mk-configure needs your help! ;-) + + The default directory for mk-files is ${PREFIX}/share/mkc-mk, where + an empty sys.mk is installed unless NOSYSMK is defined while + installation. See an explanation about this in README. + + So called built-in checks are implemented. See MKC_CHECK_BUILTINS + variable. Built-in checks are checks provided by mk-configure. At + the moment the following checks are implemented: endianness, + prog_flex, prog_bison, prog_gawk, prog_gm4. See mk-configure.7 for + the documentation. + + mkc.configure.mk: + - At the end of this file MKC_{REQUIRE,CHECK}_XXX variables as + well as MKC_{CFLAGS,LDADD,SRCS} are .undef-ed. This allows one + to .include mkc.configure.mk several times. + - This include file is activated automatically from mkc.prog.mk + and mkc.lib.mk. You need to .include mkc.configure.mk + explicitely only if postcheck actions are needed. + + SCRIPTS variable can contain subdir/<script>s, they are installed + just as <script>s, i.e. subdir/ is silently stripped. + SCRIPTSDIR_subdir_<script> and SCRIPTSNAME_subdir_<script> can be + used for specifying an alternative destination path and filename. + + If .l or .y source files are listed in SRCS variable, mk-configure + automatically checks weather ${LEX} and ${YACC} are available or + not. The same for .c/${CC}, .cpp|.cc|.cxx|.C/${CXX}, .f/${FC} and + .p/${PC}. In case of absense of appropriate tool bmake exits with + error on early stage. + + MKC_CHECK_CUSTOM, MKC_REQUIRE_CUSTOM: + - HAVE_CUSTOM.xxx bmake's variables and HAVE_CUSTOM_xxx #defines + have been renamed to CUSTOM.xxx and CUSTOM_xxx respectively. + Formally speaking this breaks backward compatibility with + earlier mk-c releases. + - Support for checks written in C++ (.cc, .cxx, .C and .cpp) and + Fortran (.f) is added. + - Support for checks implemented as an executable program/script is added. + + FIXES: + - mkc_imp.man.mk: useless TMACDIR and dependencies on tmac files + under /usr/share are removed + - mkc_check_decl: + void function() cannot 'return 0' (thanks to SunPro compiler!) + - If C++ source files are listed in SRCS, ${CXX} is used as a + linker both for executables and shared libraries. + - Linux, SunOS and lots of others have no "wheel" group. They use + "root". + - "make installdirs" should not create man/htmlN directories + unless MKHTML is set to "yes" + - mkc_imp.lib.mk: .so build rule must use ${LDFLAGS} + + ADDED: mkcmake utility (trivial wrapper over bmake) which should be + used for building a software instead of bmake. + + .c:, .f:, .l: and similar useless rules are removed. It is enough to + have .c.o:, .f.o:, .l.c etc. + + Improvements for cross-compilation. + + Lots of new regression tests: + + mkc_check_common.sh: + if MKC_NOCACHE=1, tmp.c, tmp.o, tmp.exe and tmp.err are + removed. + + Support for lex: + -ll is added to linker if needed. + + mkc_check_compiler: + - Added support for the following compilers: IBM Visual Age, HP + cc/aCC, SunPro C/C++, Watcom, Borland, DEC C/C++ and Comeau C/C++ + - New option '-x' for checking C++ compiler type. + + mkc_which: + Accepts full paths. /path/to/program -> /path/to/program + + In order to avoid confusion, position independent object files (.so) + have been renamed to .os. Also, .po has been renamed to .op. + + mkc_imp.lib.mk: + - suffix rules for .cpp, widely used extension for C++ sources, are + added. + - LDCOMPILER variable is introduced, if "yes", compiler is used + for linking a shared library. + + INCSSRCDIR variable is introduced, see the documentation. + + mkc_install: New utility for platforms having no BSD compatible + install(1). INSTALL variable is set to mkc_install if needed. + + mkc.intexts.mk is included from mkc.prog.mk and mkc.lib.mk + automatically just like mkc_imp.*.mk includes. + +====================================================================== +Version 0.12.0, by Aleksey Cheusov, Thu, 12 Nov 2009 17:58:09 +0200 + + mk-configure doesn't depend on external pkgsrc-mk-files anymore! + The only required thing is bmake itself. Everything else is inside + mk-configure tarball now (yes, I've forked mk-files. Lots of fixes, + clean-ups, reorganizations, additions, improvements, removals of + useless code...). Some interesting things were stolen from NetBSD + base system's mk-files. Do not rely on things you found in + NetBSD/pkgsrc/sjg mk-files or even mk-c sources! Only features + documented in mk-configure.7 will be supported. + + A target "install-dirs" has been renamed to "installdirs". + Ask mkc.subdir.mk why ;-) + + mkc.lib.mk: + - Commands for building a .so/.dylib shared library + is overridable by user (using bmake's "commands"). + + Shared libraries + - support for Darwin (.dylib and Apple's ld) + - support for Solaris (gcc + Solaris' ld) + - support for shared libraries is still terrible, more flexibility + is needed. + + Variables: + - New variables CLEANDIRS and DISTCLEANDIRS. + - As of this release MKC_SHOW_CACHED defaults to 0. + - New variable MKINSTALL. You can use it for internal static libraries. + - New variable MKC_REQD. Minimal mk-configure version required. If + this check fails, an entire build fails. + - New variable USETBL. NOTE: It is "yes"/"no" variable. + - New variable MANZ. NOTE: It is "yes"/"no" variable. + - New variable SCRIPTSBIN that defaults to ${BINDIR}. + - HTMLDIR is introduced containing directry for .html pages + generated from manual pages. html pages are automatically + installed if MKHTML=yes. + - LDLIBS is not used anymore. Use LDADD for libraries. + - DISTCLEANFILES modifyable by user contains a list of files + removed by targets "cleandir" and "distdir" + - New variable NROFF_MAN2DOC. + + Fixes: + - A target "uninstall" now works correctly with .cat files. + - configure.mk + Workaround for buggy 20081111 < bmake < 20090909. + See NetBSD BTS bin/41998: + /usr/bin/make: .for loop + ":" inside iter_var = bug + + mk-configure: + - "make distclean" run at the root mk-c's directory really removes + all garbage. + - TONS OF NEW REGRESSION TESTS. If you are running an exotic platform, + run "bmake test" and send me results ;-) + + mkc_check_prog (MKC_CHECK_PROG): + - Path to a found program is output instead of just "found" message. + + mkc_check_compiler - new utility, not used in mkc.*.mk yet. + +====================================================================== +Version 0.11.1, by Aleksey Cheusov, Sat, 5 Sep 2009 17:25:18 +0300 + + fixed: path to awk in mkc_check_version script + +====================================================================== +Version 0.11.0, by Aleksey Cheusov, Sat, 5 Sep 2009 15:26:01 +0300 + + mk-configure(7) + + Simon Gerrary's mk-files is not supported anymore. + Use pkgsrc mk-files! + + Regression tests have been reorganized and significantly improved. + All examples become regression tests. Lots of new tests. + Run 'bmake test' to run them. + + mk-configure uses its own mkc.*.mk scripts to build and install + itself. As a result Free/OpenBSD make cannot be used anymore for + building and installations. Use bmake! + + ADDED: FAQ document to answer frequently asked questions. + Thanks to Michael Shigorin for corrections. + + New simple module for regression tests: mkc.minitest.mk. Besides + its simplicity it is quite useful. mk-configure uses it for testing + itself. + + Initial version of mkc.pkg-config.mk module + See examples/hello_glib2 for the sample of use. + Note that it is not complete yet. + + mkc.configure.mk and configure.mk: + + - checks are not run if appropriate HAVE_xxx.yyy variable is + already defined. This makes possible to effectively build + software in a well defined stable environment. + Ex: bmake -f predefined_settings.mk -f Makefile all + + - ADDED: MKC_CHECK_TYPES for checking for types. + See the documentation in configure.mk.in and examples/. + + - ADDED: MKC_CHECK_CUSTOM for custom user's checks. + Custom check is a user's code. + Check itself -- is this code compilable or not. + See the documentation in configure.mk.in and examples/. + + - Behaviour of MKC_CHECK_MEMBERS changed: Now "struct " prefix + is not hardcoded. This gives an ability to check members in + struct-s, enum-s and typedef-s. + + - NEW: MKC_REQUIRE_HEADERS, MKC_REQUIRE_FUNCLIBS, + MKC_REQUIRE_DEFINES, MKC_REQUIRE_TYPES, MKC_REQUIRE_VARS, + MKC_REQUIRE_MEMBERS, MKC_REQUIRE_CUSTOM and + MKC_REQUIRE_FUNCS<N>. If these checks failure, bmake exits + with error and prints an error message. See configure.mk.in + for the documentation and examples/ for the samples of use. + + - NEW: MKC_CHECK_PROGS and MKC_REQUIRE_PROGS. + See configure.mk.in for the documentation and + examples/ for the samples of use. + + - NEW: targets "distclean" and "cleandir" removes _mkc_* cache files. + + - NEW: target "configure" runs all checks + and creates _mkc_ cache files. + + - all checks are disabled for targets "clean", "cleandir" and + "distclean". + + - Cache file names changed. Now they are: + _mkc_type_<type>, _mkc_sizeof_<type>, _mkc_header_<header>, + _mkc_funclib_<funclib>, _mkc_funcN_<func>, + _mkc_variable_<variable>, _mkc_custom_<custom-check>, + _mkc_prog_<progname>, _mkc_define_<define>, _mkc_member_<member> + + mkc.info.mk and mkc.man.mk are removed. They are included automatically + from mkc.prog.mk, mkc.lib.mk and mkc.files.mk if needed. + + mkc.prog.mk, mkc.lib.mk, mkc.files.mk and mkc.subdir.mk: + + - NEW: target "uninstall" is supported. + + - performance improvements. "Hard" sections of mkc.common.mk are + activated if and only if appropriate target is in action. + + - FIX: target "install-dirs" now works correctly with MAN + containing .N pages where N is not 1. + + - FIX: target "install-dirs" now takes into account LINKS and + SYMLINKS. + + - Better support for TEXINFO: + - "uninstall" target takes TEXINFO into account. + - "clean" target removes generated .info files. + + - mkc.{prog,lib,files}.mk supports a target "test". By default + it does nothing. The target "test" of mkc.subdir.mk runs + 'bmake test' for each SUBDIR. If you want to define your own + "test" target overriding the default one, define it in your + project's Makefile before any .include <mkc.*.mk> directive. + + - MKC_REQD variable + + Makefile of mk-configure: README, NEWS, TODO, FAQ and LICENSE + files are also installed unless EXTRAFILES is set to an empty string. + + "mkc_check_sizeof" and "mkc_check_decl type" don't create cache + files with spaces in its name anymore. Space inside a filename is + replaced with symbol ~ (tilde). + + FIXED: mkc_check_custom, mkc_check_decl, mkc_check_funclib, + mkc_check_header and mkc_check_sizeof failed if CC contains space. + Thanks to Vitaly Lipatov for the report. + + mkc_check_sizeof now works drammatically faster. + + MKHTML defaults to "no". + + mkc_check_sizeof, mkc_check_custom: + - fixes for problems with Solaris' /bin/sh + + Other fixes and improvements. + +====================================================================== +Version 0.10.0, by Aleksey Cheusov, Sun, 31 May 2009 14:54:10 +0300 + + mkc.configure.mk: + + New: MKC_CHECK_MEMBERS, mechanism for checking for structure + members. Regression tests for this new feature. Man page update + for mkc_check_decl. See the documentation for MKC_CHECK_MEMBERS + in configure.mk file. + + Fix: HAVE_FUNCN.funcname.dir.header_h -> + HAVE_FUNCN.funcname.dir_header_h + New: Support for HAVE_VAR.varname.dir_header_h (dir/header.h!) + New: Support for HAVE_DEFINE.defname.dir_header.h (dir/header.h!) + New: MKC_COMMON_DEFINES.`uname -s`, e.g. MKC_COMMON_DEFINES.NetBSD, + MKC_COMMON_DEFINES.Linux etc. + + "install-dirs" now work fully correctly, i.e. creates + all required directories. + + New variable DPLIBS for listing -llibs for linking. Use DPLIBS + instead of LDADD for linking with local libraries. + See examples/8/hello/Makefile. + + mkc_check_decl: + workaround for buggy ksh and FreeBSD /bin/sh. + +====================================================================== +Version 0.9.0, by Aleksey Cheusov, Sun, 29 Mar 2009 16:53:57 +0300 + + Huge amount of changes were made since previous release. Now + mk-configure provides a number of mkc.*.mk scripts working on top of + pkgsrc's mk files or Simon Gerraty's mk-files and therefore provides + a replacement not only for GNU autoconf but for GNU automake too. + It makes sense to reread README file. + Lots of new information is there. + + Lots of examples (yes, hello_worlds applications :-) ) were created + in examples/ subdirectory. + + Lots of new mkc.*.mk files were added. They work on top of bsd.*.mk + files and provide new functions. See README. + + Regression tests were added. Thanks to them a number of bugs were + detected and fixed. + + Fixes in configure.mk: + - s/return/exit/ in ${.OBJDIR}/.error-check section. + This bug is seen under Linux/bash. + + - bmake's variable SIZEOF.long_long was not set correctly + (long-long din't work) + + - MKC_CHECK_SIZEOF+=type:header.h + bmake's variable SIZEOF.<type>.<header_h> is set + instead of plain SIZEOF.<type> + + - MKC_CHECK_HEADERS += dir/hdr.h + bmake's variable: s/HAVE_HEADER.dir.hdr_h/HAVE_HEADER.dir_hdr_h/ + (`.' vs. `_') + I hope this is a last change in configure.mk's API. + + My own mkc.intexts.mk bmake module (mk file). + + configure.mk: + If CHECK_SIZEOF_xxx check fails, MKC_CFLAGS is not changed. Only + sucessful data type sizes are registered in MKC_CFLAGS and CFLAGS. + + mkc_check_decl, mkc_check_sizeof: they don't use MKC_COMMON_DEFINES + environment enymore, everything should be passed through CFLAGS and + CPPFLAGS. + + MKC_SHELL is currently disabled + +====================================================================== +Version 0.7.0, by Aleksey Cheusov, Sun, 15 Mar 2009 11:02:29 +0200 + + No CFLAGS+=-DHAVE_XXXX=0 anymore, if XXX is not found + it is not defined at all. autoconf works the same way. + + mkc_check_xxx scripts: + - installed to bin/ directory just like normal scripts. + + - if MKC_VERBOSE variable is equal to '1', verbose messages + are output to stderr. + + - -h|--help options printing usage information. + + - manual pages are created. + + new variable MKC_NOCACHE, if it is set to not empty string, + caching is disabled. + + fix in mkc_check_decl: long-long is treated as 'long long'. + + MKC_SHOW_CACHED, MKC_VERBOSE, MKC_DELETE_TMPFILES, MKC_NOCACHE + variables: 1 - true, other values - false. + + minor clean-ups in Makefile + +====================================================================== +Version 0.6.0, by Aleksey Cheusov, Sun, 8 Mar 2009 19:35:13 +0200 + + MKC_FUNCLIBS_NOAUTO.ftime.compat is replaced + with MKC_NOAUTO_FUNCLIBS list. + + Ex.: + MKC_NOAUTO_FUNCLIBS += ftime:compat crypt:crypt + MKC_NOAUTO_FUNCLIBS = 1 # for disabling + # all potential LDADD += ... + + fix: "checking for..." messages is now sent to stderr + before result is calculated, not after. + + Support for heirloom-sh and ancient Solaris-10 /bin/sh + + added: MKC_SHELL variable defaulting to /bin/sh, mkc_check_XXX + scripts are run with with this shell. This is variable is mainly for + testing purposes but who knows. + +====================================================================== +Version 0.5.0, by Aleksey Cheusov, Tue, 3 Mar 2009 00:04:52 +0200 + + Huge amount of changes. 0.5.0 is completely incompatible with 0.4.0 + because 0.4.0 was proof-of-concept only ;-) Everything was + inspired by discussion in fido7.ru.unix.prog. + + Changing in API is also possible in the future until + I stabilize it. + +====================================================================== +Version 0.4.0, by Aleksey Cheusov, Sat, 21 Feb 2009 22:47:20 +0200 + + First publicly available release. Happy birth day! :-) diff --git a/doc/NOTES b/doc/NOTES new file mode 100644 index 0000000..733033d --- /dev/null +++ b/doc/NOTES @@ -0,0 +1,179 @@ +BUILD SYSTEM IN GENERAL AND MK-CONFIGURE IN PARTICULAR IS A COMPLEX +SYSTEM. THIS FILE CONTAINS UNORDERED NOTES ABOUT HOW TO USE +MK-CONFIGURE EFFICIENTLY. I HOPE THESE NOTES WILL BE VALUABLE ADDON TO +MK-CONFIGURE(7) REFERENCE AND HELP USERS UNDERSTAND MK-CONFIGURE. +TAKE A NOTE THAT THESE NOTES ARE UNSORTED. + +*** + +For building projects with /usr prefix, run the following. + + export PREFIX=/usr SYSCONFDIR=/etc VARDIR=/var + mkcmake all + mkcmake install + +Packagers may use the following for creating a package using +unprivileged user. + + mkdir /tmp/destdir + mkcmake install DESTDIR=/tmp/destdir + +*** + +mk-configure supports out-of-tree builds. Most of functionality is +supported by bmake. Examples are below. + +1) + mkdir /tmp/xxxproj-obj + mkcmake MAKEOBJDIR=/tmp/xxxproj-obj + +In this case all objects and temporary files are created in +/tmp/xxxproj-obj. Obviously, this may work if different subprojects +doesn't produce files with the same name. This features is supported +directly by bmake. + +2) + mkdir /tmp/xxxproj-obj + mkcmake MAKEOBJDIRPREFIX=/tmp/xxxproj-obj + +Here all objects and temporary files are saved to +${MAKEOBJDIRPREFIX}${.CURDIR} directory. This features is also +supported by bmake. + +3) + mkdir /tmp/xxxproj-obj + env MKRELOBJDIR=yes MAKEOBJDIR=/tmp/xxxproj-obj mkcmake + +Unlike example 2) subdirectories under /tmp/xxxproj-obj for temporary +files won't contain ${SRCTOP}. The variable MKRELOBJDIR is provided by mk-c. + +*** + +Even if you project is trivial, that is consists of single executable +or library, I'd recommend to use mkc.subprj.mk in the top-level Makefile. +In provides better flexibility and easier work for packagers. + +*** + +It's very important to understand what is a recursive target. +See variable TARGETS. + +*** + +The variable TARGETS is a way to extend mk-c functionality. +See examples/hello_TARGETS. + +*** + +Look at examples/hello_superfs/Makefile.inc. +There you'll find a cool mk-configure's feature. + +*** + +If you want to override values for MKC_CHECK_* checks, run mkcmake +with additional parameters, like this + + mkcmake all HAVE_HEADER.stdio_h=1 HAVE_HEADER.stdlib_h=1 + +See mkc.configure.mk section in mk-configure.7 for details. + +*** + +There are several ways of passing additional information from +top-level project to subprojects: + - environment variables via .export and .export-env bmake directives. + - EXPORT_VARNAMES and NOEXPORT_VARNAMES variables from mkc.subprj.mk. + - Makefile.common and Makefile.inc files. + +*** + +For prettifying mkcmake output, one can use + + export SHRTOUT=yes + mkcmake all + +*** + +If your top-level Makefile looks like this + + Makefile: + SUBPRJ = libA:progA libB:progB + .include <mkc.subprj.mk> + +one can use + + mkcmake all-progB + +for building progB subproject without probA and libA. In this case libB +will also be built as it is a dependency. The same for + + mkcmake install-progB + mkcmake test-progB + ... + +and others. "all", "install", "test" and others are listed in variable +TARGETS. + +*** + +In traditional BSD mk files bsd.subdir.mk is allowed in any +subdirectory. The same is true for mk-configure. However, for better +flexibility it is recomended to have mkc.subprj.mk in the top-level +Makefile and specify the whole dependency graph of subpojects in +it. This allows, for example, building and testing any subproject +separately by running one command from top-level directory, +i.e. "mkcmake all-sub/sub/project". In this case all required +dependencies (and nothing else) will be built recursively. For running +mkcmake in subproject's directory, set the variable SRCTOP. + +*** + +SUBPRJ variable (mkc.subprj.mk) may contain subprojects, not +associated with any subdirectory. Such subprojects may be used as "the +name of subprojects collection". I call them "virtual +subprojects". If, for example, you're developing traditional UNIX +tools, you may have such projects as POSIX_tools BSD_tools, +bin_tools, sbin_tools etc. + +*** + +Subprojects from SUBDIR (mkc.subdir.mk) and SUBPRJ (mkc.subprj.mk) may +have slashes inside. + +*** + +NODEPS variable may be used for stripping unnecessary +dependencies. This is especially useful for target "test". In the +following example "mkcmake test" tests only programs but not libraries +(recursively). That is, it runs targets "test-tools/prog1", +"test-tools/prog2", "test-tools/prog3" and "test-tools/prog4" +but "test-libs/foo" and others. + +Example: + SUBPRJ = libs/foo:tools/prog1 + SUBPRJ += libs/bar:tools/prog2 + SUBPRJ += libs/foo:tools/prog3 libs/bar:tools/prog3 + SUBPRJ += libs/qux:tools/prog4 + + NODEPS += test-libs/*:test test-libs/*:test-tools/* + + .include <mkc.subprj.mk> + +*** + +Makefile.common and Makefile.inc included implicitely by subprojects +may be used for common code. For examples, in these files one can do +something like this. + + VERSION = 1.2.3 + INTEXTS_REPLS += version ${VERSION} + +for replacing @version@ with real version. + +*** + +If your project consists of libraries and executables, use +mkc.subprj.mk and its LIBDEPS variable. Even if you prefer shared +libraries, users will be able to link them statically with a help +STATICLIBS variable specified in environment. For this to work you +have to use += for STATICLIBS in Makefiles. diff --git a/doc/TODO b/doc/TODO new file mode 100644 index 0000000..f631dd9 --- /dev/null +++ b/doc/TODO @@ -0,0 +1,195 @@ +============================================================ +Plan 0.28.0 + +- check awk capabilities at build time +- Hide regression tests details +- "bmake -k regrtest/check" (mkc.minitest.mk?) + +- strndup(SunOS-5.10, -fgetln,_compatlib) +- PRId64 +- leveldb, strtoll, strtoull +- wmemcpy, strnlen +- wcsdup +- CFLAGS0 + +- Special marker for checks that cannot be possible in cross-compiling + +- regression tests without garbage, make it look like paexec\ + +- MKC_FEATURES: inttypes + +Some thoughts inspired by talks with Michael Crogan + +- MKASNEEDED=yes => ld --as-needed + +- _mkc_done_<prj>_<trg> + +- project "roundup" for testing + +- "errorcheck/configure" tests should be run in parallel. Something + like shlock(1) or flock(1) is needed for this. +- Alternative .depend generation, e.g. like it is described in GNU + make info files +- Additional examples/ is needed for + triggering rebuild of subproject if "something" was rebuild in + another subproject (build script for example). +- Interdependencies between targetX-subprjA and targetY-subprjB (for + example all-prject1 and install-prject2). Maybe this is cool idea + for examples/ and slides. I need some good example for this. + <<<depend-project1:errorcheck-autotools_based_project2>>>!!! +- Steal cool features from Simon Gerraty's mk files and analyse + "meta mode" he invented. + +Some "targets" from TARGETS should set MKCHECKS to "no" + +ronn(1) : markdown to man pages + + custom test failed -> exit status of mkcmake should not be zero + MKC_CUSTOM_ERR.qqqq -> error message before exiting just like + + mkcmake configure doesn't work + New variable MKC_CUSTOM_ENV.xxx + + Add script_check to MKC_CHECK_CUSTOM + Ex. MKC_CHECK_CUSTOM+= nested_funcs + MKC_CUSTOM_FN.nested_funcs= nested_funcs.c + MKC_CUSTOM_FN.script_check= checks/script_check + + - BINSUBDIR, LIBSUBDIR, LIBEXECSUBDIR etc... + - Fix USE_SSP support for clang (-mllvm -stack-protector-buffer-size=1) + - USE_RPATH + - OBJCOPTS_<proj> + - Regression tests: + * optional .f tests + * optional .p tests + * optional .m tests + * optional(!) glib2 tests + +============================================================ +Plan 1) + + - Support for MKDEBUG like in NetBSD mk files + - .lua.luac: + - Implement mkc_imp.libtool.mk to build + the shared libraries using GNU libtool(1). + - MKSTRIP, STRIP, mkc_install: use STRIP, not STRIPPROG + + Slides for: + - Slide "extensibility" about Lua module. + - code specific to GNU ld(1) (.def?) + +============================================================ +Plan 2) + + - ./configure written in shell? + - EXPORT_DYNAMIC_SYMBOLS - add the specified symbols to + dynamic symbol table (GNU ld) + - EXPORT_SYMBOLS_REGEXP + + - Syllable, Haiku, OpenServer/UnixWare and HURD + - lcc and tcc compilers + - epm -> rpm, SVR4 pkg etc. + - mkc_imp.filelist.mk + - FL_NOPREFIX + - FL_PERSUBPRJ + - IRIX: "endianness" and EXPORT_SYMBOLS + +============================================================ +Plan 3) + + = sample for home-made .mk file (Ocaml? Pike?) + = marker for user's custom tests that + run generated executables, i.e. not ready + for cross-compilation + + = support for gettext + + = mkclint? + + = Command line may be limited in size. + Save defines to config.h and set HAVE_CONFIG_H to 1 + for compiling. + + = MKC_CUSTOM_premk, MKC_CUSTOM_postmk + + = Online tutorial + + = shared libraries support for AIX, UnixWare, Hurd, Haiku. + = shared libraries support for nwcc and other compilers. + + = Comparison with quagmire, kBuild, CMake, scons, waf, framewerk, pmk, + MagicMakefiles, bjam, pymake, bitmake, pkgconf, Gradle + http://sourceforge.net/projects/mkbuild etc. + + = Often compilers need special options to compile pthread code. + Support for MKPTHREAD=yes|no is needed. + + = implement MANBZ2? + + = man page for mkc_check_compiler + +============================================================ +Plan 4) + + = EXPORT_SYMBOLS for HP-UX, AIX, SCO etc. + + = Single cache file as an automatically loaded (if exists) + bmake makefile. + + = Targets bin_rpm, bin_epm + = Targets src_tar, src_targz, src_tarbz2 + + = mkc.subdir.mk: + - continue bulding even if some subprojects failed + + = MKC_CHECK_CUSTOM: + - MKC_CUSTOM_FN=xxx.f + - MKC_CUSTOM_FN=xxx.objc + + = Implement mkc.qt.mk + + = Implement mkc.doxygen.mk? + +============================================================ +Plan 5) + + = mkc.configure.mk functionality but for bourne shell, e.g. + + Upstream creates ./configure shell script: + MKC_CONFIG_MK=mkc_config.mk + MKC_CONFIG_H=mkc_config.h + + MKC_CHECK_HEADERS=' + header1.h + header2.h + header3.h' + MKC_CHECK_FUNCLIBS=' + func1:lib1 + func2 + func3:lib3' + #<...> + . mkc_configure + mkc_run # generating mkc_config.h and mkc_config.mk + + User runs + ./configure ... + <any>make all + + = MKC_CHECK_DECL_TYPE (define, function|variable) + + = MKC_DEFINE_01 - -DHAVE_XXX=0 or -DHAVE_XXX=1 + +============================================================ +Plan 6) + = MKC_BUILTINS (from autoconf): + broken_free_NULL, + exit_ret_int, + isinf, isnan, malloc_0, putenv_xxx, realloc, signal, + snprintf, sprintf, sscanf, strerror_r, strnlen, + sysconf, unlink, unsetenv, va_copy, va_list, + signed_shr, int_div, chown_minus_1,... + (autoconf.info/Particular Function Checks) + + AC_FUNC_ALLOCA + = autoconf (Portability of headers) + = autoconf (Particular Header Checks) diff --git a/examples/Makefile.inc b/examples/Makefile.inc new file mode 100644 index 0000000..1c1912d --- /dev/null +++ b/examples/Makefile.inc @@ -0,0 +1,10 @@ +CLEANDIRS += ${.CURDIR}/usr ${.CURDIR}/opt + +.ifdef SRCDIR_builtins +# regression test for mk-configure +MKC_CACHEDIR = ${.CURDIR} +BUILTINSDIR = ${SRCDIR_builtins} +FEATURESDIR = ${SRCDIR_features} +SHRTOUT = no +.export MKC_CACHEDIR BUILTINSDIR FEATURESDIR SHRTOUT +.endif diff --git a/examples/hello_RBTREE/Makefile b/examples/hello_RBTREE/Makefile new file mode 100644 index 0000000..6b68c0b --- /dev/null +++ b/examples/hello_RBTREE/Makefile @@ -0,0 +1,10 @@ +PROG = hello_RBTREE + +WARNS = 4 + +MKC_FEATURES = RB + +MKC_REQD = 0.26.0 + +.include "test.mk" +.include <mkc.prog.mk> diff --git a/examples/hello_RBTREE/expect.out b/examples/hello_RBTREE/expect.out new file mode 100644 index 0000000..f130512 --- /dev/null +++ b/examples/hello_RBTREE/expect.out @@ -0,0 +1,7 @@ +NetBSD +black currant +blackberry +cranberry +gooseberry +red currant +strawberry diff --git a/examples/hello_RBTREE/hello_RBTREE.c b/examples/hello_RBTREE/hello_RBTREE.c new file mode 100644 index 0000000..4ee1314 --- /dev/null +++ b/examples/hello_RBTREE/hello_RBTREE.c @@ -0,0 +1,83 @@ +/********************************************************************\ + Copyright (c) 2014 by Aleksey Cheusov + + See LICENSE file in the distribution. +\********************************************************************/ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +#include <mkc_RB.h> + +struct berry { + RB_ENTRY(berry) link; + char *berry; +}; + +static int berrys_cmp (struct berry *a, struct berry *b) +{ + return strcmp (a->berry, b->berry); +} + +static RB_HEAD (berrys_entries, berry) berrys = RB_INITIALIZER(&berrys); + +RB_PROTOTYPE (berrys_entries, berry, link, berrys_cmp) +RB_GENERATE (berrys_entries, berry, link, berrys_cmp) + +static void output_berries (void) +{ + struct berry *data; + data = (struct berry *) RB_MIN (berrys_entries, &berrys); + while (data){ + puts (data->berry); + data = (struct berry *) RB_NEXT (berrys_entries, &berrys, data); + } +} + +static void destroy_berries (void) +{ + struct berry *data, *next; + data = (struct berry *) RB_MIN (berrys_entries, &berrys); + while (data){ + next = (struct berry *) RB_NEXT (berrys_entries, &berrys, data); + RB_REMOVE (berrys_entries, &berrys, data); + free (data->berry); + free (data); + + data = next; + } +} + +static void add_berry (char *s) +{ + struct berry *n = malloc (sizeof (*n)); + struct berry *data; + + n->berry = s; + + data = RB_INSERT (berrys_entries, &berrys, n); + if (data){ + free (s); + free (n); + } +} + +int main (int argc, char **argv) +{ + char buf [100]; + size_t len; + + while (fgets (buf, sizeof (buf), stdin)){ + len = strlen (buf); + if (len > 0 && buf [len-1] == '\n') + buf [len-1] = 0; + + add_berry (strdup (buf)); + } + + output_berries (); + destroy_berries (); + + return 0; +} diff --git a/examples/hello_RBTREE/input.in b/examples/hello_RBTREE/input.in new file mode 100644 index 0000000..1b03e8f --- /dev/null +++ b/examples/hello_RBTREE/input.in @@ -0,0 +1,12 @@ +cranberry +gooseberry +strawberry +strawberry +blackberry +black currant +red currant +NetBSD +strawberry +black currant +red currant +cranberry diff --git a/examples/hello_RBTREE/test.mk b/examples/hello_RBTREE/test.mk new file mode 100644 index 0000000..5188245 --- /dev/null +++ b/examples/hello_RBTREE/test.mk @@ -0,0 +1,8 @@ +.PHONY : test_output +test_output: + @set -e; \ + ${.OBJDIR}/hello_RBTREE < ${.CURDIR}/input.in; \ + \ + ${MAKE} ${MAKEFLAGS} distclean > /dev/null + +.include <mkc.minitest.mk> diff --git a/examples/hello_SLIST/Makefile b/examples/hello_SLIST/Makefile new file mode 100644 index 0000000..313db26 --- /dev/null +++ b/examples/hello_SLIST/Makefile @@ -0,0 +1,10 @@ +PROG = hello_SLIST + +WARNS = 4 + +MKC_FEATURES = SLIST + +MKC_REQD = 0.26.0 + +.include "test.mk" +.include <mkc.prog.mk> diff --git a/examples/hello_SLIST/expect.out b/examples/hello_SLIST/expect.out new file mode 100644 index 0000000..663f7ca --- /dev/null +++ b/examples/hello_SLIST/expect.out @@ -0,0 +1,7 @@ +red currant +black currant +blackberry +strawberry +gooseberry +cranberry +raspberry diff --git a/examples/hello_SLIST/hello_SLIST.c b/examples/hello_SLIST/hello_SLIST.c new file mode 100644 index 0000000..7272f65 --- /dev/null +++ b/examples/hello_SLIST/hello_SLIST.c @@ -0,0 +1,66 @@ +/********************************************************************\ + Copyright (c) 2014 by Aleksey Cheusov + + See LICENSE file in the distribution. +\********************************************************************/ + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +#include <mkc_SLIST.h> + +struct berry { + SLIST_ENTRY(berry) link; + char *berry; +}; + +static SLIST_HEAD (berry_head, berry) berries = SLIST_HEAD_INITIALIZER(berry_head); + +static void output_berries (void) +{ + struct berry *p; + + SLIST_FOREACH (p, &berries, link){ + puts (p->berry); + } +} + +static void destroy_berries (void) +{ + struct berry *e; + while (!SLIST_EMPTY (&berries)){ + e = SLIST_FIRST (&berries); + free (e->berry); + SLIST_REMOVE_HEAD (&berries, link); + free (e); + } +} + +static void add_berry (char *s) +{ + struct berry *b = calloc (1, sizeof (*b)); + + b->berry = s; + + SLIST_INSERT_HEAD (&berries, b, link); +} + +int main (int argc, char **argv) +{ + char buf [100]; + size_t len; + + while (fgets (buf, sizeof (buf), stdin)){ + len = strlen (buf); + if (len > 0 && buf [len-1] == '\n') + buf [len-1] = 0; + + add_berry (strdup (buf)); + } + + output_berries (); + destroy_berries (); + + return 0; +} diff --git a/examples/hello_SLIST/input.in b/examples/hello_SLIST/input.in new file mode 100644 index 0000000..39fcf95 --- /dev/null +++ b/examples/hello_SLIST/input.in @@ -0,0 +1,7 @@ +raspberry +cranberry +gooseberry +strawberry +blackberry +black currant +red currant diff --git a/examples/hello_SLIST/test.mk b/examples/hello_SLIST/test.mk new file mode 100644 index 0000000..b7ca05d --- /dev/null +++ b/examples/hello_SLIST/test.mk @@ -0,0 +1,8 @@ +.PHONY : test_output +test_output: + @set -e; \ + ${.OBJDIR}/hello_SLIST < ${.CURDIR}/input.in; \ + \ + ${MAKE} ${MAKEFLAGS} distclean > /dev/null + +.include <mkc.minitest.mk> diff --git a/examples/hello_TARGETS/Makefile b/examples/hello_TARGETS/Makefile new file mode 100644 index 0000000..95fcf15 --- /dev/null +++ b/examples/hello_TARGETS/Makefile @@ -0,0 +1,15 @@ +SUBDIR = hello1 hello2 + +# additional recursive target +TARGETS += codingstylechk + +# We want to include man pages to the distribution tarball. +# For this we do the following: +# mkcmake manpages; tar -cf /tmp/tarball.tar . +TARGETS += _manpages # _manpages is a new recursive target +.PHONY: manpages +manpages: _manpages + @rm ${MKC_CACHEDIR}/_mkc* + +.include "test.mk" +.include <mkc.subdir.mk> diff --git a/examples/hello_TARGETS/Makefile.inc b/examples/hello_TARGETS/Makefile.inc new file mode 100644 index 0000000..b3f20f7 --- /dev/null +++ b/examples/hello_TARGETS/Makefile.inc @@ -0,0 +1,10 @@ +CSCHK = test hello1 = '${.CURDIR:T}' # something useful should be here + +.if make(codingstylechk) +MKCHECKS = no +.endif + +.PHONY: codingstylechk +codingstylechk: + @${_MESSAGE_V} "Coding style check for ${PROJECTNAME}"; \ + ${CSCHK} || { echo FAILED 1>&2; false; } diff --git a/examples/hello_TARGETS/expect.out b/examples/hello_TARGETS/expect.out new file mode 100644 index 0000000..e88091d --- /dev/null +++ b/examples/hello_TARGETS/expect.out @@ -0,0 +1,67 @@ +Hello World 1! +Hello World 2! +=========== all ============ +/objdir/Makefile +/objdir/Makefile.inc +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/expect.out +/objdir/hello1/Makefile +/objdir/hello1/hello1 +/objdir/hello1/hello1.1 +/objdir/hello1/hello1.c +/objdir/hello1/hello1.o +/objdir/hello1/hello1.pod +/objdir/hello2/Makefile +/objdir/hello2/hello2 +/objdir/hello2/hello2.1 +/objdir/hello2/hello2.c +/objdir/hello2/hello2.o +/objdir/hello2/hello2.pod +/objdir/hello_TARGETS.test.out.tmp +/objdir/test.mk +========= codingstylechk ========== +================================================== +codingstylechk ===> hello_TARGETS/hello1 +Coding style check for hello1 +================================================== +codingstylechk ===> hello_TARGETS/hello2 +Coding style check for hello2 +FAILED +*** Error code 1 + +Stop. +bmake: stopped in /objdir/hello2 +*** Error code 1 + +Stop. +bmake: stopped in /objdir +cschk ex=1 +============= files =============== +/objdir/Makefile +/objdir/Makefile.inc +/objdir/expect.out +/objdir/hello1/Makefile +/objdir/hello1/hello1.c +/objdir/hello1/hello1.pod +/objdir/hello2/Makefile +/objdir/hello2/hello2.c +/objdir/hello2/hello2.pod +/objdir/hello_TARGETS.test.out.tmp +/objdir/test.mk +=========== manpages ============ +/objdir/Makefile +/objdir/Makefile.inc +/objdir/expect.out +/objdir/hello1/Makefile +/objdir/hello1/hello1.1 +/objdir/hello1/hello1.c +/objdir/hello1/hello1.pod +/objdir/hello2/Makefile +/objdir/hello2/hello2.1 +/objdir/hello2/hello2.c +/objdir/hello2/hello2.pod +/objdir/hello_TARGETS.test.out.tmp +/objdir/test.mk diff --git a/examples/hello_TARGETS/hello1/Makefile b/examples/hello_TARGETS/hello1/Makefile new file mode 100644 index 0000000..d1e6601 --- /dev/null +++ b/examples/hello_TARGETS/hello1/Makefile @@ -0,0 +1,15 @@ +PROG = hello1 +MAN = hello1.1 + +WARNS = 4 + +CLEANFILES = hello1.1 + +_manpages: ${MAN} + +# the following is just a regression test for exporting TARGETS +.if empty(TARGETS:Mcoding*) +MKC_ERR_MSG = "qqq" +.endif + +.include <mkc.mk> diff --git a/examples/hello_TARGETS/hello1/hello1.c b/examples/hello_TARGETS/hello1/hello1.c new file mode 100644 index 0000000..026f7e0 --- /dev/null +++ b/examples/hello_TARGETS/hello1/hello1.c @@ -0,0 +1,8 @@ +#include <stdio.h> +#include <stdlib.h> + +int main (int argc, char **argv ) +{ + puts ("Hello World 1!"); + exit (0); +} diff --git a/examples/hello_TARGETS/hello1/hello1.pod b/examples/hello_TARGETS/hello1/hello1.pod new file mode 100644 index 0000000..92581bb --- /dev/null +++ b/examples/hello_TARGETS/hello1/hello1.pod @@ -0,0 +1,17 @@ +=head1 NAME + +hello1 - mk-configure example program + +=head1 INTRODCTION + +lalala + +=head1 STEP1 + +bla bla bla + +=head1 STEP2 + +bla bla bla + +=head1 BYE diff --git a/examples/hello_TARGETS/hello2/Makefile b/examples/hello_TARGETS/hello2/Makefile new file mode 100644 index 0000000..20ada21 --- /dev/null +++ b/examples/hello_TARGETS/hello2/Makefile @@ -0,0 +1,10 @@ +PROG = hello2 +MAN = hello2.1 + +WARNS = 4 + +CLEANFILES = hello2.1 + +_manpages: ${MAN} + +.include <mkc.mk> diff --git a/examples/hello_TARGETS/hello2/hello2.c b/examples/hello_TARGETS/hello2/hello2.c new file mode 100644 index 0000000..95331f9 --- /dev/null +++ b/examples/hello_TARGETS/hello2/hello2.c @@ -0,0 +1,8 @@ +#include <stdio.h> +#include <stdlib.h> + +int main (int argc, char **argv ) +{ + puts ("Hello World 2!"); + exit (0); +} diff --git a/examples/hello_TARGETS/hello2/hello2.pod b/examples/hello_TARGETS/hello2/hello2.pod new file mode 100644 index 0000000..4479946 --- /dev/null +++ b/examples/hello_TARGETS/hello2/hello2.pod @@ -0,0 +1,22 @@ +=head1 NAME + +hello2 - mk-configure example + +=head1 SYNOPSIS + +B<hello2> I<[options]> I<[files...]> + +=head1 DESCRIPTION + +bla bla bla + +=head1 AUTHOR + +Copyright (c) 2010 Aleksey Cheusov <vle@gmx.net> + +=head1 HOME + +L<http://sourceforge.net/projects/mk-configure> + +=head1 SEE ALSO +L<mk-configure(7)> diff --git a/examples/hello_TARGETS/test.mk b/examples/hello_TARGETS/test.mk new file mode 100644 index 0000000..6949660 --- /dev/null +++ b/examples/hello_TARGETS/test.mk @@ -0,0 +1,32 @@ +# I added "codingstylechk" to "test" just for mk-configure regr. test + +test: +.PHONY : test_output +test_output : + @:; \ + ${OBJDIR_hello1}/hello1; \ + ${OBJDIR_hello2}/hello2; \ + MKCATPAGES=yes; export MKCATPAGES; \ + \ + echo =========== all ============; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= codingstylechk ==========; \ + ${MAKE} ${MAKEFLAGS} cleandir 2>/dev/null 1>&2; \ + { ${MAKE} ${MAKEFLAGS} codingstylechk 2>&1; echo cschk ex=$$?; } | \ + env NOSORT=1 mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ============= files ===============; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo =========== manpages ============; \ + env MKCATPAGES=no ${MAKE} ${MAKEFLAGS} cleandir 2>/dev/null 1>&2; \ + ${MAKE} ${MAKEFLAGS} manpages 2>/dev/null 1>&2; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}" + \ + ${MAKE} ${MAKEFLAGS} cleandir 2>/dev/null 1>&2 + +.include <mkc.minitest.mk> diff --git a/examples/hello_autoconf/Makefile b/examples/hello_autoconf/Makefile new file mode 100644 index 0000000..3f6e87b --- /dev/null +++ b/examples/hello_autoconf/Makefile @@ -0,0 +1,15 @@ +FOREIGN = autotools +FSRCDIR = proj + +AT_USE_AUTOMAKE = no +AT_MAKE = ${BUILTIN.prog_gmake} + +MKC_CHECK_BUILTINS = prog_gmake +MKCHECKS = yes # we need path to gmake for target "clean" + +# The following line is for regression tests. +# In real life we don't need this. +all: mkgen + +.include "test.mk" +.include <mkc.mk> diff --git a/examples/hello_autoconf/expect.out b/examples/hello_autoconf/expect.out new file mode 100644 index 0000000..86d30a6 --- /dev/null +++ b/examples/hello_autoconf/expect.out @@ -0,0 +1,46 @@ +Hello autoconf +=========== all ============ +/objdir/AUTHORS +/objdir/COPYING +/objdir/ChangeLog +/objdir/Makefile +/objdir/Makefile.in +/objdir/NEWS +/objdir/README +/objdir/config.h +/objdir/config.h.in +/objdir/config.log +/objdir/config.status +/objdir/configure +/objdir/configure.ac +/objdir/hello_autoconf +/objdir/hello_autoconf.c +========== clean =========== +/objdir/AUTHORS +/objdir/COPYING +/objdir/ChangeLog +/objdir/Makefile +/objdir/Makefile.in +/objdir/NEWS +/objdir/README +/objdir/config.h +/objdir/config.h.in +/objdir/config.log +/objdir/config.status +/objdir/configure +/objdir/configure.ac +/objdir/hello_autoconf.c +========== all SHRTOUT=yes =========== +MKGEN: +CONFIGURE: +configure: creating ./config.status +AUTOTOOLS: +======= cleandir ========== +/objdir/AUTHORS +/objdir/COPYING +/objdir/ChangeLog +/objdir/Makefile.in +/objdir/NEWS +/objdir/README +/objdir/configure.ac +/objdir/hello_autoconf.c diff --git a/examples/hello_autoconf/proj/AUTHORS b/examples/hello_autoconf/proj/AUTHORS new file mode 100644 index 0000000..28b4a17 --- /dev/null +++ b/examples/hello_autoconf/proj/AUTHORS @@ -0,0 +1 @@ +Aleksey Cheusov <vle@gmx.net> diff --git a/examples/hello_autoconf/proj/COPYING b/examples/hello_autoconf/proj/COPYING new file mode 100644 index 0000000..332900b --- /dev/null +++ b/examples/hello_autoconf/proj/COPYING @@ -0,0 +1,26 @@ +Copyright (c) 2014 by Aleksey Cheusov <vle@gmx.net> + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the + distribution. + +THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND +CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/examples/hello_autoconf/proj/ChangeLog b/examples/hello_autoconf/proj/ChangeLog new file mode 100644 index 0000000..82573db --- /dev/null +++ b/examples/hello_autoconf/proj/ChangeLog @@ -0,0 +1 @@ +Useless ChangeLog diff --git a/examples/hello_autoconf/proj/Makefile.in b/examples/hello_autoconf/proj/Makefile.in new file mode 100644 index 0000000..0ea68cc --- /dev/null +++ b/examples/hello_autoconf/proj/Makefile.in @@ -0,0 +1,26 @@ +# GNU Make is required + +srcdir = @srcdir@ + +CC ?= @CC@ + +CFLAGS ?= @CFLAGS@ +CPPFLAGS ?= @CPPFLAGS@ +LDFLAGS ?= @LDFLAGS@ +LIBS ?= @LIBS@ + +CPPFLAGS += -I. -I${srcdir} +CFLAGS += -DMSG='"$(shell echo Hello autoconf)"' + +.PHONY: all clean distclean + +all: hello_autoconf + +%: %.c + ${CC} -o $@ ${CPPFLAGS} ${CFLAGS} $< ${LDFLAGS} ${LIBS} + +clean: + -rm -f hello_autoconf + +distclean: clean # mk-configure removes almost everything + -rm -f ${srcdir}/config.h.in config.h diff --git a/examples/hello_autoconf/proj/NEWS b/examples/hello_autoconf/proj/NEWS new file mode 100644 index 0000000..5d9ab38 --- /dev/null +++ b/examples/hello_autoconf/proj/NEWS @@ -0,0 +1 @@ +No news is good news diff --git a/examples/hello_autoconf/proj/README b/examples/hello_autoconf/proj/README new file mode 100644 index 0000000..3d1830e --- /dev/null +++ b/examples/hello_autoconf/proj/README @@ -0,0 +1 @@ +This is a trivial autoconf-based project. diff --git a/examples/hello_autoconf/proj/configure.ac b/examples/hello_autoconf/proj/configure.ac new file mode 100644 index 0000000..bc5c142 --- /dev/null +++ b/examples/hello_autoconf/proj/configure.ac @@ -0,0 +1,14 @@ +dnl +dnl Process this file with autoconf to create configure. + +# Initialize Autoconf +AC_PREREQ([2.60]) +AC_INIT([hello_autotools], [0.28.0], + [https://github.com/cheusov/mk-configure]) +AC_CONFIG_SRCDIR([Makefile.in]) +AC_CONFIG_HEADERS([config.h]) + +dnl Checks for functions +AC_CHECK_HEADERS([stdio.h]) + +AC_OUTPUT([Makefile]) diff --git a/examples/hello_autoconf/proj/hello_autoconf.c b/examples/hello_autoconf/proj/hello_autoconf.c new file mode 100644 index 0000000..111fc7e --- /dev/null +++ b/examples/hello_autoconf/proj/hello_autoconf.c @@ -0,0 +1,11 @@ +#include <config.h> + +#ifdef HAVE_STDIO_H +#include <stdio.h> +#endif + +int main (int argc, char **argv) +{ + puts (MSG); + return 0; +} diff --git a/examples/hello_autoconf/test.mk b/examples/hello_autoconf/test.mk new file mode 100644 index 0000000..8e6586e --- /dev/null +++ b/examples/hello_autoconf/test.mk @@ -0,0 +1,27 @@ +EXCL_RE='autom4te[.]cache' + +.PHONY : test_output +test_output: + @ \ + ${.OBJDIR}/hello_autoconf; \ + rm -rf ${.OBJDIR}${PREFIX}; \ + \ + echo =========== all ============; \ + find ${.OBJDIR} -type f | grep -Ev '${EXCL_RE}' | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========== clean ===========; \ + ${MAKE} ${MAKEFLAGS} clean > /dev/null; \ + find ${.OBJDIR} -type f | grep -vE '${EXCL_RE}' | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========== all SHRTOUT=yes ===========; \ + ${MAKE} ${MAKEFLAGS} all SHRTOUT=yes | \ + grep -E '^[[:alpha:]]+:'; \ + \ + echo ======= cleandir ==========; \ + ${MAKE} ${MAKEFLAGS} cleandir > /dev/null; \ + find ${.OBJDIR} -type f | grep -vE '${EXCL_RE}' | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}" + +.include <mkc.minitest.mk> diff --git a/examples/hello_autotools/Makefile b/examples/hello_autotools/Makefile new file mode 100644 index 0000000..fa4c406 --- /dev/null +++ b/examples/hello_autotools/Makefile @@ -0,0 +1,11 @@ +FOREIGN = autotools +FSRCDIR = proj + +DISTCLEANFILES += ${.CURDIR}/${FSRCDIR}/hello_autotools-config.h.in + + +# the following is for regression tests. In real life we don't need this. +all: mkgen + +.include "test.mk" +.include <mkc.mk> diff --git a/examples/hello_autotools/expect.out b/examples/hello_autotools/expect.out new file mode 100644 index 0000000..0900108 --- /dev/null +++ b/examples/hello_autotools/expect.out @@ -0,0 +1,62 @@ +Hello AutoShi^H^H^HTools! +=========== all ============ +/objdir/.deps/main.Po +/objdir/AUTHORS +/objdir/COPYING +/objdir/ChangeLog +/objdir/Makefile +/objdir/Makefile.am +/objdir/Makefile.in +/objdir/NEWS +/objdir/README +/objdir/aclocal.m4 +/objdir/config.log +/objdir/config.status +/objdir/configure +/objdir/configure.ac +/objdir/hello_autotools +/objdir/hello_autotools-config.h +/objdir/hello_autotools-config.h.in +/objdir/main.c +/objdir/main.o +/objdir/stamp-h1 +========= install ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/bin/hello_autotools +======== uninstall ========= +/objdir/prefix +/objdir/prefix/bin +========== clean =========== +/objdir/.deps/main.Po +/objdir/AUTHORS +/objdir/COPYING +/objdir/ChangeLog +/objdir/Makefile +/objdir/Makefile.am +/objdir/Makefile.in +/objdir/NEWS +/objdir/README +/objdir/aclocal.m4 +/objdir/config.log +/objdir/config.status +/objdir/configure +/objdir/configure.ac +/objdir/hello_autotools-config.h +/objdir/hello_autotools-config.h.in +/objdir/main.c +/objdir/stamp-h1 +========== all SHRTOUT=yes =========== +MKGEN: +CONFIGURE: +configure: creating ./config.status +AUTOTOOLS: +======= cleandir ========== +/objdir/AUTHORS +/objdir/COPYING +/objdir/ChangeLog +/objdir/Makefile.am +/objdir/NEWS +/objdir/README +/objdir/configure.ac +/objdir/main.c diff --git a/examples/hello_autotools/proj/AUTHORS b/examples/hello_autotools/proj/AUTHORS new file mode 100644 index 0000000..28b4a17 --- /dev/null +++ b/examples/hello_autotools/proj/AUTHORS @@ -0,0 +1 @@ +Aleksey Cheusov <vle@gmx.net> diff --git a/examples/hello_autotools/proj/COPYING b/examples/hello_autotools/proj/COPYING new file mode 100644 index 0000000..332900b --- /dev/null +++ b/examples/hello_autotools/proj/COPYING @@ -0,0 +1,26 @@ +Copyright (c) 2014 by Aleksey Cheusov <vle@gmx.net> + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the + distribution. + +THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND +CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/examples/hello_autotools/proj/ChangeLog b/examples/hello_autotools/proj/ChangeLog new file mode 100644 index 0000000..82573db --- /dev/null +++ b/examples/hello_autotools/proj/ChangeLog @@ -0,0 +1 @@ +Useless ChangeLog diff --git a/examples/hello_autotools/proj/Makefile.am b/examples/hello_autotools/proj/Makefile.am new file mode 100644 index 0000000..5316cb9 --- /dev/null +++ b/examples/hello_autotools/proj/Makefile.am @@ -0,0 +1,3 @@ +bin_PROGRAMS = hello_autotools + +hello_autotools_SOURCES = main.c diff --git a/examples/hello_autotools/proj/NEWS b/examples/hello_autotools/proj/NEWS new file mode 100644 index 0000000..5d9ab38 --- /dev/null +++ b/examples/hello_autotools/proj/NEWS @@ -0,0 +1 @@ +No news is good news diff --git a/examples/hello_autotools/proj/README b/examples/hello_autotools/proj/README new file mode 100644 index 0000000..8b75e2d --- /dev/null +++ b/examples/hello_autotools/proj/README @@ -0,0 +1 @@ +This is a trivial autotools-based project. diff --git a/examples/hello_autotools/proj/configure.ac b/examples/hello_autotools/proj/configure.ac new file mode 100644 index 0000000..9122a3f --- /dev/null +++ b/examples/hello_autotools/proj/configure.ac @@ -0,0 +1,17 @@ +dnl +dnl Process this file with autoconf to create configure. + +# Initialize Autoconf +AC_PREREQ([2.60]) +AC_INIT([hello_autotools], [0.28.0], + [https://github.com/cheusov/mk-configure]) +AC_CONFIG_SRCDIR([Makefile.am]) +AC_CONFIG_HEADERS([hello_autotools-config.h]) + +# Initialize Automake +AM_INIT_AUTOMAKE + +dnl Checks for functions +AC_CHECK_HEADERS([stdio.h]) + +AC_OUTPUT([Makefile]) diff --git a/examples/hello_autotools/proj/main.c b/examples/hello_autotools/proj/main.c new file mode 100644 index 0000000..05a6dd3 --- /dev/null +++ b/examples/hello_autotools/proj/main.c @@ -0,0 +1,11 @@ +#include <hello_autotools-config.h> + +#ifdef HAVE_STDIO_H +#include <stdio.h> +#endif + +int main (int argc, char **argv) +{ + puts ("Hello AutoShi^H^H^HTools!"); + return 0; +} diff --git a/examples/hello_autotools/test.mk b/examples/hello_autotools/test.mk new file mode 100644 index 0000000..b8f96f3 --- /dev/null +++ b/examples/hello_autotools/test.mk @@ -0,0 +1,39 @@ +EXCL_RE='autom4te[.]cache' + +.PHONY : test_output +test_output: + @ \ + ${.OBJDIR}/hello_autotools; \ + rm -rf ${.OBJDIR}${PREFIX}; \ + \ + echo =========== all ============; \ + find ${.OBJDIR} -type f | grep -Ev '${EXCL_RE}' | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= install ==========; \ + ${MAKE} ${MAKEFLAGS} install -j3 \ + DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======== uninstall =========; \ + ${MAKE} ${MAKEFLAGS} -j4 uninstall \ + DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========== clean ===========; \ + ${MAKE} ${MAKEFLAGS} clean > /dev/null; \ + find ${.OBJDIR} -type f | grep -vE '${EXCL_RE}' | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========== all SHRTOUT=yes ===========; \ + ${MAKE} ${MAKEFLAGS} all SHRTOUT=yes | \ + grep -E '^[[:alpha:]]+:'; \ + \ + echo ======= cleandir ==========; \ + ${MAKE} ${MAKEFLAGS} cleandir > /dev/null; \ + find ${.OBJDIR} -type f | grep -vE '${EXCL_RE}' | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}" + +.include <mkc.minitest.mk> diff --git a/examples/hello_calc2/Makefile b/examples/hello_calc2/Makefile new file mode 100644 index 0000000..dbb0682 --- /dev/null +++ b/examples/hello_calc2/Makefile @@ -0,0 +1,31 @@ +PROG = calc +SRCS = lex.l parser.y + +DPSRCS = lex.c parser.c parser.h + +YHEADER = 1 +YPREFIX = calc_ +LPREFIX = calc_ + +MKC_CHECK_BUILTINS = prog_bison prog_flex + +MKC_FEATURES += libm + +lex.o: parser.h + +.include <mkc.configure.mk> + +YACC = ${"${BUILTIN.prog_bison}" != "":?${BUILTIN.prog_bison} -y:} +LEX = ${BUILTIN.prog_flex} +LEXLIB = #-lfl + +.if empty(BUILTIN.prog_flex) +MKC_ERR_MSG += "Cannot find flex, good bye!" +.endif + +.if empty(BUILTIN.prog_bison) +MKC_ERR_MSG += "Cannot find bison, good bye!" +.endif + +.include "test.mk" +.include <mkc.prog.mk> diff --git a/examples/hello_calc2/expect.out b/examples/hello_calc2/expect.out new file mode 100644 index 0000000..9c780e8 --- /dev/null +++ b/examples/hello_calc2/expect.out @@ -0,0 +1,99 @@ +4 +45 +-1 +45 +460 +484 +27 +73 +=========== all ============ +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_custom_prog_bison.err +/objdir/_mkc_custom_prog_bison.res +/objdir/_mkc_custom_prog_flex.err +/objdir/_mkc_custom_prog_flex.res +/objdir/_mkc_funclib_sqrt.c +/objdir/_mkc_funclib_sqrt.err +/objdir/_mkc_funclib_sqrt.res +/objdir/_mkc_funclib_sqrt_m.c +/objdir/_mkc_funclib_sqrt_m.err +/objdir/_mkc_funclib_sqrt_m.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/calc +/objdir/expect.out +/objdir/expressions.txt +/objdir/hello_calc2.test.out.tmp +/objdir/lex.c +/objdir/lex.l +/objdir/lex.o +/objdir/parser.c +/objdir/parser.h +/objdir/parser.o +/objdir/parser.y +/objdir/test.mk +========= install ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/bin/calc +======== uninstall ========= +========== clean =========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_custom_prog_bison.err +/objdir/_mkc_custom_prog_bison.res +/objdir/_mkc_custom_prog_flex.err +/objdir/_mkc_custom_prog_flex.res +/objdir/_mkc_funclib_sqrt.c +/objdir/_mkc_funclib_sqrt.err +/objdir/_mkc_funclib_sqrt.res +/objdir/_mkc_funclib_sqrt_m.c +/objdir/_mkc_funclib_sqrt_m.err +/objdir/_mkc_funclib_sqrt_m.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/expect.out +/objdir/expressions.txt +/objdir/hello_calc2.test.out.tmp +/objdir/lex.l +/objdir/parser.y +/objdir/test.mk +========== depend =========== +/objdir/.depend +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_custom_prog_bison.err +/objdir/_mkc_custom_prog_bison.res +/objdir/_mkc_custom_prog_flex.err +/objdir/_mkc_custom_prog_flex.res +/objdir/_mkc_funclib_sqrt.c +/objdir/_mkc_funclib_sqrt.err +/objdir/_mkc_funclib_sqrt.res +/objdir/_mkc_funclib_sqrt_m.c +/objdir/_mkc_funclib_sqrt_m.err +/objdir/_mkc_funclib_sqrt_m.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/expect.out +/objdir/expressions.txt +/objdir/hello_calc2.test.out.tmp +/objdir/lex.c +/objdir/lex.d +/objdir/lex.l +/objdir/parser.c +/objdir/parser.d +/objdir/parser.h +/objdir/parser.y +/objdir/test.mk +======= distclean ========== +/objdir/Makefile +/objdir/expect.out +/objdir/expressions.txt +/objdir/hello_calc2.test.out.tmp +/objdir/lex.l +/objdir/parser.y +/objdir/test.mk diff --git a/examples/hello_calc2/expressions.txt b/examples/hello_calc2/expressions.txt new file mode 100644 index 0000000..357aa2f --- /dev/null +++ b/examples/hello_calc2/expressions.txt @@ -0,0 +1,8 @@ +1+3 +5*9 +5-6 +(3+2)*(2+7) +(12+34)*10 +(12-34)^2 +10+34/2 +3^2+4^3 diff --git a/examples/hello_calc2/lex.l b/examples/hello_calc2/lex.l new file mode 100644 index 0000000..eb58f23 --- /dev/null +++ b/examples/hello_calc2/lex.l @@ -0,0 +1,24 @@ + +%{ +#include <stdio.h> + +#define yylval calc_lval + +#include "parser.h" +%} + +%option noyywrap + +digit [0-9] +number {digit}+\.?|{digit}*\.{digit}+ +id [a-zA-Z]+ + +%% + +[ ] { /* Skip spaces. */ } +{number} { sscanf (yytext, "%lf", &yylval.value); return NUMBER; } +\n|[-+\/*^()] { return yytext[0]; } + +%% + +YYSTYPE calc_lval; diff --git a/examples/hello_calc2/parser.y b/examples/hello_calc2/parser.y new file mode 100644 index 0000000..7837b25 --- /dev/null +++ b/examples/hello_calc2/parser.y @@ -0,0 +1,53 @@ + +%{ +#include <stdio.h> +#include <mkc_libm.h> +%} + +%union { + double value; + char* name; +} + +%token <value> NUMBER + +%type <value> expr + +%left '+' '-' +%right SQRT +%left '*' '/' +%right '^' +%right UMINUS + +%% +lines: lines expr '\n' { printf("%.10g\n", $2); } + | lines '\n' + | error '\n' { printf("Please re-enter last line: "); + yyerrok; } + | + ; + +expr: expr '+' expr { $$ = $1 + $3; } + | expr '-' expr { $$ = $1 - $3; } + | expr '*' expr { $$ = $1 * $3; } + | expr '/' expr { $$ = $1 / $3; } + | expr '^' expr { $$ = pow($1, $3); } + | '(' expr ')' { $$ = $2; } + | '-' expr %prec UMINUS { $$ = -$2; } + | NUMBER + ; + +%% +#include <ctype.h> +#include <stdio.h> + +int main (int argc, char **argv) +{ + return yyparse (); +} + +int yyerror (char* errstr) +{ + printf ("Error: %s\n", errstr); + return 1; +} diff --git a/examples/hello_calc2/test.mk b/examples/hello_calc2/test.mk new file mode 100644 index 0000000..e533b28 --- /dev/null +++ b/examples/hello_calc2/test.mk @@ -0,0 +1,38 @@ +.PHONY : test_output +test_output: + @set -e; \ + ${.OBJDIR}/calc < ${.CURDIR}/expressions.txt; \ + rm -rf ${.OBJDIR}${PREFIX}; \ + MKCATPAGES=yes; export MKCATPAGES; \ + \ + echo =========== all ============; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= install ==========; \ + ${MAKE} ${MAKEFLAGS} install -j3 DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======== uninstall =========; \ + ${MAKE} ${MAKEFLAGS} uninstall DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ========== clean ===========; \ + ${MAKE} ${MAKEFLAGS} clean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ========== depend ===========; \ + ${MAKE} ${MAKEFLAGS} depend -j4 DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ======= distclean ==========; \ + ${MAKE} ${MAKEFLAGS} distclean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}" + +.include <mkc.minitest.mk> diff --git a/examples/hello_compatlib/Makefile b/examples/hello_compatlib/Makefile new file mode 100644 index 0000000..82ec6b0 --- /dev/null +++ b/examples/hello_compatlib/Makefile @@ -0,0 +1,5 @@ +LIBDEPS = libcmpt:prog1 libcmpt:prog2 +COMPATLIB = libcmpt + +.include "test.mk" +.include <mkc.subprj.mk> diff --git a/examples/hello_compatlib/Makefile.inc b/examples/hello_compatlib/Makefile.inc new file mode 100644 index 0000000..de1cf0d --- /dev/null +++ b/examples/hello_compatlib/Makefile.inc @@ -0,0 +1 @@ +MKC_FEATURES = strlcpy strlcat getline progname fgetln err diff --git a/examples/hello_compatlib/expect.out b/examples/hello_compatlib/expect.out new file mode 100644 index 0000000..de509d4 --- /dev/null +++ b/examples/hello_compatlib/expect.out @@ -0,0 +1,90 @@ +=========== all ============ +/objdir/Makefile +/objdir/Makefile.inc +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_func0_getexecname_stdlib_h.c +/objdir/_mkc_func0_getexecname_stdlib_h.err +/objdir/_mkc_func0_getexecname_stdlib_h.res +/objdir/_mkc_func0_getprogname_stdlib_h.c +/objdir/_mkc_func0_getprogname_stdlib_h.err +/objdir/_mkc_func0_getprogname_stdlib_h.res +/objdir/_mkc_func1_setprogname_stdlib_h.c +/objdir/_mkc_func1_setprogname_stdlib_h.err +/objdir/_mkc_func1_setprogname_stdlib_h.res +/objdir/_mkc_func3_err_err_h.c +/objdir/_mkc_func3_err_err_h.err +/objdir/_mkc_func3_err_err_h.res +/objdir/_mkc_func3_errx_err_h.c +/objdir/_mkc_func3_errx_err_h.err +/objdir/_mkc_func3_errx_err_h.res +/objdir/_mkc_func3_fgetln_stdio_h.c +/objdir/_mkc_func3_fgetln_stdio_h.err +/objdir/_mkc_func3_fgetln_stdio_h.res +/objdir/_mkc_func3_getline_stdio_h.c +/objdir/_mkc_func3_getline_stdio_h.err +/objdir/_mkc_func3_getline_stdio_h.res +/objdir/_mkc_func3_strlcat_string_h.c +/objdir/_mkc_func3_strlcat_string_h.err +/objdir/_mkc_func3_strlcat_string_h.res +/objdir/_mkc_func3_strlcpy_string_h.c +/objdir/_mkc_func3_strlcpy_string_h.err +/objdir/_mkc_func3_strlcpy_string_h.res +/objdir/_mkc_func3_verr_err_h.c +/objdir/_mkc_func3_verr_err_h.err +/objdir/_mkc_func3_verr_err_h.res +/objdir/_mkc_func3_verrx_err_h.c +/objdir/_mkc_func3_verrx_err_h.err +/objdir/_mkc_func3_verrx_err_h.res +/objdir/_mkc_funclib_err.c +/objdir/_mkc_funclib_err.err +/objdir/_mkc_funclib_err.res +/objdir/_mkc_funclib_errx.c +/objdir/_mkc_funclib_errx.err +/objdir/_mkc_funclib_errx.res +/objdir/_mkc_funclib_fgetln.c +/objdir/_mkc_funclib_fgetln.err +/objdir/_mkc_funclib_fgetln.res +/objdir/_mkc_funclib_getline.c +/objdir/_mkc_funclib_getline.err +/objdir/_mkc_funclib_getline.res +/objdir/_mkc_funclib_getprogname.c +/objdir/_mkc_funclib_getprogname.err +/objdir/_mkc_funclib_getprogname.res +/objdir/_mkc_funclib_setprogname.c +/objdir/_mkc_funclib_setprogname.err +/objdir/_mkc_funclib_setprogname.res +/objdir/_mkc_funclib_strlcat.c +/objdir/_mkc_funclib_strlcat.err +/objdir/_mkc_funclib_strlcat.res +/objdir/_mkc_funclib_strlcpy.c +/objdir/_mkc_funclib_strlcpy.err +/objdir/_mkc_funclib_strlcpy.res +/objdir/_mkc_funclib_verr.c +/objdir/_mkc_funclib_verr.err +/objdir/_mkc_funclib_verr.res +/objdir/_mkc_funclib_verrx.c +/objdir/_mkc_funclib_verrx.err +/objdir/_mkc_funclib_verrx.res +/objdir/_mkc_header_err_h.c +/objdir/_mkc_header_err_h.err +/objdir/_mkc_header_err_h.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/_mkc_variable_program_invocation_short_name_errno_h.c +/objdir/_mkc_variable_program_invocation_short_name_errno_h.err +/objdir/_mkc_variable_program_invocation_short_name_errno_h.res +/objdir/expect.out +/objdir/hello_compatlib.test.out.tmp +/objdir/libcmpt/Makefile +/objdir/libcmpt/libcmpt.a +/objdir/libcmpt/libcmpt_pic.a +/objdir/prog1/Makefile +/objdir/prog1/prog1 +/objdir/prog1/prog1.c +/objdir/prog1/prog1.o +/objdir/prog2/Makefile +/objdir/prog2/prog2 +/objdir/prog2/prog2.c +/objdir/prog2/prog2.o +/objdir/test.mk diff --git a/examples/hello_compatlib/libcmpt/Makefile b/examples/hello_compatlib/libcmpt/Makefile new file mode 100644 index 0000000..a0d0bda --- /dev/null +++ b/examples/hello_compatlib/libcmpt/Makefile @@ -0,0 +1,3 @@ +LIB = cmpt + +.include <mkc.lib.mk> diff --git a/examples/hello_compatlib/prog1/Makefile b/examples/hello_compatlib/prog1/Makefile new file mode 100644 index 0000000..4a343d0 --- /dev/null +++ b/examples/hello_compatlib/prog1/Makefile @@ -0,0 +1,7 @@ +PROG = prog1 + +WARNS = 4 + +MKC_REQD = 0.27.0 + +.include <mkc.prog.mk> diff --git a/examples/hello_compatlib/prog1/prog1.c b/examples/hello_compatlib/prog1/prog1.c new file mode 100644 index 0000000..b662024 --- /dev/null +++ b/examples/hello_compatlib/prog1/prog1.c @@ -0,0 +1,38 @@ +#include <stdio.h> +#include <string.h> + +#include <mkc_strlcpy.h> +#include <mkc_strlcat.h> +#include <mkc_getline.h> +#include <mkc_progname.h> + +static const char message [] = "Theo de Raadt said: \"The strlcpy() and strlcat() functions provide a consistent, unambiguous API to help the programmer write more bullet-proof code.\""; + +int main (int argc, char ** argv) +{ + char *buf = NULL; + size_t size = 0; + ssize_t len = 0; + char small_buf [15]; + char said [19]; + + setprogname (argv [0]); + + while (len = getline (&buf, &size, stdin), len != -1){ + len = strlen (buf); + if (len > 0 && buf [len-1] == '\n') + buf [len-1] = 0; + + strlcpy (small_buf, "foo17", sizeof (small_buf)); + strlcat (small_buf, buf, sizeof (small_buf)); + puts (small_buf); + } + + strlcpy (said, message, sizeof (said)); + puts (said); + + printf ("short progname=%s\n", getprogname ()); + printf ("full progname=%s\n", argv [0]); + + return 0; +} diff --git a/examples/hello_compatlib/prog2/Makefile b/examples/hello_compatlib/prog2/Makefile new file mode 100644 index 0000000..6cde3eb --- /dev/null +++ b/examples/hello_compatlib/prog2/Makefile @@ -0,0 +1,7 @@ +PROG = prog2 + +WARNS = 4 + +MKC_REQD = 0.27.0 + +.include <mkc.prog.mk> diff --git a/examples/hello_compatlib/prog2/prog2.c b/examples/hello_compatlib/prog2/prog2.c new file mode 100644 index 0000000..8a4f0fb --- /dev/null +++ b/examples/hello_compatlib/prog2/prog2.c @@ -0,0 +1,24 @@ +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +#include <mkc_fgetln.h> +#include <mkc_err.h> + +int main (int argc, char ** argv) +{ + char *buf, *lbuf; + size_t len; + + while ((lbuf = buf = fgetln (stdin, &len)) != NULL) { + if (len > 0 && buf [len - 1] == '\n') + buf[len - 1] = '\0'; + else if ((lbuf = strndup (buf, len + 1)) == NULL) + err (1, NULL); + printf ("%s\n", lbuf); + + if (lbuf != buf) + free (lbuf); + } + return 0; +} diff --git a/examples/hello_compatlib/test.mk b/examples/hello_compatlib/test.mk new file mode 100644 index 0000000..425ad83 --- /dev/null +++ b/examples/hello_compatlib/test.mk @@ -0,0 +1,14 @@ +FUNCS_RE=(fgetln|progname|strlcat|strlcpy|getline)[.]o + +.PHONY : test_output +test_output : + @set -e; \ + echo =========== all ============; \ + find ${.OBJDIR} -type f | grep -Ev '${FUNCS_RE}' | \ + grep -vE 'libcmpt/.*[.]os?$$' | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + true =========== cleandir ============; \ + ${MAKE} ${MAKEFLAGS} distclean > /dev/null + +.include <mkc.minitest.mk> diff --git a/examples/hello_compilers/Makefile b/examples/hello_compilers/Makefile new file mode 100644 index 0000000..6f9563a --- /dev/null +++ b/examples/hello_compilers/Makefile @@ -0,0 +1,31 @@ +MKC_CHECK_DEFINES += __INTEL_COMPILER __GNUC__ _MSC_VER __PCC__ __SUNPRO_C +MKC_CHECK_DEFINES += __DECC _COMPILER_VERSION + +PROG = compiler_test + +MKC_REQD = 0.10.0 + +WARNS = 4 + +.include <mkc.configure.mk> + +.if ${HAVE_DEFINE._MSC_VER:U0} +msg = Microsoft C Compiler +.elif ${HAVE_DEFINE.__INTEL_COMPILER:U0} +msg = Intel C Compiler +.elif ${HAVE_DEFINE.__PCC__:U0} +msg = Portable C Compiler +.elif ${HAVE_DEFINE.__GNUC__:U1} +msg = GNU C Compiler +.elif ${HAVE_DEFINE.__SUNPRO_C:U1} +msg = SunPro C Compiler +.elif ${HAVE_DEFINE._COMPILER_VERSION:U1} +msg = SGI MIPSPro C Compiler +.else +msg = Unknown compiler +.endif + +CFLAGS += -DMSG='"${msg}"' + +.include "test.mk" +.include <mkc.prog.mk> diff --git a/examples/hello_compilers/compiler_test.c b/examples/hello_compilers/compiler_test.c new file mode 100644 index 0000000..30bd714 --- /dev/null +++ b/examples/hello_compilers/compiler_test.c @@ -0,0 +1,52 @@ +#include <stdio.h> +#include <string.h> + +#if defined(HAVE_DEFINE__COMPILER_VERSION) && defined(HAVE_DEFINE___GNUC__) +#undef HAVE_DEFINE__COMPILER_VERSION +#endif + + + +#ifndef HAVE_DEFINE__MSC_VER +#define HAVE_DEFINE__MSC_VER 0 +#endif + +#ifndef HAVE_DEFINE___GNUC__ +#define HAVE_DEFINE___GNUC__ 0 +#endif + +#ifndef HAVE_DEFINE___INTEL_COMPILER +#define HAVE_DEFINE___INTEL_COMPILER 0 +#else +#undef HAVE_DEFINE___GNUC__ +#define HAVE_DEFINE___GNUC__ 0 +#endif + +#ifndef HAVE_DEFINE___PCC__ +#define HAVE_DEFINE___PCC__ 0 +#endif + +#ifndef HAVE_DEFINE___SUNPRO_C +#define HAVE_DEFINE___SUNPRO_C 0 +#endif + +#ifndef HAVE_DEFINE___DECC +#define HAVE_DEFINE___DECC 0 +#endif + +#ifndef HAVE_DEFINE__COMPILER_VERSION +#define HAVE_DEFINE__COMPILER_VERSION 0 +#endif + +char msg [] = "Compiled by " MSG; + +int main (int argc, char **argv) +{ + printf ("%d\n", (strlen (MSG) > 0) + + HAVE_DEFINE__MSC_VER + HAVE_DEFINE___INTEL_COMPILER + + HAVE_DEFINE___PCC__ + HAVE_DEFINE___GNUC__ + + HAVE_DEFINE___SUNPRO_C + HAVE_DEFINE___DECC + + HAVE_DEFINE__COMPILER_VERSION); + + return 0; +} diff --git a/examples/hello_compilers/expect.out b/examples/hello_compilers/expect.out new file mode 100644 index 0000000..f2c9e71 --- /dev/null +++ b/examples/hello_compilers/expect.out @@ -0,0 +1,76 @@ +2 +=========== all ============ +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_define__COMPILER_VERSION.c +/objdir/_mkc_define__COMPILER_VERSION.err +/objdir/_mkc_define__COMPILER_VERSION.res +/objdir/_mkc_define__MSC_VER.c +/objdir/_mkc_define__MSC_VER.err +/objdir/_mkc_define__MSC_VER.res +/objdir/_mkc_define___DECC.c +/objdir/_mkc_define___DECC.err +/objdir/_mkc_define___DECC.res +/objdir/_mkc_define___GNUC__.c +/objdir/_mkc_define___GNUC__.err +/objdir/_mkc_define___GNUC__.res +/objdir/_mkc_define___INTEL_COMPILER.c +/objdir/_mkc_define___INTEL_COMPILER.err +/objdir/_mkc_define___INTEL_COMPILER.res +/objdir/_mkc_define___PCC__.c +/objdir/_mkc_define___PCC__.err +/objdir/_mkc_define___PCC__.res +/objdir/_mkc_define___SUNPRO_C.c +/objdir/_mkc_define___SUNPRO_C.err +/objdir/_mkc_define___SUNPRO_C.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/compiler_test +/objdir/compiler_test.c +/objdir/compiler_test.o +/objdir/expect.out +/objdir/hello_compilers.test.out.tmp +/objdir/test.mk +========= install ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/bin/compiler_test +======== uninstall ========= +========== clean =========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_define__COMPILER_VERSION.c +/objdir/_mkc_define__COMPILER_VERSION.err +/objdir/_mkc_define__COMPILER_VERSION.res +/objdir/_mkc_define__MSC_VER.c +/objdir/_mkc_define__MSC_VER.err +/objdir/_mkc_define__MSC_VER.res +/objdir/_mkc_define___DECC.c +/objdir/_mkc_define___DECC.err +/objdir/_mkc_define___DECC.res +/objdir/_mkc_define___GNUC__.c +/objdir/_mkc_define___GNUC__.err +/objdir/_mkc_define___GNUC__.res +/objdir/_mkc_define___INTEL_COMPILER.c +/objdir/_mkc_define___INTEL_COMPILER.err +/objdir/_mkc_define___INTEL_COMPILER.res +/objdir/_mkc_define___PCC__.c +/objdir/_mkc_define___PCC__.err +/objdir/_mkc_define___PCC__.res +/objdir/_mkc_define___SUNPRO_C.c +/objdir/_mkc_define___SUNPRO_C.err +/objdir/_mkc_define___SUNPRO_C.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/compiler_test.c +/objdir/expect.out +/objdir/hello_compilers.test.out.tmp +/objdir/test.mk +======= distclean ========== +/objdir/Makefile +/objdir/compiler_test.c +/objdir/expect.out +/objdir/hello_compilers.test.out.tmp +/objdir/test.mk diff --git a/examples/hello_compilers/test.mk b/examples/hello_compilers/test.mk new file mode 100644 index 0000000..8709b94 --- /dev/null +++ b/examples/hello_compilers/test.mk @@ -0,0 +1,33 @@ +.PHONY : test_output +test_output: + @set -e; \ + ${.OBJDIR}/compiler_test; \ + rm -rf ${.OBJDIR}${PREFIX}; \ + MKCATPAGES=yes; export MKCATPAGES; \ + \ + echo =========== all ============; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= install ==========; \ + ${MAKE} ${MAKEFLAGS} install -j3 DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======== uninstall =========; \ + ${MAKE} ${MAKEFLAGS} -j4 uninstall DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========== clean ===========; \ + ${MAKE} ${MAKEFLAGS} clean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======= distclean ==========; \ + ${MAKE} ${MAKEFLAGS} distclean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}" + +.include <mkc.minitest.mk> diff --git a/examples/hello_customtests/Makefile b/examples/hello_customtests/Makefile new file mode 100644 index 0000000..8bba131 --- /dev/null +++ b/examples/hello_customtests/Makefile @@ -0,0 +1,29 @@ +PROG = hello_customtests + +WARNS = 4 + +MKC_CHECK_CUSTOM = alloca_in_stdlib_h # C lang check +MKC_CHECK_CUSTOM += alloca_in_alloca_h # C lang check +MKC_CHECK_CUSTOM += cxx_with_templates # C++ lang check +MKC_CHECK_CUSTOM += true_is_available # script-based check +MKC_CHECK_CUSTOM += shtest # script-based check + +MKC_CUSTOM_FN.alloca_in_stdlib_h = custom_tests/alloca_in_stdlib_h.c +MKC_CUSTOM_FN.alloca_in_alloca_h = custom_tests/alloca_in_alloca_h.c +MKC_CUSTOM_FN.cxx_with_templates = custom_tests/cxx_with_templates.cc +MKC_CUSTOM_FN.true_is_available = custom_tests/true_is_available +MKC_CUSTOM_FN.shtest = custom_tests/shtest + +MKC_CHECK_BUILTINS += endianness + +MKC_REQD = 0.12.0 + +.include <mkc.configure.mk> + +BUILTIN.endianness ?= +.if ${BUILTIN.endianness} != little && ${BUILTIN.endianness} != big +MKC_ERR_MSG = "Do you run PDP-11?" +.endif + +.include "test.mk" +.include <mkc.prog.mk> diff --git a/examples/hello_customtests/custom_tests/alloca_in_alloca_h.c b/examples/hello_customtests/custom_tests/alloca_in_alloca_h.c new file mode 100644 index 0000000..4ff3f19 --- /dev/null +++ b/examples/hello_customtests/custom_tests/alloca_in_alloca_h.c @@ -0,0 +1,9 @@ +#include <alloca.h> + +int main (int argc, char **argv) +{ +#ifndef alloca + void *p = &alloca; +#endif + return 0; +} diff --git a/examples/hello_customtests/custom_tests/alloca_in_stdlib_h.c b/examples/hello_customtests/custom_tests/alloca_in_stdlib_h.c new file mode 100644 index 0000000..9b1e7a1 --- /dev/null +++ b/examples/hello_customtests/custom_tests/alloca_in_stdlib_h.c @@ -0,0 +1,9 @@ +#include <stdlib.h> + +int main (int argc, char **argv) +{ +#ifndef alloca + void *p = &alloca; +#endif + return 0; +} diff --git a/examples/hello_customtests/custom_tests/cxx_with_templates.cc b/examples/hello_customtests/custom_tests/cxx_with_templates.cc new file mode 100644 index 0000000..f580a29 --- /dev/null +++ b/examples/hello_customtests/custom_tests/cxx_with_templates.cc @@ -0,0 +1,15 @@ +#include <iostream> + +template <typename T> +T ident (T v) +{ + return v; +} + +int main (int argc, char **argv) +{ + std::cout << ident (123); + std::cout << ident ("string"); + + return 0; +} diff --git a/examples/hello_customtests/custom_tests/shtest b/examples/hello_customtests/custom_tests/shtest new file mode 100755 index 0000000..ad9ee24 --- /dev/null +++ b/examples/hello_customtests/custom_tests/shtest @@ -0,0 +1,5 @@ +#!/bin/sh + +# Just a test +foo_bar_baz +echo 0 diff --git a/examples/hello_customtests/custom_tests/true_is_available b/examples/hello_customtests/custom_tests/true_is_available new file mode 100755 index 0000000..51f40e7 --- /dev/null +++ b/examples/hello_customtests/custom_tests/true_is_available @@ -0,0 +1,3 @@ +#!/bin/sh + +echo 1 diff --git a/examples/hello_customtests/expect.out b/examples/hello_customtests/expect.out new file mode 100644 index 0000000..5ff71f7 --- /dev/null +++ b/examples/hello_customtests/expect.out @@ -0,0 +1,79 @@ +=========== all ============ +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_custom_alloca_in_alloca_h.err +/objdir/_mkc_custom_alloca_in_alloca_h.res +/objdir/_mkc_custom_alloca_in_stdlib_h.err +/objdir/_mkc_custom_alloca_in_stdlib_h.res +/objdir/_mkc_custom_cxx_with_templates.err +/objdir/_mkc_custom_cxx_with_templates.res +/objdir/_mkc_custom_endianness.err +/objdir/_mkc_custom_endianness.res +/objdir/_mkc_custom_shtest.err +/objdir/_mkc_custom_shtest.res +/objdir/_mkc_custom_true_is_available.err +/objdir/_mkc_custom_true_is_available.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/custom_tests/alloca_in_alloca_h.c +/objdir/custom_tests/alloca_in_stdlib_h.c +/objdir/custom_tests/cxx_with_templates.cc +/objdir/custom_tests/shtest +/objdir/custom_tests/true_is_available +/objdir/expect.out +/objdir/hello_customtests +/objdir/hello_customtests.c +/objdir/hello_customtests.o +/objdir/hello_customtests.test.out.tmp +/objdir/test.mk +=========== run ============ +alloca(3) succeeded +We have C++ compiler with working templates: YES +We have a working 'true' in bourne shell: YES +shtest is good: NO +========= install ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/bin/hello_customtests +======== uninstall ========= +========== clean =========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_custom_alloca_in_alloca_h.err +/objdir/_mkc_custom_alloca_in_alloca_h.res +/objdir/_mkc_custom_alloca_in_stdlib_h.err +/objdir/_mkc_custom_alloca_in_stdlib_h.res +/objdir/_mkc_custom_cxx_with_templates.err +/objdir/_mkc_custom_cxx_with_templates.res +/objdir/_mkc_custom_endianness.err +/objdir/_mkc_custom_endianness.res +/objdir/_mkc_custom_shtest.err +/objdir/_mkc_custom_shtest.res +/objdir/_mkc_custom_true_is_available.err +/objdir/_mkc_custom_true_is_available.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/custom_tests/alloca_in_alloca_h.c +/objdir/custom_tests/alloca_in_stdlib_h.c +/objdir/custom_tests/cxx_with_templates.cc +/objdir/custom_tests/shtest +/objdir/custom_tests/true_is_available +/objdir/expect.out +/objdir/hello_customtests.c +/objdir/hello_customtests.test.out.tmp +/objdir/test.mk +======= errorcheck + MAKEOBJDIR =========== +true_is_available=1 +======= distclean ========== +/objdir/Makefile +/objdir/custom_tests/alloca_in_alloca_h.c +/objdir/custom_tests/alloca_in_stdlib_h.c +/objdir/custom_tests/cxx_with_templates.cc +/objdir/custom_tests/shtest +/objdir/custom_tests/true_is_available +/objdir/expect.out +/objdir/hello_customtests.c +/objdir/hello_customtests.test.out.tmp +/objdir/test.mk diff --git a/examples/hello_customtests/hello_customtests.c b/examples/hello_customtests/hello_customtests.c new file mode 100644 index 0000000..a801f4f --- /dev/null +++ b/examples/hello_customtests/hello_customtests.c @@ -0,0 +1,38 @@ +#include <stdio.h> + +#if CUSTOM_ALLOCA_IN_STDLIB_H +#include <stdlib.h> +#elif CUSTOM_ALLOCA_IN_ALLOCA_H +#include <alloca.h> +#endif + +#ifndef CUSTOM_SHTEST +#define CUSTOM_SHTEST 0 +#endif + +#ifndef CUSTOM_CXX_WITH_TEMPLATES +#define CUSTOM_CXX_WITH_TEMPLATES 0 +#endif + +#ifndef CUSTOM_TRUE_IS_AVAILABLE +#define CUSTOM_TRUE_IS_AVAILABLE 0 +#endif + +int main (int argc, char** argv) +{ + if (alloca (100)) + puts ("alloca(3) succeeded"); + else + puts ("alloca(3) failed"); + + printf ("We have C++ compiler with working templates: %s\n", + (CUSTOM_CXX_WITH_TEMPLATES ? "YES" : "NO")); + + printf ("We have a working 'true' in bourne shell: %s\n", + (CUSTOM_TRUE_IS_AVAILABLE ? "YES" : "NO")); + + printf ("shtest is good: %s\n", + (CUSTOM_SHTEST ? "YES" : "NO")); + + return 0; +} diff --git a/examples/hello_customtests/test.mk b/examples/hello_customtests/test.mk new file mode 100644 index 0000000..ba5e27c --- /dev/null +++ b/examples/hello_customtests/test.mk @@ -0,0 +1,44 @@ +CLEANDIRS += ${.CURDIR}/testdir + +.PHONY : test_output +test_output: + @set -e; \ + rm -rf ${.OBJDIR}${PREFIX}; \ + MKCATPAGES=yes; export MKCATPAGES; \ + \ + echo =========== all ============; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo =========== run ============; \ + ${.OBJDIR}/hello_customtests; \ + \ + echo ========= install ==========; \ + ${MAKE} ${MAKEFLAGS} install -j3 DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======== uninstall =========; \ + ${MAKE} ${MAKEFLAGS} -j4 uninstall DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ========== clean ===========; \ + ${MAKE} ${MAKEFLAGS} clean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ======= errorcheck + MAKEOBJDIR ===========; \ + mkdir ${.CURDIR}/testdir || true; \ + ${MAKE} ${MAKEFLAGS} errorcheck \ + MKC_CACHEDIR=${.CURDIR}/testdir \ + MAKEOBJDIR=${.CURDIR}/testdir > /dev/null; \ + printf 'true_is_available=%s\n' `cat ${.CURDIR}/testdir/_mkc_custom_true_is_available.res`; \ + \ + echo ======= distclean ==========; \ + ${MAKE} ${MAKEFLAGS} distclean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}" + +.include <mkc.minitest.mk> diff --git a/examples/hello_customtests2/Makefile b/examples/hello_customtests2/Makefile new file mode 100644 index 0000000..b3b6b9c --- /dev/null +++ b/examples/hello_customtests2/Makefile @@ -0,0 +1,16 @@ +PROG = hello_customtests2 + +WARNS = 4 + +MKC_CUSTOM_DIR = ${.CURDIR}/../hello_customtests/custom_tests + +MKC_CHECK_CUSTOM = alloca_in_stdlib_h alloca_in_alloca_h \ + true_is_available + +# full path is for regression test +MKC_CUSTOM_FN.true_is_available = ${MKC_CUSTOM_DIR}/true_is_available + +MKC_REQD = 0.11.0 + +.include "test.mk" +.include <mkc.prog.mk> diff --git a/examples/hello_customtests2/expect.out b/examples/hello_customtests2/expect.out new file mode 100644 index 0000000..04eecd6 --- /dev/null +++ b/examples/hello_customtests2/expect.out @@ -0,0 +1,49 @@ +=========== all ============ +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_custom_alloca_in_alloca_h.err +/objdir/_mkc_custom_alloca_in_alloca_h.res +/objdir/_mkc_custom_alloca_in_stdlib_h.err +/objdir/_mkc_custom_alloca_in_stdlib_h.res +/objdir/_mkc_custom_true_is_available.err +/objdir/_mkc_custom_true_is_available.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/expect.out +/objdir/hello_customtests2 +/objdir/hello_customtests2.c +/objdir/hello_customtests2.o +/objdir/hello_customtests2.test.out.tmp +/objdir/test.mk +=========== run ============ +alloca(3) succeeded +========= install ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/bin/hello_customtests2 +======== uninstall ========= +========== clean =========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_custom_alloca_in_alloca_h.err +/objdir/_mkc_custom_alloca_in_alloca_h.res +/objdir/_mkc_custom_alloca_in_stdlib_h.err +/objdir/_mkc_custom_alloca_in_stdlib_h.res +/objdir/_mkc_custom_true_is_available.err +/objdir/_mkc_custom_true_is_available.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/expect.out +/objdir/hello_customtests2.c +/objdir/hello_customtests2.test.out.tmp +/objdir/test.mk +======= errorcheck + MAKEOBJDIR =========== +true_is_available=1 +======= distclean ========== +/objdir/Makefile +/objdir/expect.out +/objdir/hello_customtests2.c +/objdir/hello_customtests2.test.out.tmp +/objdir/test.mk diff --git a/examples/hello_customtests2/hello_customtests2.c b/examples/hello_customtests2/hello_customtests2.c new file mode 100644 index 0000000..410e634 --- /dev/null +++ b/examples/hello_customtests2/hello_customtests2.c @@ -0,0 +1,17 @@ +#include <stdio.h> + +#if CUSTOM_ALLOCA_IN_STDLIB_H +#include <stdlib.h> +#elif CUSTOM_ALLOCA_IN_ALLOCA_H +#include <alloca.h> +#endif + +int main (int argc, char** argv) +{ + if (alloca (100)) + puts ("alloca(3) succeeded"); + else + puts ("alloca(3) failed"); + + return 0; +} diff --git a/examples/hello_customtests2/test.mk b/examples/hello_customtests2/test.mk new file mode 100644 index 0000000..3a6bf21 --- /dev/null +++ b/examples/hello_customtests2/test.mk @@ -0,0 +1,44 @@ +CLEANDIRS += ${.CURDIR}/testdir + +.PHONY : test_output +test_output: + @set -e; \ + rm -rf ${.OBJDIR}${PREFIX}; \ + MKCATPAGES=yes; export MKCATPAGES; \ + \ + echo =========== all ============; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo =========== run ============; \ + ${.OBJDIR}/hello_customtests2; \ + \ + echo ========= install ==========; \ + ${MAKE} ${MAKEFLAGS} install -j3 DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======== uninstall =========; \ + ${MAKE} ${MAKEFLAGS} -j4 uninstall DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ========== clean ===========; \ + ${MAKE} ${MAKEFLAGS} clean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ======= errorcheck + MAKEOBJDIR ===========; \ + mkdir ${.CURDIR}/testdir || true; \ + ${MAKE} ${MAKEFLAGS} errorcheck \ + MKC_CACHEDIR=${.CURDIR}/testdir \ + MAKEOBJDIR=${.CURDIR}/testdir > /dev/null; \ + printf 'true_is_available=%s\n' `cat ${.CURDIR}/testdir/_mkc_custom_true_is_available.res`; \ + \ + echo ======= distclean ==========; \ + ${MAKE} ${MAKEFLAGS} distclean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}" + +.include <mkc.minitest.mk> diff --git a/examples/hello_cxx/Makefile b/examples/hello_cxx/Makefile new file mode 100644 index 0000000..be0460d --- /dev/null +++ b/examples/hello_cxx/Makefile @@ -0,0 +1,12 @@ +PROG = hello_cxx + +WARNS = 4 + +CPPFLAGS += -I. + +SRCS = main.cc hello_msg.cc five.c seven.c + +MKC_REQD = 0.12.9 + +.include "test.mk" +.include <mkc.prog.mk> diff --git a/examples/hello_cxx/expect.out b/examples/hello_cxx/expect.out new file mode 100644 index 0000000..2d97290 --- /dev/null +++ b/examples/hello_cxx/expect.out @@ -0,0 +1,65 @@ +Hello world! +Five: 5 +Seven: 7 +=========== all ============ +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_cxx_type.err +/objdir/_mkc_cxx_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/_mkc_prog_cxx.err +/objdir/_mkc_prog_cxx.res +/objdir/expect.out +/objdir/five.c +/objdir/five.h +/objdir/five.o +/objdir/hello_cxx +/objdir/hello_cxx.test.out.tmp +/objdir/hello_msg.cc +/objdir/hello_msg.h +/objdir/hello_msg.o +/objdir/main.cc +/objdir/main.o +/objdir/seven.c +/objdir/seven.h +/objdir/seven.o +/objdir/test.mk +========= install ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/bin/hello_cxx +======== uninstall ========= +========== clean =========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_cxx_type.err +/objdir/_mkc_cxx_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/_mkc_prog_cxx.err +/objdir/_mkc_prog_cxx.res +/objdir/expect.out +/objdir/five.c +/objdir/five.h +/objdir/hello_cxx.test.out.tmp +/objdir/hello_msg.cc +/objdir/hello_msg.h +/objdir/main.cc +/objdir/seven.c +/objdir/seven.h +/objdir/test.mk +======= distclean ========== +/objdir/Makefile +/objdir/expect.out +/objdir/five.c +/objdir/five.h +/objdir/hello_cxx.test.out.tmp +/objdir/hello_msg.cc +/objdir/hello_msg.h +/objdir/main.cc +/objdir/seven.c +/objdir/seven.h +/objdir/test.mk diff --git a/examples/hello_cxx/five.c b/examples/hello_cxx/five.c new file mode 100644 index 0000000..1b2f63f --- /dev/null +++ b/examples/hello_cxx/five.c @@ -0,0 +1,6 @@ +#include "five.h" + +int five (void) +{ + return 5; +} diff --git a/examples/hello_cxx/five.h b/examples/hello_cxx/five.h new file mode 100644 index 0000000..51f786b --- /dev/null +++ b/examples/hello_cxx/five.h @@ -0,0 +1,14 @@ +#ifndef _FIVE_H_ +#define _FIVE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +int five (void); + +#ifdef __cplusplus +}; +#endif + +#endif // _FIVE_H_ diff --git a/examples/hello_cxx/hello_msg.cc b/examples/hello_cxx/hello_msg.cc new file mode 100644 index 0000000..72976ef --- /dev/null +++ b/examples/hello_cxx/hello_msg.cc @@ -0,0 +1,6 @@ +#include <iostream> + +void hello_msg () +{ + std::cout << "Hello world!\n"; +} diff --git a/examples/hello_cxx/hello_msg.h b/examples/hello_cxx/hello_msg.h new file mode 100644 index 0000000..944c11f --- /dev/null +++ b/examples/hello_cxx/hello_msg.h @@ -0,0 +1 @@ +void hello_msg (); diff --git a/examples/hello_cxx/main.cc b/examples/hello_cxx/main.cc new file mode 100644 index 0000000..1d99736 --- /dev/null +++ b/examples/hello_cxx/main.cc @@ -0,0 +1,13 @@ +#include "hello_msg.h" +#include "five.h" +#include "seven.h" + +#include <iostream> + +int main (int argc, char **argv) +{ + hello_msg (); + std::cout << "Five: " << five () << '\n'; + std::cout << "Seven: " << seven () << '\n'; + return 0; +} diff --git a/examples/hello_cxx/seven.c b/examples/hello_cxx/seven.c new file mode 100644 index 0000000..1e4316a --- /dev/null +++ b/examples/hello_cxx/seven.c @@ -0,0 +1,6 @@ +#include "seven.h" + +int seven (void) +{ + return 7; +} diff --git a/examples/hello_cxx/seven.h b/examples/hello_cxx/seven.h new file mode 100644 index 0000000..34c3642 --- /dev/null +++ b/examples/hello_cxx/seven.h @@ -0,0 +1,14 @@ +#ifndef _SEVEN_H_ +#define _SEVEN_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +int seven (void); + +#ifdef __cplusplus +}; +#endif + +#endif // _SEVEN_H_ diff --git a/examples/hello_cxx/test.mk b/examples/hello_cxx/test.mk new file mode 100644 index 0000000..a961674 --- /dev/null +++ b/examples/hello_cxx/test.mk @@ -0,0 +1,33 @@ +.PHONY : test_output +test_output: + @set -e; \ + ${.OBJDIR}/hello_cxx; \ + rm -rf ${.OBJDIR}${PREFIX}; \ + MKCATPAGES=yes; export MKCATPAGES; \ + \ + echo =========== all ============; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= install ==========; \ + ${MAKE} ${MAKEFLAGS} install -j3 DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======== uninstall =========; \ + ${MAKE} ${MAKEFLAGS} -j4 uninstall DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ========== clean ===========; \ + ${MAKE} ${MAKEFLAGS} clean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ======= distclean ==========; \ + ${MAKE} ${MAKEFLAGS} distclean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}" + +.include <mkc.minitest.mk> diff --git a/examples/hello_cxxlib/Makefile b/examples/hello_cxxlib/Makefile new file mode 100644 index 0000000..2469051 --- /dev/null +++ b/examples/hello_cxxlib/Makefile @@ -0,0 +1,8 @@ +PROJECTNAME = hello_cxx + +SUBDIR += cxxlib +SUBDIR += .WAIT +SUBDIR += cxxapp + +.include "test.mk" +.include <mkc.subdir.mk> diff --git a/examples/hello_cxxlib/cxxapp/Makefile b/examples/hello_cxxlib/cxxapp/Makefile new file mode 100644 index 0000000..2bada12 --- /dev/null +++ b/examples/hello_cxxlib/cxxapp/Makefile @@ -0,0 +1,8 @@ +PROG = cxxapp +SRCS = cxxapp.cc + +WARNS = 4 + +.include "../cxxlib/linkme.mk" + +.include <mkc.prog.mk> diff --git a/examples/hello_cxxlib/cxxapp/cxxapp.cc b/examples/hello_cxxlib/cxxapp/cxxapp.cc new file mode 100644 index 0000000..0284107 --- /dev/null +++ b/examples/hello_cxxlib/cxxapp/cxxapp.cc @@ -0,0 +1,11 @@ +#include <iostream> + +#include "hello_msg.h" + +int main (int argc, char **) +{ + hello_msg1 (); + std::cout << hello_msg2 () << '\n'; + + return 0; +} diff --git a/examples/hello_cxxlib/cxxlib/Makefile b/examples/hello_cxxlib/cxxlib/Makefile new file mode 100644 index 0000000..540eb02 --- /dev/null +++ b/examples/hello_cxxlib/cxxlib/Makefile @@ -0,0 +1,18 @@ +LIB = cxxlib + +WARNS = 4 + +SHLIB_MAJOR = 1 +SHLIB_MINOR = 0 +SHLIB_TEENY = 5 + +INCS = hello_msg.h impl/hello_msg1.h impl/hello_msg2.h + +INCSSRCDIR = include + +SRCS = hello_msg1.cpp hello_msg2.cpp + +MKC_SOURCE_FUNCLIBS = dummy # a part of regression test +MKC_SOURCE_DIR.dummy.c := ${.PARSEDIR} + +.include <mkc.lib.mk> diff --git a/examples/hello_cxxlib/cxxlib/dummy.c b/examples/hello_cxxlib/cxxlib/dummy.c new file mode 100644 index 0000000..a30fafb --- /dev/null +++ b/examples/hello_cxxlib/cxxlib/dummy.c @@ -0,0 +1,6 @@ +/* we do use this function, this is just a part of regression test */ +void dummy_func (void); +void dummy_func (void) +{ + /* we do nothing here */ +} diff --git a/examples/hello_cxxlib/cxxlib/hello_msg1.cpp b/examples/hello_cxxlib/cxxlib/hello_msg1.cpp new file mode 100644 index 0000000..3271d8c --- /dev/null +++ b/examples/hello_cxxlib/cxxlib/hello_msg1.cpp @@ -0,0 +1,6 @@ +#include <iostream> + +void hello_msg1 () +{ + std::cout << "Hello world 1!\n"; +} diff --git a/examples/hello_cxxlib/cxxlib/hello_msg2.cpp b/examples/hello_cxxlib/cxxlib/hello_msg2.cpp new file mode 100644 index 0000000..a65f897 --- /dev/null +++ b/examples/hello_cxxlib/cxxlib/hello_msg2.cpp @@ -0,0 +1,10 @@ +#include <iostream> +#include <string> + +std::string hello_msg2 () +{ + std::string ret = "hello"; + ret += " world"; + ret += " 2!"; + return ret; +} diff --git a/examples/hello_cxxlib/cxxlib/include/hello_msg.h b/examples/hello_cxxlib/cxxlib/include/hello_msg.h new file mode 100644 index 0000000..5ab617d --- /dev/null +++ b/examples/hello_cxxlib/cxxlib/include/hello_msg.h @@ -0,0 +1,7 @@ +#ifndef _HELLO_H_ +#define _HELLO_H_ + +#include "impl/hello_msg1.h" +#include "impl/hello_msg2.h" + +#endif // _HELLO_H_ diff --git a/examples/hello_cxxlib/cxxlib/include/impl/hello_msg1.h b/examples/hello_cxxlib/cxxlib/include/impl/hello_msg1.h new file mode 100644 index 0000000..fa6cc7a --- /dev/null +++ b/examples/hello_cxxlib/cxxlib/include/impl/hello_msg1.h @@ -0,0 +1,6 @@ +#ifndef _HELLO_MSG1_H_ +#define _HELLO_MSG1_H_ + +void hello_msg1 (); + +#endif // _HELLO_MSG1_H_ diff --git a/examples/hello_cxxlib/cxxlib/include/impl/hello_msg2.h b/examples/hello_cxxlib/cxxlib/include/impl/hello_msg2.h new file mode 100644 index 0000000..5a39f30 --- /dev/null +++ b/examples/hello_cxxlib/cxxlib/include/impl/hello_msg2.h @@ -0,0 +1,8 @@ +#ifndef _HELLO_MSG2_H_ +#define _HELLO_MSG2_H_ + +#include <string> + +std::string hello_msg2 (); + +#endif // _HELLO_MSG2_H_ diff --git a/examples/hello_cxxlib/cxxlib/linkme.mk b/examples/hello_cxxlib/cxxlib/linkme.mk new file mode 100644 index 0000000..20864c9 --- /dev/null +++ b/examples/hello_cxxlib/cxxlib/linkme.mk @@ -0,0 +1,5 @@ +PATH.cxxlib := ${.PARSEDIR:tA} + +DPINCDIRS += ${PATH.cxxlib}/include +DPLIBDIRS += ${PATH.cxxlib} +DPLDADD += cxxlib diff --git a/examples/hello_cxxlib/expect.out b/examples/hello_cxxlib/expect.out new file mode 100644 index 0000000..09dc8a7 --- /dev/null +++ b/examples/hello_cxxlib/expect.out @@ -0,0 +1,90 @@ +Hello world 1! +hello world 2! +=========== all ============ +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_cxx_type.err +/objdir/_mkc_cxx_type.res +/objdir/_mkc_funclib_dummy.c +/objdir/_mkc_funclib_dummy.err +/objdir/_mkc_funclib_dummy.res +/objdir/_mkc_prog_cxx.err +/objdir/_mkc_prog_cxx.res +/objdir/cxxapp/Makefile +/objdir/cxxapp/cxxapp +/objdir/cxxapp/cxxapp.cc +/objdir/cxxapp/cxxapp.o +/objdir/cxxlib/Makefile +/objdir/cxxlib/dummy.c +/objdir/cxxlib/dummy.o +/objdir/cxxlib/dummy.os +/objdir/cxxlib/hello_msg1.cpp +/objdir/cxxlib/hello_msg1.o +/objdir/cxxlib/hello_msg1.os +/objdir/cxxlib/hello_msg2.cpp +/objdir/cxxlib/hello_msg2.o +/objdir/cxxlib/hello_msg2.os +/objdir/cxxlib/include/hello_msg.h +/objdir/cxxlib/include/impl/hello_msg1.h +/objdir/cxxlib/include/impl/hello_msg2.h +/objdir/cxxlib/libcxxlib.a +/objdir/cxxlib/libcxxlib.so.1.0.5 +/objdir/cxxlib/linkme.mk +/objdir/expect.out +/objdir/hello_cxxlib.test.out.tmp +/objdir/test.mk +========= install ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/bin/cxxapp +/objdir/prefix/include +/objdir/prefix/include/hello_msg.h +/objdir/prefix/include/impl +/objdir/prefix/include/impl/hello_msg1.h +/objdir/prefix/include/impl/hello_msg2.h +/objdir/prefix/lib +/objdir/prefix/lib/libcxxlib.a +/objdir/prefix/lib/libcxxlib.so +/objdir/prefix/lib/libcxxlib.so.1 +/objdir/prefix/lib/libcxxlib.so.1.0.5 +======== uninstall ========= +========== clean =========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_cxx_type.err +/objdir/_mkc_cxx_type.res +/objdir/_mkc_funclib_dummy.c +/objdir/_mkc_funclib_dummy.err +/objdir/_mkc_funclib_dummy.res +/objdir/_mkc_prog_cxx.err +/objdir/_mkc_prog_cxx.res +/objdir/cxxapp/Makefile +/objdir/cxxapp/cxxapp.cc +/objdir/cxxlib/Makefile +/objdir/cxxlib/dummy.c +/objdir/cxxlib/hello_msg1.cpp +/objdir/cxxlib/hello_msg2.cpp +/objdir/cxxlib/include/hello_msg.h +/objdir/cxxlib/include/impl/hello_msg1.h +/objdir/cxxlib/include/impl/hello_msg2.h +/objdir/cxxlib/linkme.mk +/objdir/expect.out +/objdir/hello_cxxlib.test.out.tmp +/objdir/test.mk +======= distclean ========== +/objdir/Makefile +/objdir/cxxapp/Makefile +/objdir/cxxapp/cxxapp.cc +/objdir/cxxlib/Makefile +/objdir/cxxlib/dummy.c +/objdir/cxxlib/hello_msg1.cpp +/objdir/cxxlib/hello_msg2.cpp +/objdir/cxxlib/include/hello_msg.h +/objdir/cxxlib/include/impl/hello_msg1.h +/objdir/cxxlib/include/impl/hello_msg2.h +/objdir/cxxlib/linkme.mk +/objdir/expect.out +/objdir/hello_cxxlib.test.out.tmp +/objdir/test.mk diff --git a/examples/hello_cxxlib/test.mk b/examples/hello_cxxlib/test.mk new file mode 100644 index 0000000..96b2a2b --- /dev/null +++ b/examples/hello_cxxlib/test.mk @@ -0,0 +1,37 @@ +.PHONY : test_output +test_output: + @set -e; \ + MKCATPAGES=yes; export MKCATPAGES; \ + rm -rf ${.OBJDIR}${PREFIX}; \ + LD_LIBRARY_PATH=${.CURDIR}/cxxlib:$$LD_LIBRARY_PATH; \ + DYLD_LIBRARY_PATH=${.CURDIR}/cxxlib:$$LD_LIBRARY_PATH; \ + LIBRARY_PATH=$$LIBRARY_PATH:$$LD_LIBRARY_PATH; \ + export LD_LIBRARY_PATH DYLD_LIBRARY_PATH LIBRARY_PATH; \ + ${.CURDIR}/cxxapp/cxxapp; \ + \ + echo =========== all ============; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= install ==========; \ + ${MAKE} ${MAKEFLAGS} install -j3 DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type d -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======== uninstall =========; \ + ${MAKE} ${MAKEFLAGS} -j4 uninstall DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ========== clean ===========; \ + ${MAKE} ${MAKEFLAGS} clean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ======= distclean ==========; \ + ${MAKE} ${MAKEFLAGS} distclean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}" + +.include <mkc.minitest.mk> diff --git a/examples/hello_dictd/Makefile b/examples/hello_dictd/Makefile new file mode 100644 index 0000000..5c4c567 --- /dev/null +++ b/examples/hello_dictd/Makefile @@ -0,0 +1,19 @@ +LIBDEPS = libcommon:dict +LIBDEPS += libcommon:dictd +LIBDEPS += libcommon:dictzip +LIBDEPS += libcommon:dictfmt +LIBDEPS += libmaa:dict +LIBDEPS += libmaa:dictd +LIBDEPS += libmaa:dictzip +LIBDEPS += libmaa:dictfmt +LIBDEPS += libdz:dictzip + +INTERNALLIBS += libcommon + +# Subproject "doc" has no dependencies +SUBPRJ += doc +# and is not built by default +SUBPRJ_DFLT = dict dictd dictzip dictfmt + +.include "test.mk" +.include <mkc.subprj.mk> diff --git a/examples/hello_dictd/Makefile.inc b/examples/hello_dictd/Makefile.inc new file mode 100644 index 0000000..82ca367 --- /dev/null +++ b/examples/hello_dictd/Makefile.inc @@ -0,0 +1,11 @@ +# Create Position Independent Executables (PIE) +MKPIE ?= yes + +# Enable SSP +USE_SSP ?= yes + +# Enable RELRO +USE_RELRO ?= yes + +# Fortify sources +USE_FORT ?= yes diff --git a/examples/hello_dictd/dict/Makefile b/examples/hello_dictd/dict/Makefile new file mode 100644 index 0000000..17f232f --- /dev/null +++ b/examples/hello_dictd/dict/Makefile @@ -0,0 +1,6 @@ +PROG = dict +MAN = dict.1 + +WARNS = 4 + +.include <mkc.prog.mk> diff --git a/examples/hello_dictd/dict/dict.1 b/examples/hello_dictd/dict/dict.1 new file mode 100644 index 0000000..deb00c5 --- /dev/null +++ b/examples/hello_dictd/dict/dict.1 @@ -0,0 +1,13 @@ +.\" Written by by Aleksey Cheusov (vle@gmx.net) +.\" ------------------------------------------------------------------ +.TH DICT 1 "May 16, 2010" "" "" +.SH NAME +dict \- dictionary protocol client +.SH SYNOPSIS +.B "dict" +.br +.SH DESCRIPTION +.B dict +is just a fake application +.SH AUTHOR +Aleksey Cheusov <vle@gmx.net> diff --git a/examples/hello_dictd/dict/dict.c b/examples/hello_dictd/dict/dict.c new file mode 100644 index 0000000..554f4da --- /dev/null +++ b/examples/hello_dictd/dict/dict.c @@ -0,0 +1,18 @@ +#include <stdio.h> + +int fake1 (void); +int fake2 (void); +int fake4 (void); +int fake5 (void); +int fake6 (void); + +int main (int argc, char **argv) +{ + printf ("dict: fake1=%d\n", fake1 ()); + printf ("dict: fake2=%d\n", fake2 ()); + printf ("dict: fake4=%d\n", fake4 ()); + printf ("dict: fake5=%d\n", fake5 ()); + printf ("dict: fake6=%d\n", fake6 ()); + + return 0; +} diff --git a/examples/hello_dictd/dictd/Makefile b/examples/hello_dictd/dictd/Makefile new file mode 100644 index 0000000..325df68 --- /dev/null +++ b/examples/hello_dictd/dictd/Makefile @@ -0,0 +1,6 @@ +PROG = dictd +MAN = dictd.8 + +WARNS = 4 + +.include <mkc.prog.mk> diff --git a/examples/hello_dictd/dictd/dictd.8 b/examples/hello_dictd/dictd/dictd.8 new file mode 100644 index 0000000..cc73511 --- /dev/null +++ b/examples/hello_dictd/dictd/dictd.8 @@ -0,0 +1,13 @@ +.\" Written by by Aleksey Cheusov (vle@gmx.net) +.\" ------------------------------------------------------------------ +.TH DICTD 1 "May 16, 2010" "" "" +.SH NAME +dictd \- dictionary protocol server +.SH SYNOPSIS +.B "dictd" +.br +.SH DESCRIPTION +.B dictd +is just a fake application +.SH AUTHOR +Aleksey Cheusov <vle@gmx.net> diff --git a/examples/hello_dictd/dictd/dictd.c b/examples/hello_dictd/dictd/dictd.c new file mode 100644 index 0000000..bcabcc7 --- /dev/null +++ b/examples/hello_dictd/dictd/dictd.c @@ -0,0 +1,18 @@ +#include <stdio.h> + +int fake1 (void); +int fake2 (void); +int fake4 (void); +int fake5 (void); +int fake6 (void); + +int main (int argc, char **argv) +{ + printf ("dictd: fake1=%d\n", fake1 ()); + printf ("dictd: fake2=%d\n", fake2 ()); + printf ("dictd: fake4=%d\n", fake4 ()); + printf ("dictd: fake5=%d\n", fake5 ()); + printf ("dictd: fake6=%d\n", fake6 ()); + + return 0; +} diff --git a/examples/hello_dictd/dictfmt/Makefile b/examples/hello_dictd/dictfmt/Makefile new file mode 100644 index 0000000..c30ed3e --- /dev/null +++ b/examples/hello_dictd/dictfmt/Makefile @@ -0,0 +1,6 @@ +PROG = dictfmt +MAN = dictfmt.1 + +WARNS = 4 + +.include <mkc.prog.mk> diff --git a/examples/hello_dictd/dictfmt/dictfmt.1 b/examples/hello_dictd/dictfmt/dictfmt.1 new file mode 100644 index 0000000..a83c712 --- /dev/null +++ b/examples/hello_dictd/dictfmt/dictfmt.1 @@ -0,0 +1,13 @@ +.\" Written by by Aleksey Cheusov (vle@gmx.net) +.\" ------------------------------------------------------------------ +.TH DICTFMT 1 "May 16, 2010" "" "" +.SH NAME +dictfmt \- dictionary formatting utility +.SH SYNOPSIS +.B "dictfmt" +.br +.SH DESCRIPTION +.B dictfmt +is just a fake application +.SH AUTHOR +Aleksey Cheusov <vle@gmx.net> diff --git a/examples/hello_dictd/dictfmt/dictfmt.c b/examples/hello_dictd/dictfmt/dictfmt.c new file mode 100644 index 0000000..6ef96fe --- /dev/null +++ b/examples/hello_dictd/dictfmt/dictfmt.c @@ -0,0 +1,18 @@ +#include <stdio.h> + +int fake1 (void); +int fake2 (void); +int fake4 (void); +int fake5 (void); +int fake6 (void); + +int main (int argc, char **argv) +{ + printf ("dictfmt: fake1=%d\n", fake1 ()); + printf ("dictfmt: fake2=%d\n", fake2 ()); + printf ("dictfmt: fake4=%d\n", fake4 ()); + printf ("dictfmt: fake5=%d\n", fake5 ()); + printf ("dictfmt: fake6=%d\n", fake6 ()); + + return 0; +} diff --git a/examples/hello_dictd/dictzip/Makefile b/examples/hello_dictd/dictzip/Makefile new file mode 100644 index 0000000..456bb00 --- /dev/null +++ b/examples/hello_dictd/dictzip/Makefile @@ -0,0 +1,6 @@ +PROG = dictzip +MAN = dictzip.1 + +WARNS = 4 + +.include <mkc.prog.mk> diff --git a/examples/hello_dictd/dictzip/dictzip.1 b/examples/hello_dictd/dictzip/dictzip.1 new file mode 100644 index 0000000..8534683 --- /dev/null +++ b/examples/hello_dictd/dictzip/dictzip.1 @@ -0,0 +1,13 @@ +.\" Written by by Aleksey Cheusov (vle@gmx.net) +.\" ------------------------------------------------------------------ +.TH DICTZIP 1 "May 16, 2010" "" "" +.SH NAME +dictd \- dictionary protocol server +.SH SYNOPSIS +.B "dictzip" +.br +.SH DESCRIPTION +.B dictzip +is just a fake application +.SH AUTHOR +Aleksey Cheusov <vle@gmx.net> diff --git a/examples/hello_dictd/dictzip/dictzip.c b/examples/hello_dictd/dictzip/dictzip.c new file mode 100644 index 0000000..09f057f --- /dev/null +++ b/examples/hello_dictd/dictzip/dictzip.c @@ -0,0 +1,20 @@ +#include <stdio.h> + +int fake1 (void); +int fake2 (void); +int fake3 (void); +int fake4 (void); +int fake5 (void); +int fake6 (void); + +int main (int argc, char **argv) +{ + printf ("dictzip: fake1=%d\n", fake1 ()); + printf ("dictzip: fake2=%d\n", fake2 ()); + printf ("dictzip: fake3=%d\n", fake3 ()); + printf ("dictzip: fake4=%d\n", fake4 ()); + printf ("dictzip: fake5=%d\n", fake5 ()); + printf ("dictzip: fake6=%d\n", fake6 ()); + + return 0; +} diff --git a/examples/hello_dictd/doc/Makefile b/examples/hello_dictd/doc/Makefile new file mode 100644 index 0000000..e2fc936 --- /dev/null +++ b/examples/hello_dictd/doc/Makefile @@ -0,0 +1,6 @@ +FILES = doc.txt +FILESDIR = ${DOCDIR} + +DOCDIR ?= ${DATADIR}/doc/dict + +.include <mkc.files.mk> diff --git a/examples/hello_dictd/doc/doc.txt b/examples/hello_dictd/doc/doc.txt new file mode 100644 index 0000000..cd591db --- /dev/null +++ b/examples/hello_dictd/doc/doc.txt @@ -0,0 +1 @@ +bla bla bla diff --git a/examples/hello_dictd/expect.out b/examples/hello_dictd/expect.out new file mode 100644 index 0000000..9c3f7f1 --- /dev/null +++ b/examples/hello_dictd/expect.out @@ -0,0 +1,1003 @@ +dict: fake1=1 +dict: fake2=2 +dict: fake4=4 +dict: fake5=5 +dict: fake6=6 +dictd: fake1=1 +dictd: fake2=2 +dictd: fake4=4 +dictd: fake5=5 +dictd: fake6=6 +dictfmt: fake1=1 +dictfmt: fake2=2 +dictfmt: fake4=4 +dictfmt: fake5=5 +dictfmt: fake6=6 +dictzip: fake1=1 +dictzip: fake2=2 +dictzip: fake3=3 +dictzip: fake4=4 +dictzip: fake5=5 +dictzip: fake6=6 +=========== nm ============ +symbol fake4 +symbol fake5 +symbol fake6 += +symbol fake3 +=========== all ============ +/objdir/Makefile +/objdir/Makefile.inc +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_funclib_deflate.c +/objdir/_mkc_funclib_deflate.err +/objdir/_mkc_funclib_deflate.res +/objdir/_mkc_funclib_deflate_z.c +/objdir/_mkc_funclib_deflate_z.err +/objdir/_mkc_funclib_deflate_z.res +/objdir/_mkc_header_zlib_h.c +/objdir/_mkc_header_zlib_h.err +/objdir/_mkc_header_zlib_h.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/dict/Makefile +/objdir/dict/dict +/objdir/dict/dict.1 +/objdir/dict/dict.c +/objdir/dict/dict.cat1 +/objdir/dict/dict.o +/objdir/dictd/Makefile +/objdir/dictd/dictd +/objdir/dictd/dictd.8 +/objdir/dictd/dictd.c +/objdir/dictd/dictd.cat8 +/objdir/dictd/dictd.o +/objdir/dictfmt/Makefile +/objdir/dictfmt/dictfmt +/objdir/dictfmt/dictfmt.1 +/objdir/dictfmt/dictfmt.c +/objdir/dictfmt/dictfmt.cat1 +/objdir/dictfmt/dictfmt.o +/objdir/dictzip/Makefile +/objdir/dictzip/dictzip +/objdir/dictzip/dictzip.1 +/objdir/dictzip/dictzip.c +/objdir/dictzip/dictzip.cat1 +/objdir/dictzip/dictzip.o +/objdir/doc/Makefile +/objdir/doc/doc.txt +/objdir/expect.out +/objdir/hello_dictd.test.out.tmp +/objdir/libcommon/Makefile +/objdir/libcommon/iswalnum.c +/objdir/libcommon/iswalnum.o +/objdir/libcommon/iswalnum.os +/objdir/libcommon/libcommon.a +/objdir/libcommon/libcommon_pic.a +/objdir/libcommon/str.c +/objdir/libcommon/str.o +/objdir/libcommon/str.os +/objdir/libdz/Makefile +/objdir/libdz/dz.c +/objdir/libdz/dz.o +/objdir/libdz/dz.os +/objdir/libdz/export.sym +/objdir/libdz/libdz.a +/objdir/libdz/libdz.so +/objdir/libdz/libdz.so.1 +/objdir/libdz/libdz.so.1.0 +/objdir/libmaa/Makefile +/objdir/libmaa/export.sym +/objdir/libmaa/libmaa.a +/objdir/libmaa/libmaa.so +/objdir/libmaa/libmaa.so.1 +/objdir/libmaa/libmaa.so.1.2.0 +/objdir/libmaa/log.c +/objdir/libmaa/log.o +/objdir/libmaa/log.os +/objdir/libmaa/prime.c +/objdir/libmaa/prime.o +/objdir/libmaa/prime.os +/objdir/libmaa/set.c +/objdir/libmaa/set.o +/objdir/libmaa/set.os +/objdir/test.mk +========= INTERNALLIBS ========== +installdirs ===> examples/hello_dictd/libmaa +installdirs ===> examples/hello_dictd/dict +installdirs ===> examples/hello_dictd/dictd +installdirs ===> examples/hello_dictd/libdz +installdirs ===> examples/hello_dictd/dictzip +installdirs ===> examples/hello_dictd/dictfmt +install ===> examples/hello_dictd/libmaa +install ===> examples/hello_dictd/dict +install ===> examples/hello_dictd/dictd +install ===> examples/hello_dictd/libdz +install ===> examples/hello_dictd/dictzip +install ===> examples/hello_dictd/dictfmt +uninstall ===> examples/hello_dictd/libmaa +uninstall ===> examples/hello_dictd/dict +uninstall ===> examples/hello_dictd/dictd +uninstall ===> examples/hello_dictd/libdz +uninstall ===> examples/hello_dictd/dictzip +uninstall ===> examples/hello_dictd/dictfmt +========= installdirs ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/lib +/objdir/prefix/man +/objdir/prefix/man/cat1 +/objdir/prefix/man/cat8 +/objdir/prefix/man/man1 +/objdir/prefix/man/man8 +========= install ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/bin/dict +/objdir/prefix/bin/dictd +/objdir/prefix/bin/dictfmt +/objdir/prefix/bin/dictzip +/objdir/prefix/lib +/objdir/prefix/lib/libdz.a +/objdir/prefix/lib/libdz.so +/objdir/prefix/lib/libdz.so.1 +/objdir/prefix/lib/libdz.so.1.0 +/objdir/prefix/lib/libmaa.a +/objdir/prefix/lib/libmaa.so +/objdir/prefix/lib/libmaa.so.1 +/objdir/prefix/lib/libmaa.so.1.2.0 +/objdir/prefix/man +/objdir/prefix/man/cat1 +/objdir/prefix/man/cat1/dict.0 +/objdir/prefix/man/cat1/dictfmt.0 +/objdir/prefix/man/cat1/dictzip.0 +/objdir/prefix/man/cat8 +/objdir/prefix/man/cat8/dictd.0 +/objdir/prefix/man/man1 +/objdir/prefix/man/man1/dict.1 +/objdir/prefix/man/man1/dictfmt.1 +/objdir/prefix/man/man1/dictzip.1 +/objdir/prefix/man/man8 +/objdir/prefix/man/man8/dictd.8 +======== uninstall ========= +========== nodeps-cleandir-dictfmt subdir-clean-dictzip =========== +/objdir/Makefile +/objdir/Makefile.inc +/objdir/dict/Makefile +/objdir/dict/dict +/objdir/dict/dict.1 +/objdir/dict/dict.c +/objdir/dict/dict.cat1 +/objdir/dict/dict.o +/objdir/dictd/Makefile +/objdir/dictd/dictd +/objdir/dictd/dictd.8 +/objdir/dictd/dictd.c +/objdir/dictd/dictd.cat8 +/objdir/dictd/dictd.o +/objdir/dictfmt/Makefile +/objdir/dictfmt/dictfmt.1 +/objdir/dictfmt/dictfmt.c +/objdir/dictzip/Makefile +/objdir/dictzip/dictzip.1 +/objdir/dictzip/dictzip.c +/objdir/doc/Makefile +/objdir/doc/doc.txt +/objdir/expect.out +/objdir/hello_dictd.test.out.tmp +/objdir/libcommon/Makefile +/objdir/libcommon/iswalnum.c +/objdir/libcommon/iswalnum.o +/objdir/libcommon/iswalnum.os +/objdir/libcommon/libcommon.a +/objdir/libcommon/libcommon_pic.a +/objdir/libcommon/str.c +/objdir/libcommon/str.o +/objdir/libcommon/str.os +/objdir/libdz/Makefile +/objdir/libdz/dz.c +/objdir/libdz/dz.o +/objdir/libdz/dz.os +/objdir/libdz/export.sym +/objdir/libdz/libdz.a +/objdir/libdz/libdz.so +/objdir/libdz/libdz.so.1 +/objdir/libdz/libdz.so.1.0 +/objdir/libmaa/Makefile +/objdir/libmaa/export.sym +/objdir/libmaa/libmaa.a +/objdir/libmaa/libmaa.so +/objdir/libmaa/libmaa.so.1 +/objdir/libmaa/libmaa.so.1.2.0 +/objdir/libmaa/log.c +/objdir/libmaa/log.o +/objdir/libmaa/log.os +/objdir/libmaa/prime.c +/objdir/libmaa/prime.o +/objdir/libmaa/prime.os +/objdir/libmaa/set.c +/objdir/libmaa/set.o +/objdir/libmaa/set.os +/objdir/test.mk +========== clean =========== +/objdir/Makefile +/objdir/Makefile.inc +/objdir/dict/Makefile +/objdir/dict/dict.1 +/objdir/dict/dict.c +/objdir/dictd/Makefile +/objdir/dictd/dictd.8 +/objdir/dictd/dictd.c +/objdir/dictfmt/Makefile +/objdir/dictfmt/dictfmt.1 +/objdir/dictfmt/dictfmt.c +/objdir/dictzip/Makefile +/objdir/dictzip/dictzip.1 +/objdir/dictzip/dictzip.c +/objdir/doc/Makefile +/objdir/doc/doc.txt +/objdir/expect.out +/objdir/hello_dictd.test.out.tmp +/objdir/libcommon/Makefile +/objdir/libcommon/iswalnum.c +/objdir/libcommon/str.c +/objdir/libdz/Makefile +/objdir/libdz/dz.c +/objdir/libdz/export.sym +/objdir/libmaa/Makefile +/objdir/libmaa/export.sym +/objdir/libmaa/log.c +/objdir/libmaa/prime.c +/objdir/libmaa/set.c +/objdir/test.mk +======= distclean ========== +/objdir/Makefile +/objdir/Makefile.inc +/objdir/dict/Makefile +/objdir/dict/dict.1 +/objdir/dict/dict.c +/objdir/dictd/Makefile +/objdir/dictd/dictd.8 +/objdir/dictd/dictd.c +/objdir/dictfmt/Makefile +/objdir/dictfmt/dictfmt.1 +/objdir/dictfmt/dictfmt.c +/objdir/dictzip/Makefile +/objdir/dictzip/dictzip.1 +/objdir/dictzip/dictzip.c +/objdir/doc/Makefile +/objdir/doc/doc.txt +/objdir/expect.out +/objdir/hello_dictd.test.out.tmp +/objdir/libcommon/Makefile +/objdir/libcommon/iswalnum.c +/objdir/libcommon/str.c +/objdir/libdz/Makefile +/objdir/libdz/dz.c +/objdir/libdz/export.sym +/objdir/libmaa/Makefile +/objdir/libmaa/export.sym +/objdir/libmaa/log.c +/objdir/libmaa/prime.c +/objdir/libmaa/set.c +/objdir/test.mk +=========== MKOBJDIRS=auto ============ +/objdir +/objdir/Makefile +/objdir/Makefile.inc +/objdir/dict +/objdir/dict/Makefile +/objdir/dict/dict.1 +/objdir/dict/dict.c +/objdir/dictd +/objdir/dictd/Makefile +/objdir/dictd/dictd.8 +/objdir/dictd/dictd.c +/objdir/dictfmt +/objdir/dictfmt/Makefile +/objdir/dictfmt/dictfmt.1 +/objdir/dictfmt/dictfmt.c +/objdir/dictzip +/objdir/dictzip/Makefile +/objdir/dictzip/dictzip.1 +/objdir/dictzip/dictzip.c +/objdir/doc +/objdir/doc/Makefile +/objdir/doc/doc.txt +/objdir/expect.out +/objdir/hello_dictd.test.out.tmp +/objdir/libcommon +/objdir/libcommon/Makefile +/objdir/libcommon/iswalnum.c +/objdir/libcommon/str.c +/objdir/libdz +/objdir/libdz/Makefile +/objdir/libdz/dz.c +/objdir/libdz/export.sym +/objdir/libmaa +/objdir/libmaa/Makefile +/objdir/libmaa/export.sym +/objdir/libmaa/log.c +/objdir/libmaa/prime.c +/objdir/libmaa/set.c +/objdir/test.mk +=== +/objdir/obj1/objdir +/objdir/obj1/objdir/dict +/objdir/obj1/objdir/dictd +/objdir/obj1/objdir/dictfmt +/objdir/obj1/objdir/dictzip +/objdir/obj1/objdir/libcommon +/objdir/obj1/objdir/libdz +/objdir/obj1/objdir/libmaa +=========== MKOBJDIRS=yes ============ +obj1 does not exist +=== +/objdir +/objdir/Makefile +/objdir/Makefile.inc +/objdir/dict +/objdir/dict/Makefile +/objdir/dict/dict.1 +/objdir/dict/dict.c +/objdir/dictd +/objdir/dictd/Makefile +/objdir/dictd/dictd.8 +/objdir/dictd/dictd.c +/objdir/dictfmt +/objdir/dictfmt/Makefile +/objdir/dictfmt/dictfmt.1 +/objdir/dictfmt/dictfmt.c +/objdir/dictzip +/objdir/dictzip/Makefile +/objdir/dictzip/dictzip.1 +/objdir/dictzip/dictzip.c +/objdir/doc +/objdir/doc/Makefile +/objdir/doc/doc.txt +/objdir/expect.out +/objdir/hello_dictd.test.out.tmp +/objdir/libcommon +/objdir/libcommon/Makefile +/objdir/libcommon/iswalnum.c +/objdir/libcommon/str.c +/objdir/libdz +/objdir/libdz/Makefile +/objdir/libdz/dz.c +/objdir/libdz/export.sym +/objdir/libmaa +/objdir/libmaa/Makefile +/objdir/libmaa/export.sym +/objdir/libmaa/log.c +/objdir/libmaa/prime.c +/objdir/libmaa/set.c +/objdir/test.mk +=== +/objdir/obj2/objdir +/objdir/obj2/objdir/dict +/objdir/obj2/objdir/dictd +/objdir/obj2/objdir/dictfmt +/objdir/obj2/objdir/dictzip +/objdir/obj2/objdir/libcommon +/objdir/obj2/objdir/libdz +/objdir/obj2/objdir/libmaa +/objdir/obj3 +=========== MKOBJDIRS=no ============ +======= errorcheck ========== +/objdir/Makefile +/objdir/Makefile.inc +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_funclib_deflate.c +/objdir/_mkc_funclib_deflate.err +/objdir/_mkc_funclib_deflate.res +/objdir/_mkc_funclib_deflate_z.c +/objdir/_mkc_funclib_deflate_z.err +/objdir/_mkc_funclib_deflate_z.res +/objdir/_mkc_header_zlib_h.c +/objdir/_mkc_header_zlib_h.err +/objdir/_mkc_header_zlib_h.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/dict/Makefile +/objdir/dict/dict.1 +/objdir/dict/dict.c +/objdir/dictd/Makefile +/objdir/dictd/dictd.8 +/objdir/dictd/dictd.c +/objdir/dictfmt/Makefile +/objdir/dictfmt/dictfmt.1 +/objdir/dictfmt/dictfmt.c +/objdir/dictzip/Makefile +/objdir/dictzip/dictzip.1 +/objdir/dictzip/dictzip.c +/objdir/doc/Makefile +/objdir/doc/doc.txt +/objdir/expect.out +/objdir/hello_dictd.test.out.tmp +/objdir/libcommon/Makefile +/objdir/libcommon/iswalnum.c +/objdir/libcommon/str.c +/objdir/libdz/Makefile +/objdir/libdz/dz.c +/objdir/libdz/export.sym +/objdir/libmaa/Makefile +/objdir/libmaa/export.sym +/objdir/libmaa/log.c +/objdir/libmaa/prime.c +/objdir/libmaa/set.c +/objdir/test.mk +======= all-dict ========== +/objdir/Makefile +/objdir/Makefile.inc +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/dict/Makefile +/objdir/dict/dict +/objdir/dict/dict.1 +/objdir/dict/dict.c +/objdir/dict/dict.cat1 +/objdir/dict/dict.o +/objdir/dictd/Makefile +/objdir/dictd/dictd.8 +/objdir/dictd/dictd.c +/objdir/dictfmt/Makefile +/objdir/dictfmt/dictfmt.1 +/objdir/dictfmt/dictfmt.c +/objdir/dictzip/Makefile +/objdir/dictzip/dictzip.1 +/objdir/dictzip/dictzip.c +/objdir/doc/Makefile +/objdir/doc/doc.txt +/objdir/expect.out +/objdir/hello_dictd.test.out.tmp +/objdir/libcommon/Makefile +/objdir/libcommon/iswalnum.c +/objdir/libcommon/iswalnum.o +/objdir/libcommon/iswalnum.os +/objdir/libcommon/libcommon.a +/objdir/libcommon/libcommon_pic.a +/objdir/libcommon/str.c +/objdir/libcommon/str.o +/objdir/libcommon/str.os +/objdir/libdz/Makefile +/objdir/libdz/dz.c +/objdir/libdz/export.sym +/objdir/libmaa/Makefile +/objdir/libmaa/export.sym +/objdir/libmaa/libmaa.a +/objdir/libmaa/libmaa.so +/objdir/libmaa/libmaa.so.1 +/objdir/libmaa/libmaa.so.1.2.0 +/objdir/libmaa/log.c +/objdir/libmaa/log.o +/objdir/libmaa/log.os +/objdir/libmaa/prime.c +/objdir/libmaa/prime.o +/objdir/libmaa/prime.os +/objdir/libmaa/set.c +/objdir/libmaa/set.o +/objdir/libmaa/set.os +/objdir/test.mk +======= -C dict all ========== +/objdir/Makefile +/objdir/Makefile.inc +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/dict/Makefile +/objdir/dict/dict +/objdir/dict/dict.1 +/objdir/dict/dict.c +/objdir/dict/dict.cat1 +/objdir/dict/dict.o +/objdir/dictd/Makefile +/objdir/dictd/dictd.8 +/objdir/dictd/dictd.c +/objdir/dictfmt/Makefile +/objdir/dictfmt/dictfmt.1 +/objdir/dictfmt/dictfmt.c +/objdir/dictzip/Makefile +/objdir/dictzip/dictzip.1 +/objdir/dictzip/dictzip.c +/objdir/doc/Makefile +/objdir/doc/doc.txt +/objdir/expect.out +/objdir/hello_dictd.test.out.tmp +/objdir/libcommon/Makefile +/objdir/libcommon/iswalnum.c +/objdir/libcommon/iswalnum.o +/objdir/libcommon/iswalnum.os +/objdir/libcommon/libcommon.a +/objdir/libcommon/libcommon_pic.a +/objdir/libcommon/str.c +/objdir/libcommon/str.o +/objdir/libcommon/str.os +/objdir/libdz/Makefile +/objdir/libdz/dz.c +/objdir/libdz/export.sym +/objdir/libmaa/Makefile +/objdir/libmaa/export.sym +/objdir/libmaa/libmaa.a +/objdir/libmaa/libmaa.so +/objdir/libmaa/libmaa.so.1 +/objdir/libmaa/libmaa.so.1.2.0 +/objdir/libmaa/log.c +/objdir/libmaa/log.o +/objdir/libmaa/log.os +/objdir/libmaa/prime.c +/objdir/libmaa/prime.o +/objdir/libmaa/prime.os +/objdir/libmaa/set.c +/objdir/libmaa/set.o +/objdir/libmaa/set.os +/objdir/test.mk +========= installdirs-dict ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/lib +/objdir/prefix/man +/objdir/prefix/man/cat1 +/objdir/prefix/man/man1 +========= install-dict ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/bin/dict +/objdir/prefix/lib +/objdir/prefix/lib/libmaa.a +/objdir/prefix/lib/libmaa.so +/objdir/prefix/lib/libmaa.so.1 +/objdir/prefix/lib/libmaa.so.1.2.0 +/objdir/prefix/man +/objdir/prefix/man/cat1 +/objdir/prefix/man/cat1/dict.0 +/objdir/prefix/man/man1 +/objdir/prefix/man/man1/dict.1 +========= -Cdict install ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/bin/dict +/objdir/prefix/lib +/objdir/prefix/lib/libmaa.a +/objdir/prefix/lib/libmaa.so +/objdir/prefix/lib/libmaa.so.1 +/objdir/prefix/lib/libmaa.so.1.2.0 +/objdir/prefix/man +/objdir/prefix/man/cat1 +/objdir/prefix/man/cat1/dict.0 +/objdir/prefix/man/man1 +/objdir/prefix/man/man1/dict.1 +======= uninstall-dict ========== +========== -C dict clean =========== +/objdir/Makefile +/objdir/Makefile.inc +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/dict/Makefile +/objdir/dict/dict.1 +/objdir/dict/dict.c +/objdir/dictd/Makefile +/objdir/dictd/dictd.8 +/objdir/dictd/dictd.c +/objdir/dictfmt/Makefile +/objdir/dictfmt/dictfmt.1 +/objdir/dictfmt/dictfmt.c +/objdir/dictzip/Makefile +/objdir/dictzip/dictzip.1 +/objdir/dictzip/dictzip.c +/objdir/doc/Makefile +/objdir/doc/doc.txt +/objdir/expect.out +/objdir/hello_dictd.test.out.tmp +/objdir/libcommon/Makefile +/objdir/libcommon/iswalnum.c +/objdir/libcommon/str.c +/objdir/libdz/Makefile +/objdir/libdz/dz.c +/objdir/libdz/export.sym +/objdir/libmaa/Makefile +/objdir/libmaa/export.sym +/objdir/libmaa/log.c +/objdir/libmaa/prime.c +/objdir/libmaa/set.c +/objdir/test.mk +======= cleandir-dict ========== +/objdir/Makefile +/objdir/Makefile.inc +/objdir/dict/Makefile +/objdir/dict/dict.1 +/objdir/dict/dict.c +/objdir/dictd/Makefile +/objdir/dictd/dictd.8 +/objdir/dictd/dictd.c +/objdir/dictfmt/Makefile +/objdir/dictfmt/dictfmt.1 +/objdir/dictfmt/dictfmt.c +/objdir/dictzip/Makefile +/objdir/dictzip/dictzip.1 +/objdir/dictzip/dictzip.c +/objdir/doc/Makefile +/objdir/doc/doc.txt +/objdir/expect.out +/objdir/hello_dictd.test.out.tmp +/objdir/libcommon/Makefile +/objdir/libcommon/iswalnum.c +/objdir/libcommon/str.c +/objdir/libdz/Makefile +/objdir/libdz/dz.c +/objdir/libdz/export.sym +/objdir/libmaa/Makefile +/objdir/libmaa/export.sym +/objdir/libmaa/log.c +/objdir/libmaa/prime.c +/objdir/libmaa/set.c +/objdir/test.mk +========= installdirs-doc ========== +/objdir/prefix +/objdir/prefix/share +/objdir/prefix/share/doc +/objdir/prefix/share/doc/dict +========= install-doc ========== +/objdir/prefix +/objdir/prefix/share +/objdir/prefix/share/doc +/objdir/prefix/share/doc/dict +/objdir/prefix/share/doc/dict/doc.txt +======= uninstall-doc ========== +=========== all with NOSUBDIR ============ +/objdir/Makefile +/objdir/Makefile.inc +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/dict/Makefile +/objdir/dict/dict +/objdir/dict/dict.1 +/objdir/dict/dict.c +/objdir/dict/dict.cat1 +/objdir/dict/dict.o +/objdir/dictd/Makefile +/objdir/dictd/dictd +/objdir/dictd/dictd.8 +/objdir/dictd/dictd.c +/objdir/dictd/dictd.cat8 +/objdir/dictd/dictd.o +/objdir/dictfmt/Makefile +/objdir/dictfmt/dictfmt.1 +/objdir/dictfmt/dictfmt.c +/objdir/dictzip/Makefile +/objdir/dictzip/dictzip.1 +/objdir/dictzip/dictzip.c +/objdir/doc/Makefile +/objdir/doc/doc.txt +/objdir/expect.out +/objdir/hello_dictd.test.out.tmp +/objdir/libcommon/Makefile +/objdir/libcommon/iswalnum.c +/objdir/libcommon/iswalnum.o +/objdir/libcommon/iswalnum.os +/objdir/libcommon/libcommon.a +/objdir/libcommon/libcommon_pic.a +/objdir/libcommon/str.c +/objdir/libcommon/str.o +/objdir/libcommon/str.os +/objdir/libdz/Makefile +/objdir/libdz/dz.c +/objdir/libdz/export.sym +/objdir/libmaa/Makefile +/objdir/libmaa/export.sym +/objdir/libmaa/libmaa.a +/objdir/libmaa/libmaa.so +/objdir/libmaa/libmaa.so.1 +/objdir/libmaa/libmaa.so.1.2.0 +/objdir/libmaa/log.c +/objdir/libmaa/log.o +/objdir/libmaa/log.os +/objdir/libmaa/prime.c +/objdir/libmaa/prime.o +/objdir/libmaa/prime.os +/objdir/libmaa/set.c +/objdir/libmaa/set.o +/objdir/libmaa/set.os +/objdir/test.mk +=========== all with MKPIE=yes ============ +/objdir/Makefile +/objdir/Makefile.inc +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_funclib_deflate.c +/objdir/_mkc_funclib_deflate.err +/objdir/_mkc_funclib_deflate.res +/objdir/_mkc_funclib_deflate_z.c +/objdir/_mkc_funclib_deflate_z.err +/objdir/_mkc_funclib_deflate_z.res +/objdir/_mkc_header_zlib_h.c +/objdir/_mkc_header_zlib_h.err +/objdir/_mkc_header_zlib_h.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/dict/Makefile +/objdir/dict/dict +/objdir/dict/dict.1 +/objdir/dict/dict.c +/objdir/dict/dict.cat1 +/objdir/dict/dict.o +/objdir/dictd/Makefile +/objdir/dictd/dictd +/objdir/dictd/dictd.8 +/objdir/dictd/dictd.c +/objdir/dictd/dictd.cat8 +/objdir/dictd/dictd.o +/objdir/dictfmt/Makefile +/objdir/dictfmt/dictfmt +/objdir/dictfmt/dictfmt.1 +/objdir/dictfmt/dictfmt.c +/objdir/dictfmt/dictfmt.cat1 +/objdir/dictfmt/dictfmt.o +/objdir/dictzip/Makefile +/objdir/dictzip/dictzip +/objdir/dictzip/dictzip.1 +/objdir/dictzip/dictzip.c +/objdir/dictzip/dictzip.cat1 +/objdir/dictzip/dictzip.o +/objdir/doc/Makefile +/objdir/doc/doc.txt +/objdir/expect.out +/objdir/hello_dictd.test.out.tmp +/objdir/libcommon/Makefile +/objdir/libcommon/iswalnum.c +/objdir/libcommon/iswalnum.o +/objdir/libcommon/iswalnum.os +/objdir/libcommon/libcommon.a +/objdir/libcommon/libcommon_pic.a +/objdir/libcommon/str.c +/objdir/libcommon/str.o +/objdir/libcommon/str.os +/objdir/libdz/Makefile +/objdir/libdz/dz.c +/objdir/libdz/dz.o +/objdir/libdz/dz.os +/objdir/libdz/export.sym +/objdir/libdz/libdz.a +/objdir/libdz/libdz.so +/objdir/libdz/libdz.so.1 +/objdir/libdz/libdz.so.1.0 +/objdir/libmaa/Makefile +/objdir/libmaa/export.sym +/objdir/libmaa/libmaa.a +/objdir/libmaa/libmaa.so +/objdir/libmaa/libmaa.so.1 +/objdir/libmaa/libmaa.so.1.2.0 +/objdir/libmaa/log.c +/objdir/libmaa/log.o +/objdir/libmaa/log.os +/objdir/libmaa/prime.c +/objdir/libmaa/prime.o +/objdir/libmaa/prime.os +/objdir/libmaa/set.c +/objdir/libmaa/set.o +/objdir/libmaa/set.os +/objdir/test.mk +=========== all with STATICLIBS=everything... ============ +/objdir/Makefile +/objdir/Makefile.inc +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_funclib_deflate.c +/objdir/_mkc_funclib_deflate.err +/objdir/_mkc_funclib_deflate.res +/objdir/_mkc_funclib_deflate_z.c +/objdir/_mkc_funclib_deflate_z.err +/objdir/_mkc_funclib_deflate_z.res +/objdir/_mkc_header_zlib_h.c +/objdir/_mkc_header_zlib_h.err +/objdir/_mkc_header_zlib_h.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/dict/Makefile +/objdir/dict/dict +/objdir/dict/dict.1 +/objdir/dict/dict.c +/objdir/dict/dict.cat1 +/objdir/dict/dict.o +/objdir/dictd/Makefile +/objdir/dictd/dictd +/objdir/dictd/dictd.8 +/objdir/dictd/dictd.c +/objdir/dictd/dictd.cat8 +/objdir/dictd/dictd.o +/objdir/dictfmt/Makefile +/objdir/dictfmt/dictfmt +/objdir/dictfmt/dictfmt.1 +/objdir/dictfmt/dictfmt.c +/objdir/dictfmt/dictfmt.cat1 +/objdir/dictfmt/dictfmt.o +/objdir/dictzip/Makefile +/objdir/dictzip/dictzip +/objdir/dictzip/dictzip.1 +/objdir/dictzip/dictzip.c +/objdir/dictzip/dictzip.cat1 +/objdir/dictzip/dictzip.o +/objdir/doc/Makefile +/objdir/doc/doc.txt +/objdir/expect.out +/objdir/hello_dictd.test.out.tmp +/objdir/libcommon/Makefile +/objdir/libcommon/iswalnum.c +/objdir/libcommon/iswalnum.o +/objdir/libcommon/iswalnum.os +/objdir/libcommon/libcommon.a +/objdir/libcommon/libcommon_pic.a +/objdir/libcommon/str.c +/objdir/libcommon/str.o +/objdir/libcommon/str.os +/objdir/libdz/Makefile +/objdir/libdz/dz.c +/objdir/libdz/dz.o +/objdir/libdz/dz.os +/objdir/libdz/export.sym +/objdir/libdz/libdz.a +/objdir/libdz/libdz_pic.a +/objdir/libmaa/Makefile +/objdir/libmaa/export.sym +/objdir/libmaa/libmaa.a +/objdir/libmaa/libmaa_pic.a +/objdir/libmaa/log.c +/objdir/libmaa/log.o +/objdir/libmaa/log.os +/objdir/libmaa/prime.c +/objdir/libmaa/prime.o +/objdir/libmaa/prime.os +/objdir/libmaa/set.c +/objdir/libmaa/set.o +/objdir/libmaa/set.os +/objdir/test.mk +=========== print_deps ============ +all-libcommon all-dict +all-libcommon all-dictd +all-libcommon all-dictzip +all-libcommon all-dictfmt +all-libmaa all-dict +all-libmaa all-dictd +all-libmaa all-dictzip +all-libmaa all-dictfmt +all-libdz all-dictzip +test-libcommon test-dict +test-libcommon test-dictd +test-libcommon test-dictzip +test-libcommon test-dictfmt +test-libmaa test-dict +test-libmaa test-dictd +test-libmaa test-dictzip +test-libmaa test-dictfmt +test-libdz test-dictzip +all-dict dict +all-dictd dictd +all-dictfmt dictfmt +all-dictzip dictzip +all-doc doc +all-libcommon libcommon +all-libdz libdz +all-libmaa libmaa +all-dict all +all-dictd all +all-dictzip all +all-dictfmt all +all-dict +all-dictd +all-dictfmt +all-dictzip +all-doc +all-libcommon +all-libdz +all-libmaa +test-dict +test-dictd +test-dictfmt +test-dictzip +test-doc +test-libcommon +test-libdz +test-libmaa +all +test +===== +all-libcommon all-dict +all-libcommon all-dictd +all-libmaa all-dict +all-libmaa all-dictd +test-libcommon test-dict +test-libcommon test-dictd +test-libmaa test-dict +test-libmaa test-dictd +all-dict dict +all-dictd dictd +all-doc doc +all-libcommon libcommon +all-libdz libdz +all-libmaa libmaa +all-dict all +all-dictd all +all-dict +all-dictd +all-doc +all-libcommon +all-libdz +all-libmaa +test-dict +test-dictd +test-doc +test-libcommon +test-libdz +test-libmaa +all +test +===== +all-libcommon all-dict +all-libcommon all-dictd +all-libcommon all-dictzip +all-libcommon all-dictfmt +all-libmaa all-dict +all-libmaa all-dictd +all-libmaa all-dictzip +all-libmaa all-dictfmt +all-libdz all-dictzip +test-libcommon test-dict +test-libcommon test-dictd +test-libcommon test-dictzip +test-libcommon test-dictfmt +test-libmaa test-dict +test-libmaa test-dictd +test-libmaa test-dictzip +test-libmaa test-dictfmt +test-libdz test-dictzip +all-dict dict +all-dictd dictd +all-dictfmt dictfmt +all-dictzip dictzip +all-doc doc +all-libcommon libcommon +all-libdz libdz +all-libmaa libmaa +all-dict all +all-dictd all +all-dictzip all +all-dictfmt all +test2-dict test2 +test2-dictd test2 +test2-dictzip test2 +test2-dictfmt test2 +all-dict +all-dictd +all-dictfmt +all-dictzip +all-doc +all-libcommon +all-libdz +all-libmaa +test-dict +test-dictd +test-dictfmt +test-dictzip +test-doc +test-libcommon +test-libdz +test-libmaa +test2-dict +test2-dictd +test2-dictfmt +test2-dictzip +test2-doc +test2-libcommon +test2-libdz +test2-libmaa +all +test +test2 diff --git a/examples/hello_dictd/libcommon/Makefile b/examples/hello_dictd/libcommon/Makefile new file mode 100644 index 0000000..c3c5253 --- /dev/null +++ b/examples/hello_dictd/libcommon/Makefile @@ -0,0 +1,8 @@ +# internal static library that implements functions common for dict, dictd etc. + +LIB = common +SRCS = str.c iswalnum.c # and others + +WARNS = 4 + +.include <mkc.lib.mk> diff --git a/examples/hello_dictd/libcommon/iswalnum.c b/examples/hello_dictd/libcommon/iswalnum.c new file mode 100644 index 0000000..7d8962a --- /dev/null +++ b/examples/hello_dictd/libcommon/iswalnum.c @@ -0,0 +1,6 @@ +int fake2 (void); + +int fake2 (void) +{ + return 2; +} diff --git a/examples/hello_dictd/libcommon/str.c b/examples/hello_dictd/libcommon/str.c new file mode 100644 index 0000000..34972d1 --- /dev/null +++ b/examples/hello_dictd/libcommon/str.c @@ -0,0 +1,6 @@ +int fake1 (void); + +int fake1 (void) +{ + return 1; +} diff --git a/examples/hello_dictd/libdz/Makefile b/examples/hello_dictd/libdz/Makefile new file mode 100644 index 0000000..0b462f2 --- /dev/null +++ b/examples/hello_dictd/libdz/Makefile @@ -0,0 +1,15 @@ +# library that implements compression routines for dict.dz format + +LIB = dz +SRCS = dz.c + +WARNS = 4 + +EXPORT_SYMBOLS = export.sym + +MKC_REQUIRE_HEADERS = zlib.h +MKC_REQUIRE_FUNCLIBS = deflate:z + +SHLIB_MAJOR = 1 + +.include <mkc.lib.mk> diff --git a/examples/hello_dictd/libdz/dz.c b/examples/hello_dictd/libdz/dz.c new file mode 100644 index 0000000..81442b5 --- /dev/null +++ b/examples/hello_dictd/libdz/dz.c @@ -0,0 +1,14 @@ +int fake3 (void); + +int fake3 (void) +{ + return 3; +} + +/* fake22 must not be exported */ +int fake22 (void); + +int fake22 (void) +{ + return 22; +} diff --git a/examples/hello_dictd/libdz/export.sym b/examples/hello_dictd/libdz/export.sym new file mode 100644 index 0000000..d084e3a --- /dev/null +++ b/examples/hello_dictd/libdz/export.sym @@ -0,0 +1 @@ +fake3 diff --git a/examples/hello_dictd/libmaa/Makefile b/examples/hello_dictd/libmaa/Makefile new file mode 100644 index 0000000..68753e2 --- /dev/null +++ b/examples/hello_dictd/libmaa/Makefile @@ -0,0 +1,14 @@ +# libmaa library + +LIB = maa +SRCS = set.c prime.c log.c # etc. + +EXPORT_SYMBOLS = export.sym + +SHLIB_MAJOR = 1 +SHLIB_MINOR = 2 +SHLIB_TEENY = 0 + +WARNS ?= 4 + +.include <mkc.lib.mk> diff --git a/examples/hello_dictd/libmaa/export.sym b/examples/hello_dictd/libmaa/export.sym new file mode 100644 index 0000000..ee9bd7c --- /dev/null +++ b/examples/hello_dictd/libmaa/export.sym @@ -0,0 +1,3 @@ +fake4 +fake5 +fake6 diff --git a/examples/hello_dictd/libmaa/log.c b/examples/hello_dictd/libmaa/log.c new file mode 100644 index 0000000..8cd210b --- /dev/null +++ b/examples/hello_dictd/libmaa/log.c @@ -0,0 +1,14 @@ +int fake4 (void); + +int fake4 (void) +{ + return 4; +} + +/* fake must not be exported */ +int fake2 (void); + +int fake2 (void) +{ + return 2; +} diff --git a/examples/hello_dictd/libmaa/prime.c b/examples/hello_dictd/libmaa/prime.c new file mode 100644 index 0000000..c7cc6eb --- /dev/null +++ b/examples/hello_dictd/libmaa/prime.c @@ -0,0 +1,6 @@ +int fake5 (void); + +int fake5 (void) +{ + return 5; +} diff --git a/examples/hello_dictd/libmaa/set.c b/examples/hello_dictd/libmaa/set.c new file mode 100644 index 0000000..e374c6c --- /dev/null +++ b/examples/hello_dictd/libmaa/set.c @@ -0,0 +1,6 @@ +int fake6 (void); + +int fake6 (void) +{ + return 6; +} diff --git a/examples/hello_dictd/test.mk b/examples/hello_dictd/test.mk new file mode 100644 index 0000000..7081e20 --- /dev/null +++ b/examples/hello_dictd/test.mk @@ -0,0 +1,199 @@ +next_level != expr ${.MAKE.LEVEL} + 1 + +run_nm := env NM=${NM:Q} OPSYS=${OPSTS:Q} mkc_test_nm + +.PHONY : test_output +test_output : + @set -e; \ + MKCATPAGES=yes; export MKCATPAGES; \ + SRCTOP=`pwd`; export SRCTOP; \ + \ + rm -rf ${.OBJDIR}${PREFIX}; \ + LD_LIBRARY_PATH=${.CURDIR}/libdz:${.CURDIR}/libmaa:$$LD_LIBRARY_PATH; \ + DYLD_LIBRARY_PATH=${.CURDIR}/libdz:${.CURDIR}/libmaa:$$LD_LIBRARY_PATH; \ + LIBRARY_PATH=$$LIBRARY_PATH:$$LD_LIBRARY_PATH; \ + export LD_LIBRARY_PATH DYLD_LIBRARY_PATH LIBRARY_PATH; \ + ${.CURDIR}/dict/dict; \ + ${.CURDIR}/dictd/dictd; \ + ${.CURDIR}/dictfmt/dictfmt; \ + ${.CURDIR}/dictzip/dictzip; \ + \ + echo =========== nm ============; \ + case ${OPSYS} in \ + *BSD|DragonFly|SunOS|Linux) \ + ${run_nm} ${OBJDIR_libmaa}/libmaa*.so; \ + echo =; \ + ${run_nm} ${OBJDIR_libdz}/libdz*.so;; \ + *) \ + printf 'symbol fake4\nsymbol fake5\nsymbol fake6\n=\nsymbol fake3\n';; \ + esac; \ + \ + echo =========== all ============; \ + ${MAKE} ${MAKEFLAGS} -j4 all > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= INTERNALLIBS ==========; \ + { ${MAKE} ${MAKEFLAGS} installdirs DESTDIR=${.OBJDIR}; \ + ${MAKE} ${MAKEFLAGS} install DESTDIR=${.OBJDIR}; \ + ${MAKE} ${MAKEFLAGS} uninstall DESTDIR=${.OBJDIR}; } 2>&1 | awk '/^(un)?install/'; \ + rm -rf ${.OBJDIR}${PREFIX} ${.OBJDIR}/usr ${.OBJDIR}/home ${.OBJDIR}/Users; \ + echo ========= installdirs ==========; \ + ${MAKE} ${MAKEFLAGS} installdirs DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type l -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= install ==========; \ + ${MAKE} ${MAKEFLAGS} install -j3 DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type l -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======== uninstall =========; \ + ${MAKE} ${MAKEFLAGS} -j4 uninstall DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ========== nodeps-cleandir-dictfmt subdir-clean-dictzip ===========; \ + ${MAKE} ${MAKEFLAGS} nodeps-cleandir-dictfmt nodeps-clean-dictzip > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ========== clean ===========; \ + ${MAKE} ${MAKEFLAGS} clean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ======= distclean ==========; \ + ${MAKE} ${MAKEFLAGS} distclean > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + rm -rf ${.OBJDIR}${PREFIX} ${.OBJDIR}/usr ${.OBJDIR}/home ${.OBJDIR}/Users; \ + echo =========== MKOBJDIRS=auto ============; \ + env TARGETS=fake ${MAKE} ${MAKEFLAGS} fake \ + MKCHECKS=no MAKEOBJDIRPREFIX=${.OBJDIR}/obj1 > /dev/null; \ + find ${.OBJDIR} -type d -o -type f -o -type l | grep -v obj1 | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + echo ===; \ + find ${.OBJDIR}/obj1/${.OBJDIR} -type d -o -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; rm -rf obj1; \ + \ + echo =========== MKOBJDIRS=yes ============; \ + env TARGETS=fake ${MAKE} ${MAKEFLAGS} fake \ + MKCHECKS=no MKOBJDIRS=yes MAKEOBJDIRPREFIX=${.OBJDIR}/obj1 > /dev/null; \ + printf '%s' 'obj1 '; \ + if test -d ${.OBJDIR}/obj1; then echo exists; else echo does not exist; fi; \ + rm -rf obj1; \ + echo ===; \ + ${MAKE} ${MAKEFLAGS} obj MKOBJDIRS=yes MAKEOBJDIRPREFIX=${.OBJDIR}/obj2 > /dev/null; \ + ${MAKE} ${MAKEFLAGS} obj MKOBJDIRS=yes MAKEOBJDIR=${.OBJDIR}/obj3 > /dev/null; \ + find ${.OBJDIR} -type d -o -type f -o -type l | grep -v 'obj[23]' | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + echo ===; \ + find ${.OBJDIR}/obj2/${.OBJDIR} ${.OBJDIR}/obj3 \ + -type d -o -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; rm -rf obj2 obj3; \ + \ + echo =========== MKOBJDIRS=no ============; \ + ${MAKE} ${MAKEFLAGS} obj MKOBJDIRS=no MAKEOBJDIRPREFIX=${.OBJDIR}/obj2 > /dev/null; \ + ${MAKE} ${MAKEFLAGS} obj MKOBJDIRS=no MAKEOBJDIR=${.OBJDIR}/obj3 > /dev/null; \ + find ${.OBJDIR} -type d -o -type f -o -type l | grep 'obj[23]' | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; rm -rf obj2 obj3; \ + \ + echo ======= errorcheck ==========; \ + ${MAKE} ${MAKEFLAGS} errorcheck > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + ${MAKE} ${MAKEFLAGS} cleandir > /dev/null; \ + \ + echo ======= all-dict ==========; \ + ${MAKE} ${MAKEFLAGS} -j4 all-dict > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======= -C dict all ==========; \ + ${MAKE} ${MAKEFLAGS} clean-dict > /dev/null; \ + env init_make_level=${next_level} ${MAKE} ${MAKEFLAGS} -C dict all > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ========= installdirs-dict ==========; \ + ${MAKE} ${MAKEFLAGS} installdirs-dict DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type l -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= install-dict ==========; \ + ${MAKE} ${MAKEFLAGS} install-dict DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type l -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= -Cdict install ==========; \ + rm -rf ${.OBJDIR}${PREFIX} > /dev/null; \ + env init_make_level=${next_level} ${MAKE} ${MAKEFLAGS} -C dict install DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type l -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======= uninstall-dict ==========; \ + ${MAKE} ${MAKEFLAGS} -j4 uninstall-dict DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ========== -C dict clean ===========; \ + env init_make_level=${next_level} ${MAKE} ${MAKEFLAGS} -C dict clean > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ======= cleandir-dict ==========; \ + ${MAKE} ${MAKEFLAGS} cleandir-dict > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= installdirs-doc ==========; \ + rm -rf ${.OBJDIR}${PREFIX}; \ + ${MAKE} ${MAKEFLAGS} installdirs-doc DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type l -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= install-doc ==========; \ + ${MAKE} ${MAKEFLAGS} install-doc DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type l -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======= uninstall-doc ==========; \ + ${MAKE} ${MAKEFLAGS} -j4 uninstall-doc DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo =========== all with NOSUBDIR ============; \ + ${MAKE} ${MAKEFLAGS} distclean > /dev/null; \ + NOSUBDIR='dictfmt dictzip'; export NOSUBDIR; \ + ${MAKE} ${MAKEFLAGS} -j4 all > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + unset NOSUBDIR; \ + \ + echo =========== all with MKPIE=yes ============; \ + ${MAKE} ${MAKEFLAGS} distclean > /dev/null; \ + ${MAKE} ${MAKEFLAGS} -j4 all MKPIE=yes > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo =========== all with STATICLIBS=everything... ============; \ + ${MAKE} ${MAKEFLAGS} distclean > /dev/null; \ + env STATICLIBS='libmaa libdz' ${MAKE} ${MAKEFLAGS} -j4 all > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo =========== print_deps ============; \ + ${MAKE} ${MAKEFLAGS} print_deps | grep -E '^(all|test)'; \ + echo =====; \ + NOSUBDIR='dictfmt dictzip' \ + ${MAKE} ${MAKEFLAGS} print_deps | grep -E '^(all|test)'; \ + echo =====; \ + NODEPS='test2-*:test2-dict*' TARGETS=test2 \ + ${MAKE} ${MAKEFLAGS} print_deps | grep -E '^(all|test)'; \ + \ + true =========== cleandir ============; \ + unset NOSUBDIR || true; \ + ${MAKE} ${MAKEFLAGS} distclean > /dev/null + +.include <mkc.minitest.mk> diff --git a/examples/hello_errwarn/Makefile b/examples/hello_errwarn/Makefile new file mode 100644 index 0000000..6b8c160 --- /dev/null +++ b/examples/hello_errwarn/Makefile @@ -0,0 +1,10 @@ +PROG = hello + +WARNS = 4 + +MKC_FEATURES = err warn + +MKC_REQD = 0.26.0 + +.include "test.mk" +.include <mkc.mk> diff --git a/examples/hello_errwarn/expect.out b/examples/hello_errwarn/expect.out new file mode 100644 index 0000000..8587981 --- /dev/null +++ b/examples/hello_errwarn/expect.out @@ -0,0 +1,23 @@ +======= ex ========== +hello: warnx test1: Cannot allocate memory +hello: errx test1: Cannot allocate memory +$?=21 +hello: warnx test2, six=6: Cannot allocate memory +hello: errx test2, six=6: Cannot allocate memory +$?=22 +errx(3): invalid argv +$?=94 +hello: warn test1 +hello: err test1 +$?=11 +hello: warn test2, five=5 +hello: err test2, five=5 +$?=12 +err(3): invalid argv +$?=93 +======= CLEANFILES ========== +hello.o +progname.o +err.o +warn.o +======= cleandir ========== diff --git a/examples/hello_errwarn/hello.c b/examples/hello_errwarn/hello.c new file mode 100644 index 0000000..a648890 --- /dev/null +++ b/examples/hello_errwarn/hello.c @@ -0,0 +1,54 @@ +#include <errno.h> +#include <string.h> +#include <stdio.h> + +#include <mkc_err.h> +#include <mkc_warn.h> + +int main (int argc, char ** argv) +{ + --argc; + ++argv; + + if (argc != 2) + return (90); + + if (!strcmp (argv [0], "errx")){ + switch (argv [1][0]){ + case '1': + warnx ("warn test1"); + errx (11, "err test1"); + break; + case '2': + warnx ("warn test2, five=%d", 5); + errx (12, "err test2, five=%d", 5); + break; + default: + fprintf (stderr, "err(3): invalid argv\n"); + return 93; + } + }else if (!strcmp (argv [0], "err")){ + switch (argv [1][0]){ + case '1': + errno = ENOMEM; + warn ("warnx test1"); + errno = ENOMEM; + err (21, "errx test1"); + break; + case '2': + errno = ENOMEM; + warn ("warnx test2, six=%d", 6); + errno = ENOMEM; + err (22, "errx test2, six=%d", 6); + break; + default: + fprintf (stderr, "errx(3): invalid argv\n"); + return 94; + } + }else{ + fprintf (stderr, "bad err id '%s'\n", argv [0]); + return (91); + } + + return 0; +} diff --git a/examples/hello_errwarn/test.mk b/examples/hello_errwarn/test.mk new file mode 100644 index 0000000..94f48a2 --- /dev/null +++ b/examples/hello_errwarn/test.mk @@ -0,0 +1,19 @@ +SUBST_CMD=sed -e 's,Not enough space,Cannot allocate memory,' + +.PHONY : test_output +test_output: + @\ + echo ======= ex ==========; \ + { ${.OBJDIR}/hello err 1 2>&1 >/dev/null; echo '$$?='$$?; } | ${SUBST_CMD}; \ + { ${.OBJDIR}/hello err 2 2>&1 >/dev/null; echo '$$?='$$?; } | ${SUBST_CMD}; \ + { ${.OBJDIR}/hello err 3 2>&1 >/dev/null; echo '$$?='$$?; } | ${SUBST_CMD}; \ + ${.OBJDIR}/hello errx 1 2>&1 >/dev/null; echo '$$?='$$?; \ + ${.OBJDIR}/hello errx 2 2>&1 >/dev/null; echo '$$?='$$?; \ + ${.OBJDIR}/hello errx 3 2>&1 >/dev/null; echo '$$?='$$?; \ + echo ======= CLEANFILES ==========; \ + ${MAKE} ${MAKEFLAGS} print_values VARS='CLEANFILES' MKCHECKS=no | \ + awk '{for(i=1; i<=NF; ++i) if ($$i ~ /[.]o.?$$/) print $$i}'; \ + echo ======= cleandir ==========; \ + ${MAKE} ${MAKEFLAGS} cleandir > /dev/null + +.include <mkc.minitest.mk> diff --git a/examples/hello_fgetln/Makefile b/examples/hello_fgetln/Makefile new file mode 100644 index 0000000..d77b37e --- /dev/null +++ b/examples/hello_fgetln/Makefile @@ -0,0 +1,10 @@ +MKC_FEATURES = fgetln err + +PROG = hello + +WARNS = 4 + +MKC_REQD = 0.26.0 + +.include "test.mk" +.include <mkc.prog.mk> diff --git a/examples/hello_fgetln/expect.out b/examples/hello_fgetln/expect.out new file mode 100644 index 0000000..cd19953 --- /dev/null +++ b/examples/hello_fgetln/expect.out @@ -0,0 +1,99 @@ +# Copyright (c) 2009, Aleksey Cheusov <vle@gmx.net> +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +=========== all ============ +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_func0_getexecname_stdlib_h.c +/objdir/_mkc_func0_getexecname_stdlib_h.err +/objdir/_mkc_func0_getexecname_stdlib_h.res +/objdir/_mkc_func0_getprogname_stdlib_h.c +/objdir/_mkc_func0_getprogname_stdlib_h.err +/objdir/_mkc_func0_getprogname_stdlib_h.res +/objdir/_mkc_func1_setprogname_stdlib_h.c +/objdir/_mkc_func1_setprogname_stdlib_h.err +/objdir/_mkc_func1_setprogname_stdlib_h.res +/objdir/_mkc_func3_err_err_h.c +/objdir/_mkc_func3_err_err_h.err +/objdir/_mkc_func3_err_err_h.res +/objdir/_mkc_func3_errx_err_h.c +/objdir/_mkc_func3_errx_err_h.err +/objdir/_mkc_func3_errx_err_h.res +/objdir/_mkc_func3_fgetln_stdio_h.c +/objdir/_mkc_func3_fgetln_stdio_h.err +/objdir/_mkc_func3_fgetln_stdio_h.res +/objdir/_mkc_func3_getline_stdio_h.c +/objdir/_mkc_func3_getline_stdio_h.err +/objdir/_mkc_func3_getline_stdio_h.res +/objdir/_mkc_func3_verr_err_h.c +/objdir/_mkc_func3_verr_err_h.err +/objdir/_mkc_func3_verr_err_h.res +/objdir/_mkc_func3_verrx_err_h.c +/objdir/_mkc_func3_verrx_err_h.err +/objdir/_mkc_func3_verrx_err_h.res +/objdir/_mkc_funclib_err.c +/objdir/_mkc_funclib_err.err +/objdir/_mkc_funclib_err.res +/objdir/_mkc_funclib_errx.c +/objdir/_mkc_funclib_errx.err +/objdir/_mkc_funclib_errx.res +/objdir/_mkc_funclib_fgetln.c +/objdir/_mkc_funclib_fgetln.err +/objdir/_mkc_funclib_fgetln.res +/objdir/_mkc_funclib_getline.c +/objdir/_mkc_funclib_getline.err +/objdir/_mkc_funclib_getline.res +/objdir/_mkc_funclib_getprogname.c +/objdir/_mkc_funclib_getprogname.err +/objdir/_mkc_funclib_getprogname.res +/objdir/_mkc_funclib_setprogname.c +/objdir/_mkc_funclib_setprogname.err +/objdir/_mkc_funclib_setprogname.res +/objdir/_mkc_funclib_verr.c +/objdir/_mkc_funclib_verr.err +/objdir/_mkc_funclib_verr.res +/objdir/_mkc_funclib_verrx.c +/objdir/_mkc_funclib_verrx.err +/objdir/_mkc_funclib_verrx.res +/objdir/_mkc_header_err_h.c +/objdir/_mkc_header_err_h.err +/objdir/_mkc_header_err_h.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/_mkc_variable_program_invocation_short_name_errno_h.c +/objdir/_mkc_variable_program_invocation_short_name_errno_h.err +/objdir/_mkc_variable_program_invocation_short_name_errno_h.res +/objdir/expect.out +/objdir/hello +/objdir/hello.c +/objdir/hello.o +/objdir/hello_fgetln.test.out.tmp +/objdir/test.mk +======= CLEANFILES ========== +hello.o +getline.o +fgetln.o +progname.o +err.o +======= cleandir ========== diff --git a/examples/hello_fgetln/hello.c b/examples/hello_fgetln/hello.c new file mode 100644 index 0000000..8a4f0fb --- /dev/null +++ b/examples/hello_fgetln/hello.c @@ -0,0 +1,24 @@ +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +#include <mkc_fgetln.h> +#include <mkc_err.h> + +int main (int argc, char ** argv) +{ + char *buf, *lbuf; + size_t len; + + while ((lbuf = buf = fgetln (stdin, &len)) != NULL) { + if (len > 0 && buf [len - 1] == '\n') + buf[len - 1] = '\0'; + else if ((lbuf = strndup (buf, len + 1)) == NULL) + err (1, NULL); + printf ("%s\n", lbuf); + + if (lbuf != buf) + free (lbuf); + } + return 0; +} diff --git a/examples/hello_fgetln/test.mk b/examples/hello_fgetln/test.mk new file mode 100644 index 0000000..58c7925 --- /dev/null +++ b/examples/hello_fgetln/test.mk @@ -0,0 +1,19 @@ +FUNCS_RE=(fgetln|getline|err|progname)[.]o + +.PHONY : test_output +test_output: + @set -e; \ + ${.OBJDIR}/hello < ${.CURDIR}/../hello_strlcpy2/input.in; \ + rm -rf ${.OBJDIR}${PREFIX}; \ + \ + echo =========== all ============; \ + find ${.OBJDIR} -type f | grep -Ev '${FUNCS_RE}' | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======= CLEANFILES ==========; \ + ${MAKE} ${MAKEFLAGS} print_values VARS='CLEANFILES' MKCHECKS=no | \ + awk '{for(i=1; i<=NF; ++i) if ($$i ~ /[.]o.?$$/) print $$i}'; \ + echo ======= cleandir ==========; \ + ${MAKE} ${MAKEFLAGS} cleandir > /dev/null + +.include <mkc.minitest.mk> diff --git a/examples/hello_files/DEBIAN/control b/examples/hello_files/DEBIAN/control new file mode 100644 index 0000000..35c8b6a --- /dev/null +++ b/examples/hello_files/DEBIAN/control @@ -0,0 +1,8 @@ +Package: hello-files +Version: 0.1.0-1 +Architecture: all +Depends: +Maintainer: Aleksey Cheusov <vle@gmx.net> +Description: Collection of fake scripts + This is a demo of mk-configure project. + diff --git a/examples/hello_files/Makefile b/examples/hello_files/Makefile new file mode 100644 index 0000000..7db72fb --- /dev/null +++ b/examples/hello_files/Makefile @@ -0,0 +1,32 @@ +STRANGEDIR1 ?= ${PREFIX}/share/files1 +STRANGEDIR2 ?= ${PREFIX}/share/files2 +STRANGEDIR3 ?= ${PREFIX}/share/files3 + +FILES = shell_func1 shell_func2 shell_func3 + +FILESDIR = ${BINDIR} +FILESDIR_shell_func3 = ${LIBEXECDIR} + +LINKS = ${BINDIR}/shell_func1 ${STRANGEDIR1}/shell_func1.sh +LINKS += ${BINDIR}/shell_func2 ${STRANGEDIR2}/shell_func2.sh + +SYMLINKS = ${LIBEXECDIR}/shell_func3 ${STRANGEDIR3}/shell_func3.sh + +MAN = shell_func.7 +TEXINFO = shell_func.texinfo # for .info file + +# The following line is for regression test only. +# We will not create and update dir file +INSTALL_INFO = : + +# The following lines are for regression test only. +# We will build .html from man page only under NetBSD +OPSYS != uname -s +.if ${OPSYS} != "NetBSD" +MKHTML = no +.endif + +MKC_REQD = 0.11.0 + +.include "test.mk" +.include <mkc.files.mk> diff --git a/examples/hello_files/expect.NetBSD.out b/examples/hello_files/expect.NetBSD.out new file mode 100644 index 0000000..0b28371 --- /dev/null +++ b/examples/hello_files/expect.NetBSD.out @@ -0,0 +1,97 @@ +=========== vars ============ +CLEANFILES=/path/to/hello_files.test.out pod2htmd.tmp pod2htmi.tmp shell_func.cat7 shell_func.html7 shell_func.info +DISTCLEANFILES=/path/to/_mkc_* +=========== all ============ +/objdir/DEBIAN/control +/objdir/Makefile +/objdir/expect.NetBSD.out +/objdir/expect.out +/objdir/hello_files.test.out.tmp +/objdir/shell_func.7 +/objdir/shell_func.cat7 +/objdir/shell_func.info +/objdir/shell_func.texinfo +/objdir/shell_func1 +/objdir/shell_func2 +/objdir/shell_func3 +/objdir/test.mk +======== all+html ========== +/objdir/DEBIAN/control +/objdir/Makefile +/objdir/expect.NetBSD.out +/objdir/expect.out +/objdir/hello_files.test.out.tmp +/objdir/shell_func.7 +/objdir/shell_func.cat7 +/objdir/shell_func.html7 +/objdir/shell_func.info +/objdir/shell_func.texinfo +/objdir/shell_func1 +/objdir/shell_func2 +/objdir/shell_func3 +/objdir/test.mk +========= install ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/bin/shell_func1 +/objdir/prefix/bin/shell_func2 +/objdir/prefix/info +/objdir/prefix/info/shell_func.info +/objdir/prefix/libexec +/objdir/prefix/libexec/shell_func3 +/objdir/prefix/man +/objdir/prefix/man/cat7 +/objdir/prefix/man/cat7/shell_func.0 +/objdir/prefix/man/html7 +/objdir/prefix/man/html7/shell_func.html +/objdir/prefix/man/man7 +/objdir/prefix/man/man7/shell_func.7 +/objdir/prefix/share +/objdir/prefix/share/files1 +/objdir/prefix/share/files1/shell_func1.sh +/objdir/prefix/share/files2 +/objdir/prefix/share/files2/shell_func2.sh +/objdir/prefix/share/files3 +/objdir/prefix/share/files3/shell_func3.sh +======== uninstall ========= +========== clean =========== +/objdir/DEBIAN/control +/objdir/Makefile +/objdir/expect.NetBSD.out +/objdir/expect.out +/objdir/hello_files.test.out.tmp +/objdir/shell_func.7 +/objdir/shell_func.texinfo +/objdir/shell_func1 +/objdir/shell_func2 +/objdir/shell_func3 +/objdir/test.mk +======= distclean ========== +/objdir/DEBIAN/control +/objdir/Makefile +/objdir/expect.NetBSD.out +/objdir/expect.out +/objdir/hello_files.test.out.tmp +/objdir/shell_func.7 +/objdir/shell_func.texinfo +/objdir/shell_func1 +/objdir/shell_func2 +/objdir/shell_func3 +/objdir/test.mk +==== install MKINSTALL=no ==== +/objdir/DEBIAN/control +/objdir/Makefile +/objdir/expect.NetBSD.out +/objdir/expect.out +/objdir/hello_files.test.out.tmp +/objdir/shell_func.7 +/objdir/shell_func.cat7 +/objdir/shell_func.html7 +/objdir/shell_func.info +/objdir/shell_func.texinfo +/objdir/shell_func1 +/objdir/shell_func2 +/objdir/shell_func3 +/objdir/test.mk +==== SHRTOUT=yes ==== +TEXINFO: shell_func.info diff --git a/examples/hello_files/expect.out b/examples/hello_files/expect.out new file mode 100644 index 0000000..5eebc44 --- /dev/null +++ b/examples/hello_files/expect.out @@ -0,0 +1,93 @@ +=========== vars ============ +CLEANFILES=/path/to/hello_files.test.out pod2htmd.tmp pod2htmi.tmp shell_func.cat7 shell_func.html7 shell_func.info +DISTCLEANFILES=/path/to/_mkc_* +=========== all ============ +/objdir/DEBIAN/control +/objdir/Makefile +/objdir/expect.NetBSD.out +/objdir/expect.out +/objdir/hello_files.test.out.tmp +/objdir/shell_func.7 +/objdir/shell_func.cat7 +/objdir/shell_func.info +/objdir/shell_func.texinfo +/objdir/shell_func1 +/objdir/shell_func2 +/objdir/shell_func3 +/objdir/test.mk +======== all+html ========== +/objdir/DEBIAN/control +/objdir/Makefile +/objdir/expect.NetBSD.out +/objdir/expect.out +/objdir/hello_files.test.out.tmp +/objdir/shell_func.7 +/objdir/shell_func.cat7 +/objdir/shell_func.info +/objdir/shell_func.texinfo +/objdir/shell_func1 +/objdir/shell_func2 +/objdir/shell_func3 +/objdir/test.mk +========= install ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/bin/shell_func1 +/objdir/prefix/bin/shell_func2 +/objdir/prefix/info +/objdir/prefix/info/shell_func.info +/objdir/prefix/libexec +/objdir/prefix/libexec/shell_func3 +/objdir/prefix/man +/objdir/prefix/man/cat7 +/objdir/prefix/man/cat7/shell_func.0 +/objdir/prefix/man/man7 +/objdir/prefix/man/man7/shell_func.7 +/objdir/prefix/share +/objdir/prefix/share/files1 +/objdir/prefix/share/files1/shell_func1.sh +/objdir/prefix/share/files2 +/objdir/prefix/share/files2/shell_func2.sh +/objdir/prefix/share/files3 +/objdir/prefix/share/files3/shell_func3.sh +======== uninstall ========= +========== clean =========== +/objdir/DEBIAN/control +/objdir/Makefile +/objdir/expect.NetBSD.out +/objdir/expect.out +/objdir/hello_files.test.out.tmp +/objdir/shell_func.7 +/objdir/shell_func.texinfo +/objdir/shell_func1 +/objdir/shell_func2 +/objdir/shell_func3 +/objdir/test.mk +======= distclean ========== +/objdir/DEBIAN/control +/objdir/Makefile +/objdir/expect.NetBSD.out +/objdir/expect.out +/objdir/hello_files.test.out.tmp +/objdir/shell_func.7 +/objdir/shell_func.texinfo +/objdir/shell_func1 +/objdir/shell_func2 +/objdir/shell_func3 +/objdir/test.mk +==== install MKINSTALL=no ==== +/objdir/DEBIAN/control +/objdir/Makefile +/objdir/expect.NetBSD.out +/objdir/expect.out +/objdir/hello_files.test.out.tmp +/objdir/shell_func.7 +/objdir/shell_func.cat7 +/objdir/shell_func.info +/objdir/shell_func.texinfo +/objdir/shell_func1 +/objdir/shell_func2 +/objdir/shell_func3 +/objdir/test.mk +==== SHRTOUT=yes ==== +TEXINFO: shell_func.info diff --git a/examples/hello_files/shell_func.7 b/examples/hello_files/shell_func.7 new file mode 100644 index 0000000..393c158 --- /dev/null +++ b/examples/hello_files/shell_func.7 @@ -0,0 +1,15 @@ +.\" $NetBSD$ +.\" +.\" Copyright (c) 2008 by Aleksey Cheusov (vle@gmx.net) +.\" Absolutely no warranty. +.\" +.TH SHELL_FUNCS 7 "Aug 29, 2008" +.SH NAME +shell_funcs \- collection of function written in shell +.SH DESCRIPTION +.B shell_funcs +is a collection... +.SH SEE ALSO +.BR sh(1) , +.SH AUTHOR +Aleksey Cheusov <vle@gmx.net> diff --git a/examples/hello_files/shell_func.texinfo b/examples/hello_files/shell_func.texinfo new file mode 100644 index 0000000..fa0012e --- /dev/null +++ b/examples/hello_files/shell_func.texinfo @@ -0,0 +1,38 @@ +\input texinfo @c -*-texinfo-*- +@setfilename shell_func.info +@settitle shell_func shell functions +@setchapternewpage odd + +@ifinfo +@dircategory Libraries +@direntry +* Shell_func: (shell_func). Info page for shell_func. +@end direntry + +This is fake! + +@end ifinfo + +@titlepage +@title shell_func info page +@subtitle Edition 1, Version 7. +@subtitle 5 +@author Aleksey Cheusov + +@page +foobar + +@vskip 0pt plus 1filll +Copyright @copyright{} 2009 Aleksey Cheusov +@end titlepage + +@ifinfo +@node Top +@top shell_func fake! + +This is fake too! + +@end ifinfo + +@contents +@bye diff --git a/examples/hello_files/shell_func1 b/examples/hello_files/shell_func1 new file mode 100644 index 0000000..018150f --- /dev/null +++ b/examples/hello_files/shell_func1 @@ -0,0 +1,3 @@ +func1 (){ + echo 1 +} diff --git a/examples/hello_files/shell_func2 b/examples/hello_files/shell_func2 new file mode 100644 index 0000000..884281c --- /dev/null +++ b/examples/hello_files/shell_func2 @@ -0,0 +1,3 @@ +func2 (){ + echo 2 +} diff --git a/examples/hello_files/shell_func3 b/examples/hello_files/shell_func3 new file mode 100644 index 0000000..5c8fd2f --- /dev/null +++ b/examples/hello_files/shell_func3 @@ -0,0 +1,3 @@ +func3 (){ + echo 3 +} diff --git a/examples/hello_files/test.mk b/examples/hello_files/test.mk new file mode 100644 index 0000000..e7dbfec --- /dev/null +++ b/examples/hello_files/test.mk @@ -0,0 +1,59 @@ +.PHONY : test_output +test_output: + @set -e; \ + MKCATPAGES=yes; export MKCATPAGES; \ + rm -rf ${.OBJDIR}${PREFIX}; \ + \ + echo =========== vars ============; \ + echo CLEANFILES=${CLEANFILES:Q} | \ + mkc_test_helper_paths; \ + echo DISTCLEANFILES=${DISTCLEANFILES:Q} | \ + mkc_test_helper_paths; \ + echo =========== all ============; \ + ${MAKE} ${MAKEFLAGS} -j4 all > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======== all+html ==========; \ + MKHTML=yes; export MKHTML; \ + ${MAKE} ${MAKEFLAGS} -j4 all > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= install ==========; \ + ${MAKE} ${MAKEFLAGS} install -j3 DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type l -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======== uninstall =========; \ + ${MAKE} ${MAKEFLAGS} -j4 uninstall DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========== clean ===========; \ + ${MAKE} ${MAKEFLAGS} clean > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======= distclean ==========; \ + ${MAKE} ${MAKEFLAGS} distclean > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ==== install MKINSTALL=no ====; \ + MKINSTALL=no; export MKINSTALL; \ + ${MAKE} ${MAKEFLAGS} -j4 all installdirs install -j3 DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ==== SHRTOUT=yes ====; \ + ${MAKE} ${MAKEFLAGS} distclean > /dev/null; \ + env MKCATPAGES=no MKHTML=no ${MAKE} ${MAKEFLAGS} SHRTOUT=yes all 2>&1 |\ + mkc_test_helper2; \ + \ + true ======= distclean ==========; \ + ${MAKE} ${MAKEFLAGS} distclean > /dev/null + +.include <mkc.minitest.mk> diff --git a/examples/hello_glib2/Makefile b/examples/hello_glib2/Makefile new file mode 100644 index 0000000..68ac803 --- /dev/null +++ b/examples/hello_glib2/Makefile @@ -0,0 +1,11 @@ +PROG = hello_glib2 + +PKG_CONFIG_DEPS = glib-2.0>=2.1 + +CFLAGS += -DG_DISABLE_DEPRECATED=1 +CFLAGS += -DG_DISABLE_SINGLE_INCLUDES + +MKC_REQD = 0.11.0 + +.include "test.mk" +.include <mkc.prog.mk> diff --git a/examples/hello_glib2/expect.out b/examples/hello_glib2/expect.out new file mode 100644 index 0000000..8d37a48 --- /dev/null +++ b/examples/hello_glib2/expect.out @@ -0,0 +1,53 @@ +Hello World! +glib_major_version=N +glib_minor_version=N +glib_micro_version=N +=========== all ============ +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_pkgconfig_glib-2.0_ge_2.1.err +/objdir/_mkc_pkgconfig_glib-2.0_ge_2.1.res +/objdir/_mkc_pkgconfig_glib-2.0_ge_2.1_cflags.err +/objdir/_mkc_pkgconfig_glib-2.0_ge_2.1_cflags.res +/objdir/_mkc_pkgconfig_glib-2.0_ge_2.1_libs.err +/objdir/_mkc_pkgconfig_glib-2.0_ge_2.1_libs.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/_mkc_prog_pkg-config.err +/objdir/_mkc_prog_pkg-config.res +/objdir/expect.out +/objdir/hello_glib2 +/objdir/hello_glib2.c +/objdir/hello_glib2.o +/objdir/hello_glib2.test.out.tmp +/objdir/test.mk +========= install ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/bin/hello_glib2 +======== uninstall ========= +========== clean =========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_pkgconfig_glib-2.0_ge_2.1.err +/objdir/_mkc_pkgconfig_glib-2.0_ge_2.1.res +/objdir/_mkc_pkgconfig_glib-2.0_ge_2.1_cflags.err +/objdir/_mkc_pkgconfig_glib-2.0_ge_2.1_cflags.res +/objdir/_mkc_pkgconfig_glib-2.0_ge_2.1_libs.err +/objdir/_mkc_pkgconfig_glib-2.0_ge_2.1_libs.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/_mkc_prog_pkg-config.err +/objdir/_mkc_prog_pkg-config.res +/objdir/expect.out +/objdir/hello_glib2.c +/objdir/hello_glib2.test.out.tmp +/objdir/test.mk +======= distclean ========== +/objdir/Makefile +/objdir/expect.out +/objdir/hello_glib2.c +/objdir/hello_glib2.test.out.tmp +/objdir/test.mk diff --git a/examples/hello_glib2/hello_glib2.c b/examples/hello_glib2/hello_glib2.c new file mode 100644 index 0000000..ce59fe7 --- /dev/null +++ b/examples/hello_glib2/hello_glib2.c @@ -0,0 +1,16 @@ +#include <glib.h> +#include <locale.h> +#include <stdio.h> + +int main (int argc, char** argv) +{ + setlocale (LC_ALL, ""); + + puts ("Hello World!"); + + printf ("glib_major_version=%i\n", (int) glib_major_version); + printf ("glib_minor_version=%i\n", (int) glib_minor_version); + printf ("glib_micro_version=%i\n", (int) glib_micro_version); + + return 0; +} diff --git a/examples/hello_glib2/test.mk b/examples/hello_glib2/test.mk new file mode 100644 index 0000000..8604e62 --- /dev/null +++ b/examples/hello_glib2/test.mk @@ -0,0 +1,33 @@ +.PHONY : test_output +test_output: + @set -e; \ + ${.OBJDIR}/hello_glib2 | sed 's,[0-9][0-9]*,N,'; \ + rm -rf ${.OBJDIR}${PREFIX}; \ + MKCATPAGES=yes; export MKCATPAGES; \ + \ + echo =========== all ============; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= install ==========; \ + ${MAKE} ${MAKEFLAGS} install -j3 DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======== uninstall =========; \ + ${MAKE} ${MAKEFLAGS} -j4 uninstall DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ========== clean ===========; \ + ${MAKE} ${MAKEFLAGS} clean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ======= distclean ==========; \ + ${MAKE} ${MAKEFLAGS} distclean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}" + +.include <mkc.minitest.mk> diff --git a/examples/hello_iconv/Makefile b/examples/hello_iconv/Makefile new file mode 100644 index 0000000..cd00ecf --- /dev/null +++ b/examples/hello_iconv/Makefile @@ -0,0 +1,18 @@ +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 + +PROG = hello_iconv + +WARNS = 4 + +MKC_REQD = 0.26.0 + +.include "test.mk" +.include <mkc.prog.mk> diff --git a/examples/hello_iconv/expect.out b/examples/hello_iconv/expect.out new file mode 100644 index 0000000..99878b4 --- /dev/null +++ b/examples/hello_iconv/expect.out @@ -0,0 +1 @@ +Your iconv(3) is ok diff --git a/examples/hello_iconv/hello_iconv.c b/examples/hello_iconv/hello_iconv.c new file mode 100644 index 0000000..b467c75 --- /dev/null +++ b/examples/hello_iconv/hello_iconv.c @@ -0,0 +1,21 @@ +#include <stdio.h> + +int main (int argc, char ** argv) +{ + static char compat [] = +#ifdef HAVE_PROTOTYPE_POSIX_ICONV + "compatible"; +#elif defined(HAVE_PROTOTYPE_CONST_ICONV) + "incompatible"; +#else + "???"; +#endif + + printf ("Your iconv(3) is %s with POSIX\n", compat); + +#if defined(HAVE_PROTOTYPE_POSIX_ICONV) && defined(HAVE_PROTOTYPE_CONST_ICONV) + puts ("Buggy mk-configure!"); +#endif + + return 0; +} diff --git a/examples/hello_iconv/test.mk b/examples/hello_iconv/test.mk new file mode 100644 index 0000000..e796fef --- /dev/null +++ b/examples/hello_iconv/test.mk @@ -0,0 +1,7 @@ +.PHONY : test_output +test_output: + @set -e; \ + ${.OBJDIR}/hello_iconv | sed 's/i*n*compatible.*$$/ok/'; \ + ${MAKE} ${MAKEFLAGS} cleandir > /dev/null 2>&1 + +.include <mkc.minitest.mk> diff --git a/examples/hello_lex/Makefile b/examples/hello_lex/Makefile new file mode 100644 index 0000000..e21d074 --- /dev/null +++ b/examples/hello_lex/Makefile @@ -0,0 +1,7 @@ +PROG = hello_lex +SRCS = hello_lex.l + +DPSRCS = hello_lex.c + +.include "test.mk" +.include <mkc.prog.mk> diff --git a/examples/hello_lex/expect.out b/examples/hello_lex/expect.out new file mode 100644 index 0000000..1f96feb --- /dev/null +++ b/examples/hello_lex/expect.out @@ -0,0 +1,86 @@ +# of lines = 2, # of chars = 26 +=========== all ============ +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/_mkc_prog_lex.err +/objdir/_mkc_prog_lex.res +/objdir/expect.out +/objdir/hello_lex +/objdir/hello_lex.c +/objdir/hello_lex.l +/objdir/hello_lex.o +/objdir/hello_lex.test.out.tmp +/objdir/input.txt +/objdir/test.mk +========= install ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/bin/hello_lex +======== uninstall ========= +========== clean =========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/_mkc_prog_lex.err +/objdir/_mkc_prog_lex.res +/objdir/expect.out +/objdir/hello_lex.l +/objdir/hello_lex.test.out.tmp +/objdir/input.txt +/objdir/test.mk +========== depend =========== +/objdir/.depend +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/_mkc_prog_lex.err +/objdir/_mkc_prog_lex.res +/objdir/expect.out +/objdir/hello_lex.c +/objdir/hello_lex.d +/objdir/hello_lex.l +/objdir/hello_lex.test.out.tmp +/objdir/input.txt +/objdir/test.mk +==== SHRTOUT=yes depend ==== +checking for C compiler mmm... nnn +checking for program mmm... nnn +checking for program mmm... nnn +LEX: hello_lex.l +DEP: hello_lex.d +DEP: .depend +==== SHRTOUT=yes all ==== +LEX: hello_lex.l +CC: hello_lex.c +LD: hello_lex +/objdir/.depend +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/_mkc_prog_lex.err +/objdir/_mkc_prog_lex.res +/objdir/expect.out +/objdir/hello_lex +/objdir/hello_lex.c +/objdir/hello_lex.d +/objdir/hello_lex.l +/objdir/hello_lex.o +/objdir/hello_lex.test.out.tmp +/objdir/input.txt +/objdir/test.mk +======= distclean ========== +/objdir/Makefile +/objdir/expect.out +/objdir/hello_lex.l +/objdir/hello_lex.test.out.tmp +/objdir/input.txt +/objdir/test.mk diff --git a/examples/hello_lex/hello_lex.l b/examples/hello_lex/hello_lex.l new file mode 100644 index 0000000..376eeaf --- /dev/null +++ b/examples/hello_lex/hello_lex.l @@ -0,0 +1,16 @@ + static int num_lines = 0; + static int num_chars = 0; + +%% + +\n { ++num_lines; ++num_chars; } +. ++num_chars; + +%% + +int main (int argc, char **argv) +{ + yylex (); + printf ("# of lines = %d, # of chars = %d\n", num_lines, num_chars); + return 0; +} diff --git a/examples/hello_lex/input.txt b/examples/hello_lex/input.txt new file mode 100644 index 0000000..93dc73c --- /dev/null +++ b/examples/hello_lex/input.txt @@ -0,0 +1,2 @@ +Hello World! +Foo Bar Baz! diff --git a/examples/hello_lex/test.mk b/examples/hello_lex/test.mk new file mode 100644 index 0000000..004c313 --- /dev/null +++ b/examples/hello_lex/test.mk @@ -0,0 +1,51 @@ +.PHONY : test_output +test_output: + @set -e; \ + ${.OBJDIR}/hello_lex < ${.CURDIR}/input.txt; \ + rm -rf ${.OBJDIR}${PREFIX}; \ + MKCATPAGES=yes; export MKCATPAGES; \ + \ + echo =========== all ============; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= install ==========; \ + ${MAKE} ${MAKEFLAGS} install -j3 DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======== uninstall =========; \ + ${MAKE} ${MAKEFLAGS} -j4 uninstall DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ========== clean ===========; \ + ${MAKE} ${MAKEFLAGS} clean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ========== depend ===========; \ + ${MAKE} ${MAKEFLAGS} distclean > /dev/null; \ + ${MAKE} ${MAKEFLAGS} depend -j4 > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ==== SHRTOUT=yes depend ====; \ + ${MAKE} ${MAKEFLAGS} distclean > /dev/null; \ + env ${MAKE} ${MAKEFLAGS} SHRTOUT=yes depend 2>&1 |\ + mkc_test_helper2; \ + \ + echo ==== SHRTOUT=yes all ====; \ + ${MAKE} ${MAKEFLAGS} clean > /dev/null; \ + env MKCATPAGES=no MKHTML=no ${MAKE} ${MAKEFLAGS} all SHRTOUT=yes 2>&1 |\ + mkc_test_helper2; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ======= distclean ==========; \ + ${MAKE} ${MAKEFLAGS} distclean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}" + +.include <mkc.minitest.mk> diff --git a/examples/hello_libdeps/Makefile b/examples/hello_libdeps/Makefile new file mode 100644 index 0000000..40ea9d6 --- /dev/null +++ b/examples/hello_libdeps/Makefile @@ -0,0 +1,7 @@ +LIBDEPS += libs/libfoo:libs/libfooqux +LIBDEPS += libs/libbar:progs/fooquxfoobar +LIBDEPS += libs/libfooqux:progs/fooquxfoobar +LIBDEPS += libs/libfoo:progs/foobaz libs/libbaz:progs/foobaz + +.include "test.mk" +.include <mkc.mk> diff --git a/examples/hello_libdeps/expect.out b/examples/hello_libdeps/expect.out new file mode 100644 index 0000000..a80481d --- /dev/null +++ b/examples/hello_libdeps/expect.out @@ -0,0 +1,127 @@ +=========== fooquxfoobar ============ +I am foo + and qux +I am foo +I am bar +=========== foobaz ============ +I am foo +I am baz +=========== depends ============ +bar.o bar.o bar.o: bar.c bar.h +baz.o baz.o baz.o: baz.c include/baz.h +foo.o foo.o foo.o: foo.c foo.h +foobaz.o foobaz.o foobaz.o: foobaz.c /objdir/libs/libfoo/foo.h /objdir/libs/libbaz/include/baz.h +fooqux.o fooqux.o fooqux.o: fooqux.c fooqux.h /objdir/libs/libfoo/foo.h +fooquxfoobar.o fooquxfoobar.o fooquxfoobar.o: fooquxfoobar.c /objdir/libs/libfooqux/fooqux.h /objdir/libs/libfoo/foo.h /objdir/libs/libbar/bar.h +======= install ========== +/objdir/prefix/bin/foobaz +/objdir/prefix/bin/fooquxfoobar +/objdir/prefix/include/bar.h +/objdir/prefix/include/baz.h +/objdir/prefix/include/foo.h +/objdir/prefix/include/fooqux.h +/objdir/prefix/lib/libbar.a +/objdir/prefix/lib/libbar.so +/objdir/prefix/lib/libbar.so.0 +/objdir/prefix/lib/libbar.so.0.0 +/objdir/prefix/lib/libbazbaz.a +/objdir/prefix/lib/libfoo.a +/objdir/prefix/lib/libfoo.so +/objdir/prefix/lib/libfoo.so.0 +/objdir/prefix/lib/libfoo.so.0.0 +/objdir/prefix/lib/libfooqux.a +/objdir/prefix/lib/libfooqux.so +/objdir/prefix/lib/libfooqux.so.0 +/objdir/prefix/lib/libfooqux.so.0.0 +=========== all with STATICLIBS=... ============ +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/expect.out +/objdir/hello_libdeps.test.out.tmp +/objdir/libs/libbar/Makefile +/objdir/libs/libbar/bar.c +/objdir/libs/libbar/bar.h +/objdir/libs/libbar/bar.o +/objdir/libs/libbar/bar.os +/objdir/libs/libbar/libbar.a +/objdir/libs/libbar/libbar_pic.a +/objdir/libs/libbaz/Makefile +/objdir/libs/libbaz/baz.c +/objdir/libs/libbaz/baz.o +/objdir/libs/libbaz/include/baz.h +/objdir/libs/libbaz/libbazbaz.a +/objdir/libs/libbaz/linkme.mk +/objdir/libs/libfoo/Makefile +/objdir/libs/libfoo/foo.c +/objdir/libs/libfoo/foo.h +/objdir/libs/libfoo/foo.o +/objdir/libs/libfoo/foo.os +/objdir/libs/libfoo/libfoo.a +/objdir/libs/libfoo/libfoo_pic.a +/objdir/libs/libfoo/linkme.mk +/objdir/libs/libfooqux/Makefile +/objdir/libs/libfooqux/fooqux.c +/objdir/libs/libfooqux/fooqux.h +/objdir/libs/libfooqux/fooqux.o +/objdir/libs/libfooqux/fooqux.os +/objdir/libs/libfooqux/libfooqux.a +/objdir/libs/libfooqux/libfooqux.so +/objdir/libs/libfooqux/libfooqux.so.0 +/objdir/libs/libfooqux/libfooqux.so.0.0 +/objdir/progs/foobaz/Makefile +/objdir/progs/foobaz/foobaz +/objdir/progs/foobaz/foobaz.c +/objdir/progs/foobaz/foobaz.o +/objdir/progs/fooquxfoobar/Makefile +/objdir/progs/fooquxfoobar/fooquxfoobar +/objdir/progs/fooquxfoobar/fooquxfoobar.c +/objdir/progs/fooquxfoobar/fooquxfoobar.o +/objdir/test.mk +========= install with STATICLIBS=... ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/bin/foobaz +/objdir/prefix/bin/fooquxfoobar +/objdir/prefix/include +/objdir/prefix/include/bar.h +/objdir/prefix/include/baz.h +/objdir/prefix/include/foo.h +/objdir/prefix/include/fooqux.h +/objdir/prefix/lib +/objdir/prefix/lib/libbar.a +/objdir/prefix/lib/libbar_pic.a +/objdir/prefix/lib/libbazbaz.a +/objdir/prefix/lib/libfoo.a +/objdir/prefix/lib/libfoo_pic.a +/objdir/prefix/lib/libfooqux.a +/objdir/prefix/lib/libfooqux.so +/objdir/prefix/lib/libfooqux.so.0 +/objdir/prefix/lib/libfooqux.so.0.0 +symbol foo +symbol fooqux +======= distclean ========== +/objdir/Makefile +/objdir/expect.out +/objdir/hello_libdeps.test.out.tmp +/objdir/libs/libbar/Makefile +/objdir/libs/libbar/bar.c +/objdir/libs/libbar/bar.h +/objdir/libs/libbaz/Makefile +/objdir/libs/libbaz/baz.c +/objdir/libs/libbaz/include/baz.h +/objdir/libs/libbaz/linkme.mk +/objdir/libs/libfoo/Makefile +/objdir/libs/libfoo/foo.c +/objdir/libs/libfoo/foo.h +/objdir/libs/libfoo/linkme.mk +/objdir/libs/libfooqux/Makefile +/objdir/libs/libfooqux/fooqux.c +/objdir/libs/libfooqux/fooqux.h +/objdir/progs/foobaz/Makefile +/objdir/progs/foobaz/foobaz.c +/objdir/progs/fooquxfoobar/Makefile +/objdir/progs/fooquxfoobar/fooquxfoobar.c +/objdir/test.mk diff --git a/examples/hello_libdeps/libs/libbar/Makefile b/examples/hello_libdeps/libs/libbar/Makefile new file mode 100644 index 0000000..6514a70 --- /dev/null +++ b/examples/hello_libdeps/libs/libbar/Makefile @@ -0,0 +1,9 @@ +LIB = bar +INCS = bar.h + +SHLIB_MAJOR = 0 +SHLIB_MINOR = 0 + +WARNS = 4 + +.include <mkc.mk> diff --git a/examples/hello_libdeps/libs/libbar/bar.c b/examples/hello_libdeps/libs/libbar/bar.c new file mode 100644 index 0000000..b8015fc --- /dev/null +++ b/examples/hello_libdeps/libs/libbar/bar.c @@ -0,0 +1,8 @@ +#include "bar.h" + +#include <stdio.h> + +void bar (void) +{ + puts ("I am bar"); +} diff --git a/examples/hello_libdeps/libs/libbar/bar.h b/examples/hello_libdeps/libs/libbar/bar.h new file mode 100644 index 0000000..e1d9f28 --- /dev/null +++ b/examples/hello_libdeps/libs/libbar/bar.h @@ -0,0 +1,6 @@ +#ifndef _BAR_H_ +#define _BAR_H_ + +void bar (void); + +#endif // _BAR_H_ diff --git a/examples/hello_libdeps/libs/libbaz/Makefile b/examples/hello_libdeps/libs/libbaz/Makefile new file mode 100644 index 0000000..fb96ef1 --- /dev/null +++ b/examples/hello_libdeps/libs/libbaz/Makefile @@ -0,0 +1,10 @@ +LIB = bazbaz # LIB name is not equal to ${.CURDIR:T}! +SRCS = baz.c +INCS = baz.h +INCSSRCDIR = include + +CPPFLAGS += ${INCSSRCDIR} + +WARNS = 4 + +.include <mkc.mk> diff --git a/examples/hello_libdeps/libs/libbaz/baz.c b/examples/hello_libdeps/libs/libbaz/baz.c new file mode 100644 index 0000000..e9000dc --- /dev/null +++ b/examples/hello_libdeps/libs/libbaz/baz.c @@ -0,0 +1,8 @@ +#include "baz.h" + +#include <stdio.h> + +void baz (void) +{ + puts ("I am baz"); +} diff --git a/examples/hello_libdeps/libs/libbaz/include/baz.h b/examples/hello_libdeps/libs/libbaz/include/baz.h new file mode 100644 index 0000000..3a8879c --- /dev/null +++ b/examples/hello_libdeps/libs/libbaz/include/baz.h @@ -0,0 +1,6 @@ +#ifndef _BAZ_H_ +#define _BAZ_H_ + +void baz (void); + +#endif // _BAZ_H_ diff --git a/examples/hello_libdeps/libs/libbaz/linkme.mk b/examples/hello_libdeps/libs/libbaz/linkme.mk new file mode 100644 index 0000000..8127ebd --- /dev/null +++ b/examples/hello_libdeps/libs/libbaz/linkme.mk @@ -0,0 +1,5 @@ +PATH.baz := ${.PARSEDIR:tA} + +DPINCDIRS += ${PATH.baz}/include # non-default dir for headers +DPLIBDIRS += ${OBJDIR_libs_libbaz} +DPLDADD += bazbaz # non-default library name diff --git a/examples/hello_libdeps/libs/libfoo/Makefile b/examples/hello_libdeps/libs/libfoo/Makefile new file mode 100644 index 0000000..747a9e6 --- /dev/null +++ b/examples/hello_libdeps/libs/libfoo/Makefile @@ -0,0 +1,9 @@ +LIB = foo +INCS = foo.h + +SHLIB_MAJOR = 0 +SHLIB_MINOR = 0 + +WARNS = 4 + +.include <mkc.mk> diff --git a/examples/hello_libdeps/libs/libfoo/foo.c b/examples/hello_libdeps/libs/libfoo/foo.c new file mode 100644 index 0000000..fa86b30 --- /dev/null +++ b/examples/hello_libdeps/libs/libfoo/foo.c @@ -0,0 +1,8 @@ +#include "foo.h" + +#include <stdio.h> + +void foo (void) +{ + puts ("I am foo"); +} diff --git a/examples/hello_libdeps/libs/libfoo/foo.h b/examples/hello_libdeps/libs/libfoo/foo.h new file mode 100644 index 0000000..a5bf6dd --- /dev/null +++ b/examples/hello_libdeps/libs/libfoo/foo.h @@ -0,0 +1,6 @@ +#ifndef _FOO_H_ +#define _FOO_H_ + +void foo (void); + +#endif // _FOO_H_ diff --git a/examples/hello_libdeps/libs/libfoo/linkme.mk b/examples/hello_libdeps/libs/libfoo/linkme.mk new file mode 100644 index 0000000..25e2e05 --- /dev/null +++ b/examples/hello_libdeps/libs/libfoo/linkme.mk @@ -0,0 +1 @@ +# empty linkme.mk is useless, this is a part of regression tests diff --git a/examples/hello_libdeps/libs/libfooqux/Makefile b/examples/hello_libdeps/libs/libfooqux/Makefile new file mode 100644 index 0000000..9157963 --- /dev/null +++ b/examples/hello_libdeps/libs/libfooqux/Makefile @@ -0,0 +1,9 @@ +LIB = fooqux +INCS = fooqux.h + +SHLIB_MAJOR = 0 +SHLIB_MINOR = 0 + +WARNS = 4 + +.include <mkc.mk> diff --git a/examples/hello_libdeps/libs/libfooqux/fooqux.c b/examples/hello_libdeps/libs/libfooqux/fooqux.c new file mode 100644 index 0000000..27d5225 --- /dev/null +++ b/examples/hello_libdeps/libs/libfooqux/fooqux.c @@ -0,0 +1,9 @@ +#include "fooqux.h" + +#include <stdio.h> + +void fooqux (void) +{ + foo (); + puts (" and qux"); +} diff --git a/examples/hello_libdeps/libs/libfooqux/fooqux.h b/examples/hello_libdeps/libs/libfooqux/fooqux.h new file mode 100644 index 0000000..0c4f973 --- /dev/null +++ b/examples/hello_libdeps/libs/libfooqux/fooqux.h @@ -0,0 +1,8 @@ +#ifndef _FOOQUX_H_ +#define _FOOQUX_H_ + +#include "foo.h" + +void fooqux (void); + +#endif // _FOOQUX_H_ diff --git a/examples/hello_libdeps/progs/foobaz/Makefile b/examples/hello_libdeps/progs/foobaz/Makefile new file mode 100644 index 0000000..e24d1cf --- /dev/null +++ b/examples/hello_libdeps/progs/foobaz/Makefile @@ -0,0 +1,5 @@ +PROG = foobaz + +WARNS = 4 + +.include <mkc.mk> diff --git a/examples/hello_libdeps/progs/foobaz/foobaz.c b/examples/hello_libdeps/progs/foobaz/foobaz.c new file mode 100644 index 0000000..e2cf60b --- /dev/null +++ b/examples/hello_libdeps/progs/foobaz/foobaz.c @@ -0,0 +1,11 @@ +#include "foo.h" +#include "baz.h" + +#include <stdio.h> + +int main (int argc, char **argv) +{ + foo (); + baz (); + return 0; +} diff --git a/examples/hello_libdeps/progs/fooquxfoobar/Makefile b/examples/hello_libdeps/progs/fooquxfoobar/Makefile new file mode 100644 index 0000000..5017e96 --- /dev/null +++ b/examples/hello_libdeps/progs/fooquxfoobar/Makefile @@ -0,0 +1,5 @@ +PROG = fooquxfoobar + +WARNS = 4 + +.include <mkc.mk> diff --git a/examples/hello_libdeps/progs/fooquxfoobar/fooquxfoobar.c b/examples/hello_libdeps/progs/fooquxfoobar/fooquxfoobar.c new file mode 100644 index 0000000..3d154b6 --- /dev/null +++ b/examples/hello_libdeps/progs/fooquxfoobar/fooquxfoobar.c @@ -0,0 +1,12 @@ +#include "fooqux.h" +#include "bar.h" + +#include <stdio.h> + +int main (int argc, char **argv) +{ + fooqux (); + foo (); + bar (); + return 0; +} diff --git a/examples/hello_libdeps/test.mk b/examples/hello_libdeps/test.mk new file mode 100644 index 0000000..0c9daf4 --- /dev/null +++ b/examples/hello_libdeps/test.mk @@ -0,0 +1,52 @@ +run_nm := env NM=${NM:Q} OPSYS=${OPSTS:Q} mkc_test_nm + +.PHONY : test_output +test_output: + @set -e; LC_ALL=C; export LC_ALL; \ + LD_LIBRARY_PATH=${OBJDIR_libs_libfoo}:${OBJDIR_libs_libfooqux}:${OBJDIR_libs_libbar}:${OBJDIR_libs_libbaz}; \ + DYLD_LIBRARY_PATH=$$LD_LIBRARY_PATH; \ + LIBRARY_PATH=$$LIBRARY_PATH:$$LD_LIBRARY_PATH; \ + export LD_LIBRARY_PATH DYLD_LIBRARY_PATH LIBRARY_PATH; \ + echo =========== fooquxfoobar ============; \ + ${OBJDIR_progs_fooquxfoobar}/fooquxfoobar; \ + echo =========== foobaz ============; \ + ${OBJDIR_progs_foobaz}/foobaz; \ + rm -rf ${.OBJDIR}${PREFIX}; \ + \ + echo =========== depends ============; \ + ${MAKE} ${MAKEFLAGS} -j4 depend > /dev/null; \ + mkc_long_lines `find ${.CURDIR} -type f -name .depend` | \ + awk '!/^#/ {for (i=1; i <= NF; ++i) if ($$i ~ /^\// && $$i !~ /mk-configure/) $$i = ""; print $$0; }' | \ + awk '{$$1 = $$1; gsub(/[.]o[ps]/, ".o"); print $$0}' | sort | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======= install ==========; \ + ${MAKE} ${MAKEFLAGS} install DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + rm -rf ${.OBJDIR}${PREFIX} ${.OBJDIR}/usr ${.OBJDIR}/Users ${.OBJDIR}/home; \ + \ + echo =========== all with STATICLIBS=... ============; \ + ${MAKE} ${MAKEFLAGS} distclean > /dev/null; \ + env STATICLIBS='libfoo libbar' ${MAKE} ${MAKEFLAGS} -j4 all > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= install with STATICLIBS=... ==========; \ + env STATICLIBS='libfoo libbar' ${MAKE} ${MAKEFLAGS} install DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type l -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + case ${OPSYS} in \ + *BSD|DragonFly|SunOS|Linux) \ + ${run_nm} ${OBJDIR_libfooqux}/libfooqux.so;; \ + *) \ + printf 'symbol foo\nsymbol fooqux\n';; \ + esac; \ + rm -rf ${.OBJDIR}${PREFIX} ${.OBJDIR}/usr ${.OBJDIR}/home ${.OBJDIR}/Users; \ + \ + echo ======= distclean ==========; \ + ${MAKE} ${MAKEFLAGS} distclean > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}" + +.include <mkc.minitest.mk> diff --git a/examples/hello_lua/Makefile b/examples/hello_lua/Makefile new file mode 100644 index 0000000..6bd702a --- /dev/null +++ b/examples/hello_lua/Makefile @@ -0,0 +1,13 @@ +PROJECTNAME = hello_lua + +LUA_LMODULES = foo.lua bar.lua +LUA_CMODULE = baz + +INSCRIPTS = foobar +SCRIPTS = ${INSCRIPTS} + +INTEXTS_REPLS = LUA ${PROG.lua} +MKC_REQUIRE_PROGS = lua + +.include "test.mk" +.include <mkc.lib.mk> diff --git a/examples/hello_lua/bar.lua b/examples/hello_lua/bar.lua new file mode 100644 index 0000000..2b0d8dc --- /dev/null +++ b/examples/hello_lua/bar.lua @@ -0,0 +1,5 @@ +module ("bar") + +function get () + return "bar" +end diff --git a/examples/hello_lua/baz.c b/examples/hello_lua/baz.c new file mode 100644 index 0000000..4ba942e --- /dev/null +++ b/examples/hello_lua/baz.c @@ -0,0 +1,13 @@ +#include <lua.h> + +static int baz (lua_State *L) +{ + lua_pushstring(L, "baz"); + return 1; +} + +int luaopen_baz (lua_State *L) +{ + lua_register(L, "baz", baz); + return 0; +} diff --git a/examples/hello_lua/expect.out b/examples/hello_lua/expect.out new file mode 100644 index 0000000..0e51847 --- /dev/null +++ b/examples/hello_lua/expect.out @@ -0,0 +1,132 @@ +PROJECTNAME=hello_lua +foobarbaz +=========== all ============ +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_header_lua_h.c +/objdir/_mkc_header_lua_h.err +/objdir/_mkc_header_lua_h.res +/objdir/_mkc_pkgconfig_lua.err +/objdir/_mkc_pkgconfig_lua.res +/objdir/_mkc_pkgconfig_lua_INSTALL_CMOD.err +/objdir/_mkc_pkgconfig_lua_INSTALL_CMOD.res +/objdir/_mkc_pkgconfig_lua_INSTALL_LMOD.err +/objdir/_mkc_pkgconfig_lua_INSTALL_LMOD.res +/objdir/_mkc_pkgconfig_lua_cflags.err +/objdir/_mkc_pkgconfig_lua_cflags.res +/objdir/_mkc_pkgconfig_lua_libs.err +/objdir/_mkc_pkgconfig_lua_libs.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/_mkc_prog_lua.err +/objdir/_mkc_prog_lua.res +/objdir/_mkc_prog_pkg-config.err +/objdir/_mkc_prog_pkg-config.res +/objdir/bar.lua +/objdir/baz.c +/objdir/baz.os +/objdir/baz.so +/objdir/expect.out +/objdir/foo.lua +/objdir/foobar +/objdir/foobar.in +/objdir/hello_lua.test.out.tmp +/objdir/test.mk +========= install ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/bin/foobar +/objdir/prefix/lib +/objdir/prefix/lib/lua +/objdir/prefix/lib/lua/X.Y +/objdir/prefix/lib/lua/X.Y/baz.so +/objdir/prefix/share +/objdir/prefix/share/lua +/objdir/prefix/share/lua/X.Y +/objdir/prefix/share/lua/X.Y/bar.lua +/objdir/prefix/share/lua/X.Y/foo.lua +======== uninstall ========= +========== clean =========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_header_lua_h.c +/objdir/_mkc_header_lua_h.err +/objdir/_mkc_header_lua_h.res +/objdir/_mkc_pkgconfig_lua.err +/objdir/_mkc_pkgconfig_lua.res +/objdir/_mkc_pkgconfig_lua_INSTALL_CMOD.err +/objdir/_mkc_pkgconfig_lua_INSTALL_CMOD.res +/objdir/_mkc_pkgconfig_lua_INSTALL_LMOD.err +/objdir/_mkc_pkgconfig_lua_INSTALL_LMOD.res +/objdir/_mkc_pkgconfig_lua_cflags.err +/objdir/_mkc_pkgconfig_lua_cflags.res +/objdir/_mkc_pkgconfig_lua_libs.err +/objdir/_mkc_pkgconfig_lua_libs.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/_mkc_prog_lua.err +/objdir/_mkc_prog_lua.res +/objdir/_mkc_prog_pkg-config.err +/objdir/_mkc_prog_pkg-config.res +/objdir/bar.lua +/objdir/baz.c +/objdir/expect.out +/objdir/foo.lua +/objdir/foobar.in +/objdir/hello_lua.test.out.tmp +/objdir/test.mk +======= distclean ========== +/objdir/Makefile +/objdir/bar.lua +/objdir/baz.c +/objdir/expect.out +/objdir/foo.lua +/objdir/foobar.in +/objdir/hello_lua.test.out.tmp +/objdir/test.mk +========= install2 ========== +/objdir +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_header_lua_h.c +/objdir/_mkc_header_lua_h.err +/objdir/_mkc_header_lua_h.res +/objdir/_mkc_pkgconfig_lua.err +/objdir/_mkc_pkgconfig_lua.res +/objdir/_mkc_pkgconfig_lua_cflags.err +/objdir/_mkc_pkgconfig_lua_cflags.res +/objdir/_mkc_pkgconfig_lua_libs.err +/objdir/_mkc_pkgconfig_lua_libs.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/_mkc_prog_lua.err +/objdir/_mkc_prog_lua.res +/objdir/_mkc_prog_pkg-config.err +/objdir/_mkc_prog_pkg-config.res +/objdir/bar.lua +/objdir/baz.c +/objdir/baz.os +/objdir/baz.so +/objdir/expect.out +/objdir/foo.lua +/objdir/foobar +/objdir/foobar.in +/objdir/hello_lua.test.out.tmp +/objdir/home +/objdir/home/cheusov +/objdir/home/cheusov/local +/objdir/home/cheusov/local/bin +/objdir/home/cheusov/local/bin/foobar +/objdir/home/cheusov/local/lib +/objdir/home/cheusov/local/lib/lua +/objdir/home/cheusov/local/lib/lua/X.Y +/objdir/home/cheusov/local/lib/lua/X.Y/baz.so +/objdir/home/cheusov/local/share +/objdir/home/cheusov/local/share/lua +/objdir/home/cheusov/local/share/lua/X.Y +/objdir/home/cheusov/local/share/lua/X.Y/bar.lua +/objdir/home/cheusov/local/share/lua/X.Y/foo.lua +/objdir/test.mk diff --git a/examples/hello_lua/foo.lua b/examples/hello_lua/foo.lua new file mode 100644 index 0000000..58f1ecb --- /dev/null +++ b/examples/hello_lua/foo.lua @@ -0,0 +1,5 @@ +module ("foo") + +function get () + return "foo" +end diff --git a/examples/hello_lua/foobar.in b/examples/hello_lua/foobar.in new file mode 100755 index 0000000..dd8714a --- /dev/null +++ b/examples/hello_lua/foobar.in @@ -0,0 +1,7 @@ +#!@LUA@ + +require "foo" +require "bar" +require "baz" + +io.write (foo.get () .. bar.get () .. baz () .. "\n") diff --git a/examples/hello_lua/test.mk b/examples/hello_lua/test.mk new file mode 100644 index 0000000..8b6fc91 --- /dev/null +++ b/examples/hello_lua/test.mk @@ -0,0 +1,50 @@ +CLEANDIRS += ${.OBJDIR}/home + +.PHONY : test_output +test_output: + @set -e; \ + rm -rf ${.OBJDIR}/usr ${.OBJDIR}/opt; \ + echo PROJECTNAME=${PROJECTNAME}; \ + LUA_PATH=${.CURDIR}/?.lua; \ + LUA_CPATH=${.OBJDIR}/?.so; \ + export LUA_PATH LUA_CPATH; \ + ./foobar; \ + MKCATPAGES=yes; export MKCATPAGES; \ + \ + echo =========== all ============; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= install ==========; \ + ${MAKE} ${MAKEFLAGS} install -j3 DESTDIR=${.OBJDIR} PREFIX=/usr/local \ + > /dev/null; \ + find ${.OBJDIR}/usr -type f -o -type d | \ + mkc_test_helper /usr/local "${.OBJDIR}" | uniq; \ + \ + echo ======== uninstall =========; \ + ${MAKE} ${MAKEFLAGS} -j4 uninstall DESTDIR=${.OBJDIR} PREFIX=/usr/local > /dev/null; \ + find ${.OBJDIR}/usr -type f | \ + mkc_test_helper /usr/local "${.OBJDIR}"; \ + \ + echo ========== clean ===========; \ + ${MAKE} ${MAKEFLAGS} clean > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======= distclean ==========; \ + ${MAKE} ${MAKEFLAGS} distclean > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= install2 ==========; \ + env PREFIX=/home/cheusov/local \ + LUA_LMODDIR=/home/cheusov/local/share/lua/5.1 \ + LUA_CMODDIR=/home/cheusov/local/lib/lua/5.1 \ + ${MAKE} ${MAKEFLAGS} all install -j3 DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR} -type f -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}" | uniq; \ + rm -rf ${.OBJDIR}/home; \ + ${MAKE} ${MAKEFLAGS} distclean > /dev/null + +.include <mkc.minitest.mk> diff --git a/examples/hello_lua2/Makefile b/examples/hello_lua2/Makefile new file mode 100644 index 0000000..04d6cad --- /dev/null +++ b/examples/hello_lua2/Makefile @@ -0,0 +1,5 @@ +LUA_LMODULES = foo.lua bar.lua +SCRIPTS = foobar + +.include "test.mk" +.include <mkc.prog.mk> diff --git a/examples/hello_lua2/bar.lua b/examples/hello_lua2/bar.lua new file mode 100644 index 0000000..2b0d8dc --- /dev/null +++ b/examples/hello_lua2/bar.lua @@ -0,0 +1,5 @@ +module ("bar") + +function get () + return "bar" +end diff --git a/examples/hello_lua2/expect.out b/examples/hello_lua2/expect.out new file mode 100644 index 0000000..3af692c --- /dev/null +++ b/examples/hello_lua2/expect.out @@ -0,0 +1,66 @@ +foobar +=========== all ============ +/objdir/Makefile +/objdir/_mkc_pkgconfig_lua.err +/objdir/_mkc_pkgconfig_lua.res +/objdir/_mkc_pkgconfig_lua_INSTALL_LMOD.err +/objdir/_mkc_pkgconfig_lua_INSTALL_LMOD.res +/objdir/_mkc_prog_pkg-config.err +/objdir/_mkc_prog_pkg-config.res +/objdir/bar.lua +/objdir/expect.out +/objdir/foo.lua +/objdir/foobar +/objdir/hello_lua2.test.out.tmp +/objdir/test.mk +========= install ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/bin/foobar +/objdir/prefix/share +/objdir/prefix/share/lua +/objdir/prefix/share/lua/X.Y +/objdir/prefix/share/lua/X.Y/bar.lua +/objdir/prefix/share/lua/X.Y/foo.lua +======== uninstall ========= +========== clean =========== +/objdir/Makefile +/objdir/_mkc_pkgconfig_lua.err +/objdir/_mkc_pkgconfig_lua.res +/objdir/_mkc_pkgconfig_lua_INSTALL_LMOD.err +/objdir/_mkc_pkgconfig_lua_INSTALL_LMOD.res +/objdir/_mkc_prog_pkg-config.err +/objdir/_mkc_prog_pkg-config.res +/objdir/bar.lua +/objdir/expect.out +/objdir/foo.lua +/objdir/foobar +/objdir/hello_lua2.test.out.tmp +/objdir/test.mk +======= distclean ========== +/objdir/Makefile +/objdir/bar.lua +/objdir/expect.out +/objdir/foo.lua +/objdir/foobar +/objdir/hello_lua2.test.out.tmp +/objdir/test.mk +========= install2 ========== +/objdir +/objdir/Makefile +/objdir/bar.lua +/objdir/expect.out +/objdir/foo.lua +/objdir/foobar +/objdir/hello_lua2.test.out.tmp +/objdir/home +/objdir/home/cheusov +/objdir/home/cheusov/local +/objdir/home/cheusov/local/bin +/objdir/home/cheusov/local/bin/foobar +/objdir/home/cheusov/local/share +/objdir/home/cheusov/local/share/lua +/objdir/home/cheusov/local/share/lua/X.Y +/objdir/home/cheusov/local/share/lua/X.Y/bar.lua +/objdir/home/cheusov/local/share/lua/X.Y/foo.lua +/objdir/test.mk diff --git a/examples/hello_lua2/foo.lua b/examples/hello_lua2/foo.lua new file mode 100644 index 0000000..58f1ecb --- /dev/null +++ b/examples/hello_lua2/foo.lua @@ -0,0 +1,5 @@ +module ("foo") + +function get () + return "foo" +end diff --git a/examples/hello_lua2/foobar b/examples/hello_lua2/foobar new file mode 100755 index 0000000..150da72 --- /dev/null +++ b/examples/hello_lua2/foobar @@ -0,0 +1,6 @@ +#!/usr/bin/env lua + +require "foo" +require "bar" + +io.write (foo.get () .. bar.get () .. "\n") diff --git a/examples/hello_lua2/test.mk b/examples/hello_lua2/test.mk new file mode 100644 index 0000000..0cc6d20 --- /dev/null +++ b/examples/hello_lua2/test.mk @@ -0,0 +1,48 @@ +CLEANDIRS += ${.OBJDIR}/home + +.PHONY : test_output +test_output: + @set -e; \ + rm -rf ${.OBJDIR}/usr; \ + LUA_PATH=${.CURDIR}/?.lua; \ + LUA_CPATH=${.OBJDIR}/?.so; \ + export LUA_PATH LUA_CPATH; \ + ./foobar; \ + MKCATPAGES=yes; export MKCATPAGES; \ + \ + echo =========== all ============; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= install ==========; \ + ${MAKE} ${MAKEFLAGS} install -j3 DESTDIR=${.OBJDIR} PREFIX=/usr/local \ + > /dev/null; \ + find ${.OBJDIR}/usr -type f -o -type d | \ + mkc_test_helper /usr/local "${.OBJDIR}" | uniq; \ + \ + echo ======== uninstall =========; \ + ${MAKE} ${MAKEFLAGS} -j4 uninstall DESTDIR=${.OBJDIR} PREFIX=/usr/local > /dev/null; \ + find ${.OBJDIR}/usr -type f | \ + mkc_test_helper /usr/local "${.OBJDIR}"; \ + \ + echo ========== clean ===========; \ + ${MAKE} ${MAKEFLAGS} clean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======= distclean ==========; \ + ${MAKE} ${MAKEFLAGS} distclean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= install2 ==========; \ + env PREFIX=/home/cheusov/local \ + LUA_LMODDIR=/home/cheusov/local/share/lua/5.1 \ + ${MAKE} ${MAKEFLAGS} all install -j3 DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR} -type f -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}" | uniq; \ + rm -rf ${.OBJDIR}/home; \ + ${MAKE} ${MAKEFLAGS} distclean > /dev/null + +.include <mkc.minitest.mk> diff --git a/examples/hello_lua3/Makefile b/examples/hello_lua3/Makefile new file mode 100644 index 0000000..a2a712b --- /dev/null +++ b/examples/hello_lua3/Makefile @@ -0,0 +1,7 @@ +PROJECTNAME = hello_lua3 + +LUA_MODULES = socket.foo socket.bar +LUA_CMODULE = socket.baz + +.include "test.mk" +.include <mkc.mk> diff --git a/examples/hello_lua3/expect.out b/examples/hello_lua3/expect.out new file mode 100644 index 0000000..e30135a --- /dev/null +++ b/examples/hello_lua3/expect.out @@ -0,0 +1,79 @@ +PROJECTNAME=hello_lua3 +=========== all ============ +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_header_lua_h.c +/objdir/_mkc_header_lua_h.err +/objdir/_mkc_header_lua_h.res +/objdir/_mkc_pkgconfig_lua.err +/objdir/_mkc_pkgconfig_lua.res +/objdir/_mkc_pkgconfig_lua_INSTALL_CMOD.err +/objdir/_mkc_pkgconfig_lua_INSTALL_CMOD.res +/objdir/_mkc_pkgconfig_lua_INSTALL_LMOD.err +/objdir/_mkc_pkgconfig_lua_INSTALL_LMOD.res +/objdir/_mkc_pkgconfig_lua_cflags.err +/objdir/_mkc_pkgconfig_lua_cflags.res +/objdir/_mkc_pkgconfig_lua_libs.err +/objdir/_mkc_pkgconfig_lua_libs.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/_mkc_prog_pkg-config.err +/objdir/_mkc_prog_pkg-config.res +/objdir/baz.so +/objdir/expect.out +/objdir/hello_lua3.test.out.tmp +/objdir/socket_bar.lua +/objdir/socket_baz.c +/objdir/socket_baz.os +/objdir/socket_foo.lua +/objdir/test.mk +========= install ========== +/objdir/prefix +/objdir/prefix/lib +/objdir/prefix/lib/lua +/objdir/prefix/lib/lua/X.Y +/objdir/prefix/lib/lua/X.Y/socket +/objdir/prefix/lib/lua/X.Y/socket/baz.so +/objdir/prefix/share +/objdir/prefix/share/lua +/objdir/prefix/share/lua/X.Y +/objdir/prefix/share/lua/X.Y/socket +/objdir/prefix/share/lua/X.Y/socket/bar.lua +/objdir/prefix/share/lua/X.Y/socket/foo.lua +======== uninstall ========= +========== clean =========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_header_lua_h.c +/objdir/_mkc_header_lua_h.err +/objdir/_mkc_header_lua_h.res +/objdir/_mkc_pkgconfig_lua.err +/objdir/_mkc_pkgconfig_lua.res +/objdir/_mkc_pkgconfig_lua_INSTALL_CMOD.err +/objdir/_mkc_pkgconfig_lua_INSTALL_CMOD.res +/objdir/_mkc_pkgconfig_lua_INSTALL_LMOD.err +/objdir/_mkc_pkgconfig_lua_INSTALL_LMOD.res +/objdir/_mkc_pkgconfig_lua_cflags.err +/objdir/_mkc_pkgconfig_lua_cflags.res +/objdir/_mkc_pkgconfig_lua_libs.err +/objdir/_mkc_pkgconfig_lua_libs.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/_mkc_prog_pkg-config.err +/objdir/_mkc_prog_pkg-config.res +/objdir/expect.out +/objdir/hello_lua3.test.out.tmp +/objdir/socket_bar.lua +/objdir/socket_baz.c +/objdir/socket_foo.lua +/objdir/test.mk +======= distclean ========== +/objdir/Makefile +/objdir/expect.out +/objdir/hello_lua3.test.out.tmp +/objdir/socket_bar.lua +/objdir/socket_baz.c +/objdir/socket_foo.lua +/objdir/test.mk diff --git a/examples/hello_lua3/socket_bar.lua b/examples/hello_lua3/socket_bar.lua new file mode 100644 index 0000000..2b0d8dc --- /dev/null +++ b/examples/hello_lua3/socket_bar.lua @@ -0,0 +1,5 @@ +module ("bar") + +function get () + return "bar" +end diff --git a/examples/hello_lua3/socket_baz.c b/examples/hello_lua3/socket_baz.c new file mode 100644 index 0000000..4ba942e --- /dev/null +++ b/examples/hello_lua3/socket_baz.c @@ -0,0 +1,13 @@ +#include <lua.h> + +static int baz (lua_State *L) +{ + lua_pushstring(L, "baz"); + return 1; +} + +int luaopen_baz (lua_State *L) +{ + lua_register(L, "baz", baz); + return 0; +} diff --git a/examples/hello_lua3/socket_foo.lua b/examples/hello_lua3/socket_foo.lua new file mode 100644 index 0000000..58f1ecb --- /dev/null +++ b/examples/hello_lua3/socket_foo.lua @@ -0,0 +1,5 @@ +module ("foo") + +function get () + return "foo" +end diff --git a/examples/hello_lua3/test.mk b/examples/hello_lua3/test.mk new file mode 100644 index 0000000..dfe9e9f --- /dev/null +++ b/examples/hello_lua3/test.mk @@ -0,0 +1,33 @@ +.PHONY : test_output +test_output: + @set -e; \ + rm -rf ${.OBJDIR}/usr ${.OBJDIR}/opt; \ + echo PROJECTNAME=${PROJECTNAME}; \ + MKCATPAGES=yes; export MKCATPAGES; \ + \ + echo =========== all ============; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= install ==========; \ + ${MAKE} ${MAKEFLAGS} install -j3 DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR}/usr -type f -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}" | uniq; \ + \ + echo ======== uninstall =========; \ + ${MAKE} ${MAKEFLAGS} -j4 uninstall DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}/usr -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========== clean ===========; \ + ${MAKE} ${MAKEFLAGS} clean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======= distclean ==========; \ + ${MAKE} ${MAKEFLAGS} distclean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}" + +.include <mkc.minitest.mk> diff --git a/examples/hello_plugins/Makefile b/examples/hello_plugins/Makefile new file mode 100644 index 0000000..c387e69 --- /dev/null +++ b/examples/hello_plugins/Makefile @@ -0,0 +1,4 @@ +SUBPRJ = app plugin1 plugin2 + +.include "test.mk" +.include <mkc.subprj.mk> diff --git a/examples/hello_plugins/app/Makefile b/examples/hello_plugins/app/Makefile new file mode 100644 index 0000000..5ee8501 --- /dev/null +++ b/examples/hello_plugins/app/Makefile @@ -0,0 +1,7 @@ +MKC_REQUIRE_FUNCLIBS += dlopen:dl + +PROG = app + +WARNS = 4 + +.include <mkc.prog.mk> diff --git a/examples/hello_plugins/app/app.c b/examples/hello_plugins/app/app.c new file mode 100644 index 0000000..56a3139 --- /dev/null +++ b/examples/hello_plugins/app/app.c @@ -0,0 +1,47 @@ +#include <dlfcn.h> +#include <stdlib.h> +#include <stdio.h> + +typedef void (*plugin_func_t) (void); + +int main (int argc, char **argv) +{ + void *p [10]; + plugin_func_t s [10]; + int i; + + --argc; ++argv; + + if (argc >= 10){ + argc = 10; + } + + for (i=0; i < argc; ++i){ + p [i] = dlopen (argv [i], RTLD_LAZY); + if (p [i]){ + printf ("dlopen(3) returned address: %p\n", p [i]); + }else{ + fprintf (stderr, "dlopen(3) failed: %s\n", dlerror ()); + return 1; + } + } + puts (""); + + for (i=0; i < argc; ++i){ + s [i] = (plugin_func_t) dlsym (p [i], "hello_message"); + if (s [i]){ + printf ("dlsym(3) returned address: %p\n", s [i]); + s [i] (); + }else{ + fprintf (stderr, "dlsym(3) failed: %s\n", dlerror ()); + return 1; + } + } + puts (""); + + for (i=0; i < argc; ++i){ + s [i] (); + } + + return 0; +} diff --git a/examples/hello_plugins/expect.out b/examples/hello_plugins/expect.out new file mode 100644 index 0000000..6cf181a --- /dev/null +++ b/examples/hello_plugins/expect.out @@ -0,0 +1,81 @@ +dlopen(3) returned address: 0xF00DBEAF +dlopen(3) returned address: 0xF00DBEAF + +dlsym(3) returned address: 0xF00DBEAF +Plugin1 sucessfully activated +dlsym(3) returned address: 0xF00DBEAF +Plugin1 sucessfully activated + +Plugin1 sucessfully activated +Plugin1 sucessfully activated +=========== all ============ +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_funclib_dlopen.c +/objdir/_mkc_funclib_dlopen.err +/objdir/_mkc_funclib_dlopen.res +/objdir/_mkc_funclib_dlopen_dl.c +/objdir/_mkc_funclib_dlopen_dl.err +/objdir/_mkc_funclib_dlopen_dl.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/app/Makefile +/objdir/app/app +/objdir/app/app.c +/objdir/app/app.o +/objdir/expect.out +/objdir/hello_plugins.test.out.tmp +/objdir/plugin1/Makefile +/objdir/plugin1/plugin1.c +/objdir/plugin1/plugin1.os +/objdir/plugin1/plugin1.so +/objdir/plugin2/Makefile +/objdir/plugin2/plugin2.c +/objdir/plugin2/plugin2.os +/objdir/plugin2/plugin2.so +/objdir/test.mk +========= install ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/bin/app +/objdir/prefix/lib +/objdir/prefix/lib/plugin1.so +/objdir/prefix/lib/plugin2.so +======== uninstall ========= +======== filelist ========== +/usr/local/bin/app +/usr/local/lib/plugin1.so +/usr/local/lib/plugin2.so +========== clean =========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_funclib_dlopen.c +/objdir/_mkc_funclib_dlopen.err +/objdir/_mkc_funclib_dlopen.res +/objdir/_mkc_funclib_dlopen_dl.c +/objdir/_mkc_funclib_dlopen_dl.err +/objdir/_mkc_funclib_dlopen_dl.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/app/Makefile +/objdir/app/app.c +/objdir/expect.out +/objdir/hello_plugins.test.out.tmp +/objdir/plugin1/Makefile +/objdir/plugin1/plugin1.c +/objdir/plugin2/Makefile +/objdir/plugin2/plugin2.c +/objdir/test.mk +======= distclean ========== +/objdir/Makefile +/objdir/app/Makefile +/objdir/app/app.c +/objdir/expect.out +/objdir/hello_plugins.test.out.tmp +/objdir/plugin1/Makefile +/objdir/plugin1/plugin1.c +/objdir/plugin2/Makefile +/objdir/plugin2/plugin2.c +/objdir/test.mk diff --git a/examples/hello_plugins/plugin1/Makefile b/examples/hello_plugins/plugin1/Makefile new file mode 100644 index 0000000..e0ae7b9 --- /dev/null +++ b/examples/hello_plugins/plugin1/Makefile @@ -0,0 +1,5 @@ +LIB = plugin1 + +MKDLL = only + +.include <mkc.lib.mk> diff --git a/examples/hello_plugins/plugin1/plugin1.c b/examples/hello_plugins/plugin1/plugin1.c new file mode 100644 index 0000000..6281410 --- /dev/null +++ b/examples/hello_plugins/plugin1/plugin1.c @@ -0,0 +1,8 @@ +#include <stdio.h> + +void hello_message (void); + +void hello_message (void) +{ + puts ("Plugin1 sucessfully activated"); +} diff --git a/examples/hello_plugins/plugin2/Makefile b/examples/hello_plugins/plugin2/Makefile new file mode 100644 index 0000000..bf870b3 --- /dev/null +++ b/examples/hello_plugins/plugin2/Makefile @@ -0,0 +1,5 @@ +LIB = plugin2 + +MKDLL = only + +.include <mkc.lib.mk> diff --git a/examples/hello_plugins/plugin2/plugin2.c b/examples/hello_plugins/plugin2/plugin2.c new file mode 100644 index 0000000..6e9a026 --- /dev/null +++ b/examples/hello_plugins/plugin2/plugin2.c @@ -0,0 +1,8 @@ +#include <stdio.h> + +void hello_message (void); + +void hello_message (void) +{ + puts ("Plugin2 sucessfully activated"); +} diff --git a/examples/hello_plugins/test.mk b/examples/hello_plugins/test.mk new file mode 100644 index 0000000..9325880 --- /dev/null +++ b/examples/hello_plugins/test.mk @@ -0,0 +1,37 @@ +.PHONY : test_output +test_output: + @set -e; LC_ALL=C; export LC_ALL; \ + rm -rf ${.OBJDIR}${PREFIX}; \ + app/app plugin1/plugin1${DLL_EXT} plugin1/plugin1${DLL_EXT} | \ + awk '$$3 == "address:" {$$4 = "0xF00DBEAF"} {print}'; \ + MKCATPAGES=yes; export MKCATPAGES; \ + \ + echo =========== all ============; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= install ==========; \ + ${MAKE} ${MAKEFLAGS} install -j3 DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======== uninstall =========; \ + ${MAKE} ${MAKEFLAGS} -j4 uninstall DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ======== filelist ==========; \ + ${MAKE} ${MAKEFLAGS} PREFIX=/usr/local filelist | sed 's/[.]bundle/.so/'; \ + \ + echo ========== clean ===========; \ + ${MAKE} ${MAKEFLAGS} clean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ======= distclean ==========; \ + ${MAKE} ${MAKEFLAGS} distclean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}" + +.include <mkc.minitest.mk> diff --git a/examples/hello_plugins2/Makefile b/examples/hello_plugins2/Makefile new file mode 100644 index 0000000..c387e69 --- /dev/null +++ b/examples/hello_plugins2/Makefile @@ -0,0 +1,4 @@ +SUBPRJ = app plugin1 plugin2 + +.include "test.mk" +.include <mkc.subprj.mk> diff --git a/examples/hello_plugins2/app/Makefile b/examples/hello_plugins2/app/Makefile new file mode 100644 index 0000000..772b965 --- /dev/null +++ b/examples/hello_plugins2/app/Makefile @@ -0,0 +1,7 @@ +PROG = app +WARNS = 4 + +MKC_FEATURES += libdl +EXPORT_DYNAMIC = yes + +.include <mkc.prog.mk> diff --git a/examples/hello_plugins2/app/app.c b/examples/hello_plugins2/app/app.c new file mode 100644 index 0000000..caa41a6 --- /dev/null +++ b/examples/hello_plugins2/app/app.c @@ -0,0 +1,47 @@ +#include <dlfcn.h> +#include <stdlib.h> +#include <stdio.h> + +typedef void (*plugin_func_t) (void); + +/* Function "putter" is for plugins only, it is not used by + application. On some platforms it is not exported by default, this + is why EXPORT_DYNAMIC is set to "yes" +*/ +void putter (char *s); +void putter (char *s) +{ + printf ("%s\n", s); +} + +int main (int argc, char **argv) +{ + void *pd; + plugin_func_t f; + int i; + + --argc; ++argv; + + for (i=0; i < argc; ++i){ + pd = dlopen (argv [i], RTLD_LAZY); + if (!pd){ + fprintf (stderr, "dlopen(3) failed: %s\n", dlerror ()); + return 1; + } + + f = (plugin_func_t) dlsym (pd, "print_message"); + if (!f){ + fprintf (stderr, "dlsym(3) failed: %s\n", dlerror ()); + return 1; + } + + f (); + + if (dlclose (pd)){ + fprintf (stderr, "dlclose(3) failed: %s\n", dlerror ()); + return 1; + } + } + + return 0; +} diff --git a/examples/hello_plugins2/expect.out b/examples/hello_plugins2/expect.out new file mode 100644 index 0000000..67dfd9e --- /dev/null +++ b/examples/hello_plugins2/expect.out @@ -0,0 +1,75 @@ +Plugin1 sucessfully activated +Plugin2 sucessfully activated +=========== all ============ +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_func2_dlopen_dlfcn_h.c +/objdir/_mkc_func2_dlopen_dlfcn_h.err +/objdir/_mkc_func2_dlopen_dlfcn_h.res +/objdir/_mkc_funclib_dlopen.c +/objdir/_mkc_funclib_dlopen.err +/objdir/_mkc_funclib_dlopen.res +/objdir/_mkc_funclib_dlopen_dl.c +/objdir/_mkc_funclib_dlopen_dl.err +/objdir/_mkc_funclib_dlopen_dl.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/app/Makefile +/objdir/app/app +/objdir/app/app.c +/objdir/app/app.o +/objdir/expect.out +/objdir/hello_plugins2.test.out.tmp +/objdir/plugin1/Makefile +/objdir/plugin1/plugin1.c +/objdir/plugin1/plugin1.os +/objdir/plugin1/plugin1.so +/objdir/plugin2/Makefile +/objdir/plugin2/plugin2.c +/objdir/plugin2/plugin2.os +/objdir/plugin2/plugin2.so +/objdir/test.mk +========= install ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/bin/app +/objdir/prefix/lib +/objdir/prefix/lib/plugin1.so +/objdir/prefix/lib/plugin2.so +======== uninstall ========= +========== clean =========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_func2_dlopen_dlfcn_h.c +/objdir/_mkc_func2_dlopen_dlfcn_h.err +/objdir/_mkc_func2_dlopen_dlfcn_h.res +/objdir/_mkc_funclib_dlopen.c +/objdir/_mkc_funclib_dlopen.err +/objdir/_mkc_funclib_dlopen.res +/objdir/_mkc_funclib_dlopen_dl.c +/objdir/_mkc_funclib_dlopen_dl.err +/objdir/_mkc_funclib_dlopen_dl.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/app/Makefile +/objdir/app/app.c +/objdir/expect.out +/objdir/hello_plugins2.test.out.tmp +/objdir/plugin1/Makefile +/objdir/plugin1/plugin1.c +/objdir/plugin2/Makefile +/objdir/plugin2/plugin2.c +/objdir/test.mk +======= distclean ========== +/objdir/Makefile +/objdir/app/Makefile +/objdir/app/app.c +/objdir/expect.out +/objdir/hello_plugins2.test.out.tmp +/objdir/plugin1/Makefile +/objdir/plugin1/plugin1.c +/objdir/plugin2/Makefile +/objdir/plugin2/plugin2.c +/objdir/test.mk diff --git a/examples/hello_plugins2/plugin1/Makefile b/examples/hello_plugins2/plugin1/Makefile new file mode 100644 index 0000000..e0ae7b9 --- /dev/null +++ b/examples/hello_plugins2/plugin1/Makefile @@ -0,0 +1,5 @@ +LIB = plugin1 + +MKDLL = only + +.include <mkc.lib.mk> diff --git a/examples/hello_plugins2/plugin1/plugin1.c b/examples/hello_plugins2/plugin1/plugin1.c new file mode 100644 index 0000000..8206be6 --- /dev/null +++ b/examples/hello_plugins2/plugin1/plugin1.c @@ -0,0 +1,7 @@ +extern void putter (const char*); +void print_message (void); + +void print_message (void) +{ + putter ("Plugin1 sucessfully activated"); +} diff --git a/examples/hello_plugins2/plugin2/Makefile b/examples/hello_plugins2/plugin2/Makefile new file mode 100644 index 0000000..bf870b3 --- /dev/null +++ b/examples/hello_plugins2/plugin2/Makefile @@ -0,0 +1,5 @@ +LIB = plugin2 + +MKDLL = only + +.include <mkc.lib.mk> diff --git a/examples/hello_plugins2/plugin2/plugin2.c b/examples/hello_plugins2/plugin2/plugin2.c new file mode 100644 index 0000000..2f1d75e --- /dev/null +++ b/examples/hello_plugins2/plugin2/plugin2.c @@ -0,0 +1,7 @@ +extern void putter (const char*); +void print_message (void); + +void print_message (void) +{ + putter ("Plugin2 sucessfully activated"); +} diff --git a/examples/hello_plugins2/test.mk b/examples/hello_plugins2/test.mk new file mode 100644 index 0000000..551cb99 --- /dev/null +++ b/examples/hello_plugins2/test.mk @@ -0,0 +1,33 @@ +.PHONY : test_output +test_output: + @set -e; LC_ALL=C; export LC_ALL; \ + rm -rf ${.OBJDIR}${PREFIX}; \ + app/app plugin1/plugin1${DLL_EXT} plugin2/plugin2${DLL_EXT}; \ + MKCATPAGES=yes; export MKCATPAGES; \ + \ + echo =========== all ============; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= install ==========; \ + ${MAKE} ${MAKEFLAGS} install -j3 DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======== uninstall =========; \ + ${MAKE} ${MAKEFLAGS} -j4 uninstall DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ========== clean ===========; \ + ${MAKE} ${MAKEFLAGS} clean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ======= distclean ==========; \ + ${MAKE} ${MAKEFLAGS} distclean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}" + +.include <mkc.minitest.mk> diff --git a/examples/hello_progs/Makefile b/examples/hello_progs/Makefile new file mode 100644 index 0000000..d43cfc6 --- /dev/null +++ b/examples/hello_progs/Makefile @@ -0,0 +1,8 @@ +PROGS = client server +SRCS.client = client.c client_puts.c +SRCS.server = server.c server_puts.c + +WARNS = 4 + +.include "test.mk" +.include <mkc.prog.mk> diff --git a/examples/hello_progs/client.c b/examples/hello_progs/client.c new file mode 100644 index 0000000..315873a --- /dev/null +++ b/examples/hello_progs/client.c @@ -0,0 +1,7 @@ +void puts_stdout (const char *); + +int main (int argc, char **argv) +{ + puts_stdout ("I am a client"); + return 0; +} diff --git a/examples/hello_progs/client_puts.c b/examples/hello_progs/client_puts.c new file mode 100644 index 0000000..341b206 --- /dev/null +++ b/examples/hello_progs/client_puts.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +void puts_stdout (const char *); + +void puts_stdout (const char *s) +{ + printf ("client: "); + puts (s); +} diff --git a/examples/hello_progs/expect.out b/examples/hello_progs/expect.out new file mode 100644 index 0000000..8a7e171 --- /dev/null +++ b/examples/hello_progs/expect.out @@ -0,0 +1,110 @@ +PROJECTNAME=hello_progs +client: I am a client +server: I am a server +=========== all ============ +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/client +/objdir/client.c +/objdir/client.o +/objdir/client_puts.c +/objdir/client_puts.o +/objdir/expect.out +/objdir/hello_progs.test.out.tmp +/objdir/server +/objdir/server.c +/objdir/server.o +/objdir/server_puts.c +/objdir/server_puts.o +/objdir/test.mk +========= install ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/bin/client +/objdir/prefix/bin/server +======== uninstall ========= +========== clean =========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/client.c +/objdir/client_puts.c +/objdir/expect.out +/objdir/hello_progs.test.out.tmp +/objdir/server.c +/objdir/server_puts.c +/objdir/test.mk +========== depend =========== +/objdir/.depend +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/client.c +/objdir/client.d +/objdir/client_puts.c +/objdir/client_puts.d +/objdir/expect.out +/objdir/hello_progs.test.out.tmp +/objdir/server.c +/objdir/server.d +/objdir/server_puts.c +/objdir/server_puts.d +/objdir/test.mk +========== server =========== +/objdir/.depend +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/client.c +/objdir/client.d +/objdir/client_puts.c +/objdir/client_puts.d +/objdir/expect.out +/objdir/hello_progs.test.out.tmp +/objdir/server +/objdir/server.c +/objdir/server.d +/objdir/server.o +/objdir/server_puts.c +/objdir/server_puts.d +/objdir/server_puts.o +/objdir/test.mk +========== client =========== +/objdir/.depend +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/client +/objdir/client.c +/objdir/client.d +/objdir/client.o +/objdir/client_puts.c +/objdir/client_puts.d +/objdir/client_puts.o +/objdir/expect.out +/objdir/hello_progs.test.out.tmp +/objdir/server.c +/objdir/server.d +/objdir/server_puts.c +/objdir/server_puts.d +/objdir/test.mk +======= distclean ========== +/objdir/Makefile +/objdir/client.c +/objdir/client_puts.c +/objdir/expect.out +/objdir/hello_progs.test.out.tmp +/objdir/server.c +/objdir/server_puts.c +/objdir/test.mk diff --git a/examples/hello_progs/server.c b/examples/hello_progs/server.c new file mode 100644 index 0000000..ff29cc9 --- /dev/null +++ b/examples/hello_progs/server.c @@ -0,0 +1,7 @@ +void puts_stdout (const char *); + +int main (int argc, char **argv) +{ + puts_stdout ("I am a server"); + return 0; +} diff --git a/examples/hello_progs/server_puts.c b/examples/hello_progs/server_puts.c new file mode 100644 index 0000000..9649361 --- /dev/null +++ b/examples/hello_progs/server_puts.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +void puts_stdout (const char *); + +void puts_stdout (const char *s) +{ + printf ("server: "); + puts (s); +} diff --git a/examples/hello_progs/test.mk b/examples/hello_progs/test.mk new file mode 100644 index 0000000..a0741ca --- /dev/null +++ b/examples/hello_progs/test.mk @@ -0,0 +1,51 @@ +.PHONY : test_output +test_output: + @set -e; \ + echo PROJECTNAME=${PROJECTNAME}; \ + ${.OBJDIR}/client; \ + ${.OBJDIR}/server; \ + rm -rf ${.OBJDIR}${PREFIX}; \ + MKCATPAGES=yes; export MKCATPAGES; \ + \ + echo =========== all ============; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= install ==========; \ + ${MAKE} ${MAKEFLAGS} install -j3 DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======== uninstall =========; \ + ${MAKE} ${MAKEFLAGS} -j4 uninstall DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ========== clean ===========; \ + ${MAKE} ${MAKEFLAGS} clean > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ========== depend ===========; \ + ${MAKE} ${MAKEFLAGS} depend > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ========== server ===========; \ + ${MAKE} ${MAKEFLAGS} server > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ========== client ===========; \ + ${MAKE} ${MAKEFLAGS} clean > /dev/null; \ + ${MAKE} ${MAKEFLAGS} client > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ======= distclean ==========; \ + ${MAKE} ${MAKEFLAGS} distclean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}" + +.include <mkc.minitest.mk> diff --git a/examples/hello_progs2/Makefile b/examples/hello_progs2/Makefile new file mode 100644 index 0000000..f1f361b --- /dev/null +++ b/examples/hello_progs2/Makefile @@ -0,0 +1,9 @@ +PROGS = client server +SRCS.client = client.c +SRCS.server = server.c +SRCS = common.c + +WARNS = 4 + +.include "test.mk" +.include <mkc.prog.mk> diff --git a/examples/hello_progs2/client.c b/examples/hello_progs2/client.c new file mode 100644 index 0000000..315873a --- /dev/null +++ b/examples/hello_progs2/client.c @@ -0,0 +1,7 @@ +void puts_stdout (const char *); + +int main (int argc, char **argv) +{ + puts_stdout ("I am a client"); + return 0; +} diff --git a/examples/hello_progs2/common.c b/examples/hello_progs2/common.c new file mode 100644 index 0000000..3183ce1 --- /dev/null +++ b/examples/hello_progs2/common.c @@ -0,0 +1,8 @@ +#include <stdio.h> + +void puts_stdout (const char *); + +void puts_stdout (const char *s) +{ + puts (s); +} diff --git a/examples/hello_progs2/expect.out b/examples/hello_progs2/expect.out new file mode 100644 index 0000000..a2a37e1 --- /dev/null +++ b/examples/hello_progs2/expect.out @@ -0,0 +1,76 @@ +PROJECTNAME=hello_progs2 +I am a client +I am a server +=========== all ============ +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/client +/objdir/client.c +/objdir/client.o +/objdir/common.c +/objdir/common.o +/objdir/expect.out +/objdir/hello_progs2.test.out.tmp +/objdir/server +/objdir/server.c +/objdir/server.o +/objdir/test.mk +========= install ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/bin/client +/objdir/prefix/bin/server +======== uninstall ========= +========== clean =========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/client.c +/objdir/common.c +/objdir/expect.out +/objdir/hello_progs2.test.out.tmp +/objdir/server.c +/objdir/test.mk +========== server =========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/client.c +/objdir/common.c +/objdir/common.o +/objdir/expect.out +/objdir/hello_progs2.test.out.tmp +/objdir/server +/objdir/server.c +/objdir/server.o +/objdir/test.mk +========== client =========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/client +/objdir/client.c +/objdir/client.o +/objdir/common.c +/objdir/common.o +/objdir/expect.out +/objdir/hello_progs2.test.out.tmp +/objdir/server.c +/objdir/test.mk +======= distclean ========== +/objdir/Makefile +/objdir/client.c +/objdir/common.c +/objdir/expect.out +/objdir/hello_progs2.test.out.tmp +/objdir/server.c +/objdir/test.mk diff --git a/examples/hello_progs2/server.c b/examples/hello_progs2/server.c new file mode 100644 index 0000000..ff29cc9 --- /dev/null +++ b/examples/hello_progs2/server.c @@ -0,0 +1,7 @@ +void puts_stdout (const char *); + +int main (int argc, char **argv) +{ + puts_stdout ("I am a server"); + return 0; +} diff --git a/examples/hello_progs2/test.mk b/examples/hello_progs2/test.mk new file mode 100644 index 0000000..85cd685 --- /dev/null +++ b/examples/hello_progs2/test.mk @@ -0,0 +1,46 @@ +.PHONY : test_output +test_output: + @set -e; \ + echo PROJECTNAME=${PROJECTNAME}; \ + ${.OBJDIR}/client; \ + ${.OBJDIR}/server; \ + rm -rf ${.OBJDIR}${PREFIX}; \ + MKCATPAGES=yes; export MKCATPAGES; \ + \ + echo =========== all ============; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= install ==========; \ + ${MAKE} ${MAKEFLAGS} install -j3 DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======== uninstall =========; \ + ${MAKE} ${MAKEFLAGS} -j4 uninstall DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ========== clean ===========; \ + ${MAKE} ${MAKEFLAGS} clean > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ========== server ===========; \ + ${MAKE} ${MAKEFLAGS} server > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ========== client ===========; \ + ${MAKE} ${MAKEFLAGS} clean > /dev/null; \ + ${MAKE} ${MAKEFLAGS} client > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ======= distclean ==========; \ + ${MAKE} ${MAKEFLAGS} distclean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}" + +.include <mkc.minitest.mk> diff --git a/examples/hello_require_tools/Makefile b/examples/hello_require_tools/Makefile new file mode 100644 index 0000000..ee953c5 --- /dev/null +++ b/examples/hello_require_tools/Makefile @@ -0,0 +1,12 @@ +MKC_REQUIRE_BUILTINS += prog_gawk prog_flex prog_gm4 prog_bison prog_gmake + +SCRIPTS = fake + +test: errorcheck + @echo GNU awk: ${CUSTOM.prog_gawk} + @echo GNU m4: ${CUSTOM.prog_gm4} + @echo GNU make: ${CUSTOM.prog_gmake} + @echo flex: ${CUSTOM.prog_flex} + @echo bison: ${CUSTOM.prog_bison} + +.include <mkc.prog.mk> diff --git a/examples/hello_require_tools/fake b/examples/hello_require_tools/fake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/examples/hello_require_tools/fake diff --git a/examples/hello_requirements/Makefile b/examples/hello_requirements/Makefile new file mode 100644 index 0000000..242f22a --- /dev/null +++ b/examples/hello_requirements/Makefile @@ -0,0 +1,20 @@ +PROG = hello_reqs + +WARNS = 4 + +MKC_REQUIRE_HEADERS = foobar.h string.h unistd.h +MKC_REQUIRE_FUNCLIBS = strcasecmp foobar barbaz:z +MKC_REQUIRE_DEFINES = FOOBAR +MKC_REQUIRE_TYPES = long size_t:string.h foobar_t barbaz:string.h +MKC_REQUIRE_VARS = errno:errno.h foobar_var barbaz:unistd.h +MKC_REQUIRE_MEMBERS = struct-tm.tm_isdst:time.h \ + struct-bad.member:stdlib.h +MKC_REQUIRE_FUNCS2 = strcmp:string.h foobar:stdlib.h +MKC_REQUIRE_FUNCS9 = barbaz +MKC_REQUIRE_PROGS = sh awk foobar_prog +MKC_REQUIRE_CUSTOM = custom_check1 custom_check2 + +MKC_REQD = 0.11.0 + +.include "test.mk" +.include <mkc.prog.mk> diff --git a/examples/hello_requirements/custom_check1.c b/examples/hello_requirements/custom_check1.c new file mode 100644 index 0000000..975a3b3 --- /dev/null +++ b/examples/hello_requirements/custom_check1.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main (int argc, char **argv) +{ + puts ("Hello World!"); + return 0; +} diff --git a/examples/hello_requirements/custom_check2.c b/examples/hello_requirements/custom_check2.c new file mode 100644 index 0000000..7c32983 --- /dev/null +++ b/examples/hello_requirements/custom_check2.c @@ -0,0 +1,3 @@ +#include <stdin.h> + +bad code here diff --git a/examples/hello_requirements/expect.out b/examples/hello_requirements/expect.out new file mode 100644 index 0000000..2336dad --- /dev/null +++ b/examples/hello_requirements/expect.out @@ -0,0 +1,40 @@ +checking for compiler type... known ;-) +checking for header foobar.h... no +checking for header string.h... yes +checking for header unistd.h... yes +checking for function strcasecmp... yes +checking for function foobar... no +checking for function barbaz ( -lz )... no +checking for function barbaz... no +checking for define FOOBAR... no +checking for type long... yes +checking for type size_t ( string.h )... yes +checking for type foobar_t... no +checking for type barbaz ( string.h )... no +checking for variable errno ( errno.h )... yes +checking for variable foobar_var... no +checking for variable barbaz ( unistd.h )... no +checking for member struct tm.tm_isdst ( time.h )... yes +checking for member struct bad.member ( stdlib.h )... no +checking for func strcmp ( string.h )... yes +checking for func foobar ( stdlib.h )... no +checking for func barbaz... no +checking for custom test custom_check1... 1 (yes) +checking for custom test custom_check2... 0 (no) +checking for program FOOBAR... /path/to/FOOBAR +checking for program FOOBAR... /path/to/FOOBAR +checking for program FOOBAR... NOT FOUND +checking for program FOOBAR... /path/to/FOOBAR +ERROR: cannot find header foobar.h +ERROR: cannot find function foobar +ERROR: cannot find function barbaz:z +ERROR: cannot find declaration of define FOOBAR +ERROR: cannot find declaration of type foobar_t +ERROR: cannot find declaration of type barbaz:string.h +ERROR: cannot find declaration of variable foobar_var +ERROR: cannot find declaration of variable barbaz:unistd.h +ERROR: cannot find member struct-bad.member:stdlib.h +ERROR: cannot find declaration of function foobar:stdlib.h +ERROR: cannot find declaration of function barbaz +ERROR: custom test custom_check2 failed +ERROR: cannot find program foobar_prog diff --git a/examples/hello_requirements/hello_world.c b/examples/hello_requirements/hello_world.c new file mode 100644 index 0000000..3d8f214 --- /dev/null +++ b/examples/hello_requirements/hello_world.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main (int argc, char** argv) +{ + puts ("Hello World!"); + return 0; +} diff --git a/examples/hello_requirements/test.mk b/examples/hello_requirements/test.mk new file mode 100644 index 0000000..f023e14 --- /dev/null +++ b/examples/hello_requirements/test.mk @@ -0,0 +1,12 @@ +.PHONY : test +test: + ${MAKE} distclean; \ + ${MAKE} all 2>&1 | \ + sed -e 's|for program .*[.][.][.]*|for program FOOBAR...|' \ + -e 's|[.][.][.] /[^ ]*|... /path/to/FOOBAR|' \ + -e 's/for compiler type.*$$/for compiler type... known ;-)/' | \ + awk '/Error code/ {exit 0} {print}' >${.OBJDIR}/_output.tmp; \ + diff ${.CURDIR}/expect.out ${.OBJDIR}/_output.tmp; \ + ${MAKE} distclean + +CLEANFILES+= _output.tmp diff --git a/examples/hello_scripts/Makefile b/examples/hello_scripts/Makefile new file mode 100644 index 0000000..005f212 --- /dev/null +++ b/examples/hello_scripts/Makefile @@ -0,0 +1,25 @@ +PROG = hello_world1 +SRCS = main.c msg.c + +WARNS = 4 + +INSCRIPTS = hello_world3 +SCRIPTS = hello_world2 ${INSCRIPTS} +SCRIPTS += ${:!echo more_scripts/*!:N*/CVS} + +SCRIPTSDIR_more_scripts_script1 = ${BINDIR}/subdir1 + +SCRIPTSNAME_more_scripts_script2 = myscript2 + +SCRIPTSDIR_more_scripts_script3 = ${BINDIR}/subdir3 +SCRIPTSNAME_more_scripts_script3 = myscript3 + +MKC_REQUIRE_PROGS = awk +INTEXTS_REPLS = AWK ${PROG.awk} + +MAN = hello_world.1 + +MKC_REQD = 0.10.0 + +.include "test.mk" +.include <mkc.prog.mk> diff --git a/examples/hello_scripts/expect.out b/examples/hello_scripts/expect.out new file mode 100644 index 0000000..fedcafd --- /dev/null +++ b/examples/hello_scripts/expect.out @@ -0,0 +1,99 @@ +Hello World 1! +Hello World 2! +Hello World 3! +=========== all ============ +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_awk.err +/objdir/_mkc_prog_awk.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/expect.out +/objdir/hello_scripts.test.out.tmp +/objdir/hello_world.1 +/objdir/hello_world1 +/objdir/hello_world2 +/objdir/hello_world3 +/objdir/hello_world3.in +/objdir/main.c +/objdir/main.o +/objdir/more_scripts/script1 +/objdir/more_scripts/script2 +/objdir/more_scripts/script3 +/objdir/msg.c +/objdir/msg.o +/objdir/test.mk +========= install ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/bin/hello_world1 +/objdir/prefix/bin/hello_world2 +/objdir/prefix/bin/hello_world3 +/objdir/prefix/bin/myscript2 +/objdir/prefix/bin/subdir1 +/objdir/prefix/bin/subdir1/script1 +/objdir/prefix/bin/subdir3 +/objdir/prefix/bin/subdir3/myscript3 +/objdir/prefix/man +/objdir/prefix/man/cat1 +/objdir/prefix/man/cat1/hello_world.0 +/objdir/prefix/man/man1 +/objdir/prefix/man/man1/hello_world.1 +======== uninstall ========= +========== clean =========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_awk.err +/objdir/_mkc_prog_awk.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/expect.out +/objdir/hello_scripts.test.out.tmp +/objdir/hello_world.1 +/objdir/hello_world2 +/objdir/hello_world3.in +/objdir/main.c +/objdir/more_scripts/script1 +/objdir/more_scripts/script2 +/objdir/more_scripts/script3 +/objdir/msg.c +/objdir/test.mk +======= distclean ========== +/objdir/Makefile +/objdir/expect.out +/objdir/hello_scripts.test.out.tmp +/objdir/hello_world.1 +/objdir/hello_world2 +/objdir/hello_world3.in +/objdir/main.c +/objdir/more_scripts/script1 +/objdir/more_scripts/script2 +/objdir/more_scripts/script3 +/objdir/msg.c +/objdir/test.mk +==== install MKINSTALL=no ==== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_awk.err +/objdir/_mkc_prog_awk.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/expect.out +/objdir/hello_scripts.test.out.tmp +/objdir/hello_world.1 +/objdir/hello_world.cat1 +/objdir/hello_world1 +/objdir/hello_world2 +/objdir/hello_world3 +/objdir/hello_world3.in +/objdir/main.c +/objdir/main.o +/objdir/more_scripts/script1 +/objdir/more_scripts/script2 +/objdir/more_scripts/script3 +/objdir/msg.c +/objdir/msg.o +/objdir/test.mk diff --git a/examples/hello_scripts/hello_world.1 b/examples/hello_scripts/hello_world.1 new file mode 100644 index 0000000..8817536 --- /dev/null +++ b/examples/hello_scripts/hello_world.1 @@ -0,0 +1,13 @@ +.\" Written by by Aleksey Cheusov (vle@gmx.net) +.\" ------------------------------------------------------------------ +.TH HELLO_WORLD 1 "Mar 29, 2009" "" "" +.SH NAME +hello\_world \- hello application +.SH SYNOPSIS +.B "hello_world" +.br +.SH DESCRIPTION +.B hello\_world +outputs hello world message to stdout +.SH AUTHOR +Aleksey Cheusov <vle@gmx.net> diff --git a/examples/hello_scripts/hello_world2 b/examples/hello_scripts/hello_world2 new file mode 100755 index 0000000..7441be2 --- /dev/null +++ b/examples/hello_scripts/hello_world2 @@ -0,0 +1,3 @@ +#!/bin/sh + +echo 'Hello World 2!' diff --git a/examples/hello_scripts/hello_world3.in b/examples/hello_scripts/hello_world3.in new file mode 100755 index 0000000..86dcd79 --- /dev/null +++ b/examples/hello_scripts/hello_world3.in @@ -0,0 +1,6 @@ +#!@AWK@ -f + +BEGIN { + print "Hello World 3!" + exit 0 +} diff --git a/examples/hello_scripts/main.c b/examples/hello_scripts/main.c new file mode 100644 index 0000000..9e85a32 --- /dev/null +++ b/examples/hello_scripts/main.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +extern const char *msg; + +int main (int argc, char **argv) +{ + puts (msg); + return 0; +} diff --git a/examples/hello_scripts/more_scripts/script1 b/examples/hello_scripts/more_scripts/script1 new file mode 100755 index 0000000..1e5757e --- /dev/null +++ b/examples/hello_scripts/more_scripts/script1 @@ -0,0 +1,3 @@ +#!/bin/sh + +echo 'script1' diff --git a/examples/hello_scripts/more_scripts/script2 b/examples/hello_scripts/more_scripts/script2 new file mode 100755 index 0000000..1f1db9d --- /dev/null +++ b/examples/hello_scripts/more_scripts/script2 @@ -0,0 +1,3 @@ +#!/bin/sh + +echo 'script2' diff --git a/examples/hello_scripts/more_scripts/script3 b/examples/hello_scripts/more_scripts/script3 new file mode 100755 index 0000000..2b1510e --- /dev/null +++ b/examples/hello_scripts/more_scripts/script3 @@ -0,0 +1,3 @@ +#!/bin/sh + +echo 'script3' diff --git a/examples/hello_scripts/msg.c b/examples/hello_scripts/msg.c new file mode 100644 index 0000000..5258623 --- /dev/null +++ b/examples/hello_scripts/msg.c @@ -0,0 +1 @@ +const char *msg = "Hello World 1!"; diff --git a/examples/hello_scripts/test.mk b/examples/hello_scripts/test.mk new file mode 100644 index 0000000..5449f8a --- /dev/null +++ b/examples/hello_scripts/test.mk @@ -0,0 +1,46 @@ +.PHONY : test_output +test_output: + @set -e; \ + ${.OBJDIR}/hello_world1; \ + ${.CURDIR}/hello_world2; \ + ${.CURDIR}/hello_world3; \ + \ + MKCATPAGES=yes; export MKCATPAGES; \ + rm -rf ${.OBJDIR}${PREFIX}; \ + \ + echo =========== all ============; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= install ==========; \ + ${MAKE} ${MAKEFLAGS} install -j3 DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======== uninstall =========; \ + ${MAKE} ${MAKEFLAGS} -j4 uninstall DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========== clean ===========; \ + ${MAKE} ${MAKEFLAGS} clean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======= distclean ==========; \ + ${MAKE} ${MAKEFLAGS} distclean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ==== install MKINSTALL=no ====; \ + MKINSTALL=no; export MKINSTALL; \ + ${MAKE} ${MAKEFLAGS} -j4 all installdirs install -j3 DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + true ======= distclean ==========; \ + ${MAKE} ${MAKEFLAGS} distclean > /dev/null + +.include <mkc.minitest.mk> diff --git a/examples/hello_sizeof/Makefile b/examples/hello_sizeof/Makefile new file mode 100644 index 0000000..e9ccadb --- /dev/null +++ b/examples/hello_sizeof/Makefile @@ -0,0 +1,9 @@ +MKC_CHECK_SIZEOF += int long long-long size_t:string.h void* + +PROG = sizeof_test +WARNS = 4 + +MKC_REQD = 0.10.0 + +.include "test.mk" +.include <mkc.prog.mk> diff --git a/examples/hello_sizeof/expect.out b/examples/hello_sizeof/expect.out new file mode 100644 index 0000000..7820fc8 --- /dev/null +++ b/examples/hello_sizeof/expect.out @@ -0,0 +1,68 @@ +sizeof(int)=n +sizeof(long)=n +sizeof(long long)=n +sizeof(size_t)=n +sizeof(void*)=n +=========== all ============ +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/_mkc_sizeof_int.c +/objdir/_mkc_sizeof_int.err +/objdir/_mkc_sizeof_int.res +/objdir/_mkc_sizeof_long.c +/objdir/_mkc_sizeof_long.err +/objdir/_mkc_sizeof_long.res +/objdir/_mkc_sizeof_long~long.c +/objdir/_mkc_sizeof_long~long.err +/objdir/_mkc_sizeof_long~long.res +/objdir/_mkc_sizeof_size_t.c +/objdir/_mkc_sizeof_size_t.err +/objdir/_mkc_sizeof_size_t.res +/objdir/_mkc_sizeof_voidP.c +/objdir/_mkc_sizeof_voidP.err +/objdir/_mkc_sizeof_voidP.res +/objdir/expect.out +/objdir/hello_sizeof.test.out.tmp +/objdir/sizeof_test +/objdir/sizeof_test.c +/objdir/sizeof_test.o +/objdir/test.mk +========= install ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/bin/sizeof_test +======== uninstall ========= +========== clean =========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/_mkc_sizeof_int.c +/objdir/_mkc_sizeof_int.err +/objdir/_mkc_sizeof_int.res +/objdir/_mkc_sizeof_long.c +/objdir/_mkc_sizeof_long.err +/objdir/_mkc_sizeof_long.res +/objdir/_mkc_sizeof_long~long.c +/objdir/_mkc_sizeof_long~long.err +/objdir/_mkc_sizeof_long~long.res +/objdir/_mkc_sizeof_size_t.c +/objdir/_mkc_sizeof_size_t.err +/objdir/_mkc_sizeof_size_t.res +/objdir/_mkc_sizeof_voidP.c +/objdir/_mkc_sizeof_voidP.err +/objdir/_mkc_sizeof_voidP.res +/objdir/expect.out +/objdir/hello_sizeof.test.out.tmp +/objdir/sizeof_test.c +/objdir/test.mk +======= distclean ========== +/objdir/Makefile +/objdir/expect.out +/objdir/hello_sizeof.test.out.tmp +/objdir/sizeof_test.c +/objdir/test.mk diff --git a/examples/hello_sizeof/sizeof_test.c b/examples/hello_sizeof/sizeof_test.c new file mode 100644 index 0000000..87a445c --- /dev/null +++ b/examples/hello_sizeof/sizeof_test.c @@ -0,0 +1,20 @@ +#include <stdio.h> + +int main (int argc, char **argv) +{ + printf ("sizeof(int)=%i\n", SIZEOF_INT); + printf ("sizeof(long)=%i\n", SIZEOF_LONG); +#ifdef SIZEOF_LONG_LONG + printf ("sizeof(long long)=%i\n", SIZEOF_LONG_LONG); +#else + printf ("long long type is absent\n"); +#endif +#ifdef SIZEOF_SIZE_T_STRING_H + printf ("sizeof(size_t)=%i\n", SIZEOF_SIZE_T_STRING_H); +#else + printf ("size_t type is absent???\n"); +#endif + printf ("sizeof(void*)=%i\n", SIZEOF_VOIDP); + + return 0; +} diff --git a/examples/hello_sizeof/test.mk b/examples/hello_sizeof/test.mk new file mode 100644 index 0000000..1f6b6e2 --- /dev/null +++ b/examples/hello_sizeof/test.mk @@ -0,0 +1,33 @@ +.PHONY : test_output +test_output: + @set -e; \ + ${.OBJDIR}/sizeof_test | tr '1248' 'nnnn'; \ + rm -rf ${.OBJDIR}${PREFIX}; \ + MKCATPAGES=yes; export MKCATPAGES; \ + \ + echo =========== all ============; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= install ==========; \ + ${MAKE} ${MAKEFLAGS} install -j3 DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======== uninstall =========; \ + ${MAKE} ${MAKEFLAGS} -j4 uninstall DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ========== clean ===========; \ + ${MAKE} ${MAKEFLAGS} clean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ======= distclean ==========; \ + ${MAKE} ${MAKEFLAGS} distclean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}" + +.include <mkc.minitest.mk> diff --git a/examples/hello_strlcpy/Makefile b/examples/hello_strlcpy/Makefile new file mode 100644 index 0000000..f24ed5a --- /dev/null +++ b/examples/hello_strlcpy/Makefile @@ -0,0 +1,12 @@ +MKC_SOURCE_FUNCLIBS = strlcpy getline +MKC_CHECK_FUNCS3 += strlcpy:string.h getline:stdio.h + +PROG = hello +SRCS = hello.c + +WARNS = 4 + +MKC_REQD = 0.10.0 + +.include "test.mk" +.include <mkc.prog.mk> diff --git a/examples/hello_strlcpy/expect.out b/examples/hello_strlcpy/expect.out new file mode 100644 index 0000000..8acecb6 --- /dev/null +++ b/examples/hello_strlcpy/expect.out @@ -0,0 +1,93 @@ +# Copyrig +# All rig +# +# Redistr +# modific +# are met +# 1. Redi +# noti +# 2. Redi +# noti +# docu +# +# THIS SO +# ``AS IS +# TO, THE +# PURPOSE +# BE LIAB +# CONSEQU +# SUBSTIT +# INTERRU +# CONTRAC +# ARISING +# POSSIBI +=========== all ============ +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_func3_getline_stdio_h.c +/objdir/_mkc_func3_getline_stdio_h.err +/objdir/_mkc_func3_getline_stdio_h.res +/objdir/_mkc_func3_strlcpy_string_h.c +/objdir/_mkc_func3_strlcpy_string_h.err +/objdir/_mkc_func3_strlcpy_string_h.res +/objdir/_mkc_funclib_getline.c +/objdir/_mkc_funclib_getline.err +/objdir/_mkc_funclib_getline.res +/objdir/_mkc_funclib_strlcpy.c +/objdir/_mkc_funclib_strlcpy.err +/objdir/_mkc_funclib_strlcpy.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/expect.out +/objdir/getline.c +/objdir/hello +/objdir/hello.c +/objdir/hello.o +/objdir/hello_strlcpy.test.out.tmp +/objdir/input.in +/objdir/strlcpy.c +/objdir/test.mk +========= install ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/bin/hello +======== uninstall ========= +========== clean =========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_func3_getline_stdio_h.c +/objdir/_mkc_func3_getline_stdio_h.err +/objdir/_mkc_func3_getline_stdio_h.res +/objdir/_mkc_func3_strlcpy_string_h.c +/objdir/_mkc_func3_strlcpy_string_h.err +/objdir/_mkc_func3_strlcpy_string_h.res +/objdir/_mkc_funclib_getline.c +/objdir/_mkc_funclib_getline.err +/objdir/_mkc_funclib_getline.res +/objdir/_mkc_funclib_strlcpy.c +/objdir/_mkc_funclib_strlcpy.err +/objdir/_mkc_funclib_strlcpy.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/expect.out +/objdir/getline.c +/objdir/hello.c +/objdir/hello_strlcpy.test.out.tmp +/objdir/input.in +/objdir/strlcpy.c +/objdir/test.mk +======= distclean ========== +/objdir/Makefile +/objdir/expect.out +/objdir/getline.c +/objdir/hello.c +/objdir/hello_strlcpy.test.out.tmp +/objdir/input.in +/objdir/strlcpy.c +/objdir/test.mk +======= CLEANFILES ========== +hello.o +strlcpy.o +getline.o diff --git a/examples/hello_strlcpy/getline.c b/examples/hello_strlcpy/getline.c new file mode 100644 index 0000000..8e42c75 --- /dev/null +++ b/examples/hello_strlcpy/getline.c @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2007-2013 Aleksey Cheusov <vle@gmx.net> + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include <stdio.h> +#include <stdlib.h> + +ssize_t +getline(char** lineptr, size_t* n, FILE* stream); + +ssize_t +getline(char** lineptr, size_t* n, FILE* stream) +{ + int c; + size_t sz = 0; + + while (c = getc (stream), c != EOF){ + if (sz+1 >= *n){ + /* +2 is for `c' and 0-terminator */ + *n = *n * 3 / 2 + 2; + *lineptr = realloc (*lineptr, *n); + if (!*lineptr) + return -1; + } + + (*lineptr) [sz++] = (char) c; + if (c == '\n') + break; + } + + if (ferror (stream)) + return (ssize_t) -1; + + if (!sz){ + if (feof (stream)){ + return (ssize_t) -1; + }else if (!*n){ + *lineptr = malloc (1); + if (!*lineptr) + return -1; + + *n = 1; + } + } + + (*lineptr) [sz] = 0; + return sz; +} diff --git a/examples/hello_strlcpy/hello.c b/examples/hello_strlcpy/hello.c new file mode 100644 index 0000000..1ec6315 --- /dev/null +++ b/examples/hello_strlcpy/hello.c @@ -0,0 +1,30 @@ +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +#ifndef HAVE_FUNC3_STRLCPY_STRING_H +size_t strlcpy(char *dst, const char *src, size_t siz); +#endif + +#ifndef HAVE_FUNC3_GETLINE_STDIO_H +ssize_t getline(char** lineptr, size_t* n, FILE* stream); +#endif + +int main (int argc, char ** argv) +{ + char *buf = NULL; + size_t size = 0; + ssize_t len = 0; + char small_buf [10]; + + while (len = getline (&buf, &size, stdin), len != -1){ + len = strlen (buf); + if (len > 0 && buf [len-1] == '\n') + buf [len-1] = 0; + + strlcpy (small_buf, buf, sizeof (small_buf)); + puts (small_buf); + } + + return 0; +} diff --git a/examples/hello_strlcpy/input.in b/examples/hello_strlcpy/input.in new file mode 100644 index 0000000..a5a6836 --- /dev/null +++ b/examples/hello_strlcpy/input.in @@ -0,0 +1,23 @@ +# Copyright (c) 2009, Aleksey Cheusov <vle@gmx.net> +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. diff --git a/examples/hello_strlcpy/strlcpy.c b/examples/hello_strlcpy/strlcpy.c new file mode 100644 index 0000000..c7f1fbb --- /dev/null +++ b/examples/hello_strlcpy/strlcpy.c @@ -0,0 +1,51 @@ +/* + * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND TODD C. MILLER DISCLAIMS ALL + * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER BE LIABLE + * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * Copy src to string dst of size siz. At most siz-1 characters + * will be copied. Always NUL terminates (unless siz == 0). + * Returns strlen(src); if retval >= siz, truncation occurred. + */ +#include <string.h> + +size_t +strlcpy(char *dst, const char *src, size_t siz); + +size_t +strlcpy(char *dst, const char *src, size_t siz) +{ + char *d = dst; + const char *s = src; + size_t n = siz; + + /* Copy as many bytes as will fit */ + if (n != 0 && --n != 0) { + do { + if ((*d++ = *s++) == 0) + break; + } while (--n != 0); + } + + /* Not enough room in dst, add NUL and traverse rest of src */ + if (n == 0) { + if (siz != 0) + *d = '\0'; /* NUL-terminate dst */ + while (*s++) + ; + } + + return(s - src - 1); /* count does not include NUL */ +} diff --git a/examples/hello_strlcpy/test.mk b/examples/hello_strlcpy/test.mk new file mode 100644 index 0000000..29a6e51 --- /dev/null +++ b/examples/hello_strlcpy/test.mk @@ -0,0 +1,38 @@ +.PHONY : test_output +test_output: + @set -e; \ + ${.OBJDIR}/hello < ${.CURDIR}/input.in; \ + rm -rf ${.OBJDIR}${PREFIX}; \ + MKCATPAGES=yes; export MKCATPAGES; \ + \ + echo =========== all ============; \ + find ${.OBJDIR} -type f | grep -Ev '(strlcpy|getline)[.]o' | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= install ==========; \ + ${MAKE} ${MAKEFLAGS} install -j3 DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type d | \ + grep -vE '(strlcpy|getline)[.]o' | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======== uninstall =========; \ + ${MAKE} ${MAKEFLAGS} -j4 uninstall DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f | grep -vE '(strlcpy|getline)[.]o' | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========== clean ===========; \ + ${MAKE} ${MAKEFLAGS} clean > /dev/null; \ + find ${.OBJDIR} -type f | grep -vE '(strlcpy|getline)[.]o' | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======= distclean ==========; \ + ${MAKE} ${MAKEFLAGS} distclean > /dev/null; \ + find ${.OBJDIR} -type f | grep -vE '(strlcpy|getline)[.]o' | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======= CLEANFILES ==========; \ + ${MAKE} ${MAKEFLAGS} print_values VARS='CLEANFILES' MKCHECKS=no | \ + awk '{for(i=1; i<=NF; ++i) if ($$i ~ /[.]o.?$$/) print $$i}' + +.include <mkc.minitest.mk> diff --git a/examples/hello_strlcpy2/Makefile b/examples/hello_strlcpy2/Makefile new file mode 100644 index 0000000..76e332b --- /dev/null +++ b/examples/hello_strlcpy2/Makefile @@ -0,0 +1,13 @@ +MKC_SOURCE_FUNCLIBS = strlcpy getline +MKC_CHECK_FUNCS3 += strlcpy:string.h getline:stdio.h +MKC_SOURCE_DIR = ${.CURDIR}/missing + +PROG = hello +SRCS = hello.c + +WARNS = 4 + +MKC_REQD = 0.26.0 + +.include "test.mk" +.include <mkc.prog.mk> diff --git a/examples/hello_strlcpy2/expect.out b/examples/hello_strlcpy2/expect.out new file mode 100644 index 0000000..6f351e2 --- /dev/null +++ b/examples/hello_strlcpy2/expect.out @@ -0,0 +1,93 @@ +# Copyrig +# All rig +# +# Redistr +# modific +# are met +# 1. Redi +# noti +# 2. Redi +# noti +# docu +# +# THIS SO +# ``AS IS +# TO, THE +# PURPOSE +# BE LIAB +# CONSEQU +# SUBSTIT +# INTERRU +# CONTRAC +# ARISING +# POSSIBI +=========== all ============ +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_func3_getline_stdio_h.c +/objdir/_mkc_func3_getline_stdio_h.err +/objdir/_mkc_func3_getline_stdio_h.res +/objdir/_mkc_func3_strlcpy_string_h.c +/objdir/_mkc_func3_strlcpy_string_h.err +/objdir/_mkc_func3_strlcpy_string_h.res +/objdir/_mkc_funclib_getline.c +/objdir/_mkc_funclib_getline.err +/objdir/_mkc_funclib_getline.res +/objdir/_mkc_funclib_strlcpy.c +/objdir/_mkc_funclib_strlcpy.err +/objdir/_mkc_funclib_strlcpy.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/expect.out +/objdir/hello +/objdir/hello.c +/objdir/hello.o +/objdir/hello_strlcpy2.test.out.tmp +/objdir/input.in +/objdir/missing/getline.c +/objdir/missing/strlcpy.c +/objdir/test.mk +========= install ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/bin/hello +======== uninstall ========= +========== clean =========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_func3_getline_stdio_h.c +/objdir/_mkc_func3_getline_stdio_h.err +/objdir/_mkc_func3_getline_stdio_h.res +/objdir/_mkc_func3_strlcpy_string_h.c +/objdir/_mkc_func3_strlcpy_string_h.err +/objdir/_mkc_func3_strlcpy_string_h.res +/objdir/_mkc_funclib_getline.c +/objdir/_mkc_funclib_getline.err +/objdir/_mkc_funclib_getline.res +/objdir/_mkc_funclib_strlcpy.c +/objdir/_mkc_funclib_strlcpy.err +/objdir/_mkc_funclib_strlcpy.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/expect.out +/objdir/hello.c +/objdir/hello_strlcpy2.test.out.tmp +/objdir/input.in +/objdir/missing/getline.c +/objdir/missing/strlcpy.c +/objdir/test.mk +======= distclean ========== +/objdir/Makefile +/objdir/expect.out +/objdir/hello.c +/objdir/hello_strlcpy2.test.out.tmp +/objdir/input.in +/objdir/missing/getline.c +/objdir/missing/strlcpy.c +/objdir/test.mk +======= CLEANFILES ========== +hello.o +strlcpy.o +getline.o diff --git a/examples/hello_strlcpy2/hello.c b/examples/hello_strlcpy2/hello.c new file mode 100644 index 0000000..1ec6315 --- /dev/null +++ b/examples/hello_strlcpy2/hello.c @@ -0,0 +1,30 @@ +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +#ifndef HAVE_FUNC3_STRLCPY_STRING_H +size_t strlcpy(char *dst, const char *src, size_t siz); +#endif + +#ifndef HAVE_FUNC3_GETLINE_STDIO_H +ssize_t getline(char** lineptr, size_t* n, FILE* stream); +#endif + +int main (int argc, char ** argv) +{ + char *buf = NULL; + size_t size = 0; + ssize_t len = 0; + char small_buf [10]; + + while (len = getline (&buf, &size, stdin), len != -1){ + len = strlen (buf); + if (len > 0 && buf [len-1] == '\n') + buf [len-1] = 0; + + strlcpy (small_buf, buf, sizeof (small_buf)); + puts (small_buf); + } + + return 0; +} diff --git a/examples/hello_strlcpy2/input.in b/examples/hello_strlcpy2/input.in new file mode 100644 index 0000000..a5a6836 --- /dev/null +++ b/examples/hello_strlcpy2/input.in @@ -0,0 +1,23 @@ +# Copyright (c) 2009, Aleksey Cheusov <vle@gmx.net> +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. diff --git a/examples/hello_strlcpy2/missing/getline.c b/examples/hello_strlcpy2/missing/getline.c new file mode 100644 index 0000000..8e42c75 --- /dev/null +++ b/examples/hello_strlcpy2/missing/getline.c @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2007-2013 Aleksey Cheusov <vle@gmx.net> + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include <stdio.h> +#include <stdlib.h> + +ssize_t +getline(char** lineptr, size_t* n, FILE* stream); + +ssize_t +getline(char** lineptr, size_t* n, FILE* stream) +{ + int c; + size_t sz = 0; + + while (c = getc (stream), c != EOF){ + if (sz+1 >= *n){ + /* +2 is for `c' and 0-terminator */ + *n = *n * 3 / 2 + 2; + *lineptr = realloc (*lineptr, *n); + if (!*lineptr) + return -1; + } + + (*lineptr) [sz++] = (char) c; + if (c == '\n') + break; + } + + if (ferror (stream)) + return (ssize_t) -1; + + if (!sz){ + if (feof (stream)){ + return (ssize_t) -1; + }else if (!*n){ + *lineptr = malloc (1); + if (!*lineptr) + return -1; + + *n = 1; + } + } + + (*lineptr) [sz] = 0; + return sz; +} diff --git a/examples/hello_strlcpy2/missing/strlcpy.c b/examples/hello_strlcpy2/missing/strlcpy.c new file mode 100644 index 0000000..c7f1fbb --- /dev/null +++ b/examples/hello_strlcpy2/missing/strlcpy.c @@ -0,0 +1,51 @@ +/* + * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND TODD C. MILLER DISCLAIMS ALL + * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER BE LIABLE + * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * Copy src to string dst of size siz. At most siz-1 characters + * will be copied. Always NUL terminates (unless siz == 0). + * Returns strlen(src); if retval >= siz, truncation occurred. + */ +#include <string.h> + +size_t +strlcpy(char *dst, const char *src, size_t siz); + +size_t +strlcpy(char *dst, const char *src, size_t siz) +{ + char *d = dst; + const char *s = src; + size_t n = siz; + + /* Copy as many bytes as will fit */ + if (n != 0 && --n != 0) { + do { + if ((*d++ = *s++) == 0) + break; + } while (--n != 0); + } + + /* Not enough room in dst, add NUL and traverse rest of src */ + if (n == 0) { + if (siz != 0) + *d = '\0'; /* NUL-terminate dst */ + while (*s++) + ; + } + + return(s - src - 1); /* count does not include NUL */ +} diff --git a/examples/hello_strlcpy2/test.mk b/examples/hello_strlcpy2/test.mk new file mode 100644 index 0000000..29a6e51 --- /dev/null +++ b/examples/hello_strlcpy2/test.mk @@ -0,0 +1,38 @@ +.PHONY : test_output +test_output: + @set -e; \ + ${.OBJDIR}/hello < ${.CURDIR}/input.in; \ + rm -rf ${.OBJDIR}${PREFIX}; \ + MKCATPAGES=yes; export MKCATPAGES; \ + \ + echo =========== all ============; \ + find ${.OBJDIR} -type f | grep -Ev '(strlcpy|getline)[.]o' | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= install ==========; \ + ${MAKE} ${MAKEFLAGS} install -j3 DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type d | \ + grep -vE '(strlcpy|getline)[.]o' | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======== uninstall =========; \ + ${MAKE} ${MAKEFLAGS} -j4 uninstall DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f | grep -vE '(strlcpy|getline)[.]o' | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========== clean ===========; \ + ${MAKE} ${MAKEFLAGS} clean > /dev/null; \ + find ${.OBJDIR} -type f | grep -vE '(strlcpy|getline)[.]o' | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======= distclean ==========; \ + ${MAKE} ${MAKEFLAGS} distclean > /dev/null; \ + find ${.OBJDIR} -type f | grep -vE '(strlcpy|getline)[.]o' | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======= CLEANFILES ==========; \ + ${MAKE} ${MAKEFLAGS} print_values VARS='CLEANFILES' MKCHECKS=no | \ + awk '{for(i=1; i<=NF; ++i) if ($$i ~ /[.]o.?$$/) print $$i}' + +.include <mkc.minitest.mk> diff --git a/examples/hello_strlcpy3/Makefile b/examples/hello_strlcpy3/Makefile new file mode 100644 index 0000000..7257050 --- /dev/null +++ b/examples/hello_strlcpy3/Makefile @@ -0,0 +1,11 @@ +PROG = hello +SRCS = hello.c + +WARNS = 4 + +MKC_FEATURES = strlcpy strlcat getline progname + +MKC_REQD = 0.26.0 + +.include "test.mk" +.include <mkc.prog.mk> diff --git a/examples/hello_strlcpy3/expect.out b/examples/hello_strlcpy3/expect.out new file mode 100644 index 0000000..ce90dc7 --- /dev/null +++ b/examples/hello_strlcpy3/expect.out @@ -0,0 +1,140 @@ +foo17# Copyrig +foo17# All rig +foo17# +foo17# Redistr +foo17# modific +foo17# are met +foo17# 1. Redi +foo17# noti +foo17# 2. Redi +foo17# noti +foo17# docu +foo17# +foo17# THIS SO +foo17# ``AS IS +foo17# TO, THE +foo17# PURPOSE +foo17# BE LIAB +foo17# CONSEQU +foo17# SUBSTIT +foo17# INTERRU +foo17# CONTRAC +foo17# ARISING +foo17# POSSIBI +Theo de Raadt said +short progname=hello +full progname=/path/to/hello +=========== all ============ +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_func0_getexecname_stdlib_h.c +/objdir/_mkc_func0_getexecname_stdlib_h.err +/objdir/_mkc_func0_getexecname_stdlib_h.res +/objdir/_mkc_func0_getprogname_stdlib_h.c +/objdir/_mkc_func0_getprogname_stdlib_h.err +/objdir/_mkc_func0_getprogname_stdlib_h.res +/objdir/_mkc_func1_setprogname_stdlib_h.c +/objdir/_mkc_func1_setprogname_stdlib_h.err +/objdir/_mkc_func1_setprogname_stdlib_h.res +/objdir/_mkc_func3_getline_stdio_h.c +/objdir/_mkc_func3_getline_stdio_h.err +/objdir/_mkc_func3_getline_stdio_h.res +/objdir/_mkc_func3_strlcat_string_h.c +/objdir/_mkc_func3_strlcat_string_h.err +/objdir/_mkc_func3_strlcat_string_h.res +/objdir/_mkc_func3_strlcpy_string_h.c +/objdir/_mkc_func3_strlcpy_string_h.err +/objdir/_mkc_func3_strlcpy_string_h.res +/objdir/_mkc_funclib_getline.c +/objdir/_mkc_funclib_getline.err +/objdir/_mkc_funclib_getline.res +/objdir/_mkc_funclib_getprogname.c +/objdir/_mkc_funclib_getprogname.err +/objdir/_mkc_funclib_getprogname.res +/objdir/_mkc_funclib_setprogname.c +/objdir/_mkc_funclib_setprogname.err +/objdir/_mkc_funclib_setprogname.res +/objdir/_mkc_funclib_strlcat.c +/objdir/_mkc_funclib_strlcat.err +/objdir/_mkc_funclib_strlcat.res +/objdir/_mkc_funclib_strlcpy.c +/objdir/_mkc_funclib_strlcpy.err +/objdir/_mkc_funclib_strlcpy.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/_mkc_variable_program_invocation_short_name_errno_h.c +/objdir/_mkc_variable_program_invocation_short_name_errno_h.err +/objdir/_mkc_variable_program_invocation_short_name_errno_h.res +/objdir/expect.out +/objdir/hello +/objdir/hello.c +/objdir/hello.o +/objdir/hello_strlcpy3.test.out.tmp +/objdir/input.in +/objdir/test.mk +========= install ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/bin/hello +======== uninstall ========= +========== clean =========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_func0_getexecname_stdlib_h.c +/objdir/_mkc_func0_getexecname_stdlib_h.err +/objdir/_mkc_func0_getexecname_stdlib_h.res +/objdir/_mkc_func0_getprogname_stdlib_h.c +/objdir/_mkc_func0_getprogname_stdlib_h.err +/objdir/_mkc_func0_getprogname_stdlib_h.res +/objdir/_mkc_func1_setprogname_stdlib_h.c +/objdir/_mkc_func1_setprogname_stdlib_h.err +/objdir/_mkc_func1_setprogname_stdlib_h.res +/objdir/_mkc_func3_getline_stdio_h.c +/objdir/_mkc_func3_getline_stdio_h.err +/objdir/_mkc_func3_getline_stdio_h.res +/objdir/_mkc_func3_strlcat_string_h.c +/objdir/_mkc_func3_strlcat_string_h.err +/objdir/_mkc_func3_strlcat_string_h.res +/objdir/_mkc_func3_strlcpy_string_h.c +/objdir/_mkc_func3_strlcpy_string_h.err +/objdir/_mkc_func3_strlcpy_string_h.res +/objdir/_mkc_funclib_getline.c +/objdir/_mkc_funclib_getline.err +/objdir/_mkc_funclib_getline.res +/objdir/_mkc_funclib_getprogname.c +/objdir/_mkc_funclib_getprogname.err +/objdir/_mkc_funclib_getprogname.res +/objdir/_mkc_funclib_setprogname.c +/objdir/_mkc_funclib_setprogname.err +/objdir/_mkc_funclib_setprogname.res +/objdir/_mkc_funclib_strlcat.c +/objdir/_mkc_funclib_strlcat.err +/objdir/_mkc_funclib_strlcat.res +/objdir/_mkc_funclib_strlcpy.c +/objdir/_mkc_funclib_strlcpy.err +/objdir/_mkc_funclib_strlcpy.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/_mkc_variable_program_invocation_short_name_errno_h.c +/objdir/_mkc_variable_program_invocation_short_name_errno_h.err +/objdir/_mkc_variable_program_invocation_short_name_errno_h.res +/objdir/expect.out +/objdir/hello.c +/objdir/hello_strlcpy3.test.out.tmp +/objdir/input.in +/objdir/test.mk +======= distclean ========== +/objdir/Makefile +/objdir/expect.out +/objdir/hello.c +/objdir/hello_strlcpy3.test.out.tmp +/objdir/input.in +/objdir/test.mk +======= CLEANFILES ========== +hello.o +strlcpy.o +strlcat.o +getline.o +progname.o diff --git a/examples/hello_strlcpy3/hello.c b/examples/hello_strlcpy3/hello.c new file mode 100644 index 0000000..b662024 --- /dev/null +++ b/examples/hello_strlcpy3/hello.c @@ -0,0 +1,38 @@ +#include <stdio.h> +#include <string.h> + +#include <mkc_strlcpy.h> +#include <mkc_strlcat.h> +#include <mkc_getline.h> +#include <mkc_progname.h> + +static const char message [] = "Theo de Raadt said: \"The strlcpy() and strlcat() functions provide a consistent, unambiguous API to help the programmer write more bullet-proof code.\""; + +int main (int argc, char ** argv) +{ + char *buf = NULL; + size_t size = 0; + ssize_t len = 0; + char small_buf [15]; + char said [19]; + + setprogname (argv [0]); + + while (len = getline (&buf, &size, stdin), len != -1){ + len = strlen (buf); + if (len > 0 && buf [len-1] == '\n') + buf [len-1] = 0; + + strlcpy (small_buf, "foo17", sizeof (small_buf)); + strlcat (small_buf, buf, sizeof (small_buf)); + puts (small_buf); + } + + strlcpy (said, message, sizeof (said)); + puts (said); + + printf ("short progname=%s\n", getprogname ()); + printf ("full progname=%s\n", argv [0]); + + return 0; +} diff --git a/examples/hello_strlcpy3/input.in b/examples/hello_strlcpy3/input.in new file mode 100644 index 0000000..a5a6836 --- /dev/null +++ b/examples/hello_strlcpy3/input.in @@ -0,0 +1,23 @@ +# Copyright (c) 2009, Aleksey Cheusov <vle@gmx.net> +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. diff --git a/examples/hello_strlcpy3/test.mk b/examples/hello_strlcpy3/test.mk new file mode 100644 index 0000000..065088a --- /dev/null +++ b/examples/hello_strlcpy3/test.mk @@ -0,0 +1,41 @@ +FUNCS_RE=(strlcat|strlcpy|getline|progname)[.]o + +.PHONY : test_output +test_output: + @set -e; \ + ${.OBJDIR}/hello < ${.CURDIR}/input.in | \ + mkc_test_helper_paths; \ + rm -rf ${.OBJDIR}${PREFIX}; \ + MKCATPAGES=yes; export MKCATPAGES; \ + \ + echo =========== all ============; \ + find ${.OBJDIR} -type f | grep -Ev '${FUNCS_RE}' | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= install ==========; \ + ${MAKE} ${MAKEFLAGS} install -j3 DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type d | \ + grep -vE '${FUNCS_RE}' | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======== uninstall =========; \ + ${MAKE} ${MAKEFLAGS} -j4 uninstall DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f | grep -vE '${FUNCS_RE}' | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========== clean ===========; \ + ${MAKE} ${MAKEFLAGS} clean > /dev/null; \ + find ${.OBJDIR} -type f | grep -vE '${FUNCS_RE}' | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======= distclean ==========; \ + ${MAKE} ${MAKEFLAGS} distclean > /dev/null; \ + find ${.OBJDIR} -type f | grep -vE '${FUNCS_RE}' | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======= CLEANFILES ==========; \ + ${MAKE} ${MAKEFLAGS} print_values VARS='CLEANFILES' MKCHECKS=no | \ + awk '{for(i=1; i<=NF; ++i) if ($$i ~ /[.]o.?$$/) print $$i}' + +.include <mkc.minitest.mk> diff --git a/examples/hello_subdirs/Makefile b/examples/hello_subdirs/Makefile new file mode 100644 index 0000000..3847c12 --- /dev/null +++ b/examples/hello_subdirs/Makefile @@ -0,0 +1,3 @@ +SUBDIR = prog1 prog2 + +.include <mkc.subdir.mk> diff --git a/examples/hello_subdirs/prog1/Makefile b/examples/hello_subdirs/prog1/Makefile new file mode 100644 index 0000000..0a4c0ad --- /dev/null +++ b/examples/hello_subdirs/prog1/Makefile @@ -0,0 +1,18 @@ +PROG = prog1 +SCRIPTS = prog1.sh ${INSCRIPTS} +INSCRIPTS = prog1.awk + +WARNS = 4 + +MKC_REQUIRE_PROGS = awk +INTEXTS_REPLS = AWK ${PROG.awk} + +# Do not set SCRIPTSNAME in project's Makefile! +# This is just a regression test. +SCRIPTSNAME_prog1.awk = program1.awk +SCRIPTSNAME_prog1.sh = program1.sh + +SCRIPTSDIR_prog1.sh = ${PREFIX}/libexec + +.include "test.mk" +.include <mkc.prog.mk> diff --git a/examples/hello_subdirs/prog1/expect.out b/examples/hello_subdirs/prog1/expect.out new file mode 100644 index 0000000..d3284bf --- /dev/null +++ b/examples/hello_subdirs/prog1/expect.out @@ -0,0 +1,39 @@ +Hello World1 +Hello World1-2 +Hello World1-3 +OBJDIR_prog1=/path/to/prog1 +OBJDIR_prog2=/path/to/prog2 +SRCDIR_prog1=hello_subdirs/prog1 +SRCDIR_prog2=hello_subdirs/prog2 +=========== all ============ +/objdir/Makefile +/objdir/expect.out +/objdir/prog1 +/objdir/prog1.awk +/objdir/prog1.awk.in +/objdir/prog1.c +/objdir/prog1.o +/objdir/prog1.sh +/objdir/prog1.test.out.tmp +/objdir/test.mk +========= install ========== +/objdir/prefix/bin/prog1 +/objdir/prefix/bin/program1.awk +/objdir/prefix/libexec/program1.sh +======== uninstall ========= +========== clean =========== +/objdir/Makefile +/objdir/expect.out +/objdir/prog1.awk.in +/objdir/prog1.c +/objdir/prog1.sh +/objdir/prog1.test.out.tmp +/objdir/test.mk +======= distclean ========== +/objdir/Makefile +/objdir/expect.out +/objdir/prog1.awk.in +/objdir/prog1.c +/objdir/prog1.sh +/objdir/prog1.test.out.tmp +/objdir/test.mk diff --git a/examples/hello_subdirs/prog1/prog1.awk.in b/examples/hello_subdirs/prog1/prog1.awk.in new file mode 100755 index 0000000..65ab78a --- /dev/null +++ b/examples/hello_subdirs/prog1/prog1.awk.in @@ -0,0 +1,6 @@ +#!@AWK@ -f + +BEGIN { + print "Hello World1-3" + exit 0 +} diff --git a/examples/hello_subdirs/prog1/prog1.c b/examples/hello_subdirs/prog1/prog1.c new file mode 100644 index 0000000..33fd57f --- /dev/null +++ b/examples/hello_subdirs/prog1/prog1.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main (int argc, char **argv) +{ + puts ("Hello World1"); + return 0; +} diff --git a/examples/hello_subdirs/prog1/prog1.sh b/examples/hello_subdirs/prog1/prog1.sh new file mode 100755 index 0000000..43d6573 --- /dev/null +++ b/examples/hello_subdirs/prog1/prog1.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +echo Hello World1-2 diff --git a/examples/hello_subdirs/prog1/test.mk b/examples/hello_subdirs/prog1/test.mk new file mode 100644 index 0000000..4de6167 --- /dev/null +++ b/examples/hello_subdirs/prog1/test.mk @@ -0,0 +1,40 @@ +.PHONY : test_output +test_output: + @set -e; \ + rm -rf ${.OBJDIR}${PREFIX}; \ + ${.OBJDIR}/prog1; \ + ${.OBJDIR}/prog1.sh; \ + ${.OBJDIR}/prog1.awk; \ + \ + echo OBJDIR_prog1=${OBJDIR_prog1} | mkc_test_helper_paths; \ + echo OBJDIR_prog2=${OBJDIR_prog2} | mkc_test_helper_paths; \ + \ + echo SRCDIR_prog1=${SRCDIR_prog1} | sed 's,=.*examples/,=,'; \ + echo SRCDIR_prog2=${SRCDIR_prog2} | sed 's,=.*examples/,=,'; \ + \ + echo =========== all ============; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= install ==========; \ + ${MAKE} ${MAKE_FLAGS} install DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======== uninstall =========; \ + ${MAKE} ${MAKE_FLAGS} uninstall DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ========== clean ===========; \ + ${MAKE} ${MAKE_FLAGS} clean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ======= distclean ==========; \ + ${MAKE} ${MAKE_FLAGS} distclean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}" + +.include <mkc.minitest.mk> diff --git a/examples/hello_subdirs/prog2/Makefile b/examples/hello_subdirs/prog2/Makefile new file mode 100644 index 0000000..ebf00fa --- /dev/null +++ b/examples/hello_subdirs/prog2/Makefile @@ -0,0 +1,9 @@ +PROG = prog2 +WARNS = 4 + +# Do not set PROGNAME in project's Makefile! +# This is just a regression test. +PROGNAME = program2 + +.include "test.mk" +.include <mkc.prog.mk> diff --git a/examples/hello_subdirs/prog2/expect.out b/examples/hello_subdirs/prog2/expect.out new file mode 100644 index 0000000..ab42434 --- /dev/null +++ b/examples/hello_subdirs/prog2/expect.out @@ -0,0 +1,28 @@ +Hello World2 +OBJDIR_prog1=/path/to/prog1 +OBJDIR_prog2=/path/to/prog2 +SRCDIR_prog1=hello_subdirs/prog1 +SRCDIR_prog2=hello_subdirs/prog2 +=========== all ============ +/objdir/Makefile +/objdir/expect.out +/objdir/prog2 +/objdir/prog2.c +/objdir/prog2.o +/objdir/prog2.test.out.tmp +/objdir/test.mk +========= install ========== +/objdir/prefix/bin/program2 +======== uninstall ========= +========== clean =========== +/objdir/Makefile +/objdir/expect.out +/objdir/prog2.c +/objdir/prog2.test.out.tmp +/objdir/test.mk +======= distclean ========== +/objdir/Makefile +/objdir/expect.out +/objdir/prog2.c +/objdir/prog2.test.out.tmp +/objdir/test.mk diff --git a/examples/hello_subdirs/prog2/prog2.c b/examples/hello_subdirs/prog2/prog2.c new file mode 100644 index 0000000..314960b --- /dev/null +++ b/examples/hello_subdirs/prog2/prog2.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main (int argc, char **argv) +{ + puts ("Hello World2"); + return 0; +} diff --git a/examples/hello_subdirs/prog2/test.mk b/examples/hello_subdirs/prog2/test.mk new file mode 100644 index 0000000..24910dc --- /dev/null +++ b/examples/hello_subdirs/prog2/test.mk @@ -0,0 +1,38 @@ +.PHONY : test_output +test_output: + @set -e; \ + rm -rf ${.OBJDIR}${PREFIX}; \ + ${.OBJDIR}/prog2; \ + \ + echo OBJDIR_prog1=${OBJDIR_prog1} | mkc_test_helper_paths; \ + echo OBJDIR_prog2=${OBJDIR_prog2} | mkc_test_helper_paths; \ + \ + echo SRCDIR_prog1=${SRCDIR_prog1} | sed 's,=.*examples/,=,'; \ + echo SRCDIR_prog2=${SRCDIR_prog2} | sed 's,=.*examples/,=,'; \ + \ + echo =========== all ============; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= install ==========; \ + ${MAKE} ${MAKE_FLAGS} install DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======== uninstall =========; \ + ${MAKE} ${MAKE_FLAGS} uninstall DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ========== clean ===========; \ + ${MAKE} ${MAKE_FLAGS} clean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ======= distclean ==========; \ + ${MAKE} ${MAKE_FLAGS} distclean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}" + +.include <mkc.minitest.mk> diff --git a/examples/hello_superfs/Makefile b/examples/hello_superfs/Makefile new file mode 100644 index 0000000..57a1655 --- /dev/null +++ b/examples/hello_superfs/Makefile @@ -0,0 +1,11 @@ +SUBPRJ = docs mkfs_superfs:tools fsck_superfs:tools + +SUBPRJ_DFLT = mkfs_superfs fsck_superfs docs + +# "tools" is a virtual subproject, there is no subdirectory for it + +TMPPREFIX = ${.OBJDIR}/tmp +.export TMPPREFIX + +.include "test.mk" +.include <mkc.subprj.mk> diff --git a/examples/hello_superfs/Makefile.inc b/examples/hello_superfs/Makefile.inc new file mode 100644 index 0000000..57c8208 --- /dev/null +++ b/examples/hello_superfs/Makefile.inc @@ -0,0 +1,14 @@ +BINDIR ?= ${SBINDIR} + +.ifdef MICHAEL_MODE +# If MICHAEL_MODE environment variabe is set, everything +# is installed to temporary directory after build and +# uninstalled before cleaning. +# This feature may be useful for development +# and was proposed by Michael Crogan. +PREFIX = ${TMPPREFIX} +INSTALL = mkc_install +COPY = -l # symlinks instead of copying/moving +post_all: install +pre_clean: uninstall +.endif diff --git a/examples/hello_superfs/docs/LICENSE b/examples/hello_superfs/docs/LICENSE new file mode 100644 index 0000000..2aa558a --- /dev/null +++ b/examples/hello_superfs/docs/LICENSE @@ -0,0 +1 @@ +License text here diff --git a/examples/hello_superfs/docs/Makefile b/examples/hello_superfs/docs/Makefile new file mode 100644 index 0000000..f3f0b31 --- /dev/null +++ b/examples/hello_superfs/docs/Makefile @@ -0,0 +1,6 @@ +FILES = LICENSE NEWS README +FILESDIR = ${DOCDIR} + +DOCDIR ?= ${DATADIR}/doc/dict + +.include <mkc.files.mk> diff --git a/examples/hello_superfs/docs/NEWS b/examples/hello_superfs/docs/NEWS new file mode 100644 index 0000000..e6cfeee --- /dev/null +++ b/examples/hello_superfs/docs/NEWS @@ -0,0 +1 @@ +News here diff --git a/examples/hello_superfs/docs/README b/examples/hello_superfs/docs/README new file mode 100644 index 0000000..62c8d0b --- /dev/null +++ b/examples/hello_superfs/docs/README @@ -0,0 +1 @@ +Readme file diff --git a/examples/hello_superfs/expect.out b/examples/hello_superfs/expect.out new file mode 100644 index 0000000..3e0ab3e --- /dev/null +++ b/examples/hello_superfs/expect.out @@ -0,0 +1,161 @@ +=========== all ============ +/objdir/Makefile +/objdir/Makefile.inc +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/docs/LICENSE +/objdir/docs/Makefile +/objdir/docs/NEWS +/objdir/docs/README +/objdir/expect.out +/objdir/fsck_superfs/Makefile +/objdir/fsck_superfs/fsck_superfs +/objdir/fsck_superfs/fsck_superfs.8 +/objdir/fsck_superfs/fsck_superfs.c +/objdir/fsck_superfs/fsck_superfs.o +/objdir/hello_superfs.test.out.tmp +/objdir/mkfs_superfs/Makefile +/objdir/mkfs_superfs/mkfs_superfs +/objdir/mkfs_superfs/mkfs_superfs.8 +/objdir/mkfs_superfs/mkfs_superfs.c +/objdir/mkfs_superfs/mkfs_superfs.o +/objdir/test.mk +========= install ========== +/objdir/prefix +/objdir/prefix/man +/objdir/prefix/man/cat8 +/objdir/prefix/man/cat8/fsck_superfs.0 +/objdir/prefix/man/cat8/mkfs_superfs.0 +/objdir/prefix/man/man8 +/objdir/prefix/man/man8/fsck_superfs.8 +/objdir/prefix/man/man8/mkfs_superfs.8 +/objdir/prefix/sbin +/objdir/prefix/sbin/fsck_superfs +/objdir/prefix/sbin/mkfs_superfs +/objdir/prefix/share +/objdir/prefix/share/doc +/objdir/prefix/share/doc/dict +/objdir/prefix/share/doc/dict/LICENSE +/objdir/prefix/share/doc/dict/NEWS +/objdir/prefix/share/doc/dict/README +======== uninstall ========= +========== clean =========== +/objdir/Makefile +/objdir/Makefile.inc +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/docs/LICENSE +/objdir/docs/Makefile +/objdir/docs/NEWS +/objdir/docs/README +/objdir/expect.out +/objdir/fsck_superfs/Makefile +/objdir/fsck_superfs/fsck_superfs.8 +/objdir/fsck_superfs/fsck_superfs.c +/objdir/hello_superfs.test.out.tmp +/objdir/mkfs_superfs/Makefile +/objdir/mkfs_superfs/mkfs_superfs.8 +/objdir/mkfs_superfs/mkfs_superfs.c +/objdir/test.mk +========== depend =========== +/objdir/Makefile +/objdir/Makefile.inc +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/docs/LICENSE +/objdir/docs/Makefile +/objdir/docs/NEWS +/objdir/docs/README +/objdir/expect.out +/objdir/fsck_superfs/.depend +/objdir/fsck_superfs/Makefile +/objdir/fsck_superfs/fsck_superfs.8 +/objdir/fsck_superfs/fsck_superfs.c +/objdir/fsck_superfs/fsck_superfs.d +/objdir/hello_superfs.test.out.tmp +/objdir/mkfs_superfs/.depend +/objdir/mkfs_superfs/Makefile +/objdir/mkfs_superfs/mkfs_superfs.8 +/objdir/mkfs_superfs/mkfs_superfs.c +/objdir/mkfs_superfs/mkfs_superfs.d +/objdir/test.mk +======= distclean ========== +/objdir/Makefile +/objdir/Makefile.inc +/objdir/docs/LICENSE +/objdir/docs/Makefile +/objdir/docs/NEWS +/objdir/docs/README +/objdir/expect.out +/objdir/fsck_superfs/Makefile +/objdir/fsck_superfs/fsck_superfs.8 +/objdir/fsck_superfs/fsck_superfs.c +/objdir/hello_superfs.test.out.tmp +/objdir/mkfs_superfs/Makefile +/objdir/mkfs_superfs/mkfs_superfs.8 +/objdir/mkfs_superfs/mkfs_superfs.c +/objdir/test.mk +======= errorcheck ========== +/objdir/Makefile +/objdir/Makefile.inc +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/docs/LICENSE +/objdir/docs/Makefile +/objdir/docs/NEWS +/objdir/docs/README +/objdir/expect.out +/objdir/fsck_superfs/Makefile +/objdir/fsck_superfs/fsck_superfs.8 +/objdir/fsck_superfs/fsck_superfs.c +/objdir/hello_superfs.test.out.tmp +/objdir/mkfs_superfs/Makefile +/objdir/mkfs_superfs/mkfs_superfs.8 +/objdir/mkfs_superfs/mkfs_superfs.c +/objdir/test.mk +==== install MKINSTALL=no ==== +/objdir/Makefile +/objdir/Makefile.inc +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/docs/LICENSE +/objdir/docs/Makefile +/objdir/docs/NEWS +/objdir/docs/README +/objdir/expect.out +/objdir/fsck_superfs/Makefile +/objdir/fsck_superfs/fsck_superfs +/objdir/fsck_superfs/fsck_superfs.8 +/objdir/fsck_superfs/fsck_superfs.c +/objdir/fsck_superfs/fsck_superfs.cat8 +/objdir/fsck_superfs/fsck_superfs.o +/objdir/hello_superfs.test.out.tmp +/objdir/mkfs_superfs/Makefile +/objdir/mkfs_superfs/mkfs_superfs +/objdir/mkfs_superfs/mkfs_superfs.8 +/objdir/mkfs_superfs/mkfs_superfs.c +/objdir/mkfs_superfs/mkfs_superfs.cat8 +/objdir/mkfs_superfs/mkfs_superfs.o +/objdir/test.mk +=========== Michael mode: all ============ +/objdir/tmp/man/cat8/fsck_superfs.0 +/objdir/tmp/man/cat8/mkfs_superfs.0 +/objdir/tmp/man/man8/fsck_superfs.8 +/objdir/tmp/man/man8/mkfs_superfs.8 +/objdir/tmp/sbin/fsck_superfs +/objdir/tmp/sbin/mkfs_superfs +/objdir/tmp/share/doc/dict/LICENSE +/objdir/tmp/share/doc/dict/NEWS +/objdir/tmp/share/doc/dict/README +=========== Michael mode: clean ============ +=========== Michael mode: cleandir ============ diff --git a/examples/hello_superfs/fsck_superfs/Makefile b/examples/hello_superfs/fsck_superfs/Makefile new file mode 100644 index 0000000..ffc799c --- /dev/null +++ b/examples/hello_superfs/fsck_superfs/Makefile @@ -0,0 +1,6 @@ +PROG = fsck_superfs +MAN = fsck_superfs.8 + +WARNS = 4 + +.include <mkc.prog.mk> diff --git a/examples/hello_superfs/fsck_superfs/fsck_superfs.8 b/examples/hello_superfs/fsck_superfs/fsck_superfs.8 new file mode 100644 index 0000000..63f0e5c --- /dev/null +++ b/examples/hello_superfs/fsck_superfs/fsck_superfs.8 @@ -0,0 +1,15 @@ +.\" $NetBSD$ +.\" +.\" Copyright (c) 2010 by Aleksey Cheusov (vle@gmx.net) +.\" Absolutely no warranty. +.\" +.TH FSCK_SUPERFS 8 "Jul 23, 2010" +.SH NAME +fsck_superfs \- fsck utility for superfs file system +.SH DESCRIPTION +.B fsck_superfs +is one of mk-c examples +.SH SEE ALSO +.BR fsck(8) , mkfs(8) +.SH AUTHOR +Aleksey Cheusov <vle@gmx.net> diff --git a/examples/hello_superfs/fsck_superfs/fsck_superfs.c b/examples/hello_superfs/fsck_superfs/fsck_superfs.c new file mode 100644 index 0000000..d45d5b7 --- /dev/null +++ b/examples/hello_superfs/fsck_superfs/fsck_superfs.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main (int argc, char **argv) +{ + puts ("fsck fake"); + return 0; +} diff --git a/examples/hello_superfs/mkfs_superfs/Makefile b/examples/hello_superfs/mkfs_superfs/Makefile new file mode 100644 index 0000000..eb7c9cb --- /dev/null +++ b/examples/hello_superfs/mkfs_superfs/Makefile @@ -0,0 +1,6 @@ +PROG = mkfs_superfs +MAN = mkfs_superfs.8 + +WARNS = 4 + +.include <mkc.prog.mk> diff --git a/examples/hello_superfs/mkfs_superfs/mkfs_superfs.8 b/examples/hello_superfs/mkfs_superfs/mkfs_superfs.8 new file mode 100644 index 0000000..a0401a7 --- /dev/null +++ b/examples/hello_superfs/mkfs_superfs/mkfs_superfs.8 @@ -0,0 +1,15 @@ +.\" $NetBSD$ +.\" +.\" Copyright (c) 2010 by Aleksey Cheusov (vle@gmx.net) +.\" Absolutely no warranty. +.\" +.TH MKFS_SUPERFS 8 "Jul 23, 2010" +.SH NAME +mkfs_superfs \- mkfs utility for superfs file system +.SH DESCRIPTION +.B mkfs_superfs +is one of mk-c examples +.SH SEE ALSO +.BR mkfs(8) , fsck(8) +.SH AUTHOR +Aleksey Cheusov <vle@gmx.net> diff --git a/examples/hello_superfs/mkfs_superfs/mkfs_superfs.c b/examples/hello_superfs/mkfs_superfs/mkfs_superfs.c new file mode 100644 index 0000000..e644f6a --- /dev/null +++ b/examples/hello_superfs/mkfs_superfs/mkfs_superfs.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main (int argc, char **argv) +{ + puts ("mkfs fake"); + return 0; +} diff --git a/examples/hello_superfs/test.mk b/examples/hello_superfs/test.mk new file mode 100644 index 0000000..d7b0b98 --- /dev/null +++ b/examples/hello_superfs/test.mk @@ -0,0 +1,74 @@ +next_level != expr ${.MAKE.LEVEL} + 1 + +.PHONY : test_output +test_output: + @set -e; \ + rm -rf ${.OBJDIR}${PREFIX}; \ + MKCATPAGES=yes; export MKCATPAGES; \ + \ + echo =========== all ============; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= install ==========; \ + ${MAKE} ${MAKEFLAGS} install -j3 DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type l -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======== uninstall =========; \ + ${MAKE} ${MAKEFLAGS} -j4 uninstall DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========== clean ===========; \ + ${MAKE} ${MAKEFLAGS} clean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========== depend ===========; \ + ${MAKE} ${MAKEFLAGS} depend DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======= distclean ==========; \ + ${MAKE} ${MAKEFLAGS} distclean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======= errorcheck ==========; \ + ${MAKE} ${MAKEFLAGS} errorcheck > /dev/null 2>&1; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + ${MAKE} ${MAKEFLAGS} cleandir > /dev/null 2>&1; \ + \ + echo ==== install MKINSTALL=no ====; \ + MKINSTALL=no; export MKINSTALL; \ + ${MAKE} ${MAKEFLAGS} all installdirs install -j3 DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; unset MKINSTALL; \ + \ + echo =========== Michael mode: all ============; \ + MICHAEL_MODE=1; export MICHAEL_MODE; \ + env init_make_level=${next_level} ${MAKE} ${MAKEFLAGS} all > /dev/null 2>&1; \ + find ${TMPPREFIX} -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo =========== Michael mode: clean ============; \ + env init_make_level=${next_level} ${MAKE} ${MAKEFLAGS} clean > /dev/null 2>&1; \ + find ${TMPPREFIX} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo =========== Michael mode: cleandir ============; \ + env init_make_level=${next_level} ${MAKE} ${MAKEFLAGS} all > /dev/null 2>&1; \ + env init_make_level=${next_level} ${MAKE} ${MAKEFLAGS} cleandir > /dev/null 2>&1; \ + find ${TMPPREFIX} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + true ======= distclean ==========; \ + ${MAKE} ${MAKEFLAGS} distclean DESTDIR=${.OBJDIR} > /dev/null + +CLEANDIRS += ${TMPPREFIX} + +.include <mkc.minitest.mk> diff --git a/examples/hello_world/COPYRIGHT b/examples/hello_world/COPYRIGHT new file mode 100644 index 0000000..32a633d --- /dev/null +++ b/examples/hello_world/COPYRIGHT @@ -0,0 +1,2 @@ +Everything here was written by Aleksey Cheusov <vle@gmx.net>. +Public domain. diff --git a/examples/hello_world/Makefile b/examples/hello_world/Makefile new file mode 100644 index 0000000..b993754 --- /dev/null +++ b/examples/hello_world/Makefile @@ -0,0 +1,13 @@ +DOCDIR ?= ${DATADIR}/doc/${PROG} + +PROG = hello_world + +WARNS = 4 + +FILES = COPYRIGHT README +FILESDIR = ${DOCDIR} + +MKC_REQD = 0.10.0 + +.include "test.mk" +.include <mkc.prog.mk> diff --git a/examples/hello_world/README b/examples/hello_world/README new file mode 100644 index 0000000..84f435c --- /dev/null +++ b/examples/hello_world/README @@ -0,0 +1,9 @@ +This is a well known "hello world" application. +It provides "hello_world" application written in C +and nothing else. + +In order to build this program run the following commands: + + bmake # for bulding + bmake installdirs # for creating destination directories + bmake install # for installing files diff --git a/examples/hello_world/expect.out b/examples/hello_world/expect.out new file mode 100644 index 0000000..9de8b7c --- /dev/null +++ b/examples/hello_world/expect.out @@ -0,0 +1,80 @@ +PROJECTNAME=hello_world +Hello World! +=========== all ============ +/objdir/COPYRIGHT +/objdir/Makefile +/objdir/README +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/expect.out +/objdir/hello_world +/objdir/hello_world.c +/objdir/hello_world.o +/objdir/hello_world.test.out.tmp +/objdir/test.mk +========= install ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/bin/hello_world +/objdir/prefix/share +/objdir/prefix/share/doc +/objdir/prefix/share/doc/hello_world +/objdir/prefix/share/doc/hello_world/COPYRIGHT +/objdir/prefix/share/doc/hello_world/README +======== uninstall ========= +========== clean =========== +/objdir/COPYRIGHT +/objdir/Makefile +/objdir/README +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/expect.out +/objdir/hello_world.c +/objdir/hello_world.test.out.tmp +/objdir/test.mk +======== bin_tar =========== +usr +usr/local +usr/local/bin +usr/local/bin/hello_world +usr/local/share +usr/local/share/doc +usr/local/share/doc/hello_world +usr/local/share/doc/hello_world/COPYRIGHT +usr/local/share/doc/hello_world/README +======== bin_targz =========== +usr +usr/local +usr/local/bin +usr/local/bin/hello_world +usr/local/share +usr/local/share/doc +usr/local/share/doc/hello_world +usr/local/share/doc/hello_world/COPYRIGHT +usr/local/share/doc/hello_world/README +======== bin_tarbz2 =========== +usr +usr/local +usr/local/bin +usr/local/bin/hello_world +usr/local/share +usr/local/share/doc +usr/local/share/doc/hello_world +usr/local/share/doc/hello_world/COPYRIGHT +usr/local/share/doc/hello_world/README +======= filelist =========== +/usr/local/bin/hello_world +/usr/local/share/doc/hello_world/COPYRIGHT +/usr/local/share/doc/hello_world/README +======= distclean ========== +/objdir/COPYRIGHT +/objdir/Makefile +/objdir/README +/objdir/expect.out +/objdir/hello_world.c +/objdir/hello_world.test.out.tmp +/objdir/test.mk diff --git a/examples/hello_world/hello_world.c b/examples/hello_world/hello_world.c new file mode 100644 index 0000000..3d8f214 --- /dev/null +++ b/examples/hello_world/hello_world.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main (int argc, char** argv) +{ + puts ("Hello World!"); + return 0; +} diff --git a/examples/hello_world/test.mk b/examples/hello_world/test.mk new file mode 100644 index 0000000..6676191 --- /dev/null +++ b/examples/hello_world/test.mk @@ -0,0 +1,58 @@ +DISTCLEANDIRS+= *.tar *.tar.gz *.tar.bz2 + +tartf_cleanup= sed -e 's,^[.]/,,' -e 's,/$$,,' -e '/^[.]*$$/ d' + +.PHONY : test_output +test_output: + @set -e; LC_ALL=C; export LC_ALL; \ + MKCATPAGES=yes; export MKCATPAGES; \ + echo PROJECTNAME=${PROJECTNAME}; \ + ${.OBJDIR}/hello_world; \ + rm -rf ${.OBJDIR}${PREFIX}; \ + \ + echo =========== all ============; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= install ==========; \ + ${MAKE} ${MAKEFLAGS} install -j3 DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======== uninstall =========; \ + ${MAKE} ${MAKEFLAGS} -j4 uninstall DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ========== clean ===========; \ + ${MAKE} ${MAKEFLAGS} clean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ======== bin_tar ===========; \ + ${MAKE} ${MAKEFLAGS} PREFIX=/usr/local bin_tar > /dev/null; \ + ${TAR} -tf ${.CURDIR:T}.tar | \ + sort | ${tartf_cleanup}; \ + \ + echo ======== bin_targz ===========; \ + ${MAKE} ${MAKEFLAGS} PREFIX=/usr/local bin_targz > /dev/null; \ + ${GZIP} -dc ${.CURDIR:T}.tar.gz | \ + ${TAR} -tf - | \ + sort | ${tartf_cleanup}; \ + \ + echo ======== bin_tarbz2 ===========; \ + ${MAKE} ${MAKEFLAGS} PREFIX=/usr/local bin_tarbz2 > /dev/null; \ + ${BZIP2} -dc ${.CURDIR:T}.tar.bz2 | \ + ${TAR} -tf - | \ + sort | ${tartf_cleanup}; \ + \ + echo ======= filelist ===========; \ + ${MAKE} ${MAKEFLAGS} PREFIX=/usr/local filelist; \ + \ + echo ======= distclean ==========; \ + ${MAKE} ${MAKEFLAGS} distclean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}" + +.include <mkc.minitest.mk> diff --git a/examples/hello_xxzip/Makefile b/examples/hello_xxzip/Makefile new file mode 100644 index 0000000..be0eb51 --- /dev/null +++ b/examples/hello_xxzip/Makefile @@ -0,0 +1,30 @@ +PROG = xxzip +MAN = xxzip.1 + +# manual page and tutorial will be generated from .pod documents, so +# we need pod2man and pod2html. +MKC_REQUIRE_PROGS = ${POD2MAN} ${POD2HTML} + +MKPIE ?= yes +USE_SSP ?= yes +USE_RELRO ?= yes + +WARNS = 4 + +DOCDIR ?= ${DATADIR}/doc/${PROG} + +MLINKS = xxzip.1 xxunzip.1 +MLINKS += xxzip.1 xxzcat.1 + +LINKS = ${BINDIR}/xxzip ${BINDIR}/xxunzip +LINKS += ${BINDIR}/xxzip ${BINDIR}/xxzcat + +FILES = tutorial.html +FILESDIR = ${DOCDIR} + +WARNS = 4 + +CLEANFILES += xxzip.1 tutorial.html + +.include "test.mk" +.include <mkc.prog.mk> diff --git a/examples/hello_xxzip/expect.out b/examples/hello_xxzip/expect.out new file mode 100644 index 0000000..cb5f8cb --- /dev/null +++ b/examples/hello_xxzip/expect.out @@ -0,0 +1,81 @@ +=========== all ============ +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/_mkc_prog_pod2html.err +/objdir/_mkc_prog_pod2html.res +/objdir/_mkc_prog_pod2man.err +/objdir/_mkc_prog_pod2man.res +/objdir/expect.out +/objdir/hello_xxzip.test.out.tmp +/objdir/test.mk +/objdir/tutorial.html +/objdir/tutorial.pod +/objdir/xxzip +/objdir/xxzip.1 +/objdir/xxzip.c +/objdir/xxzip.o +/objdir/xxzip.pod +===== all SHRTOUT=yes ====== +CC: xxzip.c +LD: xxzip +POD2MAN: xxzip.1 +NROFF: xxzip.cat1 +POD2HTML: tutorial.html +========= install ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/bin/xxunzip +/objdir/prefix/bin/xxzcat +/objdir/prefix/bin/xxzip +/objdir/prefix/man +/objdir/prefix/man/cat1 +/objdir/prefix/man/cat1/xxunzip.0 +/objdir/prefix/man/cat1/xxzcat.0 +/objdir/prefix/man/cat1/xxzip.0 +/objdir/prefix/man/man1 +/objdir/prefix/man/man1/xxunzip.1 +/objdir/prefix/man/man1/xxzcat.1 +/objdir/prefix/man/man1/xxzip.1 +/objdir/prefix/share +/objdir/prefix/share/doc +/objdir/prefix/share/doc/xxzip +/objdir/prefix/share/doc/xxzip/tutorial.html +======== uninstall ========= +========== clean =========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/_mkc_prog_pod2html.err +/objdir/_mkc_prog_pod2html.res +/objdir/_mkc_prog_pod2man.err +/objdir/_mkc_prog_pod2man.res +/objdir/expect.out +/objdir/hello_xxzip.test.out.tmp +/objdir/test.mk +/objdir/tutorial.pod +/objdir/xxzip.c +/objdir/xxzip.pod +======== filelist ========== +/usr/local/bin/xxunzip +/usr/local/bin/xxzcat +/usr/local/bin/xxzip +/usr/local/man/cat1/xxunzip.0 +/usr/local/man/cat1/xxzcat.0 +/usr/local/man/cat1/xxzip.0 +/usr/local/man/man1/xxunzip.1 +/usr/local/man/man1/xxzcat.1 +/usr/local/man/man1/xxzip.1 +/usr/local/share/doc/xxzip/tutorial.html +======= distclean ========== +/objdir/Makefile +/objdir/expect.out +/objdir/hello_xxzip.test.out.tmp +/objdir/test.mk +/objdir/tutorial.pod +/objdir/xxzip.c +/objdir/xxzip.pod diff --git a/examples/hello_xxzip/test.mk b/examples/hello_xxzip/test.mk new file mode 100644 index 0000000..6b3fda0 --- /dev/null +++ b/examples/hello_xxzip/test.mk @@ -0,0 +1,41 @@ +.PHONY : test_output +test_output: + @set -e; \ + MKCATPAGES=yes; export MKCATPAGES; \ + \ + rm -rf ${.OBJDIR}${PREFIX}; \ + \ + echo =========== all ============; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ===== all SHRTOUT=yes ======; \ + ${MAKE} ${MAKEFLAGS} clean > /dev/null; \ + ${MAKE} ${MAKEFLAGS} all SHRTOUT=yes 2>&1 | \ + mkc_test_helper2; \ + \ + echo ========= install ==========; \ + ${MAKE} ${MAKEFLAGS} install -j3 DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======== uninstall =========; \ + ${MAKE} ${MAKEFLAGS} -j4 uninstall DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ========== clean ===========; \ + ${MAKE} ${MAKEFLAGS} clean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ======== filelist ==========; \ + ${MAKE} ${MAKEFLAGS} filelist PREFIX=/usr/local; \ + \ + echo ======= distclean ==========; \ + ${MAKE} ${MAKEFLAGS} distclean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}" + +.include <mkc.minitest.mk> diff --git a/examples/hello_xxzip/tutorial.pod b/examples/hello_xxzip/tutorial.pod new file mode 100644 index 0000000..1973efa --- /dev/null +++ b/examples/hello_xxzip/tutorial.pod @@ -0,0 +1,17 @@ +=head1 NAME + +xxzip - super-puper compression utility + +=head1 INTRODCTION + +lalala + +=head1 STEP1 + +bla bla bla + +=head1 STEP2 + +bla bla bla + +=head1 BYE diff --git a/examples/hello_xxzip/xxzip.c b/examples/hello_xxzip/xxzip.c new file mode 100644 index 0000000..2ced760 --- /dev/null +++ b/examples/hello_xxzip/xxzip.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main (int argc, char **argv) +{ + puts ("xxzip compression utility\n"); + return 0; +} diff --git a/examples/hello_xxzip/xxzip.pod b/examples/hello_xxzip/xxzip.pod new file mode 100644 index 0000000..51ab8b3 --- /dev/null +++ b/examples/hello_xxzip/xxzip.pod @@ -0,0 +1,44 @@ +=head1 NAME + +xxzip - super-puper compression utility + +=head1 SYNOPSIS + +B<xxzip> I<[options]> I<[files...]> + +B<xxunzip> I<[options]> I<[files...]> + +B<xxzcat> I<[options]> I<[files...]> + +=head1 DESCRIPTION + +bla bla bla + +=head1 OPTIONS + +=over 6 + +=item B<-h> + +Display help information. + +=item B<-c> + +Output to the standard output stream + +=item B<-d> + +This option selects decompression rather than compression. + +=back + +=head1 AUTHOR + +Copyright (c) 2010 Aleksey Cheusov <vle@gmx.net> + +=head1 HOME + +L<http://sourceforge.net/projects/mk-configure> + +=head1 SEE ALSO +L<mk-configure(7)> diff --git a/examples/hello_yacc/Makefile b/examples/hello_yacc/Makefile new file mode 100644 index 0000000..cfb88da --- /dev/null +++ b/examples/hello_yacc/Makefile @@ -0,0 +1,7 @@ +PROG = hello_calc +SRCS = calc.y + +DPSRCS = calc.c + +.include "test.mk" +.include <mkc.prog.mk> diff --git a/examples/hello_yacc/calc.y b/examples/hello_yacc/calc.y new file mode 100644 index 0000000..a80fc30 --- /dev/null +++ b/examples/hello_yacc/calc.y @@ -0,0 +1,49 @@ +%{ +#include <ctype.h> +#include <stdio.h> + +#define YYSTYPE int +void yyerror (char const *s); +%} + +%token NUMBER +%left '+' '-' +%right '*' '/' + +%% + +lines : lines expr '\n' { printf ("%i\n", $2); } + | lines '\n' + | + ; + +expr : expr '+' expr { $$ = $1 + $3; } + | expr '-' expr { $$ = $1 - $3; } + | expr '*' expr { $$ = $1 * $3; } + | expr '-' expr { $$ = $1 / $3; } + | '(' expr ')' { $$ = $2; } + | NUMBER + ; + +%% + +yylex (){ + int c = getchar (); + + if (c >= '0' && c <= '9'){ + yylval = c - '0'; + return NUMBER; + } + return c; +} + +void yyerror (char const *s) +{ + fprintf (stderr, "%s\n", s); +} + +int main (int argc, char **argv) +{ + yyparse (); + return 0; +} diff --git a/examples/hello_yacc/expect.out b/examples/hello_yacc/expect.out new file mode 100644 index 0000000..b80f1ca --- /dev/null +++ b/examples/hello_yacc/expect.out @@ -0,0 +1,65 @@ +4 +45 +-1 +45 +=========== all ============ +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/_mkc_prog_yacc.err +/objdir/_mkc_prog_yacc.res +/objdir/calc.c +/objdir/calc.o +/objdir/calc.y +/objdir/expect.out +/objdir/hello_calc +/objdir/hello_yacc.test.out.tmp +/objdir/input.txt +/objdir/test.mk +========= install ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/bin/hello_calc +======== uninstall ========= +========== clean =========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/_mkc_prog_yacc.err +/objdir/_mkc_prog_yacc.res +/objdir/calc.y +/objdir/expect.out +/objdir/hello_yacc.test.out.tmp +/objdir/input.txt +/objdir/test.mk +========== depend =========== +/objdir/.depend +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/_mkc_prog_yacc.err +/objdir/_mkc_prog_yacc.res +/objdir/calc.c +/objdir/calc.d +/objdir/calc.y +/objdir/expect.out +/objdir/hello_yacc.test.out.tmp +/objdir/input.txt +/objdir/test.mk +==== SHRTOUT=yes ==== +YACC: calc.y +CC: calc.c +LD: hello_calc +======= distclean ========== +/objdir/Makefile +/objdir/calc.y +/objdir/expect.out +/objdir/hello_yacc.test.out.tmp +/objdir/input.txt +/objdir/test.mk diff --git a/examples/hello_yacc/input.txt b/examples/hello_yacc/input.txt new file mode 100644 index 0000000..5a5beae --- /dev/null +++ b/examples/hello_yacc/input.txt @@ -0,0 +1,4 @@ +1+3 +5*9 +5-6 +(3+2)*(2+7) diff --git a/examples/hello_yacc/test.mk b/examples/hello_yacc/test.mk new file mode 100644 index 0000000..6ba98f6 --- /dev/null +++ b/examples/hello_yacc/test.mk @@ -0,0 +1,44 @@ +.PHONY : test_output +test_output: + @set -e; \ + MKCATPAGES=yes; export MKCATPAGES; \ + \ + ${.OBJDIR}/hello_calc < ${.CURDIR}/input.txt; \ + rm -rf ${.OBJDIR}${PREFIX}; \ + \ + echo =========== all ============; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= install ==========; \ + ${MAKE} ${MAKEFLAGS} install -j3 DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======== uninstall =========; \ + ${MAKE} ${MAKEFLAGS} -j4 uninstall DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ========== clean ===========; \ + ${MAKE} ${MAKEFLAGS} clean > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ========== depend ===========; \ + ${MAKE} ${MAKEFLAGS} depend > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ==== SHRTOUT=yes ====; \ + ${MAKE} ${MAKEFLAGS} distclean > /dev/null; \ + env MKCATPAGES=no MKHTML=no ${MAKE} ${MAKEFLAGS} SHRTOUT=yes \ + all 2>/dev/null | mkc_test_helper2; \ + \ + echo ======= distclean ==========; \ + ${MAKE} ${MAKEFLAGS} distclean > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}" + +.include <mkc.minitest.mk> diff --git a/examples/pkgconfig3/Makefile b/examples/pkgconfig3/Makefile new file mode 100644 index 0000000..6ba35f8 --- /dev/null +++ b/examples/pkgconfig3/Makefile @@ -0,0 +1,8 @@ +PROG = pkgconfig3 + +MKC_CHECK_PKGCONFIG = zzzz>=2.1 + +MKC_REQD = 0.26.0 + +.include "test.mk" +.include <mkc.prog.mk> diff --git a/examples/pkgconfig3/expect.out b/examples/pkgconfig3/expect.out new file mode 100644 index 0000000..7f4cc7d --- /dev/null +++ b/examples/pkgconfig3/expect.out @@ -0,0 +1 @@ +pkg-config module 'zzz' was not found diff --git a/examples/pkgconfig3/pkgconfig3.c b/examples/pkgconfig3/pkgconfig3.c new file mode 100644 index 0000000..954b353 --- /dev/null +++ b/examples/pkgconfig3/pkgconfig3.c @@ -0,0 +1,13 @@ +#include <stdio.h> +#include <stdlib.h> + +int main (int argc, char** argv) +{ +#if HAVE_PKGCONFIG_ZZZ + abort (); /* this should not happen */ +#else + puts ("pkg-config module 'zzz' was not found"); +#endif + + return 0; +} diff --git a/examples/pkgconfig3/test.mk b/examples/pkgconfig3/test.mk new file mode 100644 index 0000000..8d7ac0c --- /dev/null +++ b/examples/pkgconfig3/test.mk @@ -0,0 +1,7 @@ +.PHONY : test_output +test_output: + @set -e; \ + ${.OBJDIR}/pkgconfig3; \ + ${MAKE} ${MAKEFLAGS} distclean DESTDIR=${.OBJDIR} > /dev/null + +.include <mkc.minitest.mk> diff --git a/examples/subprojects/Makefile b/examples/subprojects/Makefile new file mode 100644 index 0000000..10c642c --- /dev/null +++ b/examples/subprojects/Makefile @@ -0,0 +1,62 @@ +# main code +SUBDIR += libhello1 +SUBDIR += libhello2 +SUBDIR += .WAIT +SUBDIR += hello + +MKC_REQD = 0.11.0 + +# for regression test only +_THISDIR_ = +.export _THISDIR_ + +# A simpliest way to build debug and release version is to specify +# appropriate targets like the following. +.PHONY: debug release +debug: + set -e; \ + COPTS='${COPTS} -O0 -g'; LDFLAGS='${LDFLAGS} -g'; \ + MAKEOBJDIR=${.CURDIR}/debug; MKRELOBJDIR=yes; \ + export COPTS LDFLAGS MAKEOBJDIR MKRELOBJDIR; \ + mkdir -p $$MAKEOBJDIR;\ + ${MAKE} ${MAKEFLAGS} all +release: + set -e; \ + COPTS='${COPTS} -O'; \ + MAKEOBJDIR=${.CURDIR}/release; MKRELOBJDIR=yes; \ + export COPTS MAKEOBJDIR MKRELOBJDIR; \ + mkdir -p $$MAKEOBJDIR;\ + ${MAKE} ${MAKEFLAGS} all +.if make(debug) || make(release) +MKCHECKS = no +.endif + +# Alternatively (and better!) one can introduce special variable for +# this purpose like the following +.include <mkc.init.mk> # we need ${MKDIR} + +.if defined(BM) # BuildMode +. if ${BM} == "release" +COPTS += -O +MAKEOBJDIR = ${.CURDIR}/obj/release +. elif ${BM} == "debug" +COPTS += -O0 -g +LDFLAGS += -g +MAKEOBJDIR = ${.CURDIR}/obj/debug +. elif ${BM} == "profile" +COPTS += -O0 -g -pg +LDFLAGS += -pg +MAKEOBJDIR = ${.CURDIR}/obj/profile +. else +.error "Unsupported value of BM" +. endif +.OBJDIR = ${MAKEOBJDIR} +MKRELOBJDIR = yes +fake != ${MKDIR} -p ${MAKEOBJDIR}; echo # ${MAKEOBJDIR} must exist +.export COPTS LDFLAGS +.endif # defined(BM) + +# +.include "test.mk" +.include "version.mk" +.include <mkc.subdir.mk> diff --git a/examples/subprojects/expect.out b/examples/subprojects/expect.out new file mode 100644 index 0000000..b42cb16 --- /dev/null +++ b/examples/subprojects/expect.out @@ -0,0 +1,304 @@ +PROJECTNAME=subprojects +Hello1 +Hello v.1.2.3 +Hello2 +Hello World! version 1.2.3 +My email is vle@gmx.net +=========== all ============ +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_header_stdio_h.c +/objdir/_mkc_header_stdio_h.err +/objdir/_mkc_header_stdio_h.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/expect.out +/objdir/hello/Makefile +/objdir/hello/hello_subprojects +/objdir/hello/hello_subprojects.1 +/objdir/hello/hello_subprojects.1.in +/objdir/hello/hello_subprojects.c +/objdir/hello/hello_subprojects.o +/objdir/hello/hello_subprojects2 +/objdir/hello/hello_subprojects2.in +/objdir/hello/test.mk +/objdir/libhello1/Makefile +/objdir/libhello1/hello1.c +/objdir/libhello1/hello1.h +/objdir/libhello1/hello1.o +/objdir/libhello1/hello1.os +/objdir/libhello1/libhello1.a +/objdir/libhello1/libhello1.so +/objdir/libhello1/libhello1.so.1 +/objdir/libhello1/libhello1.so.1.0 +/objdir/libhello1/linkme.mk +/objdir/libhello2/Makefile +/objdir/libhello2/hello2.3 +/objdir/libhello2/hello2.c +/objdir/libhello2/hello2.o +/objdir/libhello2/include/hello2.h +/objdir/libhello2/libhello2.a +/objdir/libhello2/linkme.mk +/objdir/subprojects.test.out.tmp +/objdir/test.mk +/objdir/version.mk +===== all SHRTOUT=yes ====== +================================================== +all ===> libhello1 +CC: hello1.c +AR: libhello1.a +CC: hello1.c +LD: libhello1.so.1.0 +================================================== +all ===> libhello2 +CC: hello2.c +AR: libhello2.a +NROFF: hello2.cat3 +================================================== +all ===> hello +CC: hello_subprojects.c +LD: hello_subprojects +GEN: hello_subprojects.1 +NROFF: hello_subprojects.cat1 +GEN: hello_subprojects2 +========= installdirs ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/include +/objdir/prefix/lib +/objdir/prefix/man +/objdir/prefix/man/cat1 +/objdir/prefix/man/man1 +========= install ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/bin/hello_subprojects +/objdir/prefix/bin/hello_subprojects2 +/objdir/prefix/include +/objdir/prefix/include/hello1.h +/objdir/prefix/lib +/objdir/prefix/lib/libhello1.a +/objdir/prefix/lib/libhello1.so +/objdir/prefix/lib/libhello1.so.1 +/objdir/prefix/lib/libhello1.so.1.0 +/objdir/prefix/man +/objdir/prefix/man/cat1 +/objdir/prefix/man/cat1/hello_subprojects.0 +/objdir/prefix/man/man1 +/objdir/prefix/man/man1/hello_subprojects.1 +======== uninstall ========= +========== clean =========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_header_stdio_h.c +/objdir/_mkc_header_stdio_h.err +/objdir/_mkc_header_stdio_h.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/expect.out +/objdir/hello/Makefile +/objdir/hello/hello_subprojects.1.in +/objdir/hello/hello_subprojects.c +/objdir/hello/hello_subprojects2.in +/objdir/hello/test.mk +/objdir/libhello1/Makefile +/objdir/libhello1/hello1.c +/objdir/libhello1/hello1.h +/objdir/libhello1/linkme.mk +/objdir/libhello2/Makefile +/objdir/libhello2/hello2.3 +/objdir/libhello2/hello2.c +/objdir/libhello2/include/hello2.h +/objdir/libhello2/linkme.mk +/objdir/subprojects.test.out.tmp +/objdir/test.mk +/objdir/version.mk +======= distclean ========== +/objdir/Makefile +/objdir/expect.out +/objdir/hello/Makefile +/objdir/hello/hello_subprojects.1.in +/objdir/hello/hello_subprojects.c +/objdir/hello/hello_subprojects2.in +/objdir/hello/test.mk +/objdir/libhello1/Makefile +/objdir/libhello1/hello1.c +/objdir/libhello1/hello1.h +/objdir/libhello1/linkme.mk +/objdir/libhello2/Makefile +/objdir/libhello2/hello2.3 +/objdir/libhello2/hello2.c +/objdir/libhello2/include/hello2.h +/objdir/libhello2/linkme.mk +/objdir/subprojects.test.out.tmp +/objdir/test.mk +/objdir/version.mk +======== errorcheck ========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_header_stdio_h.c +/objdir/_mkc_header_stdio_h.err +/objdir/_mkc_header_stdio_h.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/expect.out +/objdir/hello/Makefile +/objdir/hello/hello_subprojects.1.in +/objdir/hello/hello_subprojects.c +/objdir/hello/hello_subprojects2.in +/objdir/hello/test.mk +/objdir/libhello1/Makefile +/objdir/libhello1/hello1.c +/objdir/libhello1/hello1.h +/objdir/libhello1/linkme.mk +/objdir/libhello2/Makefile +/objdir/libhello2/hello2.3 +/objdir/libhello2/hello2.c +/objdir/libhello2/include/hello2.h +/objdir/libhello2/linkme.mk +/objdir/subprojects.test.out.tmp +/objdir/test.mk +/objdir/version.mk +========= libhello1 ========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/expect.out +/objdir/hello/Makefile +/objdir/hello/hello_subprojects.1.in +/objdir/hello/hello_subprojects.c +/objdir/hello/hello_subprojects2.in +/objdir/hello/test.mk +/objdir/libhello1/Makefile +/objdir/libhello1/hello1.c +/objdir/libhello1/hello1.h +/objdir/libhello1/hello1.o +/objdir/libhello1/hello1.os +/objdir/libhello1/libhello1.a +/objdir/libhello1/libhello1.so +/objdir/libhello1/libhello1.so.1 +/objdir/libhello1/libhello1.so.1.0 +/objdir/libhello1/linkme.mk +/objdir/libhello2/Makefile +/objdir/libhello2/hello2.3 +/objdir/libhello2/hello2.c +/objdir/libhello2/include/hello2.h +/objdir/libhello2/linkme.mk +/objdir/subprojects.test.out.tmp +/objdir/test.mk +/objdir/version.mk +========= all-libhello2 ========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/expect.out +/objdir/hello/Makefile +/objdir/hello/hello_subprojects.1.in +/objdir/hello/hello_subprojects.c +/objdir/hello/hello_subprojects2.in +/objdir/hello/test.mk +/objdir/libhello1/Makefile +/objdir/libhello1/hello1.c +/objdir/libhello1/hello1.h +/objdir/libhello1/hello1.o +/objdir/libhello1/hello1.os +/objdir/libhello1/libhello1.a +/objdir/libhello1/libhello1.so +/objdir/libhello1/libhello1.so.1 +/objdir/libhello1/libhello1.so.1.0 +/objdir/libhello1/linkme.mk +/objdir/libhello2/Makefile +/objdir/libhello2/hello2.3 +/objdir/libhello2/hello2.c +/objdir/libhello2/hello2.cat3 +/objdir/libhello2/hello2.o +/objdir/libhello2/include/hello2.h +/objdir/libhello2/libhello2.a +/objdir/libhello2/linkme.mk +/objdir/subprojects.test.out.tmp +/objdir/test.mk +/objdir/version.mk +========= cleandir-libhello1 ========== +/objdir/Makefile +/objdir/expect.out +/objdir/hello/Makefile +/objdir/hello/hello_subprojects.1.in +/objdir/hello/hello_subprojects.c +/objdir/hello/hello_subprojects2.in +/objdir/hello/test.mk +/objdir/libhello1/Makefile +/objdir/libhello1/hello1.c +/objdir/libhello1/hello1.h +/objdir/libhello1/linkme.mk +/objdir/libhello2/Makefile +/objdir/libhello2/hello2.3 +/objdir/libhello2/hello2.c +/objdir/libhello2/hello2.cat3 +/objdir/libhello2/hello2.o +/objdir/libhello2/include/hello2.h +/objdir/libhello2/libhello2.a +/objdir/libhello2/linkme.mk +/objdir/subprojects.test.out.tmp +/objdir/test.mk +/objdir/version.mk +======= debug/release ======= +/objdir/debug/hello/hello_subprojects +/objdir/debug/hello/hello_subprojects.1 +/objdir/debug/hello/hello_subprojects.cat1 +/objdir/debug/hello/hello_subprojects.o +/objdir/debug/hello/hello_subprojects2 +/objdir/debug/libhello1/hello1.o +/objdir/debug/libhello1/hello1.os +/objdir/debug/libhello1/libhello1.a +/objdir/debug/libhello1/libhello1.so.1.0 +/objdir/debug/libhello2/hello2.cat3 +/objdir/debug/libhello2/hello2.o +/objdir/debug/libhello2/libhello2.a +/objdir/release/hello/hello_subprojects +/objdir/release/hello/hello_subprojects.1 +/objdir/release/hello/hello_subprojects.cat1 +/objdir/release/hello/hello_subprojects.o +/objdir/release/hello/hello_subprojects2 +/objdir/release/libhello1/hello1.o +/objdir/release/libhello1/hello1.os +/objdir/release/libhello1/libhello1.a +/objdir/release/libhello1/libhello1.so.1.0 +/objdir/release/libhello2/hello2.cat3 +/objdir/release/libhello2/hello2.o +/objdir/release/libhello2/libhello2.a +======= drp ======= +/objdir/obj/debug/hello/hello_subprojects +/objdir/obj/debug/hello/hello_subprojects.1 +/objdir/obj/debug/hello/hello_subprojects.cat1 +/objdir/obj/debug/hello/hello_subprojects.o +/objdir/obj/debug/hello/hello_subprojects2 +/objdir/obj/debug/libhello1/hello1.o +/objdir/obj/debug/libhello1/hello1.os +/objdir/obj/debug/libhello1/libhello1.a +/objdir/obj/debug/libhello1/libhello1.so.1.0 +/objdir/obj/debug/libhello2/hello2.cat3 +/objdir/obj/debug/libhello2/hello2.o +/objdir/obj/debug/libhello2/libhello2.a +======= +/objdir/obj/release/hello/hello_subprojects +/objdir/obj/release/hello/hello_subprojects.1 +/objdir/obj/release/hello/hello_subprojects.cat1 +/objdir/obj/release/hello/hello_subprojects.o +/objdir/obj/release/hello/hello_subprojects2 +/objdir/obj/release/libhello1/hello1.o +/objdir/obj/release/libhello1/hello1.os +/objdir/obj/release/libhello1/libhello1.a +/objdir/obj/release/libhello1/libhello1.so.1.0 +/objdir/obj/release/libhello2/hello2.cat3 +/objdir/obj/release/libhello2/hello2.o +/objdir/obj/release/libhello2/libhello2.a +======= library dependencies ======= +Hello1 +Hello v.1.2.3 diff --git a/examples/subprojects/hello/Makefile b/examples/subprojects/hello/Makefile new file mode 100644 index 0000000..702fcb5 --- /dev/null +++ b/examples/subprojects/hello/Makefile @@ -0,0 +1,24 @@ +PROG = hello_subprojects +SRCS = hello_subprojects.c + +MAN = hello_subprojects.1 + +INFILES = hello_subprojects.1 +INSCRIPTS = hello_subprojects2 + +INTEXTS_REPLS += HELLO_VERSION ${VERSION} +INTEXTS_REPLS += MYEMAIL vle@gmx.net + +MKC_CHECK_HEADERS += stdio.h + +SCRIPTS = ${INSCRIPTS} + +.include <mkc.configure.mk> + +.include "../libhello1/linkme.mk" +.include "../libhello2/linkme.mk" + +.include "../version.mk" + +.include "test.mk" +.include <mkc.prog.mk> diff --git a/examples/subprojects/hello/hello_subprojects.1.in b/examples/subprojects/hello/hello_subprojects.1.in new file mode 100644 index 0000000..a4fea6d --- /dev/null +++ b/examples/subprojects/hello/hello_subprojects.1.in @@ -0,0 +1,18 @@ +.\" Written by by Aleksey Cheusov (vle@gmx.net) +.\" ------------------------------------------------------------------ +.TH HELLO_WORLD 1 "Mar 29, 2009" "" "" +.SH NAME +hello\_world \- hello application +.SH SYNOPSIS +.B "hello_world" +.br +.SH DESCRIPTION +.B hello\_world +outputs hello world message to stdout +.SH "CONFIGURATION FILE" +.TP +The configuration file should be here +.I @sysconfdir@/hello_world.conf +but it is not used. +.SH AUTHOR +Aleksey Cheusov <vle@gmx.net> diff --git a/examples/subprojects/hello/hello_subprojects.c b/examples/subprojects/hello/hello_subprojects.c new file mode 100644 index 0000000..a6123c5 --- /dev/null +++ b/examples/subprojects/hello/hello_subprojects.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +#include "hello1.h" +#include "hello2.h" + +int main (int argc, char **argv) +{ + printf ("%s\n%s\n", msg1, msg2); + return 0; +} diff --git a/examples/subprojects/hello/hello_subprojects2.in b/examples/subprojects/hello/hello_subprojects2.in new file mode 100755 index 0000000..f844792 --- /dev/null +++ b/examples/subprojects/hello/hello_subprojects2.in @@ -0,0 +1,5 @@ +#!/bin/sh + +echo 'Hello2' +echo 'Hello World! version @HELLO_VERSION@' +echo 'My email is @MYEMAIL@' diff --git a/examples/subprojects/hello/test.mk b/examples/subprojects/hello/test.mk new file mode 100644 index 0000000..76a978e --- /dev/null +++ b/examples/subprojects/hello/test.mk @@ -0,0 +1,2 @@ +test: + @echo 'This should not happen' diff --git a/examples/subprojects/libhello1/Makefile b/examples/subprojects/libhello1/Makefile new file mode 100644 index 0000000..e6e7747 --- /dev/null +++ b/examples/subprojects/libhello1/Makefile @@ -0,0 +1,9 @@ +LIB = hello1 +SRCS = hello1.c + +INCS = hello1.h + +SHLIB_MAJOR = 1 +SHLIB_MINOR = 0 + +.include <mkc.lib.mk> diff --git a/examples/subprojects/libhello1/hello1.c b/examples/subprojects/libhello1/hello1.c new file mode 100644 index 0000000..4ff7965 --- /dev/null +++ b/examples/subprojects/libhello1/hello1.c @@ -0,0 +1,3 @@ +#include "hello1.h" + +const char *msg1 = "Hello1"; diff --git a/examples/subprojects/libhello1/hello1.h b/examples/subprojects/libhello1/hello1.h new file mode 100644 index 0000000..edd7f85 --- /dev/null +++ b/examples/subprojects/libhello1/hello1.h @@ -0,0 +1,6 @@ +#ifndef _HELLO1_H_ +#define _HELLO1_H_ + +extern const char *msg1; + +#endif // _HELLO1_H_ diff --git a/examples/subprojects/libhello1/linkme.mk b/examples/subprojects/libhello1/linkme.mk new file mode 100644 index 0000000..41a35b6 --- /dev/null +++ b/examples/subprojects/libhello1/linkme.mk @@ -0,0 +1,5 @@ +PATH.hello1 := ${.PARSEDIR:tA} + +DPINCDIRS += ${PATH.hello1} +DPLIBDIRS += ${PATH.hello1} +DPLDADD += hello1 diff --git a/examples/subprojects/libhello2/Makefile b/examples/subprojects/libhello2/Makefile new file mode 100644 index 0000000..8b93678 --- /dev/null +++ b/examples/subprojects/libhello2/Makefile @@ -0,0 +1,14 @@ +LIB = hello2 +SRCS = hello2.c +MAN = hello2.3 + +INCS != echo include/*.h + +MKINSTALL ?= no # This is internal library, do not install it. + +CPPFLAGS += -I${.CURDIR}/include +CFLAGS += -DHELLO_VERSION='"${VERSION}"' + +.include "../version.mk" + +.include <mkc.lib.mk> diff --git a/examples/subprojects/libhello2/hello2.3 b/examples/subprojects/libhello2/hello2.3 new file mode 100644 index 0000000..d13b31b --- /dev/null +++ b/examples/subprojects/libhello2/hello2.3 @@ -0,0 +1,13 @@ +.\" Written by by Aleksey Cheusov (vle@gmx.net) +.\" ------------------------------------------------------------------ +.TH HELLO_WORLD 3 "May 14, 2010" "" "" +.SH NAME +hello2 \- C++ function +.SH SYNOPSIS +.B "hello2" +.br +.SH DESCRIPTION +.B hello2 +fake fake fake +.SH AUTHOR +Aleksey Cheusov <vle@gmx.net> diff --git a/examples/subprojects/libhello2/hello2.c b/examples/subprojects/libhello2/hello2.c new file mode 100644 index 0000000..d3c59bc --- /dev/null +++ b/examples/subprojects/libhello2/hello2.c @@ -0,0 +1,3 @@ +#include "hello2.h" + +const char *msg2 = "Hello v."HELLO_VERSION; diff --git a/examples/subprojects/libhello2/include/hello2.h b/examples/subprojects/libhello2/include/hello2.h new file mode 100644 index 0000000..bbcd5c0 --- /dev/null +++ b/examples/subprojects/libhello2/include/hello2.h @@ -0,0 +1,14 @@ +#ifndef _HELLO2_H_ +#define _HELLO2_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +extern const char *msg2; + +#ifdef __cplusplus +}; +#endif + +#endif // _HELLO2_H_ diff --git a/examples/subprojects/libhello2/linkme.mk b/examples/subprojects/libhello2/linkme.mk new file mode 100644 index 0000000..ca21bf6 --- /dev/null +++ b/examples/subprojects/libhello2/linkme.mk @@ -0,0 +1,5 @@ +PATH.hello2 := ${.PARSEDIR:tA} + +DPINCDIRS += ${PATH.hello2}/include +DPLIBDIRS += ${PATH.hello2} +DPLDADD += hello2 diff --git a/examples/subprojects/test.mk b/examples/subprojects/test.mk new file mode 100644 index 0000000..27b2071 --- /dev/null +++ b/examples/subprojects/test.mk @@ -0,0 +1,109 @@ +next_level != expr ${.MAKE.LEVEL} + 1 + +.PHONY : test_output +test_output : + @set -e; \ + MKCATPAGES=yes; export MKCATPAGES; \ + \ + echo PROJECTNAME=${PROJECTNAME}; \ + rm -rf ${.OBJDIR}${PREFIX}; \ + LD_LIBRARY_PATH=${.CURDIR}/libhello1:${.CURDIR}/libhello2:$$LD_LIBRARY_PATH; \ + DYLD_LIBRARY_PATH=${.CURDIR}/libhello1:${.CURDIR}/libhello2:$$LD_LIBRARY_PATH; \ + LIBRARY_PATH=$$LIBRARY_PATH:$$LD_LIBRARY_PATH; \ + MKINSTALLDIRS=no; \ + export LD_LIBRARY_PATH DYLD_LIBRARY_PATH LIBRARY_PATH; \ + ${.CURDIR}/hello/hello_subprojects; \ + ${.CURDIR}/hello/hello_subprojects2; \ + \ + echo =========== all ============; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ===== all SHRTOUT=yes ======; \ + ${MAKE} ${MAKEFLAGS} clean > /dev/null; \ + ${MAKE} ${MAKEFLAGS} all SHRTOUT=YES 2>&1 | \ + grep -v warning: | \ + mkc_test_helper_paths; \ + \ + echo ========= installdirs ==========; \ + ${MAKE} ${MAKEFLAGS} installdirs DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type l -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= install ==========; \ + ${MAKE} ${MAKEFLAGS} install -j3 DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type l -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======== uninstall =========; \ + ${MAKE} ${MAKEFLAGS} -j4 uninstall DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ========== clean ===========; \ + ${MAKE} ${MAKEFLAGS} clean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ======= distclean ==========; \ + ${MAKE} ${MAKEFLAGS} distclean > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======== errorcheck ==========; \ + ${MAKE} ${MAKEFLAGS} errorcheck 2> /dev/null 1>&2; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + ${MAKE} ${MAKEFLAGS} distclean > /dev/null; \ + \ + echo ========= libhello1 ==========; \ + ${MAKE} ${MAKEFLAGS} libhello1 DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= all-libhello2 ==========; \ + ${MAKE} ${MAKEFLAGS} -j4 all-libhello2 DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= cleandir-libhello1 ==========; \ + ${MAKE} ${MAKEFLAGS} cleandir-libhello1 DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + ${MAKE} ${MAKEFLAGS} distclean DESTDIR=${.OBJDIR} > /dev/null; \ + \ + echo ======= debug/release =======; \ + ${MAKE} ${MAKEFLAGS} cleandir > /dev/null; \ + env init_make_level=${next_level} ${MAKE} ${MAKEFLAGS} -j3 debug 1>&2; \ + env init_make_level=${next_level} ${MAKE} ${MAKEFLAGS} -j3 release 1>&2; \ + find ${.CURDIR}/release ${.CURDIR}/debug -type f | \ + mkc_test_helper "${PREFIX}" "${.CURDIR}"; \ + rm -rf ${.CURDIR}/release ${.CURDIR}/debug; \ + \ + echo ======= drp =======; \ + env BM=debug init_make_level=${next_level} \ + ${MAKE} ${MAKEFLAGS} -j3 all 1>&2; \ + find ${.CURDIR}/obj -type f | \ + mkc_test_helper "${PREFIX}" "${.CURDIR}"; \ + rm -rf ${.CURDIR}/obj; \ + echo =======; \ + env BM=release init_make_level=${next_level} \ + ${MAKE} ${MAKEFLAGS} -j3 all 1>&2; \ + find ${.CURDIR}/obj -type f | \ + mkc_test_helper "${PREFIX}" "${.CURDIR}"; \ + rm -rf ${.CURDIR}/obj; \ + \ + echo ======= library dependencies =======; \ + PREFIX=${.CURDIR}/usr; export PREFIX; \ + ${MAKE} ${MAKEFLAGS} all installdirs install -j3 >&2; \ + LD_LIBRARY_PATH=${.CURDIR}/usr/lib; \ + DYLD_LIBRARY_PATH=${.CURDIR}/usr/lib; \ + export LD_LIBRARY_PATH DYLD_LIBRARY_PATH; \ + ${.CURDIR}/usr/bin/hello_subprojects; \ + \ + ${MAKE} ${MAKEFLAGS} cleandir > /dev/null + +.include <mkc.minitest.mk> diff --git a/examples/subprojects/version.mk b/examples/subprojects/version.mk new file mode 100644 index 0000000..92d4398 --- /dev/null +++ b/examples/subprojects/version.mk @@ -0,0 +1 @@ +VERSION= 1.2.3 diff --git a/examples/tools/Makefile b/examples/tools/Makefile new file mode 100644 index 0000000..6d59113 --- /dev/null +++ b/examples/tools/Makefile @@ -0,0 +1,16 @@ +LIBDEPS = libs/foo:tools/prog1 +LIBDEPS += libs/bar:tools/prog2 +LIBDEPS += libs/foo:tools/prog3 libs/bar:tools/prog3 +LIBDEPS += libs/qux:tools/prog4 + +# target "check" is used for testing because "test" is used by mk-configure +TARGETS = check + +NODEPS += check-libs/*:check check-libs/*:check-tools/* + +# for regression test only +_THISDIR_ = +.export _THISDIR_ + +.include "test.mk" +.include <mkc.subprj.mk> diff --git a/examples/tools/expect.out b/examples/tools/expect.out new file mode 100644 index 0000000..3ffe8cd --- /dev/null +++ b/examples/tools/expect.out @@ -0,0 +1,491 @@ +PROJECTNAME=tools +This is a message #1 +Message #2 +This is a message #3 +Message #3 +int_size=n +OBJDIR_tools_prog1=/path/to/prog1 +OBJDIR_tools_prog2=/path/to/prog2 +OBJDIR_tools_prog3=/path/to/prog3 +OBJDIR_tools_prog4=/path/to/prog4 +OBJDIR_libs_foo=/path/to/foo +OBJDIR_libs_bar=/path/to/bar +OBJDIR_prog3=/path/to/prog3 +OBJDIR_bar=/path/to/bar +SRCDIR_tools_prog1=tools/tools/prog1 +SRCDIR_tools_prog2=tools/tools/prog2 +SRCDIR_tools_prog3=tools/tools/prog3 +SRCDIR_tools_prog4=tools/tools/prog4 +SRCDIR_libs_foo=tools/libs/foo +SRCDIR_libs_bar=tools/libs/bar +SRCDIR_prog3=tools/tools/prog3 +SRCDIR_bar=tools/libs/bar +=========== check ============ +================================================== +check ===> tools/prog1 +================================================== +check ===> tools/prog2 +================================================== +check ===> tools/prog3 +================================================== +check ===> tools/prog4 +=========== check-tools/prog1 ============ +================================================== +check ===> tools/prog1 +=========== all ============ +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/_mkc_sizeof_int.c +/objdir/_mkc_sizeof_int.err +/objdir/_mkc_sizeof_int.res +/objdir/expect.out +/objdir/libs/bar/Makefile +/objdir/libs/bar/bar.c +/objdir/libs/bar/bar.h +/objdir/libs/bar/bar.o +/objdir/libs/bar/libbar.a +/objdir/libs/foo/Makefile +/objdir/libs/foo/foo.c +/objdir/libs/foo/foo.h +/objdir/libs/foo/foo.o +/objdir/libs/foo/libfoo.a +/objdir/libs/qux/Makefile +/objdir/libs/qux/libqux.a +/objdir/libs/qux/qux.c +/objdir/libs/qux/qux.h +/objdir/libs/qux/qux.h.in +/objdir/libs/qux/qux.o +/objdir/test.mk +/objdir/tools.test.out.tmp +/objdir/tools/prog1/Makefile +/objdir/tools/prog1/prog1 +/objdir/tools/prog1/prog1.c +/objdir/tools/prog1/prog1.o +/objdir/tools/prog2/Makefile +/objdir/tools/prog2/prog2 +/objdir/tools/prog2/prog2.c +/objdir/tools/prog2/prog2.o +/objdir/tools/prog3/Makefile +/objdir/tools/prog3/prog3 +/objdir/tools/prog3/prog3.c +/objdir/tools/prog3/prog3.o +/objdir/tools/prog4/Makefile +/objdir/tools/prog4/prog4 +/objdir/tools/prog4/prog4.c +/objdir/tools/prog4/prog4.o +===== all SHRTOUT=yes ====== +================================================== +all ===> libs/bar +CC: bar.c +AR: libbar.a +================================================== +all ===> libs/foo +CC: foo.c +AR: libfoo.a +================================================== +all ===> libs/qux +GEN: qux.h +CC: qux.c +AR: libqux.a +================================================== +all ===> tools/prog1 +CC: prog1.c +LD: prog1 +================================================== +all ===> tools/prog2 +CC: prog2.c +LD: prog2 +================================================== +all ===> tools/prog3 +CC: prog3.c +LD: prog3 +================================================== +all ===> tools/prog4 +CC: prog4.c +LD: prog4 +========= installdirs ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/include +/objdir/prefix/lib +========= install ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/bin/prog1 +/objdir/prefix/bin/prog2 +/objdir/prefix/bin/prog3 +/objdir/prefix/bin/prog4 +/objdir/prefix/include +/objdir/prefix/include/bar.h +/objdir/prefix/include/foo.h +/objdir/prefix/include/qux.h +/objdir/prefix/lib +/objdir/prefix/lib/libbar.a +/objdir/prefix/lib/libfoo.a +/objdir/prefix/lib/libqux.a +======== uninstall ========= +========== clean =========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/_mkc_sizeof_int.c +/objdir/_mkc_sizeof_int.err +/objdir/_mkc_sizeof_int.res +/objdir/expect.out +/objdir/libs/bar/Makefile +/objdir/libs/bar/bar.c +/objdir/libs/bar/bar.h +/objdir/libs/foo/Makefile +/objdir/libs/foo/foo.c +/objdir/libs/foo/foo.h +/objdir/libs/qux/Makefile +/objdir/libs/qux/qux.c +/objdir/libs/qux/qux.h.in +/objdir/test.mk +/objdir/tools.test.out.tmp +/objdir/tools/prog1/Makefile +/objdir/tools/prog1/prog1.c +/objdir/tools/prog2/Makefile +/objdir/tools/prog2/prog2.c +/objdir/tools/prog3/Makefile +/objdir/tools/prog3/prog3.c +/objdir/tools/prog4/Makefile +/objdir/tools/prog4/prog4.c +======= cleandir ========== +/objdir/Makefile +/objdir/expect.out +/objdir/libs/bar/Makefile +/objdir/libs/bar/bar.c +/objdir/libs/bar/bar.h +/objdir/libs/foo/Makefile +/objdir/libs/foo/foo.c +/objdir/libs/foo/foo.h +/objdir/libs/qux/Makefile +/objdir/libs/qux/qux.c +/objdir/libs/qux/qux.h.in +/objdir/test.mk +/objdir/tools.test.out.tmp +/objdir/tools/prog1/Makefile +/objdir/tools/prog1/prog1.c +/objdir/tools/prog2/Makefile +/objdir/tools/prog2/prog2.c +/objdir/tools/prog3/Makefile +/objdir/tools/prog3/prog3.c +/objdir/tools/prog4/Makefile +/objdir/tools/prog4/prog4.c +========= all-tools/prog1 ========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/expect.out +/objdir/libs/bar/Makefile +/objdir/libs/bar/bar.c +/objdir/libs/bar/bar.h +/objdir/libs/foo/Makefile +/objdir/libs/foo/foo.c +/objdir/libs/foo/foo.h +/objdir/libs/foo/foo.o +/objdir/libs/foo/libfoo.a +/objdir/libs/qux/Makefile +/objdir/libs/qux/qux.c +/objdir/libs/qux/qux.h.in +/objdir/test.mk +/objdir/tools.test.out.tmp +/objdir/tools/prog1/Makefile +/objdir/tools/prog1/prog1 +/objdir/tools/prog1/prog1.c +/objdir/tools/prog1/prog1.o +/objdir/tools/prog2/Makefile +/objdir/tools/prog2/prog2.c +/objdir/tools/prog3/Makefile +/objdir/tools/prog3/prog3.c +/objdir/tools/prog4/Makefile +/objdir/tools/prog4/prog4.c +========= -C tools/prog1 all ========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/expect.out +/objdir/libs/bar/Makefile +/objdir/libs/bar/bar.c +/objdir/libs/bar/bar.h +/objdir/libs/foo/Makefile +/objdir/libs/foo/foo.c +/objdir/libs/foo/foo.h +/objdir/libs/foo/foo.o +/objdir/libs/foo/libfoo.a +/objdir/libs/qux/Makefile +/objdir/libs/qux/qux.c +/objdir/libs/qux/qux.h.in +/objdir/test.mk +/objdir/tools.test.out.tmp +/objdir/tools/prog1/Makefile +/objdir/tools/prog1/prog1 +/objdir/tools/prog1/prog1.c +/objdir/tools/prog1/prog1.o +/objdir/tools/prog2/Makefile +/objdir/tools/prog2/prog2.c +/objdir/tools/prog3/Makefile +/objdir/tools/prog3/prog3.c +/objdir/tools/prog4/Makefile +/objdir/tools/prog4/prog4.c +========= all-prog1 ========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/expect.out +/objdir/libs/bar/Makefile +/objdir/libs/bar/bar.c +/objdir/libs/bar/bar.h +/objdir/libs/foo/Makefile +/objdir/libs/foo/foo.c +/objdir/libs/foo/foo.h +/objdir/libs/foo/foo.o +/objdir/libs/foo/libfoo.a +/objdir/libs/qux/Makefile +/objdir/libs/qux/qux.c +/objdir/libs/qux/qux.h.in +/objdir/test.mk +/objdir/tools.test.out.tmp +/objdir/tools/prog1/Makefile +/objdir/tools/prog1/prog1 +/objdir/tools/prog1/prog1.c +/objdir/tools/prog1/prog1.o +/objdir/tools/prog2/Makefile +/objdir/tools/prog2/prog2.c +/objdir/tools/prog3/Makefile +/objdir/tools/prog3/prog3.c +/objdir/tools/prog4/Makefile +/objdir/tools/prog4/prog4.c +========= all-tools/prog2 ========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/expect.out +/objdir/libs/bar/Makefile +/objdir/libs/bar/bar.c +/objdir/libs/bar/bar.h +/objdir/libs/bar/bar.o +/objdir/libs/bar/libbar.a +/objdir/libs/foo/Makefile +/objdir/libs/foo/foo.c +/objdir/libs/foo/foo.h +/objdir/libs/qux/Makefile +/objdir/libs/qux/qux.c +/objdir/libs/qux/qux.h.in +/objdir/test.mk +/objdir/tools.test.out.tmp +/objdir/tools/prog1/Makefile +/objdir/tools/prog1/prog1.c +/objdir/tools/prog2/Makefile +/objdir/tools/prog2/prog2 +/objdir/tools/prog2/prog2.c +/objdir/tools/prog2/prog2.o +/objdir/tools/prog3/Makefile +/objdir/tools/prog3/prog3.c +/objdir/tools/prog4/Makefile +/objdir/tools/prog4/prog4.c +========= -C tools/prog2 all ========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/expect.out +/objdir/libs/bar/Makefile +/objdir/libs/bar/bar.c +/objdir/libs/bar/bar.h +/objdir/libs/bar/bar.o +/objdir/libs/bar/libbar.a +/objdir/libs/foo/Makefile +/objdir/libs/foo/foo.c +/objdir/libs/foo/foo.h +/objdir/libs/qux/Makefile +/objdir/libs/qux/qux.c +/objdir/libs/qux/qux.h.in +/objdir/test.mk +/objdir/tools.test.out.tmp +/objdir/tools/prog1/Makefile +/objdir/tools/prog1/prog1.c +/objdir/tools/prog2/Makefile +/objdir/tools/prog2/prog2 +/objdir/tools/prog2/prog2.c +/objdir/tools/prog2/prog2.o +/objdir/tools/prog3/Makefile +/objdir/tools/prog3/prog3.c +/objdir/tools/prog4/Makefile +/objdir/tools/prog4/prog4.c +========= all-tools/prog3 ========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/expect.out +/objdir/libs/bar/Makefile +/objdir/libs/bar/bar.c +/objdir/libs/bar/bar.h +/objdir/libs/bar/bar.o +/objdir/libs/bar/libbar.a +/objdir/libs/foo/Makefile +/objdir/libs/foo/foo.c +/objdir/libs/foo/foo.h +/objdir/libs/foo/foo.o +/objdir/libs/foo/libfoo.a +/objdir/libs/qux/Makefile +/objdir/libs/qux/qux.c +/objdir/libs/qux/qux.h.in +/objdir/test.mk +/objdir/tools.test.out.tmp +/objdir/tools/prog1/Makefile +/objdir/tools/prog1/prog1.c +/objdir/tools/prog2/Makefile +/objdir/tools/prog2/prog2.c +/objdir/tools/prog3/Makefile +/objdir/tools/prog3/prog3 +/objdir/tools/prog3/prog3.c +/objdir/tools/prog3/prog3.o +/objdir/tools/prog4/Makefile +/objdir/tools/prog4/prog4.c +========= -C tools/prog4 all ========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/_mkc_sizeof_int.c +/objdir/_mkc_sizeof_int.err +/objdir/_mkc_sizeof_int.res +/objdir/expect.out +/objdir/libs/bar/Makefile +/objdir/libs/bar/bar.c +/objdir/libs/bar/bar.h +/objdir/libs/foo/Makefile +/objdir/libs/foo/foo.c +/objdir/libs/foo/foo.h +/objdir/libs/qux/Makefile +/objdir/libs/qux/libqux.a +/objdir/libs/qux/qux.c +/objdir/libs/qux/qux.h +/objdir/libs/qux/qux.h.in +/objdir/libs/qux/qux.o +/objdir/test.mk +/objdir/tools.test.out.tmp +/objdir/tools/prog1/Makefile +/objdir/tools/prog1/prog1.c +/objdir/tools/prog2/Makefile +/objdir/tools/prog2/prog2.c +/objdir/tools/prog3/Makefile +/objdir/tools/prog3/prog3.c +/objdir/tools/prog4/Makefile +/objdir/tools/prog4/prog4 +/objdir/tools/prog4/prog4.c +/objdir/tools/prog4/prog4.o +=========== print_deps ============ +all-libs/foo all-tools/prog1 +all-libs/bar all-tools/prog2 +all-libs/foo all-tools/prog3 +all-libs/bar all-tools/prog3 +all-libs/qux all-tools/prog4 +all-libs/bar bar +all-libs/bar libs/bar +all-libs/foo foo +all-libs/foo libs/foo +all-libs/qux qux +all-libs/qux libs/qux +all-tools/prog1 prog1 +all-tools/prog1 tools/prog1 +all-tools/prog2 prog2 +all-tools/prog2 tools/prog2 +all-tools/prog3 prog3 +all-tools/prog3 tools/prog3 +all-tools/prog4 prog4 +all-tools/prog4 tools/prog4 +all-libs/bar all +all-libs/foo all +all-libs/qux all +all-tools/prog1 all +all-tools/prog2 all +all-tools/prog3 all +all-tools/prog4 all +all-libs/bar +all-bar +all-libs/bar all-bar +all-libs/foo +all-foo +all-libs/foo all-foo +all-libs/qux +all-qux +all-libs/qux all-qux +all-tools/prog1 +all-prog1 +all-tools/prog1 all-prog1 +all-tools/prog2 +all-prog2 +all-tools/prog2 all-prog2 +all-tools/prog3 +all-prog3 +all-tools/prog3 all-prog3 +all-tools/prog4 +all-prog4 +all-tools/prog4 all-prog4 +bar +foo +qux +prog1 +prog2 +prog3 +prog4 +all +check +clean +cleandir +depend +errorcheck +filelist +install +installdirs +mkgen +obj +test +uninstall +===== +check-tools/prog1 check +check-tools/prog2 check +check-tools/prog3 check +check-tools/prog4 check +check-libs/bar +check-bar +check-libs/bar check-bar +check-libs/foo +check-foo +check-libs/foo check-foo +check-libs/qux +check-qux +check-libs/qux check-qux +check-tools/prog1 +check-prog1 +check-tools/prog1 check-prog1 +check-tools/prog2 +check-prog2 +check-tools/prog2 check-prog2 +check-tools/prog3 +check-prog3 +check-tools/prog3 check-prog3 +check-tools/prog4 +check-prog4 +check-tools/prog4 check-prog4 +check diff --git a/examples/tools/libs/bar/Makefile b/examples/tools/libs/bar/Makefile new file mode 100644 index 0000000..4022796 --- /dev/null +++ b/examples/tools/libs/bar/Makefile @@ -0,0 +1,7 @@ +LIB = bar +SRCS = bar.c +INCS = bar.h + +WARNS = 4 + +.include <mkc.lib.mk> diff --git a/examples/tools/libs/bar/bar.c b/examples/tools/libs/bar/bar.c new file mode 100644 index 0000000..8580fe7 --- /dev/null +++ b/examples/tools/libs/bar/bar.c @@ -0,0 +1,6 @@ +#include "bar.h" + +const char *get_msg2 (void) +{ + return "Message #"; +} diff --git a/examples/tools/libs/bar/bar.h b/examples/tools/libs/bar/bar.h new file mode 100644 index 0000000..a434759 --- /dev/null +++ b/examples/tools/libs/bar/bar.h @@ -0,0 +1 @@ +const char *get_msg2 (void); diff --git a/examples/tools/libs/foo/Makefile b/examples/tools/libs/foo/Makefile new file mode 100644 index 0000000..0003bee --- /dev/null +++ b/examples/tools/libs/foo/Makefile @@ -0,0 +1,7 @@ +LIB = foo +SRCS = foo.c +INCS = foo.h + +WARNS = 4 + +.include <mkc.lib.mk> diff --git a/examples/tools/libs/foo/foo.c b/examples/tools/libs/foo/foo.c new file mode 100644 index 0000000..1d47523 --- /dev/null +++ b/examples/tools/libs/foo/foo.c @@ -0,0 +1,6 @@ +#include "foo.h" + +const char *get_msg1 (void) +{ + return "This is a message #"; +} diff --git a/examples/tools/libs/foo/foo.h b/examples/tools/libs/foo/foo.h new file mode 100644 index 0000000..489e95b --- /dev/null +++ b/examples/tools/libs/foo/foo.h @@ -0,0 +1 @@ +const char *get_msg1 (void); diff --git a/examples/tools/libs/qux/Makefile b/examples/tools/libs/qux/Makefile new file mode 100644 index 0000000..345f614 --- /dev/null +++ b/examples/tools/libs/qux/Makefile @@ -0,0 +1,16 @@ +LIB = qux +SRCS = qux.c +INCS = qux.h + +MKC_CHECK_SIZEOF = int + +.include <mkc.configure.mk> + +INFILES = ${INCS} +INTEXTS_REPLS = int_size ${SIZEOF.int:U4} + +qux.o: qux.h + +WARNS = 4 + +.include <mkc.lib.mk> diff --git a/examples/tools/libs/qux/qux.c b/examples/tools/libs/qux/qux.c new file mode 100644 index 0000000..78786db --- /dev/null +++ b/examples/tools/libs/qux/qux.c @@ -0,0 +1,6 @@ +#include "qux.h" + +int get_int_size (void) +{ + return INT_SIZE; +} diff --git a/examples/tools/libs/qux/qux.h.in b/examples/tools/libs/qux/qux.h.in new file mode 100644 index 0000000..0a41ce1 --- /dev/null +++ b/examples/tools/libs/qux/qux.h.in @@ -0,0 +1,4 @@ + +#define INT_SIZE @int_size@ + +int get_int_size (void); diff --git a/examples/tools/test.mk b/examples/tools/test.mk new file mode 100644 index 0000000..fadfedc --- /dev/null +++ b/examples/tools/test.mk @@ -0,0 +1,127 @@ +next_level != expr ${.MAKE.LEVEL} + 1 + +.PHONY : test_output +test_output : + @set -e; \ + MKCATPAGES=yes; export MKCATPAGES; \ + SRCTOP=`pwd`; export SRCTOP; \ + \ + echo PROJECTNAME=${PROJECTNAME}; \ + rm -rf ${.OBJDIR}${PREFIX}; \ + ${.CURDIR}/tools/prog1/prog1; \ + ${.CURDIR}/tools/prog2/prog2; \ + ${.CURDIR}/tools/prog3/prog3; \ + ${.CURDIR}/tools/prog4/prog4 | sed 's/=[0-9]/=n/'; \ + echo OBJDIR_tools_prog1=${OBJDIR_tools_prog1} | mkc_test_helper_paths; \ + echo OBJDIR_tools_prog2=${OBJDIR_tools_prog2} | mkc_test_helper_paths; \ + echo OBJDIR_tools_prog3=${OBJDIR_tools_prog3} | mkc_test_helper_paths; \ + echo OBJDIR_tools_prog4=${OBJDIR_tools_prog4} | mkc_test_helper_paths; \ + echo OBJDIR_libs_foo=${OBJDIR_libs_foo} | mkc_test_helper_paths; \ + echo OBJDIR_libs_bar=${OBJDIR_libs_bar} | mkc_test_helper_paths; \ + echo OBJDIR_prog3=${OBJDIR_prog3} | mkc_test_helper_paths; \ + echo OBJDIR_bar=${OBJDIR_bar} | mkc_test_helper_paths; \ + echo SRCDIR_tools_prog1=${SRCDIR_tools_prog1} | sed 's,=.*examples/,=,'; \ + echo SRCDIR_tools_prog2=${SRCDIR_tools_prog2} | sed 's,=.*examples/,=,'; \ + echo SRCDIR_tools_prog3=${SRCDIR_tools_prog3} | sed 's,=.*examples/,=,'; \ + echo SRCDIR_tools_prog4=${SRCDIR_tools_prog4} | sed 's,=.*examples/,=,'; \ + echo SRCDIR_libs_foo=${SRCDIR_libs_foo} | sed 's,=.*examples/,=,'; \ + echo SRCDIR_libs_bar=${SRCDIR_libs_bar} | sed 's,=.*examples/,=,'; \ + echo SRCDIR_prog3=${SRCDIR_prog3} | sed 's,=.*examples/,=,'; \ + echo SRCDIR_bar=${SRCDIR_bar} | sed 's,=.*examples/,=,'; \ + \ + echo =========== check ============; \ + ${MAKE} ${MAKEFLAGS} check 2>&1; \ + \ + echo =========== check-tools/prog1 ============; \ + ${MAKE} ${MAKEFLAGS} check-tools/prog1 2>&1; \ + \ + echo =========== all ============; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ===== all SHRTOUT=yes ======; \ + ${MAKE} ${MAKEFLAGS} clean > /dev/null; \ + env SHRTOUT=YES ${MAKE} ${MAKEFLAGS} all 2>&1; \ + \ + echo ========= installdirs ==========; \ + ${MAKE} ${MAKEFLAGS} installdirs DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type l -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= install ==========; \ + ${MAKE} ${MAKEFLAGS} install -j3 DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type l -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======== uninstall =========; \ + ${MAKE} ${MAKEFLAGS} -j4 uninstall DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ========== clean ===========; \ + ${MAKE} ${MAKEFLAGS} clean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ======= cleandir ==========; \ + ${MAKE} ${MAKEFLAGS} cleandir DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= all-tools/prog1 ==========; \ + ${MAKE} ${MAKEFLAGS} -j4 all-tools/prog1 DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= -C tools/prog1 all ==========; \ + ${MAKE} ${MAKEFLAGS} -j4 clean-tools/prog1 DESTDIR=${.OBJDIR} > /dev/null; \ + env init_make_level=${next_level} ${MAKE} ${MAKEFLAGS} -j4 \ + -C `pwd`/tools/prog1 all DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= all-prog1 ==========; \ + ${MAKE} ${MAKEFLAGS} cleandir DESTDIR=${.OBJDIR} > /dev/null; \ + ${MAKE} ${MAKEFLAGS} -j4 all-prog1 DESTDIR=${.OBJDIR} > /dev/null; \ + ${MAKE} ${MAKEFLAGS} nodeps-all-prog1 DESTDIR=${.OBJDIR} > /dev/null; \ + ${MAKE} ${MAKEFLAGS} subdir-all-prog1 DESTDIR=${.OBJDIR} > /dev/null; \ + ${MAKE} ${MAKEFLAGS} prog1 DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= all-tools/prog2 ==========; \ + ${MAKE} ${MAKEFLAGS} cleandir DESTDIR=${.OBJDIR} > /dev/null; \ + ${MAKE} ${MAKEFLAGS} -j4 all-tools/prog2 DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= -C tools/prog2 all ==========; \ + ${MAKE} ${MAKEFLAGS} cleandir DESTDIR=${.OBJDIR} > /dev/null; \ + env init_make_level=${next_level} ${MAKE} ${MAKEFLAGS} -j4 \ + -C tools/prog2 all DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= all-tools/prog3 ==========; \ + ${MAKE} ${MAKEFLAGS} cleandir DESTDIR=${.OBJDIR} > /dev/null; \ + ${MAKE} ${MAKEFLAGS} -j4 all-tools/prog3 DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= -C tools/prog4 all ==========; \ + ${MAKE} ${MAKEFLAGS} cleandir DESTDIR=${.OBJDIR} > /dev/null; \ + env init_make_level=${next_level} ${MAKE} ${MAKEFLAGS} \ + -j4 all-tools/prog4 DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo =========== print_deps ============; \ + ${MAKE} ${MAKEFLAGS} print_deps | grep -E '^(all|[^-/ ]+$$)'; \ + echo =====; \ + ${MAKE} ${MAKEFLAGS} print_deps | grep -E ^check; \ + \ + ${MAKE} ${MAKEFLAGS} cleandir > /dev/null; \ + +.include <mkc.minitest.mk> diff --git a/examples/tools/tools/prog1/Makefile b/examples/tools/tools/prog1/Makefile new file mode 100644 index 0000000..bf306a3 --- /dev/null +++ b/examples/tools/tools/prog1/Makefile @@ -0,0 +1,11 @@ +PROG = prog1 + +CFLAGS += -DNUM=1 +WARNS = 4 + +MKC_REQD = 0.10.0 + +check: + @: do something useful + +.include <mkc.prog.mk> diff --git a/examples/tools/tools/prog1/prog1.c b/examples/tools/tools/prog1/prog1.c new file mode 100644 index 0000000..87578e2 --- /dev/null +++ b/examples/tools/tools/prog1/prog1.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +#include "foo.h" + +int main (int argc, char** argv) +{ + printf ("%s", get_msg1 ()); + printf ("%d\n", NUM); + return 0; +} diff --git a/examples/tools/tools/prog2/Makefile b/examples/tools/tools/prog2/Makefile new file mode 100644 index 0000000..e80873a --- /dev/null +++ b/examples/tools/tools/prog2/Makefile @@ -0,0 +1,11 @@ +PROG = prog2 + +CFLAGS += -DNUM=2 +WARNS = 4 + +MKC_REQD = 0.10.0 + +check: + @: do something useful + +.include <mkc.prog.mk> diff --git a/examples/tools/tools/prog2/prog2.c b/examples/tools/tools/prog2/prog2.c new file mode 100644 index 0000000..ed9553c --- /dev/null +++ b/examples/tools/tools/prog2/prog2.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +#include "bar.h" + +int main (int argc, char** argv) +{ + printf ("%s", get_msg2 ()); + printf ("%d\n", NUM); + return 0; +} diff --git a/examples/tools/tools/prog3/Makefile b/examples/tools/tools/prog3/Makefile new file mode 100644 index 0000000..093e2d2 --- /dev/null +++ b/examples/tools/tools/prog3/Makefile @@ -0,0 +1,11 @@ +PROG = prog3 + +CFLAGS += -DNUM=3 +WARNS = 4 + +MKC_REQD = 0.10.0 + +check: + @: do something useful + +.include <mkc.prog.mk> diff --git a/examples/tools/tools/prog3/prog3.c b/examples/tools/tools/prog3/prog3.c new file mode 100644 index 0000000..54b740b --- /dev/null +++ b/examples/tools/tools/prog3/prog3.c @@ -0,0 +1,14 @@ +#include <stdio.h> + +#include "foo.h" +#include "bar.h" + +int main (int argc, char** argv) +{ + printf ("%s", get_msg1 ()); + printf ("%d\n", NUM); + + printf ("%s", get_msg2 ()); + printf ("%d\n", NUM); + return 0; +} diff --git a/examples/tools/tools/prog4/Makefile b/examples/tools/tools/prog4/Makefile new file mode 100644 index 0000000..1d3ebf0 --- /dev/null +++ b/examples/tools/tools/prog4/Makefile @@ -0,0 +1,10 @@ +PROG = prog4 + +WARNS = 4 + +MKC_REQD = 0.10.0 + +check: + @: do something useful + +.include <mkc.prog.mk> diff --git a/examples/tools/tools/prog4/prog4.c b/examples/tools/tools/prog4/prog4.c new file mode 100644 index 0000000..3b4d087 --- /dev/null +++ b/examples/tools/tools/prog4/prog4.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +#include "qux.h" + +int main (int argc, char** argv) +{ + printf ("int_size=%d\n", get_int_size ()); + return 0; +} diff --git a/examples/tools2/Makefile b/examples/tools2/Makefile new file mode 100644 index 0000000..4476c66 --- /dev/null +++ b/examples/tools2/Makefile @@ -0,0 +1,26 @@ +LIBDEPS = libs/foo:tools/prog1 +LIBDEPS += libs/bar:tools/prog2 +LIBDEPS += libs/foo:tools/prog3 libs/bar:tools/prog3 +LIBDEPS += libs/qux:tools/prog4 + +SUBPRJ += tools/prog1:tests/prog1 +SUBPRJ += tools/prog2:tests/prog2 +SUBPRJ += tools/prog3:tests/prog3 +SUBPRJ += tools/prog4:tests/prog4 + +NODEPS += check-*/*:check-*/* \ + all-tests/*:all \ + check-libs/*:check check-tools/*:check + +# target "check" is used for testing because "test" is used by mk-configure +TARGETS = check + +SHORTPRJNAME = no + +# for regression test only +MKC_CACHEDIR = ${.OBJDIR} +_THISDIR_ = +.export _THISDIR_ + +.include "test.mk" +.include <mkc.subprj.mk> diff --git a/examples/tools2/expect.out b/examples/tools2/expect.out new file mode 100644 index 0000000..d86a609 --- /dev/null +++ b/examples/tools2/expect.out @@ -0,0 +1,470 @@ +PROJECTNAME=tools2 +This is a message #1 +Message #2 +This is a message #3 +Message #3 +int_size=n +OBJDIR_tools_prog1=/path/to/prog1 +OBJDIR_tools_prog2=/path/to/prog2 +OBJDIR_tools_prog3=/path/to/prog3 +OBJDIR_tools_prog4=/path/to/prog4 +OBJDIR_libs_foo=/path/to/foo +OBJDIR_libs_bar=/path/to/bar +OBJDIR_prog3= +OBJDIR_bar= +SRCDIR_tools_prog1=tools2/tools/prog1 +SRCDIR_tools_prog2=tools2/tools/prog2 +SRCDIR_tools_prog3=tools2/tools/prog3 +SRCDIR_tools_prog4=tools2/tools/prog4 +SRCDIR_libs_foo=tools2/libs/foo +SRCDIR_libs_bar=tools2/libs/bar +SRCDIR_prog3= +SRCDIR_bar= +=========== check ============ +================================================== +check ===> tests/prog1 +ok +================================================== +check ===> tests/prog2 +ok +================================================== +check ===> tests/prog3 +ok +================================================== +check ===> tests/prog4 +ok +=========== check-tools/prog1 ============ +================================================== +check ===> tools/prog1 +=========== all ============ +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/_mkc_sizeof_int.c +/objdir/_mkc_sizeof_int.err +/objdir/_mkc_sizeof_int.res +/objdir/expect.out +/objdir/libs/bar/Makefile +/objdir/libs/bar/bar.c +/objdir/libs/bar/bar.h +/objdir/libs/bar/bar.o +/objdir/libs/bar/libbar.a +/objdir/libs/foo/Makefile +/objdir/libs/foo/foo.c +/objdir/libs/foo/foo.h +/objdir/libs/foo/foo.o +/objdir/libs/foo/libfoo.a +/objdir/libs/qux/Makefile +/objdir/libs/qux/libqux.a +/objdir/libs/qux/qux.c +/objdir/libs/qux/qux.h +/objdir/libs/qux/qux.h.in +/objdir/libs/qux/qux.o +/objdir/test.mk +/objdir/tests/prog1/Makefile +/objdir/tests/prog2/Makefile +/objdir/tests/prog3/Makefile +/objdir/tests/prog4/Makefile +/objdir/tools/prog1/Makefile +/objdir/tools/prog1/prog1 +/objdir/tools/prog1/prog1.c +/objdir/tools/prog1/prog1.o +/objdir/tools/prog2/Makefile +/objdir/tools/prog2/prog2 +/objdir/tools/prog2/prog2.c +/objdir/tools/prog2/prog2.o +/objdir/tools/prog3/Makefile +/objdir/tools/prog3/prog3 +/objdir/tools/prog3/prog3.c +/objdir/tools/prog3/prog3.o +/objdir/tools/prog4/Makefile +/objdir/tools/prog4/prog4 +/objdir/tools/prog4/prog4.c +/objdir/tools/prog4/prog4.o +/objdir/tools2.test.out.tmp +===== all SHRTOUT=yes ====== +================================================== +all ===> libs/bar +CC: bar.c +AR: libbar.a +================================================== +all ===> libs/foo +CC: foo.c +AR: libfoo.a +================================================== +all ===> libs/qux +GEN: qux.h +CC: qux.c +AR: libqux.a +================================================== +all ===> tools/prog1 +CC: prog1.c +LD: prog1 +================================================== +all ===> tools/prog2 +CC: prog2.c +LD: prog2 +================================================== +all ===> tools/prog3 +CC: prog3.c +LD: prog3 +================================================== +all ===> tools/prog4 +CC: prog4.c +LD: prog4 +========= installdirs ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/include +/objdir/prefix/lib +========= install ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/bin/prog1 +/objdir/prefix/bin/prog2 +/objdir/prefix/bin/prog3 +/objdir/prefix/bin/prog4 +/objdir/prefix/include +/objdir/prefix/include/bar.h +/objdir/prefix/include/foo.h +/objdir/prefix/include/qux.h +/objdir/prefix/lib +/objdir/prefix/lib/libbar.a +/objdir/prefix/lib/libfoo.a +/objdir/prefix/lib/libqux.a +======== uninstall ========= +========== clean =========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/_mkc_sizeof_int.c +/objdir/_mkc_sizeof_int.err +/objdir/_mkc_sizeof_int.res +/objdir/expect.out +/objdir/libs/bar/Makefile +/objdir/libs/bar/bar.c +/objdir/libs/bar/bar.h +/objdir/libs/foo/Makefile +/objdir/libs/foo/foo.c +/objdir/libs/foo/foo.h +/objdir/libs/qux/Makefile +/objdir/libs/qux/qux.c +/objdir/libs/qux/qux.h.in +/objdir/test.mk +/objdir/tests/prog1/Makefile +/objdir/tests/prog2/Makefile +/objdir/tests/prog3/Makefile +/objdir/tests/prog4/Makefile +/objdir/tools/prog1/Makefile +/objdir/tools/prog1/prog1.c +/objdir/tools/prog2/Makefile +/objdir/tools/prog2/prog2.c +/objdir/tools/prog3/Makefile +/objdir/tools/prog3/prog3.c +/objdir/tools/prog4/Makefile +/objdir/tools/prog4/prog4.c +/objdir/tools2.test.out.tmp +======= cleandir ========== +/objdir/Makefile +/objdir/expect.out +/objdir/libs/bar/Makefile +/objdir/libs/bar/bar.c +/objdir/libs/bar/bar.h +/objdir/libs/foo/Makefile +/objdir/libs/foo/foo.c +/objdir/libs/foo/foo.h +/objdir/libs/qux/Makefile +/objdir/libs/qux/qux.c +/objdir/libs/qux/qux.h.in +/objdir/test.mk +/objdir/tests/prog1/Makefile +/objdir/tests/prog2/Makefile +/objdir/tests/prog3/Makefile +/objdir/tests/prog4/Makefile +/objdir/tools/prog1/Makefile +/objdir/tools/prog1/prog1.c +/objdir/tools/prog2/Makefile +/objdir/tools/prog2/prog2.c +/objdir/tools/prog3/Makefile +/objdir/tools/prog3/prog3.c +/objdir/tools/prog4/Makefile +/objdir/tools/prog4/prog4.c +/objdir/tools2.test.out.tmp +========= all-tools/prog1 ========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/expect.out +/objdir/libs/bar/Makefile +/objdir/libs/bar/bar.c +/objdir/libs/bar/bar.h +/objdir/libs/foo/Makefile +/objdir/libs/foo/foo.c +/objdir/libs/foo/foo.h +/objdir/libs/foo/foo.o +/objdir/libs/foo/libfoo.a +/objdir/libs/qux/Makefile +/objdir/libs/qux/qux.c +/objdir/libs/qux/qux.h.in +/objdir/test.mk +/objdir/tests/prog1/Makefile +/objdir/tests/prog2/Makefile +/objdir/tests/prog3/Makefile +/objdir/tests/prog4/Makefile +/objdir/tools/prog1/Makefile +/objdir/tools/prog1/prog1 +/objdir/tools/prog1/prog1.c +/objdir/tools/prog1/prog1.o +/objdir/tools/prog2/Makefile +/objdir/tools/prog2/prog2.c +/objdir/tools/prog3/Makefile +/objdir/tools/prog3/prog3.c +/objdir/tools/prog4/Makefile +/objdir/tools/prog4/prog4.c +/objdir/tools2.test.out.tmp +========= -C tools/prog1 all ========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/expect.out +/objdir/libs/bar/Makefile +/objdir/libs/bar/bar.c +/objdir/libs/bar/bar.h +/objdir/libs/foo/Makefile +/objdir/libs/foo/foo.c +/objdir/libs/foo/foo.h +/objdir/libs/foo/foo.o +/objdir/libs/foo/libfoo.a +/objdir/libs/qux/Makefile +/objdir/libs/qux/qux.c +/objdir/libs/qux/qux.h.in +/objdir/test.mk +/objdir/tests/prog1/Makefile +/objdir/tests/prog2/Makefile +/objdir/tests/prog3/Makefile +/objdir/tests/prog4/Makefile +/objdir/tools/prog1/Makefile +/objdir/tools/prog1/prog1 +/objdir/tools/prog1/prog1.c +/objdir/tools/prog1/prog1.o +/objdir/tools/prog2/Makefile +/objdir/tools/prog2/prog2.c +/objdir/tools/prog3/Makefile +/objdir/tools/prog3/prog3.c +/objdir/tools/prog4/Makefile +/objdir/tools/prog4/prog4.c +/objdir/tools2.test.out.tmp +========= all-tools/prog2 ========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/expect.out +/objdir/libs/bar/Makefile +/objdir/libs/bar/bar.c +/objdir/libs/bar/bar.h +/objdir/libs/bar/bar.o +/objdir/libs/bar/libbar.a +/objdir/libs/foo/Makefile +/objdir/libs/foo/foo.c +/objdir/libs/foo/foo.h +/objdir/libs/qux/Makefile +/objdir/libs/qux/qux.c +/objdir/libs/qux/qux.h.in +/objdir/test.mk +/objdir/tests/prog1/Makefile +/objdir/tests/prog2/Makefile +/objdir/tests/prog3/Makefile +/objdir/tests/prog4/Makefile +/objdir/tools/prog1/Makefile +/objdir/tools/prog1/prog1.c +/objdir/tools/prog2/Makefile +/objdir/tools/prog2/prog2 +/objdir/tools/prog2/prog2.c +/objdir/tools/prog2/prog2.o +/objdir/tools/prog3/Makefile +/objdir/tools/prog3/prog3.c +/objdir/tools/prog4/Makefile +/objdir/tools/prog4/prog4.c +/objdir/tools2.test.out.tmp +========= -C tools/prog2 all ========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/expect.out +/objdir/libs/bar/Makefile +/objdir/libs/bar/bar.c +/objdir/libs/bar/bar.h +/objdir/libs/bar/bar.o +/objdir/libs/bar/libbar.a +/objdir/libs/foo/Makefile +/objdir/libs/foo/foo.c +/objdir/libs/foo/foo.h +/objdir/libs/qux/Makefile +/objdir/libs/qux/qux.c +/objdir/libs/qux/qux.h.in +/objdir/test.mk +/objdir/tests/prog1/Makefile +/objdir/tests/prog2/Makefile +/objdir/tests/prog3/Makefile +/objdir/tests/prog4/Makefile +/objdir/tools/prog1/Makefile +/objdir/tools/prog1/prog1.c +/objdir/tools/prog2/Makefile +/objdir/tools/prog2/prog2 +/objdir/tools/prog2/prog2.c +/objdir/tools/prog2/prog2.o +/objdir/tools/prog3/Makefile +/objdir/tools/prog3/prog3.c +/objdir/tools/prog4/Makefile +/objdir/tools/prog4/prog4.c +/objdir/tools2.test.out.tmp +========= all-tools/prog3 ========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/expect.out +/objdir/libs/bar/Makefile +/objdir/libs/bar/bar.c +/objdir/libs/bar/bar.h +/objdir/libs/bar/bar.o +/objdir/libs/bar/libbar.a +/objdir/libs/foo/Makefile +/objdir/libs/foo/foo.c +/objdir/libs/foo/foo.h +/objdir/libs/foo/foo.o +/objdir/libs/foo/libfoo.a +/objdir/libs/qux/Makefile +/objdir/libs/qux/qux.c +/objdir/libs/qux/qux.h.in +/objdir/test.mk +/objdir/tests/prog1/Makefile +/objdir/tests/prog2/Makefile +/objdir/tests/prog3/Makefile +/objdir/tests/prog4/Makefile +/objdir/tools/prog1/Makefile +/objdir/tools/prog1/prog1.c +/objdir/tools/prog2/Makefile +/objdir/tools/prog2/prog2.c +/objdir/tools/prog3/Makefile +/objdir/tools/prog3/prog3 +/objdir/tools/prog3/prog3.c +/objdir/tools/prog3/prog3.o +/objdir/tools/prog4/Makefile +/objdir/tools/prog4/prog4.c +/objdir/tools2.test.out.tmp +========= -C tools/prog4 all ========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/_mkc_sizeof_int.c +/objdir/_mkc_sizeof_int.err +/objdir/_mkc_sizeof_int.res +/objdir/expect.out +/objdir/libs/bar/Makefile +/objdir/libs/bar/bar.c +/objdir/libs/bar/bar.h +/objdir/libs/foo/Makefile +/objdir/libs/foo/foo.c +/objdir/libs/foo/foo.h +/objdir/libs/qux/Makefile +/objdir/libs/qux/libqux.a +/objdir/libs/qux/qux.c +/objdir/libs/qux/qux.h +/objdir/libs/qux/qux.h.in +/objdir/libs/qux/qux.o +/objdir/test.mk +/objdir/tests/prog1/Makefile +/objdir/tests/prog2/Makefile +/objdir/tests/prog3/Makefile +/objdir/tests/prog4/Makefile +/objdir/tools/prog1/Makefile +/objdir/tools/prog1/prog1.c +/objdir/tools/prog2/Makefile +/objdir/tools/prog2/prog2.c +/objdir/tools/prog3/Makefile +/objdir/tools/prog3/prog3.c +/objdir/tools/prog4/Makefile +/objdir/tools/prog4/prog4 +/objdir/tools/prog4/prog4.c +/objdir/tools/prog4/prog4.o +/objdir/tools2.test.out.tmp +========= MKRELOBJDIR ========== +obj/_mkc_compiler_type.err +obj/_mkc_compiler_type.res +obj/_mkc_prog_cc.err +obj/_mkc_prog_cc.res +obj/_mkc_sizeof_int.c +obj/_mkc_sizeof_int.err +obj/_mkc_sizeof_int.res +obj/libs/bar/bar.o +obj/libs/bar/libbar.a +obj/libs/foo/foo.o +obj/libs/foo/libfoo.a +obj/libs/qux/libqux.a +obj/libs/qux/qux.h +obj/libs/qux/qux.o +obj/tools/prog1/prog1 +obj/tools/prog1/prog1.o +obj/tools/prog2/prog2 +obj/tools/prog2/prog2.o +obj/tools/prog3/prog3 +obj/tools/prog3/prog3.o +obj/tools/prog4/prog4 +obj/tools/prog4/prog4.o +=========== print_deps ============ +all-tools/prog1 all-tests/prog1 +all-tools/prog2 all-tests/prog2 +all-tools/prog3 all-tests/prog3 +all-tools/prog4 all-tests/prog4 +all-libs/foo all-tools/prog1 +all-libs/bar all-tools/prog2 +all-libs/foo all-tools/prog3 +all-libs/bar all-tools/prog3 +all-libs/qux all-tools/prog4 +all-libs/bar libs/bar +all-libs/foo libs/foo +all-libs/qux libs/qux +all-tests/prog1 tests/prog1 +all-tests/prog2 tests/prog2 +all-tests/prog3 tests/prog3 +all-tests/prog4 tests/prog4 +all-tools/prog1 tools/prog1 +all-tools/prog2 tools/prog2 +all-tools/prog3 tools/prog3 +all-tools/prog4 tools/prog4 +all-libs/bar all +all-libs/foo all +all-libs/qux all +all-tools/prog1 all +all-tools/prog2 all +all-tools/prog3 all +all-tools/prog4 all +all-libs/bar +all-libs/foo +all-libs/qux +all-tests/prog1 +all-tests/prog2 +all-tests/prog3 +all-tests/prog4 +all-tools/prog1 +all-tools/prog2 +all-tools/prog3 +all-tools/prog4 +all +===== diff --git a/examples/tools2/libs/bar/Makefile b/examples/tools2/libs/bar/Makefile new file mode 100644 index 0000000..4022796 --- /dev/null +++ b/examples/tools2/libs/bar/Makefile @@ -0,0 +1,7 @@ +LIB = bar +SRCS = bar.c +INCS = bar.h + +WARNS = 4 + +.include <mkc.lib.mk> diff --git a/examples/tools2/libs/bar/bar.c b/examples/tools2/libs/bar/bar.c new file mode 100644 index 0000000..8580fe7 --- /dev/null +++ b/examples/tools2/libs/bar/bar.c @@ -0,0 +1,6 @@ +#include "bar.h" + +const char *get_msg2 (void) +{ + return "Message #"; +} diff --git a/examples/tools2/libs/bar/bar.h b/examples/tools2/libs/bar/bar.h new file mode 100644 index 0000000..a434759 --- /dev/null +++ b/examples/tools2/libs/bar/bar.h @@ -0,0 +1 @@ +const char *get_msg2 (void); diff --git a/examples/tools2/libs/foo/Makefile b/examples/tools2/libs/foo/Makefile new file mode 100644 index 0000000..0003bee --- /dev/null +++ b/examples/tools2/libs/foo/Makefile @@ -0,0 +1,7 @@ +LIB = foo +SRCS = foo.c +INCS = foo.h + +WARNS = 4 + +.include <mkc.lib.mk> diff --git a/examples/tools2/libs/foo/foo.c b/examples/tools2/libs/foo/foo.c new file mode 100644 index 0000000..1d47523 --- /dev/null +++ b/examples/tools2/libs/foo/foo.c @@ -0,0 +1,6 @@ +#include "foo.h" + +const char *get_msg1 (void) +{ + return "This is a message #"; +} diff --git a/examples/tools2/libs/foo/foo.h b/examples/tools2/libs/foo/foo.h new file mode 100644 index 0000000..489e95b --- /dev/null +++ b/examples/tools2/libs/foo/foo.h @@ -0,0 +1 @@ +const char *get_msg1 (void); diff --git a/examples/tools2/libs/qux/Makefile b/examples/tools2/libs/qux/Makefile new file mode 100644 index 0000000..345f614 --- /dev/null +++ b/examples/tools2/libs/qux/Makefile @@ -0,0 +1,16 @@ +LIB = qux +SRCS = qux.c +INCS = qux.h + +MKC_CHECK_SIZEOF = int + +.include <mkc.configure.mk> + +INFILES = ${INCS} +INTEXTS_REPLS = int_size ${SIZEOF.int:U4} + +qux.o: qux.h + +WARNS = 4 + +.include <mkc.lib.mk> diff --git a/examples/tools2/libs/qux/qux.c b/examples/tools2/libs/qux/qux.c new file mode 100644 index 0000000..78786db --- /dev/null +++ b/examples/tools2/libs/qux/qux.c @@ -0,0 +1,6 @@ +#include "qux.h" + +int get_int_size (void) +{ + return INT_SIZE; +} diff --git a/examples/tools2/libs/qux/qux.h.in b/examples/tools2/libs/qux/qux.h.in new file mode 100644 index 0000000..0a41ce1 --- /dev/null +++ b/examples/tools2/libs/qux/qux.h.in @@ -0,0 +1,4 @@ + +#define INT_SIZE @int_size@ + +int get_int_size (void); diff --git a/examples/tools2/test.mk b/examples/tools2/test.mk new file mode 100644 index 0000000..e04a04b --- /dev/null +++ b/examples/tools2/test.mk @@ -0,0 +1,127 @@ +next_level != expr ${.MAKE.LEVEL} + 1 + +.PHONY : test_output +test_output : + @set -e; \ + MKCATPAGES=yes; export MKCATPAGES; \ + SRCTOP=`pwd`; export SRCTOP; \ + LC_ALL=C; export LC_ALL; \ + \ + echo PROJECTNAME=${PROJECTNAME}; \ + rm -rf ${.OBJDIR}${PREFIX}; \ + ${.CURDIR}/tools/prog1/prog1; \ + ${.CURDIR}/tools/prog2/prog2; \ + ${.CURDIR}/tools/prog3/prog3; \ + ${.CURDIR}/tools/prog4/prog4 | sed 's/=[0-9]/=n/'; \ + echo OBJDIR_tools_prog1=${OBJDIR_tools_prog1} | mkc_test_helper_paths; \ + echo OBJDIR_tools_prog2=${OBJDIR_tools_prog2} | mkc_test_helper_paths; \ + echo OBJDIR_tools_prog3=${OBJDIR_tools_prog3} | mkc_test_helper_paths; \ + echo OBJDIR_tools_prog4=${OBJDIR_tools_prog4} | mkc_test_helper_paths; \ + echo OBJDIR_libs_foo=${OBJDIR_libs_foo} | mkc_test_helper_paths; \ + echo OBJDIR_libs_bar=${OBJDIR_libs_bar} | mkc_test_helper_paths; \ + echo OBJDIR_prog3=${OBJDIR_prog3} | mkc_test_helper_paths; \ + echo OBJDIR_bar=${OBJDIR_bar} | mkc_test_helper_paths; \ + echo SRCDIR_tools_prog1=${SRCDIR_tools_prog1} | sed 's,=.*examples/,=,'; \ + echo SRCDIR_tools_prog2=${SRCDIR_tools_prog2} | sed 's,=.*examples/,=,'; \ + echo SRCDIR_tools_prog3=${SRCDIR_tools_prog3} | sed 's,=.*examples/,=,'; \ + echo SRCDIR_tools_prog4=${SRCDIR_tools_prog4} | sed 's,=.*examples/,=,'; \ + echo SRCDIR_libs_foo=${SRCDIR_libs_foo} | sed 's,=.*examples/,=,'; \ + echo SRCDIR_libs_bar=${SRCDIR_libs_bar} | sed 's,=.*examples/,=,'; \ + echo SRCDIR_prog3=${SRCDIR_prog3} | sed 's,=.*examples/,=,'; \ + echo SRCDIR_bar=${SRCDIR_bar} | sed 's,=.*examples/,=,'; \ + \ + echo =========== check ============; \ + ${MAKE} ${MAKEFLAGS} check 2>&1; \ + \ + echo =========== check-tools/prog1 ============; \ + ${MAKE} ${MAKEFLAGS} check-tools/prog1 2>&1; \ + \ + echo =========== all ============; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ===== all SHRTOUT=yes ======; \ + ${MAKE} ${MAKEFLAGS} clean > /dev/null; \ + env SHRTOUT=YES ${MAKE} ${MAKEFLAGS} all 2>&1; \ + \ + echo ========= installdirs ==========; \ + ${MAKE} ${MAKEFLAGS} installdirs DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type l -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= install ==========; \ + ${MAKE} ${MAKEFLAGS} install -j3 DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type l -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======== uninstall =========; \ + ${MAKE} ${MAKEFLAGS} -j4 uninstall DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ========== clean ===========; \ + ${MAKE} ${MAKEFLAGS} clean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ======= cleandir ==========; \ + ${MAKE} ${MAKEFLAGS} cleandir DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= all-tools/prog1 ==========; \ + ${MAKE} ${MAKEFLAGS} -j4 all-tools/prog1 DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= -C tools/prog1 all ==========; \ + ${MAKE} ${MAKEFLAGS} -j4 clean-tools/prog1 DESTDIR=${.OBJDIR} > /dev/null; \ + env init_make_level=${next_level} ${MAKE} ${MAKEFLAGS} -j4 \ + -C `pwd`/tools/prog1 all DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= all-tools/prog2 ==========; \ + ${MAKE} ${MAKEFLAGS} cleandir DESTDIR=${.OBJDIR} > /dev/null; \ + ${MAKE} ${MAKEFLAGS} -j4 all-tools/prog2 DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= -C tools/prog2 all ==========; \ + ${MAKE} ${MAKEFLAGS} cleandir DESTDIR=${.OBJDIR} > /dev/null; \ + env init_make_level=${next_level} ${MAKE} ${MAKEFLAGS} -j4 \ + -C tools/prog2 all DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= all-tools/prog3 ==========; \ + ${MAKE} ${MAKEFLAGS} cleandir DESTDIR=${.OBJDIR} > /dev/null; \ + ${MAKE} ${MAKEFLAGS} -j4 all-tools/prog3 DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= -C tools/prog4 all ==========; \ + ${MAKE} ${MAKEFLAGS} cleandir DESTDIR=${.OBJDIR} > /dev/null; \ + env init_make_level=${next_level} ${MAKE} ${MAKEFLAGS} \ + -j4 all-tools/prog4 DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= MKRELOBJDIR ==========; \ + ${MAKE} ${MAKEFLAGS} cleandir > /dev/null; \ + MKRELOBJDIR=yes; export MKRELOBJDIR; \ + mkdir obj; \ + env init_make_level=${next_level} ${MAKE} ${MAKEFLAGS} \ + -j4 all > /dev/null; \ + find obj -type f -o -type l | sort; \ + rm -rf obj; \ + \ + echo =========== print_deps ============; \ + ${MAKE} ${MAKEFLAGS} print_deps | grep -E '^all'; \ + echo =====; \ + \ + ${MAKE} ${MAKEFLAGS} cleandir > /dev/null; \ + +.include <mkc.minitest.mk> diff --git a/examples/tools2/tests/prog1/Makefile b/examples/tools2/tests/prog1/Makefile new file mode 100644 index 0000000..157ce1c --- /dev/null +++ b/examples/tools2/tests/prog1/Makefile @@ -0,0 +1,8 @@ +check: + @if test "`${OBJDIR_tools_prog1}/prog1`" = 'This is a message #1'; then \ + echo ok; \ + else \ + echo FAILED; false; \ + fi + +.include <mkc.mk> diff --git a/examples/tools2/tests/prog2/Makefile b/examples/tools2/tests/prog2/Makefile new file mode 100644 index 0000000..bb706b8 --- /dev/null +++ b/examples/tools2/tests/prog2/Makefile @@ -0,0 +1,8 @@ +check: + @if test "`${OBJDIR_tools_prog2}/prog2`" = 'Message #2'; then \ + echo ok; \ + else \ + echo FAILED; false; \ + fi + +.include <mkc.mk> diff --git a/examples/tools2/tests/prog3/Makefile b/examples/tools2/tests/prog3/Makefile new file mode 100644 index 0000000..c4cdad8 --- /dev/null +++ b/examples/tools2/tests/prog3/Makefile @@ -0,0 +1,10 @@ +check: + @if test "`${OBJDIR_tools_prog3}/prog3 | tr '\012' ' '`" = \ + 'This is a message #3 Message #3 '; \ + then \ + echo ok; \ + else \ + echo FAILED; false; \ + fi + +.include <mkc.mk> diff --git a/examples/tools2/tests/prog4/Makefile b/examples/tools2/tests/prog4/Makefile new file mode 100644 index 0000000..fb34426 --- /dev/null +++ b/examples/tools2/tests/prog4/Makefile @@ -0,0 +1,8 @@ +check: + @if test "`${OBJDIR_tools_prog4}/prog4 | tr '248' 'nnn'`" = 'int_size=n'; then \ + echo ok; \ + else \ + echo FAILED; false; \ + fi + +.include <mkc.mk> diff --git a/examples/tools2/tools/prog1/Makefile b/examples/tools2/tools/prog1/Makefile new file mode 100644 index 0000000..bf306a3 --- /dev/null +++ b/examples/tools2/tools/prog1/Makefile @@ -0,0 +1,11 @@ +PROG = prog1 + +CFLAGS += -DNUM=1 +WARNS = 4 + +MKC_REQD = 0.10.0 + +check: + @: do something useful + +.include <mkc.prog.mk> diff --git a/examples/tools2/tools/prog1/prog1.c b/examples/tools2/tools/prog1/prog1.c new file mode 100644 index 0000000..87578e2 --- /dev/null +++ b/examples/tools2/tools/prog1/prog1.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +#include "foo.h" + +int main (int argc, char** argv) +{ + printf ("%s", get_msg1 ()); + printf ("%d\n", NUM); + return 0; +} diff --git a/examples/tools2/tools/prog2/Makefile b/examples/tools2/tools/prog2/Makefile new file mode 100644 index 0000000..e80873a --- /dev/null +++ b/examples/tools2/tools/prog2/Makefile @@ -0,0 +1,11 @@ +PROG = prog2 + +CFLAGS += -DNUM=2 +WARNS = 4 + +MKC_REQD = 0.10.0 + +check: + @: do something useful + +.include <mkc.prog.mk> diff --git a/examples/tools2/tools/prog2/prog2.c b/examples/tools2/tools/prog2/prog2.c new file mode 100644 index 0000000..ed9553c --- /dev/null +++ b/examples/tools2/tools/prog2/prog2.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +#include "bar.h" + +int main (int argc, char** argv) +{ + printf ("%s", get_msg2 ()); + printf ("%d\n", NUM); + return 0; +} diff --git a/examples/tools2/tools/prog3/Makefile b/examples/tools2/tools/prog3/Makefile new file mode 100644 index 0000000..093e2d2 --- /dev/null +++ b/examples/tools2/tools/prog3/Makefile @@ -0,0 +1,11 @@ +PROG = prog3 + +CFLAGS += -DNUM=3 +WARNS = 4 + +MKC_REQD = 0.10.0 + +check: + @: do something useful + +.include <mkc.prog.mk> diff --git a/examples/tools2/tools/prog3/prog3.c b/examples/tools2/tools/prog3/prog3.c new file mode 100644 index 0000000..54b740b --- /dev/null +++ b/examples/tools2/tools/prog3/prog3.c @@ -0,0 +1,14 @@ +#include <stdio.h> + +#include "foo.h" +#include "bar.h" + +int main (int argc, char** argv) +{ + printf ("%s", get_msg1 ()); + printf ("%d\n", NUM); + + printf ("%s", get_msg2 ()); + printf ("%d\n", NUM); + return 0; +} diff --git a/examples/tools2/tools/prog4/Makefile b/examples/tools2/tools/prog4/Makefile new file mode 100644 index 0000000..1d3ebf0 --- /dev/null +++ b/examples/tools2/tools/prog4/Makefile @@ -0,0 +1,10 @@ +PROG = prog4 + +WARNS = 4 + +MKC_REQD = 0.10.0 + +check: + @: do something useful + +.include <mkc.prog.mk> diff --git a/examples/tools2/tools/prog4/prog4.c b/examples/tools2/tools/prog4/prog4.c new file mode 100644 index 0000000..3b4d087 --- /dev/null +++ b/examples/tools2/tools/prog4/prog4.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +#include "qux.h" + +int main (int argc, char** argv) +{ + printf ("int_size=%d\n", get_int_size ()); + return 0; +} diff --git a/features/Makefile b/features/Makefile new file mode 100644 index 0000000..662178b --- /dev/null +++ b/features/Makefile @@ -0,0 +1,37 @@ +.for f in strlcat strlcpy getline +FILES += mkc_${f}.h mkc_imp.f_${f}.mk ${f}/${f}.c +FILESDIR_mkc_imp.f_${f}.mk = ${MKFILESDIR} +FILESDIR_mkc_${f}.h = ${FEATURESDIR} +FILESDIR_${f}/${f}.c = ${FEATURESDIR}/${f} +.endfor + +.for f in libm libdl SLIST RB +FILES += mkc_${f}.h mkc_imp.f_${f}.mk +FILESDIR_mkc_imp.f_${f}.mk = ${MKFILESDIR} +FILESDIR_mkc_${f}.h = ${FEATURESDIR} +.endfor + +.for f in netbsd_sys_queue.h netbsd_sys_tree.h +FILES += ${f} +FILESDIR_${f} = ${FEATURESDIR} +.endfor + +LINKS += ${MKFILESDIR}/mkc_imp.f_RB.mk ${MKFILESDIR}/mkc_imp.f_SPLAY.mk + +LINKS += ${FEATURESDIR}/mkc_RB.h ${FEATURESDIR}/mkc_SPLAY.h + +.for i in SIMPLEQ STAILQ LIST TAILQ CIRCLEQ +LINKS += ${MKFILESDIR}/mkc_imp.f_SLIST.mk ${MKFILESDIR}/mkc_imp.f_${i}.mk +LINKS += ${FEATURESDIR}/mkc_SLIST.h ${FEATURESDIR}/mkc_${i}.h + +# the following section is for tests/sys_queue regression test +all: mkc_imp.f_${i}.mk mkc_${i}.h +mkc_imp.f_${i}.mk: mkc_imp.f_SLIST.mk + cp mkc_imp.f_SLIST.mk ${.TARGET} +mkc_${i}.h: mkc_SLIST.h + cp mkc_SLIST.h ${.TARGET} +CLEANFILES += mkc_${i}.h mkc_imp.f_${i}.mk +.endfor + +# +.include <mkc.files.mk> diff --git a/features/_mkcfake.c b/features/_mkcfake.c new file mode 100644 index 0000000..1afa530 --- /dev/null +++ b/features/_mkcfake.c @@ -0,0 +1,3 @@ +static void _mkcfake(void) +{ +} diff --git a/features/err/err.c b/features/err/err.c new file mode 100644 index 0000000..411f810 --- /dev/null +++ b/features/err/err.c @@ -0,0 +1,99 @@ +/* $NetBSD: err.c,v 1.4 2004/08/23 03:32:12 jlam Exp $ */ + +/* + * Copyright 1997-2000 Luke Mewburn <lukem@netbsd.org>. + * Copyright 2014 Aleksey Cheusov <vle@gmx.net>. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <stdarg.h> +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <errno.h> + +#include <mkc_progname.h> +#include <mkc_err.h> + +#if !HAVE_FUNC3_ERR_ERR_H +void err (int eval, const char *fmt, ...) +{ + va_list ap; + int sverrno; + + sverrno = errno; + fprintf (stderr, "%s: ", getprogname ()); + va_start (ap, fmt); + if (fmt != NULL) { + vfprintf (stderr, fmt, ap); + fprintf (stderr, ": "); + } + va_end (ap); + fprintf (stderr, "%s\n", strerror (sverrno)); + exit (eval); +} +#endif + +#if !HAVE_FUNC3_ERRX_ERR_H +void errx (int eval, const char *fmt, ...) +{ + va_list ap; + + fprintf (stderr, "%s: ", getprogname ()); + va_start (ap, fmt); + if (fmt != NULL) + vfprintf (stderr, fmt, ap); + va_end (ap); + fprintf (stderr, "\n"); + exit (eval); +} +#endif + +#if !HAVE_FUNC3_VERR_ERR_H +void verr (int eval, const char *fmt, va_list ap) +{ + int sverrno; + + sverrno = errno; + fprintf (stderr, "%s: ", getprogname ()); + if (fmt != NULL) { + vfprintf (stderr, fmt, ap); + fprintf (stderr, ": "); + } + fprintf (stderr, "%s\n", strerror (sverrno)); + exit (eval); +} +#endif + +#if !HAVE_FUNC3_VERRX_ERR_H +void verrx (int eval, const char *fmt, va_list ap) +{ + fprintf (stderr, "%s: ", getprogname ()); + if (fmt != NULL) + vfprintf (stderr, fmt, ap); + fprintf (stderr, "\n"); + exit (eval); +} +#endif diff --git a/features/fgetln/fgetln.c b/features/fgetln/fgetln.c new file mode 100644 index 0000000..c600b06 --- /dev/null +++ b/features/fgetln/fgetln.c @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2005 Hector Garcia Alvarez + * Copyright (c) 2005, 2008-2012 Guillem Jover <guillem@hadrons.org> + * Copyright (c) 2014 Aleksey Cheusov <vle@gmx.net> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <stdio.h> +#include <string.h> + +#include <mkc_getline.h> +#include <mkc_fgetln.h> + +struct filebuf { + FILE *fp; + char *buf; + size_t len; +}; + +#define FILEBUF_POOL_ITEMS 128 + +static struct filebuf fb_pool [FILEBUF_POOL_ITEMS]; +static int fb_pool_cur; + +char * fgetln (FILE *stream, size_t *len) +{ + struct filebuf *fb; + ssize_t nread; + + /* Try to diminish the possibility of several fgetln() calls being + * used on different streams, by using a pool of buffers per file. */ + fb = &fb_pool [fb_pool_cur]; + if (fb->fp != stream && fb->fp != NULL) { + fb_pool_cur++; + fb_pool_cur %= FILEBUF_POOL_ITEMS; + fb = &fb_pool [fb_pool_cur]; + } + fb->fp = stream; + + nread = getline (&fb->buf, &fb->len, stream); + /* Note: the getdelim/getline API ensures nread != 0. */ + if (nread == -1) { + *len = 0; + return NULL; + } else { + *len = (size_t) nread; + return fb->buf; + } +} diff --git a/features/getline/getline.c b/features/getline/getline.c new file mode 100644 index 0000000..93836b0 --- /dev/null +++ b/features/getline/getline.c @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2007-2014 by Aleksey Cheusov + * See LICENSE file in the distribution. + */ + +#include <stdio.h> +#include <stdlib.h> + +ssize_t +getline(char** lineptr, size_t* n, FILE* stream); + +ssize_t +getline(char** lineptr, size_t* n, FILE* stream) +{ + int c; + size_t sz = 0; + + while (c = getc (stream), c != EOF){ + if (sz+1 >= *n){ + /* +2 is for `c' and 0-terminator */ + *n = *n * 3 / 2 + 2; + *lineptr = realloc (*lineptr, *n); + if (!*lineptr) + return -1; + } + + (*lineptr) [sz++] = (char) c; + if (c == '\n') + break; + } + + if (ferror (stream)) + return (ssize_t) -1; + + if (!sz){ + if (feof (stream)){ + return (ssize_t) -1; + }else if (!*n){ + *lineptr = malloc (1); + if (!*lineptr) + return -1; + + *n = 1; + } + } + + (*lineptr) [sz] = 0; + return sz; +} diff --git a/features/mkc_RB.h b/features/mkc_RB.h new file mode 100644 index 0000000..f1039d2 --- /dev/null +++ b/features/mkc_RB.h @@ -0,0 +1,16 @@ +/********************************************************************\ + Copyright (c) 2014 by Aleksey Cheusov + + See LICENSE file in the distribution. +\********************************************************************/ + +#ifndef _MKC_SYS_TREE_H_ +#define _MKC_SYS_TREE_H_ + +#if defined(HAVE_DEFINE_RB_ENTRY_SYS_TREE_H) && defined(HAVE_DEFINE_SPLAY_ENTRY_SYS_TREE_H) +#include <sys/tree.h> +#else +#include "netbsd_sys_tree.h" +#endif + +#endif // _MKC_SYS_TREE_H_ diff --git a/features/mkc_SLIST.h b/features/mkc_SLIST.h new file mode 100644 index 0000000..0c72646 --- /dev/null +++ b/features/mkc_SLIST.h @@ -0,0 +1,16 @@ +/********************************************************************\ + Copyright (c) 2014 by Aleksey Cheusov + + See LICENSE file in the distribution. +\********************************************************************/ + +#ifndef _MKC_SYS_QUEUE_H_ +#define _MKC_SYS_QUEUE_H_ + +#ifdef MKC_SYS_QUEUE_IS_FINE +#include <sys/queue.h> +#else +#include "netbsd_sys_queue.h" +#endif + +#endif // _MKC_SYS_QUEUE_H_ diff --git a/features/mkc_err.h b/features/mkc_err.h new file mode 100644 index 0000000..16ee12f --- /dev/null +++ b/features/mkc_err.h @@ -0,0 +1,36 @@ +/********************************************************************\ + Copyright (c) 2014 by Aleksey Cheusov + + See LICENSE file in the distribution. +\********************************************************************/ + +#ifndef _MKC_ERR_H_ +#define _MKC_ERR_H_ + +#include <stdarg.h> + +#if HAVE_HEADER_ERR_H +#include <err.h> +#endif + +#ifdef MKC_ERR_IS_FINE + +#include <err.h> + +#else +#if !HAVE_FUNC3_ERR_ERR_H +void err (int, const char *, ...); +#endif +#if !HAVE_FUNC3_ERRX_ERR_H +void errx (int, const char *, ...); +#endif +#if !HAVE_FUNC3_VERR_ERR_H +void verr (int, const char *, va_list); +#endif +#if !HAVE_FUNC3_VERRX_ERR_H +void verrx (int, const char *, va_list); +#endif + +#endif /* MKC_ERR_IS_FINE */ + +#endif // _MKC_ERR_H_ diff --git a/features/mkc_fgetln.h b/features/mkc_fgetln.h new file mode 100644 index 0000000..4238478 --- /dev/null +++ b/features/mkc_fgetln.h @@ -0,0 +1,16 @@ +/********************************************************************\ + Copyright (c) 2014 by Aleksey Cheusov + + See LICENSE file in the distribution. +\********************************************************************/ + +#ifndef _MKC_FGETLN_H_ +#define _MKC_FGETLN_H_ + +#include <stdio.h> + +#ifndef HAVE_FUNC3_FGETLN_STDIO_H +char *fgetln (FILE *stream, size_t *len); +#endif + +#endif // _MKC_FGETLN_H_ diff --git a/features/mkc_getline.h b/features/mkc_getline.h new file mode 100644 index 0000000..728eecb --- /dev/null +++ b/features/mkc_getline.h @@ -0,0 +1,17 @@ +/********************************************************************\ + Copyright (c) 2014 by Aleksey Cheusov + + See LICENSE file in the distribution. +\********************************************************************/ + +#ifndef _MKC_GETLINE_H_ +#define _MKC_GETLINE_H_ + +#include <stdio.h> +#include <stdlib.h> + +#ifndef HAVE_FUNC3_GETLINE_STDIO_H +ssize_t getline(char** lineptr, size_t* n, FILE* stream); +#endif + +#endif // _MKC_GETLINE_H_ diff --git a/features/mkc_imp.f_RB.mk b/features/mkc_imp.f_RB.mk new file mode 100644 index 0000000..5661efd --- /dev/null +++ b/features/mkc_imp.f_RB.mk @@ -0,0 +1,11 @@ +# Copyright (c) 2014 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ +.ifndef _MKC_IMP_F_RB_MK +_MKC_IMP_F_RB_MK := 1 + +MKC_CHECK_DEFINES += RB_ENTRY:sys/tree.h +MKC_CHECK_DEFINES += SPLAY_ENTRY:sys/tree.h + +.endif # _MKC_IMP_F_RB_MK diff --git a/features/mkc_imp.f_SLIST.mk b/features/mkc_imp.f_SLIST.mk new file mode 100644 index 0000000..d5a1fc4 --- /dev/null +++ b/features/mkc_imp.f_SLIST.mk @@ -0,0 +1,36 @@ +# Copyright (c) 2014 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ +.ifndef _MKC_IMP_F_SYSQUEUE_MK +_MKC_IMP_F_SYSQUEUE_MK := 1 + +.include <mkc_imp.conf-cleanup.mk> + +_macro = SLIST SIMPLEQ STAILQ LIST TAILQ TAILQ + +.for m in ${_macro} +MKC_CHECK_DEFINES += ${m}_ENTRY:sys/queue.h +_macro.${m} = 1 +.endfor + +.include <mkc_imp.conf-cleanup.mk> + +.for f in ${MKC_FEATURES} +.if defined(_macro.${f}) && !${HAVE_DEFINE.${m}_ENTRY.sys/queue.h:U0} +bad=1 +.endif +.endfor + +.ifndef bad +CFLAGS+= -DMKC_SYS_QUEUE_IS_FINE=1 +.endif + +.for m in ${_macro} +.undef _macro.${m} +.endfor + +.undef bad +.undef _macro + +.endif # _MKC_IMP_F_SYSQUEUE_MK diff --git a/features/mkc_imp.f_err.mk b/features/mkc_imp.f_err.mk new file mode 100644 index 0000000..d3b50e1 --- /dev/null +++ b/features/mkc_imp.f_err.mk @@ -0,0 +1,29 @@ +# Copyright (c) 2014 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ +.ifndef _MKC_IMP_F_ERR_MK +_MKC_IMP_F_ERR_MK := 1 + +.include <mkc_imp.f_progname.mk> + +.include <mkc_imp.conf-cleanup.mk> + +MKC_CHECK_HEADERS += err.h +MKC_CHECK_FUNCLIBS += err errx verr verrx +MKC_CHECK_FUNCS3 += err:err.h errx:err.h verr:err.h verrx:err.h + +.include <mkc_imp.conf-cleanup.mk> + +.if ${HAVE_FUNCLIB.err:U0} && ${HAVE_FUNCLIB.errx:U0} && \ + ${HAVE_FUNCLIB.verr:U0} && ${HAVE_FUNCLIB.verrx:U0} && \ + ${HAVE_FUNC3.err.err_h:U0} && ${HAVE_FUNC3.errx.err_h:U0} && \ + ${HAVE_FUNC3.verr.err_h:U0} && ${HAVE_FUNC3.verrx.err_h:U0} +CFLAGS += -DMKC_ERR_IS_FINE +.else +MKC_SRCS += ${FEATURESDIR}/err/err.c +.endif + +.include <mkc_imp.conf-final.mk> + +.endif #_MKC_IMP_F_ERR_MK diff --git a/features/mkc_imp.f_fgetln.mk b/features/mkc_imp.f_fgetln.mk new file mode 100644 index 0000000..07e408b --- /dev/null +++ b/features/mkc_imp.f_fgetln.mk @@ -0,0 +1,13 @@ +# Copyright (c) 2014 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +.ifndef _MKC_IMP.F_FGETLN_MK +_MKC_IMP.F_FGETLN_MK := 1 + +.include <mkc_imp.f_getline.mk> + +MKC_SOURCE_FUNCLIBS += fgetln +MKC_SOURCE_DIR.fgetln.c = ${FEATURESDIR}/fgetln +MKC_CHECK_FUNCS3 += fgetln:stdio.h + +.endif # _MKC_IMP.F_FGETLN_MK diff --git a/features/mkc_imp.f_getline.mk b/features/mkc_imp.f_getline.mk new file mode 100644 index 0000000..23dca91 --- /dev/null +++ b/features/mkc_imp.f_getline.mk @@ -0,0 +1,11 @@ +# Copyright (c) 2014 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +.ifndef _MKC_IMP.F_GETLINE_MK +_MKC_IMP.F_GETLINE_MK := 1 + +MKC_SOURCE_FUNCLIBS += getline +MKC_SOURCE_DIR.getline.c = ${FEATURESDIR}/getline +MKC_CHECK_FUNCS3 += getline:stdio.h + +.endif # _MKC_IMP.F_GETLINE_MK diff --git a/features/mkc_imp.f_libdl.mk b/features/mkc_imp.f_libdl.mk new file mode 100644 index 0000000..fdee554 --- /dev/null +++ b/features/mkc_imp.f_libdl.mk @@ -0,0 +1,12 @@ +# Copyright (c) 2014 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +.ifndef _MKC_IMP_F_LIBDL_MK +_MKC_IMP_F_LIBDL_MK := 1 + +MKC_COMMON_DEFINES += -D_GNU_SOURCE + +MKC_REQUIRE_FUNCLIBS += dlopen:dl +MKC_REQUIRE_FUNCS2 += dlopen:dlfcn.h + +.endif # _MKC_IMP_F_LIBDL_MK diff --git a/features/mkc_imp.f_libm.mk b/features/mkc_imp.f_libm.mk new file mode 100644 index 0000000..5134a02 --- /dev/null +++ b/features/mkc_imp.f_libm.mk @@ -0,0 +1,9 @@ +# Copyright (c) 2014 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +.ifndef _MKC_IMP_F_LIBM_MK +_MKC_IMP_F_LIBM_MK := 1 + +MKC_CHECK_FUNCLIBS += sqrt:m + +.endif #_MKC_IMP_F_LIBM_MK diff --git a/features/mkc_imp.f_progname.mk b/features/mkc_imp.f_progname.mk new file mode 100644 index 0000000..9df8119 --- /dev/null +++ b/features/mkc_imp.f_progname.mk @@ -0,0 +1,28 @@ +# Copyright (c) 2014 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ +.ifndef _MKC_IMP.F_PROGNAME_MK +_MKC_IMP.F_PROGNAME_MK := 1 + +MKC_COMMON_DEFINES += -D_GNU_SOURCE + +MKC_CHECK_FUNCLIBS += getprogname setprogname +MKC_CHECK_FUNCS0 += getprogname:stdlib.h getexecname:stdlib.h +MKC_CHECK_FUNCS1 += setprogname:stdlib.h +MKC_CHECK_VARS += program_invocation_short_name:errno.h + +.include <mkc_imp.conf-cleanup.mk> + +.if ${HAVE_FUNCLIB.getprogname:U0} && \ + ${HAVE_FUNCLIB.setprogname:U0} && \ + ${HAVE_FUNC0.getprogname.stdlib_h:U0} && \ + ${HAVE_FUNC1.setprogname.stdlib_h:U0} +CFLAGS += -DMKC_PROGNAME_IS_FINE +.else +MKC_SRCS += ${FEATURESDIR}/progname/progname.c +.endif + +.include <mkc_imp.conf-final.mk> + +.endif # _MKC_IMP.F_PROGNAME_MK diff --git a/features/mkc_imp.f_strlcat.mk b/features/mkc_imp.f_strlcat.mk new file mode 100644 index 0000000..5d7b35a --- /dev/null +++ b/features/mkc_imp.f_strlcat.mk @@ -0,0 +1,11 @@ +# Copyright (c) 2014 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +.ifndef _MKC_IMP_F_STRLCAT_MK +_MKC_IMP_F_STRLCAT_MK := 1 + +MKC_SOURCE_FUNCLIBS += strlcat +MKC_SOURCE_DIR.strlcat.c = ${FEATURESDIR}/strlcat +MKC_CHECK_FUNCS3 += strlcat:string.h + +.endif # _MKC_IMP_F_STRLCAT_MK diff --git a/features/mkc_imp.f_strlcpy.mk b/features/mkc_imp.f_strlcpy.mk new file mode 100644 index 0000000..51759a2 --- /dev/null +++ b/features/mkc_imp.f_strlcpy.mk @@ -0,0 +1,11 @@ +# Copyright (c) 2014 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +.ifndef _MKC_IMP_F_STRLCPY_MK +_MKC_IMP_F_STRLCPY_MK := 1 + +MKC_SOURCE_FUNCLIBS += strlcpy +MKC_SOURCE_DIR.strlcpy.c = ${FEATURESDIR}/strlcpy +MKC_CHECK_FUNCS3 += strlcpy:string.h + +.endif #_MKC_IMP_F_STRLCPY_MK diff --git a/features/mkc_imp.f_warn.mk b/features/mkc_imp.f_warn.mk new file mode 100644 index 0000000..c494d50 --- /dev/null +++ b/features/mkc_imp.f_warn.mk @@ -0,0 +1,29 @@ +# Copyright (c) 2014 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ +.ifndef _MKC_IMP_F_WARN_MK +_MKC_IMP_F_WARN_MK := 1 + +.include <mkc_imp.f_progname.mk> + +.include <mkc_imp.conf-cleanup.mk> + +MKC_CHECK_HEADERS += err.h +MKC_CHECK_FUNCLIBS += warn warnx vwarn vwarnx +MKC_CHECK_FUNCS2 += warn:err.h warnx:err.h vwarn:err.h vwarnx:err.h + +.include <mkc_imp.conf-cleanup.mk> + +.if ${HAVE_FUNCLIB.warn:U0} && ${HAVE_FUNCLIB.warnx:U0} && \ + ${HAVE_FUNCLIB.vwarn:U0} && ${HAVE_FUNCLIB.vwarnx:U0} && \ + ${HAVE_FUNC2.warn.err_h:U0} && ${HAVE_FUNC2.warnx.err_h:U0} && \ + ${HAVE_FUNC2.vwarn.err_h:U0} && ${HAVE_FUNC2.vwarnx.err_h:U0} +CFLAGS += -DMKC_WARN_IS_FINE +.else +MKC_SRCS += ${FEATURESDIR}/warn/warn.c +.endif + +.include <mkc_imp.conf-final.mk> + +.endif # _MKC_IMP_F_WARN_MK diff --git a/features/mkc_libdl.h b/features/mkc_libdl.h new file mode 100644 index 0000000..046dade --- /dev/null +++ b/features/mkc_libdl.h @@ -0,0 +1,18 @@ +/********************************************************************\ + Copyright (c) 2014 by Aleksey Cheusov + + See LICENSE file in the distribution. +\********************************************************************/ + +#ifndef _MKC_LIBDL_H_ +#define _MKC_LIBDL_H_ + +#ifndef _GNU_SOURCE +# define _GNU_SOURCE +# include <dlfcn.h> +# undef _GNU_SOURCE +#else +# include <dlfcn.h> +#endif + +#endif // _MKC_LIBDL_H_ diff --git a/features/mkc_libm.h b/features/mkc_libm.h new file mode 100644 index 0000000..44919e1 --- /dev/null +++ b/features/mkc_libm.h @@ -0,0 +1,12 @@ +/********************************************************************\ + Copyright (c) 2014 by Aleksey Cheusov + + See LICENSE file in the distribution. +\********************************************************************/ + +#ifndef _MKC_LIBM_H_ +#define _MKC_LIBM_H_ + +#include <math.h> + +#endif // _MKC_LIBM_H_ diff --git a/features/mkc_progname.h b/features/mkc_progname.h new file mode 100644 index 0000000..7925e60 --- /dev/null +++ b/features/mkc_progname.h @@ -0,0 +1,26 @@ +/********************************************************************\ + Copyright (c) 2014 by Aleksey Cheusov + + See LICENSE file in the distribution. +\********************************************************************/ + +#ifndef _MKC_PROGNAME_H_ +#define _MKC_PROGNAME_H_ + +#ifdef MKC_PROGNAME_IS_FINE + +#include <stdlib.h> + +#else + +#if !HAVE_FUNC1_SETPROGNAME_STDLIB_H +void setprogname (const char *progname); +#endif + +#if !HAVE_FUNC0_GETPROGNAME_STDLIB_H +const char * getprogname (void); +#endif + +#endif /* MKC_PROGNAME_IS_FINE */ + +#endif // _MKC_PROGNAME_H_ diff --git a/features/mkc_strlcat.h b/features/mkc_strlcat.h new file mode 100644 index 0000000..8ea0f1c --- /dev/null +++ b/features/mkc_strlcat.h @@ -0,0 +1,16 @@ +/********************************************************************\ + Copyright (c) 2014 by Aleksey Cheusov + + See LICENSE file in the distribution. +\********************************************************************/ + +#ifndef _MKC_STRLCAT_H_ +#define _MKC_STRLCAT_H_ + +#include <string.h> + +#if !HAVE_FUNC3_STRLCAT_STRING_H +size_t strlcat(char *dst, const char *src, size_t size); +#endif + +#endif // _MKC_STRLCAT_H_ diff --git a/features/mkc_strlcpy.h b/features/mkc_strlcpy.h new file mode 100644 index 0000000..1826e3f --- /dev/null +++ b/features/mkc_strlcpy.h @@ -0,0 +1,16 @@ +/********************************************************************\ + Copyright (c) 2014 by Aleksey Cheusov + + See LICENSE file in the distribution. +\********************************************************************/ + +#ifndef _MKC_STRLCPY_H_ +#define _MKC_STRLCPY_H_ + +#include <string.h> + +#if !HAVE_FUNC3_STRLCPY_STRING_H +size_t strlcpy(char *dst, const char *src, size_t size); +#endif + +#endif // _MKC_STRLCPY_H_ diff --git a/features/mkc_warn.h b/features/mkc_warn.h new file mode 100644 index 0000000..3576032 --- /dev/null +++ b/features/mkc_warn.h @@ -0,0 +1,36 @@ +/********************************************************************\ + Copyright (c) 2014 by Aleksey Cheusov + + See LICENSE file in the distribution. +\********************************************************************/ + +#ifndef _MKC_WARN_H_ +#define _MKC_WARN_H_ + +#include <stdarg.h> + +#if HAVE_HEADER_ERR_H +#include <err.h> +#endif + +#ifdef MKC_WARN_IS_FINE + +#include <err.h> + +#else +#if !HAVE_FUNC2_WARN_ERR_H +void warn (const char *, ...); +#endif +#if !HAVE_FUNC2_WARNX_ERR_H +void warnx (const char *, ...); +#endif +#if !HAVE_FUNC2_VWARN_ERR_H +void vwarn (const char *, va_list); +#endif +#if !HAVE_FUNC2_VWARNX_ERR_H +void vwarnx (const char *, va_list); +#endif + +#endif /* MKC_WARN_IS_FINE */ + +#endif // _MKC_WARN_H_ diff --git a/features/netbsd_sys_queue.h b/features/netbsd_sys_queue.h new file mode 100644 index 0000000..9189c6c --- /dev/null +++ b/features/netbsd_sys_queue.h @@ -0,0 +1,743 @@ +/* $NetBSD: queue.h,v 1.53 2011/11/19 22:51:31 tls Exp $ */ + +/* + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)queue.h 8.5 (Berkeley) 8/20/94 + */ + +#ifndef _SYS_QUEUE_H_ +#define _SYS_QUEUE_H_ + +#include <stdlib.h> + +/* + * This file defines five types of data structures: singly-linked lists, + * lists, simple queues, tail queues, and circular queues. + * + * A singly-linked list is headed by a single forward pointer. The + * elements are singly linked for minimum space and pointer manipulation + * overhead at the expense of O(n) removal for arbitrary elements. New + * elements can be added to the list after an existing element or at the + * head of the list. Elements being removed from the head of the list + * should use the explicit macro for this purpose for optimum + * efficiency. A singly-linked list may only be traversed in the forward + * direction. Singly-linked lists are ideal for applications with large + * datasets and few or no removals or for implementing a LIFO queue. + * + * A list is headed by a single forward pointer (or an array of forward + * pointers for a hash table header). The elements are doubly linked + * so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list before + * or after an existing element or at the head of the list. A list + * may only be traversed in the forward direction. + * + * A simple queue is headed by a pair of pointers, one the head of the + * list and the other to the tail of the list. The elements are singly + * linked to save space, so elements can only be removed from the + * head of the list. New elements can be added to the list after + * an existing element, at the head of the list, or at the end of the + * list. A simple queue may only be traversed in the forward direction. + * + * A tail queue is headed by a pair of pointers, one to the head of the + * list and the other to the tail of the list. The elements are doubly + * linked so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list before or + * after an existing element, at the head of the list, or at the end of + * the list. A tail queue may be traversed in either direction. + * + * A circle queue is headed by a pair of pointers, one to the head of the + * list and the other to the tail of the list. The elements are doubly + * linked so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list before or after + * an existing element, at the head of the list, or at the end of the list. + * A circle queue may be traversed in either direction, but has a more + * complex end of list detection. + * + * For details on the use of these macros, see the queue(3) manual page. + */ + +/* + * List definitions. + */ +#define LIST_HEAD(name, type) \ +struct name { \ + struct type *lh_first; /* first element */ \ +} + +#define LIST_HEAD_INITIALIZER(head) \ + { NULL } + +#define LIST_ENTRY(type) \ +struct { \ + struct type *le_next; /* next element */ \ + struct type **le_prev; /* address of previous next element */ \ +} + +/* + * List functions. + */ +#if defined(_KERNEL) && defined(QUEUEDEBUG) +#define QUEUEDEBUG_LIST_INSERT_HEAD(head, elm, field) \ + if ((head)->lh_first && \ + (head)->lh_first->field.le_prev != &(head)->lh_first) \ + panic("LIST_INSERT_HEAD %p %s:%d", (head), __FILE__, __LINE__); +#define QUEUEDEBUG_LIST_OP(elm, field) \ + if ((elm)->field.le_next && \ + (elm)->field.le_next->field.le_prev != \ + &(elm)->field.le_next) \ + panic("LIST_* forw %p %s:%d", (elm), __FILE__, __LINE__);\ + if (*(elm)->field.le_prev != (elm)) \ + panic("LIST_* back %p %s:%d", (elm), __FILE__, __LINE__); +#define QUEUEDEBUG_LIST_POSTREMOVE(elm, field) \ + (elm)->field.le_next = (void *)1L; \ + (elm)->field.le_prev = (void *)1L; +#else +#define QUEUEDEBUG_LIST_INSERT_HEAD(head, elm, field) +#define QUEUEDEBUG_LIST_OP(elm, field) +#define QUEUEDEBUG_LIST_POSTREMOVE(elm, field) +#endif + +#define LIST_INIT(head) do { \ + (head)->lh_first = NULL; \ +} while (/*CONSTCOND*/0) + +#define LIST_INSERT_AFTER(listelm, elm, field) do { \ + QUEUEDEBUG_LIST_OP((listelm), field) \ + if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \ + (listelm)->field.le_next->field.le_prev = \ + &(elm)->field.le_next; \ + (listelm)->field.le_next = (elm); \ + (elm)->field.le_prev = &(listelm)->field.le_next; \ +} while (/*CONSTCOND*/0) + +#define LIST_INSERT_BEFORE(listelm, elm, field) do { \ + QUEUEDEBUG_LIST_OP((listelm), field) \ + (elm)->field.le_prev = (listelm)->field.le_prev; \ + (elm)->field.le_next = (listelm); \ + *(listelm)->field.le_prev = (elm); \ + (listelm)->field.le_prev = &(elm)->field.le_next; \ +} while (/*CONSTCOND*/0) + +#define LIST_INSERT_HEAD(head, elm, field) do { \ + QUEUEDEBUG_LIST_INSERT_HEAD((head), (elm), field) \ + if (((elm)->field.le_next = (head)->lh_first) != NULL) \ + (head)->lh_first->field.le_prev = &(elm)->field.le_next;\ + (head)->lh_first = (elm); \ + (elm)->field.le_prev = &(head)->lh_first; \ +} while (/*CONSTCOND*/0) + +#define LIST_REMOVE(elm, field) do { \ + QUEUEDEBUG_LIST_OP((elm), field) \ + if ((elm)->field.le_next != NULL) \ + (elm)->field.le_next->field.le_prev = \ + (elm)->field.le_prev; \ + *(elm)->field.le_prev = (elm)->field.le_next; \ + QUEUEDEBUG_LIST_POSTREMOVE((elm), field) \ +} while (/*CONSTCOND*/0) + +#define LIST_FOREACH(var, head, field) \ + for ((var) = ((head)->lh_first); \ + (var); \ + (var) = ((var)->field.le_next)) + +#define LIST_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = LIST_FIRST((head)); \ + (var) && ((tvar) = LIST_NEXT((var), field), 1); \ + (var) = (tvar)) +/* + * List access methods. + */ +#define LIST_EMPTY(head) ((head)->lh_first == NULL) +#define LIST_FIRST(head) ((head)->lh_first) +#define LIST_NEXT(elm, field) ((elm)->field.le_next) + + +/* + * Singly-linked List definitions. + */ +#define SLIST_HEAD(name, type) \ +struct name { \ + struct type *slh_first; /* first element */ \ +} + +#define SLIST_HEAD_INITIALIZER(head) \ + { NULL } + +#define SLIST_ENTRY(type) \ +struct { \ + struct type *sle_next; /* next element */ \ +} + +/* + * Singly-linked List functions. + */ +#define SLIST_INIT(head) do { \ + (head)->slh_first = NULL; \ +} while (/*CONSTCOND*/0) + +#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \ + (elm)->field.sle_next = (slistelm)->field.sle_next; \ + (slistelm)->field.sle_next = (elm); \ +} while (/*CONSTCOND*/0) + +#define SLIST_INSERT_HEAD(head, elm, field) do { \ + (elm)->field.sle_next = (head)->slh_first; \ + (head)->slh_first = (elm); \ +} while (/*CONSTCOND*/0) + +#define SLIST_REMOVE_HEAD(head, field) do { \ + (head)->slh_first = (head)->slh_first->field.sle_next; \ +} while (/*CONSTCOND*/0) + +#define SLIST_REMOVE(head, elm, type, field) do { \ + if ((head)->slh_first == (elm)) { \ + SLIST_REMOVE_HEAD((head), field); \ + } \ + else { \ + struct type *curelm = (head)->slh_first; \ + while(curelm->field.sle_next != (elm)) \ + curelm = curelm->field.sle_next; \ + curelm->field.sle_next = \ + curelm->field.sle_next->field.sle_next; \ + } \ +} while (/*CONSTCOND*/0) + +#define SLIST_REMOVE_AFTER(slistelm, field) do { \ + (slistelm)->field.sle_next = \ + SLIST_NEXT(SLIST_NEXT((slistelm), field), field); \ +} while (/*CONSTCOND*/0) + +#define SLIST_FOREACH(var, head, field) \ + for((var) = (head)->slh_first; (var); (var) = (var)->field.sle_next) + +#define SLIST_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = SLIST_FIRST((head)); \ + (var) && ((tvar) = SLIST_NEXT((var), field), 1); \ + (var) = (tvar)) + +/* + * Singly-linked List access methods. + */ +#define SLIST_EMPTY(head) ((head)->slh_first == NULL) +#define SLIST_FIRST(head) ((head)->slh_first) +#define SLIST_NEXT(elm, field) ((elm)->field.sle_next) + + +/* + * Singly-linked Tail queue declarations. + */ +#define STAILQ_HEAD(name, type) \ +struct name { \ + struct type *stqh_first; /* first element */ \ + struct type **stqh_last; /* addr of last next element */ \ +} + +#define STAILQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).stqh_first } + +#define STAILQ_ENTRY(type) \ +struct { \ + struct type *stqe_next; /* next element */ \ +} + +/* + * Singly-linked Tail queue functions. + */ +#define STAILQ_INIT(head) do { \ + (head)->stqh_first = NULL; \ + (head)->stqh_last = &(head)->stqh_first; \ +} while (/*CONSTCOND*/0) + +#define STAILQ_INSERT_HEAD(head, elm, field) do { \ + if (((elm)->field.stqe_next = (head)->stqh_first) == NULL) \ + (head)->stqh_last = &(elm)->field.stqe_next; \ + (head)->stqh_first = (elm); \ +} while (/*CONSTCOND*/0) + +#define STAILQ_INSERT_TAIL(head, elm, field) do { \ + (elm)->field.stqe_next = NULL; \ + *(head)->stqh_last = (elm); \ + (head)->stqh_last = &(elm)->field.stqe_next; \ +} while (/*CONSTCOND*/0) + +#define STAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ + if (((elm)->field.stqe_next = (listelm)->field.stqe_next) == NULL)\ + (head)->stqh_last = &(elm)->field.stqe_next; \ + (listelm)->field.stqe_next = (elm); \ +} while (/*CONSTCOND*/0) + +#define STAILQ_REMOVE_HEAD(head, field) do { \ + if (((head)->stqh_first = (head)->stqh_first->field.stqe_next) == NULL) \ + (head)->stqh_last = &(head)->stqh_first; \ +} while (/*CONSTCOND*/0) + +#define STAILQ_REMOVE(head, elm, type, field) do { \ + if ((head)->stqh_first == (elm)) { \ + STAILQ_REMOVE_HEAD((head), field); \ + } else { \ + struct type *curelm = (head)->stqh_first; \ + while (curelm->field.stqe_next != (elm)) \ + curelm = curelm->field.stqe_next; \ + if ((curelm->field.stqe_next = \ + curelm->field.stqe_next->field.stqe_next) == NULL) \ + (head)->stqh_last = &(curelm)->field.stqe_next; \ + } \ +} while (/*CONSTCOND*/0) + +#define STAILQ_FOREACH(var, head, field) \ + for ((var) = ((head)->stqh_first); \ + (var); \ + (var) = ((var)->field.stqe_next)) + +#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = STAILQ_FIRST((head)); \ + (var) && ((tvar) = STAILQ_NEXT((var), field), 1); \ + (var) = (tvar)) + +#define STAILQ_CONCAT(head1, head2) do { \ + if (!STAILQ_EMPTY((head2))) { \ + *(head1)->stqh_last = (head2)->stqh_first; \ + (head1)->stqh_last = (head2)->stqh_last; \ + STAILQ_INIT((head2)); \ + } \ +} while (/*CONSTCOND*/0) + +#define STAILQ_LAST(head, type, field) \ + (STAILQ_EMPTY((head)) ? \ + NULL : \ + ((struct type *)(void *) \ + ((char *)((head)->stqh_last) - offsetof(struct type, field)))) + +/* + * Singly-linked Tail queue access methods. + */ +#define STAILQ_EMPTY(head) ((head)->stqh_first == NULL) +#define STAILQ_FIRST(head) ((head)->stqh_first) +#define STAILQ_NEXT(elm, field) ((elm)->field.stqe_next) + + +/* + * Simple queue definitions. + */ +#define SIMPLEQ_HEAD(name, type) \ +struct name { \ + struct type *sqh_first; /* first element */ \ + struct type **sqh_last; /* addr of last next element */ \ +} + +#define SIMPLEQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).sqh_first } + +#define SIMPLEQ_ENTRY(type) \ +struct { \ + struct type *sqe_next; /* next element */ \ +} + +/* + * Simple queue functions. + */ +#define SIMPLEQ_INIT(head) do { \ + (head)->sqh_first = NULL; \ + (head)->sqh_last = &(head)->sqh_first; \ +} while (/*CONSTCOND*/0) + +#define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \ + if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \ + (head)->sqh_last = &(elm)->field.sqe_next; \ + (head)->sqh_first = (elm); \ +} while (/*CONSTCOND*/0) + +#define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \ + (elm)->field.sqe_next = NULL; \ + *(head)->sqh_last = (elm); \ + (head)->sqh_last = &(elm)->field.sqe_next; \ +} while (/*CONSTCOND*/0) + +#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ + if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\ + (head)->sqh_last = &(elm)->field.sqe_next; \ + (listelm)->field.sqe_next = (elm); \ +} while (/*CONSTCOND*/0) + +#define SIMPLEQ_REMOVE_HEAD(head, field) do { \ + if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \ + (head)->sqh_last = &(head)->sqh_first; \ +} while (/*CONSTCOND*/0) + +#define SIMPLEQ_REMOVE(head, elm, type, field) do { \ + if ((head)->sqh_first == (elm)) { \ + SIMPLEQ_REMOVE_HEAD((head), field); \ + } else { \ + struct type *curelm = (head)->sqh_first; \ + while (curelm->field.sqe_next != (elm)) \ + curelm = curelm->field.sqe_next; \ + if ((curelm->field.sqe_next = \ + curelm->field.sqe_next->field.sqe_next) == NULL) \ + (head)->sqh_last = &(curelm)->field.sqe_next; \ + } \ +} while (/*CONSTCOND*/0) + +#define SIMPLEQ_FOREACH(var, head, field) \ + for ((var) = ((head)->sqh_first); \ + (var); \ + (var) = ((var)->field.sqe_next)) + +#define SIMPLEQ_FOREACH_SAFE(var, head, field, next) \ + for ((var) = ((head)->sqh_first); \ + (var) && ((next = ((var)->field.sqe_next)), 1); \ + (var) = (next)) + +#define SIMPLEQ_CONCAT(head1, head2) do { \ + if (!SIMPLEQ_EMPTY((head2))) { \ + *(head1)->sqh_last = (head2)->sqh_first; \ + (head1)->sqh_last = (head2)->sqh_last; \ + SIMPLEQ_INIT((head2)); \ + } \ +} while (/*CONSTCOND*/0) + +#define SIMPLEQ_LAST(head, type, field) \ + (SIMPLEQ_EMPTY((head)) ? \ + NULL : \ + ((struct type *)(void *) \ + ((char *)((head)->sqh_last) - offsetof(struct type, field)))) + +/* + * Simple queue access methods. + */ +#define SIMPLEQ_EMPTY(head) ((head)->sqh_first == NULL) +#define SIMPLEQ_FIRST(head) ((head)->sqh_first) +#define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next) + + +/* + * Tail queue definitions. + */ +#define _TAILQ_HEAD(name, type, qual) \ +struct name { \ + qual type *tqh_first; /* first element */ \ + qual type *qual *tqh_last; /* addr of last next element */ \ +} +#define TAILQ_HEAD(name, type) _TAILQ_HEAD(name, struct type,) + +#define TAILQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).tqh_first } + +#define _TAILQ_ENTRY(type, qual) \ +struct { \ + qual type *tqe_next; /* next element */ \ + qual type *qual *tqe_prev; /* address of previous next element */\ +} +#define TAILQ_ENTRY(type) _TAILQ_ENTRY(struct type,) + +/* + * Tail queue functions. + */ +#if defined(_KERNEL) && defined(QUEUEDEBUG) +#define QUEUEDEBUG_TAILQ_INSERT_HEAD(head, elm, field) \ + if ((head)->tqh_first && \ + (head)->tqh_first->field.tqe_prev != &(head)->tqh_first) \ + panic("TAILQ_INSERT_HEAD %p %s:%d", (head), __FILE__, __LINE__); +#define QUEUEDEBUG_TAILQ_INSERT_TAIL(head, elm, field) \ + if (*(head)->tqh_last != NULL) \ + panic("TAILQ_INSERT_TAIL %p %s:%d", (head), __FILE__, __LINE__); +#define QUEUEDEBUG_TAILQ_OP(elm, field) \ + if ((elm)->field.tqe_next && \ + (elm)->field.tqe_next->field.tqe_prev != \ + &(elm)->field.tqe_next) \ + panic("TAILQ_* forw %p %s:%d", (elm), __FILE__, __LINE__);\ + if (*(elm)->field.tqe_prev != (elm)) \ + panic("TAILQ_* back %p %s:%d", (elm), __FILE__, __LINE__); +#define QUEUEDEBUG_TAILQ_PREREMOVE(head, elm, field) \ + if ((elm)->field.tqe_next == NULL && \ + (head)->tqh_last != &(elm)->field.tqe_next) \ + panic("TAILQ_PREREMOVE head %p elm %p %s:%d", \ + (head), (elm), __FILE__, __LINE__); +#define QUEUEDEBUG_TAILQ_POSTREMOVE(elm, field) \ + (elm)->field.tqe_next = (void *)1L; \ + (elm)->field.tqe_prev = (void *)1L; +#else +#define QUEUEDEBUG_TAILQ_INSERT_HEAD(head, elm, field) +#define QUEUEDEBUG_TAILQ_INSERT_TAIL(head, elm, field) +#define QUEUEDEBUG_TAILQ_OP(elm, field) +#define QUEUEDEBUG_TAILQ_PREREMOVE(head, elm, field) +#define QUEUEDEBUG_TAILQ_POSTREMOVE(elm, field) +#endif + +#define TAILQ_INIT(head) do { \ + (head)->tqh_first = NULL; \ + (head)->tqh_last = &(head)->tqh_first; \ +} while (/*CONSTCOND*/0) + +#define TAILQ_INSERT_HEAD(head, elm, field) do { \ + QUEUEDEBUG_TAILQ_INSERT_HEAD((head), (elm), field) \ + if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \ + (head)->tqh_first->field.tqe_prev = \ + &(elm)->field.tqe_next; \ + else \ + (head)->tqh_last = &(elm)->field.tqe_next; \ + (head)->tqh_first = (elm); \ + (elm)->field.tqe_prev = &(head)->tqh_first; \ +} while (/*CONSTCOND*/0) + +#define TAILQ_INSERT_TAIL(head, elm, field) do { \ + QUEUEDEBUG_TAILQ_INSERT_TAIL((head), (elm), field) \ + (elm)->field.tqe_next = NULL; \ + (elm)->field.tqe_prev = (head)->tqh_last; \ + *(head)->tqh_last = (elm); \ + (head)->tqh_last = &(elm)->field.tqe_next; \ +} while (/*CONSTCOND*/0) + +#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ + QUEUEDEBUG_TAILQ_OP((listelm), field) \ + if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\ + (elm)->field.tqe_next->field.tqe_prev = \ + &(elm)->field.tqe_next; \ + else \ + (head)->tqh_last = &(elm)->field.tqe_next; \ + (listelm)->field.tqe_next = (elm); \ + (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \ +} while (/*CONSTCOND*/0) + +#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ + QUEUEDEBUG_TAILQ_OP((listelm), field) \ + (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ + (elm)->field.tqe_next = (listelm); \ + *(listelm)->field.tqe_prev = (elm); \ + (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \ +} while (/*CONSTCOND*/0) + +#define TAILQ_REMOVE(head, elm, field) do { \ + QUEUEDEBUG_TAILQ_PREREMOVE((head), (elm), field) \ + QUEUEDEBUG_TAILQ_OP((elm), field) \ + if (((elm)->field.tqe_next) != NULL) \ + (elm)->field.tqe_next->field.tqe_prev = \ + (elm)->field.tqe_prev; \ + else \ + (head)->tqh_last = (elm)->field.tqe_prev; \ + *(elm)->field.tqe_prev = (elm)->field.tqe_next; \ + QUEUEDEBUG_TAILQ_POSTREMOVE((elm), field); \ +} while (/*CONSTCOND*/0) + +#define TAILQ_FOREACH(var, head, field) \ + for ((var) = ((head)->tqh_first); \ + (var); \ + (var) = ((var)->field.tqe_next)) + +#define TAILQ_FOREACH_SAFE(var, head, field, next) \ + for ((var) = ((head)->tqh_first); \ + (var) != NULL && ((next) = TAILQ_NEXT(var, field), 1); \ + (var) = (next)) + +#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ + for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \ + (var); \ + (var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last))) + +#define TAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, prev) \ + for ((var) = TAILQ_LAST((head), headname); \ + (var) && ((prev) = TAILQ_PREV((var), headname, field), 1);\ + (var) = (prev)) + +#define TAILQ_CONCAT(head1, head2, field) do { \ + if (!TAILQ_EMPTY(head2)) { \ + *(head1)->tqh_last = (head2)->tqh_first; \ + (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \ + (head1)->tqh_last = (head2)->tqh_last; \ + TAILQ_INIT((head2)); \ + } \ +} while (/*CONSTCOND*/0) + +/* + * Tail queue access methods. + */ +#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL) +#define TAILQ_FIRST(head) ((head)->tqh_first) +#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) + +#define TAILQ_LAST(head, headname) \ + (*(((struct headname *)((head)->tqh_last))->tqh_last)) +#define TAILQ_PREV(elm, headname, field) \ + (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) + + +/* + * Circular queue definitions. + */ +#if defined(_KERNEL) && defined(QUEUEDEBUG) +#define QUEUEDEBUG_CIRCLEQ_HEAD(head, field) \ + if ((head)->cqh_first != (void *)(head) && \ + (head)->cqh_first->field.cqe_prev != (void *)(head)) \ + panic("CIRCLEQ head forw %p %s:%d", (head), \ + __FILE__, __LINE__); \ + if ((head)->cqh_last != (void *)(head) && \ + (head)->cqh_last->field.cqe_next != (void *)(head)) \ + panic("CIRCLEQ head back %p %s:%d", (head), \ + __FILE__, __LINE__); +#define QUEUEDEBUG_CIRCLEQ_ELM(head, elm, field) \ + if ((elm)->field.cqe_next == (void *)(head)) { \ + if ((head)->cqh_last != (elm)) \ + panic("CIRCLEQ elm last %p %s:%d", (elm), \ + __FILE__, __LINE__); \ + } else { \ + if ((elm)->field.cqe_next->field.cqe_prev != (elm)) \ + panic("CIRCLEQ elm forw %p %s:%d", (elm), \ + __FILE__, __LINE__); \ + } \ + if ((elm)->field.cqe_prev == (void *)(head)) { \ + if ((head)->cqh_first != (elm)) \ + panic("CIRCLEQ elm first %p %s:%d", (elm), \ + __FILE__, __LINE__); \ + } else { \ + if ((elm)->field.cqe_prev->field.cqe_next != (elm)) \ + panic("CIRCLEQ elm prev %p %s:%d", (elm), \ + __FILE__, __LINE__); \ + } +#define QUEUEDEBUG_CIRCLEQ_POSTREMOVE(elm, field) \ + (elm)->field.cqe_next = (void *)1L; \ + (elm)->field.cqe_prev = (void *)1L; +#else +#define QUEUEDEBUG_CIRCLEQ_HEAD(head, field) +#define QUEUEDEBUG_CIRCLEQ_ELM(head, elm, field) +#define QUEUEDEBUG_CIRCLEQ_POSTREMOVE(elm, field) +#endif + +#define CIRCLEQ_HEAD(name, type) \ +struct name { \ + struct type *cqh_first; /* first element */ \ + struct type *cqh_last; /* last element */ \ +} + +#define CIRCLEQ_HEAD_INITIALIZER(head) \ + { (void *)&head, (void *)&head } + +#define CIRCLEQ_ENTRY(type) \ +struct { \ + struct type *cqe_next; /* next element */ \ + struct type *cqe_prev; /* previous element */ \ +} + +/* + * Circular queue functions. + */ +#define CIRCLEQ_INIT(head) do { \ + (head)->cqh_first = (void *)(head); \ + (head)->cqh_last = (void *)(head); \ +} while (/*CONSTCOND*/0) + +#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ + QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \ + QUEUEDEBUG_CIRCLEQ_ELM((head), (listelm), field) \ + (elm)->field.cqe_next = (listelm)->field.cqe_next; \ + (elm)->field.cqe_prev = (listelm); \ + if ((listelm)->field.cqe_next == (void *)(head)) \ + (head)->cqh_last = (elm); \ + else \ + (listelm)->field.cqe_next->field.cqe_prev = (elm); \ + (listelm)->field.cqe_next = (elm); \ +} while (/*CONSTCOND*/0) + +#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \ + QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \ + QUEUEDEBUG_CIRCLEQ_ELM((head), (listelm), field) \ + (elm)->field.cqe_next = (listelm); \ + (elm)->field.cqe_prev = (listelm)->field.cqe_prev; \ + if ((listelm)->field.cqe_prev == (void *)(head)) \ + (head)->cqh_first = (elm); \ + else \ + (listelm)->field.cqe_prev->field.cqe_next = (elm); \ + (listelm)->field.cqe_prev = (elm); \ +} while (/*CONSTCOND*/0) + +#define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \ + QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \ + (elm)->field.cqe_next = (head)->cqh_first; \ + (elm)->field.cqe_prev = (void *)(head); \ + if ((head)->cqh_last == (void *)(head)) \ + (head)->cqh_last = (elm); \ + else \ + (head)->cqh_first->field.cqe_prev = (elm); \ + (head)->cqh_first = (elm); \ +} while (/*CONSTCOND*/0) + +#define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \ + QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \ + (elm)->field.cqe_next = (void *)(head); \ + (elm)->field.cqe_prev = (head)->cqh_last; \ + if ((head)->cqh_first == (void *)(head)) \ + (head)->cqh_first = (elm); \ + else \ + (head)->cqh_last->field.cqe_next = (elm); \ + (head)->cqh_last = (elm); \ +} while (/*CONSTCOND*/0) + +#define CIRCLEQ_REMOVE(head, elm, field) do { \ + QUEUEDEBUG_CIRCLEQ_HEAD((head), field) \ + QUEUEDEBUG_CIRCLEQ_ELM((head), (elm), field) \ + if ((elm)->field.cqe_next == (void *)(head)) \ + (head)->cqh_last = (elm)->field.cqe_prev; \ + else \ + (elm)->field.cqe_next->field.cqe_prev = \ + (elm)->field.cqe_prev; \ + if ((elm)->field.cqe_prev == (void *)(head)) \ + (head)->cqh_first = (elm)->field.cqe_next; \ + else \ + (elm)->field.cqe_prev->field.cqe_next = \ + (elm)->field.cqe_next; \ + QUEUEDEBUG_CIRCLEQ_POSTREMOVE((elm), field) \ +} while (/*CONSTCOND*/0) + +#define CIRCLEQ_FOREACH(var, head, field) \ + for ((var) = ((head)->cqh_first); \ + (var) != (const void *)(head); \ + (var) = ((var)->field.cqe_next)) + +#define CIRCLEQ_FOREACH_REVERSE(var, head, field) \ + for ((var) = ((head)->cqh_last); \ + (var) != (const void *)(head); \ + (var) = ((var)->field.cqe_prev)) + +/* + * Circular queue access methods. + */ +#define CIRCLEQ_EMPTY(head) ((head)->cqh_first == (void *)(head)) +#define CIRCLEQ_FIRST(head) ((head)->cqh_first) +#define CIRCLEQ_LAST(head) ((head)->cqh_last) +#define CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next) +#define CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev) + +#define CIRCLEQ_LOOP_NEXT(head, elm, field) \ + (((elm)->field.cqe_next == (void *)(head)) \ + ? ((head)->cqh_first) \ + : (elm->field.cqe_next)) +#define CIRCLEQ_LOOP_PREV(head, elm, field) \ + (((elm)->field.cqe_prev == (void *)(head)) \ + ? ((head)->cqh_last) \ + : (elm->field.cqe_prev)) + +#endif /* !_SYS_QUEUE_H_ */ diff --git a/features/netbsd_sys_tree.h b/features/netbsd_sys_tree.h new file mode 100644 index 0000000..d044f98 --- /dev/null +++ b/features/netbsd_sys_tree.h @@ -0,0 +1,741 @@ +/* $NetBSD: tree.h,v 1.16 2008/03/21 13:07:15 ad Exp $ */ +/* $OpenBSD: tree.h,v 1.7 2002/10/17 21:51:54 art Exp $ */ +/* + * Copyright 2002 Niels Provos <provos@citi.umich.edu> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SYS_TREE_H_ +#define _SYS_TREE_H_ + +/* + * This file defines data structures for different types of trees: + * splay trees and red-black trees. + * + * A splay tree is a self-organizing data structure. Every operation + * on the tree causes a splay to happen. The splay moves the requested + * node to the root of the tree and partly rebalances it. + * + * This has the benefit that request locality causes faster lookups as + * the requested nodes move to the top of the tree. On the other hand, + * every lookup causes memory writes. + * + * The Balance Theorem bounds the total access time for m operations + * and n inserts on an initially empty tree as O((m + n)lg n). The + * amortized cost for a sequence of m accesses to a splay tree is O(lg n); + * + * A red-black tree is a binary search tree with the node color as an + * extra attribute. It fulfills a set of conditions: + * - every search path from the root to a leaf consists of the + * same number of black nodes, + * - each red node (except for the root) has a black parent, + * - each leaf node is black. + * + * Every operation on a red-black tree is bounded as O(lg n). + * The maximum height of a red-black tree is 2lg (n+1). + */ + +#define SPLAY_HEAD(name, type) \ +struct name { \ + struct type *sph_root; /* root of the tree */ \ +} + +#define SPLAY_INITIALIZER(root) \ + { NULL } + +#define SPLAY_INIT(root) do { \ + (root)->sph_root = NULL; \ +} while (/*CONSTCOND*/ 0) + +#define SPLAY_ENTRY(type) \ +struct { \ + struct type *spe_left; /* left element */ \ + struct type *spe_right; /* right element */ \ +} + +#define SPLAY_LEFT(elm, field) (elm)->field.spe_left +#define SPLAY_RIGHT(elm, field) (elm)->field.spe_right +#define SPLAY_ROOT(head) (head)->sph_root +#define SPLAY_EMPTY(head) (SPLAY_ROOT(head) == NULL) + +/* SPLAY_ROTATE_{LEFT,RIGHT} expect that tmp hold SPLAY_{RIGHT,LEFT} */ +#define SPLAY_ROTATE_RIGHT(head, tmp, field) do { \ + SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(tmp, field); \ + SPLAY_RIGHT(tmp, field) = (head)->sph_root; \ + (head)->sph_root = tmp; \ +} while (/*CONSTCOND*/ 0) + +#define SPLAY_ROTATE_LEFT(head, tmp, field) do { \ + SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(tmp, field); \ + SPLAY_LEFT(tmp, field) = (head)->sph_root; \ + (head)->sph_root = tmp; \ +} while (/*CONSTCOND*/ 0) + +#define SPLAY_LINKLEFT(head, tmp, field) do { \ + SPLAY_LEFT(tmp, field) = (head)->sph_root; \ + tmp = (head)->sph_root; \ + (head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \ +} while (/*CONSTCOND*/ 0) + +#define SPLAY_LINKRIGHT(head, tmp, field) do { \ + SPLAY_RIGHT(tmp, field) = (head)->sph_root; \ + tmp = (head)->sph_root; \ + (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \ +} while (/*CONSTCOND*/ 0) + +#define SPLAY_ASSEMBLE(head, node, left, right, field) do { \ + SPLAY_RIGHT(left, field) = SPLAY_LEFT((head)->sph_root, field); \ + SPLAY_LEFT(right, field) = SPLAY_RIGHT((head)->sph_root, field);\ + SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(node, field); \ + SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(node, field); \ +} while (/*CONSTCOND*/ 0) + +/* Generates prototypes and inline functions */ + +#define SPLAY_PROTOTYPE(name, type, field, cmp) \ +void name##_SPLAY(struct name *, struct type *); \ +void name##_SPLAY_MINMAX(struct name *, int); \ +struct type *name##_SPLAY_INSERT(struct name *, struct type *); \ +struct type *name##_SPLAY_REMOVE(struct name *, struct type *); \ + \ +/* Finds the node with the same key as elm */ \ +static __inline struct type * \ +name##_SPLAY_FIND(struct name *head, struct type *elm) \ +{ \ + if (SPLAY_EMPTY(head)) \ + return(NULL); \ + name##_SPLAY(head, elm); \ + if ((cmp)(elm, (head)->sph_root) == 0) \ + return (head->sph_root); \ + return (NULL); \ +} \ + \ +static __inline struct type * \ +name##_SPLAY_NEXT(struct name *head, struct type *elm) \ +{ \ + name##_SPLAY(head, elm); \ + if (SPLAY_RIGHT(elm, field) != NULL) { \ + elm = SPLAY_RIGHT(elm, field); \ + while (SPLAY_LEFT(elm, field) != NULL) { \ + elm = SPLAY_LEFT(elm, field); \ + } \ + } else \ + elm = NULL; \ + return (elm); \ +} \ + \ +static __inline struct type * \ +name##_SPLAY_MIN_MAX(struct name *head, int val) \ +{ \ + name##_SPLAY_MINMAX(head, val); \ + return (SPLAY_ROOT(head)); \ +} + +/* Main splay operation. + * Moves node close to the key of elm to top + */ +#define SPLAY_GENERATE(name, type, field, cmp) \ +struct type * \ +name##_SPLAY_INSERT(struct name *head, struct type *elm) \ +{ \ + if (SPLAY_EMPTY(head)) { \ + SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = NULL; \ + } else { \ + int __comp; \ + name##_SPLAY(head, elm); \ + __comp = (cmp)(elm, (head)->sph_root); \ + if(__comp < 0) { \ + SPLAY_LEFT(elm, field) = SPLAY_LEFT((head)->sph_root, field);\ + SPLAY_RIGHT(elm, field) = (head)->sph_root; \ + SPLAY_LEFT((head)->sph_root, field) = NULL; \ + } else if (__comp > 0) { \ + SPLAY_RIGHT(elm, field) = SPLAY_RIGHT((head)->sph_root, field);\ + SPLAY_LEFT(elm, field) = (head)->sph_root; \ + SPLAY_RIGHT((head)->sph_root, field) = NULL; \ + } else \ + return ((head)->sph_root); \ + } \ + (head)->sph_root = (elm); \ + return (NULL); \ +} \ + \ +struct type * \ +name##_SPLAY_REMOVE(struct name *head, struct type *elm) \ +{ \ + struct type *__tmp; \ + if (SPLAY_EMPTY(head)) \ + return (NULL); \ + name##_SPLAY(head, elm); \ + if ((cmp)(elm, (head)->sph_root) == 0) { \ + if (SPLAY_LEFT((head)->sph_root, field) == NULL) { \ + (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field);\ + } else { \ + __tmp = SPLAY_RIGHT((head)->sph_root, field); \ + (head)->sph_root = SPLAY_LEFT((head)->sph_root, field);\ + name##_SPLAY(head, elm); \ + SPLAY_RIGHT((head)->sph_root, field) = __tmp; \ + } \ + return (elm); \ + } \ + return (NULL); \ +} \ + \ +void \ +name##_SPLAY(struct name *head, struct type *elm) \ +{ \ + struct type __node, *__left, *__right, *__tmp; \ + int __comp; \ +\ + SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\ + __left = __right = &__node; \ +\ + while ((__comp = (cmp)(elm, (head)->sph_root)) != 0) { \ + if (__comp < 0) { \ + __tmp = SPLAY_LEFT((head)->sph_root, field); \ + if (__tmp == NULL) \ + break; \ + if ((cmp)(elm, __tmp) < 0){ \ + SPLAY_ROTATE_RIGHT(head, __tmp, field); \ + if (SPLAY_LEFT((head)->sph_root, field) == NULL)\ + break; \ + } \ + SPLAY_LINKLEFT(head, __right, field); \ + } else if (__comp > 0) { \ + __tmp = SPLAY_RIGHT((head)->sph_root, field); \ + if (__tmp == NULL) \ + break; \ + if ((cmp)(elm, __tmp) > 0){ \ + SPLAY_ROTATE_LEFT(head, __tmp, field); \ + if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\ + break; \ + } \ + SPLAY_LINKRIGHT(head, __left, field); \ + } \ + } \ + SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \ +} \ + \ +/* Splay with either the minimum or the maximum element \ + * Used to find minimum or maximum element in tree. \ + */ \ +void name##_SPLAY_MINMAX(struct name *head, int __comp) \ +{ \ + struct type __node, *__left, *__right, *__tmp; \ +\ + SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\ + __left = __right = &__node; \ +\ + while (1) { \ + if (__comp < 0) { \ + __tmp = SPLAY_LEFT((head)->sph_root, field); \ + if (__tmp == NULL) \ + break; \ + if (__comp < 0){ \ + SPLAY_ROTATE_RIGHT(head, __tmp, field); \ + if (SPLAY_LEFT((head)->sph_root, field) == NULL)\ + break; \ + } \ + SPLAY_LINKLEFT(head, __right, field); \ + } else if (__comp > 0) { \ + __tmp = SPLAY_RIGHT((head)->sph_root, field); \ + if (__tmp == NULL) \ + break; \ + if (__comp > 0) { \ + SPLAY_ROTATE_LEFT(head, __tmp, field); \ + if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\ + break; \ + } \ + SPLAY_LINKRIGHT(head, __left, field); \ + } \ + } \ + SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \ +} + +#define SPLAY_NEGINF -1 +#define SPLAY_INF 1 + +#define SPLAY_INSERT(name, x, y) name##_SPLAY_INSERT(x, y) +#define SPLAY_REMOVE(name, x, y) name##_SPLAY_REMOVE(x, y) +#define SPLAY_FIND(name, x, y) name##_SPLAY_FIND(x, y) +#define SPLAY_NEXT(name, x, y) name##_SPLAY_NEXT(x, y) +#define SPLAY_MIN(name, x) (SPLAY_EMPTY(x) ? NULL \ + : name##_SPLAY_MIN_MAX(x, SPLAY_NEGINF)) +#define SPLAY_MAX(name, x) (SPLAY_EMPTY(x) ? NULL \ + : name##_SPLAY_MIN_MAX(x, SPLAY_INF)) + +#define SPLAY_FOREACH(x, name, head) \ + for ((x) = SPLAY_MIN(name, head); \ + (x) != NULL; \ + (x) = SPLAY_NEXT(name, head, x)) + +/* Macros that define a red-black tree */ +#define RB_HEAD(name, type) \ +struct name { \ + struct type *rbh_root; /* root of the tree */ \ +} + +#define RB_INITIALIZER(root) \ + { NULL } + +#define RB_INIT(root) do { \ + (root)->rbh_root = NULL; \ +} while (/*CONSTCOND*/ 0) + +#define RB_BLACK 0 +#define RB_RED 1 +#define RB_ENTRY(type) \ +struct { \ + struct type *rbe_left; /* left element */ \ + struct type *rbe_right; /* right element */ \ + struct type *rbe_parent; /* parent element */ \ + int rbe_color; /* node color */ \ +} + +#define RB_LEFT(elm, field) (elm)->field.rbe_left +#define RB_RIGHT(elm, field) (elm)->field.rbe_right +#define RB_PARENT(elm, field) (elm)->field.rbe_parent +#define RB_COLOR(elm, field) (elm)->field.rbe_color +#define RB_ROOT(head) (head)->rbh_root +#define RB_EMPTY(head) (RB_ROOT(head) == NULL) + +#define RB_SET(elm, parent, field) do { \ + RB_PARENT(elm, field) = parent; \ + RB_LEFT(elm, field) = RB_RIGHT(elm, field) = NULL; \ + RB_COLOR(elm, field) = RB_RED; \ +} while (/*CONSTCOND*/ 0) + +#define RB_SET_BLACKRED(black, red, field) do { \ + RB_COLOR(black, field) = RB_BLACK; \ + RB_COLOR(red, field) = RB_RED; \ +} while (/*CONSTCOND*/ 0) + +#ifndef RB_AUGMENT +#define RB_AUGMENT(x) (void)(x) +#endif + +#define RB_ROTATE_LEFT(head, elm, tmp, field) do { \ + (tmp) = RB_RIGHT(elm, field); \ + if ((RB_RIGHT(elm, field) = RB_LEFT(tmp, field)) != NULL) { \ + RB_PARENT(RB_LEFT(tmp, field), field) = (elm); \ + } \ + RB_AUGMENT(elm); \ + if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field)) != NULL) { \ + if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \ + RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \ + else \ + RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \ + } else \ + (head)->rbh_root = (tmp); \ + RB_LEFT(tmp, field) = (elm); \ + RB_PARENT(elm, field) = (tmp); \ + RB_AUGMENT(tmp); \ + if ((RB_PARENT(tmp, field))) \ + RB_AUGMENT(RB_PARENT(tmp, field)); \ +} while (/*CONSTCOND*/ 0) + +#define RB_ROTATE_RIGHT(head, elm, tmp, field) do { \ + (tmp) = RB_LEFT(elm, field); \ + if ((RB_LEFT(elm, field) = RB_RIGHT(tmp, field)) != NULL) { \ + RB_PARENT(RB_RIGHT(tmp, field), field) = (elm); \ + } \ + RB_AUGMENT(elm); \ + if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field)) != NULL) { \ + if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \ + RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \ + else \ + RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \ + } else \ + (head)->rbh_root = (tmp); \ + RB_RIGHT(tmp, field) = (elm); \ + RB_PARENT(elm, field) = (tmp); \ + RB_AUGMENT(tmp); \ + if ((RB_PARENT(tmp, field))) \ + RB_AUGMENT(RB_PARENT(tmp, field)); \ +} while (/*CONSTCOND*/ 0) + +/* Generates prototypes and inline functions */ +#define RB_PROTOTYPE(name, type, field, cmp) \ + RB_PROTOTYPE_INTERNAL(name, type, field, cmp,) +#define RB_PROTOTYPE_STATIC(name, type, field, cmp) \ + RB_PROTOTYPE_INTERNAL(name, type, field, cmp, __unused static) +#define RB_PROTOTYPE_INTERNAL(name, type, field, cmp, attr) \ +attr void name##_RB_INSERT_COLOR(struct name *, struct type *); \ +attr void name##_RB_REMOVE_COLOR(struct name *, struct type *, struct type *);\ +attr struct type *name##_RB_REMOVE(struct name *, struct type *); \ +attr struct type *name##_RB_INSERT(struct name *, struct type *); \ +attr struct type *name##_RB_FIND(struct name *, struct type *); \ +attr struct type *name##_RB_NFIND(struct name *, struct type *); \ +attr struct type *name##_RB_NEXT(struct type *); \ +attr struct type *name##_RB_PREV(struct type *); \ +attr struct type *name##_RB_MINMAX(struct name *, int); \ + \ + +/* Main rb operation. + * Moves node close to the key of elm to top + */ +#define RB_GENERATE(name, type, field, cmp) \ + RB_GENERATE_INTERNAL(name, type, field, cmp,) +#define RB_GENERATE_STATIC(name, type, field, cmp) \ + RB_GENERATE_INTERNAL(name, type, field, cmp, __unused static) +#define RB_GENERATE_INTERNAL(name, type, field, cmp, attr) \ +attr void \ +name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \ +{ \ + struct type *parent, *gparent, *tmp; \ + while ((parent = RB_PARENT(elm, field)) != NULL && \ + RB_COLOR(parent, field) == RB_RED) { \ + gparent = RB_PARENT(parent, field); \ + if (parent == RB_LEFT(gparent, field)) { \ + tmp = RB_RIGHT(gparent, field); \ + if (tmp && RB_COLOR(tmp, field) == RB_RED) { \ + RB_COLOR(tmp, field) = RB_BLACK; \ + RB_SET_BLACKRED(parent, gparent, field);\ + elm = gparent; \ + continue; \ + } \ + if (RB_RIGHT(parent, field) == elm) { \ + RB_ROTATE_LEFT(head, parent, tmp, field);\ + tmp = parent; \ + parent = elm; \ + elm = tmp; \ + } \ + RB_SET_BLACKRED(parent, gparent, field); \ + RB_ROTATE_RIGHT(head, gparent, tmp, field); \ + } else { \ + tmp = RB_LEFT(gparent, field); \ + if (tmp && RB_COLOR(tmp, field) == RB_RED) { \ + RB_COLOR(tmp, field) = RB_BLACK; \ + RB_SET_BLACKRED(parent, gparent, field);\ + elm = gparent; \ + continue; \ + } \ + if (RB_LEFT(parent, field) == elm) { \ + RB_ROTATE_RIGHT(head, parent, tmp, field);\ + tmp = parent; \ + parent = elm; \ + elm = tmp; \ + } \ + RB_SET_BLACKRED(parent, gparent, field); \ + RB_ROTATE_LEFT(head, gparent, tmp, field); \ + } \ + } \ + RB_COLOR(head->rbh_root, field) = RB_BLACK; \ +} \ + \ +attr void \ +name##_RB_REMOVE_COLOR(struct name *head, struct type *parent, struct type *elm) \ +{ \ + struct type *tmp; \ + while ((elm == NULL || RB_COLOR(elm, field) == RB_BLACK) && \ + elm != RB_ROOT(head)) { \ + if (RB_LEFT(parent, field) == elm) { \ + tmp = RB_RIGHT(parent, field); \ + if (RB_COLOR(tmp, field) == RB_RED) { \ + RB_SET_BLACKRED(tmp, parent, field); \ + RB_ROTATE_LEFT(head, parent, tmp, field);\ + tmp = RB_RIGHT(parent, field); \ + } \ + if ((RB_LEFT(tmp, field) == NULL || \ + RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) &&\ + (RB_RIGHT(tmp, field) == NULL || \ + RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) {\ + RB_COLOR(tmp, field) = RB_RED; \ + elm = parent; \ + parent = RB_PARENT(elm, field); \ + } else { \ + if (RB_RIGHT(tmp, field) == NULL || \ + RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK) {\ + struct type *oleft; \ + if ((oleft = RB_LEFT(tmp, field)) \ + != NULL) \ + RB_COLOR(oleft, field) = RB_BLACK;\ + RB_COLOR(tmp, field) = RB_RED; \ + RB_ROTATE_RIGHT(head, tmp, oleft, field);\ + tmp = RB_RIGHT(parent, field); \ + } \ + RB_COLOR(tmp, field) = RB_COLOR(parent, field);\ + RB_COLOR(parent, field) = RB_BLACK; \ + if (RB_RIGHT(tmp, field)) \ + RB_COLOR(RB_RIGHT(tmp, field), field) = RB_BLACK;\ + RB_ROTATE_LEFT(head, parent, tmp, field);\ + elm = RB_ROOT(head); \ + break; \ + } \ + } else { \ + tmp = RB_LEFT(parent, field); \ + if (RB_COLOR(tmp, field) == RB_RED) { \ + RB_SET_BLACKRED(tmp, parent, field); \ + RB_ROTATE_RIGHT(head, parent, tmp, field);\ + tmp = RB_LEFT(parent, field); \ + } \ + if ((RB_LEFT(tmp, field) == NULL || \ + RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) &&\ + (RB_RIGHT(tmp, field) == NULL || \ + RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) {\ + RB_COLOR(tmp, field) = RB_RED; \ + elm = parent; \ + parent = RB_PARENT(elm, field); \ + } else { \ + if (RB_LEFT(tmp, field) == NULL || \ + RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) {\ + struct type *oright; \ + if ((oright = RB_RIGHT(tmp, field)) \ + != NULL) \ + RB_COLOR(oright, field) = RB_BLACK;\ + RB_COLOR(tmp, field) = RB_RED; \ + RB_ROTATE_LEFT(head, tmp, oright, field);\ + tmp = RB_LEFT(parent, field); \ + } \ + RB_COLOR(tmp, field) = RB_COLOR(parent, field);\ + RB_COLOR(parent, field) = RB_BLACK; \ + if (RB_LEFT(tmp, field)) \ + RB_COLOR(RB_LEFT(tmp, field), field) = RB_BLACK;\ + RB_ROTATE_RIGHT(head, parent, tmp, field);\ + elm = RB_ROOT(head); \ + break; \ + } \ + } \ + } \ + if (elm) \ + RB_COLOR(elm, field) = RB_BLACK; \ +} \ + \ +attr struct type * \ +name##_RB_REMOVE(struct name *head, struct type *elm) \ +{ \ + struct type *child, *parent, *old = elm; \ + int color; \ + if (RB_LEFT(elm, field) == NULL) \ + child = RB_RIGHT(elm, field); \ + else if (RB_RIGHT(elm, field) == NULL) \ + child = RB_LEFT(elm, field); \ + else { \ + struct type *left; \ + elm = RB_RIGHT(elm, field); \ + while ((left = RB_LEFT(elm, field)) != NULL) \ + elm = left; \ + child = RB_RIGHT(elm, field); \ + parent = RB_PARENT(elm, field); \ + color = RB_COLOR(elm, field); \ + if (child) \ + RB_PARENT(child, field) = parent; \ + if (parent) { \ + if (RB_LEFT(parent, field) == elm) \ + RB_LEFT(parent, field) = child; \ + else \ + RB_RIGHT(parent, field) = child; \ + RB_AUGMENT(parent); \ + } else \ + RB_ROOT(head) = child; \ + if (RB_PARENT(elm, field) == old) \ + parent = elm; \ + (elm)->field = (old)->field; \ + if (RB_PARENT(old, field)) { \ + if (RB_LEFT(RB_PARENT(old, field), field) == old)\ + RB_LEFT(RB_PARENT(old, field), field) = elm;\ + else \ + RB_RIGHT(RB_PARENT(old, field), field) = elm;\ + RB_AUGMENT(RB_PARENT(old, field)); \ + } else \ + RB_ROOT(head) = elm; \ + RB_PARENT(RB_LEFT(old, field), field) = elm; \ + if (RB_RIGHT(old, field)) \ + RB_PARENT(RB_RIGHT(old, field), field) = elm; \ + if (parent) { \ + left = parent; \ + do { \ + RB_AUGMENT(left); \ + } while ((left = RB_PARENT(left, field)) != NULL); \ + } \ + goto color; \ + } \ + parent = RB_PARENT(elm, field); \ + color = RB_COLOR(elm, field); \ + if (child) \ + RB_PARENT(child, field) = parent; \ + if (parent) { \ + if (RB_LEFT(parent, field) == elm) \ + RB_LEFT(parent, field) = child; \ + else \ + RB_RIGHT(parent, field) = child; \ + RB_AUGMENT(parent); \ + } else \ + RB_ROOT(head) = child; \ +color: \ + if (color == RB_BLACK) \ + name##_RB_REMOVE_COLOR(head, parent, child); \ + return (old); \ +} \ + \ +/* Inserts a node into the RB tree */ \ +attr struct type * \ +name##_RB_INSERT(struct name *head, struct type *elm) \ +{ \ + struct type *tmp; \ + struct type *parent = NULL; \ + int comp = 0; \ + tmp = RB_ROOT(head); \ + while (tmp) { \ + parent = tmp; \ + comp = (cmp)(elm, parent); \ + if (comp < 0) \ + tmp = RB_LEFT(tmp, field); \ + else if (comp > 0) \ + tmp = RB_RIGHT(tmp, field); \ + else \ + return (tmp); \ + } \ + RB_SET(elm, parent, field); \ + if (parent != NULL) { \ + if (comp < 0) \ + RB_LEFT(parent, field) = elm; \ + else \ + RB_RIGHT(parent, field) = elm; \ + RB_AUGMENT(parent); \ + } else \ + RB_ROOT(head) = elm; \ + name##_RB_INSERT_COLOR(head, elm); \ + return (NULL); \ +} \ + \ +/* Finds the node with the same key as elm */ \ +attr struct type * \ +name##_RB_FIND(struct name *head, struct type *elm) \ +{ \ + struct type *tmp = RB_ROOT(head); \ + int comp; \ + while (tmp) { \ + comp = cmp(elm, tmp); \ + if (comp < 0) \ + tmp = RB_LEFT(tmp, field); \ + else if (comp > 0) \ + tmp = RB_RIGHT(tmp, field); \ + else \ + return (tmp); \ + } \ + return (NULL); \ +} \ + \ +/* Finds the first node greater than or equal to the search key */ \ +attr struct type * \ +name##_RB_NFIND(struct name *head, struct type *elm) \ +{ \ + struct type *tmp = RB_ROOT(head); \ + struct type *res = NULL; \ + int comp; \ + while (tmp) { \ + comp = cmp(elm, tmp); \ + if (comp < 0) { \ + res = tmp; \ + tmp = RB_LEFT(tmp, field); \ + } \ + else if (comp > 0) \ + tmp = RB_RIGHT(tmp, field); \ + else \ + return (tmp); \ + } \ + return (res); \ +} \ + \ +/* ARGSUSED */ \ +attr struct type * \ +name##_RB_NEXT(struct type *elm) \ +{ \ + if (RB_RIGHT(elm, field)) { \ + elm = RB_RIGHT(elm, field); \ + while (RB_LEFT(elm, field)) \ + elm = RB_LEFT(elm, field); \ + } else { \ + if (RB_PARENT(elm, field) && \ + (elm == RB_LEFT(RB_PARENT(elm, field), field))) \ + elm = RB_PARENT(elm, field); \ + else { \ + while (RB_PARENT(elm, field) && \ + (elm == RB_RIGHT(RB_PARENT(elm, field), field)))\ + elm = RB_PARENT(elm, field); \ + elm = RB_PARENT(elm, field); \ + } \ + } \ + return (elm); \ +} \ + \ +/* ARGSUSED */ \ +attr struct type * \ +name##_RB_PREV(struct type *elm) \ +{ \ + if (RB_LEFT(elm, field)) { \ + elm = RB_LEFT(elm, field); \ + while (RB_RIGHT(elm, field)) \ + elm = RB_RIGHT(elm, field); \ + } else { \ + if (RB_PARENT(elm, field) && \ + (elm == RB_RIGHT(RB_PARENT(elm, field), field))) \ + elm = RB_PARENT(elm, field); \ + else { \ + while (RB_PARENT(elm, field) && \ + (elm == RB_LEFT(RB_PARENT(elm, field), field)))\ + elm = RB_PARENT(elm, field); \ + elm = RB_PARENT(elm, field); \ + } \ + } \ + return (elm); \ +} \ + \ +attr struct type * \ +name##_RB_MINMAX(struct name *head, int val) \ +{ \ + struct type *tmp = RB_ROOT(head); \ + struct type *parent = NULL; \ + while (tmp) { \ + parent = tmp; \ + if (val < 0) \ + tmp = RB_LEFT(tmp, field); \ + else \ + tmp = RB_RIGHT(tmp, field); \ + } \ + return (parent); \ +} + +#define RB_NEGINF -1 +#define RB_INF 1 + +#define RB_INSERT(name, x, y) name##_RB_INSERT(x, y) +#define RB_REMOVE(name, x, y) name##_RB_REMOVE(x, y) +#define RB_FIND(name, x, y) name##_RB_FIND(x, y) +#define RB_NFIND(name, x, y) name##_RB_NFIND(x, y) +#define RB_NEXT(name, x, y) name##_RB_NEXT(y) +#define RB_PREV(name, x, y) name##_RB_PREV(y) +#define RB_MIN(name, x) name##_RB_MINMAX(x, RB_NEGINF) +#define RB_MAX(name, x) name##_RB_MINMAX(x, RB_INF) + +#define RB_FOREACH(x, name, head) \ + for ((x) = RB_MIN(name, head); \ + (x) != NULL; \ + (x) = name##_RB_NEXT(x)) + +#define RB_FOREACH_REVERSE(x, name, head) \ + for ((x) = RB_MAX(name, head); \ + (x) != NULL; \ + (x) = name##_RB_PREV(x)) + +#endif /* _SYS_TREE_H_ */ diff --git a/features/progname/progname.c b/features/progname/progname.c new file mode 100644 index 0000000..c025cfe --- /dev/null +++ b/features/progname/progname.c @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2014 by Aleksey Cheusov + * See LICENSE file in the distribution. + */ + +#include <string.h> +#include <stdlib.h> +#include <errno.h> + +#include <mkc_progname.h> + +static const char *__prog = NULL; + +const char * getprogname (void) +{ + if (__prog) + return __prog; + +#ifdef HAVE_FUNC0_GETEXECNAME_STDLIB_H + /* SunOS */ + setprogname (getexecname ()); + return getprogname (); +#elif defined(HAVE_VAR_PROGRAM_INVOCATION_SHORT_NAME_ERRNO_H) + return program_invocation_short_name; +#else + return "<unset_progname>"; +#endif +} + +void setprogname (const char *progname) +{ + const char *s = strrchr (progname, '/'); + __prog = progname; + + if (s) + __prog = s + 1; +} diff --git a/features/strlcat/strlcat.c b/features/strlcat/strlcat.c new file mode 100644 index 0000000..4d6c29a --- /dev/null +++ b/features/strlcat/strlcat.c @@ -0,0 +1,60 @@ +/* + * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND TODD C. MILLER DISCLAIMS ALL + * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER BE LIABLE + * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <assert.h> +#include <string.h> + +/* + * Appends src to string dst of size siz (unlike strncat, siz is the + * full size of dst, not space left). At most siz-1 characters + * will be copied. Always NUL terminates (unless siz <= strlen(dst)). + * Returns strlen(src) + MIN(siz, strlen(initial dst)). + * If retval >= siz, truncation occurred. + */ +size_t +strlcat (char *dst, const char *src, size_t siz); + +size_t +strlcat (char *dst, const char *src, size_t siz) +{ + char *d = dst; + const char *s = src; + size_t n = siz; + size_t dlen; + + assert (dst != NULL); + assert (src != NULL); + + /* Find the end of dst and adjust bytes left but don't go past end */ + while (n-- != 0 && *d != '\0') + d++; + dlen = d - dst; + n = siz - dlen; + + if (n == 0) + return (dlen + strlen(s)); + + while (*s != '\0'){ + if (n != 1){ + *d++ = *s; + n--; + } + s++; + } + *d = '\0'; + + return (dlen + (s - src)); /* count does not include NUL */ +} diff --git a/features/strlcpy/strlcpy.c b/features/strlcpy/strlcpy.c new file mode 100644 index 0000000..4fca883 --- /dev/null +++ b/features/strlcpy/strlcpy.c @@ -0,0 +1,55 @@ +/* + * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND TODD C. MILLER DISCLAIMS ALL + * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER BE LIABLE + * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <assert.h> +#include <string.h> + +/* + * Copy src to string dst of size siz. At most siz-1 characters + * will be copied. Always NUL terminates (unless siz == 0). + * Returns strlen(src); if retval >= siz, truncation occurred. + */ +size_t +strlcpy(char *dst, const char *src, size_t siz); + +size_t +strlcpy(char *dst, const char *src, size_t siz) +{ + char *d = dst; + const char *s = src; + size_t n = siz; + + assert (dst != NULL); + assert (src != NULL); + + /* Copy as many bytes as will fit */ + if (n != 0 && --n != 0){ + do{ + if ((*d++ = *s++) == 0) + break; + }while (--n != 0); + } + + /* Not enough room in dst, add NUL and traverse rest of src */ + if (n == 0){ + if (siz != 0) + *d = '\0'; /* NUL-terminate dst */ + while (*s++) + ; + } + + return (s - src - 1); /* count does not include NUL */ +} diff --git a/features/warn/warn.c b/features/warn/warn.c new file mode 100644 index 0000000..8b39b48 --- /dev/null +++ b/features/warn/warn.c @@ -0,0 +1,95 @@ +/* $NetBSD: warn.c,v 1.4 2004/08/23 03:32:12 jlam Exp $ */ + +/* + * Copyright 1997-2000 Luke Mewburn <lukem@netbsd.org>. + * Copyright 2014 Aleksey Cheusov <vle@gmx.net>. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <stdarg.h> +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <errno.h> + +#include <mkc_progname.h> +#include <mkc_warn.h> + +#if !HAVE_FUNC2_WARN_ERR_H +void warn (const char *fmt, ...) +{ + va_list ap; + int sverrno; + + sverrno = errno; + fprintf (stderr, "%s: ", getprogname ()); + va_start (ap, fmt); + if (fmt != NULL) { + vfprintf (stderr, fmt, ap); + fprintf (stderr, ": "); + } + va_end (ap); + fprintf (stderr, "%s\n", strerror (sverrno)); +} +#endif + +#if !HAVE_FUNC2_WARNX_ERR_H +void warnx (const char *fmt, ...) +{ + va_list ap; + + fprintf (stderr, "%s: ", getprogname ()); + va_start (ap, fmt); + if (fmt != NULL) + vfprintf (stderr, fmt, ap); + va_end (ap); + fprintf (stderr, "\n"); +} +#endif + +#if !HAVE_FUNC2_VWARN_ERR_H +void vwarn (const char *fmt, va_list ap) +{ + int sverrno; + + sverrno = errno; + fprintf (stderr, "%s: ", getprogname ()); + if (fmt != NULL) { + vfprintf (stderr, fmt, ap); + fprintf (stderr, ": "); + } + fprintf (stderr, "%s\n", strerror (sverrno)); +} +#endif + +#if !HAVE_FUNC2_VWARNX_ERR_H +void vwarnx (const char *fmt, va_list ap) +{ + fprintf (stderr, "%s: ", getprogname ()); + if (fmt != NULL) + vfprintf (stderr, fmt, ap); + fprintf (stderr, "\n"); +} +#endif diff --git a/helpers/Makefile b/helpers/Makefile new file mode 100644 index 0000000..a37e0f2 --- /dev/null +++ b/helpers/Makefile @@ -0,0 +1,4 @@ +SCRIPTS = mkc_test_helper ${INSCRIPTS} +INSCRIPTS = mkc_long_lines + +.include <mkc.mk> diff --git a/helpers/mkc_long_lines.in b/helpers/mkc_long_lines.in new file mode 100755 index 0000000..91a07e4 --- /dev/null +++ b/helpers/mkc_long_lines.in @@ -0,0 +1,17 @@ +#!@AWK@ -f + +############################################################ +# Copyright (c) 2014 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +# processes backslash in the end of line + +/\\$/ { + printf "%s", substr($0, 1, length($0)-1) + next +} +{ + print +} diff --git a/helpers/mkc_test_helper b/helpers/mkc_test_helper new file mode 100755 index 0000000..934fa72 --- /dev/null +++ b/helpers/mkc_test_helper @@ -0,0 +1,43 @@ +#!/bin/sh + +############################################################ +# Copyright (c) 2009-2010 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +set -e +test $# -eq 2 + +prefix="$1" +objdir="$2" + +LC_ALL=C +export LC_ALL + +if test -z "$NOSORT"; then + SORT_CMD=sort +else + SORT_CMD=cat +fi + +grep -v CVS | +grep -v '~$' | +sed -e "s,$objdir,/objdir,g" \ + -e "s,$prefix,/prefix,g" \ + -e "s,/usr/pkg,/prefix," \ + -e "s,/usr,/prefix," \ + -e "s,/opt/local,/prefix," \ + -e "s,/opt,/prefix," \ + -e 's/\([.][^ ]*\)[.]dylib/.so\1/' \ + -e 's/[.]dylib/.so/' \ + -e 's/[.]bundle/.so/' \ + -e 's/[.]exe//' \ + -e '/export[.]sym[.]tmp/ d' \ + -e '/pod2htmd.tmp/ d' \ + -e '/pod2htmi.tmp/ d' \ + -e 's,lua/[0-9]*[.][0-9]*,lua/X.Y,' \ + -e 's,//,/,g' \ + -e 's,^bmake:.*line [0-9][0-9]*: "\(.*\)".*$,\1,g' \ + -e 's/[.]sl/.so/' -e /so_locations/d | +$SORT_CMD diff --git a/helpers/mkc_test_helper2 b/helpers/mkc_test_helper2 new file mode 100755 index 0000000..0d23176 --- /dev/null +++ b/helpers/mkc_test_helper2 @@ -0,0 +1,14 @@ +#!/bin/sh + +############################################################ +# Copyright (c) 2009-2010 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +set -e + +LC_ALL=C +export LC_ALL + +sed '/^checking / s|^\(.*\) [^ ]*[.][.][.].*$|\1 mmm... nnn|' "$@" diff --git a/helpers/mkc_test_helper_paths b/helpers/mkc_test_helper_paths new file mode 100755 index 0000000..2feae85 --- /dev/null +++ b/helpers/mkc_test_helper_paths @@ -0,0 +1,17 @@ +#!/bin/sh + +############################################################ +# Copyright (c) 2012 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +set -e + +LC_ALL=C +export LC_ALL + +sed -e 's,/[^ ]*/,/path/to/,' \ + -e 's/\([.][^ ]*\)[.]dylib/.so\1/' \ + -e 's/[.]bundle/.so/' \ + "$@" diff --git a/helpers/mkc_test_nm b/helpers/mkc_test_nm new file mode 100755 index 0000000..82be0b8 --- /dev/null +++ b/helpers/mkc_test_nm @@ -0,0 +1,22 @@ +#!/bin/sh + +: ${OPSYS:=`uname -s`} +: ${NM:=nm} + +case ${OPSYS} in + *BSD|DragonFly) + ${NM} "$@" | + grep -Ev 'fini|init' | + awk '$2=="T" {print "symbol " $3}' + ;; + SunOS) + ${NM} -P "$@" | + grep -Ev 'fini|init' | + awk 'NF==4 && $2=="T" {print "symbol " $1}' + ;; + Linux) + ${NM} "$@" | + grep -Ev 'fini|init' | + awk 'NF==3 && $2 ~ /^[DT]$/ {print "symbol " $3}' + ;; +esac @@ -0,0 +1,65 @@ +# Copyright (c) 2014 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +.sinclude "cheusov_local_settings.mk" # for debugging + +################################################## +SUBPRJ_DFLT = builtins helpers mk scripts features doc +SUBPRJ = examples presentation ${SUBPRJ_DFLT} + +tests = configure_test mkinstall mkshlib mkstaticlib mkpiclib \ + mkprofilelib mkdll pkg_config_0 pkg_config_1 pkg_config_1_1 pkg_config_2 \ + lua_dirs rec_makefiles reqd reqd2 reqd3 reqd4 reqd_clean_cache \ + intexts_cleantrg require_prototype test_subprj_dash test_mkc_vs_PROG \ + test_mkc_vs_LIB test_mkc_vs_SUBDIR test_mkc_vs_SUBPRJ endianess \ + create_cachedir sys_queue predopost_targets FSRCDIR +.for t in ${tests} +SUBPRJ += tests/${t}:tests +.endfor + +examples = hello_world hello_scripts hello_files hello_sizeof hello_lex \ + hello_yacc hello_calc2 subprojects hello_compilers hello_plugins \ + hello_plugins2 hello_glib2 hello_subdirs hello_strlcpy hello_strlcpy2 \ + hello_strlcpy3 hello_customtests hello_customtests2 hello_requirements \ + hello_iconv hello_cxx hello_cxxlib hello_dictd hello_lua hello_lua2 \ + hello_lua3 hello_superfs hello_xxzip hello_progs hello_progs2 tools \ + tools2 pkgconfig3 hello_SLIST hello_RBTREE hello_errwarn hello_fgetln \ + hello_autotools hello_autoconf hello_libdeps hello_compatlib \ + hello_require_tools +.for t in ${examples} +SUBPRJ += examples/${t}:tests +.endfor + +################################################## +SHRTOUT = yes + +PROJECTNAME = mk-configure + +# +NOEXPORT_VARNAMES = MKC_CACHEDIR + +DIST_TARGETS = pdf clean-mk clean-scripts mkc_clean + +INSTALL = ${.CURDIR}/scripts/mkc_install +PATH := ${OBJDIR_builtins}:${OBJDIR_helpers}:${.CURDIR}/helpers:${OBJDIR_scripts}:${.CURDIR}/scripts:${PATH} + +.export SHRTOUT INSTALL PATH + +################################################## +.PHONY: pdf +pdf: all-presentation +pdf: + @set -e; cd presentation; \ + ${MAKE} ${MAKEFLAGS} clean-garbage; \ + rm -f myprojects.* + +################################################## +cleandir: cleandir-tests cleandir-presentation +clean: clean-tests clean-presentation +test: test-tests + +################################################## +.include "Makefile.inc" +.include <mkc.mk> diff --git a/mk/Makefile b/mk/Makefile new file mode 100644 index 0000000..567e001 --- /dev/null +++ b/mk/Makefile @@ -0,0 +1,56 @@ +FILES = sys.mk mkc.configure.mk mkc_imp.conf.mk mkc_imp.conf-cleanup.mk \ + mkc.mk mkc.init.mk mkc_imp.intexts.mk mkc_imp.mk \ + mkc.minitest.mk mkc_imp.pkg-config.mk mkc_imp.dpvars.mk \ + mkc_imp.files.mk mkc_imp.inc.mk mkc_imp.info.mk mkc_imp.lib.mk \ + mkc_imp.links.mk mkc_imp.man.mk mkc_imp.prog.mk \ + mkc_imp.subprj.mk mkc_imp.conf-final.mk mkc_imp.rules.mk \ + mkc_imp.final.mk mkc_imp.scripts.mk mkc_imp.checkprogs.mk \ + mkc_imp.platform.sys.mk mkc_imp.dep.mk mkc_imp.lua.mk \ + mkc_imp.arch.mk mkc_imp.pod.mk mkc_imp.preinit.mk \ + mkc.prog.mk mkc.files.mk mkc.lib.mk mkc.subdir.mk mkc.subprj.mk \ + mkc_imp.objdir.mk mkc_imp.obj.mk ${INFILES} + +FILESDIR = ${MKFILESDIR} + +INFILES += mkc_imp.vars.mk + +################################################# +.for i in prog_mkdep prog_nbmkdep +MKC_CHECK_CUSTOM += ${i} +MKC_CUSTOM_FN.${i} = ${.CURDIR}/../builtins/${i} +.endfor + +MKC_CHECK_PROGS += makedepend + +.include <mkc.configure.mk> + +.if !empty(CUSTOM.prog_nbmkdep) +mkdep_cmd = ${CUSTOM.prog_nbmkdep} +mkdep_type = nbmkdep +.elif !empty(CUSTOM.prog_mkdep) +mkdep_cmd = ${CUSTOM.prog_mkdep} +mkdep_type = mkdep +.elif ${HAVE_PROG.makedepend:U0} +makedepend_cmd = ${PROG.makedepend} +mkdep_cmd = mkdep +mkdep_type = makedepend +.else +MKC_ERR_MSG += "mkdep(1) cannot be found" +.endif + +.if exists(/usr/xpg4/bin/nm) +PROG.nm ?= /usr/xpg4/bin/nm +.else +MKC_REQUIRE_PROGS += nm +.endif + +makedepend_cmd ?= makedepend + +INTEXTS_REPLS += mkdep_cmd ${mkdep_cmd} +INTEXTS_REPLS += makedepend_cmd ${makedepend_cmd} +INTEXTS_REPLS += mkdep_type ${mkdep_type} +INTEXTS_REPLS += featuresdir ${FEATURESDIR} +INTEXTS_REPLS += NM ${PROG.nm} + +################################################# +.include <mkc.mk> diff --git a/mk/mkc.configure.mk b/mk/mkc.configure.mk new file mode 100644 index 0000000..bf48c5f --- /dev/null +++ b/mk/mkc.configure.mk @@ -0,0 +1,12 @@ +# Copyright (c) 2009-2010 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +.include <mkc_imp.preinit.mk> +.include <mkc.init.mk> + +.include <mkc_imp.conf.mk> + +.PHONY: configure +configure: errorcheck diff --git a/mk/mkc.files.mk b/mk/mkc.files.mk new file mode 100644 index 0000000..8974529 --- /dev/null +++ b/mk/mkc.files.mk @@ -0,0 +1,2 @@ +_top_mk := mkc.files.mk +.include <mkc.mk> diff --git a/mk/mkc.init.mk b/mk/mkc.init.mk new file mode 100644 index 0000000..6f7e3cb --- /dev/null +++ b/mk/mkc.init.mk @@ -0,0 +1,440 @@ +# Copyright (c) 2009-2014 by Aleksey Cheusov +# Copyright (c) 1994-2009 The NetBSD Foundation, Inc. +# Copyright (c) 1988, 1989, 1993 The Regents of the University of California +# Copyright (c) 1988, 1989 by Adam de Boor +# Copyright (c) 1989 by Berkeley Softworks +# Copyright (c) 2009-2014 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +.ifndef OPSYS +OPSYS != uname -s +OPSYS := ${OPSYS:C/^CYGWIN.*$/Cygwin/} +.endif +TARGET_OPSYS ?= ${OPSYS} + +########### +SHORTPRJNAME ?= yes + +###################################################################### +.ifndef __initialized__ +__initialized__ := 1 + +.MAIN: all + +########### +.sinclude <mkc_imp.vars.mk> # .sinclude for bootstrapping + +#.if defined(MKC_SHELL) +#.SHELL: name=${MKC_SHELL} +#.elif ${OPSYS} == "SunOS" +#.SHELL: name=/usr/xpg4/bin/sh +#.endif + +########### + +.for p in ${PROGS} +SRCS.${p} ?= ${p}.c +SRCS.${p} += ${SRCS} # SRCS may be changed by mkc_imp.conf.mk +_srcsall += ${SRCS.${p}} +.endfor + +.if defined(PROG) +PROGS ?= ${PROG} +SRCS ?= ${PROG}.c +SRCS.${PROG} ?= ${SRCS} +_srcsall += ${SRCS} +.elif ${.CURDIR:T} == ${COMPATLIB:U} +SRCS ?= ${FEATURESDIR}/_mkcfake.c +_srcsall += ${SRCS} +.elif defined(LIB) +SRCS ?= ${LIB}.c +_srcsall += ${SRCS} +.endif # defined(PROG) + +.if !empty(_srcsall:U:M*.cxx) || !empty(_srcsall:U:M*.cpp) || !empty(_srcsall:U:M*.C) || !empty(_srcsall:U:M*.cc) +src_type += cxx +LDREAL ?= ${CXX} +.elif !empty(_srcsall:U:M*.pas) || !empty(_srcsall:U:M*.p) +src_type += pas +LDREAL ?= ${PC} +.endif + +.if !empty(_srcsall:U:M*.c) || !empty(_srcsall:U:M*.l) || !empty(_srcsall:U:M*.y) || defined(MKC_SOURCE_FUNCLIBS) +src_type += c +.endif + +src_type ?= 0 + +LDREAL ?= ${CC} + +.if defined(PROGS) +LDREAL ?= ${CC} +.else +LDREAL ?= ${LD} +.endif + +MKC_CACHEDIR ?= ${.OBJDIR} # directory for cache and intermediate files + +init_make_level ?= 0 # for mkc_imp.conf.mk + +.if ${.MAKE.LEVEL} == ${init_make_level} +SRCTOP ?= ${.CURDIR} +OBJTOP ?= ${.OBJDIR} +.export SRCTOP OBJTOP +.endif + +########### +.if exists(${SRCTOP}/Makefile.common) +.include "${SRCTOP}/Makefile.common" +.endif + +.if ${SRCTOP:U} != ${.CURDIR} && exists(${.CURDIR}/../Makefile.inc) +.include "${.CURDIR}/../Makefile.inc" +.endif + +########### + +PROJECTNAME ?= ${!empty(PROG):?${PROG}:${!empty(LIB):?${LIB}:${.CURDIR:T}}} + +.if defined(MAKECONF) && exists(${MAKECONF}) +.include "${MAKECONF}" +.elif defined(MKC_SYSCONFDIR) && exists(${MKC_SYSCONFDIR}/mk-c.conf) +.include "${MKC_SYSCONFDIR}/mk-c.conf" +.elif defined(MKC_SYSCONFDIR) && exists(${MKC_SYSCONFDIR}/mk.conf) +.include "${MKC_SYSCONFDIR}/mk.conf" +.endif + +.if ${OPSYS:Ux} == "SunOS" +_MKC_USER != /usr/xpg4/bin/id -un +_MKC_GROUP != /usr/xpg4/bin/id -gn +.else +_MKC_USER != id -un +_MKC_GROUP != id -gn +.endif + +.if ${_MKC_USER} != root && ${OPSYS}${_MKC_USER} != "InterixAdministrator" +ROOT_USER ?= ${_MKC_USER} +ROOT_GROUP ?= ${_MKC_GROUP} +.endif + +# Define MANZ to have the man pages compressed (gzip) +#MANZ= 1 + +PREFIX ?= /usr/local + +BINDIR ?= ${PREFIX}/bin +SBINDIR ?= ${PREFIX}/sbin +FILESDIR ?= ${PREFIX}/bin +LIBEXECDIR ?= ${PREFIX}/libexec +INCSDIR ?= ${PREFIX}/include +DATADIR ?= ${PREFIX}/share +SHAREDSTATEDIR ?= ${PREFIX}/com +VARDIR ?= ${PREFIX}/var +SYSCONFDIR ?= ${PREFIX}/etc +INFODIR ?= ${PREFIX}/info +MANDIR ?= ${PREFIX}/man +LIBDIR ?= ${PREFIX}/lib +SCRIPTSDIR ?= ${BINDIR} + +DOCDIR? = ${DATADIR}/doc +HTMLDOCDIR ?= ${DOCDIR}/html +HTMLDIR ?= ${MANDIR} + +BINGRP ?= ${ROOT_GROUP} +BINOWN ?= ${ROOT_USER} + +SHLIBMODE.HP-UX = ${BINMODE} +SHLIBMODE.OSF1 = ${BINMODE} +SHLIBMODE.Interix = ${BINMODE} +SHLIBMODE ?= ${SHLIBMODE.${TARGET_OPSYS}:U${NONBINMODE}} + +ROOT_GROUP.NetBSD = wheel +ROOT_GROUP.OpenBSD = wheel +ROOT_GROUP.FreeBSD = wheel +ROOT_GROUP.Darwin = wheel +ROOT_GROUP.DragonFly = wheel +ROOT_GROUP.MirBSD = wheel +ROOT_GROUP.HP-UX = bin +ROOT_GROUP.OSF1 = bin +ROOT_GROUP.Interix = +Administrators +ROOR_GROUP.Haiku = root + +ROOT_USER.HP-UX = bin +ROOT_USER.OSF1 = bin +ROOT_USER.Interix = Administrator +ROOT_USER.Haiku = user + +ROOT_USER ?= ${ROOT_USER.${OPSYS}:Uroot} +ROOT_GROUP ?= ${ROOT_GROUP.${OPSYS}:Uroot} + +BINMODE.Interix.Administrator = 775 +NONBINMODE.Interix.Administrator = 664 + +BINMODE ?= ${BINMODE.${TARGET_OPSYS}.${ROOT_USER}:U755} +NONBINMODE ?= ${BINMODE.${TARGET_OPSYS}.${ROOT_USER}:U644} +DIRMODE ?= ${BINMODE} + +MANGRP ?= ${ROOT_GROUP} +MANOWN ?= ${ROOT_USER} +MANMODE ?= ${NONBINMODE} +MANINSTALL ?= maninstall catinstall + +INFOGRP ?= ${ROOT_GROUP} +INFOOWN ?= ${ROOT_USER} +INFOMODE ?= ${NONBINMODE} + +LIBGRP ?= ${BINGRP} +LIBOWN ?= ${BINOWN} +LIBMODE ?= ${NONBINMODE} + +DOCGRP ?= ${ROOT_GROUP} +DOCOWN ?= ${ROOT_USER} +DOCMODE ?= ${NONBINMODE} + +FILESOWN ?= ${BINOWN} +FILESGRP ?= ${BINGRP} +FILESMODE ?= ${NONBINMODE} + +SCRIPTSOWN ?= ${BINOWN} +SCRIPTSGRP ?= ${BINGRP} +SCRIPTSMODE ?= ${BINMODE} + +COPY ?= -c +PRESERVE ?= +STRIPFLAG ?= -s + +MKINSTALL ?= yes + +MKCATPAGES ?= no +MKHTML ?= no +MKDOC ?= yes +MKINFO ?= yes +MKMAN ?= yes +MKSHARE ?= yes + +# +# MKOBJDIRS controls whether object dirs are created during "make all" or "make obj". +# +MKOBJDIRS ?= auto +MKRELOBJDIR ?= no + +MKPIE ?= no +USE_SSP ?= no +USE_RELRO ?= no +USE_FORT ?= no + +MKDLL ?= no +.if ${MKDLL:tl} == "only" +MKDLL = yes +MKSTATICLIB ?= no +.else +MKSTATICLIB ?= yes +.endif # MKDLL + +SHLIB_MINOR ?= 0 +.if ${MKDLL:tl} != "no" +SHLIB_MAJOR ?= 1 +.endif # MKDLL + +INTERNALLIBS += ${COMPATLIB} +STATICLIBS += ${INTERNALLIBS} + +.if defined(SHLIB_MAJOR) && empty(STATICLIBS:M${.CURDIR:T}) +MKSHLIB ?= yes +.else +MKSHLIB ?= no +.endif # SHLIB_MAJOR + +.if !empty(STATICLIBS:M${.CURDIR:T}) +MKPICLIB ?= yes +.else +MKPICLIB ?= no +.endif + +MKPROFILELIB ?= no + +MKINSTALLDIRS ?= yes + +EXPORT_VARNAMES += MKC_CACHEDIR TARGETS SHORTPRJNAME + +EXPORT_DYNAMIC ?= no + +DISTCLEANFILES += ${MKC_CACHEDIR}/_mkc_* + +.include <mkc_imp.platform.sys.mk> + +###### +.if ${MKPIE:U:tl} == "yes" +LDFLAGS.prog += ${LDFLAGS.pie} +_CFLAGS.pie += ${CFLAGS.pie} +_CXXFLAGS.pie += ${CXXFLAGS.pie} +.endif + +.if ${USE_SSP:U:tl} == "yes" +_CFLAGS.ssp = ${CFLAGS.ssp} +_CXXFLAGS.ssp = ${CXXFLAGS.ssp} +.endif + +.if ${USE_RELRO:U:tl} == "yes" +LDFLAGS.prog += ${LDFLAGS.relro} +.endif + +.if ${USE_FORT:U:tl} == "yes" +CPPFLAGS += -D_FORTIFY_SOURCE=2 +CFLAGS += -O +.endif + +SHRTOUT ?= no + +.if ${SHRTOUT:tl} != "no" +_MESSAGE ?= echo +_MESSAGE_V ?= : +_V ?= @ +.else +_MESSAGE ?= : +_MESSAGE_V ?= echo +_V ?= +.endif + +AR ?= ar +ARFLAGS ?= rl +RANLIB ?= ranlib +MESSAGE.ar ?= @${_MESSAGE} "AR: ${.TARGET}" + +AS ?= as +AFLAGS ?= +COMPILE.s ?= ${_V} ${CC_PREFIX} ${CC} ${AFLAGS} -c +MESSAGE.s ?= @${_MESSAGE} "AS: ${.IMPSRC}" + +CC ?= cc +CFLAGS ?= +COMPILE.c ?= ${_V} ${CC_PREFIX} ${CC} ${CFLAGS} ${_CPPFLAGS} ${_CFLAGS.ssp} ${_CFLAGS.pie} ${CFLAGS.warns} -c +MESSAGE.c ?= @${_MESSAGE} "CC: ${.IMPSRC}" + +CXX ?= c++ +CXXFLAGS += ${CFLAGS} +COMPILE.cc ?= ${_V} ${CXX_PREFIX} ${CXX} ${CXXFLAGS} ${_CPPFLAGS} ${_CXXFLAGS.ssp} ${_CXXFLAGS.pie} ${CXXFLAGS.warns} -c +MESSAGE.cc ?= @${_MESSAGE} "CXX: ${.IMPSRC}" + +OBJC ?= ${CC} +OBJCFLAGS ?= ${CFLAGS} +COMPILE.m ?= ${_V} ${OBJC} ${OBJCFLAGS} ${_CPPFLAGS} -c +MESSAGE.m ?= @${_MESSAGE} "OBJC: ${.IMPSRC}" + +CPP ?= cpp +CPPFLAGS ?= + +_CPPFLAGS = ${CPPFLAGS0} ${CPPFLAGS} + +FC ?= f77 +FFLAGS ?= -O +RFLAGS ?= +COMPILE.f ?= ${_V} ${FC} ${FFLAGS} -c +MESSAGE.f ?= @${_MESSAGE} "FC: ${.IMPSRC}" +COMPILE.F ?= ${_V} ${FC} ${FFLAGS} ${_CPPFLAGS} -c +MESSAGE.F ?= ${MESSAGE.f} +COMPILE.r ?= ${_V} ${FC} ${FFLAGS} ${RFLAGS} -c +MESSAGE.r ?= ${MESSAGE.f} + +MESSAGE.ld ?= @${_MESSAGE} "LD: ${.TARGET}" + +CLEANFILES_CMD ?= ${RM} -f +CLEANDIRS_CMD ?= ${RM} -rf + +INSTALL ?= install +UNINSTALL ?= ${RM} -f + +LEX ?= lex +LFLAGS ?= +LEX.l ?= ${_V} ${LEX} ${LFLAGS} +MESSAGE.l ?= @${_MESSAGE} "LEX: ${.IMPSRC}" + +LD.SunOS ?= /usr/ccs/bin/ld +LD.OSF1 ?= /usr/bin/ld +LD ?= ${LD.${TARGET_OPSYS}:Uld} +LDFLAGS ?= + +.if ${OPSYS} == "Haiku" +LN ?= ln -s +LN_S ?= ln -s +.else +LN ?= ln +LN_S ?= ${LN} -s +.endif + +LORDER ?= lorder + +NM ?= nm + +MKDIR ?= mkdir + +PC ?= pc +PFLAGS ?= +COMPILE.p ?= ${_V} ${PC} ${PFLAGS} ${_CPPFLAGS} -c +MESSAGE.p ?= @${_MESSAGE} "PC: ${.IMPSRC}" + +SHELL ?= sh + +SIZE ?= size + +TSORT ?= tsort -q + +YACC ?= yacc +YFLAGS ?= +YACC.y ?= ${_V} ${YACC} ${YFLAGS} +MESSAGE.y ?= @${_MESSAGE} "YACC: ${.IMPSRC}" + +MESSAGE.mkgen ?= @${_MESSAGE} "MKGEN:" + +TAR ?= tar +GZIP ?= gzip +BZIP2 ?= bzip2 +ZIP ?= zip + +OBJCOPY ?= objcopy + +OBJDUMP ?= objdump + +STRIP ?= strip + +RM ?= rm + +#ADDR2LINE ?= addr2line +#READELF ?= readelf +#STRINGS ?= strings + +_PN = ${PROJECTNAME} # short synonym +# Lex +LPREFIX ?= yy +.if ${LPREFIX} != "yy" +LFLAGS += -P${LPREFIX} +.endif +LEXLIB ?= -ll + +# Yacc +YFLAGS += ${YPREFIX:D-p${YPREFIX}} ${YHEADER:D-d} + +########### + +.if defined(MKC_REQD) && defined(MKC_VERSION) +_mkc_version_ok != mkc_check_version ${MKC_REQD} ${MKC_VERSION} +.if !${_mkc_version_ok} +MKC_ERR_MSG += "ERROR: We need mk-configure v.${MKC_REQD} while ${MKC_VERSION} is detected" +MKCHECKS = no +.endif +.endif + +########### + +TARGETS += all install clean cleandir depend test \ + installdirs uninstall errorcheck filelist obj mkgen +TARGETS := ${TARGETS:O:u} + +ALLTARGETS += errorcheck all install clean cleandir depend uninstall installdirs \ + mkgen bin_tar bin_targz bin_tarbz2 bin_zip bin_deb + +VERBOSE_ECHO ?= echo + +.endif # __initialized__ diff --git a/mk/mkc.lib.mk b/mk/mkc.lib.mk new file mode 100644 index 0000000..299adb6 --- /dev/null +++ b/mk/mkc.lib.mk @@ -0,0 +1,2 @@ +_top_mk := mkc.lib.mk +.include <mkc.mk> diff --git a/mk/mkc.minitest.mk b/mk/mkc.minitest.mk new file mode 100644 index 0000000..168073f --- /dev/null +++ b/mk/mkc.minitest.mk @@ -0,0 +1,27 @@ +# Copyright (c) 2009-2013 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +TEST_PREREQS ?= all + +_tmp_out:=${.OBJDIR}/${.CURDIR:T}.test.out + +.PHONY : test +test: ${TEST_PREREQS} + @echo 'Testing ${.CURDIR}... ' 1>&2; \ + set -e; cd ${.CURDIR}; \ + ${RM} -f ${_tmp_out}; \ + ${MAKE} ${MAKEFLAGS} test_output > ${_tmp_out}.tmp; \ + mv ${_tmp_out}.tmp ${_tmp_out}; \ + if test -f ${.CURDIR}/expect.${OPSYS}.out; then \ + expect=${.CURDIR}/expect.${OPSYS}.out; \ + else \ + expect=${.CURDIR}/expect.out; \ + fi; \ + diff $$expect ${_tmp_out} && \ + echo ' succeeded' 1>&2 || \ + { echo ' FAILED' 1>&2; false; } + +CLEANFILES += ${.OBJDIR}/${.CURDIR:T}.test.out +#DISTCLEANFILES+= ${.OBJDIR}/${.CURDIR:T}.test.out.tmp diff --git a/mk/mkc.mk b/mk/mkc.mk new file mode 100644 index 0000000..3528e5a --- /dev/null +++ b/mk/mkc.mk @@ -0,0 +1,21 @@ +# Copyright (c) 2013 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +.ifndef _MKC_MK +_MKC_MK := 1 + +init_make_level ?= 0 + +.if defined(SRCTOP) && ${SRCTOP:U} != ${.CURDIR} && ${.MAKE.LEVEL} == ${init_make_level} +MKC_CACHEDIR ?= ${SRCTOP} +.export MKC_CACHEDIR +.MAIN: all +.DEFAULT: + @set -e; cd ${SRCTOP}; ${MAKE} ${MAKEFLAGS} ${.TARGET}-${.CURDIR:S,${SRCTOP}/,,} +.else +.include <mkc_imp.mk> +.endif #SRCTOP + +.endif # _MKC_MK diff --git a/mk/mkc.prog.mk b/mk/mkc.prog.mk new file mode 100644 index 0000000..ee33237 --- /dev/null +++ b/mk/mkc.prog.mk @@ -0,0 +1,2 @@ +_top_mk := mkc.prog.mk +.include <mkc.mk> diff --git a/mk/mkc.subdir.mk b/mk/mkc.subdir.mk new file mode 100644 index 0000000..d13879d --- /dev/null +++ b/mk/mkc.subdir.mk @@ -0,0 +1,2 @@ +_top_mk := mkc.subdir.mk +.include <mkc.mk> diff --git a/mk/mkc.subprj.mk b/mk/mkc.subprj.mk new file mode 100644 index 0000000..ef6e0b2 --- /dev/null +++ b/mk/mkc.subprj.mk @@ -0,0 +1,2 @@ +_top_mk := mkc.subprj.mk +.include <mkc.mk> diff --git a/mk/mkc_imp.arch.mk b/mk/mkc_imp.arch.mk new file mode 100644 index 0000000..30554ad --- /dev/null +++ b/mk/mkc_imp.arch.mk @@ -0,0 +1,36 @@ +# Copyright (c) 2010-2014 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +.ifndef _MKC_IMP_ARCH_MK +_MKC_IMP_ARCH_MK := 1 + +rnd != echo $$$$ +destdir = ${TMPDIR:U/tmp}/mkc.${rnd} +basefile = ${.CURDIR}/${PROJECTNAME} + +bin_cleanup: .PHONY + set -e; ${RM} -rf ${destdir}; ${MKDIR} -m 0700 ${destdir}; \ + ${MAKE} ${MAKEFLAGS} all install DESTDIR=${destdir} + +realdo_bin_tar: bin_cleanup + set -e; ${RM} -f ${basefile}.tar; cd ${destdir}; \ + ${TAR} -cf ${basefile}.tar .; cd /; ${RM} -rf ${destdir} + +realdo_bin_targz: bin_tar + ${GZIP} ${basefile}.tar + +realdo_bin_tarbz2: bin_tar + ${BZIP2} ${basefile}.tar + +realdo_bin_zip: bin_cleanup + set -e; ${RM} -f ${basefile}.zip; cd ${destdir}; \ + ${ZIP} -r ${basefile}.zip .; ${RM} -rf ${destdir} + +realdo_bin_deb: DEBIAN/control bin_cleanup + set -e; cp -rp DEBIAN ${destdir}; ${RM} -rf ${destdir}/DEBIAN/CVS; \ + dpkg-deb -b ${destdir} ${.CURDIR:T:S/_/-/g}.deb; \ + ${RM} -rf ${destdir} + +.endif # _MKC_IMP_ARCH_MK diff --git a/mk/mkc_imp.checkprogs.mk b/mk/mkc_imp.checkprogs.mk new file mode 100644 index 0000000..da5c168 --- /dev/null +++ b/mk/mkc_imp.checkprogs.mk @@ -0,0 +1,29 @@ +.if !empty(_srcsall:U:M*.y) && !empty(YACC) +MKC_REQUIRE_PROGS += ${YACC:[1]} +MKC_PROG.id.${YACC:[1]:S/+/x/g} = yacc +.endif + +.if !empty(_srcsall:U:M*.l) && !empty(LEX) +MKC_REQUIRE_PROGS += ${LEX:[1]} +MKC_PROG.id.${LEX:[1]:S/+/x/g} = lex +.endif + +.if !empty(_srcsall:U:M*.c) || !empty(_srcsall:U:M*.l) || !empty(_srcsall:U:M*.y) && !empty(CC) +MKC_REQUIRE_PROGS += ${CC:[1]} +MKC_PROG.id.${CC:[1]:S|+|x|g} = cc +.endif + +.if !empty(_srcsall:U:M*.cc) || !empty(_srcsall:U:M*.C) || !empty(_srcsall:U:M*.cxx) || !empty(_srcsall:U:M*.cpp) && !empty(CXX) +MKC_REQUIRE_PROGS += ${CXX:[1]} +MKC_PROG.id.${CXX:[1]:S/+/x/g} = cxx +.endif + +.if !empty(_srcsall:U:M*.f) && !empty(FC) +MKC_REQUIRE_PROGS += ${FC:[1]} +MKC_PROG.id.${FC:[1]:S/+/x/g} = fc +.endif + +.if !empty(_srcsall:U:M*.p) && !empty(PC) +MKC_REQUIRE_PROGS += ${PC:[1]} +MKC_PROG.id.${PC:[1]:S/+/x/g} = pc +.endif diff --git a/mk/mkc_imp.conf-cleanup.mk b/mk/mkc_imp.conf-cleanup.mk new file mode 100644 index 0000000..0a341f1 --- /dev/null +++ b/mk/mkc_imp.conf-cleanup.mk @@ -0,0 +1,9 @@ +# Copyright (c) 2014 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +.include <mkc_imp.conf.mk> + +.undef MKC_NOAUTO +.undef MKC_NOSRCSAUTO diff --git a/mk/mkc_imp.conf-final.mk b/mk/mkc_imp.conf-final.mk new file mode 100644 index 0000000..947034e --- /dev/null +++ b/mk/mkc_imp.conf-final.mk @@ -0,0 +1,51 @@ +# Copyright (c) 2014, Aleksey Cheusov <vle@gmx.net> +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +# MKC_AUTO_* variables are for debugging purposes only +MKC_AUTO_CPPFLAGS := ${MKC_AUTO_CPPFLAGS} ${MKC_CPPFLAGS} +MKC_AUTO_CFLAGS := ${MKC_AUTO_CFLAGS} ${MKC_CFLAGS} +MKC_AUTO_LDADD := ${MKC_AUTO_LDADD} ${MKC_LDADD} +MKC_AUTO_SRCS := ${MKC_AUTO_SRCS} ${MKC_SRCS} + +.if !${MKC_NOAUTO:U0} +.for i in ${MKC_CPPFLAGS} +CPPFLAGS += ${i} +.endfor +.for i in ${MKC_CFLAGS} +CFLAGS += ${i} +.endfor +.for i in ${MKC_LDADD} +LDADD += ${i} +.endfor +.if !${MKC_NOSRCSAUTO:U0} +. for i in ${MKC_SRCS} +SRCS += ${i} +. endfor +.endif +.endif # .if MKC_AUTO + +.undef MKC_CPPFLAGS +.undef MKC_CFLAGS +.undef MKC_LDADD +.undef MKC_SRCS diff --git a/mk/mkc_imp.conf.mk b/mk/mkc_imp.conf.mk new file mode 100644 index 0000000..b103834 --- /dev/null +++ b/mk/mkc_imp.conf.mk @@ -0,0 +1,360 @@ +# Copyright (c) 2009-2014, Aleksey Cheusov <vle@gmx.net> +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +###################################################################### +# See mk-configure(7) for documentation +# + +# user defined variables +MKC_SHOW_CACHED ?= 0 # set it to `1' to show "...(cached)..." lines +MKC_DELETE_TMPFILES ?= 0 # set it to `1' to delete temporary files +MKC_CACHEDIR ?= ${.OBJDIR} # directory for cache and intermediate files +MKC_COMMON_HEADERS ?= # list of headers always #included +MKC_NOCACHE ?= # 1 or yes for disabling cache +MKC_CUSTOM_DIR ?=${.CURDIR} # directory with custom tests.c +MKC_SOURCE_DIR ?=${.CURDIR} # directory with missing strlcat.c etc. +.if ${COMPATLIB:U} == ${.CURDIR:T} +MKC_NOSRCSAUTO ?= 1 +.else +MKC_NOSRCSAUTO ?= 0 +.endif + +# +MKC_SOURCE_FUNCLIBS ?= +_MKC_SOURCE_FUNCS = ${MKC_SOURCE_FUNCLIBS:C/:.*//} + +# .endif for the next .if is in the end of file +.if ${MKCHECKS:Uno:tl} == "yes" + +HAVE_FUNCLIB.main ?= 1 + +.if defined(MKC_COMMON_DEFINES.${TARGET_OPSYS}) +CPPFLAGS += ${MKC_COMMON_DEFINES.${TARGET_OPSYS}} +.endif +.if defined(MKC_COMMON_DEFINES) +CPPFLAGS += ${MKC_COMMON_DEFINES} +.endif + +# +_MKC_CPPFLAGS := ${CPPFLAGS} +_MKC_CFLAGS := ${CFLAGS} +_MKC_CXXFLAGS := ${CXXFLAGS} +_MKC_FFLAGS := ${FFLAGS} +_MKC_LDFLAGS := ${LDFLAGS} +_MKC_LDADD := ${LDADD} + +mkc.environ=CC='${CC}' CXX='${CXX}' FC='${FC}' CPPFLAGS='${_MKC_CPPFLAGS}' CFLAGS='${_MKC_CFLAGS}' CXXFLAGS='${_MKC_CXXFLAGS}' FFLAGS='${_MKC_FFLAGS}' LDFLAGS='${_MKC_LDFLAGS}' LDADD='${_MKC_LDADD}' LEX='${LEX}' YACC='${YACC}' MKC_CACHEDIR='${MKC_CACHEDIR}' MKC_COMMON_HEADERS='${MKC_COMMON_HEADERS}' MKC_DELETE_TMPFILES='${MKC_DELETE_TMPFILES}' MKC_SHOW_CACHED='${MKC_SHOW_CACHED}' MKC_NOCACHE='${MKC_NOCACHE}' MKC_VERBOSE=1 + +###################################################### +# checking for builtin checks +.for i in ${MKC_CHECK_BUILTINS} ${MKC_REQUIRE_BUILTINS} +MKC_CUSTOM_FN.${i} ?= ${BUILTINSDIR}/${i:S/endianess/endianness/} +MKC_CHECK_CUSTOM += ${i} +MKC_REQUIRE_CUSTOM += ${MKC_REQUIRE_BUILTINS:M${i}} +.endfor + +###################################################### +# checking for headers +.for h in ${MKC_CHECK_HEADERS} ${MKC_REQUIRE_HEADERS} +.if !defined(HAVE_HEADER.${h:S|.|_|g:S|/|_|g}) +HAVE_HEADER.${h:S|.|_|g:S|/|_|g} != env ${mkc.environ} mkc_check_header ${h} +.endif +.if ${HAVE_HEADER.${h:S|.|_|g:S|/|_|g}} +.if empty(MKC_REQUIRE_HEADERS:U:M${h}) +MKC_CFLAGS += -DHAVE_HEADER_${h:tu:S|.|_|g:S|/|_|g}=${HAVE_HEADER.${h:S|.|_|g:S|/|_|g}} +.endif +.elif !empty(MKC_REQUIRE_HEADERS:U:M${h}) +_fake != env ${mkc.environ} mkc_check_header -d ${h} && echo +MKC_ERR_MSG += "ERROR: cannot find header ${h}" +.endif +.endfor + +.undef MKC_CHECK_HEADERS +.undef MKC_REQUIRE_HEADERS + +###################################################### +# checking for functions in libraries +.for f in ${MKC_CHECK_FUNCLIBS:U} ${MKC_SOURCE_FUNCLIBS:U} ${MKC_REQUIRE_FUNCLIBS:U} +.if !defined(HAVE_FUNCLIB.${f:S/:/./g}) +HAVE_FUNCLIB.${f:S/:/./g} != env ${mkc.environ} mkc_check_funclib ${f:S/:/ /g} +.endif +.if !defined(HAVE_FUNCLIB.${f:C/:.*//}) +HAVE_FUNCLIB.${f:C/:.*//} != env ${mkc.environ} mkc_check_funclib ${f:C/:.*//} +.endif +.if ${HAVE_FUNCLIB.${f:C/:.*//}} != ${HAVE_FUNCLIB.${f:S/:/./g}} +.if empty(MKC_NOAUTO_FUNCLIBS:U:S/:/./g:M${f:S/:/./g}) && empty(MKC_NOAUTO_FUNCLIBS:U:M1) && ${HAVE_FUNCLIB.${f:S/:/./g}} && !${HAVE_FUNCLIB.${f:C/:.*//}} +MKC_LDADD += -l${f:C/^.*://} +.endif +.endif +.if !${HAVE_FUNCLIB.${f:S/:/./g}} && !${HAVE_FUNCLIB.${f:C/:.*//}} && !empty(_MKC_SOURCE_FUNCS:M${f:C/:.*//}) +MKC_SRCS += ${MKC_SOURCE_DIR.${f:C/:.*//}.c:U${MKC_SOURCE_DIR}}/${f:C/:.*//}.c +.endif +.endfor # f + +.for f in ${MKC_REQUIRE_FUNCLIBS:U} +.if !${HAVE_FUNCLIB.${f:S/:/./g}} && !${HAVE_FUNCLIB.${f:C/:.*//}} +_fake != env ${mkc.environ} mkc_check_funclib -d ${f:C/:.*//} && echo +_fake != env ${mkc.environ} mkc_check_funclib -d ${f:S/:/ /g} && echo +MKC_ERR_MSG += "ERROR: cannot find function ${f}" +.endif +.endfor # f + +.undef MKC_CHECK_FUNCLIBS +.undef MKC_REQUIRE_FUNCLIBS + +###################################################### +# checking for sizeof(xxx) +.for t in ${MKC_CHECK_SIZEOF:U} +.if !defined(SIZEOF.${t:S|.|_|g:S|-|_|g:S|*|P|g:S|/|_|g:S|:|.|g}) +SIZEOF.${t:S|.|_|g:S|-|_|g:S|*|P|g:S|/|_|g:S|:|.|g} != env ${mkc.environ} mkc_check_sizeof ${t:S/:/ /g} +.endif +.if ${SIZEOF.${t:S|.|_|g:S|-|_|g:S|*|P|g:S|/|_|g:S|:|.|g}} != failed +MKC_CFLAGS += -DSIZEOF_${t:S/-/_/g:S| |_|g:S|*|P|g:S|:|_|g:S|.|_|g:tu}=${SIZEOF.${t:S|.|_|g:S|-|_|g:S|*|P|g:S|/|_|g:S|:|.|g}} +.endif +.endfor + +.undef MKC_CHECK_SIZEOF + +###################################################### +# checking for declared #define +.for d in ${MKC_CHECK_DEFINES:U} ${MKC_REQUIRE_DEFINES:U} +.if !defined(HAVE_DEFINE.${d:S/./_/g:S/:/./g:S|/|_|g}) +HAVE_DEFINE.${d:S/./_/g:S/:/./g:S|/|_|g} != env ${mkc.environ} mkc_check_decl define ${d:S/:/ /g} +.endif +.if ${HAVE_DEFINE.${d:S/./_/g:S/:/./g:S|/|_|g}} +.if empty(MKC_REQUIRE_DEFINES:U:M${d}) +MKC_CFLAGS += -DHAVE_DEFINE_${d:tu:S/:/_/g:S/./_/g:S|/|_|g}=1 +.endif +.endif +.endfor + +.for d in ${MKC_REQUIRE_DEFINES:U} +.if !${HAVE_DEFINE.${d:S/./_/g:S/:/./g:S|/|_|g}} +_fake != env ${mkc.environ} mkc_check_decl -d define ${d:S/:/ /g} && echo +MKC_ERR_MSG += "ERROR: cannot find declaration of define ${d}" +.endif +.endfor + +.undef MKC_CHECK_DEFINES +.undef MKC_REQUIRE_DEFINES + +###################################################### +# checking for declared type +.for t in ${MKC_CHECK_TYPES:U} ${MKC_REQUIRE_TYPES:U} +.if !defined(HAVE_TYPE.${t:S/./_/g:S/:/./g:S|/|_|g}) +HAVE_TYPE.${t:S/./_/g:S/:/./g:S|/|_|g} != env ${mkc.environ} mkc_check_decl type ${t:S/:/ /g} +.endif +.if ${HAVE_TYPE.${t:S/./_/g:S/:/./g:S|/|_|g}} +.if empty(MKC_REQUIRE_TYPES:U:M${t}) +MKC_CFLAGS += -DHAVE_TYPE_${t:tu:S/:/_/g:S/./_/g:S|/|_|g}=1 +.endif +.endif +.endfor + +.for t in ${MKC_REQUIRE_TYPES:U} +.if !${HAVE_TYPE.${t:S/./_/g:S/:/./g:S|/|_|g}} +_fake != env ${mkc.environ} mkc_check_decl -d type ${t:S/:/ /g} && echo +MKC_ERR_MSG += "ERROR: cannot find declaration of type ${t}" +.endif +.endfor + +.undef MKC_CHECK_TYPES +.undef MKC_REQUIRE_TYPES + +###################################################### +# checking for declared variables +.for d in ${MKC_CHECK_VARS:U} ${MKC_REQUIRE_VARS:U} +.if !defined(HAVE_VAR.${d:S/./_/g:S/:/./g:S|/|_|g}) +HAVE_VAR.${d:S/./_/g:S/:/./g:S|/|_|g} != env ${mkc.environ} mkc_check_decl variable ${d:S/:/ /g} +.endif +.if ${HAVE_VAR.${d:S/./_/g:S/:/./g:S|/|_|g}} +.if empty(MKC_REQUIRE_VARS:U:M${d}) +MKC_CFLAGS += -DHAVE_VAR_${d:tu:S/:/_/g:S/./_/g:S|/|_|g}=1 +.endif +.endif +.endfor + +.for d in ${MKC_REQUIRE_VARS:U} +.if !${HAVE_VAR.${d:S/./_/g:S/:/./g:S|/|_|g}} +_fake != env ${mkc.environ} mkc_check_decl -d variable ${d:S/:/ /g} && echo +MKC_ERR_MSG += "ERROR: cannot find declaration of variable ${d}" +.endif +.endfor + +.undef MKC_CHECK_VARS +.undef MKC_REQUIRE_VARS + +###################################################### +# checking for struct members +.for m in ${MKC_CHECK_MEMBERS:U} ${MKC_REQUIRE_MEMBERS:U} +.if !defined(HAVE_MEMBER.${m:S/./_/g:S/:/./g:S|/|_|g:S/-/_/g}) +HAVE_MEMBER.${m:S/./_/g:S/:/./g:S|/|_|g:S/-/_/g} != env ${mkc.environ} mkc_check_decl member ${m:S/:/ /g} +.endif +.if ${HAVE_MEMBER.${m:S/./_/g:S/:/./g:S|/|_|g:S/-/_/g}} +.if empty(MKC_REQUIRE_MEMBERS:U:M${m}) +MKC_CFLAGS += -DHAVE_MEMBER_${m:tu:S/:/_/g:S/./_/g:S|/|_|g:S/-/_/g}=1 +.endif +.endif +.endfor + +.for m in ${MKC_REQUIRE_MEMBERS:U} +.if !${HAVE_MEMBER.${m:S/./_/g:S/:/./g:S|/|_|g:S/-/_/g}} +_fake != env ${mkc.environ} mkc_check_decl -d member ${m:S/:/ /g} && echo +MKC_ERR_MSG += "ERROR: cannot find member ${m}" +.endif +.endfor + +.undef MKC_CHECK_MEMBERS +.undef MKC_REQUIRE_MEMBERS + +###################################################### +# checking for declared functions +.for n in 0 1 2 3 4 5 6 7 8 9 + +.for d in ${MKC_CHECK_FUNCS${n}:U} ${MKC_REQUIRE_FUNCS${n}:U} +.if !defined(HAVE_FUNC${n}.${d:S/./_/g:S/:/./g:S|/|_|g}) +HAVE_FUNC${n}.${d:S/./_/g:S/:/./g:S|/|_|g} != env ${mkc.environ} mkc_check_decl func${n} ${d:S/:/ /g} +.endif +.if ${HAVE_FUNC${n}.${d:S/./_/g:S/:/./g:S|/|_|g}} +.if empty(MKC_REQUIRE_FUNCS${n}:U:M${d}) +MKC_CFLAGS += -DHAVE_FUNC${n}_${d:tu:S/:/_/g:S/./_/g:S|/|_|g}=1 +.endif +.endif +.endfor # d + +.for d in ${MKC_REQUIRE_FUNCS${n}:U} +.if !${HAVE_FUNC${n}.${d:S/./_/g:S/:/./g:S|/|_|g}} +_fake != env ${mkc.environ} mkc_check_decl -d func${n} ${d:S/:/ /g} && echo +MKC_ERR_MSG += "ERROR: cannot find declaration of function ${d}" +.endif +.endfor # d + +MKC_CHECK_FUNCS${n} := # workaround for buggy bmake-20110606 +MKC_REQUIRE_FUNCS${n} := # workaround for buggy bmake-20110606 + +.undef MKC_CHECK_FUNCS${n} +.undef MKC_REQUIRE_FUNCS${n} + +.endfor # n + +###################################################### +# custom checks +.for c in ${MKC_CHECK_CUSTOM} ${MKC_REQUIRE_CUSTOM} +.if !defined(CUSTOM.${c}) +.if !defined(MKC_CUSTOM_FN.${c}) +MKC_CUSTOM_FN.${c} = ${c}.c +.endif +.if empty(MKC_CUSTOM_FN.${c}:M/*) +MKC_CUSTOM_FN.${c} := ${MKC_CUSTOM_DIR}/${MKC_CUSTOM_FN.${c}} +.endif +.if ${c} == "endianess" +.warning "endianess test deprecated; use endianness instead" +.endif +CUSTOM.${c} != env ${mkc.environ} mkc_check_custom ${MKC_CUSTOM_FN.${c}} +.endif +.if !empty(CUSTOM.${c}) && ${CUSTOM.${c}} != 0 +.if empty(MKC_REQUIRE_CUSTOM:U:M${c}) +MKC_CFLAGS += -DCUSTOM_${c:tu}=${CUSTOM.${c}} +.endif +.endif +.endfor + +.for c in ${MKC_REQUIRE_CUSTOM} +.if empty(CUSTOM.${c}) || ${CUSTOM.${c}} == 0 +_fake != env ${mkc.environ} mkc_check_custom -d ${MKC_CUSTOM_FN.${c}} && echo +MKC_ERR_MSG += "ERROR: custom test ${c} failed" +.endif +.endfor + +.for c in ${MKC_CHECK_BUILTINS} +BUILTIN.${c} = ${CUSTOM.${c}} +.endfor + +###################################################### +# checking for programs +.for p in ${MKC_CHECK_PROGS} ${MKC_REQUIRE_PROGS} +p_ := ${p} +prog_id := ${MKC_PROG.id.${p:S|+|x|g}:U${p}:S|/|_|g} +.ifdef PROG.${prog_id} +.elif !empty(p_:M/*) +PROG.${prog_id} = ${p} +.else +PROG.${prog_id} != env ${mkc.environ} mkc_check_prog -i '${prog_id}' '${p}' +.endif # !defined(PROG.${prog_id}) +.ifndef HAVE_PROG.${prog_id} +.if !empty(PROG.${prog_id}) && exists(${PROG.${prog_id}}) +HAVE_PROG.${prog_id} = 1 +.else +HAVE_PROG.${prog_id} = 0 +.endif +.endif # ifndef HAVE_PROG.${prog_id} + +.if !${HAVE_PROG.${prog_id}} && !empty(MKC_REQUIRE_PROGS:U1:M${p}) +_fake != env ${mkc.environ} mkc_check_prog -d -i '${prog_id}' '${p}' && echo +MKC_ERR_MSG += "ERROR: cannot find program ${p}" +.endif +.endfor # p + +.undef MKC_CHECK_PROGS +.undef MKC_REQUIRE_PROGS + +.undef MKC_CHECK_CUSTOM +.undef MKC_REQUIRE_CUSTOM + +###################################################### +# prototype checks +.for p in ${MKC_CHECK_PROTOTYPES} ${MKC_REQUIRE_PROTOTYPES} +.if !defined(HAVE_PROTOTYPE.${p}) +HAVE_PROTOTYPE.${p} != env ${mkc.environ} mkc_check_decl prototype \ + ${MKC_PROTOTYPE_FUNC.${p}:Q} ${MKC_PROTOTYPE_HEADERS.${p}} +.endif # !defined(HAVE_PROTOTYPE.${p}) +.if ${HAVE_PROTOTYPE.${p}} +MKC_CFLAGS += -DHAVE_PROTOTYPE_${p:tu}=1 +.elif !empty(MKC_REQUIRE_PROTOTYPES:U:M${p}) +_fake != env ${mkc.environ} mkc_check_decl -d prototype \ + ${MKC_PROTOTYPE_FUNC.${p}:Q} ${MKC_PROTOTYPE_HEADERS.${p}}; echo +MKC_ERR_MSG += "ERROR: prototype test ${p} failed" +.endif # ${PROTOTYPE.${p}} +.endfor # p + +.undef MKC_CHECK_PROTOTYPES +.undef MKC_REQUIRE_PROTOTYPES + +.else # MKCHECKS == yes + +.for i in ${_MKC_SOURCE_FUNCS} +MKC_SRCS += ${i} # for changing CLEANFILES +.endfor + +.endif # MKCHECKS? + +###################################################### +# final assignments +.include <mkc_imp.conf-final.mk> + +###################################################### +###################################################### +###################################################### + +.undef MKC_SOURCE_FUNCLIBS diff --git a/mk/mkc_imp.dep.mk b/mk/mkc_imp.dep.mk new file mode 100644 index 0000000..2a37767 --- /dev/null +++ b/mk/mkc_imp.dep.mk @@ -0,0 +1,95 @@ +# Copyright (c) 2010-1013 by Aleksey Cheusov +# Copyright (c) 1994-2009 The NetBSD Foundation, Inc. + +###################################################################### +.if !defined(_MKC_IMP_DEP_MK) && !empty(_SRCS_ALL) +_MKC_IMP_DEP_MK := 1 + +DISTCLEANFILES += .depend ${__DPSRCS.d} ${CLEANDEPEND} + +##### Basic targets +do_depend1 do_depend2: .PHONY # ensure existence +realdo_depend: do_depend1 .WAIT do_depend2 + +##### Default values +MKDEP ?= mkdep +MKDEP_SUFFIXES ?= .o .os .op +MKDEP_CC ?= ${CC} + +##### Build rules +# some of the rules involve .h sources, so remove them from mkdep line + +.if defined(_SRCS_ALL) +__DPSRCS.all = ${_SRCS_ALL:C/\.(c|m|s|S|C|cc|cpp|cxx)$/.d/} \ + ${DPSRCS:C/\.(c|m|s|S|C|cc|cpp|cxx)$/.d/} +__DPSRCS.d = ${__DPSRCS.all:O:u:M*.d} +__DPSRCS.notd = ${__DPSRCS.all:O:u:N*.d} + +do_depend1: ${DPSRCS} +do_depend2: .depend + +MESSAGE.dep ?= @${_MESSAGE} "DEP: ${.TARGET}" + +.NOPATH: .depend ${__DPSRCS.d} + +.if !empty(__DPSRCS.d) +${__DPSRCS.d}: ${__DPSRCS.notd} ${DPSRCS} +.endif # __DPSRCS.d + +.if ${MKDEP_TYPE:U} == "nbmkdep" +ddash=-- +.else +ddash= +.endif + +.if ${MKDEP_TYPE:U} == "makedepend" +MKDEP.c = ${MAKEDEPEND} -f- ${ddash} ${MKDEPFLAGS} \ + ${CFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} ${_CPPFLAGS} > ${.TARGET} +MKDEP.m = ${MKDEP} -f- ${ddash} ${MKDEPFLAGS} \ + ${OBJCFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} ${_CPPFLAGS} > ${.TARGET} +MKDEP.cc = ${MKDEP} -f- ${ddash} ${MKDEPFLAGS} \ + ${CXXFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} ${_CPPFLAGS} > ${.TARGET} +MKDEP.s = ${MKDEP} -f- ${ddash} ${MKDEPFLAGS} \ + ${AFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} ${_CPPFLAGS} > ${.TARGET} +.else +MKDEP.c = ${MKDEP} -f ${.TARGET} ${ddash} ${MKDEPFLAGS} \ + ${CFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} ${_CPPFLAGS} +MKDEP.m = ${MKDEP} -f ${.TARGET} ${ddash} ${MKDEPFLAGS} \ + ${OBJCFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} ${_CPPFLAGS} +MKDEP.cc = ${MKDEP} -f ${.TARGET} ${ddash} ${MKDEPFLAGS} \ + ${CXXFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} ${_CPPFLAGS} +MKDEP.s = ${MKDEP} -f ${.TARGET} ${ddash} ${MKDEPFLAGS} \ + ${AFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} ${_CPPFLAGS} +.endif + +.depend: ${__DPSRCS.d} + ${MESSAGE.dep} + @${RM} -f ${.TARGET} +.if ${MKDEP_TYPE:U} == "nbmkdep" + @${MKDEP} -d -f ${.TARGET} -s ${MKDEP_SUFFIXES:Q} ${__DPSRCS.d} +.else + @sed 's/^\([^ ]*\)[.]o\(.*\)$$/${MKDEP_SUFFIXES:C,^,\\\\1,}\2/' ${__DPSRCS.d} > ${.TARGET} +.endif + +.SUFFIXES: .d .s .S .c .C .cc .cpp .cxx .m + +.c.d: + ${MESSAGE.dep} + @env CC=${MKDEP_CC:Q} ${MKDEP.c} ${.IMPSRC} + +.m.d: + ${MESSAGE.dep} + @${MKDEP.m} ${.IMPSRC} + +.s.d .S.d: + ${MESSAGE.dep} + @env CC=${MKDEP_CC:Q} ${MKDEP.s} ${.IMPSRC} + +.C.d .cc.d .cpp.d .cxx.d: + ${MESSAGE.dep} + @env CC=${MKDEP_CC:Q} ${MKDEP.cc} ${.IMPSRC} + +.endif # defined(SRCS) + +###################################################################### +.endif # _MKC_IMP_DEP_MK diff --git a/mk/mkc_imp.dpvars.mk b/mk/mkc_imp.dpvars.mk new file mode 100644 index 0000000..a76518d --- /dev/null +++ b/mk/mkc_imp.dpvars.mk @@ -0,0 +1,27 @@ +# Copyright (c) 2014 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +.for i in ${DPLDADD} +. if ( ${MKPIE:U:tl} == "yes" || defined(SHLIB_MAJOR) ) && !empty(STATICLIBS:Mlib${i}) +LDADD0 += -l${i}_pic +. else +LDADD0 += -l${i} +. endif +.endfor + +.for i in ${DPLIBDIRS} +. if ${TARGET_OPSYS} == "HP-UX" +LDFLAGS0 += ${CFLAGS.cctold}+b ${CFLAGS.cctold}${LIBDIR} +. endif +LDFLAGS0 += -L${i} +.endfor + +.for i in ${DPINCDIRS:O:u} +CPPFLAGS0 += -I${i} +.endfor + +.undef DPLIBDIRS +.undef DPINCDIRS +.undef DPLDADD diff --git a/mk/mkc_imp.files.mk b/mk/mkc_imp.files.mk new file mode 100644 index 0000000..40c9f53 --- /dev/null +++ b/mk/mkc_imp.files.mk @@ -0,0 +1,46 @@ +# Copyright (c) 2009-2014 by Aleksey Cheusov +# Copyright (c) 1994-2009 The NetBSD Foundation, Inc. +# Copyright (c) 1988, 1989, 1993 The Regents of the University of California +# Copyright (c) 1988, 1989 by Adam de Boor +# Copyright (c) 1989 by Berkeley Softworks +# +# See LICENSE file in the distribution. +############################################################ + +.if !defined(_BSD_FILES_MK) +_BSD_FILES_MK := 1 + +filesinstall: .PHONY # ensure existence + +.include <mkc.init.mk> + +do_install1: .PHONY filesinstall + +.if defined(FILES) && !empty(FILES) + +realdo_all: ${FILES} + +.if ${MKINSTALL:tl} == "yes" +destination_files = ${FILES:@F@${DESTDIR}${FILESDIR_${F}:U${FILESDIR}}/${FILESNAME_${F}:U${FILESNAME:U${F:T}}}@} + +filesinstall: ${destination_files} +.PRECIOUS: ${destination_files} +.PHONY: ${destination_files} + +__fileinstall: .USE + ${INSTALL} ${RENAME} ${PRESERVE} ${COPY} \ + -o ${FILESOWN_${.ALLSRC:T}:U${FILESOWN}:Q} \ + -g ${FILESGRP_${.ALLSRC:T}:U${FILESGRP}:Q} \ + -m ${FILESMODE_${.ALLSRC:T}:U${FILESMODE}} \ + ${.ALLSRC} ${.TARGET} + +.for F in ${FILES:O:u} +${DESTDIR}${FILESDIR_${F}:U${FILESDIR}}/${FILESNAME_${F}:U${FILESNAME:U${F:T}}}: ${F} __fileinstall +.endfor + +UNINSTALLFILES += ${destination_files} +INSTALLDIRS += ${destination_files:H} +.endif # MKINSTALL +.endif # FILES + +.endif # _BSD_FILES_MK diff --git a/mk/mkc_imp.final.mk b/mk/mkc_imp.final.mk new file mode 100644 index 0000000..02fb20d --- /dev/null +++ b/mk/mkc_imp.final.mk @@ -0,0 +1,69 @@ +# Copyright (c) 2009-2012 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +.ifndef MKC_IMP.FINAL.MK +MKC_IMP.FINAL.MK = 1 + +.PATH: ${SRC_PATHADD} + +LDADD += ${DPLIBS} # DPLIBS is deprecated (2012-08-13) +LDADD += ${LDADD_${PROJECTNAME}} + +LDFLAGS += ${LDFLAGS_${PROJECTNAME}} + +.if !empty(SRCS:U:M*.l) +LDADD += ${LEXLIB} +.endif + +.for i in ${EXPORT_VARNAMES} +.if empty(NOEXPORT_VARNAMES:U:M${i}) +export_cmd += ${i}=${${i}:Q}; export ${i}; +.endif +.endfor + +.if ${MKRELOBJDIR} == "yes" && defined(SRCTOP) +export_cmd += MAKEOBJDIR=${.OBJDIR}/${.TARGET:C/^.*-//}; \ + export MAKEOBJDIR; ${MKDIR} -p $${MAKEOBJDIR}; +.endif + +########## +realdo_clean: mkc_clean + +mkc_clean: .PHONY +.if ${CLEANFILES:U} != "" + -${CLEANFILES_CMD} ${CLEANFILES} +.endif +.if ${CLEANDIRS:U} != "" + -${CLEANDIRS_CMD} ${CLEANDIRS} +.endif + +##### +distclean: cleandir + +realdo_cleandir: mkc_cleandir + +mkc_cleandir: +.if ${CLEANFILES:U} != "" || ${DISTCLEANFILES:U} != "" + -${CLEANFILES_CMD} ${DISTCLEANFILES} ${CLEANFILES} +.endif +.if ${CLEANDIRS:U} != "" || ${DISTCLEANDIRS:U} != "" + -${CLEANDIRS_CMD} ${DISTCLEANDIRS} ${CLEANDIRS} +.endif + +########## +# pre_, do_, post_ targets +.for t in ${ALLTARGETS} +${t}: pre_${t} .WAIT do_${t} .WAIT post_${t} +pre_${t} do_${t} realdo_${t} post_${t}: .PHONY # ensure existence +.if !commands(do_${t}) +do_${t}: realdo_${t} +.endif +.endfor + +${TARGETS}: .PHONY + +########## + +.endif # MKC_IMP.FINAL.MK diff --git a/mk/mkc_imp.foreign_autotools.mk b/mk/mkc_imp.foreign_autotools.mk new file mode 100644 index 0000000..f3b5a2f --- /dev/null +++ b/mk/mkc_imp.foreign_autotools.mk @@ -0,0 +1,79 @@ +# Copyright (c) 2014 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +.ifndef _MKC_IMP_FOREIGN_AUTOTOOLS_MK +_MKC_IMP_FOREIGN_AUTOTOOLS_MK := 1 + +MESSAGE.atconf ?= @${_MESSAGE} "CONFIGURE:" +MESSAGE.autotools ?= @${_MESSAGE} "AUTOTOOLS:" + +MKC_REQUIRE_PROGS += autoreconf + +AT_USE_AUTOMAKE ?= yes +AT_MAKE ?= ${MAKE} +AT_AUTORECONF_ARGS ?= -is -f + +.if empty(FSRCDIR) +MKC_ERR_MSG += "FSRCDIR should not be empty" +.elif empty(FSRCDIR:M/*) +_FSRCDIR = ${.CURDIR}/${FSRCDIR} +.else +_FSRCDIR = ${FSRCDIR} +.endif + +.if ${.OBJDIR} == ${.CURDIR} +.OBJDIR = ${_FSRCDIR} +.endif +_FOBJDIR = ${.OBJDIR} + +_CONFIGURE_ARGS = --prefix ${PREFIX:Q} --bindir=${BINDIR:Q} \ + --sbindir=${SBINDIR:Q} --libexecdir=${LIBEXECDIR} \ + --sysconfdir=${SYSCONFDIR:Q} --sharedstatedir=${SHAREDSTATEDIR:Q} \ + --localstatedir=${VARDIR:Q} --libdir=${LIBDIR:Q} \ + --includedir=${INCSDIR:Q} --datarootdir=${DATADIR:Q} \ + --infodir=${INFODIR:Q} --localedir=${DATADIR:Q}/locale \ + --mandir=${MANDIR:Q} --docdir=${DATADIR:Q}/doc/${PROJECTNAME} \ + --srcdir=${_FSRCDIR} ${AT_CONFIGURE_ARGS} + +_CONFIGURE_ENV = CC=${CC:Q} CFLAGS=${CFLAGS:Q} \ + CXX=${CXX:Q} CXXFLAGS=${CXXFLAGS:Q} \ + CPPFLAGS=${_CPPFLAGS:Q} \ + LDFLAGS=${LDFLAGS:Q} LIBS=${LDADD:Q} CPP=${CPP:Q} ${AT_CONFIGURE_ENV} + +_AT_MAKE_ENV = ${DESTDIR:DDESTDIR=${DESTDIR:Q}} ${AT_MAKE_ENV} + +realdo_mkgen: + ${MESSAGE.mkgen} + ${_V} ${PROG.autoreconf} ${AT_AUTORECONF_ARGS} ${_FSRCDIR} + +realdo_errorcheck: check_mkc_err_msg .WAIT at_do_errorcheck + +at_do_errorcheck: .PHONY + ${MESSAGE.atconf} + ${_V} cd ${_FOBJDIR}; env ${_CONFIGURE_ENV} ${_FSRCDIR}/configure ${_CONFIGURE_ARGS} + +.for i in all clean cleandir install uninstall +realdo_${i}: at_do_${i} +at_do_${i}: .PHONY + ${MESSAGE.autotools} + ${_V} set -e; \ + cd ${_FOBJDIR}; \ + if test -f Makefile; then \ + env ${_AT_MAKE_ENV} ${AT_MAKE} ${AT_MAKEFLAGS} ${.TARGET:S/^at_do_//:S/cleandir/distclean/}; \ + fi +.endfor + +DISTCLEANDIRS += ${_FSRCDIR}/autom4te.cache +DISTCLEANFILES += ${_FSRCDIR}/aclocal.m4 ${_FOBJDIR}/config.log \ + ${_FOBJDIR}/config.status ${_FSRCDIR}/configure ${_FSRCDIR}/depcomp \ + ${_FSRCDIR}/INSTALL ${_FSRCDIR}/install-sh ${_FOBJDIR}/Makefile \ + ${_FSRCDIR}/missing ${_FSRCDIR}/compile ${_FOBJDIR}/stamp-h1 + +.if ${AT_USE_AUTOMAKE:tl:U} == yes +DISTCLEANFILES += ${_FSRCDIR}/Makefile.in +MKC_REQUIRE_PROGS += automake +.endif + +.endif # _MKC_IMP_FOREIGN_AUTOTOOLS_MK diff --git a/mk/mkc_imp.inc.mk b/mk/mkc_imp.inc.mk new file mode 100644 index 0000000..d6f46ff --- /dev/null +++ b/mk/mkc_imp.inc.mk @@ -0,0 +1,36 @@ +# Copyright (c) 2009-2010 by Aleksey Cheusov +# Copyright (c) 1994-2009 The NetBSD Foundation, Inc. +# Copyright (c) 1988, 1989, 1993 The Regents of the University of California +# Copyright (c) 1988, 1989 by Adam de Boor +# Copyright (c) 1989 by Berkeley Softworks +# +# See LICENSE file in the distribution. +############################################################ + +do_install1: incinstall +incinstall: .PHONY # ensure existence + +.if defined(INCS) +INCSSRCDIR ?= . +CPPFLAGS0 += -I${INCSSRCDIR} + +.if ${MKINSTALL:tl} == "yes" +destination_incs = ${INCS:@I@${DESTDIR}${INCSDIR}/$I@} + +incinstall: ${destination_incs} +.PRECIOUS: ${destination_incs} +.PHONY: ${destination_incs} + +__incinstall: .USE + ${INSTALL} ${RENAME} ${PRESERVE} ${COPY} \ + -o ${BINOWN:Q} \ + -g ${BINGRP:Q} -m ${NONBINMODE} ${.ALLSRC} ${.TARGET} + +.for I in ${INCS:O:u} +${DESTDIR}${INCSDIR}/$I: ${"${INCSSRCDIR}" != ".":?${INCSSRCDIR}/$I:$I} __incinstall +.endfor + +UNINSTALLFILES += ${destination_incs} +INSTALLDIRS += ${destination_incs:H} +.endif # MKINSTALL +.endif # INCS diff --git a/mk/mkc_imp.info.mk b/mk/mkc_imp.info.mk new file mode 100644 index 0000000..7d3976d --- /dev/null +++ b/mk/mkc_imp.info.mk @@ -0,0 +1,68 @@ +# Copyright (c) 2009-2010 by Aleksey Cheusov +# Copyright (c) 1994-2009 The NetBSD Foundation, Inc. +# Copyright (c) 1988, 1989, 1993 The Regents of the University of California +# Copyright (c) 1988, 1989 by Adam de Boor +# Copyright (c) 1989 by Berkeley Softworks +# +# See LICENSE file in the distribution. +############################################################ + +.if !defined(_MKC_IMP_INFO_MK) && defined(TEXINFO) +_MKC_IMP_INFO_MK := 1 + +infoinstall: .PHONY + +.include <mkc.init.mk> + +MAKEINFO ?= makeinfo +INFOFLAGS ?= +INSTALL_INFO ?= install-info + +.SUFFIXES: .txi .texi .texinfo .info + +MESSAGE.texinfo ?= @${_MESSAGE} "TEXINFO: ${.TARGET}" + +.txi.info .texi.info .texinfo.info: + ${MESSAGE.texinfo} + ${_V}${MAKEINFO} ${INFOFLAGS} --no-split -o $@ $< + +.if defined(TEXINFO) && !empty(TEXINFO) +realdo_all: ${TEXINFO} + +INFOFILES = ${TEXINFO:S/.texinfo/.info/g:S/.texi/.info/g:S/.txi/.info/g} +.NOPATH: ${INFOFILES} + +.if ${MKINFO:tl} != "no" +realdo_all: ${INFOFILES} + +CLEANFILES += ${INFOFILES} + +destination_infos = ${INFOFILES:@F@${DESTDIR}${INFODIR_${F}:U${INFODIR}}/${INFONAME_${F}:U${INFONAME:U${F:T}}}@} + +infoinstall: ${destination_infos} +.PRECIOUS: ${destination_infos} +.PHONY: ${destination_infos} + +__infoinstall: .USE + ${INSTALL} ${RENAME} ${PRESERVE} ${COPY} ${INSTPRIV} \ + -o ${INFOOWN_${.ALLSRC:T}:U${INFOOWN}:Q} \ + -g ${INFOGRP_${.ALLSRC:T}:U${INFOGRP}:Q} \ + -m ${INFOMODE_${.ALLSRC:T}:U${INFOMODE}} \ + ${.ALLSRC} ${.TARGET} + @${INSTALL_INFO} --remove --info-dir=${DESTDIR}${INFODIR} ${.TARGET} + ${INSTALL_INFO} --info-dir=${DESTDIR}${INFODIR} ${.TARGET} + +.if ${MKINSTALL:tl} == "yes" +do_install1: infoinstall +.for F in ${INFOFILES:O:u} +${DESTDIR}${INFODIR_${F}:U${INFODIR}}/${INFONAME_${F}:U${INFONAME:U${F:T}}}: ${F} __infoinstall +.endfor # F + +UNINSTALLFILES += ${destination_infos} +INSTALLDIRS += ${destination_infos:H} +.endif # MKINSTALL +.endif # MKINFO + +.endif # TEXINFO + +.endif # _MKC_IMP_INFO_MK diff --git a/mk/mkc_imp.intexts.mk b/mk/mkc_imp.intexts.mk new file mode 100644 index 0000000..f733874 --- /dev/null +++ b/mk/mkc_imp.intexts.mk @@ -0,0 +1,59 @@ +# Copyright (c) 2009-2014 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +# Given a list of files in INFILES or INSCRIPTS mkc.intexts.mk +# generates them from appropriate *.in files replacing @prefix@, +# @sysconfdir@, @libdir@, @bindir@, @sbindir@, @datadir@ etc. with +# real ${PREFIX}, ${SYSCONFDIR} etc. See examples/ projects. + +.ifndef _MKC_IMP_INTEXTS_MK +_MKC_IMP_INTEXTS_MK := 1 + +MESSAGE.gen ?= @${_MESSAGE} "GEN: ${.TARGET}" + +INTEXTS_SED += -e 's,@sysconfdir@,${SYSCONFDIR},g' +INTEXTS_SED += -e 's,@libdir@,${LIBDIR},g' +INTEXTS_SED += -e 's,@libexecdir@,${LIBEXECDIR},g' +INTEXTS_SED += -e 's,@prefix@,${PREFIX},g' +INTEXTS_SED += -e 's,@bindir@,${BINDIR},g' +INTEXTS_SED += -e 's,@sbindir@,${SBINDIR},g' +INTEXTS_SED += -e 's,@datadir@,${DATADIR},g' +INTEXTS_SED += -e 's,@mandir@,${MANDIR},g' +INTEXTS_SED += -e 's,@incsdir@,${INCSDIR},g' +INTEXTS_SED += -e 's,@vardir@,${VARDIR},g' +INTEXTS_SED += -e 's,@sharedstatedir@,${SHAREDSTATEDIR},g' + +.if !make(clean) && !make(cleandir) && !make(distclean) #&& empty(MKC_ERR_MSG) +. if !empty(INTEXTS_REPLS) && ${INTEXTS_REPLS:[\#]:M*[13579]} != "" +MKC_ERR_MSG += "ERROR: odd number of tokens in INTEXTS_REPLS" +. else +. for _pattern _repl in ${INTEXTS_REPLS} +INTEXTS_SED += -e 's,@${_pattern}@,${_repl},g' +. endfor +. endif +.endif + +.for i in ${INFILES} +.NOPATH: ${i:T} +${i:T} : ${i}.in + ${MESSAGE.gen} + ${_V} sed ${INTEXTS_SED} ${.ALLSRC} > ${.TARGET} && \ + chmod 0644 ${.TARGET} +.endfor + +.for i in ${INSCRIPTS} +.NOPATH: ${i:T} +${i:T} : ${i}.in + ${MESSAGE.gen} + ${_V} sed ${INTEXTS_SED} ${.ALLSRC} > ${.TARGET} && \ + chmod 0755 ${.TARGET} +.endfor + +CLEANFILES += ${INSCRIPTS:T} ${INFILES:T} + +realdo_all: ${INSCRIPTS:T} ${INFILES:T} + +###################################################################### +.endif # _MKC_IMP_INTEXTS_MK diff --git a/mk/mkc_imp.lib.mk b/mk/mkc_imp.lib.mk new file mode 100644 index 0000000..001819e --- /dev/null +++ b/mk/mkc_imp.lib.mk @@ -0,0 +1,182 @@ +# Copyright (c) 2009-2014 by Aleksey Cheusov +# Copyright (c) 1994-2009 The NetBSD Foundation, Inc. +# Copyright (c) 1988, 1989, 1993 The Regents of the University of California +# Copyright (c) 1988, 1989 by Adam de Boor +# Copyright (c) 1989 by Berkeley Softworks +# +# See LICENSE file in the distribution. +############################################################ + +.if !defined(_MKC_IMP_LIB_MK) +_MKC_IMP_LIB_MK := 1 + +.PHONY: libinstall +.if ${MKINSTALL:tl} == "yes" +do_install1: libinstall +INSTALLDIRS += ${DESTDIR}${LIBDIR} +UNINSTALLFILES += ${UNINSTALLFILES.lib} +.endif # MKINSTALL + +# Set PICFLAGS to cc flags for producing position-independent code, +# if not already set. Includes -DPIC, if required. + +# Data-driven table using make variables to control how shared libraries +# are built for different platforms and object formats. +# OBJECT_FMT: currently either "ELF" or "a.out", from <bsd.own.mk> +# LDFLAGS.soname: Flags to tell ${LD} to emit shared library. +# with ELF, also set shared-lib version for ld.so. +# +# FFLAGS.pic: flags for ${FC} to compile .[fF] files to .os objects. +# CPPICFLAGS: flags for ${CPP} to preprocess .[sS] files for ${AS} +# CFLAGS.pic: flags for ${CC} to compile .[cC] files to .os objects. +# CAFLAGS.pic flags for {$CC} to compiling .[Ss] files +# (usually just ${CPPFLAGS.pic} ${CFLAGS.pic}) +# AFLAGS.pic: flags for ${AS} to assemble .[sS] to .os objects. + +CFLAGS += ${COPTS} +FFLAGS += ${FOPTS} + +OBJS += ${SRCS:N*.h:N*.sh:T:R:S/$/.o/g} +SOBJS = ${OBJS:.o=.os} +POBJS = ${OBJS:.o=.op} + +.if !empty(SRCS:N*.h:N*.sh:M*/*:H) +SRC_PATHADD += ${SRCS:N*.h:N*.sh:M*/*:H} +.endif + +.if ${MKSTATICLIB:tl} != "no" +_LIBS += lib${LIB}.a +.endif + +.if ${MKPROFILELIB:tl} != "no" +_LIBS += lib${LIB}_p.a +.endif + +.if ${MKPICLIB:tl} != "no" +_LIBS += lib${LIB}_pic.a +.endif # MKPICLIB + +.if ${MKSHLIB:tl} != "no" +.if ${MKDLL:tl} == "no" +SHLIBFN = lib${LIB}${SHLIB_EXTFULL} +.else +SHLIBFN = ${LIB}${DLL_EXT} +.endif +_LIBS += ${SHLIBFN} +.endif + +.NOPATH: ${_LIBS} + +realdo_all: ${SRCS} ${_LIBS} + +_SRCS_ALL = ${SRCS} + +__archivebuild: .USE + @${RM} -f ${.TARGET} + ${MESSAGE.ar} + ${_V} ${AR} cq ${.TARGET} ${.ALLSRC}; \ + ${RANLIB} ${.TARGET} + +__archiveinstall: .USE + ${INSTALL} ${RENAME} ${PRESERVE} ${COPY} -o ${LIBOWN:Q} \ + -g ${LIBGRP:Q} -m ${LIBMODE} ${.ALLSRC} ${.TARGET} + +DPSRCS += ${SRCS:M*.l:.l=.c} ${SRCS:M*.y:.y=.c} +CLEANFILES += ${DPSRCS} +.if defined(YHEADER) +CLEANFILES += ${SRCS:M*.y:.y=.h} +.endif + +lib${LIB}.a:: ${OBJS} __archivebuild + @${_MESSAGE_V} "building standard ${LIB} library" + +lib${LIB}_p.a:: ${POBJS} __archivebuild + @${_MESSAGE_V} "building profiled ${LIB} library" + +lib${LIB}_pic.a:: ${SOBJS} __archivebuild + @${_MESSAGE_V} "building shared object ${LIB} library" + +${SHLIBFN}: ${SOBJS} ${DPADD} +.if !commands(${SHLIBFN}) + @${_MESSAGE_V} building shared ${LIB} library \(version ${SHLIB_FULLVERSION}\) + @${RM} -f ${.TARGET} + @${_MESSAGE} "LD: ${.TARGET}" + ${_V} $(LDREAL) ${LDFLAGS.shlib} -o ${.TARGET} \ + ${SOBJS} ${LDFLAGS0} ${LDADD0} ${LDFLAGS} ${LDADD} +.if ${OBJECT_FMT} == "ELF" && ${MKDLL:tl} == "no" + @${LN_S} -f ${SHLIBFN} lib${LIB}${SHLIB_EXT} + @${LN_S} -f ${SHLIBFN} lib${LIB}${SHLIB_EXT1} +.endif # ELF +.endif # !commands(...) + +CLEANFILES += \ + ${OBJS} ${POBJS} ${SOBJS} + +.if !target(libinstall) +# Make sure it gets defined +libinstall:: + +CLEANFILES += lib${LIB}.a lib${LIB}_pic.a lib${LIB}_p.a + + # MKSTATICLIB +.if ${MKSTATICLIB:tl} != "no" +libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}.a +.PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}.a +.PHONY: ${DESTDIR}${LIBDIR}/lib${LIB}.a +UNINSTALLFILES.lib += ${DESTDIR}${LIBDIR}/lib${LIB}.a + +${DESTDIR}${LIBDIR}/lib${LIB}.a: lib${LIB}.a __archiveinstall +.endif + + # MKPROFILELIB +.if ${MKPROFILELIB:tl} != "no" +libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a +.PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a +.PHONY: ${DESTDIR}${LIBDIR}/lib${LIB}_p.a +UNINSTALLFILES.lib += ${DESTDIR}${LIBDIR}/lib${LIB}_p.a + +${DESTDIR}${LIBDIR}/lib${LIB}_p.a: lib${LIB}_p.a __archiveinstall +.endif + + # MKPICLIB +.if ${MKPICLIB:tl} != "no" +libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a +.PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a +.PHONY: ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a +UNINSTALLFILES.lib += ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a + +${DESTDIR}${LIBDIR}/lib${LIB}_pic.a: lib${LIB}_pic.a __archiveinstall +.endif + + # MKSHLIB +.if ${MKSHLIB:tl} != "no" +libinstall:: ${DESTDIR}${LIBDIR}/${SHLIBFN} +.PRECIOUS: ${DESTDIR}${LIBDIR}/${SHLIBFN} +.PHONY: ${DESTDIR}${LIBDIR}/${SHLIBFN} +UNINSTALLFILES.lib += ${DESTDIR}${LIBDIR}/${SHLIBFN} +.if ${MKDLL:tl} == "no" +UNINSTALLFILES.lib += ${DESTDIR}${LIBDIR}/lib${LIB}${SHLIB_EXT} \ + ${DESTDIR}${LIBDIR}/lib${LIB}${SHLIB_EXT1} +CLEANFILES += \ + lib${LIB}${SHLIB_EXT} lib${LIB}${SHLIB_EXT1} \ + lib${LIB}${SHLIB_EXT2} ${SHLIB_EXT3:Dlib${LIB}${SHLIB_EXT3}} +.else +CLEANFILES += ${SHLIBFN} +.endif + +${DESTDIR}${LIBDIR}/${SHLIBFN}: ${SHLIBFN} + ${INSTALL} ${RENAME} ${PRESERVE} ${COPY} -o ${LIBOWN:Q} \ + -g ${LIBGRP:Q} -m ${SHLIBMODE} ${.ALLSRC} ${.TARGET} +.if ${OBJECT_FMT} == "a.out" && !defined(DESTDIR) && ${MKDLL:tl} == "no" + /sbin/ldconfig -m ${LIBDIR} +.endif +.if ${OBJECT_FMT} == "ELF" && ${MKDLL:tl} == "no" + ${LN_S} -f ${SHLIBFN} \ + ${DESTDIR}${LIBDIR}/lib${LIB}${SHLIB_EXT1} + ${LN_S} -f ${SHLIBFN} \ + ${DESTDIR}${LIBDIR}/lib${LIB}${SHLIB_EXT} +.endif +.endif +.endif + +.endif #_MKC_IMP_LIB_MK diff --git a/mk/mkc_imp.links.mk b/mk/mkc_imp.links.mk new file mode 100644 index 0000000..00cbec1 --- /dev/null +++ b/mk/mkc_imp.links.mk @@ -0,0 +1,34 @@ +# Copyright (c) 2009-2013 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +.if !defined(_MKC_IMP_LINKS_MK) +_MKC_IMP_LINKS_MK := 1 + +linksinstall: .PHONY # ensure existence + +do_install2: linksinstall + +.if ${MKINSTALL:tl} == "yes" + +linksinstall: +.for l r in ${LINKS} + ${RM} -f ${DESTDIR}${r}; ${LN} ${DESTDIR}${l} ${DESTDIR}${r} +.endfor +.for l r in ${SYMLINKS} + ${RM} -f ${DESTDIR}${r}; ${LN_S} ${l} ${DESTDIR}${r} +.endfor + +.for l r in ${LINKS} +UNINSTALLFILES += ${DESTDIR}${r} +INSTALLDIRS += ${DESTDIR}${r:H} +.endfor + +.for l r in ${SYMLINKS} +UNINSTALLFILES += ${DESTDIR}${r} +INSTALLDIRS += ${DESTDIR}${r:H} +.endfor + +.endif # MKINSTALL=yes +.endif # _MKC_IMP_LINKS_MK diff --git a/mk/mkc_imp.lua.mk b/mk/mkc_imp.lua.mk new file mode 100644 index 0000000..7e7fa48 --- /dev/null +++ b/mk/mkc_imp.lua.mk @@ -0,0 +1,60 @@ +# Copyright (c) 2010 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +.for i in ${LUA_LMODULES} +LUA_MODULES += ${i:T:R} +LUA_SRCS.${i:T:R} = ${i} +.endfor + +.if defined(LUA_MODULES) || defined(LUA_CMODULE) + +#### .lua modules +.if defined(LUA_MODULES) +.if !defined(LUA_LMODDIR) +PKG_CONFIG_DEPS += lua +PKG_CONFIG_VARS.lua += INSTALL_LMOD +LUA_LMODDIR ?= ${PKG_CONFIG.var.lua.INSTALL_LMOD} +.endif +.for i in ${LUA_MODULES} +LUA_SRCS.${i} ?= ${i:S/./_/g}.lua +FILES += ${LUA_SRCS.${i}} +FILESDIR_${LUA_SRCS.${i}} = ${LUA_LMODDIR}/${i:S|.|/|g:H} +FILESNAME_${LUA_SRCS.${i}} = ${i:S|.|/|g:T}.lua +.endfor # i +.endif # defined(LUA_MODULES) + +### .c module +.if defined(LUA_CMODULE) +PKG_CONFIG_DEPS += lua + +.if !defined(LUA_CMODDIR) +PKG_CONFIG_VARS.lua += INSTALL_CMOD +LUA_CMODDIR ?= ${PKG_CONFIG.var.lua.INSTALL_CMOD} +.endif +LIB = ${LUA_CMODULE:S|.|/|:T} +SRCS ?= ${LUA_CMODULE:S/./_/g}.c +MKDLL = Only +DLL_EXT = .so +LIBDIR = ${LUA_CMODDIR}/${LUA_CMODULE:S|.|/|g:H} +.endif # defined(LUA_CMODULES) + +###################### +.include <mkc_imp.pkg-config.mk> + +.if defined(LUA_MODULES) && empty(LUA_LMODDIR) +MKC_ERR_MSG += "ERROR: pkg-config --variable=INSTALL_LMOD lua failed" +.endif # LUA_MODULES + +.ifdef LUA_CMODULE +.if empty(LUA_CMODDIR) +MKC_ERR_MSG += "ERROR: pkg-config --variable=INSTALL_CMOD lua failed" +.endif + +.if empty(MKC_ERR_MSG) +MKC_REQUIRE_HEADERS += lua.h +.endif # !empty(MKC_ERR_MSG) +.endif # LUA_CMODULE + +.endif # LUA_MODULES) || LUA_CMODULE diff --git a/mk/mkc_imp.man.mk b/mk/mkc_imp.man.mk new file mode 100644 index 0000000..c66f056 --- /dev/null +++ b/mk/mkc_imp.man.mk @@ -0,0 +1,187 @@ +# Copyright (c) 2009-2010 by Aleksey Cheusov +# Copyright (c) 1994-2009 The NetBSD Foundation, Inc. +# Copyright (c) 1988, 1989, 1993 The Regents of the University of California +# Copyright (c) 1988, 1989 by Adam de Boor +# Copyright (c) 1989 by Berkeley Softworks +# +# See LICENSE file in the distribution. +############################################################ + +.if !defined(_MKC_IMP_MAN_MK) +_MKC_IMP_MAN_MK := 1 + +MESSAGE.nroff ?= @${_MESSAGE} "NROFF: ${.TARGET}" + +.if ${MKSHARE:tl} == "no" +MKCATPAGES = no +MKDOC = no +MKINFO = no +MKMAN = no +.endif + +.if ${MKMAN:tl} == "no" +MKCATPAGES = no +.endif + +.if defined(USETBL) && ${USETBL:U:tl} == "no" +.undef USETBL +.endif + +.if defined(MANZ) && ${MANZ:U:tl} == "no" +.undef MANZ +.endif + +.PHONY: catinstall maninstall catpages manpages catlinks \ + manlinks html installhtml +.if ${MKMAN:tl} != "no" +do_install1: ${MANINSTALL} +.endif + +MANTARGET ?= cat +NROFF ?= nroff +GROFF ?= groff +TBL ?= tbl + +.SUFFIXES: .1 .2 .3 .4 .5 .6 .7 .8 .9 \ + .cat1 .cat2 .cat3 .cat4 .cat5 .cat6 .cat7 .cat8 .cat9 \ + .html1 .html2 .html3 .html4 .html5 .html6 .html7 .html8 .html9 + +.9.cat9 .8.cat8 .7.cat7 .6.cat6 .5.cat5 .4.cat4 .3.cat3 .2.cat2 .1.cat1: + ${MESSAGE.nroff} +.if !defined(USETBL) + ${_V} ${NROFF} ${NROFF_MAN2CAT} ${.IMPSRC} > ${.TARGET} || \ + (${RM} -f ${.TARGET}; false) +.else + ${_V} ${TBL} ${.IMPSRC} | ${NROFF} ${NROFF_MAN2CAT} > ${.TARGET} || \ + (${RM} -f ${.TARGET}; false) +.endif + +.9.html9 .8.html8 .7.html7 .6.html6 .5.html5 .4.html4 .3.html3 .2.html2 .1.html1: +.if !defined(USETBL) + @echo "${GROFF} -Tascii -mdoc2html -P-b -P-u -P-o ${.IMPSRC} > ${.TARGET}" + @${GROFF} -Tascii -mdoc2html -P-b -P-u -P-o ${.IMPSRC} > ${.TARGET} || \ + (${RM} -f ${.TARGET}; false) +.else + @echo "${TBL} ${.IMPSRC} | ${GROFF} -mdoc2html -P-b -P-u -P-o > ${.TARGET}" + @cat ${.IMPSRC} | ${GROFF} -mdoc2html -P-b -P-u -P-o > ${.TARGET} || \ + (${RM} -f ${.TARGET}; false) +.endif + +.if defined(MAN) && !empty(MAN) +realdo_all: ${MAN} +MANPAGES = ${MAN} +CATPAGES = ${MANPAGES:C/(.*).([1-9])/\1.cat\2/} +CLEANFILES += ${CATPAGES} +.NOPATH: ${CATPAGES} +HTMLPAGES = ${MANPAGES:C/(.*).([1-9])/\1.html\2/} +.endif + +MINSTALL = ${INSTALL} ${RENAME} ${PRESERVE} ${COPY} \ + -o ${MANOWN:Q} -g ${MANGRP:Q} -m ${MANMODE} + +.if defined(MANZ) +# chown and chmod are done afterward automatically +MCOMPRESS = gzip -cf +MCOMPRESSSUFFIX = .gz +.endif + +catinstall: catlinks +maninstall: manlinks + +__installpage: .USE +.if defined(MCOMPRESS) && !empty(MCOMPRESS) + @${RM} -f ${.TARGET} + ${MCOMPRESS} ${.ALLSRC} > ${.TARGET} + @chown ${MANOWN:Q}:${MANGRP:Q} ${.TARGET} + @chmod ${MANMODE} ${.TARGET} +.else + ${MINSTALL} ${.ALLSRC} ${.TARGET} +.endif + + +# Rules for cat'ed man page installation +.if defined(CATPAGES) && !empty(CATPAGES) && ${MKCATPAGES:tl} != "no" +realdo_all: ${CATPAGES} + +.if ${MKINSTALL:tl} == "yes" +destination_capages = ${CATPAGES:@P@${DESTDIR}${MANDIR}/${P:T:E}${MANSUBDIR}/${P:T:R}.0${MCOMPRESSSUFFIX}@} +UNINSTALLFILES += ${destination_capages} +INSTALLDIRS += ${destination_capages:H} +.endif # MKINSTALL + +catpages:: ${destination_capages} +.PRECIOUS: ${destination_capages} +.PHONY: ${destination_capages} + +.for P in ${CATPAGES:O:u} +${DESTDIR}${MANDIR}/${P:T:E}${MANSUBDIR}/${P:T:R}.0${MCOMPRESSSUFFIX}: ${P} __installpage +.endfor + +.else +catpages:: +.endif # CATPAGES + +# Rules for source page installation +.if defined(MANPAGES) && !empty(MANPAGES) + +.if ${MKINSTALL:tl} == "yes" +destination_manpages = ${MANPAGES:@P@${DESTDIR}${MANDIR}/man${P:T:E}${MANSUBDIR}/${P}${MCOMPRESSSUFFIX}@} +UNINSTALLFILES += ${destination_manpages} +INSTALLDIRS += ${destination_manpages:H} +.endif # MKINSTALL + +manpages:: ${destination_manpages} +.PRECIOUS: ${destination_manpages} +.PHONY: ${destination_manpages} + +.for P in ${MANPAGES:O:u} +${DESTDIR}${MANDIR}/man${P:T:E}${MANSUBDIR}/${P}${MCOMPRESSSUFFIX}: ${P} __installpage +.endfor + +.else +manpages:: +.endif # MANPAGES + +.if ${MKCATPAGES:tl} != "no" +.for s d in ${MLINKS} +LINKS += ${MANDIR}/cat${s:T:E}${MANSUBDIR}/${s:R}.0${MCOMPRESSSUFFIX} \ + ${MANDIR}/cat${d:T:E}${MANSUBDIR}/${d:R}.0${MCOMPRESSSUFFIX} +UNINSTALLFILES += ${DESTDIR}${MANDIR}/cat${d:T:E}${MANSUBDIR}/${d:R}.0${MCOMPRESSSUFFIX} +.endfor +catlinks: catpages +.endif +catlinks: + +.for s d in ${MLINKS} +LINKS += ${MANDIR}/man${s:T:E}${MANSUBDIR}/${s}${MCOMPRESSSUFFIX} \ + ${MANDIR}/man${d:T:E}${MANSUBDIR}/${d}${MCOMPRESSSUFFIX} +UNINSTALLFILES += ${DESTDIR}${MANDIR}/man${d:T:E}${MANSUBDIR}/${d}${MCOMPRESSSUFFIX} +.endfor +manlinks: manpages + +# Html rules +.PHONY: html +html: ${HTMLPAGES} + +.if defined(HTMLPAGES) && !empty(HTMLPAGES) +.for P in ${HTMLPAGES:O:u} +${DESTDIR}${HTMLDIR}/${P:T:E}/${P:T:R}.html: ${P} + ${MINSTALL} ${.ALLSRC} ${.TARGET} +.endfor + +.if ${MKINSTALL:tl} == "yes" +destination_htmls = ${HTMLPAGES:@P@${DESTDIR}${HTMLDIR}/${P:T:E}/${P:T:R}.html@} +.endif + +installhtml: ${destination_htmls} +CLEANFILES += ${HTMLPAGES} + +.if ${MKHTML:tl} == "yes" +do_install1: installhtml +realdo_all: ${HTMLPAGES} +UNINSTALLFILES += ${destination_htmls} +INSTALLDIRS += ${destination_htmls:H} +.endif # MKHTML +.endif # HTMLPAGES + +.endif # _MKC_IMP_MAN_MK diff --git a/mk/mkc_imp.mk b/mk/mkc_imp.mk new file mode 100644 index 0000000..5a34007 --- /dev/null +++ b/mk/mkc_imp.mk @@ -0,0 +1,161 @@ +# Copyright (c) 2009-2014 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ +.include <mkc_imp.preinit.mk> + +.ifdef SUBDIR +SUBPRJ = ${SUBDIR} +.endif + +.ifdef SUBPRJS +SUBPRJ += ${SUBPRJS} # for backward compatibility only, use SUBPRJ! +.endif # defined(SUBPRJS) + +.include <mkc_imp.lua.mk> +.include <mkc_imp.pod.mk> +.include <mkc.init.mk> + +.ifdef AXCIENT_LIBDEPS # This feature was proposed by axcient.com developers +all_deps != mkc_get_deps ${.CURDIR:S,^${SUBPRJSRCTOP}/,,} +. for p in ${all_deps} +_mkfile = ${SUBPRJSRCTOP}/${p}/linkme.mk +. if exists(${_mkfile}) +. include "${_mkfile}" +. endif +DPLDADD ?= ${p:T:S/^lib//} +DPLIBDIRS ?= ${OBJDIR_${p:S,/,_,g}} +DPINCDIRS ?= ${SRCDIR_${p:S,/,_,g}} ${OBJDIR_${p:S,/,_,g}} +. include <mkc_imp.dpvars.mk> +. endfor +.endif + +.ifdef DPLIBDIRS +.warning "This way of using DPLIBDIRS is deprecated since 2014-08-21" +_DPLIBDIRS := ${DPLIBDIRS} +. for _dir in ${_DPLIBDIRS} +DPLIBDIRS = ${OBJDIR_${_dir:S,^${SUBPRJSRCTOP}/,,:S,/,_,g}} +. include <mkc_imp.dpvars.mk> +. endfor +. undef _DPLIBDIRS +. undef DPLIBDIRS +.endif + +.if defined(LIBDEPS) +SUBPRJ += ${LIBDEPS} # library dependencies +AXCIENT_LIBDEPS := ${LIBDEPS} +EXPORT_VARNAMES += AXCIENT_LIBDEPS +.endif # defined(LIBDEPS) + +.if !defined(LIB) && !defined(SUBPRJ) +_use_prog := 1 +.endif + +.ifdef FOREIGN +.include <mkc_imp.foreign_${FOREIGN}.mk> +.endif +.include <mkc_imp.rules.mk> +.include <mkc_imp.obj.mk> + +# Make sure all of the standard targets are defined, even if they do nothing. +do_install1 do_install2: .PHONY + +distclean: .PHONY cleandir + +.if ${MKINSTALLDIRS:tl} == "yes" +install: pre_installdirs .WAIT do_installdirs .WAIT post_installdirs .WAIT \ + pre_install .WAIT do_install .WAIT post_install +.endif + +realdo_install: do_install1 .WAIT do_install2 + +# skip uninstalling files and creating destination dirs for mkc.subprj.mk +.if !defined(SUBPRJ) + +realdo_uninstall: + -${UNINSTALL} ${UNINSTALLFILES} + +realdo_installdirs: + for d in _ ${INSTALLDIRS:O:u:S|/.$||}; do \ + test "$$d" = _ || ${INSTALL} -d -m ${DIRMODE} "$$d"; \ + done + +filelist: + @for d in ${UNINSTALLFILES:O:u}; do \ + echo $$d; \ + done + +test: + +.endif # SUBPRJ + +########### +.PHONY : print_values +print_values : +.for v in ${VARS} + @printf "%s=%s\n" ${v} ${${v}:Q} +.endfor + +.PHONY : print_values2 +print_values2 : +.for v in ${VARS} + @printf "%s\n" ${${v}:Q} +.endfor + +########### +check_mkc_err_msg: + @if test -n '${MKC_ERR_MSG}'; then \ + for msg in '' ${MKC_ERR_MSG}; do \ + fn=`printf '%s\n' "$$msg" | sed -n 's/^%%%: //p'`; \ + if test -n "$$fn"; then \ + awk '{print "ERROR: " $$0}' "$$fn"; ex=1; \ + elif test -n "$$msg"; then printf '%s\n' "$$msg"; ex=1; \ + fi; \ + done; \ + exit $$ex; \ + fi + +all: pre_errorcheck .WAIT do_errorcheck .WAIT post_errorcheck .WAIT pre_all .WAIT do_all .WAIT post_all +realdo_errorcheck: check_mkc_err_msg + +.include <mkc_imp.checkprogs.mk> +.include <mkc_imp.conf-cleanup.mk> + +# features +.for f in ${MKC_FEATURES} +.include <mkc_imp.f_${f}.mk> +.endfor +.include <mkc_imp.conf-cleanup.mk> +CFLAGS += ${MKC_FEATURES:D-I${FEATURESDIR}} + +.if !defined(MKC_ERR_MSG) || make(clean) || make(cleandir) || make(distclean) + +.if defined(LIB) +.include <mkc_imp.lib.mk> +.elif defined(_use_prog) +.include <mkc_imp.prog.mk> +.endif + +.if defined(_use_prog) || defined(LIB) +.include <mkc_imp.man.mk> +.include <mkc_imp.info.mk> +.include <mkc_imp.inc.mk> +.include <mkc_imp.intexts.mk> +.include <mkc_imp.pkg-config.mk> +.include <mkc_imp.dep.mk> +.include <mkc_imp.files.mk> +.include <mkc_imp.scripts.mk> +.include <mkc_imp.links.mk> +.endif # _use_prog || LIB + +######################################## +.if defined(SUBPRJ) +.include <mkc_imp.subprj.mk> +.endif # SUBPRJ +######################################## + +.include <mkc_imp.arch.mk> + +.endif # MKC_ERR_MSG + +.include <mkc_imp.final.mk> diff --git a/mk/mkc_imp.obj.mk b/mk/mkc_imp.obj.mk new file mode 100644 index 0000000..77d6f44 --- /dev/null +++ b/mk/mkc_imp.obj.mk @@ -0,0 +1,34 @@ +# Copyright (c) 2013 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +.ifndef _MKC_IMP_OBJ_MK +_MKC_IMP_OBJ_MK := 1 + +obj: # ensure existence + +.ifdef MAKEOBJDIRPREFIX +__objdir := ${MAKEOBJDIRPREFIX}${.CURDIR} +.elif defined(MAKEOBJDIR) +__objdir := ${MAKEOBJDIR} +.endif # defined(MAKEOBJDIRPREFIX) + +.if defined(__objdir) + +.if ${MKOBJDIRS:tl} == "yes" +.if !defined(SUBPRJ) +obj: + @${MKDIR} -p ${__objdir} +.endif # !defined(SUBPRJ) +.elif ${MKOBJDIRS:tl} == "auto" && !exists(${__objdir}/) +__objdir_made != if ${MKDIR} -p ${__objdir}; then echo 1; else echo 0; fi + +.if !${__objdir_made} +.error could not create ${__objdir} +.endif # ${__objdir_made} + +.endif # MKOBJDIRS + +.endif # defined(__objdir)... +.endif # _MKC_IMP_OBJ_MK diff --git a/mk/mkc_imp.objdir.mk b/mk/mkc_imp.objdir.mk new file mode 100644 index 0000000..8e8636a --- /dev/null +++ b/mk/mkc_imp.objdir.mk @@ -0,0 +1,42 @@ +# Copyright (c) 2012 by Aleksey Cheusov +# +# See LICENSE file in the distribution. + +.if !defined(_MKC_IMP_OBJDIR_MK) +_MKC_IMP_OBJDIR_MK := 1 + +.if ${:!if test -d ${.CURDIR}/obj.${MACHINE}; then echo 1; else echo 0; fi!} + _OBJ_MACHINE_DIR := 1 +.elif ${:!if test -d ${.CURDIR}/obj; then echo 1; else echo 0; fi!} + _OBJ_DIR := 1 +.endif + +.for i in ${__REALSUBPRJ} +j:=${i:S,/,_,g} +.if empty(j:U:M*[.]*) +EXPORT_VARNAMES += OBJDIR_${i:S,/,_,g} +. if ${MKRELOBJDIR:tl} == "yes" +OBJDIR_${j} := ${.OBJDIR}/${i} +. elif defined(MAKEOBJDIRPREFIX) +OBJDIR_${j} := ${MAKEOBJDIRPREFIX}${.CURDIR} +. elif defined(MAKEOBJDIR) +OBJDIR_${j} := ${MAKEOBJDIR} +. elif defined(_OBJ_MACHINE_DIR) +OBJDIR_${j} := ${.CURDIR}/obj.${MACHINE} +. elif defined(_OBJ_DIR) +OBJDIR_${j} := ${.CURDIR}/obj +. else +OBJDIR_${j} := ${.CURDIR}/${i} +. endif # MAKEOBJDIRPREFIX... +. if ${SHORTPRJNAME:tl} == "yes" && ${i} != ${j} +OBJDIR_${i:T} := ${OBJDIR_${j}} +EXPORT_VARNAMES += OBJDIR_${i:T} +. endif +.endif + +.endfor # i + +.undef _OBJ_MACHINE_DIR +.undef _OBJ_DIR + +.endif # _MKC_IMP_OBJDIR_MK diff --git a/mk/mkc_imp.pkg-config.mk b/mk/mkc_imp.pkg-config.mk new file mode 100644 index 0000000..8edd88b --- /dev/null +++ b/mk/mkc_imp.pkg-config.mk @@ -0,0 +1,80 @@ +# Copyright (c) 2009-2014 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +.if defined(PKG_CONFIG_DEPS) # PKG_CONFIG_DEPS -- deprecated 2014.01.15 +MKC_REQUIRE_PKGCONFIG += ${PKG_CONFIG_DEPS} +.endif +.if defined(MKC_REQUIRE_PKGCONFIG) +MKC_CHECK_PKGCONFIG += ${MKC_REQUIRE_PKGCONFIG} +.endif + +.if defined(MKC_CHECK_PKGCONFIG) && !make(clean) && !make(cleandir) && !make(distclean) +MKC_REQUIRE_PROGS+= pkg-config +.include <mkc_imp.conf-cleanup.mk> + +.if ${HAVE_PROG.pkg-config} + +.for l in ${MKC_CHECK_PKGCONFIG:O:u} +_lpair = ${l:C/(>=|<=|=|>|<)/ & /g} +_id = ${_lpair:[1]} +_pcname = ${PCNAME.${_id:S/-/_/g:S/+/p/g:S/./_/g}:U${_id}} +_lp := ${_pcname} ${_lpair:[2]} ${_lpair:[3]} +_ln = ${l:S/>=/_ge_/:S/>/_gt_/:S/<=/_le_/:S/</_lt_/:S/=/_eq_/} + +PKG_CONFIG.exists.${_ln} != env ${mkc.environ} mkc_check_custom \ + -p pkgconfig -s -n '${_ln}' -m '[pkg-config] ${_lp}' \ + ${PROG.pkg-config} --print-errors --exists "${_lp}" + +.if ${PKG_CONFIG.exists.${_ln}} +# --cflags and --libs +.if defined(PROGS) || defined(LIB) +.if !defined(CPPFLAGS.pkg-config.${_ln}) +CPPFLAGS.pkg-config.${_ln} != env ${mkc.environ} mkc_check_custom \ + -p pkgconfig -n '${_ln}_cflags' -m '[pkg-config] ${_lp} --cflags' \ + ${PROG.pkg-config} --cflags "${_lp}" +.endif # CPPFLAGS.pkg-config.${l} + +.if !defined(LDADD.pkg-config.${_ln}) +LDADD.pkg-config.${_ln} != env ${mkc.environ} mkc_check_custom \ + -p pkgconfig -n '${_ln}_libs' -m '[pkg-config] ${_lp} --libs' \ + ${PROG.pkg-config} --libs "${_lp}" +.endif # LDADD.pkg-config.${l} + +MKC_CPPFLAGS := ${MKC_CPPFLAGS} ${CPPFLAGS.pkg-config.${_ln}} +MKC_LDADD := ${MKC_LDADD} ${LDADD.pkg-config.${_ln}} +.endif # PROGS || LIB + +.for i in ${PKG_CONFIG_VARS.${_ln}} +.if !defined(PKG_CONFIG.var.${_ln}.${i}) +PKG_CONFIG.var.${_ln}.${i} != env ${mkc.environ} mkc_check_custom \ + -p pkgconfig -n '${_ln}_${i}' -m '[pkg-config] ${_lp} --variable=${i}' \ + ${PROG.pkg-config} --variable=${i} "${_lp}" +.endif # PKG_CONFIG.var.${_ln}.${i} +.endfor # i + +MKC_CFLAGS := ${MKC_CFLAGS} -DHAVE_PKGCONFIG_${_id:S/-/_/g:S/+/P/g:S/./_/g}=1 + +.elif !empty(MKC_REQUIRE_PKGCONFIG:M${l}) +MKC_ERR_MSG := ${MKC_ERR_MSG} "%%%: ${MKC_CACHEDIR}/_mkc_pkgconfig_${_ln}.err" +.endif # PKG-CONFIG.exists + +.endfor # .for l in MKC_CHECK_PKGCONFIG + +###################################################### +.include <mkc_imp.conf-final.mk> + +.undef PKG_CONFIG_DEPS +.undef MKC_CHECK_PKGCONFIG +.undef MKC_REQUIRE_PKGCONFIG + +.undef _lpair +.undef _id +.undef _pcname +.undef _lp +.undef _ln + +.endif # HAVE_PROG.pkg-config + +.endif # !make(clean) && !make(cleandir) && !make(distclean) diff --git a/mk/mkc_imp.platform.sys.mk b/mk/mkc_imp.platform.sys.mk new file mode 100644 index 0000000..7fb81c4 --- /dev/null +++ b/mk/mkc_imp.platform.sys.mk @@ -0,0 +1,487 @@ +# Copyright (c) 2009-2010 by Aleksey Cheusov +# Copyright (c) 1994-2009 The NetBSD Foundation, Inc. +# Copyright (c) 1988, 1989, 1993 The Regents of the University of California +# Copyright (c) 1988, 1989 by Adam de Boor +# Copyright (c) 1989 by Berkeley Softworks +# +# See LICENSE file in the distribution. +############################################################ + +.ifndef _MKC_PLATFORM_MK +_MKC_PLATFORM_MK := 1 + +#################### +# cross tools +.ifdef SYSROOT +CFLAGS.sysroot ?= --sysroot=${SYSROOT} +LDFLAGS.sysroot ?= --sysroot=${SYSROOT} +CFLAGS += ${CFLAGS.sysroot} +LDFLAGS0 += ${LDFLAGS.sysroot} + +TOOLCHAIN_PREFIX ?= ${MACHINE_GNU_PLATFORM}- +TOOLCHAIN_DIR ?= ${TOOLDIR}/bin + +NM = ${TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}nm +#ADDR2LINE = ${TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}addr2line +AR = ${TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}ar +AS = ${TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}as +CXX = ${TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}g++ +CPP = ${TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}cpp +CC = ${TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}gcc +INSTALL = ${TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}install +LD = ${TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}ld +OBJCOPY = ${TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}objcopy +OBJDUMP = ${TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}objdump +RANLIB = ${TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}ranlib +#READELF = ${TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}readelf +SIZE = ${TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}size +#STRINGS = ${TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}strings +STRIP = ${TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}strip +.endif + +#################### +SHLIB_EXT.Darwin = .dylib +SHLIB_EXT.HP-UX = .sl + +SHLIB_EXT ?= ${SHLIB_EXT.${TARGET_OPSYS}:U.so} + +DLL_EXT.Darwin = .bundle +DLL_EXT ?= ${DLL_EXT.${TARGET_OPSYS}:U${SHLIB_EXT}} + +#################### +INSTALL.NetBSD = /usr/bin/install +INSTALL.OpenBSD = /usr/bin/install +INSTALL.FreeBSD = /usr/bin/install +INSTALL.DragonFly = /usr/bin/install +INSTALL.MirBSD = /usr/bin/install +INSTALL.Haiku = /bin/install + +INSTALL ?= ${INSTALL.${TARGET_OPSYS}:Umkc_install} + +# The following line is for debugging only +#INSTALL= mkc_install + +#################### + +CC.SunOS = cc +CXX.SunOS = CC + +CPP.SunOS = ${CC} -E + +CC.UnixWare = gcc +CXX.UnixWare = g++ +CPP.UnixWare = ${CC} -E + +CC.OSF1 = gcc +CXX.OSF1 = g++ +CPP.OSF1 = ${CC} -E + +CC.Interix = gcc +CXX.Interix = g++ +CPP.Interix = cpp + +CC.IRIX64 = cc +CXX.IRIX64 = CC +CPP.IRIX64 = ${CC} -E + +CC.QNX = gcc +CXX.QNX = g++ +CPP.QNX = ${CC} -E + +CPP.AIX = ${CC} -E + +CC ?= ${CC.${TARGET_OPSYS}:Ucc} +CXX ?= ${CXX.${TARGET_OPSYS}:Uc++} +CPP ?= ${CPP.${TARGET_OPSYS}:Ucpp} + +#################### +CPPFLAGS.Interix = -D_ALL_SOURCE +CPPFLAGS.UnixWare = -DUNIXWARE + +CPPFLAGS += ${CPPFLAGS.${TARGET_OPSYS}:U} + +############################################################ +# CC compiler type +.if make(cleandir) || make(distclean) || make(clean) +.elif ${MKCHECKS:Uno:tl} == "yes" && !defined(CC_TYPE) && (defined(PROGS) || defined(LIB) || defined(MKC_CHECK_PROTOTYPES)) +mkc.cc_type.environ = CC='${CC}' CXX='${CXX}' CPPFLAGS='${CPPFLAGS}' CFLAGS='${CFLAGS}' LDFLAGS='${LDFLAGS}' LDADD='${LDADD}' MKC_CACHEDIR='${MKC_CACHEDIR}' MKC_DELETE_TMPFILES='${MKC_DELETE_TMPFILES}' MKC_SHOW_CACHED='${MKC_SHOW_CACHED}' MKC_NOCACHE='${MKC_NOCACHE}' MKC_VERBOSE=1 +.if !empty(src_type:Mc) +CC_TYPE != env ${mkc.cc_type.environ} mkc_check_compiler +.endif +.if !empty(src_type:Mcxx) +CXX_TYPE != env ${mkc.cc_type.environ} mkc_check_compiler -x +.endif # src_type +.endif # cleandir|distclean|... + +CC_TYPE ?= unknown +CXX_TYPE ?= unknown + +#################### +# Default compiler-specific options + +# C +CFLAGS.dflt.clang = -Qunused-arguments +CFLAGS.dflt.icc = -we147 # 147 is required for MKC_CHECK_PROTOTYPES + +CFLAGS += ${CFLAGS.dflt.${CC_TYPE}} + +# C++ +CXXFLAGS.dflt.clang = ${CFLAGS.dflt.clang} +CXXFLAGS.dflt.icc = -we147 + +CXXFLAGS += ${CXXFLAGS.dflt.${CXX_TYPE}} + +#################### +# Warnings as error +CFLAGS.warnerr.gcc = -Werror +CFLAGS.warnerr.icc = -Werror +CFLAGS.warnerr.sunpro = -errwarn=%all +CFLAGS.warnerr.clang = -Werror + +#WARNERR?= ${${WARNS:U0}==4:?yes:no} # Eh, buggy bmake :-( +.if ${WARNS:U0} == 4 +WARNERR ?= yes +.else +WARNERR ?= no +.endif + +.if ${WARNERR:tl} == "yes" +CFLAGS.warnerr = ${CFLAGS.warnerr.${CC_TYPE}} +CXXFLAGS.warnerr = ${CFLAGS.warnerr.${CXX_TYPE}} +.endif + +#################### +# C warns for GCC +CFLAGS.warns.gcc.1 = -Wall -Wstrict-prototypes -Wmissing-prototypes \ + -Wpointer-arith +CFLAGS.warns.gcc.2 = ${CFLAGS.warns.gcc.1} -Wreturn-type -Wswitch -Wshadow +CFLAGS.warns.gcc.3 = ${CFLAGS.warns.gcc.2} -Wcast-qual -Wwrite-strings \ + -Wno-unused-parameter +CFLAGS.warns.gcc.4 = ${CFLAGS.warns.gcc.3} + +# C++ warns +CXXFLAGS.warns.gcc.1 = -Wabi -Wold-style-cast -Wctor-dtor-privacy \ + -Wnon-virtual-dtor -Wreorder -Wno-deprecated \ + -Wno-non-template-friend -Woverloaded-virtual \ + -Wno-pmf-conversions -Wsign-promo -Wsynth +CXXFLAGS.warns.gcc.2 = ${CXXFLAGS.warns.gcc.1} -Wreturn-type -Wswitch -Wshadow +CXXFLAGS.warns.gcc.3 = ${CXXFLAGS.warns.gcc.2} -Wcast-qual -Wwrite-strings \ + -Wno-unused-parameter +CXXFLAGS.warns.gcc.4 = ${CXXFLAGS.warns.gcc.3} + +#################### +# C warns for ICC +CFLAGS.warns.icc.1 = -Wall -we1011 +CFLAGS.warns.icc.2 = ${CFLAGS.warns.icc.1} +CFLAGS.warns.icc.3 = ${CFLAGS.warns.icc.2} +CFLAGS.warns.icc.4 = ${CFLAGS.warns.icc.3} + +# C++ warns +CXXFLAGS.warns.icc.1 = ${CFLAGS.warns.icc.1} +CXXFLAGS.warns.icc.2 = ${CFLAGS.warns.icc.2} +CXXFLAGS.warns.icc.3 = ${CFLAGS.warns.icc.3} +CXXFLAGS.warns.icc.4 = ${CFLAGS.warns.icc.4} + +#################### +# C warns for clang +CFLAGS.warns.clang.1 = -Wall +CFLAGS.warns.clang.2 = ${CFLAGS.warns.clang.1} +CFLAGS.warns.clang.3 = ${CFLAGS.warns.clang.2} +CFLAGS.warns.clang.4 = ${CFLAGS.warns.clang.3} + +CXXFLAGS.warns.clang.1 = ${CFLAGS.warns.clang.1} +CXXFLAGS.warns.clang.2 = ${CFLAGS.warns.clang.2} +CXXFLAGS.warns.clang.3 = ${CFLAGS.warns.clang.3} +CXXFLAGS.warns.clang.4 = ${CFLAGS.warns.clang.4} + +#################### +# C warns for HP-UX +CFLAGS.warns.hpc.0 = -w3 +CFLAGS.warns.hpc.1 = -w2 +CFLAGS.warns.hpc.2 = -w2 +CFLAGS.warns.hpc.3 = -w2 +CFLAGS.warns.hpc.4 = -w2 + +# C++ warns +CXXFLAGS.warns.hpc.0 = ${CFLAGS.warns.hpc.0} +CXXFLAGS.warns.hpc.1 = ${CFLAGS.warns.hpc.1} +CXXFLAGS.warns.hpc.2 = ${CFLAGS.warns.hpc.2} +CXXFLAGS.warns.hpc.3 = ${CFLAGS.warns.hpc.3} +CXXFLAGS.warns.hpc.4 = ${CFLAGS.warns.hpc.4} + +#################### + +CFLAGS.warns = ${CFLAGS.warns.${CC_TYPE}.${WARNS}} ${CFLAGS.warnerr} +CXXFLAGS.warns = ${CXXFLAGS.warns.${CXX_TYPE}.${WARNS}} ${CXXFLAGS.warnerr} + +#################### +CFLAGS.pic.gcc.Interix = +CFLAGS.pic.gcc = -fPIC -DPIC +CFLAGS.pic.icc = -fPIC -DPIC +CFLAGS.pic.clang = -fPIC -DPIC +CFLAGS.pic.pcc = -k -DPIC +CFLAGS.pic.mipspro = -KPIC +CFLAGS.pic.sunpro = -xcode=pic32 # -KPIC +CFLAGS.pic.hpc = +Z # +z +CFLAGS.pic.ibmc = -qpic=large # -qpic=small +CFLAGS.pic.decc = # ? + +CFLAGS.pic ?= ${CFLAGS.pic.${CC_TYPE}.${TARGET_OPSYS}:U${CFLAGS.pic.${CC_TYPE}:U}} +CXXFLAGS.pic ?= ${CFLAGS.pic.${CXX_TYPE}.${TARGET_OPSYS}:U${CFLAGS.pic.${CXX_TYPE}:U}} + +#################### +CFLAGS.pie.gcc.Interix = +CFLAGS.pie.gcc = -fPIE -DPIC +CFLAGS.pie.icc = -fPIE -DPIC +CFLAGS.pie.clang = -fPIE -DPIC + +CFLAGS.pie ?= ${CFLAGS.pie.${CC_TYPE}.${TARGET_OPSYS}:U${CFLAGS.pie.${CC_TYPE}}:U${CFLAGS.pic}} +CXXFLAGS.pie ?= ${CFLAGS.pie.${CC_TYPE}.${TARGET_OPSYS}:U${CFLAGS.pie.${CXX_TYPE}}:U${CXXFLAGS.pic}} + +#################### +CFLAGS.ssp.gcc = -fstack-protector -Wstack-protector --param ssp-buffer-size=1 +CFLAGS.ssp.icc = -fstack-security-check +CFLAGS.ssp.ibmc = -qstackprotect +CFLAGS.ssp.clang = ${CFLAGS.ssp.gcc} + +CFLAGS.ssp ?= ${CFLAGS.ssp.${CC_TYPE}.${TARGET_OPSYS}:U${CFLAGS.ssp.${CC_TYPE}:U}} +CXXFLAGS.ssp ?= ${CFLAGS.ssp.${CXX_TYPE}.${TARGET_OPSYS}:U${CFLAGS.ssp.${CXX_TYPE}:U}} + +#################### +RANLIB.IRIX64 = true + +RANLIB ?= ${RANLIB.${TARGET_OPSYS}:Uranlib} + +#################### +NROFF_MAN2CAT.SunOS ?= -man +NROFF_MAN2CAT.HP-UX ?= -man +NROFF_MAN2CAT.OSF1 ?= -man + +NROFF_MAN2CAT ?= ${NROFF_MAN2CAT.${OPSYS}:U-mandoc -Tascii} + +#################### +LD_TYPE.UnixWare = scold +LD_TYPE.AIX = aixld +LD_TYPE.HP-UX = hpld +LD_TYPE.SunOS = sunld +LD_TYPE.Darwin = darwinld +LD_TYPE.Interix = interixld +LD_TYPE.OSF1 = osf1ld +LD_TYPE.IRIX64 = irixld + +LD_TYPE ?= ${LD_TYPE.${TARGET_OPSYS}:Ugnuld} + +#################### +OBJECT_FMT ?= ELF + +#################### +LDFLAGS.shared.sunld = -G +LDFLAGS.soname.sunld = -h lib${LIB}.so.${SHLIB_MAJOR} + +LDFLAGS.shared.darwinld = -dylib +LDFLAGS.soname.darwinld = # + +LDFLAGS.shared.gnuld = -shared +LDFLAGS.soname.gnuld = -soname lib${LIB}${SHLIB_EXT}.${SHLIB_MAJOR} + +LDFLAGS.shared.hpld = -b +b ${LIBDIR} +LDFLAGS.soname.hpld = +h lib${LIB}.sl.${SHLIB_MAJOR} + +LDFLAGS.shared.aixld = -G +LDFLAGS.soname.aixld = # + +LDFLAGS.shared.irixld = -shared +LDFLAGS.soname.irixld = # + +LDFLAGS.shared.osf1ld = -shared -msym -expect_unresolved '*' +LDFLAGS.soname.osf1ld = -soname lib${LIB}${SHLIB_EXT}.${SHLIB_MAJOR} \ + -set_version ${SHLIB_MAJOR}.${SHLIB_MINOR} \ + -update_registry ${.OBJDIR}/${LIB}_so_locations + +LDFLAGS.shared.irixld = -shared +LDFLAGS.soname.irixld = -soname lib${LIB}${SHLIB_EXT}.${SHLIB_MAJOR} + +LDFLAGS.shared.interixld = -shared --image-base,`expr $${RANDOM-$$$$} % 4096 / 2 \* 262144 + 1342177280` +LDFLAGS.soname.interixld = -h lib${LIB}${SHLIB_EXT}.${SHLIB_MAJOR} + +LDFLAGS.shared.gcc.Interix = -shared --image-base,`expr $${RANDOM-$$$$} % 4096 / 2 \* 262144 + 1342177280` +LDFLAGS.shared.gcc = -shared +LDFLAGS.shared.clang = -shared +LDFLAGS.shared.pcc = -shared +LDFLAGS.shared.icc = -shared +LDFLAGS.shared.hpc = -b +LDFLAGS.shared.imbc = -qmkshrobj +LDFLAGS.shared.mipspro = -shared +LDFLAGS.shared.sunpro = -G +LDFLAGS.shared.decc = -shared + +LDFLAGS.soname.sunpro = ${LDFLAGS.soname.sunld} + +.if ${TARGET_OPSYS:Unone} == "Darwin" +.if ${MKDLL:U} == "no" +LDFLAGS.shared.gcc.Darwin = -dynamiclib -install_name ${LIBDIR}/lib${LIB}${SHLIB_EXTFULL} +LDFLAGS.shared.clang.Darwin = -dynamiclib -install_name ${LIBDIR}/lib${LIB}${SHLIB_EXTFULL} +SHLIB_MAJORp1 != expr 1 + ${SHLIB_MAJOR:U0} +LDFLAGS.soname.gcc = -current_version ${SHLIB_MAJORp1}${SHLIB_MINOR:D.${SHLIB_MINOR}}${SHLIB_TEENY:D.${SHLIB_TEENY}} +LDFLAGS.soname.gcc += -compatibility_version ${SHLIB_MAJORp1} +.else +LDFLAGS.shared.gcc.Darwin = -flat_namespace -bundle -undefined suppress +LDFLAGS.shared.clang.Darwin = -flat_namespace -bundle -undefined suppress +.endif +.elif ${TARGET_OPSYS:Unone} == "OSF1" && defined(LIB) +CLEANFILES += ${.OBJDIR}/${LIB}_so_locations +.endif + +CFLAGS.cctold ?= ${CFLAGS.cctold.${CC_TYPE}:U-Wl,} +CXXFLAGS.cctold ?= ${CFLAGS.cctold.${CXX_TYPE}:U-Wl,} + +LDFLAGS.soname.ld = ${LDFLAGS.soname.${LD_TYPE}:U} + +.if ${LDREAL:U0} == ${LD:U0} +LDFLAGS.shared ?= ${LDFLAGS.shared.${LD_TYPE}:U-shared} +LDFLAGS.soname ?= ${LDFLAGS.soname.ld} +.elif ${LDREAL:U0} == ${CC:U0} +LDFLAGS.shared ?= ${LDFLAGS.shared.${CC_TYPE}.${TARGET_OPSYS}:U${LDFLAGS.shared.${CC_TYPE}:U-shared}} +LDFLAGS.soname ?= ${LDFLAGS.soname.${CC_TYPE}:U${LDFLAGS.soname.ld:@v@${CFLAGS.cctold}${v}@}} +.elif ${LDREAL:U0} == ${CXX:U0} +LDFLAGS.shared ?= ${LDFLAGS.shared.${CXX_TYPE}.${TARGET_OPSYS}:U${LDFLAGS.shared.${CXX_TYPE}:U-shared}} +LDFLAGS.soname ?= ${LDFLAGS.soname.${CXX_TYPE}:U${LDFLAGS.soname.ld:@v@${CXXFLAGS.cctold}${v}@}} +.endif + +#################### +LDFLAGS.pie.gcc = -pie + +.if ${LDREAL:U0} == ${CC:U0} +LDFLAGS.pie ?= ${LDFLAGS.pie.${CC_TYPE}} +.elif ${LDREAL:U0} == ${CXX:U0} +LDFLAGS.pie ?= ${LDFLAGS.pie.${CXX_TYPE}} +.endif +#################### +LDFLAGS.relro.gnuld = -zrelro -znow + +LDFLAGS.relro ?= ${LDFLAGS.relro.${LD_TYPE}} + +#################### +.if ${LDREAL:U0} != ${LD:U0} +.if !empty(LDFLAGS.relro) +LDFLAGS.relro := ${LDFLAGS.relro:S/^/-Wl,/g} +.endif +.endif + +############################################################ +############################################################ +.if ${TARGET_OPSYS:Unone} == "Darwin" + +COMPILE.s ?= ${AS} ${AFLAGS} +COMPILE.S ?= ${CC} ${AFLAGS} ${_CPPFLAGS} -c + +.if ${MKDLL:U} != "no" + +SHLIB_EXTFULL ?= .bundle + +.else # MKDLL + +.if defined(SHLIB_MAJOR) && !empty(SHLIB_MAJOR) +SHLIB_EXT1 ?= .${SHLIB_MAJOR}.dylib +.if defined(SHLIB_MINOR) && !empty(SHLIB_MINOR) +SHLIB_EXT2 ?= .${SHLIB_MAJOR}.${SHLIB_MINOR}.dylib +.if defined(SHLIB_TEENY) && !empty(SHLIB_TEENY) +SHLIB_EXT3 ?= .${SHLIB_FULLVERSION}.dylib +SHLIB_FULLVERSION = ${SHLIB_MAJOR}.${SHLIB_MINOR}.${SHLIB_TEENY} +.else +SHLIB_FULLVERSION = ${SHLIB_MAJOR}.${SHLIB_MINOR} +.endif # SHLIB_TEENY +.else +SHLIB_FULLVERSION = ${SHLIB_MAJOR} +.endif # SHLIB_MINOR +.endif # SHLIB_MAJOR + +SHLIB_EXTFULL ?= .${SHLIB_FULLVERSION}.dylib +.endif + +.endif # Darwin! + +############################################################ +############################################################ + +.if ${SHLIB_EXT:U} == ".so" || ${SHLIB_EXT:U} == ".sl" + +.if defined(SHLIB_MAJOR) && !empty(SHLIB_MAJOR) +SHLIB_EXT1 = ${SHLIB_EXT}.${SHLIB_MAJOR} +.if defined(SHLIB_MINOR) && !empty(SHLIB_MINOR) +SHLIB_EXT2 = ${SHLIB_EXT}.${SHLIB_MAJOR}.${SHLIB_MINOR} +.if defined(SHLIB_TEENY) && !empty(SHLIB_TEENY) +SHLIB_FULLVERSION=${SHLIB_MAJOR}.${SHLIB_MINOR}.${SHLIB_TEENY} +SHLIB_EXT3 = ${SHLIB_EXT}.${SHLIB_FULLVERSION} +.else +SHLIB_FULLVERSION = ${SHLIB_MAJOR}.${SHLIB_MINOR} +.endif # SHLIB_TEENY +.else +SHLIB_FULLVERSION = ${SHLIB_MAJOR} +.endif # SHLIB_MINOR +.endif # SHLIB_MAJOR + +SHLIB_EXTFULL = ${SHLIB_EXT}.${SHLIB_FULLVERSION} + +.endif # SHLIB_EXT + +############################################################ +############################################################ + +.ifdef EXPORT_SYMBOLS +.if ${LD_TYPE} == "sunld" || ${LD_TYPE} == "gnuld" +CLEANFILES += ${EXPORT_SYMBOLS}.tmp +lib${LIB}${SHLIB_EXTFULL}: ${EXPORT_SYMBOLS}.tmp +${EXPORT_SYMBOLS}.tmp: ${EXPORT_SYMBOLS} + awk 'BEGIN {print "{ global:"} \ + {print $$0 ";"} \ + END {print "local: *; };"}' ${.ALLSRC} > ${.TARGET} +.elif ${LD_TYPE} == "darwinld" +CLEANFILES += ${EXPORT_SYMBOLS}.tmp +lib${LIB}${SHLIB_EXTFULL}: ${EXPORT_SYMBOLS}.tmp +${EXPORT_SYMBOLS}.tmp: ${EXPORT_SYMBOLS} + awk '{print "_" $$0}' ${.ALLSRC} > ${.TARGET} +.endif # sunld or darwinld + +LDFLAGS.expsym.gnuld = --version-script ${EXPORT_SYMBOLS}.tmp +LDFLAGS.expsym.sunld = -M ${EXPORT_SYMBOLS}.tmp +LDFLAGS.expsym.darwinld = -exported_symbols_list ${EXPORT_SYMBOLS}.tmp +.endif # EXPORT_SYMBOLS + +.if ${LDREAL:U0} == ${LD:U0} +LDFLAGS.expsym ?= ${LDFLAGS.expsym.${LD_TYPE}} +.elif defined(LDFLAGS.expsym.${LD_TYPE}) +LDFLAGS.expsym ?= ${LDFLAGS.expsym.${LD_TYPE}:S/^/-Wl,/} +.endif # LDREAL == LD + +############################################################ +############################################################ + +.if ${EXPORT_DYNAMIC:U:tl} == "yes" +LDFLAGS.expdyn.gnuld ?= -Wl,-E +LDFLAGS.expdyn.hpld ?= -Wl,-E +LDFLAGS.expdyn.interixld ?= -Wl,-E +LDFLAGS.expdyn.darwinld ?= +LDFLAGS.expdyn.irixld ?= +LDFLAGS.expdyn.gcc ?= -rdynamic +LDFLAGS.expdyn.clang ?= -rdynamic +.ifndef LDFLAGS.expdyn +.if defined(LDFLAGS.expdyn.${LD_TYPE}) +LDFLAGS.expdyn = ${LDFLAGS.expdyn.${LD_TYPE}} +.elif defined(LDFLAGS.expdyn.${CC_TYPE}) && ${LDREAL:U0} == ${CC:U0} +LDFLAGS.expdyn = ${LDFLAGS.expdyn.${CC_TYPE}} +.elif defined(LDFLAGS.expdyn.${CXX_TYPE}) && ${LDREAL:U0} == ${CXX:U0} +LDFLAGS.expdyn = ${LDFLAGS.expdyn.${CXX_TYPE}} +.endif # LDFLAGS.expdyn.xxx +.endif # LDFLAGS.expdyn +.endif # EXPORT_DYNAMIC + +############################################################ +############################################################ + +LDFLAGS.shlib = ${LDFLAGS.shared} ${LDFLAGS.soname} ${LDFLAGS.expsym} +LDFLAGS.prog = ${LDFLAGS.expdyn} +############################################################ +############################################################ + +.endif #_MKC_PLATFORM_MK diff --git a/mk/mkc_imp.pod.mk b/mk/mkc_imp.pod.mk new file mode 100644 index 0000000..5a4fb32 --- /dev/null +++ b/mk/mkc_imp.pod.mk @@ -0,0 +1,34 @@ +# Copyright (c) 2010-2013 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +.if !defined(_MKC_IMP_POD_MK) +_MKC_IMP_POD_MK := 1 + +POD2MAN ?= pod2man +POD2MAN_FLAGS := -r '' -n '${.TARGET:T:R}' -c '' +MESSAGE.pod2man ?= @${_MESSAGE} "POD2MAN: ${.TARGET}" +COMPILE.pod2man ?= ${_V} ${POD2MAN} ${POD2MAN_FLAGS} + +POD2HTML ?= pod2html +POD2HTML_FLAGS ?= +MESSAGE.pod2html ?= @${_MESSAGE} "POD2HTML: ${.TARGET}" +COMPILE.pod2html ?= ${_V} ${POD2HTML} ${POD2HTML_FLAGS} + +.SUFFIXES: .pod +.for i in 1 2 3 4 5 6 7 8 9 +.SUFFIXES: .${i} +.pod.${i}: + ${MESSAGE.pod2man} + ${COMPILE.pod2man} -s ${i} ${.IMPSRC} > ${.TARGET} +.endfor + +.SUFFIXES: .html +.pod.html: + ${MESSAGE.pod2html} + ${COMPILE.pod2html} < ${.IMPSRC} > ${.TARGET} + +CLEANFILES += pod2htmd.tmp pod2htmi.tmp + +.endif # _MKC_IMP_POD_MK diff --git a/mk/mkc_imp.preinit.mk b/mk/mkc_imp.preinit.mk new file mode 100644 index 0000000..81cdc1f --- /dev/null +++ b/mk/mkc_imp.preinit.mk @@ -0,0 +1,32 @@ +# Copyright (c) 2010 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ + +#################### +BMAKE_REQD ?= 20110606 + +.ifdef MAKE_VERSION +_bmake_ok != test ${MAKE_VERSION} -ge ${BMAKE_REQD} && echo 1 || echo 0 +.else +_bmake_ok = 0 +.endif + +.if !${_bmake_ok} +.error "bmake-${BMAKE_REQD} or newer is required" +.endif + +.ifdef _top_mk +.for i in SUBDIR SUBPRJ PROG LIB +.if defined(${i}) && ${_top_mk} != "mkc.${i:tl}.mk" +.error "${i} is not allowed for ${_top_mk}" +.endif +.endfor +.endif + +#################### +.if !make(clean) && !make(cleandir) && !make(distclean) && !make(obj) +MKCHECKS ?= yes +.else +MKCHECKS ?= no +.endif # clean/cleandir/distclean diff --git a/mk/mkc_imp.prog.mk b/mk/mkc_imp.prog.mk new file mode 100644 index 0000000..b634564 --- /dev/null +++ b/mk/mkc_imp.prog.mk @@ -0,0 +1,77 @@ +# Copyright (c) 2009-2010 by Aleksey Cheusov +# Copyright (c) 1994-2009 The NetBSD Foundation, Inc. +# Copyright (c) 1988, 1989, 1993 The Regents of the University of California +# Copyright (c) 1988, 1989 by Adam de Boor +# Copyright (c) 1989 by Berkeley Softworks +# +# See LICENSE file in the distribution. +############################################################ + +.if !defined(_MKC_IMP_PROG_MK) +_MKC_IMP_PROG_MK := 1 + +proginstall: .PHONY # ensure existence + +CFLAGS += ${COPTS} + +__proginstall: .USE + ${INSTALL} ${RENAME} ${PRESERVE} ${COPY} ${STRIPFLAG} \ + -o ${BINOWN:Q} -g ${BINGRP:Q} -m ${BINMODE} ${.ALLSRC} ${.TARGET} + +.for p in ${PROGS} +do_install1: proginstall + +_SRCS_ALL += ${SRCS.${p}} + +DPSRCS.${p} = ${SRCS.${p}:M*.l:.l=.c} ${SRCS.${p}:M*.y:.y=.c} +CLEANFILES += ${DPSRCS.${p}} +.if defined(YHEADER) +CLEANFILES += ${SRCS.${p}:M*.y:.y=.h} +.endif # defined(YHEADER) + +OBJS.${p} = ${SRCS.${p}:N*.h:N*.sh:N*.fth:T:R:S/$/.o/g} + +.if !empty(SRCS.${p}:N*.h:N*.sh:M*/*:H) +SRC_PATHADD += ${SRCS:N*.h:N*.sh:M*/*:H} +.endif + +.if defined(OBJS.${p}) && !empty(OBJS.${p}) +.NOPATH: ${OBJS.${p}} + +${p}: ${LIBCRT0} ${DPSRCS.${p}} ${OBJS.${p}} ${LIBC} ${LIBCRTBEGIN} ${LIBCRTEND} ${DPADD} +.if !commands(${p}) + ${MESSAGE.ld} + ${_V}${LDREAL} -o ${.TARGET} ${OBJS.${p}} \ + ${LDFLAGS0} ${LDADD0} \ + ${LDFLAGS} ${LDFLAGS.prog} ${LDADD} +.endif # !commands(...) + +.endif # defined(OBJS.${p}) && !empty(OBJS.${p}) + +.if !defined(MAN) && exists(${p}.1) +MAN += ${p}.1 +.endif # !defined(MAN) + +PROGNAME.${p} ?= ${PROGNAME:U${p}} + +.if ${MKINSTALL:tl} == "yes" +dest_prog.${p} = ${DESTDIR}${BINDIR}/${PROGNAME.${p}} +UNINSTALLFILES += ${dest_prog.${p}} +INSTALLDIRS += ${dest_prog.${p}:H} + +proginstall: ${dest_prog.${p}} +.PRECIOUS: ${dest_prog.${p}} +.PHONY: ${dest_prog.${p}} +.endif # ${MKINSTALL:tl} == "yes" + +${DESTDIR}${BINDIR}/${PROGNAME.${p}}: ${p} __proginstall + +CLEANFILES += ${OBJS.${p}} + +.endfor # ${PROGS} + +realdo_all: ${PROGS} + +CLEANFILES += ${PROGS} + +.endif # _MKC_IMP_PROG_MK diff --git a/mk/mkc_imp.rules.mk b/mk/mkc_imp.rules.mk new file mode 100644 index 0000000..6e5e0cc --- /dev/null +++ b/mk/mkc_imp.rules.mk @@ -0,0 +1,99 @@ +# Copyright (c) 2014 by Aleksey Cheusov +# +# See LICENSE file in the distribution. +############################################################ +.SUFFIXES: .a .o .op .os .s .S .c .cc .cpp .cxx .C .F .f .r .m .y .l .cl .p .h + +.LIBS: .a + +# C + +.c.o: + ${MESSAGE.c} + ${COMPILE.c} ${CPPFLAGS_${_PN}} ${CFLAGS_${_PN}} \ + ${COPTS_${_PN}} -o ${.TARGET} ${.IMPSRC} +.c.op: + ${MESSAGE.c} + ${COMPILE.c} -pg ${CPPFLAGS_${_PN}} ${CFLAGS_${_PN}} \ + ${COPTS_${_PN}} -o ${.TARGET} ${.IMPSRC} +.c.os: + ${MESSAGE.c} + ${COMPILE.c} ${CFLAGS.pic} ${CPPFLAGS_${_PN}} \ + ${CFLAGS_${_PN}} ${COPTS_${_PN}} -o ${.TARGET} ${.IMPSRC} + +# C++ +.cc.o .cpp.o .cxx.o .C.o: + ${MESSAGE.cc} + ${COMPILE.cc} ${CPPFLAGS_${_PN}} ${CXXFLAGS_${_PN}} \ + ${COPTS_${_PN}} -o ${.TARGET} ${.IMPSRC} +.cc.op .C.op .cpp.op: + ${MESSAGE.cc} + ${COMPILE.cc} -pg ${CPPFLAGS_${_PN}} ${CXXFLAGS_${_PN}} \ + ${COPTS_${_PN}} -o ${.TARGET} ${.IMPSRC} +.cc.os .C.os .cpp.os: + ${MESSAGE.cc} + ${COMPILE.cc} ${CXXFLAGS.pic} ${CPPFLAGS_${_PN}} \ + ${CXXFLAGS_${_PN}} ${COPTS_${_PN}} -o ${.TARGET} ${.IMPSRC} + +# Fortran/Ratfor +.f.o: + ${MESSAGE.f} + ${COMPILE.f} ${FFLAGS_${_PN}} -o ${.TARGET} ${.IMPSRC} +.f.op: + ${MESSAGE.f} + ${COMPILE.f} -pg ${FFLAGS_${_PN}} -o ${.TARGET} ${.IMPSRC} +.f.os: + ${MESSAGE.f} + ${COMPILE.f} ${FFLAGS.pic} ${FFLAGS_${_PN}} -o ${.TARGET} ${.IMPSRC} + +#.F: +.F.o: + ${MESSAGE.F} + ${COMPILE.F} -o ${.TARGET} ${.IMPSRC} + +#.r: +.r.o: + ${MESSAGE.r} + ${COMPILE.r} -o ${.TARGET} ${.IMPSRC} + +# Pascal +.p.o: + ${MESSAGE.p} + ${COMPILE.p} -o ${.TARGET} ${.IMPSRC} + +# Assembly +.S.o .s.o: + ${MESSAGE.s} + ${COMPILE.s} -o ${.TARGET} ${.IMPSRC} +.S.op .s.op: + ${MESSAGE.s} + ${COMPILE.s} -o ${.TARGET} -pg ${.IMPSRC} +.S.os .s.os: + ${MESSAGE.s} + ${COMPILE.s} ${CAFLAGS.pic} -o ${.TARGET} ${.IMPSRC} + +# Objective-C +.m.o: + ${MESSAGE.m} + ${COMPILE.m} ${.IMPSRC} +.m.op: + ${MESSAGE.m} + ${COMPILE.m} -pg -o ${.TARGET} ${.IMPSRC} +.m.os: + ${MESSAGE.m} + ${COMPILE.m} ${CMFLAGS.pic} -o ${.TARGET} ${.IMPSRC} + +# Lex +.l.c: + ${MESSAGE.l} + ${LEX.l} -t ${.IMPSRC} > ${.TARGET} + +# Yacc +.y.h: ${.TARGET:R}.c +.y.c: + ${MESSAGE.y} + ${YACC.y} ${.IMPSRC} + ${_V}mv y.tab.c ${.TARGET} +.ifdef YHEADER + ${_V}mv y.tab.h ${.TARGET:R}.h +.endif diff --git a/mk/mkc_imp.scripts.mk b/mk/mkc_imp.scripts.mk new file mode 100644 index 0000000..1d53b48 --- /dev/null +++ b/mk/mkc_imp.scripts.mk @@ -0,0 +1,42 @@ +# Copyright (c) 2009-2014 by Aleksey Cheusov +# Copyright (c) 1994-2009 The NetBSD Foundation, Inc. +# Copyright (c) 1988, 1989, 1993 The Regents of the University of California +# Copyright (c) 1988, 1989 by Adam de Boor +# Copyright (c) 1989 by Berkeley Softworks +# +# See LICENSE file in the distribution. +############################################################ + +.if !defined(_MKC_IMP_SCRIPTS_MK) +_MKC_IMP_SCRIPTS_MK := 1 + +scriptsinstall: .PHONY # ensure existence +do_install1: scriptsinstall + +realdo_all: ${SCRIPTS} + +.if defined(SCRIPTS) +.if ${MKINSTALL:tl} == "yes" +destination_scripts = ${SCRIPTS:@S@${DESTDIR}${SCRIPTSDIR_${S:S|/|_|g}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S:S|/|_|g}:U${SCRIPTSNAME:U${S:T}}}@} +UNINSTALLFILES += ${destination_scripts} +INSTALLDIRS += ${destination_scripts:H} +.endif # MKINSTALL + +scriptsinstall: ${destination_scripts} +.PRECIOUS: ${destination_scripts} +.PHONY: ${destination_scripts} + +__scriptinstall: .USE + ${INSTALL} ${RENAME} ${PRESERVE} ${COPY} \ + -o ${SCRIPTSOWN_${.ALLSRC:T}:U${SCRIPTSOWN}:Q} \ + -g ${SCRIPTSGRP_${.ALLSRC:T}:U${SCRIPTSGRP}:Q} \ + -m ${SCRIPTSMODE_${.ALLSRC:T}:U${SCRIPTSMODE}} \ + ${.ALLSRC} ${.TARGET} + +.for S in ${SCRIPTS:O:u} +${DESTDIR}${SCRIPTSDIR_${S:S|/|_|g}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S:S|/|_|g}:U${SCRIPTSNAME:U${S:T}}}: ${S} __scriptinstall +.endfor + +.endif # defined(SCRIPTS) + +.endif # _MKC_IMP_SCRIPTS_MK diff --git a/mk/mkc_imp.subprj.mk b/mk/mkc_imp.subprj.mk new file mode 100644 index 0000000..73c5649 --- /dev/null +++ b/mk/mkc_imp.subprj.mk @@ -0,0 +1,137 @@ +# Copyright (c) 2010-2013 by Aleksey Cheusov +# Copyright (c) 1994-2009 The NetBSD Foundation, Inc. +# Copyright (c) 1988, 1989, 1993 The Regents of the University of California +# Copyright (c) 1988, 1989 by Adam de Boor +# Copyright (c) 1989 by Berkeley Softworks +# +# See LICENSE file in the distribution. +############################################################ + +.if !defined(_MKC_IMP_SUBPRJ_MK) +_MKC_IMP_SUBPRJ_MK := 1 + +EXPORT_VARNAMES += STATICLIBS COMPATLIB + +.for dir in ${SUBPRJ:S/:/ /g} +.if empty(NOSUBDIR:U:M${dir}) +__REALSUBPRJ += ${dir} +.endif +.endfor + +.for dir in ${NOSUBDIR} +NODEPS += *-${dir}:* *:*-${dir} *-*/${dir}:* *:*-*/${dir} +.endfor +.for dir in ${INTERNALLIBS} +NODEPS += install-${dir}:* install-*/${dir}:* \ + uninstall-${dir}:* uninstall-*/${dir}:* \ + installdirs-${dir}:* installdirs-*/${dir}:* +.endfor + +.ifndef SUBDIR +__REALSUBPRJ := ${__REALSUBPRJ:O:u} +.endif + +.if !empty(__REALSUBPRJ:M*-*) +.error "Dash symbol is not allowed inside subdir (${__REALSUBPRJ:M*-*})" +.endif + +SUBPRJ_DFLT ?= ${__REALSUBPRJ} + +.for targ in ${TARGETS} +.for dir in ${__REALSUBPRJ:N.WAIT} +_ALLTARGDEPS3 += ${targ}-${dir} +.PHONY: nodeps-${targ}-${dir} subdir-${targ}-${dir} ${targ}-${dir} +nodeps-${targ}-${dir}: .MAKE __recurse + ${targ}-${dir}: .MAKE __recurse +subdir-${targ}-${dir}: .MAKE __recurse +.if ${SHORTPRJNAME:tl} == "yes" && ${dir} != ${dir:T} +_ALLTARGDEPS3 += ${targ}-${dir:T} +.PHONY: nodeps-${targ}-${dir:T} subdir-${targ}-${dir:T} ${targ}-${dir:T} +nodeps-${targ}-${dir:T}: nodeps-${targ}-${dir} + ${targ}-${dir:T}: ${targ}-${dir} +subdir-${targ}-${dir:T}: subdir-${targ}-${dir} +_ALLTARGDEPS3 += ${targ}-${dir}:${targ}-${dir:T} +.endif +.endfor # dir + +.if !commands(${targ}) +. for dir in ${SUBPRJ_DFLT} +dir_ = ${dir} +. if ${dir_} == ".WAIT" +_SUBDIR_${targ} += .WAIT +. else +_SUBDIR_${targ} += ${targ}-${dir}:${targ} +. endif # .WAIT +. endfor # dir +.for excl in ${NODEPS} +_SUBDIR_${targ} := ${_SUBDIR_${targ}:N${excl}} +.endfor # excl +_ALLTARGDEPS2 += ${_SUBDIR_${targ}} +${targ}: ${_SUBDIR_${targ}:S/:${targ}$//} +.endif #!command(${targ}) + +.for dep prj in ${SUBPRJ:M*\:*:S/:/ /} +_ALLTARGDEPS += ${targ}-${dep}:${targ}-${prj} +.endfor # dep prj + +.endfor # targ + +.for dir in ${__REALSUBPRJ} +.if ${SHORTPRJNAME:tl} == "yes" && ${dir:T} != ${dir} +SRCDIR_${dir:T} = ${.CURDIR}/${dir} +EXPORT_VARNAMES += SRCDIR_${dir:T} +_ALLTARGDEPS += all-${dir}:${dir:T} +_ALLTARGDEPS3 += ${dir:T} +.endif # .if ${SHORTPRJNAME:tl} == "yes" ... +j:=${dir:S,/,_,g} +.if empty(j:M*[.]*) +SRCDIR_${j} = ${.CURDIR}/${dir} +EXPORT_VARNAMES += SRCDIR_${dir:S,/,_,g} +.endif # .if dir contains . +_ALLTARGDEPS += all-${dir}:${dir} +.endfor # dir + +.for excl in ${NODEPS} +_ALLTARGDEPS := ${_ALLTARGDEPS:N${excl}} +.endfor # excl + +.for deptarg prjtarg in ${_ALLTARGDEPS:S/:/ /} +.PHONY: ${prjtarg} ${deptarg} +${prjtarg}: ${deptarg} +.endfor + +.PHONY: print_deps +print_deps: +.for i in ${_ALLTARGDEPS} ${_ALLTARGDEPS2} ${_ALLTARGDEPS3} ${TARGETS} + @echo ${i:S/:/ /} +.endfor + +__recurse: .USE + @targ=${.TARGET:S/^nodeps-//:C/-.*$//}; \ + dir=${.TARGET:S/^nodeps-//:C/^[^-]*-//}; \ + if ! test -f ${.CURDIR}/$$dir/Makefile; then exit 0; fi; \ + test "$${targ}_${MKINSTALL:tl}" = 'install_no' && exit 0; \ + test "$${targ}_${MKINSTALL:tl}" = 'installdirs_no' && exit 0; \ + ${export_cmd} \ + set -e; \ + ${VERBOSE_ECHO} ================================================== 1>&2;\ + case "$$dir" in /*) \ + ${VERBOSE_ECHO} "$$targ ===> $$dir" 1>&2; \ + cd "$$dir"; \ + env "_THISDIR_=$$dir/" ${MAKE} ${MAKEFLAGS} $$targ; \ + ;; \ + *) \ + ${VERBOSE_ECHO} "$$targ ===> ${_THISDIR_}$$dir" 1>&2; \ + cd "${.CURDIR}/$$dir"; \ + env "_THISDIR_=${_THISDIR_}$$dir/" ${MAKE} ${MAKEFLAGS} $$targ; \ + ;; \ + esac + +########### +SUBPRJSRCTOP = ${.CURDIR} +.export SUBPRJSRCTOP +########### + +.include <mkc_imp.objdir.mk> + +.endif # _MKC_IMP_SUBPRJ_MK diff --git a/mk/mkc_imp.vars.mk.in b/mk/mkc_imp.vars.mk.in new file mode 100644 index 0000000..28af702 --- /dev/null +++ b/mk/mkc_imp.vars.mk.in @@ -0,0 +1,9 @@ +MKC_VERSION = @version@ +BUILTINSDIR ?= @syscustomdir@ +FEATURESDIR ?= @featuresdir@ +MKC_LIBEXECDIR = @libexecdir@ +MKC_SYSCONFDIR = @sysconfdir@ +MKDEP = @mkdep_cmd@ +MKDEP_TYPE = @mkdep_type@ +MAKEDEPEND = @makedepend_cmd@ +NM = @NM@ diff --git a/mk/sys.mk b/mk/sys.mk new file mode 100644 index 0000000..0e6f63e --- /dev/null +++ b/mk/sys.mk @@ -0,0 +1,22 @@ +# +# mk-configure can not know everything about your platform. +# This file is a system-wide default configuration file. +# In addition, @sysconfdir@/etc/mk.conf and /etc/mk.conf +# may be used by system administrator. +# +# Example is below: +# +# CC ?= /usr/bin/cc +# CXX ?= /usr/bin/CC +# YACC ?= /usr/sfw/bin/bison -y +# LEX ?= /usr/sfw/bin/flex +# INSTALL ?= /usr/ucb/install +# STRIP ?= /usr/ccs/bin/strip +# LD ?= /usr/ccs/bin/ld +# AR ?= /usr/ccs/bin/ar +# AS ?= /usr/ccs/bin/as +# LORDER ?= /usr/ccs/bin/lorder +# RANLIB ?= /usr/ccs/bin/ranlib +# LUA_LMODDIR ?= /usr/share/lua/5.1 +# LUA_CMODDIR ?= /usr/lib/lua/5.1 +# ... diff --git a/presentation/Makefile b/presentation/Makefile new file mode 100644 index 0000000..cdafd80 --- /dev/null +++ b/presentation/Makefile @@ -0,0 +1,49 @@ +############################################################ + +MKC_REQUIRE_PROGS = ${PS2PDF} ${DOT} ${DVIPS} ${LATEX} + +############################################################ + +all : presentation.pdf myprojects.pdf + +.PHONY : pdf dvi rtf +pdf : presentation.pdf +ps : presentation.ps +dvi : presentation.dvi + +.SUFFIXES: .ps .eps .pdf .dvi .tex .dot + +presentation.ps presentation.pdf presentation.dvi: my_prjs.eps dep_graph.eps + +.ps.pdf: + ${PROG.${PS2PDF}} "$<" "$@" + +#.tex.pdf: +# pdflatex "$<" && pdflatex "$<" + +.dot.eps: + ${PROG.${DOT}} -Tps ${.IMPSRC} > ${.TARGET} + +.dvi.ps: + ${PROG.${DVIPS}} $< + +.tex.dvi: + ${PROG.${LATEX}} "${.IMPSRC}" && ${PROG.${LATEX}} "${.IMPSRC}" + +.gz: + gzip ${.IMPSRC} + +GARBAGE= *.dvi *.aux *.vrb *.toc *.snm *.log *.nav *.out *.eps *.ps +CLEANFILES+= ${GARBAGE} *.pdf *.ps myprojects.tex + +.PHONY: clean-garbage +clean-garbage: + rm -f ${GARBAGE} + +################################################## +myprojects.tex : presentation.tex + awk '/^%%%begin-myprojects/, /^%%%end-myprojects/' \ + ${.ALLSRC} > ${.TARGET} +myprojects.ps myprojects.pdf myprojects.dvi: my_prjs.eps + +.include <mkc.mk> diff --git a/presentation/_mkc_prog_awk.err b/presentation/_mkc_prog_awk.err new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/presentation/_mkc_prog_awk.err diff --git a/presentation/_mkc_prog_awk.res b/presentation/_mkc_prog_awk.res new file mode 100644 index 0000000..36178d1 --- /dev/null +++ b/presentation/_mkc_prog_awk.res @@ -0,0 +1 @@ +/usr/bin/awk diff --git a/presentation/_mkc_prog_dot.err b/presentation/_mkc_prog_dot.err new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/presentation/_mkc_prog_dot.err diff --git a/presentation/_mkc_prog_dot.res b/presentation/_mkc_prog_dot.res new file mode 100644 index 0000000..f99bbc3 --- /dev/null +++ b/presentation/_mkc_prog_dot.res @@ -0,0 +1 @@ +/usr/pkg/bin/dot diff --git a/presentation/_mkc_prog_dvips.err b/presentation/_mkc_prog_dvips.err new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/presentation/_mkc_prog_dvips.err diff --git a/presentation/_mkc_prog_dvips.res b/presentation/_mkc_prog_dvips.res new file mode 100644 index 0000000..47aba39 --- /dev/null +++ b/presentation/_mkc_prog_dvips.res @@ -0,0 +1 @@ +/usr/pkg/bin/dvips diff --git a/presentation/_mkc_prog_latex.err b/presentation/_mkc_prog_latex.err new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/presentation/_mkc_prog_latex.err diff --git a/presentation/_mkc_prog_latex.res b/presentation/_mkc_prog_latex.res new file mode 100644 index 0000000..591631a --- /dev/null +++ b/presentation/_mkc_prog_latex.res @@ -0,0 +1 @@ +/usr/pkg/bin/latex diff --git a/presentation/_mkc_prog_ps2pdf.err b/presentation/_mkc_prog_ps2pdf.err new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/presentation/_mkc_prog_ps2pdf.err diff --git a/presentation/_mkc_prog_ps2pdf.res b/presentation/_mkc_prog_ps2pdf.res new file mode 100644 index 0000000..57c9f89 --- /dev/null +++ b/presentation/_mkc_prog_ps2pdf.res @@ -0,0 +1 @@ +/usr/pkg/bin/ps2pdf diff --git a/presentation/dep_graph.dot b/presentation/dep_graph.dot new file mode 100644 index 0000000..73ad03f --- /dev/null +++ b/presentation/dep_graph.dot @@ -0,0 +1,16 @@ +digraph FSA { + graph [ ratio=compress layout=dot rankdir=UB ratio=0.4 ]; + + node [ shape = oval style=filled fontsize=18 ]; + + "libmaa" -> "dict"; + "libmaa" -> "dictd"; + "libmaa" -> "dictfmt"; + "libmaa" -> "dictzip"; + "libcommon" -> "dict"; + "libcommon" -> "dictd"; + "libcommon" -> "dictfmt"; + "libcommon" -> "dictzip"; + "libdz" -> "dictzip"; + "doc"; +} diff --git a/presentation/my_prjs.dot b/presentation/my_prjs.dot new file mode 100644 index 0000000..e2bcfe0 --- /dev/null +++ b/presentation/my_prjs.dot @@ -0,0 +1,52 @@ +digraph FSA { + graph [ ratio=compress layout=dot rankdir=UB ratio=0.4 ]; + + node [ shape = hexagon style=filled fontsize=20 ]; + + "mk-configure" [ fillcolor = grey60, fontcolor = white ]; + "lmdbg"; + "paexec"; + "distbb"; + "pkg_online"; + "runawk"; + "pkg_summary-utils"; + "nih"; + "pipestatus"; + + node [ shape = oval style=solid ]; + + "dictd"; + "dictem"; + + node [ shape = box ]; + + "runawk" -> "pkg_summary-utils"; + "runawk" -> "lmdbg"; + "runawk" -> "paexec"; + "runawk" -> "distbb"; + "runawk" -> "nih"; + "pkg_summary-utils" -> "distbb"; + "paexec" -> "distbb"; + "dictd" -> "dictem"; + "pkg_summary-utils" -> "pkg_online"; + "pkg_summary-utils" -> "pkg_conflicts"; + "pkg_summary-utils" -> "nih"; + "pkg_online" -> "nih"; + + "pkg_summary-utils"; + "pkg_conflicts"; + + node [ shape = oval style=solid ]; + + "dictd" -> "pkg_online"; + "pipestatus" -> "pkg_summary-utils"; + +} + +digraph FSA { + graph [ ratio=compress layout=dot rankdir=UB ratio=0.4 ]; + + node [ shape = hexagon style=filled fontsize=20 ]; + "lua-alt-getopt"; + "judyhash"; +} diff --git a/presentation/presentation.pdf b/presentation/presentation.pdf Binary files differnew file mode 100644 index 0000000..8037e2d --- /dev/null +++ b/presentation/presentation.pdf diff --git a/presentation/presentation.tex b/presentation/presentation.tex new file mode 100644 index 0000000..0a388f3 --- /dev/null +++ b/presentation/presentation.tex @@ -0,0 +1,1307 @@ +%%%begin-myprojects +\documentclass[hyperref={colorlinks=true}]{beamer} + +\usepackage{fancyvrb,relsize} +\usepackage{graphicx} + +\setbeamertemplate{navigation symbols}{} + +%\usetheme{Boadilla} +%\usetheme{CambridgeUS} +%\usetheme{Malmoe} +%\usetheme{Singapore} +%\usetheme{boxes} + +%\usecolortheme{crane} +%\usecolortheme{dove} +\usecolortheme{seagull} % very cool with \usetheme{default} +%\usefonttheme{professionalfonts} +%\useinnertheme{rectangles} + +\mode<presentation> +\title{MK-CONFIGURE (MK-C) -- lightweight, + easy to use alternative for GNU Autotools} +\author{Aleksey Cheusov \\ \texttt{vle@gmx.net}} +\date{Minsk, Belarus, 2012} + +\begin{document} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\newenvironment{Code}[1]% + {\Verbatim[label=\bf{#1},frame=single,% + fontsize=\small,% + commandchars=\\\{\}]}% + {\endVerbatim} + +%\newenvironment{Code}[1]% +% {\semiverbatim[]}% +% {\endsemiverbatim} + +\newenvironment{CodeNoLabel}% + {\Verbatim[frame=single,% + fontsize=\small,% + commandchars=\\\{\}]}% + {\endVerbatim} + +\newenvironment{CodeNoLabelSmallest}% + {\Verbatim[frame=single,% + fontsize=\footnotesize,% + commandchars=\\\{\}]}% + {\endVerbatim} +\newenvironment{CodeLarge}% + {\Verbatim[frame=single,% + fontsize=\large,% + commandchars=\\\{\}]}% + {\endVerbatim} + +%\newcommand{\prompt}[1]{\textcolor{blue}{#1}} +%\newcommand{\prompt}[1]{\textbf{#1}\textnormal{}} +\newcommand{\prompt}[1]{{\bf{#1}}} +%\newcommand{\h}[1]{\textbf{#1}} +%\newcommand{\h}[1]{\bf{#1}\textnormal{}} +\newcommand{\h}[1]{{\bf{#1}}} +\newcommand{\URL}[1]{\textbf{#1}} +\newcommand{\AutohellFile}[1]{\textcolor{red}{#1}} +\newcommand{\MKCfile}[1]{\textcolor{green}{#1}} +\newcommand{\ModuleName}[1]{\textbf{#1}\textnormal{}} +\newcommand{\ProgName}[1]{\textbf{#1}\textnormal{}} +\newcommand{\ProjectName}[1]{\textbf{#1}\textnormal{}} +\newcommand{\PackageName}[1]{\textbf{#1}\textnormal{}} +\newcommand{\MKC}[1]{\large\textsf{#1}\textnormal{}\normalsize} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% \begin{frame} +%% \frametitle{qqq} +%% \begin{code}{files in the directory} +%% bla bla bla +%% \end{code} +%% \end{frame} + +%%%end-myprojects + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame} + \titlepage +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame} + \frametitle{About this presentation} + \begin{block}{} + \begin{itemize} + \item It is a part of official documentation. + Latest version is available for download from here\\ + \URL{http://mova.org/\~{}cheusov/pub/mk-c/mk-c.pdf} +% \item +% \URL{http://sourceforge.net/projects/mk-configure} \\ +% \URL{http://freshmeat.net/projects/mk-configure} + \item part 1: Introduction + \item part 2: A number of samples of use + \item part 3: More complete list of features, TODO and more. + \end{itemize} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame} + \frametitle{Concepts behind mk-configure} + \begin{block}{Design principles and goals} + \begin{itemize} + \item \h{I detest code generation} as in Autotools and CMake!\\ + \h{Library approach} is used instead. + \item Written in \h{bmake}, portable version of \h{NetBSD make(1)}, + and UNIX tools. \h{No heavy dependencies} like python, ruby and perl. + As a programming language + bmake is not as powerful as RuPyPe, but\\ + \h{\mbox{bmake+sh} is good enough} for this task. + \item Basic principles are \h{similar to + traditional \mbox{bsd.*.mk} files}. + Actually mk-c contains heavily reworked Mk files from NetBSD. + \item \h{Portability} to all UNIX-like systems. + \item KISS. Only about 4000 lines of code. + \end{itemize} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame} + \frametitle{Concepts behind mk-configure} + \begin{block}{Design principles and goals} + \begin{itemize} + \item mk-configure is not only for end-users and packagers + but for developers too. + So, one of the main goals is to provide a convenient \h{tool for + development}. + \item Declarative approach of writing Makefile(s). Build and + installation process is controlled with a help of special + variables and bmake's include files. + \item \h{Cross-compilation}. + \item \h{Extensibility}. Extensions to mk-configure are implemented + using bmake include files and standard UNIX tools, i.e. shell, + awk, sed, grep etc. when needed. + \item MK-C is \h{Easy to use}. Only one command is needed to build + a project --- \h{mkcmake}. \h{Only Makefile(s)} are needed for + specifying build instructions. + \end{itemize} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame} + \frametitle{Concepts behind mk-configure} + \begin{block}{Negative side-effects} + \begin{itemize} + \item End-users/packagers have to install bmake and + mk-configure to build applications based on mk-configure. + \end{itemize} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 1: Hello world application} + + \begin{block}{Source code} + \begin{Code}{Makefile} +PROG = hello + +.include <\h{mkc.prog.mk}> + \end{Code} + \begin{Code}{hello.c} +#include <stdio.h> + +int main (int, char **) +\{ + puts ("Hello World!"); + return 0; +\} + \end{Code} +% \end{columns} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 1: Hello world application} + +% \begin{block} +\begin{block}{How it works} +\begin{CodeNoLabel} +\prompt{\$ export PREFIX=/usr SYSCONFDIR=/etc} +\prompt{\$ mkcmake} +checking for compiler type... gcc +checking for program cc... /usr/bin/cc +cc -c hello.c +cc -o hello hello.o +\prompt{\$ ./hello} +Hello World! +\prompt{\$ DESTDIR=/tmp/fakeroot mkcmake install} +for d in \_ /tmp/fakeroot/usr/bin; do test "\$d" = \_ || + install -d "\$d"; done +install -c -s -o cheusov -g users -m 755 + hello /tmp/fakeroot/usr/bin/hello +\prompt{\$} +\end{CodeNoLabel} +\end{block} +Supported targets: all, clean, cleandir (distclean), install, +uninstall, installdirs, depend etc. +% \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 2: Application using non-standard strlcpy(3)} + +\begin{block}{Source code} + % files + \begin{Code}{files in the directory} +\prompt{\$ ls -l} +total 12 +-rw-r--r-- 1 cheusov users 158 May 2 15:04 Makefile +-rw-r--r-- 1 cheusov users 187 May 2 15:05 main.c +-rw-r--r-- 1 cheusov users 332 May 2 15:09 \h{strlcpy.c} +\prompt{\$} + \end{Code} + +% Makefile + \begin{Code}{Makefile} +PROG = strlcpy_test +SRCS = main.c + +\h{MKC\_SOURCE\_FUNCLIBS} = strlcpy +\h{MKC\_CHECK\_FUNCS3} = strlcpy:string.h + +.include <mkc.prog.mk> + \end{Code} +\end{block} + +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 2: Application using non-standard strlcpy(3)} + +\begin{block}{Source code} +\begin{Code}{main.c} +#include <string.h> + +#ifndef \h{HAVE\_FUNC3\_STRLCPY\_STRING\_H} +size_t strlcpy(char *dst, const char *src, size_t siz); +#endif + +int main (int argc, char** argv) +\{ + /* Use strlcpy(3) here */ + return 0; +\} +\end{Code} +\end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 2: Application using non-standard strlcpy(3)} + + \begin{block}{How it works on Linux} +\begin{CodeNoLabel} +\prompt{\$ CC=icc mkcmake} +checking for compiler type... \h{icc} +checking for function strlcpy... \h{no} +checking for func strlcpy ( string.h )... \h{no} +checking for program icc... /opt/intel/cc/10.1.008/bin/icc +icc -c main.c +icc -c strlcpy.c +icc -o strlcpy_test main.o \h{strlcpy.o} +\prompt{\$ echo \_mkc\_*} +_mkc_compiler_type.err _mkc_compiler_type.res +_mkc_func3_strlcpy_string_h.c +_mkc_func3_strlcpy_string_h.err +_mkc_func3_strlcpy_string_h.res +_mkc_funclib_strlcpy.c _mkc_funclib_strlcpy.err +_mkc_funclib_strlcpy.res _mkc_prog_cc.err _mkc_prog_cc.res +\prompt{\$} +\end{CodeNoLabel} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 2: Application using non-standard strlcpy(3)} + + \begin{block}{How it works on NetBSD} +\begin{CodeNoLabel} +\prompt{\$ mkcmake} +checking for compiler type... gcc +checking for function strlcpy... \h{yes} +checking for func strlcpy ( string.h )... \h{yes} +checking for program cc... /usr/bin/cc +cc -D\h{HAVE\_FUNC3\_STRLCPY\_STRING\_H}=1 -c main.c +cc -o strlcpy_test main.o +\prompt{\$} +\end{CodeNoLabel} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 3: Application using plugins} + + \begin{block}{Source code} + \begin{Code}{Makefile} +PROG = myapp + +\h{MKC\_CHECK\_FUNCLIBS} = dlopen:dl + +.include <\h{mkc.configure.mk}> + +.if $\{\h{HAVE\_FUNCLIB.dlopen}:U0\} || \ {} + $\{\h{HAVE\_FUNCLIB.dlopen.dl}:U0\} +CFLAGS += -DPLUGINS_ENABLED=1 +.endif + +.include <mkc.prog.mk> + \end{Code} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 3: Application using plugins} + + \begin{block}{How it works on QNX} +\begin{CodeNoLabel} +\prompt{\$ mkcmake} +checking for compiler type... gcc +checking for function dlopen ( \h{-ldl} )... \h{yes} +checking for function dlopen... \h{no} +checking for program gcc... + /usr/qnx650/host/qnx6/x86/usr/bin/gcc +gcc \h{-DPLUGINS\_ENABLED=1} -c myapp.c +gcc -o myapp myapp.o \h{-ldl} +\prompt{\$} +\end{CodeNoLabel} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 3: Application using plugins} + + \begin{block}{How it works on OpenBSD} +\begin{CodeNoLabel} +\prompt{\$ mkcmake} +checking for compiler type... gcc +checking for function dlopen ( \h{-ldl} )... \h{no} +checking for function dlopen... \h{yes} +checking for program cc... /usr/bin/cc +cc \h{-DPLUGINS\_ENABLED=1} -c myapp.c +cc -o myapp myapp.o +\prompt{\$} +\end{CodeNoLabel} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 4: Support for shared libraries and C++} + + \begin{block}{Source code} + \begin{Code}{Makefile} +LIB = foobar +SRCS = foo.\h{cc} bar.\h{cc} baz.\h{cc} + +MKPICLIB ?= no +MKSTATICLIB ?= no + +\h{SHLIB\_MAJOR} = 1 +\h{SHLIB\_MINOR} = 0 + +.include <\h{mkc.lib.mk}> + \end{Code} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 4: Support for shared libraries} + + \begin{block}{How it works on Solaris with SunStudio compiler} +\begin{CodeNoLabel} +\prompt{\$ mkcmake} +checking for compiler type... \h{sunpro} +checking for program CC... /opt/SUNWspro/bin +CC -c \h{-KPIC} foo.cc -o foo.os +CC -c \h{-KPIC} bar.cc -o bar.os +CC -c \h{-KPIC} baz.cc -o baz.os +building shared foobar library (version \h{1.0}) +CC \h{-G} \h{-h libfoobar.so.1} + -o libfoobar.so.1.0 foo.os bar.os baz.os +ln -sf libfoobar.so.1.0 libfoobar.so +ln -sf libfoobar.so.1.0 libfoobar.so.1 +\prompt{\$} +\end{CodeNoLabel} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 4: Support for shared libraries} + + \begin{block}{How it works on Darwin} +\begin{CodeNoLabel} +\prompt{\$ mkcmake} +checking for compiler type... gcc +checking for program c++... /usr/bin/c++ +c++ -c \h{-fPIC -DPIC} foo.cc -o foo.os +c++ -c \h{-fPIC -DPIC} bar.cc -o bar.os +c++ -c \h{-fPIC -DPIC} baz.cc -o baz.os +building shared foobar library (version 1.0) +c++ \h{-dynamiclib -install\_name} + /usr/local/lib/libfoobar.1.0.\h{dylib} + \h{-current\_version 2.0 -compatibility\_version 2} + -o libfoobar.1.0.dylib foo.os bar.os baz.os +ln -sf libfoobar.1.0.dylib libfoobar.dylib +ln -sf libfoobar.1.0.dylib libfoobar.1.dylib +\prompt{\$} +\end{CodeNoLabel} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 4: Support for shared libraries (Exported symbols)} + + \begin{block}{} +\begin{CodeNoLabel} +\prompt{\$ cat Makefile} +LIB = foo +INCS = foo.h +\h{EXPORT\_SYMBOLS} = foo.sym +SHLIB_MAJOR = 1 +MKSTATICLIB = no +.include <mkc.lib.mk> +\prompt{\$ mkcmake} +awk 'BEGIN \{print "\{ global:"\} \{print \$0 ";"\} + END \{print "local: *; \};"\}' foo.sym + > foo.sym.tmp1 && mv foo.sym.tmp1 foo.sym.tmp +cc -I. -c -fPIC -DPIC foo.c -o foo.os +building shared foo library (version 1) +ld -shared -soname libfoo.so.1 + \h{--version-script foo.sym.tmp} -o libfoo.so.1 foo.os +\prompt{\$} +\end{CodeNoLabel} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 5: Big project consisting of several subprojects} + + \begin{block}{Dependency graph for all subprojects} +This project consists of several subprojects: dict, dictd, dictfmt, +dictzip, libdz, libmaa and libcommon. libcommon contains common code +for executables and should not be installed. + \begin{figure} + \includegraphics[width=\textwidth, height=0.50\textheight, keepaspectratio=false]{dep_graph.eps} + \end{figure} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 5: Big project consisting of several subprojects} + + \begin{block}{Files and directories} + \begin{CodeNoLabel} +\prompt{\$ ls -l} +total 4 +drwxr-xr-x 2 cheusov users 1 Jan 26 12:01 dict +drwxr-xr-x 2 cheusov users 1 Jan 26 12:01 dictd +drwxr-xr-x 2 cheusov users 1 Jan 26 12:01 dictfmt +drwxr-xr-x 2 cheusov users 1 Jan 26 12:01 dictzip +drwxr-xr-x 2 cheusov users 1 Jan 26 12:03 doc +drwxr-xr-x 2 cheusov users 1 Jan 26 12:01 libcommon +drwxr-xr-x 2 cheusov users 1 Jan 26 12:01 libdz +drwxr-xr-x 2 cheusov users 1 Jan 26 12:01 libmaa +-rw-r--r-- 1 cheusov users 306 Jan 26 12:03 \h{Makefile} +\prompt{\$} + \end{CodeNoLabel} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 5: Big project consisting of several subprojects} + + \begin{block}{Source code} + \begin{Code}{Makefile} +SUBPRJ = libcommon:dict # dict depends on libcommon +SUBPRJ += libcommon:dictd +SUBPRJ += libcommon:dictzip +SUBPRJ += libcommon:dictfmt +SUBPRJ += libmaa:dict +SUBPRJ += libmaa:dictd +SUBPRJ += libmaa:dictfmt +SUBPRJ += libmaa:dictzip +SUBPRJ += libdz:dictzip +SUBPRJ += doc + +.include <\h{mkc.subprj.mk}> + \end{Code} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 5: Big project consisting of several subprojects} + + \begin{block}{Source code} + \begin{Code}{libcommon/Makefile} +# Internal static library that implements functions +# common for dict, dictd, dictfmt and dictzip applications + +LIB = common +SRCS = str.c iswalnum.c # and others + +\h{MKINSTALL} = no # Do not install internal library! + +.include <mkc.lib.mk> + \end{Code} + \begin{Code}{libcommon/linkme.mk} +PATH.common := \$\{.PARSEDIR\} + +CPPFLAGS += -I\$\{PATH.common\}\h{/include} +DPLIBDIRS += \$\{PATH.common\} + \end{Code} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 5: Big project consisting of several subprojects} + + \begin{block}{Source code} + \begin{Code}{libmaa/Makefile} +LIB = maa +SRCS = set.c prime.c log.c # etc. + +\h{INCS} = maa.h + +SHLIB_MAJOR = 1 +SHLIB_MINOR = 2 +SHLIB_TEENY = 0 + +# list of exported symbols +\h{EXPORT\_SYMBOLS} = maa.sym + +.include <mkc.lib.mk> + \end{Code} + \begin{Code}{libmaa/linkme.mk} +PATH.maa := \$\{.PARSEDIR\} +CPPFLAGS += -I\$\{PATH.maa\} +DPLIBDIRS += \$\{PATH.maa\} + \end{Code} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 5: Big project consisting of several subprojects} + + \begin{block}{Source code} + \begin{Code}{libmaa/maa.sym} +hsh_create +hsh_destroy +hsh_insert +hsh_delete +hsh_retrieve +... +lst_create +lst_destroy +lst_insert +... +set_create +set_destroy +set_add +set_union +... + \end{Code} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 5: Big project consisting of several subprojects} + + \begin{block}{Source code} + \begin{Code}{libdz/Makefile} +LIB = dz +SRCS = dz.c + +INCS = dz.h + +\h{MKC\_REQUIRE\_HEADERS} = zlib.h +\h{MKC\_REQUIRE\_FUNCLIBS} = deflate:z +EXPORT_SYMBOLS = dz.sym +SHLIB_MAJOR = 1 +SHLIB_MINOR = 0 +LDADD = -lz + +.include <mkc.lib.mk> + \end{Code} + \begin{Code}{libdz/linkme.mk} +PATH.dz := \$\{.PARSEDIR\} +CPPFLAGS += -I\$\{PATH.dz\} +DPLIBDIRS += \$\{PATH.dz\} + \end{Code} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 5: Big project consisting of several subprojects} + + \begin{block}{Source code} + \begin{Code}{dictzip/Makefile} +PROG = dictzip +MAN = dictzip.1 + +\h{.include} "../libcommon/linkme.mk" +\h{.include} "../libdz/linkme.mk" +\h{.include} "../libmaa/linkme.mk" + +DPLIBS += -lcommon -ldz -lmaa + +.include <mkc.prog.mk> + \end{Code} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 5: Big project consisting of several subprojects} + + \begin{block}{How it fails ;-)} + \begin{CodeNoLabel} +\prompt{\$ mkcmake errorcheck-dictzip} +================================================== +errorcheck ===> \h{libcommon} +... +errorcheck ===> \h{libmaa} +... +================================================== +errorcheck ===> \h{libdz} +checking for header zlib.h... \h{no} +checking for function deflate ( -lz )... \h{no} +checking for function deflate... \h{no} +\h{ERROR: cannot find header zlib.h} +\h{ERROR: cannot find function deflate:z} +... +\prompt{\$ echo \$?} +1 +\prompt{\$} + \end{CodeNoLabel} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 5: Big project consisting of several subprojects} + + \begin{block}{How it works} + \begin{CodeNoLabel} +\prompt{\$ mkcmake dictzip} +... +================================================== +all ===> \h{libdz} +... +checking for header zlib.h... \h{yes} +checking for function deflate ( -lz )... \h{yes} +... +================================================== +all ===> \h{dictzip} +... +cc \h{-I../libcommon -I../libdz -I../libmaa} -c dictzip.c +cc \h{-L/tmp/hello\_dictd/libcommon -L/tmp/hello\_dictd/libdz} + \h{-L/tmp/hello\_dictd/libmaa} -o dictzip + dictzip.o -lcommon -lmaa -ldz +\prompt{\$} + \end{CodeNoLabel} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 6: Support for Lua programming language} + + \begin{block}{Source code} + \begin{Code}{Makefile} +SCRIPTS = foobar # scripts written in Lua +LUA\_LMODULES = foo bar # modules written in Lua +LUA\_CMODULE = baz # Lua module written in C + +.include <mkc.lib.mk> + \end{Code} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 6: Support for Lua programming language} + + \begin{block}{How it works} + \begin{CodeNoLabel} +\prompt{\$ mkcmake errorcheck} +checking for program pkg-config... + /usr/pkg/bin/pkg-config +checking for [pkg-config] lua... 1 (yes) +checking for [pkg-config] lua --cflags... + -I/usr/pkg/include +checking for [pkg-config] lua --libs... + -Wl,-R/usr/pkg/lib -L/usr/pkg/lib -llua -lm +checking for [pkg-config] lua --variable=INSTALL_LMOD... + /usr/pkg/share/lua/5.1 +checking for [pkg-config] lua --variable=INSTALL_CMOD... + /usr/pkg/lib/lua/5.1 +checking for compiler type... gcc +checking for header lua.h... yes +checking for program cc... /usr/bin/cc +\prompt{\$} + \end{CodeNoLabel} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 6: Support for Lua programming language} + + \begin{block}{How it works} + \begin{CodeNoLabel} +\prompt{\$ export PREFIX=/usr/pkg} +\prompt{\$ mkcmake all} +cc -DHAVE_HEADER_LUA_H=1 -I/usr/pkg/include + -c -fPIC -DPIC baz.c -o baz.os +building shared baz library (version 1.0) +cc -shared -Wl,-soname -Wl,libbaz.so.1 -o baz.so baz.os + -Wl,-R/usr/pkg/lib -L/usr/pkg/lib -llua -lm +\prompt{\$} + \end{CodeNoLabel} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 6: Support for Lua programming language} + + \begin{block}{How it works} + \begin{CodeNoLabel} +\prompt{\$ mkcmake install DESTDIR=/tmp/fakeroot} + ... +\prompt{\$ find /tmp/fakeroot -type f} +/tmp/fakeroot/usr/pkg/bin/foobar +/tmp/fakeroot/usr/pkg/lib/lua/5.1/baz.so +/tmp/fakeroot/usr/pkg/share/lua/5.1/foo.lua +/tmp/fakeroot/usr/pkg/share/lua/5.1/bar.lua +\prompt{\$} + \end{CodeNoLabel} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 7: Custom tests and sizeof of system types} + +\begin{block}{Source code} +\begin{Code}{Makefile} +MKC\_CUSTOM\_DIR = \h{\$\{.CURDIR\}/checks} + +# m4 supports -P flag (GNU, NetBSD) +M4 ?= m4 # overridable (\h{gm4}) +MKC\_REQUIRE\_CUSTOM += m4P +MKC\_CUSTOM\_FN.m4P = \h{m4P.sh} +.export: M4 + +# \_\_attribute ((\{con,de\}structor)) +MKC\_REQUIRE\_CUSTOM += \h{constructor destructor} + +# sizeof +MKC\_CHECK\_SIZEOF = char short int long void* long-long + +LIB = mylib +CFLAGS += -DM4\_CMD='"\$\{M4\}"' +.include <mkc.lib.mk> +\end{Code} +\end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 7: Custom tests and sizeof of system types} + +\begin{block}{Source code} +\begin{Code}{Files in checks/ subdirectory} +\prompt{\$ ls checks/} +constructor.c +destructor.c +m4P.sh +\prompt{\$} +\end{Code} +\end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 7: Custom tests and sizeof of system types} + +\begin{block}{Source code} +\begin{Code}{checks/m4P.sh} +#!/bin/sh + +input ()\{ + cat <<'EOF' +m4\_define(fruit, apple) +fruit +EOF +\} + +M4=\$\{M4-m4\} + +if input | \$\{M4\} -P | grep \^{}apple > /dev/null; then + echo 1 +else + echo 0 +fi +\end{Code} +\end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 7: Custom tests and sizeof of system types} +\begin{block}{Source code} +\begin{Code}{checks/constructor.c} +void __attribute ((constructor)) + dummy (void) +\{ +\} +\end{Code} +\begin{Code}{checks/destructor.c} +void __attribute ((destructor)) + dummy (void) +\{ +\} +\end{Code} +\end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 7: Custom tests and sizeof of system types} + + \begin{block}{How it works on FreeBSD} + \begin{CodeNoLabel} +\prompt{\$ mkcmake} +checking for compiler type... gcc +checking for sizeof char... \h{1} +checking for sizeof short... \h{2} +checking for sizeof int... \h{4} +checking for sizeof long... \h{4} +checking for sizeof void*... \h{4} +checking for sizeof long long... \h{8} +checking for custom test \h{m4P... 0 (no)} +checking for custom test \h{constructor}... \h{1 (yes)} +checking for custom test \h{destructor}... \h{1 (yes)} +checking for program cc... /usr/bin/cc +\h{ERROR: custom test m4P failed} +*** Error code 1 +... +\prompt{\$} + \end{CodeNoLabel} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 7: Custom tests and sizeof of system types} + + \begin{block}{How it works on FreeBSD with GNU m4} + \begin{CodeNoLabel} +\prompt{\$ M4=gm4 mkcmake} +checking for compiler type... gcc +checking for sizeof char... 1 +checking for sizeof short... 2 +checking for sizeof int... 4 +checking for sizeof long... 4 +checking for sizeof void*... 4 +checking for sizeof long long... 8 +checking for custom test \h{m4P... 1 (yes)} +checking for custom test constructor... 1 (yes) +checking for custom test destructor... 1 (yes) +checking for program cc... /usr/bin/cc +... +\prompt{\$} + \end{CodeNoLabel} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 8: Portable version of AWK from NetBSD} + +\begin{block}{http://mova.org/\~{}cheusov/pub/mk-configure/nbawk/} +\begin{Code}{Makefile (part 1)} +PROG = awk +SRCS = awkgram.y b.c lex.c lib.c main.c parse.c + proctab.c run.c tran.c +YHEADER = yes + +MKC\_COMMON\_DEFINES.Linux = -D\_GNU\_SOURCE +MKC\_COMMON\_HEADERS = ctype.h stdio.h string.h +MKC\_CHECK\_FUNCS1 = \_\_fpurge:stdio\_ext.h fpurge isblank +MKC\_CHECK\_FUNCS3 = strlcat +MKC\_SOURCE\_FUNCLIBS = fpurge strlcat + +WARNS= 4 +WARNERR= no # do not treat warnings as errors + +MKC\_REQD= 0.19.0 # mk-configure>=0.19.0 is required +... # to be continued on the next slide +\end{Code} +\end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 8: Portable version of AWK from NetBSD} + +\begin{block}{http://mova.org/\~{}cheusov/pub/mk-configure/nbawk/} +\begin{Code}{Makefile (part 2)} +... # beginning is on the previous slide +\h{.include} <mkc.configure.mk> + +\h{.if} \$\{HAVE\_FUNC1.isblank:U0\} +CPPFLAGS += -DHAS\_ISBLANK +\h{.endif} + +\h{.if} !\$\{HAVE\_FUNC1.fpurge:U1\} && + !\$\{HAVE_FUNC1.\_\_fpurge.stdio\_ext\_h:U1\} +MKC\_ERR\_MSG+= "fpurge(3) cannot be found" +\h{.endif} + +CPPFLAGS += -I. +LDADD += -lm + +\h{.include} <mkc.prog.mk> +\end{Code} +\end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 8: Portable version of AWK from NetBSD} + +\begin{block}{run.c} +\begin{CodeNoLabelSmallest} +--- nbawk-20100903/run.c.orig ++++ nbawk-20100903/run.c +@@ -40,6 +40,14 @@ + #include "awk.h" + #include "awkgram.h" + ++#ifndef HAVE_FUNC1_FPURGE ++int fpurge (FILE *stream); ++#endif ++ ++#ifndef HAVE\_FUNC3\_STRLCAT ++size\_t strlcat(char *dst, const char *src, size_t size); ++#endif ++ + #define tempfree(x) if (istemp(x)) tfree(x); else + + void stdinit(void); +\end{CodeNoLabelSmallest} +\end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 8: Portable version of AWK from NetBSD} + +\begin{block}{fpurge.c} +\begin{CodeNoLabelSmallest} +#include <stdio.h> + +#if HAVE\_FUNC1\_\_\_FPURGE\_STDIO\_EXT\_H +#include <stdio\_ext.h> +#endif + +int fpurge(FILE *stream); + +int fpurge(FILE *stream) +\{ +#if HAVE\_FUNC1\_\_\_FPURGE\_STDIO\_EXT\_H + \_\_fpurge (stream); + return 0; +#else +#error "cannot find fpurge(3), sorry" +#endif +\} +\end{CodeNoLabelSmallest} +\end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 8: Portable version of AWK from NetBSD} + +\begin{block}{strlcpy.c} +\begin{CodeNoLabel} +If you need this code, you know where to get it from! ;-) +\end{CodeNoLabel} +\end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 8: Portable version of AWK from NetBSD} + +% \begin{block} +\begin{block}{How it works on Linux} +\begin{CodeNoLabel} +\prompt{\$ mkcmake} +checking for compiler type... gcc +checking for function fpurge... \h{no} +checking for function strlcat... \h{no} +checking for func __fpurge ( stdio_ext.h )... \h{yes} +checking for func fpurge... \h{no} +checking for func isblank... \h{yes} +checking for func strlcat... \h{no} +checking for program yacc... \h{/usr/bin/yacc} +... +cc \h{-Wall -Wstrict-prototypes ...} + -I. \h{-D\_GNU\_SOURCE} -c awkgram.c +... +cc -o awk awkgram.o ... \h{fpurge.o strlcat.o} -lm +\prompt{\$ ./awk} +usage: ./awk [-F fs] [-v var=value] [-f progfile + | 'prog'] [file ...] +\prompt{\$} +\end{CodeNoLabel} +\end{block} +Supported targets: all, clean, cleandir (distclean), install, +uninstall, installdirs, depend etc. +% \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Example 9: Cross-compilation} + +\begin{block}{How it works} +\begin{CodeNoLabel} +\prompt{\$ export SYSROOT=/tmp/destdir.sparc64} +\prompt{\$ export TOOLCHAIN\_PREFIX=sparc64--netbsd-} +\prompt{\$ export TOOLCHAIN\_DIR=/tmp/tooldir.sparc64/bin} +\prompt{\$ uname -srm} +NetBSD 5.99.56 amd64 +\prompt{\$ mkcmake} +checking for compiler type... gcc +/tmp/tooldir.sparc64/bin/sparc64--netbsd-gcc + --sysroot=/tmp/destdir.sparc64 -c hello.c -o hello.o +/tmp/tooldir.sparc64/bin/sparc64--netbsd-gcc + --sysroot=/tmp/destdir.sparc64 -o hello hello.o +\prompt{\$ file hello} +hello: ELF 64-bit MSB executable, SPARC V9, relaxed + memory ordering, (SYSV), dynamically linked (uses + shared libs), for NetBSD 5.99.56, not stripped +\prompt{\$ } +\end{CodeNoLabel} +\end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile] + \frametitle{Features} + \begin{block}{} + \begin{enumerate} + \item Automatic detection of OS features + (\ModuleName{mkc.configure.mk}) + \begin{itemize} + \item \h{header presence} (MKC\_\{CHECK,REQUIRE\}\_HEADERS) + \item \h{function declaration} (MKC\_\{CHECK,REQUIRE\}\_FUNCS[n]) + \item \h{type declaration} (MKC\_\{CHECK,REQUIRE\}\_TYPES) + \item \h{structure member} (MKC\_\{CHECK,REQUIRE\}\_MEMBERS) + \item \h{variable declaration} (MKC\_\{CHECK,REQUIRE\}\_VARS) + \item \h{define declaration} (MKC\_\{CHECK,REQUIRE\}\_DEFINES) + \item \h{type size} (MKC\_CHECK\_SIZEOF) + \item \h{function} implementation \h{in the library} + (MKC\_\{CHECK,REQUIRE\}\_FUNCLIBS and MKC\_SOURCE\_FUNCLIBS) + \item \h{checks for programs} (MKC\_\{CHECK,REQUIRE\}\_PROGS) + \item \h{user's custom checks} (MKC\_\{CHECK,REQUIRE\}\_CUSTOM) + \item \h{built-in checks} (MKC\_CHECK\_BUILTINS), e.g. endianness, + prog\_flex, prog\_bison, prog\_gawk or prog\_gm4) + \end{itemize} + \end{enumerate} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\begin{frame}[fragile,t] + \frametitle{Features} + \begin{block}{} + \begin{enumerate} + \setcounter{enumi}{1} + \item Building, installing, uninstalling, cleaning + etc. Supported targets: \h{all}, \h{install}, + \h{uninstall}, + \h{clean}, \h{cleandir} (\h{distclean}), \h{installdirs}, \h{depend} + and others. + \item Building \h{standalone programs} (\ModuleName{mkc.prog.mk}), + \h{static, shared and dynamically loaded libraries} + (\ModuleName{mkc.lib.mk}) using \h{C}, + \h{C++}, \h{Objective C}, \h{Pascal} and \h{Fortran} compilers. + Shared libraries + support is provided for numerous OSes: \h{NetBSD}, \h{FreeBSD}, + \h{OpenBSD}, + \h{DragonFlyBSD}, \h{MirOS BSD}, \h{Linux}, \h{Solaris}, \h{Darwin} + (MacOS-X), \h{Interix}, \h{Tru64}, + \h{QNX}, \h{HP-UX}, \h{Cygwin} (no support for shared libraries + and DLLs yet) and + compilers: \h{GCC}, \h{Intel C/C++} compilers, \h{Portable C compiler} AKA + \h{pcc}, \h{DEC C/C++ compiler}, \h{HP C/C++ compiler}, + \h{Oracle SunStudio} and others. + \end{enumerate} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\begin{frame}[fragile,t] + \frametitle{Features} + \begin{block}{} + \begin{enumerate} + \setcounter{enumi}{3} + \item Handling \h{man} pages, \h{info} manuals and \h{POD} documents. + \item Handling \h{scripts} as well as \h{plain text files}, + i.e. installing, uninstalling and handling \h{.in files} + (replacing, for example, \h{@bindir@}, \h{@sysconfdir@}, \h{@version@} + fragments with real values). + \item \h{Cross-compilation}. mk-configure itself doesn't run + target system + executables, so you can freely use cross-tools (compiler, linker + etc.). You can also override/set any variable initialized by mk-configure. + \item Support for \h{pkg-config}. + \item Support for \h{Lua} programming language. + \item Support for \h{yacc} and \h{lex}. + \end{enumerate} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\begin{frame}[fragile,t] + \frametitle{Features} + \begin{block}{} + \begin{enumerate} + \setcounter{enumi}{10} + \item Support for projects with multiple subprojects + (\ModuleName{mkc.subprj.mk} and \ModuleName{mkc.subdir.mk}). + \item Special targets bin\_tar, bin\_targz, bin\_tarbz2, bin\_zip, + bin\_deb creates .tar, .tar.gz, .tar.bz2, .zip archives and .deb + package (on Debian Linux). + \item Parts of mk-configure functionality is + accesible via individual programs, e.g. \ProgName{mkc\_install}, + \ProgName{mkc\_check\_compiler}, + \ProgName{mkc\_check\_header}, \ProgName{mkc\_check\_funclib}, + \ProgName{mkc\_check\_decl}, + \ProgName{mkc\_check\_prog}, \ProgName{mkc\_check\_sizeof} and + \ProgName{mkc\_check\_custom}. + \end{enumerate} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\begin{frame}[fragile,t] + \frametitle{MK-CONFIGURE in real world} + \begin{block}{Packagers are welcome! ;-)} + \small + NetBSD make (bmake) is packaged in the following OSes: + \begin{itemize} + \item FreeBSD, pkgsrc (NetBSD, DragonFlyBSD...) (\h{devel/bmake}) + \item Gentoo Linux, Fedora Linux, AltLinux + \item Debian/Ubuntu\\ + deb http://mova.org/\~{}cheusov/pub/debian lenny main\\ + deb-src http://mova.org/\~{}cheusov/pub/debian lenny main + \end{itemize} + mk-configure is packaged in the following OSes + \begin{itemize} + \item FreeBSD, pkgsrc (NetBSD, DragonFlyBSD...) (\h{devel/mk-configure}) + \item Debian/Ubuntu\\ + deb http://mova.org/\~{}cheusov/pub/debian lenny main\\ + deb-src http://mova.org/\~{}cheusov/pub/debian lenny main + \end{itemize} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\begin{frame}[fragile,t] + \frametitle{MK-CONFIGURE in real world} + \begin{block}{Real life samples of use} + \begin{itemize} + \item Lightweight modular malloc Debugger.\\ + \URL{http://sourceforge.net/projects/lmdbg/} + \URL{http://pkgsrc.se/wip/lmdbg/}\\ + \item NetBSD version of AWK programming language, ported + to other Operating Systems.\\ + \URL{http://mova.org/\~{}cheusov/pub/mk-configure/nbawk/} + \item Modules support for AWK programming language\\ + \URL{http://sourceforge.net/projects/runawk/} + \URL{http://pkgsrc.se/lang/runawk/}\\ + \item Tool for distributing tasks over network or CPUs\\ + \URL{http://sourceforge.net/projects/paexec/} + \URL{http://pkgsrc.se/wip/paexec/}\\ + \end{itemize} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\begin{frame}[fragile,t] + \frametitle{MK-CONFIGURE in real world} + \begin{block}{Real life samples of use} + \begin{itemize} + \item Distributed fault tolerant bulk build tool for pkgsrc\\ + \URL{http://mova.org/\~{}cheusov/pub/distbb/}\\ + \URL{http://pkgsrc.se/wip/distbb/}\\ + \item Client/server package search system for pkgsrc\\ + \URL{http://mova.org/\~{}cheusov/pub/pkg\_online/} + \URL{http://pkgsrc.se/wip/pkg\_online-client/}\\ + \URL{http://pkgsrc.se/wip/pkg\_online-server/}\\ + \item Any project based on traditional + \ModuleName{bsd.\{prog,lib,subdir\}.mk} can easily be converted + to \MKC{mk-configure}. + \end{itemize} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%begin-myprojects + +\begin{frame}[fragile,t] + \frametitle{MK-CONFIGURE in real world} + \begin{block}{My opensource projects using + mk-configure (filled hexagon), Mk files (box) and others (oval)} + \begin{figure} + \includegraphics[width=\textwidth, height=0.60\textheight, keepaspectratio=false]{my_prjs.eps} + \end{figure} +% \begin{figure} +% \includegraphics[width=0.7\textwidth, height=0.10\textwidth, keepaspectratio=false]{my_prjs2.eps} +% \end{figure} + \end{block} +\end{frame} + +%%%end-myprojects + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\begin{frame}[fragile,t] + \frametitle{MK-C needs your help ;-)} + \begin{block}{} + \begin{itemize} + \item Packagers are welcome (Linux distros, OpenBSD etc.) + \item MK-C distribution contains \h{a lot of regression tests and + samples of use} (samples are used for testing too).\\ + \h{Shell accounts} on + "exotic" UNIX-like platforms are needed (AIX, HP-UX, non-ELF BSDs, + IRIX, Solaris, Hurd etc.) for testing and development. + \item Review of the documentation. At the moment only mk-configure(7), + samples/ and this presentation are available. + \item sf.net provides two mailing lists:\\ + \h{mk-configure-help} and \h{mk-configure-discuss}. + \item TODO file in the distribution is full of tasks. + \end{itemize} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\begin{frame}[fragile] + \frametitle{} + \begin{block}{} + \begin{center} + \Huge{The END.} + \end{center} + \end{block} +\end{frame} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%begin-myprojects + +\end{document} + +%%%end-myprojects diff --git a/scripts/Makefile b/scripts/Makefile new file mode 100644 index 0000000..4ecb5e8 --- /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 mkc_get_deps + +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..ab6c9da --- /dev/null +++ b/scripts/mk-configure.7.in @@ -0,0 +1,2113 @@ +.\" $NetBSD$ +.\" +.\" This file contains parts of NetBSD's bsd.README file +.\" +.\" Copyright (c) 2009-2014 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 "Aug 21, 2014" "" "" +.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, mkc.init.mk loads +"${MAKECONF}" file if it exists. +Otherwise, it loads +@sysconfdir@/mk-c.conf if it exists. +If neither ${MAKECONF} nor @sysconfdir@/mk-c.conf exist, +it tries to load @sysconfdir@/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. 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 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. +.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/hello_files +for the sample. +.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. +.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 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 CPPFLAGS0 +The same as CPPFLAGS but CPPFLAGS0 are passed to the compiler before CPPFLAGS. +Normally, CPPFLAGS0 should be modified in makefiles and should not +be set from environment by user. +.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 SRC_PATHADD +List of directories added to +.IR .PATH . +.RI < Im > +.RI [ "" ] +.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 SHAREDSTATEDIR +Target directory for modifiable architecture-independent data files. +.RI < "Iu" > +.RI [ ${PREFIX}/com ] +.IP VARDIR +Target directory for modifiable single-machine data files. +.RI < "Iu" > +.RI [ ${PREFIX}/var ] +.IP INCSDIR +Target directory for header files. +.RI < "Iu" > +.RI [ ${PREFIX}/include ] +.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.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 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 LDADD0 +The same as LDADD but LDFLAGS0 and LDADD0 are passed to the linker before LDFLAGS and LDADD. +.RI < "M" > +.IP LDFLAGS +Additional linker flags. Often used for specifying library directories. +.VS + LDFLAGS+= -L/opt/company/software/lib +.VE +.RI < "Mu I" > +.IP LDFLAGS_<project> +Similar to LDFLAGS but for project ${PROJECTNAME}. +.IP LDFLAGS0 +The same as LDFLAGS but LDFLAGS0 and LDADD0 are passed to the linker before LDFLAGS and LDADD. +Normally, LDFLAGS0 and LDADD0 should be modified in makefiles and should not +be set from environment by user. +.RI < "M" > +.IP "BINDIR, BINMODE, BINOWN and BINGRP" +See +.IR "Common variables " and " mkc.files.mk" +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 ] +.IP DPINCDIRS +See LIBDEPS in section +.BR mk.subprj.mk . +.IP DPLIBDIRS +See LIBDEPS in section +.BR mk.subprj.mk . +.IP DPLDADD +See LIBDEPS in section +.BR mk.subprj.mk . +.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 and dynanic library or DLL. +.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 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 DPINCDIRS +See LIBDEPS in section +.BR mk.subprj.mk . +.IP DPLIBDIRS +See LIBDEPS in section +.BR mk.subprj.mk . +.IP DPLDADD +See LIBDEPS in section +.BR mk.subprj.mk . +.\" .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. +.P +.B mkc.subprj.mk +provides the following variables: +.IP SUBPRJ +List of subprojects (subdirectories) and dependencies. If the +subdirectory doesn't exist the subproject becomes "virtual" and may be +used to group several subprojects into a new virtual one. +.RI < "M" > +.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 <library:program> 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 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 INTERNALLIBS +A list of subprojects (basenames) with internal libraries. +These libraries are static and not installed by target "install". +.RI < M > +.RI [ "" ] +.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 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. +.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 SRCDIR_<dir> +Value of ${.CURDIR} inside +.I dir +subdirectory. Slash symbols inside <dir> are replaced with underlines. +In addition, SRCDIR_<dir:T> variable is set to ${SRCDIR_<dir>} +if ${SHORTPRJNAME} is "yes". +.IP TARGETS +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 ", " errorcheck ", " 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. +.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 SHORTPRJNAME +If "yes", special targets with last component of the subprojects are provided. +.RI < "Im" > +.RI [ yes ] +.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 SUBPRJSRCTOP +This variables contains ${.CURDIR} directory and is passed to subprojects. +.RI < "I" > +.RI [ ${.CURDIR} ] +.P +.B mkc.subprj.mk +provides the following targets: +.IP "<subdir> and <subdir:T>" +<subdir> is a subdirectory listed in SUBDIR or SUBPRJ. +This target is equivalent to all-<subdir>. +<subdir:T> means the last component of the directory +and is created if ${SHORTPRJNAME} is "yes". +.IP <target>-<subdir> +Runs the specified <target> for the specified <subdir>. +The target <target>-<subdir:T> is provided +if ${SHORTPRJNAME} is "yes". +.IP "subdir-<target>-<subdir> and nodeps-<target>-<subdir>" +Runs the specified <target> for the specified <subdir> without dependencies. +Targets subdir-<target>-<subdir:T> +and nodeps-<target>-<subdir:T> are provided +if ${SHORTPRJNAME} is "yes". +.IP print_deps +Outputs the dependency graph on targets in tsort(1) format +taking NODEPS and NOSUBDIR variables into account. +.SS "mkc.subdir.mk" +The include file +.B mkc.subdir.mk +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_SOURCE_DIR, MKC_SOURCE_DIR.<source>" +Directory with sources for MKC_SOURCE_FUNCLIBS. If MKC_SOURCE_DIR.<source> is unset, +MKC_SOURCE_DIR is used that defaults to ${.CURDIR}. +.VS + Ex: MKC_SOURCE_FUNCLIBS += getline + MKC_SOURCE_DIR.getline.c = ${.CURDIR}/../missing + Res: SRCS+= ${.CURDIR}/../missing/getline.c + HAVE_FUNCLIB.getline= 0 +.VE +.IP MKC_CHECK_DEFINES +List of define:header to check. <header> part is optional. + +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. +Here <N> means the number of arguments. +As a result of the check bmake's variable +HAVE_FUNC<N>.<func>.<header> (or HAVE_FUNC<N>.<func>) +is set to either 0 or 1. +.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 ", " 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_<progname> 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_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_CHECK_PROTOTYPES +A list of checks (list of names) for C function prototypes. +MKC_PROTOTYPE_FUNC.<name> is a C function prototype. +MKC_PROTOTYPE_HEADERS.<name> is a list of headers to #include. +mk-configure verifies that the specified prototype is correct and if +so, HAVE_PROTOTYPE.<name> bmake variable is set to 1 and +-DHAVE_PROTOTYPE_<NAME>=1 is added to CFLAGS unless MKC_NOAUTO is set to 1. +Otherwise, HAVE_PROTOTYPE.<name> variable is set to 0. +.VS +Ex. + MKC_CHECK_PROTOTYPES = posix_iconv const_iconv + MKC_PROTOTYPE_FUNC.posix_iconv = \ + size_t iconv(iconv_t,char**,size_t*,char**,size_t*) + MKC_PROTOTYPE_FUNC.const_iconv = \ + size_t iconv(iconv_t,const char**,size_t*,char**,size_t*) + MKC_PROTOTYPE_HEADERS.posix_iconv = iconv.h + MKC_PROTOTYPE_HEADERS.const_iconv = iconv.h +Res. + HAVE_PROTOTYPE.posix_iconv=0 + HAVE_PROTOTYPE.const_iconv=1 + CFLAGS += -DHAVE_PROTOTYPE_CONST_ICONV=1 +.VE +.IP MKC_REQUIRE_PROTOTYPES +The same as MKC_CHECK_PROTOTYPES, but incorrect prototype is +treated as a fatal error (See +.B errorcheck +target. +.IP MKC_NOAUTO_FUNCLIBS +See MKC_CHECK_FUNCLIBS +.IP MKC_NOAUTO +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}. +By default MKC_CACHEDIR variable is exported for subprojects. +As a result cache files +for subprojects are created in the top-level directory. +If cache directory doesn't exist, it is created automatically. +.IP MKC_SHOW_CACHED +Setting it to 0 will hide +.VS + 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 +.IP MKC_FEATURES +This is a list of "features" required by project. In general, a feature +is something that has problems with portability. This may be a +function name or header missing on some platforms, for example. +What developer +needs to do is to add FEATURENAME to MKC_FEATURES variable and add +#include <mkc_FEATURENAME.h> where it is needed. Internally, system +requiremets are checked in the automatically included +mkc_imp.f_FEATURENAME.mk +file and all required actions (includes, define checks etc.) +are made in mkc_FEATURENAME.h header file. +Currently the following features are provided: +.RS +.TP +.B strlcat +This feature corresponds to strlcat(3) function available on almost +all systems except glibc-based Linux-es. mkc_imp.f_strlcat.mk checks +whether strlcat declaration is available in string.h and +implementation is available in libc. If not, strlcat.c provided by +mk-configure is added to SRCS and declaration is provided in +mkc_strlcat.h header. +.TP +.B strlcpy +Similar to strlcat. +.TP +.B getline +This feature corresponds to getline(3) function which is a part of POSIX2008 +unavailable on some +systems. mkc_imp.f_getline.mk checks +whether getline declaration is available in stdio.h and +implementation is available in libc. If not, getline.c provided by +mk-configure is added to SRCS and declaration is provided in +mkc_getline.h header. +.TP +.B progname +This feature provides getprogname(3) and setprogname(3) functions +available in *BSD. +.TP +.B fgetln +This feature provides fgetln(3) BSD-ism. +.TP +.B err +This feature provides err(3), errx(3), verr(3) and verrx(3) BSD-isms. +.TP +.B warn +This feature provides warn(3), warnx(3), vwarn(3) and vwarnx(3) BSD-isms. +.TP +.B libm +This feature checks whether libm is available and if yes, adds -lm to +LDADD. Most UNIX-like systems have libm but Haiku, for example, does +not. mkc_imp.f_libm.mk checks whether libm library is available and if yes, +-lm is added to LDADD. +.TP +.B libdl +This feature checks whether libdl library is available and dlopen(3) +is declared in dlfcn.h. If yes, -ldl is added to LDADD. mkc_libdl.h +provides declarations for dlopen(3), dlsym(3), dlclose(3) etc. +.TP +.B "RB SPLAY" +BSD systems provide sys/tree.h header where RB_* and SPLAY_* macroses +are defined for red-black tree and splay. These features check whether +sys/tree.h and appropriate macroses are available. If yes, mkc_RB.h +and mkc_SPLAY.h include system-wide sys/tree.h, otherwise NetBSD +version of sys/tree.h provided by mk-configure is included. +.TP +.B "SLIST SIMPLEQ STAILQ LIST TAILQ CIRCLEQ" +BSD systems provide sys/queue.h header where SLIST_* etc. macroses are +defined for lists and queues. These features check whether sys/queue.h +and appropriate macroses are available. If yes, mkc_SLIST.h and others +include system-wide sys/queue.h, otherwise NetBSD version of +sys/queue.h provided by mk-configure is included. +.RE +.SS mkc_imp.scripts.mk +is internal include file which is included from +.BR mkc.prog.mk ", " mkc.lib.mk " and " mkc.files.mk . +Do not use it directly! +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 +---------------------- +.RI @ "" "prefix@ ${PREFIX}" +.RI @ "" "bindir@ ${BINDIR}" +.RI @ "" "mandir@ ${MANDIR}" +.RI @ "" "sbindir@ ${SBINDIR}" +.RI @ "" "libdir@ ${LIBDIR}" +.RI @ "" "libexecdir@ ${LIBEXECDIR}" +.RI @ "" "datadir@ ${DATADIR}" +.RI @ "" "sysconfdir@ ${SYSCONFDIR}" +.RI @ "" "incsdir@ ${INCSDIR}" +.RI @ "" "vardir@ ${VARDIR}" +.RI @ "" "sharedstate@ ${SHAREDSTATEDIR}" +.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 +See +.BR mkc.init.mk . +.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 MKC_CHECK_PKGCONFIG +List of libraries to check, for example, glib-2.0>=2.1. +Spaces around <=, >=, =, < and > are not allowed. +As a result of the check bmake's variable +PKG_CONFIG.exists.<lib> is set to 1 for success or 0 for failure. +Unless MKC_NOAUTO is set to 1 -DHAVE_PKGCONFIG_<LIB>=1 +is also added to CFLAGS if <lib> was found. <LIB> is tr/a-z+.-/A-ZP__/ of <lib>. +.RI < "M" > +.IP MKC_REQUIRE_PKGCONFIG +The same as MKC_REQUIRE_PKGCONFIG, but absense of library is +treated as a fatal error (See +.B errorcheck +target. +.RI < "M" > +.IP PKG_CONFIG_DEPS +Synonym for MKC_REQUIRE_PKGCONFIG. Deprecated. +.IP PKG_CONFIG.exists.<lib> +If "1", <lib> exists, "0" otherwise. +Inside <lib> <=, >=, =, < and > and replaced with +_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}. +.IP MKDEP_CC +Compiler passed to mkdep(1). +.RI < "Iu" > +.RI [ "${CC}" ]. +.SS "mkc_imp.foreign_autotools.mk" +This module is activated if variable FOREIGN is set to "autotools" and provides +support for building external projects using autotools. +It also provides a recursive target +.B mkgen +for generating "configure" script, "Makefile.in" file etc. using +.BR autoreconf(1) " utility." +The following variables are provided: +.IP FSRCDIR +Relative (to ${.CURDIR}) or absolute directory to autotools-based sources. +.IP AT_MAKE +Make(1)-like utility for the project. +.RI < "Imu" > +.RI [ "${MAKE}" ]. +.IP AT_USE_AUTOMAKE +If "yes", +.B automake(1) +is used. +.RI < "M" > +.RI [ yes ]. +.IP AT_CONFIGURE_ARGS +Extra arguments passed to "configure" script set in addition to +standard ones (--prefix, --bindir etc.). +.RI < "Mu" > +.RI [ "" ]. +.IP AT_CONFIGURE_ENV +Environment variables for "configure" script set in addition to +standard ones (CC, CFLAGS etc.). +.RI < "Mu" > +.RI [ "" ]. +.IP AT_AUTORECONF_ARGS +Arguments passed to +.BR autoreconf(1) . +.RI < "U" > +.RI [ "-sif" ]. +.SH "CROSS COMPILATION" +The following variables are used for compiling software using cross-tools. +.IP MACHINE_GNU_PLATFORM +See TOOLCHAIN_PREFIX. +.IP OPSYS_TARGET +OPSYS for target OS. +.IP SYSROOT +Root directory for headers and libraries. +If set, the following variables +are set to ${TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}<toolname>: AR, AS, CXX, CPP, CC, +INSTALL, LD, NM, OBJCOPY, OBJDUMP, RANLIB, SIZE and STRIP. +.RI < "U" > +.RI [ "" ]. +.IP TOOLDIR +See TOOLCHAIN_DIR. +.IP TOOLCHAIN_DIR +Directory that contains cross-toolchain. +.RI < "U" > +.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.init.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..1196446 --- /dev/null +++ b/scripts/mkc_check_common.sh @@ -0,0 +1,101 @@ +# Copyright (c) 2009-2014 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} + +if test -x "$MKC_CACHEDIR"; then + : +else + mkdir -p "$MKC_CACHEDIR" +fi + +tmpc=$MKC_CACHEDIR/_mkc_${pathpart}${MKC_NOCACHE}.c +tmpo=$MKC_CACHEDIR/_mkc_${pathpart}${MKC_NOCACHE}.o +tmperr=$MKC_CACHEDIR/_mkc_${pathpart}${MKC_NOCACHE}.err +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..6930a2f --- /dev/null +++ b/scripts/mkc_check_compiler @@ -0,0 +1,72 @@ +#!/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 + langname='C++' + CC="$CXX" + export CC +else + langname='C' +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 $langname 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..e0d32d1 --- /dev/null +++ b/scripts/mkc_check_custom @@ -0,0 +1,180 @@ +#!/bin/sh + +############################################################ +# Copyright (c) 2009-2014 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 text prefix for cache filename, defaults to "custom" + -n text a part of cache filename, defaults to + `basename <source_file>` without extension + -m text 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..8655577 --- /dev/null +++ b/scripts/mkc_check_custom.1 @@ -0,0 +1,124 @@ +.\" $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] sourcefile" +.br +.BI mkc_check_custom " cmd [args...]" +.br +.BI mkc_check_custom " -h" +.SH DESCRIPTION +If +.I cmd +is executable +.B mkc_check_custom +runs +.IR "cmd args" . +Otherwise it tries to compile +.IR sourcefile +and output 1 if compilation succeeded and 0 otherwise. +If -r option was applied it runs a compiled program. +What type of compiler to use depends on +.I sourcefile +extension. '.c' corresponds to +.I ${CC} +(C language), '.cc', '.cxx', '.C' and '.cpp' correspond to +.I ${CXX} +(C++ language), '.f' -- to +.I ${FC} +(Fortran). +.SH OPTIONS +.TP +.B "-h" +Display help message. +.TP +.B "-r" +Run executable compiled from +.IR sourcefile . +.TP +.BI "-p " text +Prefix of the generated cache file. The default is "custom". +.TP +.BI "-n " text +Name part of the generated cache file. +.br +The default is `basename <sourcefile>`. +.TP +.BI "-m " text +Message +.B mkc_check_custom +outputs. +.br +The default is "custom test sourcefile_or_cmd". +.TP +.BI -s +.B mkc_check_custom +outputs an exit status of +.IR "cmd args" . +.TP +.BI -d +Delete cache files. +.SH ENVIRONMENT +.TP +.B CC +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..ea2a962 --- /dev/null +++ b/scripts/mkc_check_decl @@ -0,0 +1,259 @@ +#!/bin/sh + +############################################################ +# Copyright (c) 2009-2014 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", "member" or "prototype". + +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 + mkc_check_decl prototype 'int connect(int __fd, const struct sockaddr * __addr, socklen_t __len)' sys/socket.h + mkc_check_decl prototype 'int connect(int __fd, struct sockaddr * __addr, socklen_t __len)' sys/socket.h +EOF +} + +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" | awk '{gsub(/-/, " "); gsub(/ +[(]/, "("); $1=$1; print}'` +shift + +typemsg="$decltype $declwhat" +case "$decltype" in + type) + pathpart=`echo "${decltype}_${declwhat}_$*" | tr '/. ' '__~'` + ;; + prototype) + pathpart=`echo "${decltype}_${declwhat}_$*" | tr '/(). *' '____~8'` + funcname=`echo "$declwhat" | sed 's,^.* \([^ ]*\)[(].*$,\1,'` + ;; + *) + pathpart=`echo "$decltype$argscnt $declwhat" $* | tr '/. ' '___'` + ;; +esac + +. mkc_check_common.sh + +################################################## +# 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_prototype (){ + get_includes "$@" > "$tmpc" + + cat >> "$tmpc" <<EOF +${declwhat}; +void func (void) +{ + if (${funcname}) return; +} +EOF + + # + 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 + +if test $# -gt 0; then + incs_msg=" ( $* )" +fi + +check_itself (){ + if is_${decltype} "$@" + then + echo 1 + else + echo 0 + fi +} + +check_and_cache "checking for ${typemsg}${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..f3434bb --- /dev/null +++ b/scripts/mkc_check_decl.1 @@ -0,0 +1,89 @@ +.\" $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, type or +function prototype. +.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" , " member " or +.IR " prototype" . +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 + mkc_check_decl prototype 'int connect(int __fd, const struct sockaddr * __addr, socklen_t __len)' sys/socket.h + mkc_check_decl prototype 'int connect(int __fd, struct sockaddr * __addr, socklen_t __len)' sys/socket.h +.VE +.SH AUTHOR +Aleksey Cheusov <vle@gmx.net> diff --git a/scripts/mkc_check_funclib b/scripts/mkc_check_funclib new file mode 100755 index 0000000..0bfd771 --- /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 implementation ${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_get_deps.in b/scripts/mkc_get_deps.in new file mode 100755 index 0000000..74c8092 --- /dev/null +++ b/scripts/mkc_get_deps.in @@ -0,0 +1,43 @@ +#!@AWK@ -f + +# Usage: mkc_get_deps +# $1 -- project name +# ENVIRON ["AXCIENT_LIBDEPS"] -- dep1:prj1 dep2:prj2 ... + +function print_all_deps (prj, i,next_prj){ + if (prj in processed) + return + + processed [prj]=1 + + for (i=1; i <= count [prj]; ++i){ + next_prj = graph[prj, i] + print_all_deps(next_prj) + } + + if (topprj != prj) + result [++result_sz] = prj +} + +BEGIN { + topprj = ARGV [1] + if (!topprj) + exit(10) + + cnt = split(ENVIRON ["AXCIENT_LIBDEPS"], deps, / +|:/) + if (int(cnt/2)*2 != cnt) + exit(11) + + for (i=1; i <= cnt; i += 2){ + from = deps [i] + to = deps [i+1] + graph[to, ++count [to]] = from + } + + print_all_deps(topprj) + + for (i=result_sz; i >= 1; --i) + print result [i] + + print "" # for bmake +} diff --git a/scripts/mkc_install b/scripts/mkc_install new file mode 100755 index 0000000..a17d086 --- /dev/null +++ b/scripts/mkc_install @@ -0,0 +1,198 @@ +#!/bin/sh +# +# install - install a program, script, or datafile +# This comes from X11R5 (mit/util/scripts/install.sh) +# and was modified by Aleksey Cheusov <vle@gmx.net>. +# +# Copyright 1991 by the Massachusetts Institute of Technology +# Copyright 2013-2014 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 +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}" +lnsprog="${LNSPROG-ln -f -s}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +instcmd="$mvprog" +chmodcmd=mkcchmod; mod=0755; +chowncmd=":" +chgrpcmd=":" +stripcmd=":" +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src="" +dst="" +dir_arg="" + +set -e + +mkcchgrp () { $chgrpprog "$grp" "$@"; } +mkcchown () { $chownprog "$own" "$@"; } +mkcchmod () { $chmodprog "$mod" "$@"; } + +while [ x"$1" != x ]; do + case "$1" in + -c) instcmd="$cpprog" + shift + continue;; + + -l) instcmd="$lnsprog" + shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -m) mod="$2" + chmodcmd=mkcchmod + shift + shift + continue;; + + -o) own="$2" + chowncmd=mkcchown + shift + shift + continue;; + + -g) grp="$2" + chgrpcmd=mkcchgrp + shift + shift + continue;; + + -s) stripcmd="$stripprog" + shift + continue;; + + *) if [ x"$src" = x ]; then + src="$1" + else + dst="$1" + fi + shift + continue;; + esac +done + +if test "_$instcmd" = "_$lnsprog"; then + chowncmd=: + chgrpcmd=: + chmodcmd=: + stripcmd=: +fi + +if [ x"$src" = x ]; then + echo "install: no input file specified" + exit 1 +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 + 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"` + fi +fi + +## +dstdir=`dirname "$dst"` + +if [ x"$dir_arg" != x ]; then + $doit $instcmd "$dst" + + $doit $chowncmd "$dst" + $doit $chgrpcmd "$dst" + $doit $stripcmd "$dst" + $doit $chmodcmd "$dst" +else +# Make sure that the destination directory exists. + if [ ! -d "$dstdir" ]; then + $mkdirprog -p "$dstdir" + 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. + + $doit $chowncmd "$dsttmp" + $doit $chgrpcmd "$dsttmp" + $doit $stripcmd "$dsttmp" + $doit $chmodcmd "$dsttmp" + +# Now rename the file to the real destination. + + $doit $rmcmd -f "$dstdir/$dstfile" + $doit $mvcmd "$dsttmp" "$dstdir/$dstfile" +fi 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@ "$@" diff --git a/tests/FSRCDIR/Makefile b/tests/FSRCDIR/Makefile new file mode 100644 index 0000000..76e9392 --- /dev/null +++ b/tests/FSRCDIR/Makefile @@ -0,0 +1,5 @@ +FOREIGN = autotools +TEST_PREREQS = + +.include "test.mk" +.include <mkc.mk> diff --git a/tests/FSRCDIR/expect.out b/tests/FSRCDIR/expect.out new file mode 100644 index 0000000..3f29ee1 --- /dev/null +++ b/tests/FSRCDIR/expect.out @@ -0,0 +1,3 @@ +=========== all ============ +FSRCDIR should not be empty +*** Error code 1 diff --git a/tests/FSRCDIR/test.mk b/tests/FSRCDIR/test.mk new file mode 100644 index 0000000..6059c8f --- /dev/null +++ b/tests/FSRCDIR/test.mk @@ -0,0 +1,10 @@ +.PHONY : test_output +test_output : + @set -e; \ + \ + echo =========== all ============; \ + ${MAKE} ${MAKEFLAGS} all 2>&1 | head -n 2; \ + \ + ${MAKE} ${MAKEFLAGS} cleandir > /dev/null + +.include <mkc.minitest.mk> diff --git a/tests/Makefile.inc b/tests/Makefile.inc new file mode 100644 index 0000000..2b0aecf --- /dev/null +++ b/tests/Makefile.inc @@ -0,0 +1 @@ +.include "../examples/Makefile.inc" diff --git a/tests/configure_test/Makefile b/tests/configure_test/Makefile new file mode 100644 index 0000000..ea986a0 --- /dev/null +++ b/tests/configure_test/Makefile @@ -0,0 +1,16 @@ +.PHONY: test_output +test_output: + @set -e; cd ${.CURDIR}; \ + OPSYS=${OPSYS}; export OPSYS; \ + env CPPFLAGS="${CPPFLAGS} -I${.CURDIR}" ${MAKE} ${MAKEFLAGS} \ + -f mkc_test.mk; \ + echo ===============================; \ + env CPPFLAGS="${CPPFLAGS} -I${.CURDIR}" ${MAKE} ${MAKEFLAGS} \ + -f mkc_test_preset.mk \ + -f mkc_test.mk; \ + true ===============================; \ + ${MAKE} ${MAKEFLAGS} -f mkc_test_preset.mk -f mkc_test.mk \ + cleandir > /dev/null 2>&1 + +.include <mkc.minitest.mk> +.include <mkc.mk> diff --git a/tests/configure_test/custom/custom_check1.c b/tests/configure_test/custom/custom_check1.c new file mode 100644 index 0000000..975a3b3 --- /dev/null +++ b/tests/configure_test/custom/custom_check1.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main (int argc, char **argv) +{ + puts ("Hello World!"); + return 0; +} diff --git a/tests/configure_test/custom/custom_check3.c b/tests/configure_test/custom/custom_check3.c new file mode 100644 index 0000000..bc0a5a1 --- /dev/null +++ b/tests/configure_test/custom/custom_check3.c @@ -0,0 +1,4 @@ +int main (int argc, char **argv) +{ + return 1; +} diff --git a/tests/configure_test/custom/my_check2.c b/tests/configure_test/custom/my_check2.c new file mode 100644 index 0000000..7c32983 --- /dev/null +++ b/tests/configure_test/custom/my_check2.c @@ -0,0 +1,3 @@ +#include <stdin.h> + +bad code here diff --git a/tests/configure_test/expect.out b/tests/configure_test/expect.out new file mode 100644 index 0000000..5b8d11b --- /dev/null +++ b/tests/configure_test/expect.out @@ -0,0 +1,99 @@ +HAVE_HEADER.sys_time_h=1 +HAVE_HEADER.string_h=1 +HAVE_FUNCLIB.strcpy=1 +HAVE_FUNCLIB.sqrt=ok +HAVE_FUNC2.strcmp.string_h=1 +HAVE_FUNC3.strcpy=0 +SIZEOF.int=n +SIZEOF.long_long=n +SIZEOF.voidP=n +SIZEOF.size_t.string_h=n +HAVE_TYPE.size_t.string_h=1 +HAVE_TYPE.bad_type=0 +HAVE_HEADER.bad_header_h=0 +HAVE_HEADER.bad_dir_bad_header_h=0 +HAVE_FUNCLIB.bad_func=0 +HAVE_FUNCLIB.bad_func.bad_lib=0 +HAVE_DEFINE.__BAD_DEFINE__=0 +HAVE_FUNC1.bad_func=0 +HAVE_FUNC1.bad_func.bad_header=0 +SIZEOF.bad_type=failed +SIZEOF.bad_type.bad_header_h=failed +HAVE_FUNCLIB.superfunc1=0 +HAVE_FUNCLIB.superfunc2.superlib2=0 +HAVE_MEMBER.struct_tm_tm_isdst.time_h=1 +HAVE_MEMBER.struct_sockaddr_in_sin_addr_s_addr.netinet_in_h=1 +HAVE_MEMBER.bad_member=0 +HAVE_MEMBER.bad_member.string_h=0 +HAVE_HEADER.include_mkc_test_h=1 +HAVE_DEFINE.MKC_TEST_DEFINE.include_mkc_test_h=1 +HAVE_FUNC5.mkc_test_func.include_mkc_test_h=1 +HAVE_VAR.mkc_test_var.include_mkc_test_h=1 +HAVE_MEMBER.struct_mkc_test_t_a.include_mkc_test_h=1 +HAVE_MEMBER.struct_mkc_test_t_b_c.include_mkc_test_h=1 +HAVE_PROTOTYPE.strcmp_ok=1 +HAVE_PROTOTYPE.strcmp_bad=0 +CUSTOM.custom_check1=1 +CUSTOM.custom_check2=0 +HAVE_PROG.sh=1 +PROG.sh=/somewhere/bin/sh +HAVE_PROG.awk=1 +PROG.awk=/somewhere/bin/awk +HAVE_PROG.megaprog-x34=0 +PROG.megaprog-x34= +MKC_AUTO_CFLAGS= -DHAVE_HEADER_SYS_TIME_H=1 -DHAVE_HEADER_STRING_H=1 -DHAVE_HEADER_INCLUDE_MKC_TEST_H=1 -DSIZEOF_INT=n -DSIZEOF_LONG_LONG=n -DSIZEOF_VOIDP=n -DSIZEOF_SIZE_T_STRING_H=n -DHAVE_DEFINE_MKC_TEST_DEFINE_INCLUDE_MKC_TEST_H=1 -DHAVE_TYPE_SIZE_T_STRING_H=1 -DHAVE_VAR_ERRNO_ERRNO_H=1 -DHAVE_VAR_MKC_TEST_VAR_INCLUDE_MKC_TEST_H=1 -DHAVE_MEMBER_STRUCT_TM_TM_ISDST_TIME_H=1 -DHAVE_MEMBER_STRUCT_SOCKADDR_IN_SIN_ADDR_S_ADDR_ARPA_INET_H_NETINET_IN_H=1 -DHAVE_MEMBER_STRUCT_MKC_TEST_T_A_INCLUDE_MKC_TEST_H=1 -DHAVE_MEMBER_STRUCT_MKC_TEST_T_B_C_INCLUDE_MKC_TEST_H=1 -DHAVE_FUNC2_STRCMP_STRING_H=1 -DHAVE_FUNC5_MKC_TEST_FUNC_INCLUDE_MKC_TEST_H=1 -DCUSTOM_CUSTOM_CHECK1=1 -DHAVE_PROTOTYPE_STRCMP_OK=1 +MKC_AUTO_SRCS= superfunc1.c superfunc2.c +MKC_AUTO_LDADD= + +KNOWN_SYSTEM +MKC_COMMON_DEFINES_WORKS_FINE +=============================== +HAVE_HEADER.sys_time_h=2 +HAVE_HEADER.string_h=2 +HAVE_FUNCLIB.strcpy=2 +HAVE_FUNCLIB.sqrt=ok +HAVE_FUNC2.strcmp.string_h=2 +HAVE_FUNC3.strcpy=2 +SIZEOF.int=n +SIZEOF.long_long=n +SIZEOF.voidP=n +SIZEOF.size_t.string_h=n +HAVE_TYPE.size_t.string_h=2 +HAVE_TYPE.bad_type=2 +HAVE_HEADER.bad_header_h=0 +HAVE_HEADER.bad_dir_bad_header_h=0 +HAVE_FUNCLIB.bad_func=0 +HAVE_FUNCLIB.bad_func.bad_lib=0 +HAVE_DEFINE.__BAD_DEFINE__=2 +HAVE_FUNC1.bad_func=0 +HAVE_FUNC1.bad_func.bad_header=0 +SIZEOF.bad_type=failed +SIZEOF.bad_type.bad_header_h=failed +HAVE_FUNCLIB.superfunc1=0 +HAVE_FUNCLIB.superfunc2.superlib2=0 +HAVE_MEMBER.struct_tm_tm_isdst.time_h=1 +HAVE_MEMBER.struct_sockaddr_in_sin_addr_s_addr.netinet_in_h=1 +HAVE_MEMBER.bad_member=2 +HAVE_MEMBER.bad_member.string_h=2 +HAVE_HEADER.include_mkc_test_h=1 +HAVE_DEFINE.MKC_TEST_DEFINE.include_mkc_test_h=1 +HAVE_FUNC5.mkc_test_func.include_mkc_test_h=1 +HAVE_VAR.mkc_test_var.include_mkc_test_h=2 +HAVE_MEMBER.struct_mkc_test_t_a.include_mkc_test_h=1 +HAVE_MEMBER.struct_mkc_test_t_b_c.include_mkc_test_h=1 +HAVE_PROTOTYPE.strcmp_ok=0 +HAVE_PROTOTYPE.strcmp_bad=1 +CUSTOM.custom_check1=0 +CUSTOM.custom_check2=1 +HAVE_PROG.sh=1 +PROG.sh=/somewhere/bin/sh +HAVE_PROG.awk=0 +PROG.awk= +HAVE_PROG.megaprog-x34=0 +PROG.megaprog-x34=/bad/path +MKC_AUTO_CFLAGS= -DHAVE_HEADER_SYS_TIME_H=2 -DHAVE_HEADER_STRING_H=2 -DHAVE_HEADER_INCLUDE_MKC_TEST_H=1 -DSIZEOF_INT=n -DSIZEOF_LONG_LONG=n -DSIZEOF_VOIDP=n -DSIZEOF_SIZE_T_STRING_H=n -DHAVE_DEFINE___BAD_DEFINE__=1 -DHAVE_DEFINE_MKC_TEST_DEFINE_INCLUDE_MKC_TEST_H=1 -DHAVE_TYPE_SIZE_T_STRING_H=1 -DHAVE_TYPE_BAD_TYPE=1 -DHAVE_VAR_ERRNO_ERRNO_H=1 -DHAVE_VAR_MKC_TEST_VAR_INCLUDE_MKC_TEST_H=1 -DHAVE_MEMBER_STRUCT_TM_TM_ISDST_TIME_H=1 -DHAVE_MEMBER_STRUCT_SOCKADDR_IN_SIN_ADDR_S_ADDR_ARPA_INET_H_NETINET_IN_H=1 -DHAVE_MEMBER_BAD_MEMBER=1 -DHAVE_MEMBER_BAD_MEMBER_STRING_H=1 -DHAVE_MEMBER_STRUCT_MKC_TEST_T_A_INCLUDE_MKC_TEST_H=1 -DHAVE_MEMBER_STRUCT_MKC_TEST_T_B_C_INCLUDE_MKC_TEST_H=1 -DHAVE_FUNC2_STRCMP_STRING_H=1 -DHAVE_FUNC3_STRCPY=1 -DHAVE_FUNC5_MKC_TEST_FUNC_INCLUDE_MKC_TEST_H=1 -DCUSTOM_CUSTOM_CHECK2=1 -DHAVE_PROTOTYPE_STRCMP_BAD=1 +MKC_AUTO_SRCS= superfunc1.c superfunc2.c +MKC_AUTO_LDADD= + +KNOWN_SYSTEM +MKC_COMMON_DEFINES_WORKS_FINE diff --git a/tests/configure_test/include/mkc_test.h b/tests/configure_test/include/mkc_test.h new file mode 100644 index 0000000..6c3e099 --- /dev/null +++ b/tests/configure_test/include/mkc_test.h @@ -0,0 +1,15 @@ +#define MKC_TEST_DEFINE 1 + +extern int mkc_test_var; +extern int mkc_test_var2; + +int mkc_test_func (int a, int b, int c, int d, int e); +int mkc_test_func2 (void); + +struct mkc_test_t { + int a; + struct test_t { + int c; + } b; + int d; +}; diff --git a/tests/configure_test/mkc_test.mk b/tests/configure_test/mkc_test.mk new file mode 100644 index 0000000..3a09220 --- /dev/null +++ b/tests/configure_test/mkc_test.mk @@ -0,0 +1,140 @@ +MKC_COMMON_DEFINES.NetBSD= -DSYSTEM_NetBSD +MKC_COMMON_DEFINES.FreeBSD= -DSYSTEM_FreeBSD +MKC_COMMON_DEFINES.OpenBSD= -DSYSTEM_OpenBSD +MKC_COMMON_DEFINES.DragonFly= -DSYSTEM_DragonFly +MKC_COMMON_DEFINES.MirBSD= -DSYSTEM_MirBSD +MKC_COMMON_DEFINES.SunOS= -DSYSTEM_SunOS +MKC_COMMON_DEFINES.Linux= -DSYSTEM_Linux +MKC_COMMON_DEFINES.Darwin= -DSYSTEM_Darwin +MKC_COMMON_DEFINES.Interix= -DSYSTEM_Interix +MKC_COMMON_DEFINES.QNX= -DSYSTEM_QNX +MKC_COMMON_DEFINES.HP-UX= -DSYSTEM_HPUX +MKC_COMMON_DEFINES.OSF1= -DSYSTEM_OSF1 +MKC_COMMON_DEFINES.Cygwin= -DSYSTEM_CYGWIN +MKC_COMMON_DEFINES.Haiku= -DSYSTEM_Haiku +MKC_COMMON_DEFINES.IRIX64= -DSYSTEM_IRIX64 + +MKC_COMMON_DEFINES= -DMKC_COMMON_DEFINES_WORKS_FINE +MKC_COMMON_DEFINES+= -D__JUSTATEST + +MKC_COMMON_HEADERS+= string.h + +MKC_SOURCE_FUNCLIBS+= superfunc1 +MKC_SOURCE_FUNCLIBS+= superfunc2:superlib2 + +MKC_CHECK_HEADERS+= sys/time.h string.h +MKC_CHECK_HEADERS+= bad_dir/bad_header.h bad_header.h +MKC_CHECK_HEADERS+= include/mkc_test.h + +MKC_REQUIRE_HEADERS+= stdio.h + +MKC_CHECK_FUNCLIBS+= strcpy sqrt:m +MKC_CHECK_FUNCLIBS+= bad_func:bad_lib bad_func + +MKC_NOAUTO_FUNCLIBS+= sqrt:m + +MKC_CHECK_DEFINES+= __BAD_DEFINE__ +MKC_CHECK_DEFINES+= MKC_TEST_DEFINE:include/mkc_test.h + +MKC_REQUIRE_DEFINES+= __JUSTATEST + +MKC_CHECK_VARS+= errno:errno.h +MKC_CHECK_VARS+= bad_var:bar_header +MKC_CHECK_VARS+= mkc_test_var:include/mkc_test.h + +MKC_REQUIRE_VARS+= mkc_test_var2:include/mkc_test.h + +MKC_CHECK_FUNCS2+= strcmp:string.h +MKC_CHECK_FUNCS3+= strcpy +MKC_CHECK_FUNCS1+= bad_func bad_func:bad_header +MKC_CHECK_FUNCS5+= mkc_test_func:include/mkc_test.h + +MKC_REQUIRE_FUNCS0+= mkc_test_func2:include/mkc_test.h + +MKC_CHECK_SIZEOF+= int long-long void* size_t:string.h +MKC_CHECK_SIZEOF+= bad_type bad-type:bad_header.h + +MKC_CHECK_TYPES+= size_t:string.h +MKC_CHECK_TYPES+= bad_type bad-type:bad_header.h + +MKC_REQUIRE_TYPES+= size_t:stdlib.h + +MKC_CHECK_MEMBERS+= struct-tm.tm_isdst:time.h +MKC_CHECK_MEMBERS+= struct-sockaddr_in.sin_addr.s_addr:arpa/inet.h:netinet/in.h +MKC_CHECK_MEMBERS+= bad.member +MKC_CHECK_MEMBERS+= bad.member:string.h +MKC_CHECK_MEMBERS+= struct-mkc_test_t.a:include/mkc_test.h +MKC_CHECK_MEMBERS+= struct-mkc_test_t.b.c:include/mkc_test.h + +MKC_REQUIRE_MEMBERS+= struct-mkc_test_t.d:include/mkc_test.h + +MKC_CHECK_PROGS+= awk sh megaprog-x34 + +MKC_CUSTOM_DIR= ${.CURDIR}/custom + +MKC_CHECK_CUSTOM+= custom_check1 custom_check2 +MKC_CUSTOM_FN.custom_check2= my_check2.c + +MKC_REQUIRE_CUSTOM+= custom_check3 + +MKC_CHECK_PROTOTYPES = strcmp_ok strcmp_bad +MKC_PROTOTYPE_FUNC.strcmp_ok = int strcmp(const char*, const char*) +MKC_PROTOTYPE_FUNC.strcmp_bad = int strcmp(const char*, const char*, int lalala) +MKC_PROTOTYPE_HEADERS.strcmp_ok = string.h +MKC_PROTOTYPE_HEADERS.strcmp_bad = string.h + +vars+= HAVE_HEADER.sys_time_h HAVE_HEADER.string_h \ + HAVE_FUNCLIB.strcpy HAVE_FUNCLIB.sqrt \ + HAVE_FUNC2.strcmp.string_h HAVE_FUNC3.strcpy \ + SIZEOF.int SIZEOF.long_long SIZEOF.voidP SIZEOF.size_t.string_h \ + HAVE_TYPE.size_t.string_h \ + HAVE_TYPE.bad_type \ + HAVE_HEADER.bad_header_h HAVE_HEADER.bad_dir_bad_header_h \ + HAVE_FUNCLIB.bad_func HAVE_FUNCLIB.bad_func.bad_lib \ + HAVE_DEFINE.__BAD_DEFINE__ \ + HAVE_FUNC1.bad_func HAVE_FUNC1.bad_func.bad_header \ + SIZEOF.bad_type SIZEOF.bad_type.bad_header_h \ + HAVE_FUNCLIB.superfunc1 HAVE_FUNCLIB.superfunc2.superlib2 \ + HAVE_MEMBER.struct_tm_tm_isdst.time_h \ + HAVE_MEMBER.struct_sockaddr_in_sin_addr_s_addr.netinet_in_h \ + HAVE_MEMBER.bad_member \ + HAVE_MEMBER.bad_member.string_h \ + HAVE_HEADER.include_mkc_test_h \ + HAVE_DEFINE.MKC_TEST_DEFINE.include_mkc_test_h \ + HAVE_FUNC5.mkc_test_func.include_mkc_test_h \ + HAVE_VAR.mkc_test_var.include_mkc_test_h \ + HAVE_MEMBER.struct_mkc_test_t_a.include_mkc_test_h \ + HAVE_MEMBER.struct_mkc_test_t_b_c.include_mkc_test_h \ + HAVE_PROTOTYPE.strcmp_ok HAVE_PROTOTYPE.strcmp_bad \ + \ + CUSTOM.custom_check1 CUSTOM.custom_check2 \ + \ + HAVE_PROG.sh PROG.sh \ + HAVE_PROG.awk PROG.awk \ + HAVE_PROG.megaprog-x34 PROG.megaprog-x34 \ + \ + MKC_AUTO_CFLAGS MKC_AUTO_SRCS MKC_AUTO_LDADD + +.include <mkc.configure.mk> + +HAVE_MEMBER.struct_sockaddr_in_sin_addr_s_addr.netinet_in_h ?= \ + ${HAVE_MEMBER.struct_sockaddr_in_sin_addr_s_addr.arpa_inet_h.netinet_in_h} + +.if HAVE_FUNCLIB.sqrt || HAVE_FUNCLIB.sqrt.m +HAVE_FUNCLIB.sqrt= ok +.endif + +all: +.for i in ${vars} + @echo ${i}=${${i}} | \ + sed -e 's|\([^ ]*SIZEOF[^ =]*\)=[0-9][0-9]*|\1=n|g' \ + -e 's|\([^ ]*PROG[^ =]*\)=[^ =]*bin/|\1=/somewhere/bin/|g' \ + -e '/^MKC_AUTO_SRCS=/ s|/[^ ]*/||g' +.endfor + @echo '' + @printf "%s\n" "${CPPFLAGS}" | \ + sed "s/^.*-DSYSTEM_.*$$/KNOWN_SYSTEM/" + @printf "%s\n" "${CPPFLAGS}" | \ + sed 's/^.*\(MKC_COMMON_DEFINES_WORKS_FINE\).*$$/\1/' + +.include <mkc.mk> diff --git a/tests/configure_test/mkc_test_preset.mk b/tests/configure_test/mkc_test_preset.mk new file mode 100644 index 0000000..ec381a8 --- /dev/null +++ b/tests/configure_test/mkc_test_preset.mk @@ -0,0 +1,24 @@ +# I use invalid value 2 here in order to view it in a difference in +# case of failure +HAVE_HEADER.sys_time_h=2 +HAVE_HEADER.string_h=2 +HAVE_FUNCLIB.strcpy=2 +HAVE_FUNCLIB.sqrt.m=2 +SIZEOF.int=4 +SIZEOF.long_long=8 +SIZEOF.voidP=8 +SIZEOF.size_t.string_h=4 +HAVE_DEFINE.__BAD_DEFINE__=2 +HAVE_VAR.mkc_test_var.include_mkc_test_h=2 +HAVE_MEMBER.bad_member=2 +HAVE_MEMBER.bad_member.string_h=2 +HAVE_FUNC2.strcmp.string_h=2 +HAVE_FUNC3.strcpy=2 +HAVE_TYPE.size_t.string_h=2 +HAVE_TYPE.bad_type=2 +CUSTOM.custom_check1=0 +CUSTOM.custom_check2=1 +PROG.awk= +PROG.megaprog-x34=/bad/path +HAVE_PROTOTYPE.strcmp_ok=0 +HAVE_PROTOTYPE.strcmp_bad=1 diff --git a/tests/create_cachedir/Makefile b/tests/create_cachedir/Makefile new file mode 100644 index 0000000..74abaa5 --- /dev/null +++ b/tests/create_cachedir/Makefile @@ -0,0 +1,8 @@ +PROG = hello + +MKC_CHECK_HEADERS = string.h + +CLEANFILES += ${.OBJDIR}/${.CURDIR:T}.test.out + +.include "test.mk" +.include <mkc.prog.mk> diff --git a/tests/create_cachedir/expect.out b/tests/create_cachedir/expect.out new file mode 100644 index 0000000..bfd8cd9 --- /dev/null +++ b/tests/create_cachedir/expect.out @@ -0,0 +1,2 @@ +checking for header string.h... yes +cache file exists diff --git a/tests/create_cachedir/hello.c b/tests/create_cachedir/hello.c new file mode 100644 index 0000000..b8327a7 --- /dev/null +++ b/tests/create_cachedir/hello.c @@ -0,0 +1,5 @@ +int main (int argc, char ** argv) +{ + /* just a test */ + return 0; +} diff --git a/tests/create_cachedir/test.mk b/tests/create_cachedir/test.mk new file mode 100644 index 0000000..cdd989e --- /dev/null +++ b/tests/create_cachedir/test.mk @@ -0,0 +1,22 @@ +TEST_MKC_CACHEDIR = ${.CURDIR}/.cache +CLEANFILES += ${.OBJDIR}/${.CURDIR:T}.test.out ${TEST_MKC_CACHEDIR} +CLEANDIRS += ${TEST_MKC_CACHEDIR} + +.PHONY : test_output +test_output: + @echo 'Testing ${.CURDIR}... ' 1>&2; \ + tmp_out=${.OBJDIR}/${.CURDIR:T}.test.out; \ + rm -rf $$tmp_out ${TEST_MKC_CACHEDIR}; \ + ${MAKE} ${MAKEFLAGS} errorcheck MKC_CACHEDIR=${TEST_MKC_CACHEDIR} 2>&1 | \ + grep 'checking.*header' ;\ + if test -f ${TEST_MKC_CACHEDIR}/_mkc_header_string_h.c; then \ + echo cache file exists; \ + else \ + echo cache file does not exist; \ + fi \ + ; \ + ${MAKE} ${MAKEFLAGS} cleandir 2>/dev/null 1>&2 + +# rm -rf $$MKC_CACHEDIR; \ + +.include <mkc.minitest.mk> diff --git a/tests/endianess/Makefile b/tests/endianess/Makefile new file mode 100644 index 0000000..958a2e4 --- /dev/null +++ b/tests/endianess/Makefile @@ -0,0 +1,14 @@ +# this is a backward compatibility test for endianess (single n) + +MKC_CHECK_BUILTINS += endianess + +MKC_REQD = 0.12.0 + +.include <mkc.configure.mk> + +.PHONY: showme +showme: + @echo BUILTIN.endianess=${BUILTIN.endianess} + +.include "test.mk" +.include <mkc.prog.mk> diff --git a/tests/endianess/expect.out b/tests/endianess/expect.out new file mode 100644 index 0000000..ab508f5 --- /dev/null +++ b/tests/endianess/expect.out @@ -0,0 +1,3 @@ +=========== all ============ +warning: "endianess test deprecated; use endianness instead" +BUILTIN.endianess=big diff --git a/tests/endianess/test.mk b/tests/endianess/test.mk new file mode 100644 index 0000000..26d9005 --- /dev/null +++ b/tests/endianess/test.mk @@ -0,0 +1,12 @@ +CLEANDIRS += ${.CURDIR}/testdir + +.PHONY : test_output +test_output: + @set -e; \ + \ + echo =========== all ============; \ + ${MAKE} ${MAKEFLAGS} showme 2>&1 | \ + sed -e 's,^.*warning:,warning:,' -e 's,little,big,'; \ + ${MAKE} ${MAKEFLAGS} distclean > /dev/null + +.include <mkc.minitest.mk> diff --git a/tests/intexts_cleantrg/Makefile b/tests/intexts_cleantrg/Makefile new file mode 100644 index 0000000..6ed3399 --- /dev/null +++ b/tests/intexts_cleantrg/Makefile @@ -0,0 +1,6 @@ +INFILES = foo +INTEXTS_REPLS = AWK ${PROG.awk} +MKC_CHECK_PROGS = awk + +.include "test.mk" +.include <mkc.mk> diff --git a/tests/intexts_cleantrg/expect.out b/tests/intexts_cleantrg/expect.out new file mode 100644 index 0000000..b0d1d21 --- /dev/null +++ b/tests/intexts_cleantrg/expect.out @@ -0,0 +1,29 @@ +=========== all ============ +/objdir/Makefile +/objdir/_mkc_prog_awk.err +/objdir/_mkc_prog_awk.res +/objdir/expect.out +/objdir/foo +/objdir/foo.in +/objdir/intexts_cleantrg.test.out.tmp +/objdir/test.mk +========== clean =========== +/objdir/Makefile +/objdir/_mkc_prog_awk.err +/objdir/_mkc_prog_awk.res +/objdir/expect.out +/objdir/foo.in +/objdir/intexts_cleantrg.test.out.tmp +/objdir/test.mk +======= distclean ========== +/objdir/Makefile +/objdir/expect.out +/objdir/foo.in +/objdir/intexts_cleantrg.test.out.tmp +/objdir/test.mk +======= cleandir ========== +/objdir/Makefile +/objdir/expect.out +/objdir/foo.in +/objdir/intexts_cleantrg.test.out.tmp +/objdir/test.mk diff --git a/tests/intexts_cleantrg/foo.in b/tests/intexts_cleantrg/foo.in new file mode 100644 index 0000000..9e1d5a8 --- /dev/null +++ b/tests/intexts_cleantrg/foo.in @@ -0,0 +1,6 @@ +#!@AWK@ + +BEGIN { + print "Hello World!" +} + diff --git a/tests/intexts_cleantrg/test.mk b/tests/intexts_cleantrg/test.mk new file mode 100644 index 0000000..c1964a5 --- /dev/null +++ b/tests/intexts_cleantrg/test.mk @@ -0,0 +1,26 @@ +.PHONY : test_output +test_output : + @set -e; \ + \ + echo =========== all ============; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========== clean ===========; \ + ${MAKE} ${MAKEFLAGS} clean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======= distclean ==========; \ + ${MAKE} ${MAKEFLAGS} distclean > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======= cleandir ==========; \ + ${MAKE} ${MAKEFLAGS} distclean > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + ${MAKE} ${MAKEFLAGS} cleandir > /dev/null + +.include <mkc.minitest.mk> diff --git a/tests/lua_dirs/Makefile b/tests/lua_dirs/Makefile new file mode 100644 index 0000000..80603d8 --- /dev/null +++ b/tests/lua_dirs/Makefile @@ -0,0 +1,12 @@ +LUA_LMODDIR= ${PREFIX}/share/luamods_l +LUA_CMODDIR= ${PREFIX}/lib/luamods_c + +LUA_LMODULES= ../../examples/hello_lua/foo.lua +LUA_LMODULES+= ../../examples/hello_lua/bar.lua +LUA_CMODULE= baz + +SCRIPTS = ${INSCRIPTS:T} +INSCRIPTS= ../../examples/hello_lua/foobar + +.include <mkc.lib.mk> +.include "test.mk" diff --git a/tests/lua_dirs/baz.c b/tests/lua_dirs/baz.c new file mode 100644 index 0000000..4ba942e --- /dev/null +++ b/tests/lua_dirs/baz.c @@ -0,0 +1,13 @@ +#include <lua.h> + +static int baz (lua_State *L) +{ + lua_pushstring(L, "baz"); + return 1; +} + +int luaopen_baz (lua_State *L) +{ + lua_register(L, "baz", baz); + return 0; +} diff --git a/tests/lua_dirs/expect.out b/tests/lua_dirs/expect.out new file mode 100644 index 0000000..ef92d27 --- /dev/null +++ b/tests/lua_dirs/expect.out @@ -0,0 +1,63 @@ +=========== all ============ +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_header_lua_h.c +/objdir/_mkc_header_lua_h.err +/objdir/_mkc_header_lua_h.res +/objdir/_mkc_pkgconfig_lua.err +/objdir/_mkc_pkgconfig_lua.res +/objdir/_mkc_pkgconfig_lua_cflags.err +/objdir/_mkc_pkgconfig_lua_cflags.res +/objdir/_mkc_pkgconfig_lua_libs.err +/objdir/_mkc_pkgconfig_lua_libs.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/_mkc_prog_pkg-config.err +/objdir/_mkc_prog_pkg-config.res +/objdir/baz.c +/objdir/baz.os +/objdir/baz.so +/objdir/expect.out +/objdir/foobar +/objdir/lua_dirs.test.out.tmp +/objdir/test.mk +========= install ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/bin/foobar +/objdir/prefix/lib +/objdir/prefix/lib/luamods_c +/objdir/prefix/lib/luamods_c/baz.so +/objdir/prefix/share +/objdir/prefix/share/luamods_l +/objdir/prefix/share/luamods_l/bar.lua +/objdir/prefix/share/luamods_l/foo.lua +======== uninstall ========= +========== clean =========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_header_lua_h.c +/objdir/_mkc_header_lua_h.err +/objdir/_mkc_header_lua_h.res +/objdir/_mkc_pkgconfig_lua.err +/objdir/_mkc_pkgconfig_lua.res +/objdir/_mkc_pkgconfig_lua_cflags.err +/objdir/_mkc_pkgconfig_lua_cflags.res +/objdir/_mkc_pkgconfig_lua_libs.err +/objdir/_mkc_pkgconfig_lua_libs.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/_mkc_prog_pkg-config.err +/objdir/_mkc_prog_pkg-config.res +/objdir/baz.c +/objdir/expect.out +/objdir/lua_dirs.test.out.tmp +/objdir/test.mk +======= distclean ========== +/objdir/Makefile +/objdir/baz.c +/objdir/expect.out +/objdir/lua_dirs.test.out.tmp +/objdir/test.mk diff --git a/tests/lua_dirs/test.mk b/tests/lua_dirs/test.mk new file mode 100644 index 0000000..824da7e --- /dev/null +++ b/tests/lua_dirs/test.mk @@ -0,0 +1,33 @@ +DISTCLEANDIRS+= ${.CURDIR}/usr + +.PHONY : test_output +test_output: + @set -e; \ + rm -rf ${.OBJDIR}/usr; \ + \ + echo =========== all ============; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= install ==========; \ + ${MAKE} ${MAKEFLAGS} installdirs install DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}" | uniq; \ + \ + echo ======== uninstall =========; \ + ${MAKE} ${MAKEFLAGS} uninstall DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========== clean ===========; \ + ${MAKE} ${MAKEFLAGS} clean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======= distclean ==========; \ + ${MAKE} ${MAKEFLAGS} distclean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}" + +.include <mkc.minitest.mk> diff --git a/tests/mkdll/Makefile b/tests/mkdll/Makefile new file mode 100644 index 0000000..c3cc464 --- /dev/null +++ b/tests/mkdll/Makefile @@ -0,0 +1,6 @@ +.PATH: ../../examples/hello_cxxlib/cxxlib + +MKDLL = only + +.include "../../examples/hello_cxxlib/cxxlib/Makefile" +.include "../mkpiclib/test.mk" diff --git a/tests/mkdll/expect.out b/tests/mkdll/expect.out new file mode 100644 index 0000000..c1c93eb --- /dev/null +++ b/tests/mkdll/expect.out @@ -0,0 +1,64 @@ +=========== all ============ +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_cxx_type.err +/objdir/_mkc_cxx_type.res +/objdir/_mkc_funclib_dummy.c +/objdir/_mkc_funclib_dummy.err +/objdir/_mkc_funclib_dummy.res +/objdir/_mkc_prog_cxx.err +/objdir/_mkc_prog_cxx.res +/objdir/cxxlib.so +/objdir/dummy.os +/objdir/expect.out +/objdir/hello_msg1.os +/objdir/hello_msg2.os +/objdir/mkdll.test.out.tmp +========= install ========== +/objdir/prefix +/objdir/prefix/include +/objdir/prefix/include/hello_msg.h +/objdir/prefix/include/impl +/objdir/prefix/include/impl/hello_msg1.h +/objdir/prefix/include/impl/hello_msg2.h +/objdir/prefix/lib +/objdir/prefix/lib/cxxlib.so +======== uninstall ========= +========== clean =========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_cxx_type.err +/objdir/_mkc_cxx_type.res +/objdir/_mkc_funclib_dummy.c +/objdir/_mkc_funclib_dummy.err +/objdir/_mkc_funclib_dummy.res +/objdir/_mkc_prog_cxx.err +/objdir/_mkc_prog_cxx.res +/objdir/expect.out +/objdir/mkdll.test.out.tmp +======= CLEANFILES ========== +/objdir/mkdll.test.out +cxxlib.so +dummy.o +dummy.op +dummy.os +hello_msg1.o +hello_msg1.op +hello_msg1.os +hello_msg2.o +hello_msg2.op +hello_msg2.os +libcxxlib.a +libcxxlib_p.a +libcxxlib_pic.a +======= UNINSTALLFILES ========== +/prefix/include/hello_msg.h +/prefix/include/impl/hello_msg1.h +/prefix/include/impl/hello_msg2.h +/prefix/lib/cxxlib.so +======= distclean ========== +/objdir/Makefile +/objdir/expect.out +/objdir/mkdll.test.out.tmp diff --git a/tests/mkinstall/Makefile b/tests/mkinstall/Makefile new file mode 100644 index 0000000..8a4cc6a --- /dev/null +++ b/tests/mkinstall/Makefile @@ -0,0 +1,12 @@ +PROG = qux +MAN = qux.1 +FILES = foo +SCRIPTS = bar +INCS = baz.h +LINKS = ${BINDIR}/qux ${BINDIR}/qux2 +SYMLINKS = ${BINDIR}/foo ${BINDIR}/foo2 +MLINKS = qux.1 qux2.1 +TEXINFO = qux.info + +.include "test.mk" +.include <mkc.mk> diff --git a/tests/mkinstall/bar b/tests/mkinstall/bar new file mode 100755 index 0000000..97cca98 --- /dev/null +++ b/tests/mkinstall/bar @@ -0,0 +1,3 @@ +#!/bin/sh + +echo 'Hello World!' diff --git a/tests/mkinstall/baz.h b/tests/mkinstall/baz.h new file mode 100644 index 0000000..de42f2d --- /dev/null +++ b/tests/mkinstall/baz.h @@ -0,0 +1 @@ +extern int baz; diff --git a/tests/mkinstall/expect.out b/tests/mkinstall/expect.out new file mode 100644 index 0000000..4e40bcf --- /dev/null +++ b/tests/mkinstall/expect.out @@ -0,0 +1,55 @@ +=========== all ============ +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_prog_cc.err +/objdir/_mkc_prog_cc.res +/objdir/bar +/objdir/baz.h +/objdir/expect.out +/objdir/foo +/objdir/foo.in +/objdir/mkinstall.test.out.tmp +/objdir/qux +/objdir/qux.1 +/objdir/qux.c +/objdir/qux.cat1 +/objdir/qux.info +/objdir/qux.o +/objdir/qux.texinfo +/objdir/test.mk +===== all SHRTOUT=yes ====== +CC: qux.c +LD: qux +NROFF: qux.cat1 +TEXINFO: qux.info +========= installdirs MKINSTALL=no ========== +========= install MKINSTALL=no ========== +========= installdirs ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/include +/objdir/prefix/info +/objdir/prefix/man +/objdir/prefix/man/cat1 +/objdir/prefix/man/man1 +========= install ========== +/objdir/prefix +/objdir/prefix/bin +/objdir/prefix/bin/bar +/objdir/prefix/bin/foo +/objdir/prefix/bin/foo2 +/objdir/prefix/bin/qux +/objdir/prefix/bin/qux2 +/objdir/prefix/include +/objdir/prefix/include/baz.h +/objdir/prefix/info +/objdir/prefix/info/dir +/objdir/prefix/info/qux.info +/objdir/prefix/man +/objdir/prefix/man/cat1 +/objdir/prefix/man/cat1/qux.0 +/objdir/prefix/man/cat1/qux2.0 +/objdir/prefix/man/man1 +/objdir/prefix/man/man1/qux.1 +/objdir/prefix/man/man1/qux2.1 diff --git a/tests/mkinstall/foo b/tests/mkinstall/foo new file mode 100644 index 0000000..a371886 --- /dev/null +++ b/tests/mkinstall/foo @@ -0,0 +1 @@ +# lalala diff --git a/tests/mkinstall/foo.in b/tests/mkinstall/foo.in new file mode 100644 index 0000000..9e1d5a8 --- /dev/null +++ b/tests/mkinstall/foo.in @@ -0,0 +1,6 @@ +#!@AWK@ + +BEGIN { + print "Hello World!" +} + diff --git a/tests/mkinstall/qux.1 b/tests/mkinstall/qux.1 new file mode 100644 index 0000000..7c0573a --- /dev/null +++ b/tests/mkinstall/qux.1 @@ -0,0 +1,15 @@ +.\" $NetBSD$ +.\" +.\" Copyright (c) 2013 by Aleksey Cheusov (vle@gmx.net) +.\" Absolutely no warranty. +.\" +.TH SHELL_FUNCS 7 "Oct 29, 2013" +.SH NAME +qux - test +.SH DESCRIPTION +.B qux +is a test... +.SH SEE ALSO +.BR sh(1) , +.SH AUTHOR +Aleksey Cheusov <vle@gmx.net> diff --git a/tests/mkinstall/qux.c b/tests/mkinstall/qux.c new file mode 100644 index 0000000..bab33e9 --- /dev/null +++ b/tests/mkinstall/qux.c @@ -0,0 +1,4 @@ +int main (int argc, char **argv) +{ + return 0; +} diff --git a/tests/mkinstall/qux.texinfo b/tests/mkinstall/qux.texinfo new file mode 100644 index 0000000..13e7efb --- /dev/null +++ b/tests/mkinstall/qux.texinfo @@ -0,0 +1,38 @@ +\input texinfo @c -*-texinfo-*- +@setfilename qux.info +@settitle qux shell functions +@setchapternewpage odd + +@ifinfo +@dircategory Libraries +@direntry +* qux: (qux). Info page for qux. +@end direntry + +This is fake! + +@end ifinfo + +@titlepage +@title qux info page +@subtitle Edition 11, Version 22. +@subtitle 5 +@author Aleksey Cheusov + +@page +foobar + +@vskip 0pt plus 1filll +Copyright @copyright{} 2009 Aleksey Cheusov +@end titlepage + +@ifinfo +@node Top +@top qux fake! + +This is fake too! + +@end ifinfo + +@contents +@bye diff --git a/tests/mkinstall/test.mk b/tests/mkinstall/test.mk new file mode 100644 index 0000000..d3af118 --- /dev/null +++ b/tests/mkinstall/test.mk @@ -0,0 +1,47 @@ +.PHONY : test_output +test_output : + @set -e; \ + MKCATPAGES=yes; export MKCATPAGES; \ + rm -rf ${.OBJDIR}${PREFIX}; \ + \ + echo =========== all ============; \ + ${MAKE} ${MAKEFLAGS} all > /dev/null; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ===== all SHRTOUT=yes ======; \ + ${MAKE} ${MAKEFLAGS} clean > /dev/null; \ + env ${MAKE} ${MAKEFLAGS} SHRTOUT=YES all 2>&1 | \ + mkc_test_helper_paths; \ + \ + echo ========= installdirs MKINSTALL=no ==========; \ + env MKINSTALL=no ${MAKE} ${MAKEFLAGS} installdirs \ + DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f -o -type l -o -type d | grep '${PREFIX}' | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + rm -rf ${.OBJDIR}${PREFIX}; \ + \ + echo ========= install MKINSTALL=no ==========; \ + env MKINSTALL=no ${MAKE} ${MAKEFLAGS} install \ + DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f -o -type l -o -type d | grep '${PREFIX}' | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + rm -rf ${.OBJDIR}${PREFIX}; \ + \ + echo ========= installdirs ==========; \ + ${MAKE} ${MAKEFLAGS} installdirs \ + DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type l -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + rm -rf ${.OBJDIR}${PREFIX}; \ + \ + echo ========= install ==========; \ + ${MAKE} ${MAKEFLAGS} install \ + DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type l -o -type d | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + rm -rf ${.OBJDIR}${PREFIX}; \ + ${MAKE} ${MAKEFLAGS} distclean DESTDIR=${.OBJDIR} > /dev/null + +.include <mkc.minitest.mk> diff --git a/tests/mkpiclib/Makefile b/tests/mkpiclib/Makefile new file mode 100644 index 0000000..538c9f9 --- /dev/null +++ b/tests/mkpiclib/Makefile @@ -0,0 +1,8 @@ +.PATH: ../../examples/hello_cxxlib/cxxlib + +MKPICLIB= yes +MKSHLIB= no +MKSTATICLIB= no + +.include "../../examples/hello_cxxlib/cxxlib/Makefile" +.include "test.mk" diff --git a/tests/mkpiclib/expect.out b/tests/mkpiclib/expect.out new file mode 100644 index 0000000..9ec67cf --- /dev/null +++ b/tests/mkpiclib/expect.out @@ -0,0 +1,66 @@ +=========== all ============ +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_cxx_type.err +/objdir/_mkc_cxx_type.res +/objdir/_mkc_funclib_dummy.c +/objdir/_mkc_funclib_dummy.err +/objdir/_mkc_funclib_dummy.res +/objdir/_mkc_prog_cxx.err +/objdir/_mkc_prog_cxx.res +/objdir/dummy.os +/objdir/expect.out +/objdir/hello_msg1.os +/objdir/hello_msg2.os +/objdir/libcxxlib_pic.a +/objdir/mkpiclib.test.out.tmp +/objdir/test.mk +========= install ========== +/objdir/prefix +/objdir/prefix/include +/objdir/prefix/include/hello_msg.h +/objdir/prefix/include/impl +/objdir/prefix/include/impl/hello_msg1.h +/objdir/prefix/include/impl/hello_msg2.h +/objdir/prefix/lib +/objdir/prefix/lib/libcxxlib_pic.a +======== uninstall ========= +========== clean =========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_cxx_type.err +/objdir/_mkc_cxx_type.res +/objdir/_mkc_funclib_dummy.c +/objdir/_mkc_funclib_dummy.err +/objdir/_mkc_funclib_dummy.res +/objdir/_mkc_prog_cxx.err +/objdir/_mkc_prog_cxx.res +/objdir/expect.out +/objdir/mkpiclib.test.out.tmp +/objdir/test.mk +======= CLEANFILES ========== +/objdir/mkpiclib.test.out +dummy.o +dummy.op +dummy.os +hello_msg1.o +hello_msg1.op +hello_msg1.os +hello_msg2.o +hello_msg2.op +hello_msg2.os +libcxxlib.a +libcxxlib_p.a +libcxxlib_pic.a +======= UNINSTALLFILES ========== +/prefix/include/hello_msg.h +/prefix/include/impl/hello_msg1.h +/prefix/include/impl/hello_msg2.h +/prefix/lib/libcxxlib_pic.a +======= distclean ========== +/objdir/Makefile +/objdir/expect.out +/objdir/mkpiclib.test.out.tmp +/objdir/test.mk diff --git a/tests/mkpiclib/test.mk b/tests/mkpiclib/test.mk new file mode 100644 index 0000000..a4856dd --- /dev/null +++ b/tests/mkpiclib/test.mk @@ -0,0 +1,41 @@ +DISTCLEANDIRS+= ${.CURDIR}/usr + +.PHONY : test_output +test_output: + @set -e; \ + rm -rf ${.OBJDIR}${PREFIX}; \ + \ + echo =========== all ============; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ========= install ==========; \ + ${MAKE} ${MAKEFLAGS} installdirs install DESTDIR=${.OBJDIR} \ + > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f -o -type d -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo ======== uninstall =========; \ + ${MAKE} ${MAKEFLAGS} uninstall DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR}${PREFIX} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ========== clean ===========; \ + ${MAKE} ${MAKEFLAGS} clean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}";\ + \ + echo ======= CLEANFILES ==========; \ + ${MAKE} ${MAKEFLAGS} print_values VARS='CLEANFILES' MKCHECKS=no | \ + awk '{for(i=1; i<=NF; ++i) print $$i}' | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + echo ======= UNINSTALLFILES ==========; \ + ${MAKE} ${MAKEFLAGS} print_values2 VARS='UNINSTALLFILES' MKCHECKS=no | \ + awk '{for(i=1; i<=NF; ++i) print $$i}' | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + echo ======= distclean ==========; \ + ${MAKE} ${MAKEFLAGS} distclean DESTDIR=${.OBJDIR} > /dev/null; \ + find ${.OBJDIR} -type f | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}" + +.include <mkc.minitest.mk> diff --git a/tests/mkprofilelib/Makefile b/tests/mkprofilelib/Makefile new file mode 100644 index 0000000..121ad49 --- /dev/null +++ b/tests/mkprofilelib/Makefile @@ -0,0 +1,6 @@ +.PATH: ../../examples/hello_cxxlib/cxxlib + +MKPROFILELIB= yes + +.include "../../examples/hello_cxxlib/cxxlib/Makefile" +.include "../mkpiclib/test.mk" diff --git a/tests/mkprofilelib/expect.out b/tests/mkprofilelib/expect.out new file mode 100644 index 0000000..041e2e3 --- /dev/null +++ b/tests/mkprofilelib/expect.out @@ -0,0 +1,83 @@ +=========== all ============ +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_cxx_type.err +/objdir/_mkc_cxx_type.res +/objdir/_mkc_funclib_dummy.c +/objdir/_mkc_funclib_dummy.err +/objdir/_mkc_funclib_dummy.res +/objdir/_mkc_prog_cxx.err +/objdir/_mkc_prog_cxx.res +/objdir/dummy.o +/objdir/dummy.op +/objdir/dummy.os +/objdir/expect.out +/objdir/hello_msg1.o +/objdir/hello_msg1.op +/objdir/hello_msg1.os +/objdir/hello_msg2.o +/objdir/hello_msg2.op +/objdir/hello_msg2.os +/objdir/libcxxlib.a +/objdir/libcxxlib.so.1.0.5 +/objdir/libcxxlib_p.a +/objdir/mkprofilelib.test.out.tmp +========= install ========== +/objdir/prefix +/objdir/prefix/include +/objdir/prefix/include/hello_msg.h +/objdir/prefix/include/impl +/objdir/prefix/include/impl/hello_msg1.h +/objdir/prefix/include/impl/hello_msg2.h +/objdir/prefix/lib +/objdir/prefix/lib/libcxxlib.a +/objdir/prefix/lib/libcxxlib.so +/objdir/prefix/lib/libcxxlib.so.1 +/objdir/prefix/lib/libcxxlib.so.1.0.5 +/objdir/prefix/lib/libcxxlib_p.a +======== uninstall ========= +========== clean =========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_cxx_type.err +/objdir/_mkc_cxx_type.res +/objdir/_mkc_funclib_dummy.c +/objdir/_mkc_funclib_dummy.err +/objdir/_mkc_funclib_dummy.res +/objdir/_mkc_prog_cxx.err +/objdir/_mkc_prog_cxx.res +/objdir/expect.out +/objdir/mkprofilelib.test.out.tmp +======= CLEANFILES ========== +/objdir/mkprofilelib.test.out +dummy.o +dummy.op +dummy.os +hello_msg1.o +hello_msg1.op +hello_msg1.os +hello_msg2.o +hello_msg2.op +hello_msg2.os +libcxxlib.a +libcxxlib.so +libcxxlib.so.1 +libcxxlib.so.1.0 +libcxxlib.so.1.0.5 +libcxxlib_p.a +libcxxlib_pic.a +======= UNINSTALLFILES ========== +/prefix/include/hello_msg.h +/prefix/include/impl/hello_msg1.h +/prefix/include/impl/hello_msg2.h +/prefix/lib/libcxxlib.a +/prefix/lib/libcxxlib.so +/prefix/lib/libcxxlib.so.1 +/prefix/lib/libcxxlib.so.1.0.5 +/prefix/lib/libcxxlib_p.a +======= distclean ========== +/objdir/Makefile +/objdir/expect.out +/objdir/mkprofilelib.test.out.tmp diff --git a/tests/mkshlib/Makefile b/tests/mkshlib/Makefile new file mode 100644 index 0000000..76d74e7 --- /dev/null +++ b/tests/mkshlib/Makefile @@ -0,0 +1,6 @@ +.PATH: ../../examples/hello_cxxlib/cxxlib + +MKSHLIB= no + +.include "../../examples/hello_cxxlib/cxxlib/Makefile" +.include "../mkpiclib/test.mk" diff --git a/tests/mkshlib/expect.out b/tests/mkshlib/expect.out new file mode 100644 index 0000000..caad11d --- /dev/null +++ b/tests/mkshlib/expect.out @@ -0,0 +1,63 @@ +=========== all ============ +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_cxx_type.err +/objdir/_mkc_cxx_type.res +/objdir/_mkc_funclib_dummy.c +/objdir/_mkc_funclib_dummy.err +/objdir/_mkc_funclib_dummy.res +/objdir/_mkc_prog_cxx.err +/objdir/_mkc_prog_cxx.res +/objdir/dummy.o +/objdir/expect.out +/objdir/hello_msg1.o +/objdir/hello_msg2.o +/objdir/libcxxlib.a +/objdir/mkshlib.test.out.tmp +========= install ========== +/objdir/prefix +/objdir/prefix/include +/objdir/prefix/include/hello_msg.h +/objdir/prefix/include/impl +/objdir/prefix/include/impl/hello_msg1.h +/objdir/prefix/include/impl/hello_msg2.h +/objdir/prefix/lib +/objdir/prefix/lib/libcxxlib.a +======== uninstall ========= +========== clean =========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_cxx_type.err +/objdir/_mkc_cxx_type.res +/objdir/_mkc_funclib_dummy.c +/objdir/_mkc_funclib_dummy.err +/objdir/_mkc_funclib_dummy.res +/objdir/_mkc_prog_cxx.err +/objdir/_mkc_prog_cxx.res +/objdir/expect.out +/objdir/mkshlib.test.out.tmp +======= CLEANFILES ========== +/objdir/mkshlib.test.out +dummy.o +dummy.op +dummy.os +hello_msg1.o +hello_msg1.op +hello_msg1.os +hello_msg2.o +hello_msg2.op +hello_msg2.os +libcxxlib.a +libcxxlib_p.a +libcxxlib_pic.a +======= UNINSTALLFILES ========== +/prefix/include/hello_msg.h +/prefix/include/impl/hello_msg1.h +/prefix/include/impl/hello_msg2.h +/prefix/lib/libcxxlib.a +======= distclean ========== +/objdir/Makefile +/objdir/expect.out +/objdir/mkshlib.test.out.tmp diff --git a/tests/mkstaticlib/Makefile b/tests/mkstaticlib/Makefile new file mode 100644 index 0000000..c6d17ab --- /dev/null +++ b/tests/mkstaticlib/Makefile @@ -0,0 +1,6 @@ +.PATH: ../../examples/hello_cxxlib/cxxlib + +MKSTATICLIB= no + +.include "../../examples/hello_cxxlib/cxxlib/Makefile" +.include "../mkpiclib/test.mk" diff --git a/tests/mkstaticlib/expect.out b/tests/mkstaticlib/expect.out new file mode 100644 index 0000000..db17b35 --- /dev/null +++ b/tests/mkstaticlib/expect.out @@ -0,0 +1,71 @@ +=========== all ============ +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_cxx_type.err +/objdir/_mkc_cxx_type.res +/objdir/_mkc_funclib_dummy.c +/objdir/_mkc_funclib_dummy.err +/objdir/_mkc_funclib_dummy.res +/objdir/_mkc_prog_cxx.err +/objdir/_mkc_prog_cxx.res +/objdir/dummy.os +/objdir/expect.out +/objdir/hello_msg1.os +/objdir/hello_msg2.os +/objdir/libcxxlib.so.1.0.5 +/objdir/mkstaticlib.test.out.tmp +========= install ========== +/objdir/prefix +/objdir/prefix/include +/objdir/prefix/include/hello_msg.h +/objdir/prefix/include/impl +/objdir/prefix/include/impl/hello_msg1.h +/objdir/prefix/include/impl/hello_msg2.h +/objdir/prefix/lib +/objdir/prefix/lib/libcxxlib.so +/objdir/prefix/lib/libcxxlib.so.1 +/objdir/prefix/lib/libcxxlib.so.1.0.5 +======== uninstall ========= +========== clean =========== +/objdir/Makefile +/objdir/_mkc_compiler_type.err +/objdir/_mkc_compiler_type.res +/objdir/_mkc_cxx_type.err +/objdir/_mkc_cxx_type.res +/objdir/_mkc_funclib_dummy.c +/objdir/_mkc_funclib_dummy.err +/objdir/_mkc_funclib_dummy.res +/objdir/_mkc_prog_cxx.err +/objdir/_mkc_prog_cxx.res +/objdir/expect.out +/objdir/mkstaticlib.test.out.tmp +======= CLEANFILES ========== +/objdir/mkstaticlib.test.out +dummy.o +dummy.op +dummy.os +hello_msg1.o +hello_msg1.op +hello_msg1.os +hello_msg2.o +hello_msg2.op +hello_msg2.os +libcxxlib.a +libcxxlib.so +libcxxlib.so.1 +libcxxlib.so.1.0 +libcxxlib.so.1.0.5 +libcxxlib_p.a +libcxxlib_pic.a +======= UNINSTALLFILES ========== +/prefix/include/hello_msg.h +/prefix/include/impl/hello_msg1.h +/prefix/include/impl/hello_msg2.h +/prefix/lib/libcxxlib.so +/prefix/lib/libcxxlib.so.1 +/prefix/lib/libcxxlib.so.1.0.5 +======= distclean ========== +/objdir/Makefile +/objdir/expect.out +/objdir/mkstaticlib.test.out.tmp diff --git a/tests/pkg_config_0/Makefile b/tests/pkg_config_0/Makefile new file mode 100644 index 0000000..7641be6 --- /dev/null +++ b/tests/pkg_config_0/Makefile @@ -0,0 +1,8 @@ +PROG= mkc_fake2 + +PKG_CONFIG_DEPS= mkc_fake2 + +PROG.pkg-config= # This is a regression test! Suppose pkg-config is not found + +.include "test.mk" +.include <mkc.prog.mk> diff --git a/tests/pkg_config_0/expect.out b/tests/pkg_config_0/expect.out new file mode 100644 index 0000000..179f2d9 --- /dev/null +++ b/tests/pkg_config_0/expect.out @@ -0,0 +1 @@ +ERROR: cannot find program pkg-config diff --git a/tests/pkg_config_0/test.mk b/tests/pkg_config_0/test.mk new file mode 100644 index 0000000..b135009 --- /dev/null +++ b/tests/pkg_config_0/test.mk @@ -0,0 +1,14 @@ +test: + @echo 'Testing ${.CURDIR}... ' 1>&2; \ + set -e; cd ${.CURDIR}; \ + tmp_out=${.OBJDIR}/${.CURDIR:T}.test.out; \ + rm -f $$tmp_out; \ + ${MAKE} ${MAKEFLAGS} all 2>&1 | grep ERROR: > $$tmp_out || true; \ + if diff ${.CURDIR}/expect.out $$tmp_out; \ + then echo ' succeeded' 1>&2; \ + else echo ' FAILED' 1>&2; ex=1; \ + fi; \ + ${MAKE} ${MAKEFLAGS} cleandir 2>&1 | grep ERROR: > $$tmp_out || true; \ + exit $$ex + +CLEANFILES += ${.OBJDIR}/${.CURDIR:T}.test.out diff --git a/tests/pkg_config_1/Makefile b/tests/pkg_config_1/Makefile new file mode 100644 index 0000000..533a5a6 --- /dev/null +++ b/tests/pkg_config_1/Makefile @@ -0,0 +1,6 @@ +LIB= mkc_fake + +PKG_CONFIG_DEPS= mkc_fake-2.0>=2.10 + +.include "test.mk" +.include <mkc.lib.mk> diff --git a/tests/pkg_config_1/test.mk b/tests/pkg_config_1/test.mk new file mode 100644 index 0000000..6fe834c --- /dev/null +++ b/tests/pkg_config_1/test.mk @@ -0,0 +1,14 @@ +test: + @echo 'Testing ${.CURDIR}... ' 1>&2; \ + set -e; cd ${.CURDIR}; \ + tmp_out=${.OBJDIR}/${.CURDIR:T}.test.out; \ + rm -f $$tmp_out; \ + ${MAKE} ${MAKEFLAGS} all 2>&1 | grep ERROR: > $$tmp_out || true; \ + if test -s $$tmp_out; \ + then echo ' succeeded' 1>&2; \ + else echo ' FAILED' 1>&2; ex=1; \ + fi; \ + ${MAKE} ${MAKEFLAGS} cleandir 2>&1 | grep ERROR: > $$tmp_out || true; \ + exit $$ex + +CLEANFILES += ${.OBJDIR}/${.CURDIR:T}.test.out diff --git a/tests/pkg_config_1_1/Makefile b/tests/pkg_config_1_1/Makefile new file mode 100644 index 0000000..203f131 --- /dev/null +++ b/tests/pkg_config_1_1/Makefile @@ -0,0 +1,7 @@ +# The same as pkg_config_1 but with diferent variable +LIB= mkc_fake + +MKC_REQUIRE_PKGCONFIG= mkc_fake-2.0>=2.10 + +.include "test.mk" +.include <mkc.lib.mk> diff --git a/tests/pkg_config_1_1/test.mk b/tests/pkg_config_1_1/test.mk new file mode 100644 index 0000000..6fe834c --- /dev/null +++ b/tests/pkg_config_1_1/test.mk @@ -0,0 +1,14 @@ +test: + @echo 'Testing ${.CURDIR}... ' 1>&2; \ + set -e; cd ${.CURDIR}; \ + tmp_out=${.OBJDIR}/${.CURDIR:T}.test.out; \ + rm -f $$tmp_out; \ + ${MAKE} ${MAKEFLAGS} all 2>&1 | grep ERROR: > $$tmp_out || true; \ + if test -s $$tmp_out; \ + then echo ' succeeded' 1>&2; \ + else echo ' FAILED' 1>&2; ex=1; \ + fi; \ + ${MAKE} ${MAKEFLAGS} cleandir 2>&1 | grep ERROR: > $$tmp_out || true; \ + exit $$ex + +CLEANFILES += ${.OBJDIR}/${.CURDIR:T}.test.out diff --git a/tests/pkg_config_2/Makefile b/tests/pkg_config_2/Makefile new file mode 100644 index 0000000..05e5064 --- /dev/null +++ b/tests/pkg_config_2/Makefile @@ -0,0 +1,6 @@ +PROG= hello + +PKG_CONFIG_DEPS= glib-2.0>=99.0 + +.include "test.mk" +.include <mkc.prog.mk> diff --git a/tests/pkg_config_2/expect.out b/tests/pkg_config_2/expect.out new file mode 100644 index 0000000..c1af47a --- /dev/null +++ b/tests/pkg_config_2/expect.out @@ -0,0 +1 @@ +ERROR: Requested 'glib-2.0 >= 99.0' but version of GLib is 2.NN diff --git a/tests/pkg_config_2/test.mk b/tests/pkg_config_2/test.mk new file mode 100644 index 0000000..68d2326 --- /dev/null +++ b/tests/pkg_config_2/test.mk @@ -0,0 +1,16 @@ +test: + @echo 'Testing ${.CURDIR}... ' 1>&2; \ + set -e; cd ${.CURDIR}; \ + tmp_out=${.OBJDIR}/${.CURDIR:T}.test.out; \ + rm -f $$tmp_out; \ + ${MAKE} ${MAKEFLAGS} all 2>&1 | \ + grep ERROR: | \ + sed 's/ 2\([.][0-9]*\)*/ 2.NN/' > $$tmp_out || true; \ + if diff ${.CURDIR}/expect.out $$tmp_out; \ + then echo ' succeeded' 1>&2; \ + else echo ' FAILED' 1>&2; ex=1; \ + fi; \ + ${MAKE} ${MAKEFLAGS} cleandir 2>&1 | grep ERROR: > $$tmp_out || true; \ + exit $$ex + +CLEANFILES += ${.OBJDIR}/${.CURDIR:T}.test.out diff --git a/tests/predopost_targets/Makefile b/tests/predopost_targets/Makefile new file mode 100644 index 0000000..01e4388 --- /dev/null +++ b/tests/predopost_targets/Makefile @@ -0,0 +1,9 @@ +SUBDIR = lib others lua +TEST_PREREQS = + +.ifdef INCFILE +.include "${INCFILE}" +.endif + +.include "test.mk" +.include <mkc.mk> diff --git a/tests/predopost_targets/Makefile.inc b/tests/predopost_targets/Makefile.inc new file mode 100644 index 0000000..3f66516 --- /dev/null +++ b/tests/predopost_targets/Makefile.inc @@ -0,0 +1,7 @@ +.ifndef REAL_TARGETS +.for i in errorcheck clean cleandir install all uninstall installdirs depend \ + bin_tar bin_targz bin_tarbz2 bin_zip bin_deb +pre_${i} do_${i} post_${i}: + @echo "fake target ${.TARGET}" +.endfor +.endif diff --git a/tests/predopost_targets/expect.out b/tests/predopost_targets/expect.out new file mode 100644 index 0000000..4315220 --- /dev/null +++ b/tests/predopost_targets/expect.out @@ -0,0 +1,172 @@ +=========== {pre,do,post}_recursive ============ +================================================== +errorcheck ===> tests/predopost_targets/lib +fake target pre_errorcheck +fake target do_errorcheck +fake target post_errorcheck +================================================== +errorcheck ===> tests/predopost_targets/others +fake target pre_errorcheck +fake target do_errorcheck +fake target post_errorcheck +================================================== +errorcheck ===> tests/predopost_targets/lua +fake target pre_errorcheck +fake target do_errorcheck +fake target post_errorcheck +================================================== +clean ===> tests/predopost_targets/lib +fake target pre_clean +fake target do_clean +fake target post_clean +================================================== +clean ===> tests/predopost_targets/others +fake target pre_clean +fake target do_clean +fake target post_clean +================================================== +clean ===> tests/predopost_targets/lua +fake target pre_clean +fake target do_clean +fake target post_clean +rm -rf /objdir/prefix /objdir/prefix +================================================== +cleandir ===> tests/predopost_targets/lib +fake target pre_cleandir +fake target do_cleandir +fake target post_cleandir +================================================== +cleandir ===> tests/predopost_targets/others +fake target pre_cleandir +fake target do_cleandir +fake target post_cleandir +================================================== +cleandir ===> tests/predopost_targets/lua +fake target pre_cleandir +fake target do_cleandir +fake target post_cleandir +rm -rf /objdir/prefix /objdir/prefix +================================================== +install ===> tests/predopost_targets/lib +fake target pre_installdirs +fake target do_installdirs +fake target post_installdirs +fake target pre_install +fake target do_install +fake target post_install +================================================== +install ===> tests/predopost_targets/others +fake target pre_installdirs +fake target do_installdirs +fake target post_installdirs +fake target pre_install +fake target do_install +fake target post_install +================================================== +install ===> tests/predopost_targets/lua +fake target pre_installdirs +fake target do_installdirs +fake target post_installdirs +fake target pre_install +fake target do_install +fake target post_install +================================================== +all ===> tests/predopost_targets/lib +fake target pre_errorcheck +fake target do_errorcheck +fake target post_errorcheck +fake target pre_all +fake target do_all +fake target post_all +================================================== +all ===> tests/predopost_targets/others +fake target pre_errorcheck +fake target do_errorcheck +fake target post_errorcheck +fake target pre_all +fake target do_all +fake target post_all +================================================== +all ===> tests/predopost_targets/lua +fake target pre_errorcheck +fake target do_errorcheck +fake target post_errorcheck +fake target pre_all +fake target do_all +fake target post_all +================================================== +uninstall ===> tests/predopost_targets/lib +fake target pre_uninstall +fake target do_uninstall +fake target post_uninstall +================================================== +uninstall ===> tests/predopost_targets/others +fake target pre_uninstall +fake target do_uninstall +fake target post_uninstall +================================================== +uninstall ===> tests/predopost_targets/lua +fake target pre_uninstall +fake target do_uninstall +fake target post_uninstall +================================================== +installdirs ===> tests/predopost_targets/lib +fake target pre_installdirs +fake target do_installdirs +fake target post_installdirs +================================================== +installdirs ===> tests/predopost_targets/others +fake target pre_installdirs +fake target do_installdirs +fake target post_installdirs +================================================== +installdirs ===> tests/predopost_targets/lua +fake target pre_installdirs +fake target do_installdirs +fake target post_installdirs +================================================== +depend ===> tests/predopost_targets/lib +fake target pre_depend +fake target do_depend +fake target post_depend +================================================== +depend ===> tests/predopost_targets/others +fake target pre_depend +fake target do_depend +fake target post_depend +================================================== +depend ===> tests/predopost_targets/lua +fake target pre_depend +fake target do_depend +fake target post_depend +================================================== +install ===> tests/predopost_targets/lib +fake target pre_install +fake target do_install +fake target post_install +================================================== +install ===> tests/predopost_targets/others +fake target pre_install +fake target do_install +fake target post_install +================================================== +install ===> tests/predopost_targets/lua +fake target pre_install +fake target do_install +fake target post_install +=========== {pre,do,post}_nonrec ============ +fake target pre_bin_tar +fake target do_bin_tar +fake target post_bin_tar +fake target pre_bin_targz +fake target do_bin_targz +fake target post_bin_targz +fake target pre_bin_tarbz2 +fake target do_bin_tarbz2 +fake target post_bin_tarbz2 +fake target pre_bin_zip +fake target do_bin_zip +fake target post_bin_zip +fake target pre_bin_deb +fake target do_bin_deb +fake target post_bin_deb diff --git a/tests/predopost_targets/lib/Makefile b/tests/predopost_targets/lib/Makefile new file mode 100644 index 0000000..6793f09 --- /dev/null +++ b/tests/predopost_targets/lib/Makefile @@ -0,0 +1,3 @@ +LIB = foo + +.include <mkc.mk> diff --git a/tests/predopost_targets/lua/Makefile b/tests/predopost_targets/lua/Makefile new file mode 100644 index 0000000..4b52cb7 --- /dev/null +++ b/tests/predopost_targets/lua/Makefile @@ -0,0 +1,4 @@ +LUA_LMODULES = cat.module1 +LUA_CMODULES = cat.module2 + +.include <mkc.mk> diff --git a/tests/predopost_targets/others/Makefile b/tests/predopost_targets/others/Makefile new file mode 100644 index 0000000..d0812e1 --- /dev/null +++ b/tests/predopost_targets/others/Makefile @@ -0,0 +1,15 @@ +PROG = program +INSCRIPTS = lalala foo +INFILES = bar +TEXINFO = program.texinfo +SCRIPTS = baz shell_script +FILES = file1 file2 +MAN = program.1 +MKCATPAGES= yes +MLINKS = bar1 bar2 +SYMLINKS = foo1 foo2 +LINKS = baz1 baz2 +INCS = qqq.h +DPSRCS = zzz.c + +.include <mkc.mk> diff --git a/tests/predopost_targets/test.mk b/tests/predopost_targets/test.mk new file mode 100644 index 0000000..6ec1c09 --- /dev/null +++ b/tests/predopost_targets/test.mk @@ -0,0 +1,23 @@ +.PHONY : test_output +test_output : + @set -e; \ + \ + { \ + echo '=========== {pre,do,post}_recursive ============'; \ + for t in errorcheck clean cleandir install all uninstall installdirs depend; do \ + ${MAKE} ${MAKEFLAGS} -j1 $$t | \ + grep -v checking; \ + done ; \ + env MKINSTALLDIRS=no ${MAKE} ${MAKEFLAGS} -j1 install; \ + } | env NOSORT=1 mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + echo '=========== {pre,do,post}_nonrec ============'; \ + for t in bin_tar bin_targz bin_tarbz2 bin_zip bin_deb; do \ + env INCFILE=Makefile.inc ${MAKE} ${MAKEFLAGS} -j1 $$t | \ + grep -v checking; \ + done ; \ + \ + true =========== cleandir ============; \ + env REAL_TARGETS=1 ${MAKE} ${MAKEFLAGS} distclean > /dev/null + +.include <mkc.minitest.mk> diff --git a/tests/rec_makefiles/Makefile b/tests/rec_makefiles/Makefile new file mode 100644 index 0000000..9eadedb --- /dev/null +++ b/tests/rec_makefiles/Makefile @@ -0,0 +1,4 @@ +SUBDIR= subdir1 subdir2 + +.include "test.mk" +.include <mkc.subdir.mk> diff --git a/tests/rec_makefiles/Makefile.common b/tests/rec_makefiles/Makefile.common new file mode 100644 index 0000000..b919dc5 --- /dev/null +++ b/tests/rec_makefiles/Makefile.common @@ -0,0 +1,11 @@ +.PHONY: print-values +print-values: + @echo =========== ${.CURDIR:T} ============= +.for i in A B C D + @echo ${i}=${${i}} +.endfor + +A=1 +B=2 +C=3 +D=4 diff --git a/tests/rec_makefiles/expect.out b/tests/rec_makefiles/expect.out new file mode 100644 index 0000000..d2f1d8e --- /dev/null +++ b/tests/rec_makefiles/expect.out @@ -0,0 +1,15 @@ +=========== subsubdir1 ============= +A=1 +B=2 +C=3 +D=4 +=========== subsubdir2 ============= +A=1 +B=2 +C=3 +D=4 +=========== prj2 ============= +A=1 +B=2 +C=3 +D=4 diff --git a/tests/rec_makefiles/subdir1/Makefile b/tests/rec_makefiles/subdir1/Makefile new file mode 100644 index 0000000..2b18863 --- /dev/null +++ b/tests/rec_makefiles/subdir1/Makefile @@ -0,0 +1,3 @@ +SUBPRJ=subsubdir1:subsubdir2 + +.include <mkc.subprj.mk> diff --git a/tests/rec_makefiles/subdir1/subsubdir1/Makefile b/tests/rec_makefiles/subdir1/subsubdir1/Makefile new file mode 100644 index 0000000..fe69a55 --- /dev/null +++ b/tests/rec_makefiles/subdir1/subsubdir1/Makefile @@ -0,0 +1,4 @@ +.PHONY: all +all: print-values + +.include <mkc.files.mk> diff --git a/tests/rec_makefiles/subdir1/subsubdir2/Makefile b/tests/rec_makefiles/subdir1/subsubdir2/Makefile new file mode 100644 index 0000000..fe69a55 --- /dev/null +++ b/tests/rec_makefiles/subdir1/subsubdir2/Makefile @@ -0,0 +1,4 @@ +.PHONY: all +all: print-values + +.include <mkc.files.mk> diff --git a/tests/rec_makefiles/subdir2/Makefile b/tests/rec_makefiles/subdir2/Makefile new file mode 100644 index 0000000..9661778 --- /dev/null +++ b/tests/rec_makefiles/subdir2/Makefile @@ -0,0 +1,3 @@ +SUBDIR= prj2 + +.include <mkc.subdir.mk> diff --git a/tests/rec_makefiles/subdir2/prj2/Makefile b/tests/rec_makefiles/subdir2/prj2/Makefile new file mode 100644 index 0000000..fe69a55 --- /dev/null +++ b/tests/rec_makefiles/subdir2/prj2/Makefile @@ -0,0 +1,4 @@ +.PHONY: all +all: print-values + +.include <mkc.files.mk> diff --git a/tests/rec_makefiles/test.mk b/tests/rec_makefiles/test.mk new file mode 100644 index 0000000..a9ff6c8 --- /dev/null +++ b/tests/rec_makefiles/test.mk @@ -0,0 +1,11 @@ +.PHONY : test +test: + set -e; \ + env SRCTOP=${.CURDIR} VERBOSE_ECHO=: \ + ${MAKE} ${MAKEFLAGS} all > ${.OBJDIR}/_output.tmp; \ + if cmp ${.CURDIR}/expect.out ${.OBJDIR}/_output.tmp; \ + then echo ' succeeded' 1>&2; \ + else echo ' FAILED' 1>&2; false; \ + fi + +CLEANFILES+= ${.OBJDIR}/_output.tmp diff --git a/tests/reqd/Makefile b/tests/reqd/Makefile new file mode 100644 index 0000000..4131fcb --- /dev/null +++ b/tests/reqd/Makefile @@ -0,0 +1,8 @@ +MKC_REQD = 999.0.0 + +SCRIPTS = hello + +CLEANFILES += ${.OBJDIR}/${.CURDIR:T}.test.out + +.include "test.mk" +.include <mkc.prog.mk> diff --git a/tests/reqd/expect.out b/tests/reqd/expect.out new file mode 100644 index 0000000..2cf1c41 --- /dev/null +++ b/tests/reqd/expect.out @@ -0,0 +1 @@ +ERROR: We need mk-configure v.999.0.0 while 0.28.0 is detected diff --git a/tests/reqd/test.mk b/tests/reqd/test.mk new file mode 100644 index 0000000..47e1d9b --- /dev/null +++ b/tests/reqd/test.mk @@ -0,0 +1,9 @@ +test: + @echo 'Testing ${.CURDIR}... ' 1>&2; \ + set -e; cd ${.CURDIR}; \ + tmp_out=${.OBJDIR}/${.CURDIR:T}.test.out; \ + rm -f $$tmp_out; \ + ${MAKE} ${MAKEFLAGS} all 2>&1 | head -1 > $$tmp_out; \ + diff ${.CURDIR}/expect.out $$tmp_out && \ + echo ' succeeded' 1>&2 || \ + { echo ' FAILED' 1>&2; false; } diff --git a/tests/reqd2/Makefile b/tests/reqd2/Makefile new file mode 100644 index 0000000..92fe873 --- /dev/null +++ b/tests/reqd2/Makefile @@ -0,0 +1,8 @@ +MKC_REQD = 999.0.0 + +SUBPRJ= dir1 dir2 + +CLEANFILES += ${.OBJDIR}/${.CURDIR:T}.test.out + +.include "test.mk" +.include <mkc.subprj.mk> diff --git a/tests/reqd2/expect.out b/tests/reqd2/expect.out new file mode 100644 index 0000000..2cf1c41 --- /dev/null +++ b/tests/reqd2/expect.out @@ -0,0 +1 @@ +ERROR: We need mk-configure v.999.0.0 while 0.28.0 is detected diff --git a/tests/reqd2/test.mk b/tests/reqd2/test.mk new file mode 100644 index 0000000..47e1d9b --- /dev/null +++ b/tests/reqd2/test.mk @@ -0,0 +1,9 @@ +test: + @echo 'Testing ${.CURDIR}... ' 1>&2; \ + set -e; cd ${.CURDIR}; \ + tmp_out=${.OBJDIR}/${.CURDIR:T}.test.out; \ + rm -f $$tmp_out; \ + ${MAKE} ${MAKEFLAGS} all 2>&1 | head -1 > $$tmp_out; \ + diff ${.CURDIR}/expect.out $$tmp_out && \ + echo ' succeeded' 1>&2 || \ + { echo ' FAILED' 1>&2; false; } diff --git a/tests/reqd3/Makefile b/tests/reqd3/Makefile new file mode 100644 index 0000000..0274c38 --- /dev/null +++ b/tests/reqd3/Makefile @@ -0,0 +1,8 @@ +MKC_REQD = 999.0.0 + +SUBDIR= dir1 dir2 + +CLEANFILES += ${.OBJDIR}/${.CURDIR:T}.test.out + +.include "test.mk" +.include <mkc.subdir.mk> diff --git a/tests/reqd3/expect.out b/tests/reqd3/expect.out new file mode 100644 index 0000000..2cf1c41 --- /dev/null +++ b/tests/reqd3/expect.out @@ -0,0 +1 @@ +ERROR: We need mk-configure v.999.0.0 while 0.28.0 is detected diff --git a/tests/reqd3/test.mk b/tests/reqd3/test.mk new file mode 100644 index 0000000..47e1d9b --- /dev/null +++ b/tests/reqd3/test.mk @@ -0,0 +1,9 @@ +test: + @echo 'Testing ${.CURDIR}... ' 1>&2; \ + set -e; cd ${.CURDIR}; \ + tmp_out=${.OBJDIR}/${.CURDIR:T}.test.out; \ + rm -f $$tmp_out; \ + ${MAKE} ${MAKEFLAGS} all 2>&1 | head -1 > $$tmp_out; \ + diff ${.CURDIR}/expect.out $$tmp_out && \ + echo ' succeeded' 1>&2 || \ + { echo ' FAILED' 1>&2; false; } diff --git a/tests/reqd4/Makefile b/tests/reqd4/Makefile new file mode 100644 index 0000000..fc3d62b --- /dev/null +++ b/tests/reqd4/Makefile @@ -0,0 +1,9 @@ +MKC_REQD = 999.0.0 + +MKC_CHECK_HEADERS = stdio.h + +INSCRIPTS = hello +SCRIPTS = ${INSCRIPTS} + +.include "test.mk" +.include <mkc.prog.mk> diff --git a/tests/reqd4/expect.out b/tests/reqd4/expect.out new file mode 100644 index 0000000..0cb180a --- /dev/null +++ b/tests/reqd4/expect.out @@ -0,0 +1,8 @@ +ERROR: We need mk-configure v.999.0.0 while 0.28.0 is detected +"bmake-20110606 or newer is required" +=========== all ============ +/objdir/Makefile +/objdir/expect.out +/objdir/hello.in +/objdir/reqd4.test.out +/objdir/test.mk diff --git a/tests/reqd4/hello.in b/tests/reqd4/hello.in new file mode 100755 index 0000000..97cca98 --- /dev/null +++ b/tests/reqd4/hello.in @@ -0,0 +1,3 @@ +#!/bin/sh + +echo 'Hello World!' diff --git a/tests/reqd4/test.mk b/tests/reqd4/test.mk new file mode 100644 index 0000000..bfcfb07 --- /dev/null +++ b/tests/reqd4/test.mk @@ -0,0 +1,18 @@ +CLEANFILES += ${.OBJDIR}/${.CURDIR:T}.test.out + +test: + @echo 'Testing ${.CURDIR}... ' 1>&2; \ + set -e; cd ${.CURDIR}; \ + tmp_out=${.OBJDIR}/${.CURDIR:T}.test.out; \ + { \ + ${MAKE} ${MAKEFLAGS} -j3 all 2>&1 | sed -n 2p; \ + ${MAKE} ${MAKEFLAGS} -j3 all MAKE_VERSION=00000000 2>&1 | sed 's/^.*"bmake/"bmake/'; \ + echo =========== all ============; \ + find ${.OBJDIR} -type f -o -type l | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + } > $$tmp_out; \ + diff ${.CURDIR}/expect.out $$tmp_out && \ + echo ' succeeded' 1>&2 || \ + { echo ' FAILED' 1>&2; ex=1; }; \ + ${MAKE} ${MAKEFLAGS} cleandir; \ + exit $$ex diff --git a/tests/reqd_clean_cache/Makefile b/tests/reqd_clean_cache/Makefile new file mode 100644 index 0000000..bbbabe2 --- /dev/null +++ b/tests/reqd_clean_cache/Makefile @@ -0,0 +1,18 @@ +MKC_REQUIRE_HEADERS = trtrtr.h sys/brbrbr.h +MKC_REQUIRE_PROGS = trtrtr brbrbr +MKC_REQUIRE_FUNCLIBS = trtrtr brbrbr:dl +MKC_REQUIRE_DEFINES = TRTRTR BRBRBR:sys/time.h +MKC_REQUIRE_TYPES = trtrtr_t brbrbr_t:sys/time.h +MKC_REQUIRE_VARS = v_trtrtr v_brbrbr:sys/time.h +MKC_REQUIRE_MEMBERS = trtr.trtr_t:string.h brbr.brbr_t:sys/time.h +MKC_REQUIRE_FUNCS2 = trtrtr:sys/time.h +MKC_REQUIRE_FUNCS3 = brbrbr +MKC_REQUIRE_CUSTOM = test1 +MKC_CUSTOM_FN.test1 = test1.c + +MKC_REQUIRE_PROTOTYPES = bad999 +MKC_PROTOTYPE_HEADERS.bad999 = bad_include.h +MKC_PROTOTYPE_FUNC.bad999 = void badfunc999(void) + +.include "test.mk" +.include <mkc.mk> diff --git a/tests/reqd_clean_cache/expect.out b/tests/reqd_clean_cache/expect.out new file mode 100644 index 0000000..bd1e169 --- /dev/null +++ b/tests/reqd_clean_cache/expect.out @@ -0,0 +1,28 @@ +=========== all ============ +ERROR: cannot find header trtrtr.h +ERROR: cannot find header sys/brbrbr.h +ERROR: cannot find function trtrtr +ERROR: cannot find function brbrbr:dl +ERROR: cannot find declaration of define TRTRTR +ERROR: cannot find declaration of define BRBRBR:sys/time.h +ERROR: cannot find declaration of type trtrtr_t +ERROR: cannot find declaration of type brbrbr_t:sys/time.h +ERROR: cannot find declaration of variable v_trtrtr +ERROR: cannot find declaration of variable v_brbrbr:sys/time.h +ERROR: cannot find member trtr.trtr_t:string.h +ERROR: cannot find member brbr.brbr_t:sys/time.h +ERROR: cannot find declaration of function trtrtr:sys/time.h +ERROR: cannot find declaration of function brbrbr +ERROR: custom test test1 failed +ERROR: cannot find program trtrtr +ERROR: cannot find program brbrbr +ERROR: prototype test bad999 failed +*** Error code 1 + +Stop. +bmake: stopped in /objdir +/objdir/Makefile +/objdir/expect.out +/objdir/reqd_clean_cache.test.out.tmp +/objdir/test.mk +/objdir/test1.c diff --git a/tests/reqd_clean_cache/test.mk b/tests/reqd_clean_cache/test.mk new file mode 100644 index 0000000..55e71b8 --- /dev/null +++ b/tests/reqd_clean_cache/test.mk @@ -0,0 +1,15 @@ +TEST_PREREQS = # empty + +.PHONY : test_output +test_output : + @set -e; LC_ALL=C; export LC_ALL; \ + \ + echo =========== all ============; \ + { ${MAKE} ${MAKEFLAGS} all 2>/dev/null || true; \ + find ${.OBJDIR} -type f -o -type l | sort; } | \ + sed 's,n*bmake\[[0-9]*\],bmake,' | \ + env NOSORT=1 mkc_test_helper "${PREFIX}" "${.OBJDIR}"; \ + \ + ${MAKE} ${MAKEFLAGS} cleandir > /dev/null + +.include <mkc.minitest.mk> diff --git a/tests/reqd_clean_cache/test1.c b/tests/reqd_clean_cache/test1.c new file mode 100644 index 0000000..cdbfe11 --- /dev/null +++ b/tests/reqd_clean_cache/test1.c @@ -0,0 +1 @@ +badtype_t var = 0; diff --git a/tests/require_prototype/Makefile b/tests/require_prototype/Makefile new file mode 100644 index 0000000..bdcf340 --- /dev/null +++ b/tests/require_prototype/Makefile @@ -0,0 +1,14 @@ +CLEANFILES += ${.OBJDIR}/${.CURDIR:T}.test.out + +test: + @echo 'Testing ${.CURDIR}... ' 1>&2; \ + set -e; \ + tmp_out=${.OBJDIR}/${.CURDIR:T}.test.out; \ + rm -f $$tmp_out; \ + ${MAKE} ${MAKEFLAGS} -f ${.CURDIR}/test.mk cleandir >/dev/null 2>&1; \ + ${MAKE} ${MAKEFLAGS} -f ${.CURDIR}/test.mk all > $$tmp_out 2>&1; \ + diff ${.CURDIR}/expect.out $$tmp_out && \ + echo ' succeeded' 1>&2 || \ + { echo ' FAILED' 1>&2; false; } + +.include <mkc.subprj.mk> diff --git a/tests/require_prototype/expect.out b/tests/require_prototype/expect.out new file mode 100644 index 0000000..40bb8b4 --- /dev/null +++ b/tests/require_prototype/expect.out @@ -0,0 +1 @@ +checking for prototype pid_t fork(void) ( unistd.h unistd.h )... yes diff --git a/tests/require_prototype/test.mk b/tests/require_prototype/test.mk new file mode 100644 index 0000000..d8fa02e --- /dev/null +++ b/tests/require_prototype/test.mk @@ -0,0 +1,5 @@ +MKC_REQUIRE_PROTOTYPES = fork +MKC_PROTOTYPE_HEADERS.fork = unistd.h unistd.h # intentionally double! +MKC_PROTOTYPE_FUNC.fork = pid_t fork (void) + +.include <mkc.prog.mk> diff --git a/tests/sys_queue/Makefile b/tests/sys_queue/Makefile new file mode 100644 index 0000000..96a92bf --- /dev/null +++ b/tests/sys_queue/Makefile @@ -0,0 +1,12 @@ +PROG = hello +SRCS = hello.c + +WARNS = 4 + +MKC_FEATURES = CIRCLEQ LIST SIMPLEQ SLIST STAILQ TAILQ + +MKC_REQD = 0.26.0 + +test: all +.include "test.mk" +.include <mkc.prog.mk> diff --git a/tests/sys_queue/hello.c b/tests/sys_queue/hello.c new file mode 100644 index 0000000..dbdae31 --- /dev/null +++ b/tests/sys_queue/hello.c @@ -0,0 +1,17 @@ +#include <mkc_CIRCLEQ.h> +#include <mkc_LIST.h> +#include <mkc_SIMPLEQ.h> +#include <mkc_SLIST.h> +#include <mkc_STAILQ.h> +#include <mkc_TAILQ.h> + +#if !defined(CIRCLEQ_ENTRY) || !defined(LIST_ENTRY) || \ + !defined(SIMPLEQ_ENTRY) || !defined(SLIST_ENTRY) || \ + !defined(STAILQ_ENTRY) || !defined(TAILQ_ENTRY) +#error "mk-configure bug!!!" +#endif + +int main (int argc, char ** argv) +{ + return 0; +} diff --git a/tests/sys_queue/test.mk b/tests/sys_queue/test.mk new file mode 100644 index 0000000..d6a56ab --- /dev/null +++ b/tests/sys_queue/test.mk @@ -0,0 +1,3 @@ +test: + @set -e; \ + ${MAKE} ${MAKEFLAGS} cleandir > /dev/null diff --git a/tests/test_mkc_vs_LIB/Makefile b/tests/test_mkc_vs_LIB/Makefile new file mode 100644 index 0000000..764c949 --- /dev/null +++ b/tests/test_mkc_vs_LIB/Makefile @@ -0,0 +1 @@ +.include "../test_mkc_vs_PROG/Makefile" diff --git a/tests/test_mkc_vs_LIB/expect.out b/tests/test_mkc_vs_LIB/expect.out new file mode 100644 index 0000000..5d75455 --- /dev/null +++ b/tests/test_mkc_vs_LIB/expect.out @@ -0,0 +1 @@ +LIB is not allowed for mkc.files.mk diff --git a/tests/test_mkc_vs_LIB/test.mk b/tests/test_mkc_vs_LIB/test.mk new file mode 100644 index 0000000..23930e1 --- /dev/null +++ b/tests/test_mkc_vs_LIB/test.mk @@ -0,0 +1,3 @@ +LIB = my + +.include <mkc.files.mk> diff --git a/tests/test_mkc_vs_PROG/Makefile b/tests/test_mkc_vs_PROG/Makefile new file mode 100644 index 0000000..706f1d2 --- /dev/null +++ b/tests/test_mkc_vs_PROG/Makefile @@ -0,0 +1 @@ +.include "../test_subprj_dash/Makefile" diff --git a/tests/test_mkc_vs_PROG/expect.out b/tests/test_mkc_vs_PROG/expect.out new file mode 100644 index 0000000..fe8b169 --- /dev/null +++ b/tests/test_mkc_vs_PROG/expect.out @@ -0,0 +1 @@ +PROG is not allowed for mkc.lib.mk diff --git a/tests/test_mkc_vs_PROG/test.mk b/tests/test_mkc_vs_PROG/test.mk new file mode 100644 index 0000000..c46502f --- /dev/null +++ b/tests/test_mkc_vs_PROG/test.mk @@ -0,0 +1,3 @@ +PROG = prog + +.include <mkc.lib.mk> diff --git a/tests/test_mkc_vs_SUBDIR/Makefile b/tests/test_mkc_vs_SUBDIR/Makefile new file mode 100644 index 0000000..764c949 --- /dev/null +++ b/tests/test_mkc_vs_SUBDIR/Makefile @@ -0,0 +1 @@ +.include "../test_mkc_vs_PROG/Makefile" diff --git a/tests/test_mkc_vs_SUBDIR/expect.out b/tests/test_mkc_vs_SUBDIR/expect.out new file mode 100644 index 0000000..c62036f --- /dev/null +++ b/tests/test_mkc_vs_SUBDIR/expect.out @@ -0,0 +1 @@ +SUBDIR is not allowed for mkc.subprj.mk diff --git a/tests/test_mkc_vs_SUBDIR/test.mk b/tests/test_mkc_vs_SUBDIR/test.mk new file mode 100644 index 0000000..518407c --- /dev/null +++ b/tests/test_mkc_vs_SUBDIR/test.mk @@ -0,0 +1,3 @@ +SUBDIR = dir1 dir2 + +.include <mkc.subprj.mk> diff --git a/tests/test_mkc_vs_SUBPRJ/Makefile b/tests/test_mkc_vs_SUBPRJ/Makefile new file mode 100644 index 0000000..764c949 --- /dev/null +++ b/tests/test_mkc_vs_SUBPRJ/Makefile @@ -0,0 +1 @@ +.include "../test_mkc_vs_PROG/Makefile" diff --git a/tests/test_mkc_vs_SUBPRJ/expect.out b/tests/test_mkc_vs_SUBPRJ/expect.out new file mode 100644 index 0000000..0b488de --- /dev/null +++ b/tests/test_mkc_vs_SUBPRJ/expect.out @@ -0,0 +1 @@ +SUBPRJ is not allowed for mkc.prog.mk diff --git a/tests/test_mkc_vs_SUBPRJ/test.mk b/tests/test_mkc_vs_SUBPRJ/test.mk new file mode 100644 index 0000000..227e635 --- /dev/null +++ b/tests/test_mkc_vs_SUBPRJ/test.mk @@ -0,0 +1,3 @@ +SUBPRJ = dir1 dir2 + +.include <mkc.prog.mk> diff --git a/tests/test_subprj_dash/Makefile b/tests/test_subprj_dash/Makefile new file mode 100644 index 0000000..a0f8d9b --- /dev/null +++ b/tests/test_subprj_dash/Makefile @@ -0,0 +1,15 @@ +CLEANFILES += ${.OBJDIR}/${.CURDIR:T}.test.out + +test: + @echo 'Testing ${.CURDIR}... ' 1>&2; \ + set -e; \ + tmp_out=${.OBJDIR}/${.CURDIR:T}.test.out; \ + rm -f $$tmp_out; \ + ${MAKE} ${MAKEFLAGS} -f ${.CURDIR}/test.mk all 2>&1 | \ + sed 's,n*bmake\[[0-9]*\],bmake,' | \ + mkc_test_helper "${PREFIX}" "${.OBJDIR}" > $$tmp_out; \ + diff ${.CURDIR}/expect.out $$tmp_out && \ + echo ' succeeded' 1>&2 || \ + { echo ' FAILED' 1>&2; false; } + +.include <mkc.subprj.mk> diff --git a/tests/test_subprj_dash/expect.out b/tests/test_subprj_dash/expect.out new file mode 100644 index 0000000..e23e0e3 --- /dev/null +++ b/tests/test_subprj_dash/expect.out @@ -0,0 +1 @@ +Dash symbol is not allowed inside subdir (another-one prog100-500) diff --git a/tests/test_subprj_dash/test.mk b/tests/test_subprj_dash/test.mk new file mode 100644 index 0000000..7ba6a8f --- /dev/null +++ b/tests/test_subprj_dash/test.mk @@ -0,0 +1,3 @@ +SUBPRJ = prog prog100-500 liba another-one + +.include <mkc.subprj.mk> |