MKMK(1) MKMK(1) NAME mkmk - create a mkfile for foreign software SYNOPSIS mkmk [ -aSA ] [ -S file ] [ -I incdir ] [ -L libdir ] [ -D name [ =value ]] [ -U name ] [ -w column ] [ -C cflags ] [ -x exclude ] [ file... ] DESCRIPTION mkmk attempts to generate a correct mkfile for mk(1) based on the files given, or if none, those found in the current directory, it writes the generated mkfile to its standard output. Though mkmk(1) makes strenuous attempts to identify the dependency tree and required macro definitions it will make mistakes. It is expected that mkmk(1) will usually be invoked from an rc(1) script, 9port, which will use the var- ious command options to modify the generated mkfile. In extreme cases it may even have to use other tools such as sed(1) and awk(1) to massage the generated script. One of these scripts would be needed for each package ported using mkmk(1). Using a script is preferable to hand editing the generated mkfile as it allows updates of the package to be installed by simply re-running the 9port script. There are a number of options: -o target -m -l target -s target mkmk(1) is able to generate the four standard mkfile types: -o a single executable file target, -m multiple targets, one per source file, -l a user library, and -s a system library. In each case where a single target is required it's name must follow the option letter. If none of these options is specified it is assumed the the mkfile is a top level driver and exists only to recursively call mk(1) in subdirectories. -A Autoconf mode, most defines are written to the file config.h in the current directory (provided it doesn't exist), and heuristics are used parse Autoconf feature tests and provide correct answers to them. MKMK(1) MKMK(1) -a APE mode, target libraries will be placed in /$objtype/lib/ape, binaries in /$objtype/bin/ape, manu- als in /sys/lib/Xape (where X is the manual section number). This infers that the target application or library will only be used from within the APE environ- ment. -S mkmk(1) normally reads each header file only once, how- ever strange preprocessor code can mean a single header file will compile differently depending on which source file inludes it. The -S option, (slow but accurate), disables this optimisation at the expense of much longer runtimes. -I incdir Aditional include directories to be searched by the compiler may be given, these are also added to the CFLAGS= macro in the generated mkfile. This option make be repeated as required. -w width text in the generated mkfile is word wrapped, at column 78 by default giving wide but short output. this col- umn number may be controlled by this option; a value of zero will give one object per line style - narrow but tall files, preferred by some users. -D name[=value] C preprocessor macros may be defined using the same syntax as the C preprocessor. This option may be repeated as often as required. -U name C preprocessor macros may be undefined using the same syntax as the C preprocessor. This option may be repeated as often as required. -B This is shorthand for -c -B which turns off the warn- ings about function calls in the absence of prototypes. Sadly it owes its existence to the frequency that it is needed. -c flags Arbitary C compiler flags can be added to the CFLAGS variable in the generated mkfile using this option, it make be repeated as required. -a APE mode, controls the installation directories for target files. Libraries are installed to MKMK(1) MKMK(1) /$objtype/lib/ape rather than /$objtype/lib, executa- bles to /$objtype/bin/ape rather than /$objtype/bin and manuals to /sys/man/apeX rather than /sys/man/X. -x file Exclude file from processing. Mkmk(1) parses all the files in the current directory, except those specified with the -x option. This option can appear as often as necessary. -h flags Aditional libker flags make be specified, these are appended to the LDFLAGS variable in the generate mkfile. This option can appear as often as necessary. -H libs User libraries required may be specified, these are appended to the LIBS variable in the generate mkfile. System libraries need not be listed as pcc(1) knows how to find them. -C file Files to be deleted by the clean mk(1) target may be specified, these are appended to the CLEANFILES vari- able in the generate mkfile. This option can appear as often as necessary. AUTOCONF In autoconf mode mkmk(1) attempts to autodetect features requested in the source code by examining the symbols in the plan9 libraries, and by infering which plan9 sourcecode con- trol defines are required. A small number of specific pre- processor macros are also defined automaticially when they are tested; these relate to features that Plan9 has but which automated testing is too painful. BUGS mkmk(1) needs to have a much better understanding of the APE subsystem. It should be able to extract the prototypes defined in the APE headers and what preprocessor macros they are controlled by. Currently this information is compiled into the source. SOURCE /sys/src/cmd/mkmk /sys/src/cmd/mkmk/9port - example 9port scripts SEE ALSO mk(1)