diff options
Diffstat (limited to 'share/mk')
38 files changed, 5122 insertions, 0 deletions
diff --git a/share/mk/Makefile b/share/mk/Makefile new file mode 100644 index 0000000..2110b26 --- /dev/null +++ b/share/mk/Makefile @@ -0,0 +1,50 @@ +# $FreeBSD$ +# @(#)Makefile 8.1 (Berkeley) 6/8/93 + +.include <bsd.own.mk> + +FILES= \ + bsd.README \ + bsd.arch.inc.mk \ + bsd.compiler.mk \ + bsd.cpu.mk \ + bsd.crunchgen.mk \ + bsd.dep.mk \ + bsd.doc.mk \ + bsd.dtrace.mk \ + bsd.endian.mk \ + bsd.files.mk \ + bsd.incs.mk \ + bsd.info.mk \ + bsd.init.mk \ + bsd.kmod.mk \ + bsd.lib.mk \ + bsd.libnames.mk \ + bsd.links.mk \ + bsd.man.mk \ + bsd.nls.mk \ + bsd.obj.mk \ + bsd.own.mk \ + bsd.port.mk \ + bsd.port.options.mk \ + bsd.port.post.mk \ + bsd.port.pre.mk \ + bsd.port.subdir.mk \ + bsd.prog.mk \ + bsd.progs.mk \ + bsd.snmpmod.mk \ + bsd.subdir.mk \ + bsd.symver.mk \ + bsd.sys.mk \ + bsd.test.mk \ + sys.mk \ + version_gen.awk + +NO_OBJ= +FILESDIR= ${BINDIR}/mk + +.if ${MK_ATF} != "no" +FILES+= atf.test.mk +.endif + +.include <bsd.prog.mk> diff --git a/share/mk/atf.test.mk b/share/mk/atf.test.mk new file mode 100644 index 0000000..7e19087 --- /dev/null +++ b/share/mk/atf.test.mk @@ -0,0 +1,148 @@ +# $NetBSD$ +# $FreeBSD$ +# + +.include <bsd.init.mk> + +ATF_TESTS:= + +.if make(*test) +TESTSDIR?= . +.endif + +.if defined(ATF_TESTS_SUBDIRS) +# Only visit subdirs when building, etc because ATF does this it on its own. +.if !make(atf-test) +SUBDIR+= ${ATF_TESTS_SUBDIRS} +.endif +ATF_TESTS+= ${ATF_TESTS_SUBDIRS} + +.include <bsd.subdir.mk> +.endif + +.if defined(TESTS_C) +ATF_TESTS+= ${TESTS_C} +.for _T in ${TESTS_C} +SRCS.${_T}?= ${_T}.c +DPADD.${_T}+= ${LIBATF_C} +LDADD.${_T}+= -latf-c +.endfor +.endif + +.if defined(TESTS_CXX) +ATF_TESTS+= ${TESTS_CXX} +.for _T in ${TESTS_CXX} +SRCS.${_T}?= ${_T}${CXX_SUFFIX:U.cc} +DPADD.${_T}+= ${LIBATF_CXX} ${LIBATF_C} +LDADD.${_T}+= -latf-c++ -latf-c +.endfor +.endif + +.if defined(TESTS_SH) +ATF_TESTS+= ${TESTS_SH} +.for _T in ${TESTS_SH} +CLEANFILES+= ${_T} ${_T}.tmp +TESTS_SH_SRC_${_T}?= ${_T}.sh +${_T}: ${TESTS_SH_SRC_${_T}} + echo '#! /usr/bin/atf-sh' > ${.TARGET}.tmp + cat ${.ALLSRC} >> ${.TARGET}.tmp + chmod +x ${.TARGET}.tmp + mv ${.TARGET}.tmp ${.TARGET} +.endfor +.endif + +ATFFILE?= auto + +.if ${ATFFILE:tl} != "no" +FILES+= Atffile +FILESDIR_Atffile= ${TESTSDIR} + +.if ${ATFFILE:tl} == "auto" +CLEANFILES+= Atffile Atffile.tmp + +Atffile: Makefile + @{ echo 'Content-Type: application/X-atf-atffile; version="1"'; \ + echo; \ + echo '# Automatically generated by atf-test.mk.'; \ + echo; \ + echo 'prop: test-suite = "'`uname -o`'"'; \ + echo; \ + for tp in ${ATF_TESTS}; do \ + echo "tp: $${tp}"; \ + done; } >Atffile.tmp + @mv Atffile.tmp Atffile +.endif +.endif + +# Generate support variables for atf-test. +# +# atf-test can only work for native builds, i.e. a build host of a particular +# OS building a release for the same OS version and architecture. The target +# runs ATF, which is on the build host, and the tests execute code built for +# the target host. +# +# Due to the dependencies of the binaries built by the source tree and how they +# are used by tests, it is highly possible for a execution of "make test" to +# report bogus results unless the new binaries are put in place. + +# XXX (gcooper): Executing ATF from outside the source tree is improper; it +# should be built as part of the OS toolchain build for the host OS and +# executed from there. +ATF_PATH+= ${DESTDIR}/bin ${DESTDIR}/sbin ${DESTDIR}/usr/bin ${DESTDIR}/usr/sbin +TESTS_ENV+= PATH=${ATF_PATH:ts:}:${PATH} + +ATF_BUILD_CC?= ${DESTDIR}/usr/bin/cc +ATF_BUILD_CPP?= ${DESTDIR}/usr/bin/cpp +ATF_BUILD_CXX?= ${DESTDIR}/usr/bin/c++ +ATF_CONFDIR?= ${DESTDIR}/etc +ATF_INCLUDEDIR?= ${DESTDIR}/usr/include +ATF_LIBDIR?= ${DESTDIR}/usr/lib +ATF_LIBEXECDIR?= ${DESTDIR}/usr/libexec +ATF_PKGDATADIR?= ${DESTDIR}/usr/share/atf +ATF_SHELL?= ${DESTDIR}/bin/sh +LD_LIBRARY_PATH?= ${TESTS_LD_LIBRARY_PATH:tW:S/ /:/g} + +ATF_ENV_VARS= \ + ATF_BUILD_CC \ + ATF_BUILD_CPP \ + ATF_BUILD_CXX \ + ATF_CONFDIR \ + ATF_INCLUDEDIR \ + ATF_LIBDIR \ + ATF_LIBEXECDIR \ + ATF_PKGDATADIR \ + ATF_SHELL \ + +.for v in ${ATF_ENV_VARS} +.if !empty($v) +TESTS_ENV+= $v=${$v} +.endif +.endfor + +_TESTS_FIFO= ${.OBJDIR}/atf-run.fifo +_TESTS_LOG= ${.OBJDIR}/atf-run.log +CLEANFILES+= ${_TESTS_FIFO} ${_TESTS_LOG} + +ATF_BIN?= ${DESTDIR}/usr/bin +ATF_REPORT?= ${ATF_BIN}/atf-report +ATF_RUN?= ${ATF_BIN}/atf-run + +.PHONY: realtest +realtest: +.if defined(TESTSDIR) + @set -e; \ + cd ${DESTDIR}${TESTSDIR}; \ + rm -f ${_TESTS_FIFO}; \ + mkfifo ${_TESTS_FIFO}; \ + tee ${_TESTS_LOG} < ${_TESTS_FIFO} | ${TESTS_ENV} ${ATF_REPORT} & \ + set +e; \ + ${TESTS_ENV} ${ATF_RUN} >> ${_TESTS_FIFO}; \ + result=$${?}; \ + wait; \ + rm -f ${_TESTS_FIFO}; \ + echo; \ + echo "*** The verbatim output of atf-run has been saved to ${_TESTS_LOG}"; \ + exit $${result} +.endif + +.include <bsd.test.mk> diff --git a/share/mk/bsd.README b/share/mk/bsd.README new file mode 100644 index 0000000..a9adc1f --- /dev/null +++ b/share/mk/bsd.README @@ -0,0 +1,367 @@ +# @(#)bsd.README 8.2 (Berkeley) 4/2/94 +# $FreeBSD$ + +This is the README file for the "include" files for the FreeBSD +source tree. The files are installed in /usr/share/mk, and are by +convention, named with the suffix ".mk". These files store several +build options and should be handled with caution. + +Note, this file is not intended to replace reading through the .mk +files for anything tricky. + +There are two main types of make include files. One type is the generally +usable make include files, such as bsd.prog.mk and bsd.lib.mk. The other is +the internal make include files, such as bsd.files.mk and bsd.man.mk, which +can not/should not be used directly but are used by the other make include +files. In most cases it is only interesting to include bsd.prog.mk or +bsd.lib.mk. + +bsd.cpu.mk - sets CPU/arch-related variables +bsd.dep.mk - handle Makefile dependencies +bsd.doc.mk - building troff system documents +bsd.files.mk - install of general purpose files +bsd.incs.mk - install of include files +bsd.info.mk - building GNU Info hypertext system +bsd.init.mk - initialization for the make include files +bsd.kmod.mk - building loadable kernel modules +bsd.lib.mk - support for building libraries +bsd.libnames.mk - define library names +bsd.links.mk - install of links (sym/hard) +bsd.man.mk - install of manual pages and their links +bsd.nls.mk - build and install of NLS catalogs +bsd.obj.mk - creating 'obj' directories and cleaning up +bsd.own.mk - define common variables +bsd.port.mk - building ports +bsd.port.post.mk - building ports +bsd.port.pre.mk - building ports +bsd.port.subdir.mk - targets for building subdirectories for ports +bsd.prog.mk - building programs from source files +bsd.snmpmod.mk - building modules for the SNMP daemon bsnmpd +bsd.subdir.mk - targets for building subdirectories +bsd.sys.mk - common settings used for building FreeBSD sources +sys.mk - default rules for all makes + +This file does not document bsd.port*.mk. They are documented in ports(7). + +See also make(1), mkdep(1), style.Makefile(5) and `PMake - A +Tutorial', located in /usr/share/doc/psd/12.make. + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +Random things worth knowing about this document: + +If appropriate when documenting the variables the default value is +indicated using square brackets e.g. [gzip]. +In some cases the default value depend on other values (e.g. system +architecture). In these cases the most common value is indicated. + +This document contains some simple examples of the usage of the BSD make +include files. For more examples look at the makefiles in the FreeBSD +source tree. + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +RANDOM THINGS WORTH KNOWING: + +The files are like C-style #include files, and pretty much behave like +you'd expect. The syntax is slightly different in that a single '.' is +used instead of the hash mark, i.e. ".include <bsd.prog.mk>". + +One difference that will save you lots of debugging time is that inclusion +of the file is normally done at the *end* of the Makefile. The reason for +this is because .mk files often modify variables and behavior based on the +values of variables set in the Makefile. To make this work, remember that +the FIRST target found is the target that is used, i.e. if the Makefile has: + + a: + echo a + a: + echo a number two + +the command "make a" will echo "a". To make things confusing, the SECOND +variable assignment is the overriding one, i.e. if the Makefile has: + + a= foo + a= bar + + b: + echo ${a} + +the command "make b" will echo "bar". This is for compatibility with the +way the V7 make behaved. + +It's fairly difficult to make the BSD .mk files work when you're building +multiple programs in a single directory. It's a lot easier to split up +the programs than to deal with the problem. Most of the agony comes from +making the "obj" directory stuff work right, not because we switch to a new +version of make. So, don't get mad at us, figure out a better way to handle +multiple architectures so we can quit using the symbolic link stuff. +(Imake doesn't count.) + +The file .depend in the source directory is expected to contain dependencies +for the source files. This file is read automatically by make after reading +the Makefile. + +The variable DESTDIR works as before. It's not set anywhere but will change +the tree where the file gets installed. + +The profiled libraries are no longer built in a different directory than +the regular libraries. A new suffix, ".po", is used to denote a profiled +object. + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +The include file <sys.mk> has the default rules for all makes, in the BSD +environment or otherwise. You probably don't want to touch this file. + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +The include file <bsd.man.mk> handles installing manual pages and their +links. + +It has three targets: + + all-man: + build manual pages. + maninstall: + install the manual pages and their links. + manlint: + verify the validity of manual pages. + +It sets/uses the following variables: + +MANDIR Base path for manual installation. + +MANGRP Manual group. + +MANOWN Manual owner. + +MANMODE Manual mode. + +MANSUBDIR Subdirectory under the manual page section, i.e. "/vax" + or "/tahoe" for machine specific manual pages. + +MAN The manual pages to be installed (use a .1 - .9 suffix). + +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 soft-linked. + +The include file <bsd.man.mk> includes a file named "../Makefile.inc" if +it exists. + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +The include file <bsd.own.mk> contains the owners, groups, etc. for both +manual pages and binaries. + +It has no targets. + +It sets/uses the following variables: + +BINGRP Binary group. + +BINOWN Binary owner. + +BINMODE Binary mode. + +MANDIR Base path for manual installation. + +MANGRP Manual group. + +MANOWN Manual owner. + +MANMODE Manual mode. + +This file is generally useful when building your own Makefiles so that +they use the same default owners etc. as the rest of the tree. + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +The include file <bsd.prog.mk> handles building programs from one or +more source files, along with their manual pages. It has a limited number +of suffixes, consistent with the current needs of the BSD tree. + +It has seven targets: + + all: + build the program and its manual page + clean: + remove the program and any object files. + cleandir: + remove all of the files removed by the target clean, as + well as .depend, tags, and any manual pages. + depend: + make the dependencies for the source files, and store + them in the file .depend. + install: + install the program and its manual pages; if the Makefile + does not itself define the target install, the targets + beforeinstall and afterinstall may also be used to cause + actions immediately before and after the install target + is executed. + lint: + run lint on the source files + tags: + create a tags file for the source files. + +It sets/uses the following variables: + +BINGRP Binary group. + +BINOWN Binary owner. + +BINMODE Binary mode. + +CLEANFILES Additional files to remove and +CLEANDIRS additional directories to remove during clean and cleandir + targets. "rm -f" and "rm -rf" used respectively. + +CFLAGS Flags to the compiler when creating C objects. + +FILES A list of non-executable files. + The installation is controlled by the FILESNAME, FILESOWN, + FILESGRP, FILESMODE, FILESDIR variables that can be + further specialized by FILES<VAR>_<file>. + +LDADD Additional loader objects. Usually used for libraries. + For example, to load with the compatibility and utility + libraries, use: + + LDADD=-lutil -lcompat + +LDFLAGS Additional loader flags. + +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 + /bin/test and /bin/[, use: + + LINKS= ${DESTDIR}/bin/test ${DESTDIR}/bin/[ + +MAN Manual pages (should end in .1 - .9). If no MAN variable + is defined, "MAN=${PROG}.1" is assumed. + +PROG The name of the program to build. If not supplied, nothing + is built. + +PROG_CXX If defined, the name of the program to build. Also + causes <bsd.prog.mk> to link the program with the + standard C++ library. PROG_CXX overrides the value + of PROG if PROG is also set. + +PROGNAME The name that the above program will be installed as, if + different from ${PROG}. + +SRCS List of source files to build the program. If SRCS is not + defined, it's assumed to be ${PROG}.c or, if PROG_CXX is + defined, ${PROG_CXX}.cc. + +DPADD Additional dependencies for the program. Usually used for + libraries. For example, to depend on the compatibility and + utility libraries use: + + DPADD=${LIBCOMPAT} ${LIBUTIL} + + There is a predefined identifier for each (non-profiled, + non-shared) library and object. Library file names are + transformed to identifiers by removing the extension and + converting to upper case. + + There are no special identifiers for profiled or shared + libraries or objects. The identifiers for the standard + libraries are used in DPADD. This works correctly iff all + the libraries are built at the same time. Unfortunately, + it causes unnecessary relinks to shared libraries when + only the static libraries have changed. Dependencies on + shared libraries should be only on the library version + numbers. + +STRIP The flag passed to the install program to cause the binary + to be stripped. This is to be used when building your + own install script so that the entire system can be made + stripped/not-stripped using a single nob. + +SUBDIR A list of subdirectories that should be built as well. + Each of the targets will execute the same target in the + subdirectories. + +SCRIPTS A list of interpreter scripts [file.{sh,csh,pl,awk,...}]. + The installation is controlled by the SCRIPTSNAME, SCRIPTSOWN, + SCRIPTSGRP, SCRIPTSMODE, SCRIPTSDIR variables that can be + further specialized by SCRIPTS<VAR>_<script>. + +The include file <bsd.prog.mk> includes the file named "../Makefile.inc" +if it exists, as well as the include file <bsd.man.mk>. + +Some simple examples: + +To build foo from foo.c with a manual page foo.1, use: + + PROG= foo + + .include <bsd.prog.mk> + +To build foo from foo.c with a manual page foo.2, add the line: + + MAN= foo.2 + +If foo does not have a manual page at all, add the line: + + NO_MAN= + +If foo has multiple source files, add the line: + + SRCS= a.c b.c c.c d.c + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +The include file <bsd.subdir.mk> contains the default targets for building +subdirectories. It has the same seven targets as <bsd.prog.mk>: all, clean, +cleandir, depend, install, lint, and tags. For all of the directories +listed in the variable SUBDIRS, the specified directory will be visited +and the target made. There is also a default target which allows the +command "make subdir" where subdir is any directory listed in the variable +SUBDIRS. + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +The include file <bsd.lib.mk> has support for building libraries. It has +the same seven targets as <bsd.prog.mk>: all, clean, cleandir, depend, +install, lint, and tags. It has a limited number of suffixes, consistent +with the current needs of the BSD tree. + +It sets/uses the following variables: + +LIBDIR Target directory for libraries. + +LINTLIBDIR Target directory for lint libraries. + +LIBGRP Library group. + +LIBOWN Library owner. + +LIBMODE Library mode. + +LDADD Additional loader objects. + +MAN The manual pages to be installed (use a .1 - .9 suffix). + +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. (This is not the default for + versions of make.) + +SHLIB_LDSCRIPT Template file to generate shared library linker script. + Unless used, a simple symlink is created to the real + shared object. + +LIBRARIES_ONLY Do not build or install files other than the library. + +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. + +Libraries are ranlib'd before installation. diff --git a/share/mk/bsd.arch.inc.mk b/share/mk/bsd.arch.inc.mk new file mode 100644 index 0000000..98e429e --- /dev/null +++ b/share/mk/bsd.arch.inc.mk @@ -0,0 +1,11 @@ +# +# Include the arch-specific Makefile.inc.$ARCH. We go from most specific +# to least specific, stopping after we get a hit. +# +.if exists(${.CURDIR}/Makefile.${MACHINE}) +.include "Makefile.${MACHINE}" +.elif exists(${.CURDIR}/Makefile.${MACHINE_ARCH}) +.include "Makefile.${MACHINE_ARCH}" +.elif exists(${.CURDIR}/Makefile.${MACHINE_CPUARCH}) +.include "Makefile.${MACHINE_CPUARCH}" +.endif diff --git a/share/mk/bsd.compiler.mk b/share/mk/bsd.compiler.mk new file mode 100644 index 0000000..2d648de --- /dev/null +++ b/share/mk/bsd.compiler.mk @@ -0,0 +1,27 @@ +# $FreeBSD$ + +.if !defined(COMPILER_TYPE) +. if ${CC:T:Mgcc*} +COMPILER_TYPE:= gcc +. elif ${CC:T:Mclang} +COMPILER_TYPE:= clang +. else +_COMPILER_VERSION!= ${CC} --version +. if ${_COMPILER_VERSION:Mgcc} +COMPILER_TYPE:= gcc +. elif ${_COMPILER_VERSION:M\(GCC\)} +COMPILER_TYPE:= gcc +. elif ${_COMPILER_VERSION:Mclang} +COMPILER_TYPE:= clang +. else +.error Unable to determine compiler type for ${CC}. Consider setting COMPILER_TYPE. +. endif +. undef _COMPILER_VERSION +. endif +.endif + +.if ${COMPILER_TYPE} == "clang" +COMPILER_FEATURES= c++11 +.else +COMPILER_FEATURES= +.endif diff --git a/share/mk/bsd.cpu.mk b/share/mk/bsd.cpu.mk new file mode 100644 index 0000000..caf8340 --- /dev/null +++ b/share/mk/bsd.cpu.mk @@ -0,0 +1,262 @@ +# $FreeBSD$ + +# Set default CPU compile flags and baseline CPUTYPE for each arch. The +# compile flags must support the minimum CPU type for each architecture but +# may tune support for more advanced processors. + +.if !defined(CPUTYPE) || empty(CPUTYPE) +_CPUCFLAGS = +. if ${MACHINE_CPUARCH} == "i386" +MACHINE_CPU = i486 +. elif ${MACHINE_CPUARCH} == "amd64" +MACHINE_CPU = amd64 sse2 sse mmx +. elif ${MACHINE_CPUARCH} == "ia64" +MACHINE_CPU = itanium +. elif ${MACHINE_CPUARCH} == "powerpc" +MACHINE_CPU = aim +. elif ${MACHINE_CPUARCH} == "sparc64" +MACHINE_CPU = ultrasparc +. elif ${MACHINE_CPUARCH} == "arm" +MACHINE_CPU = arm +. elif ${MACHINE_CPUARCH} == "mips" +MACHINE_CPU = mips +. endif +.else + +# Handle aliases (not documented in make.conf to avoid user confusion +# between e.g. i586 and pentium) + +. if ${MACHINE_CPUARCH} == "i386" +. if ${CPUTYPE} == "barcelona" +CPUTYPE = amdfam10 +. elif ${CPUTYPE} == "k7" +CPUTYPE = athlon +. elif ${CPUTYPE} == "westmere" || ${CPUTYPE} == "nehalem" +CPUTYPE = corei7 +. elif ${CPUTYPE} == "core" +CPUTYPE = prescott +. elif ${CPUTYPE} == "p4" +CPUTYPE = pentium4 +. elif ${CPUTYPE} == "p4m" +CPUTYPE = pentium4m +. elif ${CPUTYPE} == "p3" +CPUTYPE = pentium3 +. elif ${CPUTYPE} == "p3m" +CPUTYPE = pentium3m +. elif ${CPUTYPE} == "p-m" +CPUTYPE = pentium-m +. elif ${CPUTYPE} == "p2" +CPUTYPE = pentium2 +. elif ${CPUTYPE} == "i686" +CPUTYPE = pentiumpro +. elif ${CPUTYPE} == "i586/mmx" +CPUTYPE = pentium-mmx +. elif ${CPUTYPE} == "i586" +CPUTYPE = pentium +. endif +. elif ${MACHINE_CPUARCH} == "amd64" +. if ${CPUTYPE} == "barcelona" +CPUTYPE = amdfam10 +. elif ${CPUTYPE} == "westmere" || ${CPUTYPE} == "nehalem" +CPUTYPE = corei7 +. elif ${CPUTYPE} == "prescott" +CPUTYPE = nocona +. endif +. elif ${MACHINE_ARCH} == "sparc64" +. if ${CPUTYPE} == "us" +CPUTYPE = ultrasparc +. elif ${CPUTYPE} == "us3" +CPUTYPE = ultrasparc3 +. endif +. endif + +############################################################################### +# Logic to set up correct gcc optimization flag. This must be included +# after /etc/make.conf so it can react to the local value of CPUTYPE +# defined therein. Consult: +# http://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html +# http://gcc.gnu.org/onlinedocs/gcc/IA_002d64-Options.html +# http://gcc.gnu.org/onlinedocs/gcc/RS_002f6000-and-PowerPC-Options.html +# http://gcc.gnu.org/onlinedocs/gcc/MIPS-Options.html +# http://gcc.gnu.org/onlinedocs/gcc/SPARC-Options.html +# http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86_002d64-Options.html + +. if ${MACHINE_CPUARCH} == "i386" +. if ${CPUTYPE} == "crusoe" +_CPUCFLAGS = -march=i686 -falign-functions=0 -falign-jumps=0 -falign-loops=0 +. elif ${CPUTYPE} == "k5" +_CPUCFLAGS = -march=pentium +. elif ${CPUTYPE} == "c7" +_CPUCFLAGS = -march=c3-2 +. else +_CPUCFLAGS = -march=${CPUTYPE} +. endif +. elif ${MACHINE_CPUARCH} == "amd64" +_CPUCFLAGS = -march=${CPUTYPE} +. elif ${MACHINE_CPUARCH} == "arm" +. if ${CPUTYPE} == "xscale" +#XXX: gcc doesn't seem to like -mcpu=xscale, and dies while rebuilding itself +#_CPUCFLAGS = -mcpu=xscale +_CPUCFLAGS = -march=armv5te -D__XSCALE__ +. elif ${CPUTYPE} == "armv6" +_CPUCFLAGS = -march=${CPUTYPE} -DARM_ARCH_6=1 +. elif ${CPUTYPE} == "cortexa" +_CPUCFLAGS = -DARM_ARCH_6=1 -mfpu=vfp +. else +_CPUCFLAGS = -mcpu=${CPUTYPE} +. endif +. elif ${MACHINE_ARCH} == "powerpc" +. if ${CPUTYPE} == "e500" +_CPUCFLAGS = -Wa,-me500 -msoft-float +. else +_CPUCFLAGS = -mcpu=${CPUTYPE} -mno-powerpc64 +. endif +. elif ${MACHINE_ARCH} == "powerpc64" +_CPUCFLAGS = -mcpu=${CPUTYPE} +. elif ${MACHINE_CPUARCH} == "mips" +. if ${CPUTYPE} == "mips32" +_CPUCFLAGS = -march=mips32 +. elif ${CPUTYPE} == "mips32r2" +_CPUCFLAGS = -march=mips32r2 +. elif ${CPUTYPE} == "mips64" +_CPUCFLAGS = -march=mips64 +. elif ${CPUTYPE} == "mips64r2" +_CPUCFLAGS = -march=mips64r2 +. elif ${CPUTYPE} == "mips4kc" +_CPUCFLAGS = -march=4kc +. elif ${CPUTYPE} == "mips24kc" +_CPUCFLAGS = -march=24kc +. endif +. elif ${MACHINE_ARCH} == "sparc64" +. if ${CPUTYPE} == "v9" +_CPUCFLAGS = -mcpu=v9 +. elif ${CPUTYPE} == "ultrasparc" +_CPUCFLAGS = -mcpu=ultrasparc +. elif ${CPUTYPE} == "ultrasparc3" +_CPUCFLAGS = -mcpu=ultrasparc3 +. endif +. endif + +# Set up the list of CPU features based on the CPU type. This is an +# unordered list to make it easy for client makefiles to test for the +# presence of a CPU feature. + +. if ${MACHINE_CPUARCH} == "i386" +. if ${CPUTYPE} == "bdver2" || ${CPUTYPE} == "bdver1" +MACHINE_CPU = xop avx sse42 sse41 ssse3 sse4a sse3 sse2 sse mmx k6 k5 i586 +. elif ${CPUTYPE} == "btver2" +MACHINE_CPU = avx sse42 sse41 ssse3 sse4a sse3 sse2 sse mmx k6 k5 i586 +. elif ${CPUTYPE} == "btver1" +MACHINE_CPU = ssse3 sse4a sse3 sse2 sse mmx k6 k5 i586 +. elif ${CPUTYPE} == "amdfam10" +MACHINE_CPU = athlon-xp athlon k7 3dnow sse4a sse3 sse2 sse mmx k6 k5 i586 +. elif ${CPUTYPE} == "opteron-sse3" || ${CPUTYPE} == "athlon64-sse3" +MACHINE_CPU = athlon-xp athlon k7 3dnow sse3 sse2 sse mmx k6 k5 i586 +. elif ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || \ + ${CPUTYPE} == "athlon-fx" +MACHINE_CPU = athlon-xp athlon k7 3dnow sse2 sse mmx k6 k5 i586 +. elif ${CPUTYPE} == "athlon-mp" || ${CPUTYPE} == "athlon-xp" || \ + ${CPUTYPE} == "athlon-4" +MACHINE_CPU = athlon-xp athlon k7 3dnow sse mmx k6 k5 i586 +. elif ${CPUTYPE} == "athlon" || ${CPUTYPE} == "athlon-tbird" +MACHINE_CPU = athlon k7 3dnow mmx k6 k5 i586 +. elif ${CPUTYPE} == "k6-3" || ${CPUTYPE} == "k6-2" || ${CPUTYPE} == "geode" +MACHINE_CPU = 3dnow mmx k6 k5 i586 +. elif ${CPUTYPE} == "k6" +MACHINE_CPU = mmx k6 k5 i586 +. elif ${CPUTYPE} == "k5" +MACHINE_CPU = k5 i586 +. elif ${CPUTYPE} == "core-avx2" +MACHINE_CPU = avx2 avx sse42 sse41 ssse3 sse3 sse2 sse i686 mmx i586 +. elif ${CPUTYPE} == "core-avx-i" || ${CPUTYPE} == "corei7-avx" +MACHINE_CPU = avx sse42 sse41 ssse3 sse3 sse2 sse i686 mmx i586 +. elif ${CPUTYPE} == "corei7" +MACHINE_CPU = sse42 sse41 ssse3 sse3 sse2 sse i686 mmx i586 +. elif ${CPUTYPE} == "penryn" +MACHINE_CPU = sse41 ssse3 sse3 sse2 sse i686 mmx i586 +. elif ${CPUTYPE} == "atom" || ${CPUTYPE} == "core2" +MACHINE_CPU = ssse3 sse3 sse2 sse i686 mmx i586 +. elif ${CPUTYPE} == "yonah" || ${CPUTYPE} == "prescott" +MACHINE_CPU = sse3 sse2 sse i686 mmx i586 +. elif ${CPUTYPE} == "pentium4" || ${CPUTYPE} == "pentium4m" || \ + ${CPUTYPE} == "pentium-m" +MACHINE_CPU = sse2 sse i686 mmx i586 +. elif ${CPUTYPE} == "pentium3" || ${CPUTYPE} == "pentium3m" +MACHINE_CPU = sse i686 mmx i586 +. elif ${CPUTYPE} == "pentium2" +MACHINE_CPU = i686 mmx i586 +. elif ${CPUTYPE} == "pentiumpro" +MACHINE_CPU = i686 i586 +. elif ${CPUTYPE} == "pentium-mmx" +MACHINE_CPU = mmx i586 +. elif ${CPUTYPE} == "pentium" +MACHINE_CPU = i586 +. elif ${CPUTYPE} == "c7" +MACHINE_CPU = sse3 sse2 sse i686 mmx i586 +. elif ${CPUTYPE} == "c3-2" +MACHINE_CPU = sse i686 mmx i586 +. elif ${CPUTYPE} == "c3" +MACHINE_CPU = 3dnow mmx i586 +. elif ${CPUTYPE} == "winchip2" +MACHINE_CPU = 3dnow mmx +. elif ${CPUTYPE} == "winchip-c6" +MACHINE_CPU = mmx +. endif +MACHINE_CPU += i486 +. elif ${MACHINE_CPUARCH} == "amd64" +. if ${CPUTYPE} == "bdver2" || ${CPUTYPE} == "bdver1" +MACHINE_CPU = xop avx sse42 sse41 ssse3 sse4a sse3 +. elif ${CPUTYPE} == "btver2" +MACHINE_CPU = avx sse42 sse41 ssse3 sse4a sse3 +. elif ${CPUTYPE} == "btver1" +MACHINE_CPU = ssse3 sse4a sse3 +. elif ${CPUTYPE} == "amdfam10" +MACHINE_CPU = k8 3dnow sse4a sse3 +. elif ${CPUTYPE} == "opteron-sse3" || ${CPUTYPE} == "athlon64-sse3" || \ + ${CPUTYPE} == "k8-sse3" +MACHINE_CPU = k8 3dnow sse3 +. elif ${CPUTYPE} == "opteron" || ${CPUTYPE} == "athlon64" || \ + ${CPUTYPE} == "athlon-fx" || ${CPUTYPE} == "k8" +MACHINE_CPU = k8 3dnow +. elif ${CPUTYPE} == "core-avx2" +MACHINE_CPU = avx2 avx sse42 sse41 ssse3 sse3 +. elif ${CPUTYPE} == "core-avx-i" || ${CPUTYPE} == "corei7-avx" +MACHINE_CPU = avx sse42 sse41 ssse3 sse3 +. elif ${CPUTYPE} == "corei7" +MACHINE_CPU = sse42 sse41 ssse3 sse3 +. elif ${CPUTYPE} == "penryn" +MACHINE_CPU = sse41 ssse3 sse3 +. elif ${CPUTYPE} == "atom" || ${CPUTYPE} == "core2" +MACHINE_CPU = ssse3 sse3 +. elif ${CPUTYPE} == "nocona" +MACHINE_CPU = sse3 +. endif +MACHINE_CPU += amd64 sse2 sse mmx +. elif ${MACHINE_CPUARCH} == "ia64" +. if ${CPUTYPE} == "itanium" +MACHINE_CPU = itanium +. endif +. elif ${MACHINE_ARCH} == "powerpc" +. if ${CPUTYPE} == "e500" +MACHINE_CPU = booke +. endif +. elif ${MACHINE_ARCH} == "sparc64" +. if ${CPUTYPE} == "v9" +MACHINE_CPU = v9 +. elif ${CPUTYPE} == "ultrasparc" +MACHINE_CPU = v9 ultrasparc +. elif ${CPUTYPE} == "ultrasparc3" +MACHINE_CPU = v9 ultrasparc ultrasparc3 +. endif +. endif +.endif + +.if ${MACHINE_CPUARCH} == "mips" +CFLAGS += -G0 +.endif + +# NB: COPTFLAGS is handled in /usr/src/sys/conf/kern.pre.mk + +.if !defined(NO_CPU_CFLAGS) +CFLAGS += ${_CPUCFLAGS} +.endif diff --git a/share/mk/bsd.crunchgen.mk b/share/mk/bsd.crunchgen.mk new file mode 100644 index 0000000..d8f07b1 --- /dev/null +++ b/share/mk/bsd.crunchgen.mk @@ -0,0 +1,167 @@ +################################################################# +# +# General notes: +# +# A number of Make variables are used to generate the crunchgen config file. +# +# CRUNCH_SRCDIRS: lists directories to search for included programs +# CRUNCH_PROGS: lists programs to be included +# CRUNCH_LIBS: libraries to statically link with +# CRUNCH_SHLIBS: libraries to dynamically link with +# CRUNCH_BUILDOPTS: generic build options to be added to every program +# CRUNCH_BUILDTOOLS: lists programs that need build tools built in the +# local architecture. +# +# Special options can be specified for individual programs +# CRUNCH_SRCDIR_$(P): base source directory for program $(P) +# CRUNCH_BUILDOPTS_$(P): additional build options for $(P) +# CRUNCH_ALIAS_$(P): additional names to be used for $(P) +# +# By default, any name appearing in CRUNCH_PROGS or CRUNCH_ALIAS_${P} +# will be used to generate a hard link to the resulting binary. +# Specific links can be suppressed by setting +# CRUNCH_SUPPRESS_LINK_$(NAME) to 1. +# +# If CRUNCH_GENERATE_LINKS is set to no, no links will be generated. +# + +# $FreeBSD$ + +################################################################## +# The following is pretty nearly a generic crunchgen-handling makefile +# + +CONF= $(PROG).conf +OUTMK= $(PROG).mk +OUTC= $(PROG).c +OUTPUTS=$(OUTMK) $(OUTC) $(PROG).cache +CRUNCHOBJS= ${.OBJDIR} +.if defined(MAKEOBJDIRPREFIX) +CANONICALOBJDIR:= ${MAKEOBJDIRPREFIX}${.CURDIR} +.elif defined(MAKEOBJDIR) && ${MAKEOBJDIR:M/*} != "" +CANONICALOBJDIR:=${MAKEOBJDIR} +.else +CANONICALOBJDIR:= /usr/obj${.CURDIR} +.endif +CRUNCH_GENERATE_LINKS?= yes + +CLEANFILES+= $(CONF) *.o *.lo *.c *.mk *.cache *.a *.h + +# Don't try to extract debug info from ${PROG}. +NO_DEBUG_FILES= + +# Program names and their aliases contribute hardlinks to 'rescue' executable, +# except for those that get suppressed. +.for D in $(CRUNCH_SRCDIRS) +.for P in $(CRUNCH_PROGS_$(D)) +.ifdef CRUNCH_SRCDIR_${P} +$(OUTPUTS): $(CRUNCH_SRCDIR_${P})/Makefile +.else +$(OUTPUTS): $(.CURDIR)/../../$(D)/$(P)/Makefile +.endif +.if ${CRUNCH_GENERATE_LINKS} == "yes" +.ifndef CRUNCH_SUPPRESS_LINK_${P} +LINKS+= $(BINDIR)/$(PROG) $(BINDIR)/$(P) +.endif +.for A in $(CRUNCH_ALIAS_$(P)) +.ifndef CRUNCH_SUPPRESS_LINK_${A} +LINKS+= $(BINDIR)/$(PROG) $(BINDIR)/$(A) +.endif +.endfor +.endif +.endfor +.endfor + +all: $(PROG) +exe: $(PROG) + +$(CONF): Makefile + echo \# Auto-generated, do not edit >$(.TARGET) +.ifdef CRUNCH_BUILDOPTS + echo buildopts $(CRUNCH_BUILDOPTS) >>$(.TARGET) +.endif +.ifdef CRUNCH_LIBS + echo libs $(CRUNCH_LIBS) >>$(.TARGET) +.endif +.ifdef CRUNCH_SHLIBS + echo libs_so $(CRUNCH_SHLIBS) >>$(.TARGET) +.endif +.for D in $(CRUNCH_SRCDIRS) +.for P in $(CRUNCH_PROGS_$(D)) + echo progs $(P) >>$(.TARGET) +.ifdef CRUNCH_SRCDIR_${P} + echo special $(P) srcdir $(CRUNCH_SRCDIR_${P}) >>$(.TARGET) +.else + echo special $(P) srcdir $(.CURDIR)/../../$(D)/$(P) >>$(.TARGET) +.endif +.ifdef CRUNCH_BUILDOPTS_${P} + echo special $(P) buildopts DIRPRFX=${DIRPRFX}${P}/ \ + $(CRUNCH_BUILDOPTS_${P}) >>$(.TARGET) +.else + echo special $(P) buildopts DIRPRFX=${DIRPRFX}${P}/ >>$(.TARGET) +.endif +.for A in $(CRUNCH_ALIAS_$(P)) + echo ln $(P) $(A) >>$(.TARGET) +.endfor +.endfor +.endfor + +# XXX Make sure we don't pass -P to crunchgen(1). +.MAKEFLAGS:= ${.MAKEFLAGS:N-P} +.ORDER: $(OUTPUTS) objs +$(OUTPUTS): $(CONF) + MAKE=${MAKE} MAKEOBJDIRPREFIX=${CRUNCHOBJS} crunchgen -fq -m $(OUTMK) \ + -c $(OUTC) $(CONF) + +$(PROG): $(OUTPUTS) objs + MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) exe + +objs: $(OUTMK) + MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) objs + +# <sigh> Someone should replace the bin/csh and bin/sh build-tools with +# shell scripts so we can remove this nonsense. +build-tools: +.for _tool in $(CRUNCH_BUILDTOOLS) + cd $(.CURDIR)/../../${_tool}; \ + MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} obj; \ + MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} build-tools +.endfor + +# Use a separate build tree to hold files compiled for this crunchgen binary +# Yes, this does seem to partly duplicate bsd.subdir.mk, but I can't +# get that to cooperate with bsd.prog.mk. Besides, many of the standard +# targets should NOT be propagated into the components. +cleandepend cleandir obj objlink: +.for D in $(CRUNCH_SRCDIRS) +.for P in $(CRUNCH_PROGS_$(D)) +.ifdef CRUNCH_SRCDIR_${P} + cd ${CRUNCH_SRCDIR_$(P)} && \ + MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \ + DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET} +.else + cd $(.CURDIR)/../../${D}/${P} && \ + MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \ + DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET} +.endif +.endfor +.endfor + +clean: + rm -f ${CLEANFILES} + if [ -e ${.OBJDIR}/$(OUTMK) ]; then \ + MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) clean; \ + fi +.for D in $(CRUNCH_SRCDIRS) +.for P in $(CRUNCH_PROGS_$(D)) +.ifdef CRUNCH_SRCDIR_${P} + cd ${CRUNCH_SRCDIR_$(P)} && \ + MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \ + DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET} +.else + cd $(.CURDIR)/../../${D}/${P} && \ + MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \ + DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET} +.endif +.endfor +.endfor diff --git a/share/mk/bsd.dep.mk b/share/mk/bsd.dep.mk new file mode 100644 index 0000000..deac736 --- /dev/null +++ b/share/mk/bsd.dep.mk @@ -0,0 +1,192 @@ +# $FreeBSD$ +# +# The include file <bsd.dep.mk> handles Makefile dependencies. +# +# +# +++ variables +++ +# +# CTAGS A tags file generation program [gtags] +# +# CTAGSFLAGS Options for ctags(1) [not set] +# +# DEPENDFILE dependencies file [.depend] +# +# GTAGSFLAGS Options for gtags(1) [-o] +# +# HTAGSFLAGS Options for htags(1) [not set] +# +# MKDEP Options for ${MKDEPCMD} [not set] +# +# MKDEPCMD Makefile dependency list program [mkdep] +# +# SRCS List of source files (c, c++, assembler) +# +# DPSRCS List of source files which are needed for generating +# dependencies, ${SRCS} are always part of it. +# +# +++ targets +++ +# +# cleandepend: +# Remove depend and tags file +# +# depend: +# Make the dependencies for the source files, and store +# them in the file ${DEPENDFILE}. +# +# tags: +# In "ctags" mode, create a tags file for the source files. +# In "gtags" mode, create a (GLOBAL) gtags file for the +# source files. If HTML is defined, htags(1) is also run +# after gtags(1). + +.if !target(__<bsd.init.mk>__) +.error bsd.dep.mk cannot be included directly. +.endif + +CTAGS?= gtags +CTAGSFLAGS?= +GTAGSFLAGS?= -o +HTAGSFLAGS?= + +.if ${CC} != "cc" +MKDEPCMD?= CC='${CC}' mkdep +.else +MKDEPCMD?= mkdep +.endif +DEPENDFILE?= .depend + +# Keep `tags' here, before SRCS are mangled below for `depend'. +.if !target(tags) && defined(SRCS) && !defined(NO_TAGS) +tags: ${SRCS} +.if ${CTAGS:T} == "gtags" + @cd ${.CURDIR} && ${CTAGS} ${GTAGSFLAGS} ${.OBJDIR} +.if defined(HTML) + @cd ${.CURDIR} && htags ${HTAGSFLAGS} -d ${.OBJDIR} ${.OBJDIR} +.endif +.else + @${CTAGS} ${CTAGSFLAGS} -f /dev/stdout \ + ${.ALLSRC:N*.h} | sed "s;${.CURDIR}/;;" > ${.TARGET} +.endif +.endif + +.if defined(SRCS) +CLEANFILES?= + +.if !exists(${.OBJDIR}/${DEPENDFILE}) +.for _S in ${SRCS:N*.[hly]} +${_S:R}.o: ${_S} +.endfor +.endif + +.for _LSRC in ${SRCS:M*.l:N*/*} +.for _LC in ${_LSRC:R}.c +${_LC}: ${_LSRC} + ${LEX} -t ${LFLAGS} ${.ALLSRC} > ${.TARGET} +.if !exists(${.OBJDIR}/${DEPENDFILE}) +${_LC:R}.o: ${_LC} +.endif +SRCS:= ${SRCS:S/${_LSRC}/${_LC}/} +CLEANFILES+= ${_LC} +.endfor +.endfor + +.for _YSRC in ${SRCS:M*.y:N*/*} +.for _YC in ${_YSRC:R}.c +SRCS:= ${SRCS:S/${_YSRC}/${_YC}/} +CLEANFILES+= ${_YC} +.if !empty(YFLAGS:M-d) && !empty(SRCS:My.tab.h) +.ORDER: ${_YC} y.tab.h +${_YC} y.tab.h: ${_YSRC} + ${YACC} ${YFLAGS} ${.ALLSRC} + cp y.tab.c ${_YC} +CLEANFILES+= y.tab.c y.tab.h +.elif !empty(YFLAGS:M-d) +.for _YH in ${_YC:R}.h +${_YH}: ${_YC} +${_YC}: ${_YSRC} + ${YACC} ${YFLAGS} -o ${_YC} ${.ALLSRC} +SRCS+= ${_YH} +CLEANFILES+= ${_YH} +.endfor +.else +${_YC}: ${_YSRC} + ${YACC} ${YFLAGS} -o ${_YC} ${.ALLSRC} +.endif +.if !exists(${.OBJDIR}/${DEPENDFILE}) +${_YC:R}.o: ${_YC} +.endif +.endfor +.endfor +.endif + +.if !target(depend) +.if defined(SRCS) +depend: beforedepend ${DEPENDFILE} afterdepend + +# Tell bmake not to look for generated files via .PATH +.NOPATH: ${DEPENDFILE} + +# Different types of sources are compiled with slightly different flags. +# Split up the sources, and filter out headers and non-applicable flags. +MKDEP_CFLAGS= ${CFLAGS:M-nostdinc*} ${CFLAGS:M-[BIDU]*} ${CFLAGS:M-std=*} \ + ${CFLAGS:M-ansi} +MKDEP_CXXFLAGS= ${CXXFLAGS:M-nostdinc*} ${CXXFLAGS:M-[BIDU]*} \ + ${CXXFLAGS:M-std=*} ${CXXFLAGS:M-ansi} ${CXXFLAGS:M-stdlib=*} + +DPSRCS+= ${SRCS} +${DEPENDFILE}: ${DPSRCS} + rm -f ${DEPENDFILE} +.if !empty(DPSRCS:M*.[cS]) + ${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \ + ${MKDEP_CFLAGS} ${.ALLSRC:M*.[cS]} +.endif +.if !empty(DPSRCS:M*.cc) || !empty(DPSRCS:M*.C) || !empty(DPSRCS:M*.cpp) || \ + !empty(DPSRCS:M*.cxx) + ${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \ + ${MKDEP_CXXFLAGS} \ + ${.ALLSRC:M*.cc} ${.ALLSRC:M*.C} ${.ALLSRC:M*.cpp} ${.ALLSRC:M*.cxx} +.endif +.if target(_EXTRADEPEND) +_EXTRADEPEND: .USE +${DEPENDFILE}: _EXTRADEPEND +.endif + +.ORDER: ${DEPENDFILE} afterdepend +.else +depend: beforedepend afterdepend +.endif +.if !target(beforedepend) +beforedepend: +.else +.ORDER: beforedepend ${DEPENDFILE} +.ORDER: beforedepend afterdepend +.endif +.if !target(afterdepend) +afterdepend: +.endif +.endif + +.if !target(cleandepend) +cleandepend: +.if defined(SRCS) +.if ${CTAGS:T} == "gtags" + rm -f ${DEPENDFILE} GPATH GRTAGS GSYMS GTAGS +.if defined(HTML) + rm -rf HTML +.endif +.else + rm -f ${DEPENDFILE} tags +.endif +.endif +.endif + +.if !target(checkdpadd) && (defined(DPADD) || defined(LDADD)) +_LDADD_FROM_DPADD= ${DPADD:C;^/usr/lib/lib(.*)\.a$;-l\1;} +_LDADD_CANONICALIZED= ${LDADD:S/$//} +checkdpadd: +.if ${_LDADD_FROM_DPADD} != ${_LDADD_CANONICALIZED} + @echo ${.CURDIR} + @echo "DPADD -> ${_LDADD_FROM_DPADD}" + @echo "LDADD -> ${_LDADD_CANONICALIZED}" +.endif +.endif diff --git a/share/mk/bsd.doc.mk b/share/mk/bsd.doc.mk new file mode 100644 index 0000000..49b2d9b --- /dev/null +++ b/share/mk/bsd.doc.mk @@ -0,0 +1,194 @@ +# from: @(#)bsd.doc.mk 5.3 (Berkeley) 1/2/91 +# $FreeBSD$ +# +# The include file <bsd.doc.mk> handles installing BSD troff documents. +# +# +# +++ variables +++ +# +# DCOMPRESS_CMD Program to compress troff documents. Output is to stdout. +# [${COMPRESS_CMD}] +# +# DESTDIR Change the tree where the documents get installed. [not set] +# +# DOC Document name. [paper] +# +# EXTRA Extra files (not SRCS) that make up the document. [not set] +# +# LPR Printer command. [lpr] +# +# MACROS Macro packages used to build the document. [not set] +# +# NO_DOCCOMPRESS If you do not want formatted troff documents to be +# compressed when they are installed. [not set] +# +# PRINTERDEVICE Indicates which output formats will be generated +# (ascii, ps, html). [ascii] +# +# SRCDIR Directory where source files live. [${.CURDIR}] +# +# SRCS List of source files. [not set] +# +# TRFLAGS Additional flags to groff(1). [not set] +# +# USE_EQN If set, preprocess with eqn(1). [not set] +# +# USE_PIC If set, preprocess with pic(1). [not set] +# +# USE_REFER If set, preprocess with refer(1). [not set] +# +# USE_SOELIM If set, preprocess with soelim(1). [not set] +# +# USE_TBL If set, preprocess with tbl(1). [not set] +# +# VOLUME Volume the document belongs to. [not set] + +.include <bsd.init.mk> + +PRINTERDEVICE?= ascii + +BIB?= bib +GREMLIN?= grn +GRIND?= vgrind -f +INDXBIB?= indxbib +PIC?= pic +REFER?= refer +.for _dev in ${PRINTERDEVICE:Mascii} +ROFF.ascii?= groff -Tascii -P-c ${TRFLAGS} -mtty-char ${MACROS} ${PAGES:C/^/-o/1} +.endfor +.for _dev in ${PRINTERDEVICE:Nascii} +ROFF.${_dev}?= groff -T${_dev} ${TRFLAGS} ${MACROS} ${PAGES:C/^/-o/1} +.endfor +SOELIM?= soelim +TBL?= tbl + +DOC?= paper +LPR?= lpr + +.if defined(USE_EQN) +TRFLAGS+= -e +.endif +.if defined(USE_PIC) +TRFLAGS+= -p +.endif +.if defined(USE_REFER) +TRFLAGS+= -R +.endif +.if defined(USE_SOELIM) +TRFLAGS+= -I${SRCDIR} +.endif +.if defined(USE_TBL) +TRFLAGS+= -t +.endif + +DCOMPRESS_EXT?= ${COMPRESS_EXT} +DCOMPRESS_CMD?= ${COMPRESS_CMD} +.for _dev in ${PRINTERDEVICE:Mhtml} +DFILE.html= ${DOC}.html +.endfor +.for _dev in ${PRINTERDEVICE:Nhtml} +.if defined(NO_DOCCOMPRESS) +DFILE.${_dev}= ${DOC}.${_dev} +.else +DFILE.${_dev}= ${DOC}.${_dev}${DCOMPRESS_EXT} +.endif +.endfor + +UNROFF?= unroff +HTML_SPLIT?= yes +UNROFFFLAGS?= -fhtml +.if ${HTML_SPLIT} == "yes" +UNROFFFLAGS+= split=1 +.endif + +# Compatibility mode flag for groff. Use this when formatting documents with +# Berkeley me macros (orig_me(7)). +COMPAT?= -C + +.PATH: ${.CURDIR} ${SRCDIR} + +.for _dev in ${PRINTERDEVICE} +all: ${DFILE.${_dev}} +.endfor + +.if !target(print) +.for _dev in ${PRINTERDEVICE} +print: ${DFILE.${_dev}} +.endfor +print: +.for _dev in ${PRINTERDEVICE} +.if defined(NO_DOCCOMPRESS) + ${LPR} ${DFILE.${_dev}} +.else + ${DCOMPRESS_CMD} -d ${DFILE.${_dev}} | ${LPR} +.endif +.endfor +.endif + +.for _dev in ${PRINTERDEVICE:Nascii:Nps:Nhtml} +CLEANFILES+= ${DOC}.${_dev} ${DOC}.${_dev}${DCOMPRESS_EXT} +.endfor +CLEANFILES+= ${DOC}.ascii ${DOC}.ascii${DCOMPRESS_EXT} \ + ${DOC}.ps ${DOC}.ps${DCOMPRESS_EXT} \ + ${DOC}.html ${DOC}-*.html + +realinstall: +.for _dev in ${PRINTERDEVICE:Mhtml} + cd ${SRCDIR}; \ + ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ + ${DOC}*.html ${DESTDIR}${BINDIR}/${VOLUME} +.endfor +.for _dev in ${PRINTERDEVICE:Nhtml} + ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ + ${DFILE.${_dev}} ${DESTDIR}${BINDIR}/${VOLUME} +.endfor + +spell: ${SRCS} + (cd ${.CURDIR}; spell ${SRCS} ) | sort | \ + comm -23 - ${.CURDIR}/spell.ok > ${DOC}.spell + +BINDIR?= /usr/share/doc +BINMODE= 444 + +SRCDIR?= ${.CURDIR} + +.if defined(EXTRA) && !empty(EXTRA) +_stamp.extra: ${EXTRA} + touch ${.TARGET} +.endif + +CLEANFILES+= _stamp.extra +.for _dev in ${PRINTERDEVICE:Nhtml} +.if !target(${DFILE.${_dev}}) +.if target(_stamp.extra) +${DFILE.${_dev}}: _stamp.extra +.endif +${DFILE.${_dev}}: ${SRCS} +.if defined(NO_DOCCOMPRESS) + ${ROFF.${_dev}} ${.ALLSRC:N_stamp.extra} > ${.TARGET} +.else + ${ROFF.${_dev}} ${.ALLSRC:N_stamp.extra} | ${DCOMPRESS_CMD} > ${.TARGET} +.endif +.endif +.endfor + +.for _dev in ${PRINTERDEVICE:Mhtml} +.if !target(${DFILE.html}) +.if target(_stamp.extra) +${DFILE.html}: _stamp.extra +.endif +${DFILE.html}: ${SRCS} +.if defined(MACROS) && !empty(MACROS) + cd ${SRCDIR}; ${UNROFF} ${MACROS} ${UNROFFFLAGS} \ + document=${DOC} ${SRCS} +.else # unroff(1) requires a macro package as an argument + cd ${SRCDIR}; ${UNROFF} -ms ${UNROFFFLAGS} \ + document=${DOC} ${SRCS} +.else +.endif +.endif +.endfor + +DISTRIBUTION?= doc + +.include <bsd.obj.mk> diff --git a/share/mk/bsd.dtrace.mk b/share/mk/bsd.dtrace.mk new file mode 100644 index 0000000..518de30f --- /dev/null +++ b/share/mk/bsd.dtrace.mk @@ -0,0 +1,60 @@ +# $FreeBSD$ +# +# Copyright (c) 2010 The FreeBSD Foundation +# All rights reserved. +# +# This software was developed by Rui Paulo under sponsorship from the +# FreeBSD Foundation. +# +# 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 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 AUTHOR 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. +# +# +# The only variable that you should define on your Makefile is 'DTRACEOBJS'. +# You must include this file before bsd.lib.mk or bsd.prog.mk. +# + +.if defined(WITH_DTRACE) + +CFLAGS+=-DWITH_DTRACE +DTRACEHEADERS=${DTRACEOBJS:S/o$/h/} +DTRACESRCS=${DTRACEOBJS:S/o$/d/} +CLEANFILES+=${DTRACEOBJS} ${DTRACEHEADERS} + +DPADD+=${LIBELF} +LDADD+=-lelf + +.if defined(PROG) +_DTRACELINKING=${OBJS} +OBJS+=${DTRACEOBJS} +.else +_DTRACELINKING=${SOBJS} +SOBJS+=${DTRACEOBJS} +.endif + +${DTRACEOBJS}: + +beforedepend: + ${DTRACE} -C -h -s ${DTRACESRCS} +beforelinking: + ${DTRACE} -G -s ${DTRACESRCS} ${_DTRACELINKING:S/${DTRACEOBJS}//} + +.endif diff --git a/share/mk/bsd.endian.mk b/share/mk/bsd.endian.mk new file mode 100644 index 0000000..12dcbc0 --- /dev/null +++ b/share/mk/bsd.endian.mk @@ -0,0 +1,17 @@ +# $FreeBSD$ + +.if ${MACHINE_ARCH} == "amd64" || \ + ${MACHINE_ARCH} == "i386" || \ + ${MACHINE_ARCH} == "ia64" || \ + ${MACHINE_ARCH} == "arm" || \ + ${MACHINE_ARCH} == "armv6" || \ + ${MACHINE_ARCH:Mmips*el} != "" +TARGET_ENDIANNESS= 1234 +.elif ${MACHINE_ARCH} == "powerpc" || \ + ${MACHINE_ARCH} == "powerpc64" || \ + ${MACHINE_ARCH} == "sparc64" || \ + ${MACHINE_ARCH} == "armeb" || \ + ${MACHINE_ARCH} == "armv6eb" || \ + ${MACHINE_ARCH:Mmips*} != "" +TARGET_ENDIANNESS= 4321 +.endif diff --git a/share/mk/bsd.files.mk b/share/mk/bsd.files.mk new file mode 100644 index 0000000..240f958 --- /dev/null +++ b/share/mk/bsd.files.mk @@ -0,0 +1,69 @@ +# $FreeBSD$ + +.if !target(__<bsd.init.mk>__) +.error bsd.files.mk cannot be included directly. +.endif + +FILESGROUPS?= FILES + +.if !target(buildfiles) +.for group in ${FILESGROUPS} +buildfiles: ${${group}} +.endfor +.endif + +all: buildfiles + +.if !target(installfiles) +.for group in ${FILESGROUPS} +.if defined(${group}) && !empty(${group}) + +${group}OWN?= ${SHAREOWN} +${group}GRP?= ${SHAREGRP} +${group}MODE?= ${SHAREMODE} +${group}DIR?= ${BINDIR} + +_${group}FILES= +.for file in ${${group}} +.if defined(${group}OWN_${file:T}) || defined(${group}GRP_${file:T}) || \ + defined(${group}MODE_${file:T}) || defined(${group}DIR_${file:T}) || \ + defined(${group}NAME_${file:T}) +${group}OWN_${file:T}?= ${${group}OWN} +${group}GRP_${file:T}?= ${${group}GRP} +${group}MODE_${file:T}?= ${${group}MODE} +${group}DIR_${file:T}?= ${${group}DIR} +.if defined(${group}NAME) +${group}NAME_${file:T}?= ${${group}NAME} +.else +${group}NAME_${file:T}?= ${file:T} +.endif +installfiles: _${group}INS_${file:T} +_${group}INS_${file:T}: ${file} + ${INSTALL} -o ${${group}OWN_${.ALLSRC:T}} \ + -g ${${group}GRP_${.ALLSRC:T}} -m ${${group}MODE_${.ALLSRC:T}} \ + ${.ALLSRC} \ + ${DESTDIR}${${group}DIR_${.ALLSRC:T}}/${${group}NAME_${.ALLSRC:T}} +.else +_${group}FILES+= ${file} +.endif +.endfor +.if !empty(_${group}FILES) +installfiles: _${group}INS +_${group}INS: ${_${group}FILES} +.if defined(${group}NAME) + ${INSTALL} -o ${${group}OWN} -g ${${group}GRP} \ + -m ${${group}MODE} ${.ALLSRC} \ + ${DESTDIR}${${group}DIR}/${${group}NAME} +.else + ${INSTALL} -o ${${group}OWN} -g ${${group}GRP} \ + -m ${${group}MODE} ${.ALLSRC} ${DESTDIR}${${group}DIR} +.endif +.endif + +.endif # defined(${group}) && !empty(${group}) +.endfor + +.endif # !target(installfiles) + +realinstall: installfiles +.ORDER: beforeinstall installfiles diff --git a/share/mk/bsd.incs.mk b/share/mk/bsd.incs.mk new file mode 100644 index 0000000..74c378b --- /dev/null +++ b/share/mk/bsd.incs.mk @@ -0,0 +1,84 @@ +# $FreeBSD$ + +.if !target(__<bsd.init.mk>__) +.error bsd.incs.mk cannot be included directly. +.endif + +.if !defined(NO_INCS) && ${MK_TOOLCHAIN} != "no" + +INCSGROUPS?= INCS + +.if !target(buildincludes) +.for group in ${INCSGROUPS} +buildincludes: ${${group}} +.endfor +.endif + +all: buildincludes + +.if !target(installincludes) +.for group in ${INCSGROUPS} +.if defined(${group}) && !empty(${group}) + +${group}OWN?= ${BINOWN} +${group}GRP?= ${BINGRP} +${group}MODE?= ${NOBINMODE} +${group}DIR?= ${INCLUDEDIR} + +_${group}INCS= +.for header in ${${group}} +.if defined(${group}OWN_${header:T}) || defined(${group}GRP_${header:T}) || \ + defined(${group}MODE_${header:T}) || defined(${group}DIR_${header:T}) || \ + defined(${group}NAME_${header:T}) +${group}OWN_${header:T}?= ${${group}OWN} +${group}GRP_${header:T}?= ${${group}GRP} +${group}MODE_${header:T}?= ${${group}MODE} +${group}DIR_${header:T}?= ${${group}DIR} +.if defined(${group}NAME) +${group}NAME_${header:T}?= ${${group}NAME} +.else +${group}NAME_${header:T}?= ${header:T} +.endif +installincludes: _${group}INS_${header:T} +_${group}INS_${header:T}: ${header} + ${INSTALL} -C -o ${${group}OWN_${.ALLSRC:T}} \ + -g ${${group}GRP_${.ALLSRC:T}} -m ${${group}MODE_${.ALLSRC:T}} \ + ${.ALLSRC} \ + ${DESTDIR}${${group}DIR_${.ALLSRC:T}}/${${group}NAME_${.ALLSRC:T}} +.else +_${group}INCS+= ${header} +.endif +.endfor +.if !empty(_${group}INCS) +installincludes: _${group}INS +_${group}INS: ${_${group}INCS} +.if defined(${group}NAME) + ${INSTALL} -C -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \ + ${.ALLSRC} ${DESTDIR}${${group}DIR}/${${group}NAME} +.else + ${INSTALL} -C -o ${${group}OWN} -g ${${group}GRP} -m ${${group}MODE} \ + ${.ALLSRC} ${DESTDIR}${${group}DIR} +.endif +.endif + +.endif # defined(${group}) && !empty(${group}) +.endfor + +.if defined(INCSLINKS) && !empty(INCSLINKS) +installincludes: + @set ${INCSLINKS}; \ + while test $$# -ge 2; do \ + l=$$1; \ + shift; \ + t=${DESTDIR}$$1; \ + shift; \ + ${ECHO} $$t -\> $$l; \ + ${INSTALL_SYMLINK} $$l $$t; \ + done; true +.endif +.endif # !target(installincludes) + +realinstall: installincludes +.ORDER: beforeinstall installincludes + +.endif # !defined(NO_INCS) && ${MK_TOOLCHAIN} != "no" diff --git a/share/mk/bsd.info.mk b/share/mk/bsd.info.mk new file mode 100644 index 0000000..c54b435 --- /dev/null +++ b/share/mk/bsd.info.mk @@ -0,0 +1,199 @@ +# $FreeBSD$ +# +# The include file <bsd.info.mk> handles installing GNU (tech)info files. +# Texinfo is a documentation system that uses a single source +# file to produce both on-line information and printed output. +# +# +# +++ variables +++ +# +# CLEANFILES Additional files to remove for the clean and cleandir targets. +# +# DESTDIR Change the tree where the info files gets installed. [not set] +# +# DVIPS A program which convert a TeX DVI file to PostScript [dvips] +# +# DVIPS2ASCII A program to convert a PostScript file which was prior +# converted from a TeX DVI file to ascii/latin1 [dvips2ascii] +# +# FORMATS Indicates which output formats will be generated +# (info, dvi, latin1, ps, html). [info] +# +# ICOMPRESS_CMD Program to compress info files. Output is to +# stdout. [${COMPRESS_CMD}] +# +# INFO texinfo files, without suffix. [set in Makefile] +# +# INFO2HTML A program for converting GNU info files into HTML files +# [info2html] +# +# INFODIR Base path for GNU's hypertext system +# called Info (see info(1)). [${SHAREDIR}/info] +# +# INFODIRFILE Top level node/index for info files. [dir] +# +# INFOGRP Info group. [${SHAREGRP}] +# +# INFOMODE Info mode. [${NOBINMODE}] +# +# INFOOWN Info owner. [${SHAREOWN}] +# +# INFOSECTION Default section (if one could not be found in +# the Info file). [Miscellaneous] +# +# INSTALLINFO A program for installing directory entries from Info +# file in the ${INFODIR}/${INFODIRFILE}. [install-info] +# +# INSTALLINFOFLAGS Options for ${INSTALLINFO} command. [--quiet] +# +# INSTALLINFODIRS ??? +# +# MAKEINFO A program for converting GNU Texinfo files into Info +# file. [makeinfo] +# +# MAKEINFOFLAGS Options for ${MAKEINFO} command. [--no-split] +# +# NO_INFOCOMPRESS If you do not want info files be +# compressed when they are installed. [not set] +# +# TEX A program for converting tex files into dvi files [tex] +# +# +# +++ targets +++ +# +# install: +# Install the info files. +# +# +# bsd.obj.mk: cleandir and obj + +.include <bsd.init.mk> + +MAKEINFO?= makeinfo +MAKEINFOFLAGS+= --no-split # simplify some things, e.g., compression +SRCDIR?= ${.CURDIR} +INFODIRFILE?= dir +INSTALLINFO?= install-info +INSTALLINFOFLAGS+=--quiet +INFOSECTION?= Miscellaneous +ICOMPRESS_CMD?= ${COMPRESS_CMD} +ICOMPRESS_EXT?= ${COMPRESS_EXT} +FORMATS?= info +INFO2HTML?= info2html +TEX?= tex +DVIPS?= dvips +DVIPS2ASCII?= dvips2ascii + +.SUFFIXES: ${ICOMPRESS_EXT} .info .texi .texinfo .dvi .ps .latin1 .html + +.texi.info .texinfo.info: + ${MAKEINFO} ${MAKEINFOFLAGS} -I ${.CURDIR} -I ${SRCDIR} ${.IMPSRC} \ + -o ${.TARGET} + +.texi.dvi .texinfo.dvi: + TEXINPUTS=${.CURDIR}:${SRCDIR}:$$TEXINPUTS \ + ${TEX} ${.IMPSRC} </dev/null +# Run again to resolve cross references. + TEXINPUTS=${.CURDIR}:${SRCDIR}:$$TEXINPUTS \ + ${TEX} ${.IMPSRC} </dev/null + +.texinfo.latin1 .texi.latin1: + perl -npe 's/(^\s*\\input\s+texinfo\s+)/$$1\n@tex\n\\global\\hsize=120mm\n@end tex\n\n/' ${.IMPSRC} >> ${.IMPSRC:T:R}-la.texi + TEXINPUTS=${.CURDIR}:${SRCDIR}:$$TEXINPUTS \ + ${TEX} ${.IMPSRC:T:R}-la.texi </dev/null +# Run again to resolve cross references. + TEXINPUTS=${.CURDIR}:${SRCDIR}:$$TEXINPUTS \ + ${TEX} ${.IMPSRC:T:R}-la.texi </dev/null + ${DVIPS} -o /dev/stdout ${.IMPSRC:T:R}-la.dvi | \ + ${DVIPS2ASCII} > ${.TARGET}.new + mv -f ${.TARGET}.new ${.TARGET} + +.dvi.ps: + ${DVIPS} -o ${.TARGET} ${.IMPSRC} + +.info.html: + ${INFO2HTML} ${.IMPSRC} + ${INSTALL_LINK} ${.TARGET:R}.info.Top.html ${.TARGET} + +.PATH: ${.CURDIR} ${SRCDIR} + +.for _f in ${FORMATS} +IFILENS+= ${INFO:S/$/.${_f}/} +.endfor + +.if ${MK_INFO} != "no" +CLEANFILES+= ${IFILENS} +.if !defined(NO_INFOCOMPRESS) +CLEANFILES+= ${IFILENS:S/$/${ICOMPRESS_EXT}/} +IFILES= ${IFILENS:S/$/${ICOMPRESS_EXT}/:S/.html${ICOMPRESS_EXT}/.html/} +all: ${IFILES} +.else +IFILES= ${IFILENS} +all: ${IFILES} +.endif +.else +all: +.endif + +.for x in ${IFILENS} +${x:S/$/${ICOMPRESS_EXT}/}: ${x} + ${ICOMPRESS_CMD} ${.ALLSRC} > ${.TARGET} +.endfor + +.for x in ${INFO} +INSTALLINFODIRS+= ${x:S/$/-install/} +${x:S/$/-install/}: +.if !empty(.MAKEFLAGS:M-j) + lockf -k ${DESTDIR}${INFODIR}/${INFODIRFILE} \ + ${INSTALLINFO} ${INSTALLINFOFLAGS} \ + --defsection=${INFOSECTION} \ + --defentry=${INFOENTRY_${x}} \ + ${x}.info ${DESTDIR}${INFODIR}/${INFODIRFILE} +.else + ${INSTALLINFO} ${INSTALLINFOFLAGS} \ + --defsection=${INFOSECTION} \ + --defentry=${INFOENTRY_${x}} \ + ${x}.info ${DESTDIR}${INFODIR}/${INFODIRFILE} +.endif +.endfor + +.PHONY: ${INSTALLINFODIRS} + +.if defined(SRCS) +CLEANFILES+= ${INFO}.texi +${INFO}.texi: ${SRCS} + cat ${.ALLSRC} > ${.TARGET} +.endif + +# tex garbage +.if !empty(FORMATS:Mps) || !empty(FORMATS:Mdvi) || !empty(FORMATS:Mlatin1) +.for _f in aux cp fn ky log out pg toc tp vr dvi +CLEANFILES+= ${INFO:S/$/.${_f}/} ${INFO:S/$/-la.${_f}/} +.endfor +CLEANFILES+= ${INFO:S/$/-la.texi/} +.endif + +.if !empty(FORMATS:Mhtml) +CLEANFILES+= ${INFO:S/$/.info.*.html/} ${INFO:S/$/.info/} +.endif + +.if ${MK_INFO} != "no" && defined(INFO) +install: ${INSTALLINFODIRS} +.if !empty(IFILES:N*.html) + ${INSTALL} -o ${INFOOWN} -g ${INFOGRP} -m ${INFOMODE} \ + ${IFILES:N*.html} ${DESTDIR}${INFODIR} +.endif +.if !empty(FORMATS:Mhtml) + ${INSTALL} -o ${INFOOWN} -g ${INFOGRP} -m ${INFOMODE} \ + ${INFO:S/$/.info.*.html/} ${DESTDIR}${INFODIR} +.endif +.else +# The indirection in the following is to avoid the null install rule +# "install:" from being overridden by the implicit .sh rule if there +# happens to be a source file named install.sh. This assumes that there +# is no source file named __null_install.sh. +install: __null_install +__null_install: +.endif + +.include <bsd.obj.mk> diff --git a/share/mk/bsd.init.mk b/share/mk/bsd.init.mk new file mode 100644 index 0000000..f5f4c66 --- /dev/null +++ b/share/mk/bsd.init.mk @@ -0,0 +1,14 @@ +# $FreeBSD$ + +# The include file <bsd.init.mk> includes ../Makefile.inc and +# <bsd.own.mk>; this is used at the top of all <bsd.*.mk> files +# that actually "build something". + +.if !target(__<bsd.init.mk>__) +__<bsd.init.mk>__: +.if exists(${.CURDIR}/../Makefile.inc) +.include "${.CURDIR}/../Makefile.inc" +.endif +.include <bsd.own.mk> +.MAIN: all +.endif # !target(__<bsd.init.mk>__) diff --git a/share/mk/bsd.kmod.mk b/share/mk/bsd.kmod.mk new file mode 100644 index 0000000..fd4f993 --- /dev/null +++ b/share/mk/bsd.kmod.mk @@ -0,0 +1,17 @@ +# $FreeBSD$ + +# Search for kernel source tree in standard places. +.for _dir in ${.CURDIR}/../.. ${.CURDIR}/../../.. ${.CURDIR}/../../../.. \ + ${.CURDIR}/../../../../.. /sys /usr/src/sys +.if !defined(SYSDIR) && exists(${_dir}/kern/) && exists(${_dir}/conf/kmod.mk) +SYSDIR= ${_dir} +.endif +.endfor +.if !defined(SYSDIR) || !exists(${SYSDIR}/kern/) || \ + !exists(${SYSDIR}/conf/kmod.mk) +.error Unable to locate the kernel source tree. Set SYSDIR to override. +.endif + +.include "${SYSDIR}/conf/kmod.mk" + +.include <bsd.sys.mk> diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk new file mode 100644 index 0000000..66d0a29 --- /dev/null +++ b/share/mk/bsd.lib.mk @@ -0,0 +1,446 @@ +# from: @(#)bsd.lib.mk 5.26 (Berkeley) 5/2/91 +# $FreeBSD$ +# + +.include <bsd.init.mk> + +# Set up the variables controlling shared libraries. After this section, +# SHLIB_NAME will be defined only if we are to create a shared library. +# SHLIB_LINK will be defined only if we are to create a link to it. +# INSTALL_PIC_ARCHIVE will be defined only if we are to create a PIC archive. +.if defined(NO_PIC) +.undef SHLIB_NAME +.undef INSTALL_PIC_ARCHIVE +.else +.if !defined(SHLIB) && defined(LIB) +SHLIB= ${LIB} +.endif +.if !defined(SHLIB_NAME) && defined(SHLIB) && defined(SHLIB_MAJOR) +SHLIB_NAME= lib${SHLIB}.so.${SHLIB_MAJOR} +.endif +.if defined(SHLIB_NAME) && !empty(SHLIB_NAME:M*.so.*) +SHLIB_LINK?= ${SHLIB_NAME:R} +.endif +SONAME?= ${SHLIB_NAME} +.endif + +.if defined(CRUNCH_CFLAGS) +CFLAGS+= ${CRUNCH_CFLAGS} +.endif + +.if ${MK_ASSERT_DEBUG} == "no" +CFLAGS+= -DNDEBUG +NO_WERROR= +.endif + +.if defined(DEBUG_FLAGS) +CFLAGS+= ${DEBUG_FLAGS} + +.if ${MK_CTF} != "no" && ${DEBUG_FLAGS:M-g} != "" +CTFFLAGS+= -g +.endif +.else +STRIP?= -s +.endif + +.if ${MK_DEBUG_FILES} != "no" && empty(DEBUG_FLAGS:M-g) && \ + empty(DEBUG_FLAGS:M-gdwarf*) +CFLAGS+= -g +CTFFLAGS+= -g +.endif + +.include <bsd.libnames.mk> + +# prefer .s to a .c, add .po, remove stuff not used in the BSD libraries +# .So used for PIC object files +.SUFFIXES: +.SUFFIXES: .out .o .po .So .S .asm .s .c .cc .cpp .cxx .C .f .y .l .ln + +.if !defined(PICFLAG) +.if ${MACHINE_CPUARCH} == "sparc64" +PICFLAG=-fPIC +.else +PICFLAG=-fpic +.endif +.endif + +PO_FLAG=-pg + +.c.o: + ${CC} ${STATIC_CFLAGS} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} + ${CTFCONVERT_CMD} + +.c.po: + ${CC} ${PO_FLAG} ${STATIC_CFLAGS} ${PO_CFLAGS} -c ${.IMPSRC} -o ${.TARGET} + ${CTFCONVERT_CMD} + +.c.So: + ${CC} ${PICFLAG} -DPIC ${SHARED_CFLAGS} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} + ${CTFCONVERT_CMD} + +.cc.o .C.o .cpp.o .cxx.o: + ${CXX} ${STATIC_CXXFLAGS} ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET} + +.cc.po .C.po .cpp.po .cxx.po: + ${CXX} ${PO_FLAG} ${STATIC_CXXFLAGS} ${PO_CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET} + +.cc.So .C.So .cpp.So .cxx.So: + ${CXX} ${PICFLAG} -DPIC ${SHARED_CXXFLAGS} ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET} + +.f.po: + ${FC} -pg ${FFLAGS} -o ${.TARGET} -c ${.IMPSRC} + ${CTFCONVERT_CMD} + +.f.So: + ${FC} ${PICFLAG} -DPIC ${FFLAGS} -o ${.TARGET} -c ${.IMPSRC} + ${CTFCONVERT_CMD} + +.s.po .s.So: + ${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC} + ${CTFCONVERT_CMD} + +.asm.po: + ${CC} -x assembler-with-cpp -DPROF ${PO_CFLAGS} ${ACFLAGS} \ + -c ${.IMPSRC} -o ${.TARGET} + ${CTFCONVERT_CMD} + +.asm.So: + ${CC} -x assembler-with-cpp ${PICFLAG} -DPIC ${CFLAGS} ${ACFLAGS} \ + -c ${.IMPSRC} -o ${.TARGET} + ${CTFCONVERT_CMD} + +.S.po: + ${CC} -DPROF ${PO_CFLAGS} ${ACFLAGS} -c ${.IMPSRC} -o ${.TARGET} + ${CTFCONVERT_CMD} + +.S.So: + ${CC} ${PICFLAG} -DPIC ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} -o ${.TARGET} + ${CTFCONVERT_CMD} + +all: objwarn + +.if defined(SHLIB_NAME) +.if ${MK_DEBUG_FILES} != "no" +SHLIB_NAME_FULL=${SHLIB_NAME}.full +# Use ${DEBUGDIR} for base system debug files, else .debug subdirectory +.if ${SHLIBDIR} == "/boot" ||\ + ${SHLIBDIR:C%/lib(/.*)?$%/lib%} == "/lib" ||\ + ${SHLIBDIR:C%/usr/lib(32)?(/.*)?%/usr/lib%} == "/usr/lib" +DEBUGFILEDIR=${DEBUGDIR}${SHLIBDIR} +.else +DEBUGFILEDIR=${SHLIBDIR}/.debug +DEBUGMKDIR= +.endif +.else +SHLIB_NAME_FULL=${SHLIB_NAME} +.endif +.endif + +.include <bsd.symver.mk> + +# Allow libraries to specify their own version map or have it +# automatically generated (see bsd.symver.mk above). +.if ${MK_SYMVER} == "yes" && !empty(VERSION_MAP) +${SHLIB_NAME_FULL}: ${VERSION_MAP} +LDFLAGS+= -Wl,--version-script=${VERSION_MAP} +.endif + +.if defined(LIB) && !empty(LIB) || defined(SHLIB_NAME) +OBJS+= ${SRCS:N*.h:R:S/$/.o/} +.endif + +.if defined(LIB) && !empty(LIB) +_LIBS= lib${LIB}.a + +lib${LIB}.a: ${OBJS} ${STATICOBJS} + @${ECHO} building static ${LIB} library + @rm -f ${.TARGET} +.if !defined(NM) + @${AR} ${ARFLAGS} ${.TARGET} `lorder ${OBJS} ${STATICOBJS} | tsort -q` ${ARADD} +.else + @${AR} ${ARFLAGS} ${.TARGET} `NM='${NM}' lorder ${OBJS} ${STATICOBJS} | tsort -q` ${ARADD} +.endif + ${RANLIB} ${.TARGET} +.endif + +.if !defined(INTERNALLIB) + +.if ${MK_PROFILE} != "no" && defined(LIB) && !empty(LIB) +_LIBS+= lib${LIB}_p.a +POBJS+= ${OBJS:.o=.po} ${STATICOBJS:.o=.po} + +lib${LIB}_p.a: ${POBJS} + @${ECHO} building profiled ${LIB} library + @rm -f ${.TARGET} +.if !defined(NM) + @${AR} ${ARFLAGS} ${.TARGET} `lorder ${POBJS} | tsort -q` ${ARADD} +.else + @${AR} ${ARFLAGS} ${.TARGET} `NM='${NM}' lorder ${POBJS} | tsort -q` ${ARADD} +.endif + ${RANLIB} ${.TARGET} +.endif + +.if defined(SHLIB_NAME) || \ + defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) +SOBJS+= ${OBJS:.o=.So} +.endif + +.if defined(SHLIB_NAME) +_LIBS+= ${SHLIB_NAME} + +SOLINKOPTS= -shared -Wl,-x +.if !defined(ALLOW_SHARED_TEXTREL) +SOLINKOPTS+= -Wl,--fatal-warnings -Wl,--warn-shared-textrel +.endif + +.if target(beforelinking) +beforelinking: ${SOBJS} +${SHLIB_NAME_FULL}: beforelinking +.endif +${SHLIB_NAME_FULL}: ${SOBJS} + @${ECHO} building shared library ${SHLIB_NAME} + @rm -f ${SHLIB_NAME} ${SHLIB_LINK} +.if defined(SHLIB_LINK) + @${INSTALL_SYMLINK} ${SHLIB_NAME} ${SHLIB_LINK} +.endif +.if !defined(NM) + @${CC} ${LDFLAGS} ${SSP_CFLAGS} ${SOLINKOPTS} \ + -o ${.TARGET} -Wl,-soname,${SONAME} \ + `lorder ${SOBJS} | tsort -q` ${LDADD} +.else + @${CC} ${LDFLAGS} ${SSP_CFLAGS} ${SOLINKOPTS} \ + -o ${.TARGET} -Wl,-soname,${SONAME} \ + `NM='${NM}' lorder ${SOBJS} | tsort -q` ${LDADD} +.endif +.if ${MK_CTF} != "no" + ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SOBJS} +.endif + +.if ${MK_DEBUG_FILES} != "no" +CLEANFILES+= ${SHLIB_NAME_FULL} ${SHLIB_NAME}.debug +${SHLIB_NAME}: ${SHLIB_NAME_FULL} ${SHLIB_NAME}.debug + ${OBJCOPY} --strip-debug --add-gnu-debuglink=${SHLIB_NAME}.debug \ + ${SHLIB_NAME_FULL} ${.TARGET} + +${SHLIB_NAME}.debug: ${SHLIB_NAME_FULL} + ${OBJCOPY} --only-keep-debug ${SHLIB_NAME_FULL} ${.TARGET} +.endif +.endif #defined(SHLIB_NAME) + +.if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) && ${MK_TOOLCHAIN} != "no" +_LIBS+= lib${LIB}_pic.a + +lib${LIB}_pic.a: ${SOBJS} + @${ECHO} building special pic ${LIB} library + @rm -f ${.TARGET} + @${AR} ${ARFLAGS} ${.TARGET} ${SOBJS} ${ARADD} + ${RANLIB} ${.TARGET} +.endif + +.if defined(WANT_LINT) && !defined(NO_LINT) && defined(LIB) && !empty(LIB) +LINTLIB= llib-l${LIB}.ln +_LIBS+= ${LINTLIB} +LINTOBJS+= ${SRCS:M*.c:.c=.ln} + +${LINTLIB}: ${LINTOBJS} + @${ECHO} building lint library ${.TARGET} + @rm -f ${.TARGET} + ${LINT} ${LINTLIBFLAGS} ${CFLAGS:M-[DIU]*} ${.ALLSRC} +.endif + +.endif # !defined(INTERNALLIB) + +all: ${_LIBS} + +.if ${MK_MAN} != "no" +all: _manpages +.endif + +_EXTRADEPEND: + @TMP=_depend$$$$; \ + sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.So:/' < ${DEPENDFILE} \ + > $$TMP; \ + mv $$TMP ${DEPENDFILE} +.if !defined(NO_EXTRADEPEND) && defined(SHLIB_NAME) +.if defined(DPADD) && !empty(DPADD) + echo ${SHLIB_NAME}: ${DPADD} >> ${DEPENDFILE} +.endif +.endif + +.if !target(install) + +.if defined(PRECIOUSLIB) +.if !defined(NO_FSCHG) +SHLINSTALLFLAGS+= -fschg +.endif +SHLINSTALLFLAGS+= -S +.endif + +_INSTALLFLAGS:= ${INSTALLFLAGS} +.for ie in ${INSTALLFLAGS_EDIT} +_INSTALLFLAGS:= ${_INSTALLFLAGS${ie}} +.endfor +_SHLINSTALLFLAGS:= ${SHLINSTALLFLAGS} +.for ie in ${INSTALLFLAGS_EDIT} +_SHLINSTALLFLAGS:= ${_SHLINSTALLFLAGS${ie}} +.endfor + +.if !defined(INTERNALLIB) +realinstall: _libinstall +.ORDER: beforeinstall _libinstall +_libinstall: +.if defined(LIB) && !empty(LIB) && ${MK_INSTALLLIB} != "no" + ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + ${_INSTALLFLAGS} lib${LIB}.a ${DESTDIR}${LIBDIR} +.endif +.if ${MK_PROFILE} != "no" && defined(LIB) && !empty(LIB) + ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + ${_INSTALLFLAGS} lib${LIB}_p.a ${DESTDIR}${LIBDIR} +.endif +.if defined(SHLIB_NAME) + ${INSTALL} ${STRIP} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + ${_INSTALLFLAGS} ${_SHLINSTALLFLAGS} \ + ${SHLIB_NAME} ${DESTDIR}${SHLIBDIR} +.if ${MK_DEBUG_FILES} != "no" +.if defined(DEBUGMKDIR) + ${INSTALL} -T debug -d ${DESTDIR}${DEBUGFILEDIR} +.endif + ${INSTALL} -T debug -o ${LIBOWN} -g ${LIBGRP} -m ${DEBUGMODE} \ + ${_INSTALLFLAGS} \ + ${SHLIB_NAME}.debug ${DESTDIR}${DEBUGFILEDIR} +.endif +.if defined(SHLIB_LINK) +# ${_SHLIBDIRPREFIX} and ${_LDSCRIPTROOT} are both needed when cross-building +# and when building 32 bits library shims. ${_SHLIBDIRPREFIX} is the directory +# prefix where shared objects will be installed by the install target. +# +# ${_LDSCRIPTROOT} is the directory prefix that will be used when generating +# ld(1) scripts. The crosstools' ld is configured to lookup libraries in an +# alternative directory which is called "sysroot", so during buildworld binaries +# won't be linked against the running system libraries but against the ones of +# the current source tree. ${_LDSCRIPTROOT} behavior is twisted because of +# the location where we store them: +# - 64 bits libs are located under sysroot, so ${_LDSCRIPTROOT} must be empty +# because ld(1) will manage to find them from sysroot; +# - 32 bits shims are not, so ${_LDSCRIPTROOT} is used to specify their full +# path, outside of sysroot. +# Note that ld(1) scripts are generated both during buildworld and +# installworld; in the later case ${_LDSCRIPTROOT} must be obviously empty +# because on the target system, libraries are meant to be looked up from /. +.if defined(SHLIB_LDSCRIPT) && !empty(SHLIB_LDSCRIPT) && exists(${.CURDIR}/${SHLIB_LDSCRIPT}) + sed -e 's,@@SHLIB@@,${_LDSCRIPTROOT}${SHLIBDIR}/${SHLIB_NAME},g' \ + -e 's,@@LIBDIR@@,${_LDSCRIPTROOT}${LIBDIR},g' \ + ${.CURDIR}/${SHLIB_LDSCRIPT} > ${DESTDIR}${LIBDIR}/${SHLIB_LINK:R}.ld + ${INSTALL} -S -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + ${_INSTALLFLAGS} ${DESTDIR}${LIBDIR}/${SHLIB_LINK:R}.ld \ + ${DESTDIR}${LIBDIR}/${SHLIB_LINK} + rm -f ${DESTDIR}${LIBDIR}/${SHLIB_LINK:R}.ld + +.else +.if ${SHLIBDIR} == ${LIBDIR} + ${INSTALL_SYMLINK} ${SHLIB_NAME} ${DESTDIR}${LIBDIR}/${SHLIB_LINK} +.else + ${INSTALL_SYMLINK} ${_SHLIBDIRPREFIX}${SHLIBDIR}/${SHLIB_NAME} \ + ${DESTDIR}${LIBDIR}/${SHLIB_LINK} +.if exists(${DESTDIR}${LIBDIR}/${SHLIB_NAME}) + -chflags noschg ${DESTDIR}${LIBDIR}/${SHLIB_NAME} + rm -f ${DESTDIR}${LIBDIR}/${SHLIB_NAME} +.endif +.endif +.endif # SHLIB_LDSCRIPT +.endif # SHLIB_LINK +.endif # SHIB_NAME +.if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) && ${MK_TOOLCHAIN} != "no" + ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + ${_INSTALLFLAGS} lib${LIB}_pic.a ${DESTDIR}${LIBDIR} +.endif +.if defined(WANT_LINT) && !defined(NO_LINT) && defined(LIB) && !empty(LIB) + ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + ${_INSTALLFLAGS} ${LINTLIB} ${DESTDIR}${LINTLIBDIR} +.endif +.endif # !defined(INTERNALLIB) + +.if !defined(LIBRARIES_ONLY) +.include <bsd.nls.mk> +.include <bsd.files.mk> +.include <bsd.incs.mk> +.endif + +.include <bsd.links.mk> + +.if ${MK_MAN} != "no" && !defined(LIBRARIES_ONLY) +realinstall: _maninstall +.ORDER: beforeinstall _maninstall +.endif + +.endif + +.if !target(lint) +lint: ${SRCS:M*.c} + ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.ALLSRC} +.endif + +.if ${MK_MAN} != "no" && !defined(LIBRARIES_ONLY) +.include <bsd.man.mk> +.endif + +.include <bsd.dep.mk> + +.if !exists(${.OBJDIR}/${DEPENDFILE}) +.if defined(LIB) && !empty(LIB) +${OBJS} ${STATICOBJS} ${POBJS}: ${SRCS:M*.h} +.for _S in ${SRCS:N*.[hly]} +${_S:R}.po: ${_S} +.endfor +.endif +.if defined(SHLIB_NAME) || \ + defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) +${SOBJS}: ${SRCS:M*.h} +.for _S in ${SRCS:N*.[hly]} +${_S:R}.So: ${_S} +.endfor +.endif +.endif + +.if !target(clean) +clean: +.if defined(CLEANFILES) && !empty(CLEANFILES) + rm -f ${CLEANFILES} +.endif +.if defined(LIB) && !empty(LIB) + rm -f a.out ${OBJS} ${OBJS:S/$/.tmp/} ${STATICOBJS} +.endif +.if !defined(INTERNALLIB) +.if ${MK_PROFILE} != "no" && defined(LIB) && !empty(LIB) + rm -f ${POBJS} ${POBJS:S/$/.tmp/} +.endif +.if defined(SHLIB_NAME) || \ + defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) + rm -f ${SOBJS} ${SOBJS:.So=.so} ${SOBJS:S/$/.tmp/} +.endif +.if defined(SHLIB_NAME) +.if defined(SHLIB_LINK) +.if defined(SHLIB_LDSCRIPT) && exists(${.CURDIR}/${SHLIB_LDSCRIPT}) + rm -f lib${LIB}.ld +.endif + rm -f ${SHLIB_LINK} +.endif +.endif # defined(SHLIB_NAME) +.if defined(WANT_LINT) && defined(LIB) && !empty(LIB) + rm -f ${LINTOBJS} +.endif +.endif # !defined(INTERNALLIB) +.if defined(_LIBS) && !empty(_LIBS) + rm -f ${_LIBS} +.endif +.if defined(CLEANDIRS) && !empty(CLEANDIRS) + rm -rf ${CLEANDIRS} +.endif +.if !empty(VERSION_DEF) && !empty(SYMBOL_MAPS) + rm -f ${VERSION_MAP} +.endif +.endif + +.include <bsd.obj.mk> + +.include <bsd.sys.mk> diff --git a/share/mk/bsd.libnames.mk b/share/mk/bsd.libnames.mk new file mode 100644 index 0000000..e11ac81 --- /dev/null +++ b/share/mk/bsd.libnames.mk @@ -0,0 +1,178 @@ +# $FreeBSD$ + +# The include file <bsd.libnames.mk> define library names. +# Other include files (e.g. bsd.prog.mk, bsd.lib.mk) include this +# file where necessary. + +.if !target(__<bsd.init.mk>__) +.error bsd.libnames.mk cannot be included directly. +.endif + +LIBCRT0?= ${DESTDIR}${LIBDIR}/crt0.o + +LIBALIAS?= ${DESTDIR}${LIBDIR}/libalias.a +LIBARCHIVE?= ${DESTDIR}${LIBDIR}/libarchive.a +LIBASN1?= ${DESTDIR}${LIBDIR}/libasn1.a +LIBATF_C?= ${DESTDIR}${LIBDIR}/libatf-c.a +LIBATF_CXX?= ${DESTDIR}${LIBDIR}/libatf-c++.a +LIBATM?= ${DESTDIR}${LIBDIR}/libatm.a +LIBAUDITD?= ${DESTDIR}${LIBDIR}/libauditd.a +LIBAVL?= ${DESTDIR}${LIBDIR}/libavl.a +LIBBEGEMOT?= ${DESTDIR}${LIBDIR}/libbegemot.a +.if ${MK_BIND_LIBS} != "no" +LIBBIND?= ${DESTDIR}${LIBDIR}/libbind.a +LIBBIND9?= ${DESTDIR}${LIBDIR}/libbind9.a +.endif +LIBBLUETOOTH?= ${DESTDIR}${LIBDIR}/libbluetooth.a +LIBBSDXML?= ${DESTDIR}${LIBDIR}/libbsdxml.a +LIBBSDYML?= ${DESTDIR}${LIBDIR}/libbsdyml.a +LIBBSM?= ${DESTDIR}${LIBDIR}/libbsm.a +LIBBSNMP?= ${DESTDIR}${LIBDIR}/libbsnmp.a +LIBBZ2?= ${DESTDIR}${LIBDIR}/libbz2.a +.if ${MK_LIBCPLUSPLUS} != "no" +LIBCXXRT?= ${DESTDIR}${LIBDIR}/libcxxrt.a +LIBCPLUSPLUS?= ${DESTDIR}${LIBDIR}/libc++.a +.endif +LIBC?= ${DESTDIR}${LIBDIR}/libc.a +LIBC_PIC?= ${DESTDIR}${LIBDIR}/libc_pic.a +LIBCALENDAR?= ${DESTDIR}${LIBDIR}/libcalendar.a +LIBCAM?= ${DESTDIR}${LIBDIR}/libcam.a +LIBCOM_ERR?= ${DESTDIR}${LIBDIR}/libcom_err.a +LIBCOMPAT?= ${DESTDIR}${LIBDIR}/libcompat.a +LIBCRYPT?= ${DESTDIR}${LIBDIR}/libcrypt.a +LIBCRYPTO?= ${DESTDIR}${LIBDIR}/libcrypto.a +LIBCTF?= ${DESTDIR}${LIBDIR}/libctf.a +LIBCURSES?= ${DESTDIR}${LIBDIR}/libcurses.a +LIBDEVINFO?= ${DESTDIR}${LIBDIR}/libdevinfo.a +LIBDEVSTAT?= ${DESTDIR}${LIBDIR}/libdevstat.a +LIBDIALOG?= ${DESTDIR}${LIBDIR}/libdialog.a +LIBDNS?= ${DESTDIR}${LIBDIR}/libdns.a +LIBDTRACE?= ${DESTDIR}${LIBDIR}/libdtrace.a +LIBDWARF?= ${DESTDIR}${LIBDIR}/libdwarf.a +LIBEDIT?= ${DESTDIR}${LIBDIR}/libedit.a +LIBELF?= ${DESTDIR}${LIBDIR}/libelf.a +LIBFETCH?= ${DESTDIR}${LIBDIR}/libfetch.a +LIBFL?= "don't use LIBFL, use LIBL" +LIBFORM?= ${DESTDIR}${LIBDIR}/libform.a +LIBG2C?= ${DESTDIR}${LIBDIR}/libg2c.a +LIBGCC?= ${DESTDIR}${LIBDIR}/libgcc.a +LIBGCC_PIC?= ${DESTDIR}${LIBDIR}/libgcc_pic.a +LIBGEOM?= ${DESTDIR}${LIBDIR}/libgeom.a +LIBGNUREGEX?= ${DESTDIR}${LIBDIR}/libgnuregex.a +LIBGSSAPI?= ${DESTDIR}${LIBDIR}/libgssapi.a +LIBGSSAPI_KRB5?= ${DESTDIR}${LIBDIR}/libgssapi_krb5.a +LIBHDB?= ${DESTDIR}${LIBDIR}/libhdb.a +LIBHISTORY?= ${DESTDIR}${LIBDIR}/libhistory.a +LIBHEIMBASE?= ${DESTDIR}${LIBDIR}/libheimbase.a +LIBHEIMNTLM?= ${DESTDIR}${LIBDIR}/libheimntlm.a +LIBHEIMSQLITE?= ${DESTDIR}${LIBDIR}/libheimsqlite.a +LIBHX509?= ${DESTDIR}${LIBDIR}/libhx509.a +LIBIPSEC?= ${DESTDIR}${LIBDIR}/libipsec.a +.if ${MK_IPX} != "no" +LIBIPX?= ${DESTDIR}${LIBDIR}/libipx.a +.endif +.if ${MK_BIND_LIBS} != "no" +LIBISC?= ${DESTDIR}${LIBDIR}/libisc.a +LIBISCCC?= ${DESTDIR}${LIBDIR}/libisccc.a +LIBISCCFG?= ${DESTDIR}${LIBDIR}/libisccfg.a +.endif +LIBJAIL?= ${DESTDIR}${LIBDIR}/libjail.a +LIBKADM5CLNT?= ${DESTDIR}${LIBDIR}/libkadm5clnt.a +LIBKADM5SRV?= ${DESTDIR}${LIBDIR}/libkadm5srv.a +LIBKAFS5?= ${DESTDIR}${LIBDIR}/libkafs5.a +LIBKDC?= ${DESTDIR}${LIBDIR}/libkdc.a +LIBKEYCAP?= ${DESTDIR}${LIBDIR}/libkeycap.a +LIBKICONV?= ${DESTDIR}${LIBDIR}/libkiconv.a +LIBKRB5?= ${DESTDIR}${LIBDIR}/libkrb5.a +LIBKVM?= ${DESTDIR}${LIBDIR}/libkvm.a +LIBL?= ${DESTDIR}${LIBDIR}/libl.a +.if ${MK_LDNS} != "no" +LIBLDNS?= ${DESTDIR}${LIBDIR}/libldns.a +.endif +LIBLN?= "don't use LIBLN, use LIBL" +.if ${MK_BIND} != "no" +LIBLWRES?= ${DESTDIR}${LIBDIR}/liblwres.a +.endif +LIBLZMA?= ${DESTDIR}${LIBDIR}/liblzma.a +LIBM?= ${DESTDIR}${LIBDIR}/libm.a +LIBMAGIC?= ${DESTDIR}${LIBDIR}/libmagic.a +LIBMD?= ${DESTDIR}${LIBDIR}/libmd.a +LIBMEMSTAT?= ${DESTDIR}${LIBDIR}/libmemstat.a +LIBMENU?= ${DESTDIR}${LIBDIR}/libmenu.a +.if ${MK_SENDMAIL} != "no" +LIBMILTER?= ${DESTDIR}${LIBDIR}/libmilter.a +.endif +LIBMP?= ${DESTDIR}${LIBDIR}/libmp.a +LIBNCURSES?= ${DESTDIR}${LIBDIR}/libncurses.a +LIBNCURSESW?= ${DESTDIR}${LIBDIR}/libncursesw.a +LIBNETGRAPH?= ${DESTDIR}${LIBDIR}/libnetgraph.a +LIBNGATM?= ${DESTDIR}${LIBDIR}/libngatm.a +LIBNVPAIR?= ${DESTDIR}${LIBDIR}/libnvpair.a +LIBOPIE?= ${DESTDIR}${LIBDIR}/libopie.a + +# The static PAM library doesn't know its secondary dependencies, +# so we have to specify them explicitly. +LIBPAM?= ${DESTDIR}${LIBDIR}/libpam.a +MINUSLPAM= -lpam +.if defined(LDFLAGS) && !empty(LDFLAGS:M-static) +.if ${MK_KERBEROS} != "no" +LIBPAM+= ${LIBKRB5} ${LIBHX509} ${LIBASN1} ${LIBCRYPTO} ${LIBCRYPT} \ + ${LIBROKEN} ${LIBCOM_ERR} +MINUSLPAM+= -lkrb5 -lhx509 -lasn1 -lcrypto -lcrypt -lroken -lcom_err +.endif +LIBPAM+= ${LIBRADIUS} ${LIBTACPLUS} ${LIBCRYPT} \ + ${LIBUTIL} ${LIBOPIE} ${LIBMD} +MINUSLPAM+= -lradius -ltacplus -lcrypt \ + -lutil -lopie -lmd +.if ${MK_OPENSSH} != "no" +LIBPAM+= ${LIBSSH} ${LIBCRYPTO} ${LIBCRYPT} +MINUSLPAM+= -lssh -lcrypto -lcrypt +.endif +.if ${MK_NIS} != "no" +LIBPAM+= ${LIBYPCLNT} +MINUSLPAM+= -lypclnt +.endif +.endif + +LIBPANEL?= ${DESTDIR}${LIBDIR}/libpanel.a +LIBPCAP?= ${DESTDIR}${LIBDIR}/libpcap.a +LIBPMC?= ${DESTDIR}${LIBDIR}/libpmc.a +LIBPROC?= ${DESTDIR}${LIBDIR}/libproc.a +LIBPROCSTAT?= ${DESTDIR}${LIBDIR}/libprocstat.a +LIBPTHREAD?= ${DESTDIR}${LIBDIR}/libpthread.a +LIBRADIUS?= ${DESTDIR}${LIBDIR}/libradius.a +LIBREADLINE?= ${DESTDIR}${LIBDIR}/libreadline.a +LIBROKEN?= ${DESTDIR}${LIBDIR}/libroken.a +LIBRPCSVC?= ${DESTDIR}${LIBDIR}/librpcsvc.a +LIBRPCSEC_GSS?= ${DESTDIR}${LIBDIR}/librpcsec_gss.a +LIBRT?= ${DESTDIR}${LIBDIR}/librt.a +LIBRTLD_DB?= ${DESTDIR}${LIBDIR}/librtld_db.a +LIBSBUF?= ${DESTDIR}${LIBDIR}/libsbuf.a +LIBSDP?= ${DESTDIR}${LIBDIR}/libsdp.a +LIBSSH?= ${DESTDIR}${LIBDIR}/libssh.a +LIBSSL?= ${DESTDIR}${LIBDIR}/libssl.a +LIBSTAND?= ${DESTDIR}${LIBDIR}/libstand.a +LIBSTDCPLUSPLUS?= ${DESTDIR}${LIBDIR}/libstdc++.a +LIBTACPLUS?= ${DESTDIR}${LIBDIR}/libtacplus.a +LIBTERMCAP?= ${DESTDIR}${LIBDIR}/libtermcap.a +LIBTERMLIB?= "don't use LIBTERMLIB, use LIBTERMCAP" +LIBTINFO?= "don't use LIBTINFO, use LIBNCURSES" +LIBUFS?= ${DESTDIR}${LIBDIR}/libufs.a +LIBUGIDFW?= ${DESTDIR}${LIBDIR}/libugidfw.a +LIBUMEM?= ${DESTDIR}${LIBDIR}/libumem.a +LIBUSBHID?= ${DESTDIR}${LIBDIR}/libusbhid.a +LIBUSB?= ${DESTDIR}${LIBDIR}/libusb.a +LIBULOG?= ${DESTDIR}${LIBDIR}/libulog.a +LIBUTIL?= ${DESTDIR}${LIBDIR}/libutil.a +LIBUUTIL?= ${DESTDIR}${LIBDIR}/libuutil.a +LIBVGL?= ${DESTDIR}${LIBDIR}/libvgl.a +LIBVMMAPI?= ${DESTDIR}${LIBDIR}/libvmmapi.a +LIBWIND?= ${DESTDIR}${LIBDIR}/libwind.a +LIBWRAP?= ${DESTDIR}${LIBDIR}/libwrap.a +LIBXPG4?= ${DESTDIR}${LIBDIR}/libxpg4.a +LIBY?= ${DESTDIR}${LIBDIR}/liby.a +LIBYPCLNT?= ${DESTDIR}${LIBDIR}/libypclnt.a +LIBZ?= ${DESTDIR}${LIBDIR}/libz.a +LIBZFS?= ${DESTDIR}${LIBDIR}/libzfs.a +LIBZFS_CORE?= ${DESTDIR}${LIBDIR}/libzfs_core.a +LIBZPOOL?= ${DESTDIR}${LIBDIR}/libzpool.a diff --git a/share/mk/bsd.links.mk b/share/mk/bsd.links.mk new file mode 100644 index 0000000..1e4d57e --- /dev/null +++ b/share/mk/bsd.links.mk @@ -0,0 +1,31 @@ +# $FreeBSD$ + +.if !target(__<bsd.init.mk>__) +.error bsd.links.mk cannot be included directly. +.endif + +afterinstall: _installlinks +.ORDER: realinstall _installlinks +_installlinks: +.if defined(LINKS) && !empty(LINKS) + @set ${LINKS}; \ + while test $$# -ge 2; do \ + l=${DESTDIR}$$1; \ + shift; \ + t=${DESTDIR}$$1; \ + shift; \ + ${ECHO} $$t -\> $$l; \ + ${INSTALL_LINK} $$l $$t; \ + done; true +.endif +.if defined(SYMLINKS) && !empty(SYMLINKS) + @set ${SYMLINKS}; \ + while test $$# -ge 2; do \ + l=$$1; \ + shift; \ + t=${DESTDIR}$$1; \ + shift; \ + ${ECHO} $$t -\> $$l; \ + ${INSTALL_SYMLINK} $$l $$t; \ + done; true +.endif diff --git a/share/mk/bsd.man.mk b/share/mk/bsd.man.mk new file mode 100644 index 0000000..6445ba3 --- /dev/null +++ b/share/mk/bsd.man.mk @@ -0,0 +1,250 @@ +# $FreeBSD$ +# +# The include file <bsd.man.mk> handles installing manual pages and +# their links. +# +# +# +++ variables +++ +# +# DESTDIR Change the tree where the man pages gets installed. [not set] +# +# MANDIR Base path for manual installation. [${SHAREDIR}/man/man] +# +# MANOWN Manual owner. [${SHAREOWN}] +# +# MANGRP Manual group. [${SHAREGRP}] +# +# MANMODE Manual mode. [${NOBINMODE}] +# +# MANSUBDIR Subdirectory under the manual page section, i.e. "/i386" +# or "/tahoe" for machine specific manual pages. +# +# MAN The manual pages to be installed. For sections see +# variable ${SECTIONS} +# +# MCOMPRESS_CMD Program to compress man pages. Output is to +# stdout. [${COMPRESS_CMD}] +# +# MLINKS List of manual page links (using a suffix). The +# linked-to file must come first, the linked file +# second, and there may be multiple pairs. The files +# are hard-linked. +# +# NO_MANCOMPRESS If you do not want unformatted manual pages to be +# compressed when they are installed. [not set] +# +# NO_MLINKS If you do not want install manual page links. [not set] +# +# MANFILTER command to pipe the raw man page through before compressing +# or installing. Can be used to do sed substitution. +# +# MANBUILDCAT create preformatted manual pages in addition to normal +# pages. [not set] +# +# MROFF_CMD command and flags to create preformatted pages +# +# +++ targets +++ +# +# maninstall: +# Install the manual pages and their links. +# + +.if !target(__<bsd.init.mk>__) +.error bsd.man.mk cannot be included directly. +.endif + +MINSTALL?= ${INSTALL} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} + +CATDIR= ${MANDIR:H:S/$/\/cat/} +CATEXT= .cat +MROFF_CMD?= groff -Tascii -mtty-char -man -t + +MCOMPRESS_CMD?= ${COMPRESS_CMD} +MCOMPRESS_EXT?= ${COMPRESS_EXT} + +SECTIONS= 1 2 3 4 5 6 7 8 9 +.SUFFIXES: ${SECTIONS:S/^/./g} + +# Backwards compatibility. +.if !defined(MAN) +.for __sect in ${SECTIONS} +.if defined(MAN${__sect}) && !empty(MAN${__sect}) +MAN+= ${MAN${__sect}} +.endif +.endfor +.endif + +_manpages: +all-man: _manpages + +.if defined(NO_MANCOMPRESS) + +# Make special arrangements to filter to a temporary file at build time +# for NO_MANCOMPRESS. +.if defined(MANFILTER) +FILTEXTENSION= .filt +.else +FILTEXTENSION= +.endif + +ZEXT= + +.if defined(MANFILTER) +.if defined(MAN) && !empty(MAN) +CLEANFILES+= ${MAN:T:S/$/${FILTEXTENSION}/g} +CLEANFILES+= ${MAN:T:S/$/${CATEXT}${FILTEXTENSION}/g} +.for __page in ${MAN} +.for __target in ${__page:T:S/$/${FILTEXTENSION}/g} +_manpages: ${__target} +${__target}: ${__page} + ${MANFILTER} < ${.ALLSRC} > ${.TARGET} +.endfor +.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) +.for __target in ${__page:T:S/$/${CATEXT}${FILTEXTENSION}/g} +_manpages: ${__target} +${__target}: ${__page} + ${MANFILTER} < ${.ALLSRC} | ${MROFF_CMD} > ${.TARGET} +.endfor +.endif +.endfor +.endif +.else +.if defined(MAN) && !empty(MAN) +CLEANFILES+= ${MAN:T:S/$/${CATEXT}/g} +.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) +.for __page in ${MAN} +.for __target in ${__page:T:S/$/${CATEXT}/g} +_manpages: ${__target} +${__target}: ${__page} + ${MROFF_CMD} ${.ALLSRC} > ${.TARGET} +.endfor +.endfor +.else +_manpages: ${MAN} +.endif +.endif +.endif + +.else + +ZEXT= ${MCOMPRESS_EXT} + +.if defined(MAN) && !empty(MAN) +CLEANFILES+= ${MAN:T:S/$/${MCOMPRESS_EXT}/g} +CLEANFILES+= ${MAN:T:S/$/${CATEXT}${MCOMPRESS_EXT}/g} +.for __page in ${MAN} +.for __target in ${__page:T:S/$/${MCOMPRESS_EXT}/} +_manpages: ${__target} +${__target}: ${__page} +.if defined(MANFILTER) + ${MANFILTER} < ${.ALLSRC} | ${MCOMPRESS_CMD} > ${.TARGET} +.else + ${MCOMPRESS_CMD} ${.ALLSRC} > ${.TARGET} +.endif +.endfor +.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) +.for __target in ${__page:T:S/$/${CATEXT}${MCOMPRESS_EXT}/} +_manpages: ${__target} +${__target}: ${__page} +.if defined(MANFILTER) + ${MANFILTER} < ${.ALLSRC} | ${MROFF_CMD} | ${MCOMPRESS_CMD} > ${.TARGET} +.else + ${MROFF_CMD} ${.ALLSRC} | ${MCOMPRESS_CMD} > ${.TARGET} +.endif +.endfor +.endif +.endfor +.endif + +.endif + +maninstall: _maninstall +_maninstall: +.if defined(MAN) && !empty(MAN) +_maninstall: ${MAN} +.if defined(NO_MANCOMPRESS) +.if defined(MANFILTER) +.for __page in ${MAN} + ${MINSTALL} ${__page:T:S/$/${FILTEXTENSION}/g} \ + ${DESTDIR}${MANDIR}${__page:E}${MANSUBDIR}/${__page} +.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) + ${MINSTALL} ${__page:T:S/$/${CATEXT}${FILTEXTENSION}/g} \ + ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page} +.endif +.endfor +.else + @set ${.ALLSRC:C/\.([^.]*)$/.\1 \1/}; \ + while : ; do \ + case $$# in \ + 0) break;; \ + 1) echo "warn: missing extension: $$1"; break;; \ + esac; \ + page=$$1; shift; sect=$$1; shift; \ + d=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}; \ + ${ECHO} ${MINSTALL} $${page} $${d}; \ + ${MINSTALL} $${page} $${d}; \ + done +.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) +.for __page in ${MAN} + ${MINSTALL} ${__page:T:S/$/${CATEXT}/} \ + ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page:T} +.endfor +.endif +.endif +.else +.for __page in ${MAN} + ${MINSTALL} ${__page:T:S/$/${MCOMPRESS_EXT}/g} \ + ${DESTDIR}${MANDIR}${__page:E}${MANSUBDIR} +.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) + ${MINSTALL} ${__page:T:S/$/${CATEXT}${MCOMPRESS_EXT}/g} \ + ${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page:T:S/$/${MCOMPRESS_EXT}/} +.endif +.endfor +.endif +.endif + +.if !defined(NO_MLINKS) && defined(MLINKS) && !empty(MLINKS) + @set ${MLINKS:C/\.([^.]*)$/.\1 \1/}; \ + while : ; do \ + case $$# in \ + 0) break;; \ + [123]) echo "warn: empty MLINK: $$1 $$2 $$3"; break;; \ + esac; \ + name=$$1; shift; sect=$$1; shift; \ + l=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}/$$name; \ + name=$$1; shift; sect=$$1; shift; \ + t=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}/$$name; \ + ${ECHO} $${t}${ZEXT} -\> $${l}${ZEXT}; \ + rm -f $${t} $${t}${MCOMPRESS_EXT}; \ + ${INSTALL_LINK} $${l}${ZEXT} $${t}${ZEXT}; \ + done +.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) + @set ${MLINKS:C/\.([^.]*)$/.\1 \1/}; \ + while : ; do \ + case $$# in \ + 0) break;; \ + [123]) echo "warn: empty MLINK: $$1 $$2 $$3"; break;; \ + esac; \ + name=$$1; shift; sect=$$1; shift; \ + l=${DESTDIR}${CATDIR}$${sect}${MANSUBDIR}/$$name; \ + name=$$1; shift; sect=$$1; shift; \ + t=${DESTDIR}${CATDIR}$${sect}${MANSUBDIR}/$$name; \ + ${ECHO} $${t}${ZEXT} -\> $${l}${ZEXT}; \ + rm -f $${t} $${t}${MCOMPRESS_EXT}; \ + ${INSTALL_LINK} $${l}${ZEXT} $${t}${ZEXT}; \ + done +.endif +.endif + +manlint: +.if defined(MAN) && !empty(MAN) +.for __page in ${MAN} +manlint: ${__page}lint +${__page}lint: ${__page} +.if defined(MANFILTER) + ${MANFILTER} < ${.ALLSRC} | ${MROFF_CMD} -ww -z +.else + ${MROFF_CMD} -ww -z ${.ALLSRC} +.endif +.endfor +.endif diff --git a/share/mk/bsd.nls.mk b/share/mk/bsd.nls.mk new file mode 100644 index 0000000..48093eb --- /dev/null +++ b/share/mk/bsd.nls.mk @@ -0,0 +1,74 @@ +# $FreeBSD$ +# +# This include file <bsd.nls.mk> handles building and installing Native +# Language Support (NLS) catalogs +# +# +++ variables +++ +# +# GENCAT A program for converting .msg files into compiled NLS +# .cat files. [gencat] +# +# NLS Source or intermediate .msg files. [set in Makefile] +# +# NLSDIR Base path for National Language Support files +# installation. [${SHAREDIR}/nls] +# +# NLSGRP National Language Support files group. [${SHAREGRP}] +# +# NLSMODE National Language Support files mode. [${NOBINMODE}] +# +# NLSOWN National Language Support files owner. [${SHAREOWN}] + +.if !target(__<bsd.init.mk>__) +.error bsd.nls.mk cannot be included directly. +.endif + +GENCAT?= gencat + +.SUFFIXES: .cat .msg + +.msg.cat: + ${GENCAT} ${.TARGET} ${.IMPSRC} + +.if defined(NLS) && !empty(NLS) && ${MK_NLS} != "no" + +# +# .msg file pre-build rules +# +NLSSRCDIR?= ${.CURDIR} +.for file in ${NLS} +.if defined(NLSSRCFILES) +NLSSRCFILES_${file}?= ${NLSSRCFILES} +.endif +.if defined(NLSSRCFILES_${file}) +NLSSRCDIR_${file}?= ${NLSSRCDIR} +${file}.msg: ${NLSSRCFILES_${file}:S/^/${NLSSRCDIR_${file}}\//} + @rm -f ${.TARGET} + cat ${.ALLSRC} > ${.TARGET} +CLEANFILES+= ${file}.msg +.endif +.endfor + +# +# .cat file build rules +# +NLS:= ${NLS:=.cat} +CLEANFILES+= ${NLS} +FILESGROUPS?= FILES +FILESGROUPS+= NLS +NLSDIR?= ${SHAREDIR}/nls + +# +# installation rules +# +.for file in ${NLS} +NLSNAME_${file:T}= ${file:T:R}/${NLSNAME}.cat +.if defined(NLSLINKS_${file:R}) && !empty(NLSLINKS_${file:R}) +NLSLINKS+= ${file:R} +.endif +.for dst in ${NLSLINKS_${file:R}} +SYMLINKS+= ../${file:R}/${NLSNAME}.cat ${NLSDIR}/${dst}/${NLSNAME}.cat +.endfor +.endfor + +.endif # defined(NLS) && !empty(NLS) && ${MK_NLS} != "no" diff --git a/share/mk/bsd.obj.mk b/share/mk/bsd.obj.mk new file mode 100644 index 0000000..634261e --- /dev/null +++ b/share/mk/bsd.obj.mk @@ -0,0 +1,140 @@ +# $FreeBSD$ +# +# The include file <bsd.obj.mk> handles creating the 'obj' directory +# and cleaning up object files, etc. +# +# +++ variables +++ +# +# CLEANDIRS Additional directories to remove for the clean target. +# +# CLEANFILES Additional files to remove for the clean target. +# +# MAKEOBJDIR A pathname for the directory where the targets +# are built. Note: MAKEOBJDIR is an *environment* variable +# and works properly only if set as an environment variable, +# not as a global or command line variable! +# +# E.g. use `env MAKEOBJDIR=temp-obj make' +# +# MAKEOBJDIRPREFIX Specifies somewhere other than /usr/obj to root the object +# tree. Note: MAKEOBJDIRPREFIX is an *environment* variable +# and works properly only if set as an environment variable, +# not as a global or command line variable! +# +# E.g. use `env MAKEOBJDIRPREFIX=/somewhere/obj make' +# +# NO_OBJ Do not create object directories. This should not be set +# if anything is built. +# +# +++ targets +++ +# +# clean: +# remove ${CLEANFILES}; remove ${CLEANDIRS} and all contents. +# +# cleandir: +# remove the build directory (and all its contents) created by obj +# +# obj: +# create build directory. +# + +.if !target(__<bsd.obj.mk>__) +__<bsd.obj.mk>__: +.include <bsd.own.mk> + +.if defined(MAKEOBJDIRPREFIX) +CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR} +.elif defined(MAKEOBJDIR) && ${MAKEOBJDIR:M/*} != "" +CANONICALOBJDIR:=${MAKEOBJDIR} +.else +CANONICALOBJDIR:=/usr/obj${.CURDIR} +.endif + +# +# Warn of unorthodox object directory. +# +# The following directories are tried in order for ${.OBJDIR}: +# +# 1. ${MAKEOBJDIRPREFIX}/`pwd` +# 2. ${MAKEOBJDIR} +# 3. obj.${MACHINE} +# 4. obj +# 5. /usr/obj/`pwd` +# 6. ${.CURDIR} +# +# If ${.OBJDIR} is constructed using canonical cases 1 or 5, or +# case 2 (using MAKEOBJDIR), don't issue a warning. Otherwise, +# issue a warning differentiating between cases 6 and (3 or 4). +# +objwarn: +.if !defined(NO_OBJ) && ${.OBJDIR} != ${CANONICALOBJDIR} && \ + !(defined(MAKEOBJDIRPREFIX) && exists(${CANONICALOBJDIR}/)) && \ + !(defined(MAKEOBJDIR) && exists(${MAKEOBJDIR}/)) +.if ${.OBJDIR} == ${.CURDIR} + @${ECHO} "Warning: Object directory not changed from original ${.CURDIR}" +.elif exists(${.CURDIR}/obj.${MACHINE}/) || exists(${.CURDIR}/obj/) + @${ECHO} "Warning: Using ${.OBJDIR} as object directory instead of\ + canonical ${CANONICALOBJDIR}" +.endif +.endif + +.if !defined(NO_OBJ) +.if !target(obj) +obj: .PHONY + @if ! test -d ${CANONICALOBJDIR}/; then \ + mkdir -p ${CANONICALOBJDIR}; \ + if ! test -d ${CANONICALOBJDIR}/; then \ + ${ECHO} "Unable to create ${CANONICALOBJDIR}."; \ + exit 1; \ + fi; \ + ${ECHO} "${CANONICALOBJDIR} created for ${.CURDIR}"; \ + fi +.endif + +.if !target(objlink) +objlink: + @if test -d ${CANONICALOBJDIR}/; then \ + rm -f ${.CURDIR}/obj; \ + ln -s ${CANONICALOBJDIR} ${.CURDIR}/obj; \ + else \ + echo "No ${CANONICALOBJDIR} to link to - do a make obj."; \ + fi +.endif +.endif # !defined(NO_OBJ) + +# +# where would that obj directory be? +# +.if !target(whereobj) +whereobj: + @echo ${.OBJDIR} +.endif + +.if ${CANONICALOBJDIR} != ${.CURDIR} && exists(${CANONICALOBJDIR}/) +cleanobj: + @rm -rf ${CANONICALOBJDIR} +.else +cleanobj: clean cleandepend +.endif + @if [ -L ${.CURDIR}/obj ]; then rm -f ${.CURDIR}/obj; fi + +# Tell bmake not to look for generated files via .PATH +.if !empty(CLEANFILES) +.NOPATH: ${CLEANFILES} +.endif + +.if !target(clean) +clean: +.if defined(CLEANFILES) && !empty(CLEANFILES) + rm -f ${CLEANFILES} +.endif +.if defined(CLEANDIRS) && !empty(CLEANDIRS) + rm -rf ${CLEANDIRS} +.endif +.endif + +cleandir: cleanobj + +.include <bsd.subdir.mk> + +.endif # !target(__<bsd.obj.mk>__) diff --git a/share/mk/bsd.own.mk b/share/mk/bsd.own.mk new file mode 100644 index 0000000..e96b6a2 --- /dev/null +++ b/share/mk/bsd.own.mk @@ -0,0 +1,659 @@ +# $FreeBSD$ +# +# The include file <bsd.own.mk> set common variables for owner, +# group, mode, and directories. Defaults are in brackets. +# +# +# +++ variables +++ +# +# DESTDIR Change the tree where the file gets installed. [not set] +# +# DISTDIR Change the tree where the file for a distribution +# gets installed (see /usr/src/release/Makefile). [not set] +# +# COMPRESS_CMD Program to compress documents. +# Output is to stdout. [gzip -cn] +# +# COMPRESS_EXT File name extension of ${COMPRESS_CMD} command. [.gz] +# +# BINOWN Binary owner. [root] +# +# BINGRP Binary group. [wheel] +# +# BINMODE Binary mode. [555] +# +# NOBINMODE Mode for non-executable files. [444] +# +# LIBDIR Base path for libraries. [/usr/lib] +# +# LIBCOMPATDIR Base path for compat libraries. [/usr/lib/compat] +# +# LIBDATADIR Base path for misc. utility data files. [/usr/libdata] +# +# LIBEXECDIR Base path for system daemons and utilities. [/usr/libexec] +# +# LINTLIBDIR Base path for lint libraries. [/usr/libdata/lint] +# +# SHLIBDIR Base path for shared libraries. [${LIBDIR}] +# +# LIBOWN Library owner. [${BINOWN}] +# +# LIBGRP Library group. [${BINGRP}] +# +# LIBMODE Library mode. [${NOBINMODE}] +# +# +# DEBUGDIR Base path for standalone debug files. [/usr/lib/debug] +# +# DEBUGMODE Mode for debug files. [${NOBINMODE}] +# +# +# KMODDIR Base path for loadable kernel modules +# (see kld(4)). [/boot/kernel] +# +# KMODOWN Kernel and KLD owner. [${BINOWN}] +# +# KMODGRP Kernel and KLD group. [${BINGRP}] +# +# KMODMODE KLD mode. [${BINMODE}] +# +# +# SHAREDIR Base path for architecture-independent ascii +# text files. [/usr/share] +# +# SHAREOWN ASCII text file owner. [root] +# +# SHAREGRP ASCII text file group. [wheel] +# +# SHAREMODE ASCII text file mode. [${NOBINMODE}] +# +# +# CONFDIR Base path for configuration files. [/etc] +# +# CONFOWN Configuration file owner. [root] +# +# CONFGRP Configuration file group. [wheel] +# +# CONFMODE Configuration file mode. [644] +# +# +# DOCDIR Base path for system documentation (e.g. PSD, USD, +# handbook, FAQ etc.). [${SHAREDIR}/doc] +# +# DOCOWN Documentation owner. [${SHAREOWN}] +# +# DOCGRP Documentation group. [${SHAREGRP}] +# +# DOCMODE Documentation mode. [${NOBINMODE}] +# +# +# INFODIR Base path for GNU's hypertext system +# called Info (see info(1)). [${SHAREDIR}/info] +# +# INFOOWN Info owner. [${SHAREOWN}] +# +# INFOGRP Info group. [${SHAREGRP}] +# +# INFOMODE Info mode. [${NOBINMODE}] +# +# +# MANDIR Base path for manual installation. [${SHAREDIR}/man/man] +# +# MANOWN Manual owner. [${SHAREOWN}] +# +# MANGRP Manual group. [${SHAREGRP}] +# +# MANMODE Manual mode. [${NOBINMODE}] +# +# +# NLSDIR Base path for National Language Support files +# installation. [${SHAREDIR}/nls] +# +# NLSOWN National Language Support files owner. [${SHAREOWN}] +# +# NLSGRP National Language Support files group. [${SHAREGRP}] +# +# NLSMODE National Language Support files mode. [${NOBINMODE}] +# +# INCLUDEDIR Base path for standard C include files [/usr/include] + +.if !target(__<bsd.own.mk>__) +__<bsd.own.mk>__: + +.if !defined(_WITHOUT_SRCCONF) +SRCCONF?= /etc/src.conf +.if exists(${SRCCONF}) || ${SRCCONF} != "/etc/src.conf" +.include "${SRCCONF}" +.endif +.endif + +# Binaries +BINOWN?= root +BINGRP?= wheel +BINMODE?= 555 +NOBINMODE?= 444 + +.if defined(MODULES_WITH_WORLD) +KMODDIR?= /boot/modules +.else +KMODDIR?= /boot/kernel +.endif +KMODOWN?= ${BINOWN} +KMODGRP?= ${BINGRP} +KMODMODE?= ${BINMODE} + +LIBDIR?= /usr/lib +LIBCOMPATDIR?= /usr/lib/compat +LIBDATADIR?= /usr/libdata +LIBEXECDIR?= /usr/libexec +LINTLIBDIR?= /usr/libdata/lint +SHLIBDIR?= ${LIBDIR} +LIBOWN?= ${BINOWN} +LIBGRP?= ${BINGRP} +LIBMODE?= ${NOBINMODE} + +DEBUGDIR?= /usr/lib/debug +DEBUGMODE?= ${NOBINMODE} + + +# Share files +SHAREDIR?= /usr/share +SHAREOWN?= root +SHAREGRP?= wheel +SHAREMODE?= ${NOBINMODE} + +CONFDIR?= /etc +CONFOWN?= root +CONFGRP?= wheel +CONFMODE?= 644 + +MANDIR?= ${SHAREDIR}/man/man +MANOWN?= ${SHAREOWN} +MANGRP?= ${SHAREGRP} +MANMODE?= ${NOBINMODE} + +DOCDIR?= ${SHAREDIR}/doc +DOCOWN?= ${SHAREOWN} +DOCGRP?= ${SHAREGRP} +DOCMODE?= ${NOBINMODE} + +INFODIR?= ${SHAREDIR}/info +INFOOWN?= ${SHAREOWN} +INFOGRP?= ${SHAREGRP} +INFOMODE?= ${NOBINMODE} + +NLSDIR?= ${SHAREDIR}/nls +NLSOWN?= ${SHAREOWN} +NLSGRP?= ${SHAREGRP} +NLSMODE?= ${NOBINMODE} + +INCLUDEDIR?= /usr/include + +# +# install(1) parameters. +# +HRDLINK?= -l h +SYMLINK?= -l s + +INSTALL_LINK?= ${INSTALL} ${HRDLINK} +INSTALL_SYMLINK?= ${INSTALL} ${SYMLINK} + +# Common variables +.if !defined(DEBUG_FLAGS) +STRIP?= -s +.endif + +COMPRESS_CMD?= gzip -cn +COMPRESS_EXT?= .gz + +.if !defined(_WITHOUT_SRCCONF) +# +# Define MK_* variables (which are either "yes" or "no") for users +# to set via WITH_*/WITHOUT_* in /etc/src.conf and override in the +# make(1) environment. +# These should be tested with `== "no"' or `!= "no"' in makefiles. +# The NO_* variables should only be set by makefiles. +# + +# +# Supported NO_* options (if defined, MK_* will be forced to "no", +# regardless of user's setting). +# +.for var in \ + CTF \ + DEBUG_FILES \ + INSTALLLIB \ + MAN \ + PROFILE +.if defined(NO_${var}) +.if defined(WITH_${var}) +.undef WITH_${var} +.endif +WITHOUT_${var}= +.endif +.endfor + +# +# Older-style variables that enabled behaviour when set. +# +.if defined(YES_HESIOD) +WITH_HESIOD= +.endif + +__DEFAULT_YES_OPTIONS = \ + ACCT \ + ACPI \ + AMD \ + APM \ + ASSERT_DEBUG \ + AT \ + ATF \ + ATM \ + AUDIT \ + AUTHPF \ + BIND \ + BIND_DNSSEC \ + BIND_ETC \ + BIND_LIBS_LWRES \ + BIND_MTREE \ + BIND_NAMED \ + BIND_UTILS \ + BINUTILS \ + BLUETOOTH \ + BMAKE \ + BOOT \ + BSD_CPIO \ + BSNMP \ + BZIP2 \ + CALENDAR \ + CAPSICUM \ + CDDL \ + CPP \ + CROSS_COMPILER \ + CRYPT \ + CTM \ + CXX \ + DICT \ + DYNAMICROOT \ + ED_CRYPTO \ + EXAMPLES \ + FLOPPY \ + FORMAT_EXTENSIONS \ + FORTH \ + FP_LIBC \ + FREEBSD_UPDATE \ + GAMES \ + GCC \ + GCOV \ + GDB \ + GNU \ + GPIB \ + GPIO \ + GROFF \ + HTML \ + INET \ + INET6 \ + INFO \ + INSTALLLIB \ + IPFILTER \ + IPFW \ + IPX \ + JAIL \ + KDUMP \ + KERBEROS \ + KERNEL_SYMBOLS \ + KVM \ + LDNS \ + LEGACY_CONSOLE \ + LIB32 \ + LIBPTHREAD \ + LIBTHR \ + LOCALES \ + LOCATE \ + LPR \ + LS_COLORS \ + MAIL \ + MAILWRAPPER \ + MAKE \ + MAN \ + NDIS \ + NETCAT \ + NETGRAPH \ + NIS \ + NLS \ + NLS_CATALOGS \ + NS_CACHING \ + NTP \ + OPENSSH \ + OPENSSL \ + PAM \ + PC_SYSINSTALL \ + PF \ + PKGBOOTSTRAP \ + PKGTOOLS \ + PMC \ + PORTSNAP \ + PPP \ + PROFILE \ + QUOTAS \ + RCMDS \ + RCS \ + RESCUE \ + ROUTED \ + SENDMAIL \ + SETUID_LOGIN \ + SHAREDOCS \ + SOURCELESS \ + SOURCELESS_HOST \ + SOURCELESS_UCODE \ + SSP \ + SVNLITE \ + SYMVER \ + SYSCONS \ + SYSINSTALL \ + TCSH \ + TELNET \ + TEXTPROC \ + TOOLCHAIN \ + USB \ + UTMPX \ + WIRELESS \ + WPA_SUPPLICANT_EAPOL \ + ZFS \ + ZONEINFO + +__DEFAULT_NO_OPTIONS = \ + ARM_EABI \ + BSD_PATCH \ + BIND_IDN \ + BIND_LARGE_FILE \ + BIND_LIBS \ + BIND_SIGCHASE \ + BIND_XML \ + BSDCONFIG \ + BSD_GREP \ + CLANG_EXTRAS \ + CTF \ + DEBUG_FILES \ + GPL_DTC \ + HESIOD \ + ICONV \ + INSTALL_AS_USER \ + LDNS_UTILS \ + NMTREE \ + NAND \ + OFED \ + OPENSSH_NONE_CIPHER \ + SHARED_TOOLCHAIN \ + SVN + +# +# Default behaviour of some options depends on the architecture. Unfortunately +# this means that we have to test TARGET_ARCH (the buildworld case) as well +# as MACHINE_ARCH (the non-buildworld case). Normally TARGET_ARCH is not +# used at all in bsd.*.mk, but we have to make an exception here if we want +# to allow defaults for some things like clang and fdt to vary by target +# architecture. +# +.if defined(TARGET_ARCH) +__T=${TARGET_ARCH} +.else +__T=${MACHINE_ARCH} +.endif +# Clang is only for x86, powerpc and little-endian arm right now, by default. +.if ${__T} == "amd64" || ${__T} == "i386" || ${__T:Mpowerpc*} +__DEFAULT_YES_OPTIONS+=CLANG CLANG_FULL +.elif ${__T} == "arm" || ${__T} == "armv6" +__DEFAULT_YES_OPTIONS+=CLANG +# GCC is unable to build the full clang on arm, disable it by default. +__DEFAULT_NO_OPTIONS+=CLANG_FULL +.else +__DEFAULT_NO_OPTIONS+=CLANG CLANG_FULL +.endif +# Clang the default system compiler only on little-endian arm and x86. +.if ${__T} == "amd64" || ${__T} == "arm" || ${__T} == "armv6" || \ + ${__T} == "i386" +__DEFAULT_YES_OPTIONS+=CLANG_IS_CC +.else +__DEFAULT_NO_OPTIONS+=CLANG_IS_CC +.endif +# FDT is needed only for arm, mips and powerpc +.if ${__T:Marm*} || ${__T:Mpowerpc*} || ${__T:Mmips*} +__DEFAULT_YES_OPTIONS+=FDT +.else +__DEFAULT_NO_OPTIONS+=FDT +.endif +.undef __T + +# +# MK_* options which default to "yes". +# +.for var in ${__DEFAULT_YES_OPTIONS} +.if defined(WITH_${var}) && defined(WITHOUT_${var}) +.error WITH_${var} and WITHOUT_${var} can't both be set. +.endif +.if defined(MK_${var}) +.error MK_${var} can't be set by a user. +.endif +.if defined(WITHOUT_${var}) +MK_${var}:= no +.else +MK_${var}:= yes +.endif +.endfor +.undef __DEFAULT_YES_OPTIONS + +# +# MK_* options which default to "no". +# +.for var in ${__DEFAULT_NO_OPTIONS} +.if defined(WITH_${var}) && defined(WITHOUT_${var}) +.error WITH_${var} and WITHOUT_${var} can't both be set. +.endif +.if defined(MK_${var}) +.error MK_${var} can't be set by a user. +.endif +.if defined(WITH_${var}) +MK_${var}:= yes +.else +MK_${var}:= no +.endif +.endfor +.undef __DEFAULT_NO_OPTIONS + +# +# Force some options off if their dependencies are off. +# Order is somewhat important. +# +.if ${MK_LIBPTHREAD} == "no" +MK_LIBTHR:= no +.endif + +.if ${MK_LIBTHR} == "no" +MK_BIND:= no +.endif + +.if ${MK_BIND} == "no" +MK_BIND_DNSSEC:= no +MK_BIND_ETC:= no +MK_BIND_LIBS:= no +MK_BIND_LIBS_LWRES:= no +MK_BIND_MTREE:= no +MK_BIND_NAMED:= no +MK_BIND_UTILS:= no +.endif + +.if ${MK_LDNS} == "no" +MK_LDNS_UTILS:= no +.endif + +.if ${MK_LDNS_UTILS} != "no" +MK_BIND_UTILS:= no +.endif + +.if ${MK_BIND_MTREE} == "no" +MK_BIND_ETC:= no +.endif + +.if ${MK_SOURCELESS} == "no" +MK_SOURCELESS_HOST:= no +MK_SOURCELESS_UCODE:= no +.endif + +.if ${MK_CDDL} == "no" +MK_ZFS:= no +MK_CTF:= no +.endif + +.if ${MK_CRYPT} == "no" +MK_OPENSSL:= no +MK_OPENSSH:= no +MK_KERBEROS:= no +.endif + +.if ${MK_CXX} == "no" +MK_CLANG:= no +MK_GROFF:= no +.endif + +.if ${MK_MAIL} == "no" +MK_MAILWRAPPER:= no +MK_SENDMAIL:= no +.endif + +.if ${MK_NETGRAPH} == "no" +MK_ATM:= no +MK_BLUETOOTH:= no +.endif + +.if ${MK_OPENSSL} == "no" +MK_OPENSSH:= no +MK_KERBEROS:= no +.endif + +.if ${MK_PF} == "no" +MK_AUTHPF:= no +.endif + +.if ${MK_TEXTPROC} == "no" +MK_GROFF:= no +.endif + +.if ${MK_TOOLCHAIN} == "no" +MK_BINUTILS:= no +MK_CLANG:= no +MK_GCC:= no +MK_GDB:= no +.endif + +.if ${MK_CLANG} == "no" +MK_CLANG_EXTRAS:= no +MK_CLANG_FULL:= no +MK_CLANG_IS_CC:= no +.endif + +# +# Set defaults for the MK_*_SUPPORT variables. +# + +# +# MK_*_SUPPORT options which default to "yes" unless their corresponding +# MK_* variable is set to "no". +# +.for var in \ + BZIP2 \ + GNU \ + INET \ + INET6 \ + IPX \ + KERBEROS \ + KVM \ + NETGRAPH \ + PAM \ + WIRELESS +.if defined(WITH_${var}_SUPPORT) && defined(WITHOUT_${var}_SUPPORT) +.error WITH_${var}_SUPPORT and WITHOUT_${var}_SUPPORT can't both be set. +.endif +.if defined(MK_${var}_SUPPORT) +.error MK_${var}_SUPPORT can't be set by a user. +.endif +.if defined(WITHOUT_${var}_SUPPORT) || ${MK_${var}} == "no" +MK_${var}_SUPPORT:= no +.else +MK_${var}_SUPPORT:= yes +.endif +.endfor + +# +# MK_* options whose default value depends on another option. +# +.for vv in \ + GSSAPI/KERBEROS \ + MAN_UTILS/MAN +.if defined(WITH_${vv:H}) && defined(WITHOUT_${vv:H}) +.error WITH_${vv:H} and WITHOUT_${vv:H} can't both be set. +.endif +.if defined(MK_${vv:H}) +.error MK_${vv:H} can't be set by a user. +.endif +.if defined(WITH_${vv:H}) +MK_${vv:H}:= yes +.elif defined(WITHOUT_${vv:H}) +MK_${vv:H}:= no +.else +MK_${vv:H}:= ${MK_${vv:T}} +.endif +.endfor + +# +# MK_* options that default to "yes" if the compiler is a C++11 compiler. +# +.include <bsd.compiler.mk> +.for var in \ + LIBCPLUSPLUS +.if defined(WITH_${var}) && defined(WITHOUT_${var}) +.error WITH_${var} and WITHOUT_${var} can't both be set. +.endif +.if defined(MK_${var}) +.error MK_${var} can't be set by a user. +.endif +.if ${COMPILER_FEATURES:Mc++11} +.if defined(WITHOUT_${var}) +MK_${var}:= no +.else +MK_${var}:= yes +.endif +.else +.if defined(WITH_${var}) +MK_${var}:= yes +.else +MK_${var}:= no +.endif +.endif +.endfor + +.if ${MK_CTF} != "no" +CTFCONVERT_CMD= ${CTFCONVERT} ${CTFFLAGS} ${.TARGET} +.elif defined(.PARSEDIR) || (defined(MAKE_VERSION) && ${MAKE_VERSION} >= 5201111300) +CTFCONVERT_CMD= +.else +CTFCONVERT_CMD= @: +.endif + +.if ${MK_INSTALL_AS_USER} != "no" +_uid!= id -u +.if ${_uid} != 0 +.if !defined(USER) +USER!= id -un +.endif +_gid!= id -gn +.for x in BIN CONF DOC INFO KMOD LIB MAN NLS SHARE +$xOWN= ${USER} +$xGRP= ${_gid} +.endfor +.endif +.endif + +.endif # !_WITHOUT_SRCCONF + +.endif # !target(__<bsd.own.mk>__) diff --git a/share/mk/bsd.pkg.mk b/share/mk/bsd.pkg.mk new file mode 100644 index 0000000..3d1ca42 --- /dev/null +++ b/share/mk/bsd.pkg.mk @@ -0,0 +1,48 @@ +# $FreeBSD$ + +WRKDIR=${.OBJDIR} +.if ${.OBJDIR} == ${.CURDIR} +WRKDIR=${.CURDIR}/work +.endif +NO_WRKSUBDIR=YES +NO_CHECKSUM=YES +NO_BUILD=YES + +fetch: +extract: +patch: +configure: +build: + +.if target(__<bsd.obj.mk>__) +clean: do-clean +.if ${CANONICALOBJDIR} != ${.CURDIR} && exists(${CANONICALOBJDIR}/) + @rm -rf ${CANONICALOBJDIR} +.else + @if [ -L ${.CURDIR}/obj ]; then rm -f ${.CURDIR}/obj; fi +.if defined(CLEANFILES) && !empty(CLEANFILES) + rm -f ${CLEANFILES} +.endif +.if defined(CLEANDIRS) && !empty(CLEANDIRS) + rm -rf ${CLEANDIRS} +.endif +.endif +.endif + +.if !target(beforeinstall) +beforeinstall: +.endif +.if !target(afterinstall) +afterinstall: +.endif + +install: install-message check-categories check-conflicts \ + run-depends lib-depends pre-install pre-install-script \ + generate-plist check-already-installed \ + check-umask install-mtree pre-su-install \ + pre-su-install-script \ + beforeinstall realinstall afterinstall \ + add-plist-info post-install post-install-script \ + compress-man run-ldconfig fake-pkg + +.include <bsd.port.mk> diff --git a/share/mk/bsd.port.mk b/share/mk/bsd.port.mk new file mode 100644 index 0000000..87e4935 --- /dev/null +++ b/share/mk/bsd.port.mk @@ -0,0 +1,16 @@ +# $FreeBSD$ + +PORTSDIR?= /usr/ports +BSDPORTMK?= ${PORTSDIR}/Mk/bsd.port.mk + +# Needed to keep bsd.own.mk from reading in /etc/src.conf +# and setting MK_* variables when building ports. +_WITHOUT_SRCCONF= + +# Enable CTF conversion on request. +.if defined(WITH_CTF) +.undef NO_CTF +.endif + +.include <bsd.own.mk> +.include "${BSDPORTMK}" diff --git a/share/mk/bsd.port.options.mk b/share/mk/bsd.port.options.mk new file mode 100644 index 0000000..e043cc2 --- /dev/null +++ b/share/mk/bsd.port.options.mk @@ -0,0 +1,8 @@ +# $FreeBSD$ + +USEOPTIONSMK= yes +INOPTIONSMK= yes + +.include <bsd.port.mk> + +.undef INOPTIONSMK diff --git a/share/mk/bsd.port.post.mk b/share/mk/bsd.port.post.mk new file mode 100644 index 0000000..d64dc12 --- /dev/null +++ b/share/mk/bsd.port.post.mk @@ -0,0 +1,7 @@ +# $FreeBSD$ + +AFTERPORTMK= yes + +.include <bsd.port.mk> + +.undef AFTERPORTMK diff --git a/share/mk/bsd.port.pre.mk b/share/mk/bsd.port.pre.mk new file mode 100644 index 0000000..dff464e --- /dev/null +++ b/share/mk/bsd.port.pre.mk @@ -0,0 +1,7 @@ +# $FreeBSD$ + +BEFOREPORTMK= yes + +.include <bsd.port.mk> + +.undef BEFOREPORTMK diff --git a/share/mk/bsd.port.subdir.mk b/share/mk/bsd.port.subdir.mk new file mode 100644 index 0000000..5115602 --- /dev/null +++ b/share/mk/bsd.port.subdir.mk @@ -0,0 +1,6 @@ +# $FreeBSD$ + +PORTSDIR?= /usr/ports +BSDPORTSUBDIRMK?= ${PORTSDIR}/Mk/bsd.port.subdir.mk + +.include "${BSDPORTSUBDIRMK}" diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk new file mode 100644 index 0000000..f4546dc --- /dev/null +++ b/share/mk/bsd.prog.mk @@ -0,0 +1,277 @@ +# from: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91 +# $FreeBSD$ + +.include <bsd.init.mk> + +.SUFFIXES: .out .o .c .cc .cpp .cxx .C .m .y .l .ln .s .S .asm + +# XXX The use of COPTS in modern makefiles is discouraged. +.if defined(COPTS) +CFLAGS+=${COPTS} +.endif + +.if ${MK_ASSERT_DEBUG} == "no" +CFLAGS+= -DNDEBUG +NO_WERROR= +.endif + +.if defined(DEBUG_FLAGS) +CFLAGS+=${DEBUG_FLAGS} +CXXFLAGS+=${DEBUG_FLAGS} + +.if ${MK_CTF} != "no" && ${DEBUG_FLAGS:M-g} != "" +CTFFLAGS+= -g +.endif +.endif + +.if defined(PROG_CXX) +PROG= ${PROG_CXX} +.endif + +.if defined(PROG) && target(${PROG}) +MK_DEBUG_FILES= no +.elif !empty(LDFLAGS:M-Wl,*--oformat,*) || !empty(LDFLAGS:M-static) +MK_DEBUG_FILES= no +.endif + +.if defined(CRUNCH_CFLAGS) +CFLAGS+=${CRUNCH_CFLAGS} +.else +.if ${MK_DEBUG_FILES} != "no" && empty(DEBUG_FLAGS:M-g) && \ + empty(DEBUG_FLAGS:M-gdwarf-*) +CFLAGS+= -g +CTFFLAGS+= -g +.endif +.endif + +.if !defined(DEBUG_FLAGS) +STRIP?= -s +.endif + +.if defined(NO_SHARED) && (${NO_SHARED} != "no" && ${NO_SHARED} != "NO") +LDFLAGS+= -static +.endif + +.if ${MK_DEBUG_FILES} != "no" +PROG_FULL=${PROG}.full +# Use ${DEBUGDIR} for base system debug files, else .debug subdirectory +.if defined(BINDIR) && (\ + ${BINDIR} == "/bin" ||\ + ${BINDIR} == "/libexec" ||\ + ${BINDIR} == "/sbin" ||\ + ${BINDIR:C%/usr/(bin|bsdinstall|games|libexec|lpr|sendmail|sm.bin|sbin)(/.*)?%/usr/bin%} == "/usr/bin"\ + ) +DEBUGFILEDIR= ${DEBUGDIR}${BINDIR} +.else +DEBUGFILEDIR?= ${BINDIR}/.debug +DEBUGMKDIR= +.endif +.else +PROG_FULL= ${PROG} +.endif + +.if defined(PROG) +PROGNAME?= ${PROG} + +.if defined(SRCS) + +OBJS+= ${SRCS:N*.h:R:S/$/.o/g} + +.if target(beforelinking) +beforelinking: ${OBJS} +${PROG_FULL}: beforelinking +.endif +${PROG_FULL}: ${OBJS} +.if defined(PROG_CXX) + ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} +.else + ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} +.endif +.if ${MK_CTF} != "no" + ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS} +.endif + +.else # !defined(SRCS) + +.if !target(${PROG}) +.if defined(PROG_CXX) +SRCS= ${PROG}.cc +.else +SRCS= ${PROG}.c +.endif + +# Always make an intermediate object file because: +# - it saves time rebuilding when only the library has changed +# - the name of the object gets put into the executable symbol table instead of +# the name of a variable temporary object. +# - it's useful to keep objects around for crunching. +OBJS+= ${PROG}.o + +.if target(beforelinking) +beforelinking: ${OBJS} +${PROG_FULL}: beforelinking +.endif +${PROG_FULL}: ${OBJS} +.if defined(PROG_CXX) + ${CXX} ${CXXFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} +.else + ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${OBJS} ${LDADD} +.endif +.if ${MK_CTF} != "no" + ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS} +.endif +.endif # !target(${PROG}) + +.endif # !defined(SRCS) + +.if ${MK_DEBUG_FILES} != "no" +${PROG}: ${PROG_FULL} ${PROGNAME}.debug + ${OBJCOPY} --strip-debug --add-gnu-debuglink=${PROGNAME}.debug \ + ${PROG_FULL} ${.TARGET} + +${PROGNAME}.debug: ${PROG_FULL} + ${OBJCOPY} --only-keep-debug ${PROG_FULL} ${.TARGET} +.endif + +.if ${MK_MAN} != "no" && !defined(MAN) && \ + !defined(MAN1) && !defined(MAN2) && !defined(MAN3) && \ + !defined(MAN4) && !defined(MAN5) && !defined(MAN6) && \ + !defined(MAN7) && !defined(MAN8) && !defined(MAN9) +MAN= ${PROG}.1 +MAN1= ${MAN} +.endif +.endif # defined(PROG) + +all: objwarn ${PROG} ${SCRIPTS} +.if ${MK_MAN} != "no" +all: _manpages +.endif + +.if defined(PROG) +CLEANFILES+= ${PROG} +.if ${MK_DEBUG_FILES} != "no" +CLEANFILES+= ${PROG_FULL} ${PROGNAME}.debug +.endif +.endif + +.if defined(OBJS) +CLEANFILES+= ${OBJS} +.endif + +.include <bsd.libnames.mk> + +.if defined(PROG) +_EXTRADEPEND: +.if defined(LDFLAGS) && !empty(LDFLAGS:M-nostdlib) +.if defined(DPADD) && !empty(DPADD) + echo ${PROG}: ${DPADD} >> ${DEPENDFILE} +.endif +.else + echo ${PROG}: ${LIBC} ${DPADD} >> ${DEPENDFILE} +.if defined(PROG_CXX) +.if !empty(CXXFLAGS:M-stdlib=libc++) + echo ${PROG}: ${LIBCPLUSPLUS} >> ${DEPENDFILE} +.else + echo ${PROG}: ${LIBSTDCPLUSPLUS} >> ${DEPENDFILE} +.endif +.endif +.endif +.endif + +.if !target(install) + +.if defined(PRECIOUSPROG) +.if !defined(NO_FSCHG) +INSTALLFLAGS+= -fschg +.endif +INSTALLFLAGS+= -S +.endif + +_INSTALLFLAGS:= ${INSTALLFLAGS} +.for ie in ${INSTALLFLAGS_EDIT} +_INSTALLFLAGS:= ${_INSTALLFLAGS${ie}} +.endfor + +.if !target(realinstall) && !defined(INTERNALPROG) +realinstall: _proginstall +.ORDER: beforeinstall _proginstall +_proginstall: +.if defined(PROG) + ${INSTALL} ${STRIP} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ + ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${BINDIR}/${PROGNAME} +.if ${MK_DEBUG_FILES} != "no" +.if defined(DEBUGMKDIR) + ${INSTALL} -T debug -d ${DESTDIR}${DEBUGFILEDIR} +.endif + ${INSTALL} -T debug -o ${BINOWN} -g ${BINGRP} -m ${DEBUGMODE} \ + ${PROGNAME}.debug ${DESTDIR}${DEBUGFILEDIR}/${PROGNAME}.debug +.endif +.endif +.endif # !target(realinstall) + +.if defined(SCRIPTS) && !empty(SCRIPTS) +realinstall: _scriptsinstall +.ORDER: beforeinstall _scriptsinstall + +SCRIPTSDIR?= ${BINDIR} +SCRIPTSOWN?= ${BINOWN} +SCRIPTSGRP?= ${BINGRP} +SCRIPTSMODE?= ${BINMODE} + +.for script in ${SCRIPTS} +.if defined(SCRIPTSNAME) +SCRIPTSNAME_${script:T}?= ${SCRIPTSNAME} +.else +SCRIPTSNAME_${script:T}?= ${script:T:R} +.endif +SCRIPTSDIR_${script:T}?= ${SCRIPTSDIR} +SCRIPTSOWN_${script:T}?= ${SCRIPTSOWN} +SCRIPTSGRP_${script:T}?= ${SCRIPTSGRP} +SCRIPTSMODE_${script:T}?= ${SCRIPTSMODE} +_scriptsinstall: _SCRIPTSINS_${script:T} +_SCRIPTSINS_${script:T}: ${script} + ${INSTALL} -o ${SCRIPTSOWN_${.ALLSRC:T}} \ + -g ${SCRIPTSGRP_${.ALLSRC:T}} -m ${SCRIPTSMODE_${.ALLSRC:T}} \ + ${.ALLSRC} \ + ${DESTDIR}${SCRIPTSDIR_${.ALLSRC:T}}/${SCRIPTSNAME_${.ALLSRC:T}} +.endfor +.endif + +NLSNAME?= ${PROG} +.include <bsd.nls.mk> + +.include <bsd.files.mk> +.include <bsd.incs.mk> +.include <bsd.links.mk> + +.if ${MK_MAN} != "no" +realinstall: _maninstall +.ORDER: beforeinstall _maninstall +.endif + +.endif + +.if !target(lint) +lint: ${SRCS:M*.c} +.if defined(PROG) + ${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} ${.ALLSRC} +.endif +.endif + +.if ${MK_MAN} != "no" +.include <bsd.man.mk> +.endif + +.include <bsd.dep.mk> + +.if defined(PROG) && !exists(${.OBJDIR}/${DEPENDFILE}) +${OBJS}: ${SRCS:M*.h} +.endif + +.include <bsd.obj.mk> + +.include <bsd.sys.mk> + +.if defined(PORTNAME) +.include <bsd.pkg.mk> +.endif diff --git a/share/mk/bsd.progs.mk b/share/mk/bsd.progs.mk new file mode 100644 index 0000000..3262004 --- /dev/null +++ b/share/mk/bsd.progs.mk @@ -0,0 +1,91 @@ +# $FreeBSD$ +# $Id: progs.mk,v 1.11 2012/11/06 17:18:54 sjg Exp $ +# +# @(#) Copyright (c) 2006, Simon J. Gerraty +# +# This file is provided in the hope that it will +# be of use. There is absolutely NO WARRANTY. +# Permission to copy, redistribute or otherwise +# use this file is hereby granted provided that +# the above copyright notice and this notice are +# left intact. +# +# Please send copies of changes and bug-fixes to: +# sjg@crufty.net +# + +.MAIN: all + +.if defined(PROGS) + +# In meta mode, we can capture dependenices for _one_ of the progs. +# if makefile doesn't nominate one, we use the first. +.ifndef UPDATE_DEPENDFILE_PROG +UPDATE_DEPENDFILE_PROG = ${PROGS:[1]} +.export UPDATE_DEPENDFILE_PROG +.endif + +.ifndef PROG +# They may have asked us to build just one +.for t in ${PROGS} +.if make($t) +PROG ?= $t +.endif +.endfor +.endif + +.if defined(PROG) +# just one of many +PROG_VARS += BINDIR CFLAGS CPPFLAGS CXXFLAGS DPADD DPLIBS LDADD MAN SRCS +.for v in ${PROG_VARS:O:u} +.if defined(${v}.${PROG}) +$v += ${${v}_${PROG}:U${${v}.${PROG}}} +.endif +.endfor + +# for meta mode, there can be only one! +.if ${PROG} == ${UPDATE_DEPENDFILE_PROG:Uno} +UPDATE_DEPENDFILE ?= yes +.endif +UPDATE_DEPENDFILE ?= NO + +# ensure that we don't clobber each other's dependencies +DEPENDFILE?= .depend.${PROG} +# prog.mk will do the rest +.else +all: ${PROGS} + +# We cannot capture dependencies for meta mode here +UPDATE_DEPENDFILE = NO +# nor can we safely run in parallel. +.NOTPARALLEL: +.endif +.endif + +# handle being called [bsd.]progs.mk +.include <${.PARSEFILE:S,progs,prog,}> + +.ifndef PROG +# tell progs.mk we might want to install things +PROGS_TARGETS+= cleandepend cleandir cleanobj depend install + +.for p in ${PROGS} +.if defined(PROGS_CXX) && !empty(PROGS_CXX:M$p) +# bsd.prog.mk may need to know this +x.$p= PROG_CXX=$p +.endif + +$p ${p}_p: .PHONY .MAKE + (cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} PROG=$p ${x.$p}) + +.for t in ${PROGS_TARGETS:O:u} +$p.$t: .PHONY .MAKE + (cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} PROG=$p ${x.$p} ${@:E}) +.endfor +.endfor + +.for t in ${PROGS_TARGETS:O:u} +$t: ${PROGS:%=%.$t} +.endfor + +.endif diff --git a/share/mk/bsd.snmpmod.mk b/share/mk/bsd.snmpmod.mk new file mode 100644 index 0000000..552f936 --- /dev/null +++ b/share/mk/bsd.snmpmod.mk @@ -0,0 +1,27 @@ +# $FreeBSD$ + +INCSDIR= ${INCLUDEDIR}/bsnmp + +SHLIB_NAME= snmp_${MOD}.so.${SHLIB_MAJOR} +SRCS+= ${MOD}_oid.h ${MOD}_tree.c ${MOD}_tree.h +CLEANFILES+= ${MOD}_oid.h ${MOD}_tree.c ${MOD}_tree.h +CFLAGS+= -I. + +${MOD}_oid.h: ${MOD}_tree.def ${EXTRAMIBDEFS} ${EXTRAMIBSYMS} + cat ${.ALLSRC} | gensnmptree -e ${XSYM} > ${.TARGET} + +.ORDER: ${MOD}_tree.c ${MOD}_tree.h +${MOD}_tree.c ${MOD}_tree.h: ${MOD}_tree.def ${EXTRAMIBDEFS} + cat ${.ALLSRC} | gensnmptree -p ${MOD}_ + +.if defined(DEFS) +FILESGROUPS+= DEFS +DEFSDIR= ${SHAREDIR}/snmp/defs +.endif + +.if defined(BMIBS) +FILESGROUPS+= BMIBS +BMIBSDIR= ${SHAREDIR}/snmp/mibs +.endif + +.include <bsd.lib.mk> diff --git a/share/mk/bsd.subdir.mk b/share/mk/bsd.subdir.mk new file mode 100644 index 0000000..12dd4de --- /dev/null +++ b/share/mk/bsd.subdir.mk @@ -0,0 +1,99 @@ +# from: @(#)bsd.subdir.mk 5.9 (Berkeley) 2/1/91 +# $FreeBSD$ +# +# The include file <bsd.subdir.mk> contains the default targets +# for building subdirectories. +# +# For all of the directories listed in the variable SUBDIRS, the +# specified directory will be visited and the target made. There is +# also a default target which allows the command "make subdir" where +# subdir is any directory listed in the variable SUBDIRS. +# +# +# +++ variables +++ +# +# DISTRIBUTION Name of distribution. [base] +# +# SUBDIR A list of subdirectories that should be built as well. +# Each of the targets will execute the same target in the +# subdirectories. +# +# +++ targets +++ +# +# distribute: +# This is a variant of install, which will +# put the stuff into the right "distribution". +# +# afterinstall, all, all-man, beforeinstall, checkdpadd, clean, +# cleandepend, cleandir, cleanilinks depend, install, lint, +# maninstall, manlint, obj, objlink, realinstall, regress, tags +# + +.if !target(__<bsd.subdir.mk>__) +__<bsd.subdir.mk>__: + +.include <bsd.init.mk> + +DISTRIBUTION?= base +.if !target(distribute) +distribute: .MAKE +.for dist in ${DISTRIBUTION} + ${_+_}cd ${.CURDIR}; \ + ${MAKE} install -DNO_SUBDIR DESTDIR=${DISTDIR}/${dist} SHARED=copies +.endfor +.endif + +_SUBDIR: .USE .MAKE +.if defined(SUBDIR) && !empty(SUBDIR) && !defined(NO_SUBDIR) + @${_+_}set -e; for entry in ${SUBDIR}; do \ + if test -d ${.CURDIR}/$${entry}.${MACHINE_ARCH}; then \ + ${ECHODIR} "===> ${DIRPRFX}$${entry}.${MACHINE_ARCH} (${.TARGET:realinstall=install})"; \ + edir=$${entry}.${MACHINE_ARCH}; \ + cd ${.CURDIR}/$${edir}; \ + else \ + ${ECHODIR} "===> ${DIRPRFX}$$entry (${.TARGET:realinstall=install})"; \ + edir=$${entry}; \ + cd ${.CURDIR}/$${edir}; \ + fi; \ + ${MAKE} ${.TARGET:realinstall=install} \ + DIRPRFX=${DIRPRFX}$$edir/; \ + done +.endif + +${SUBDIR}: .PHONY .MAKE + ${_+_}@if test -d ${.TARGET}.${MACHINE_ARCH}; then \ + cd ${.CURDIR}/${.TARGET}.${MACHINE_ARCH}; \ + else \ + cd ${.CURDIR}/${.TARGET}; \ + fi; \ + ${MAKE} all + +.for __target in all all-man checkdpadd clean cleandepend cleandir \ + cleanilinks depend distribute lint maninstall manlint obj objlink \ + realinstall regress tags ${SUBDIR_TARGETS} +${__target}: _SUBDIR +.endfor + +.for __target in files includes +.for __stage in build install +${__stage}${__target}: +.if make(${__stage}${__target}) +${__stage}${__target}: _SUBDIR +.endif +.endfor +${__target}: .MAKE + ${_+_}set -e; cd ${.CURDIR}; ${MAKE} build${__target}; ${MAKE} install${__target} +.endfor + +.if !target(install) +.if !target(beforeinstall) +beforeinstall: +.endif +.if !target(afterinstall) +afterinstall: +.endif +install: beforeinstall realinstall afterinstall +.ORDER: beforeinstall realinstall afterinstall +.endif + +.endif diff --git a/share/mk/bsd.symver.mk b/share/mk/bsd.symver.mk new file mode 100644 index 0000000..7626274 --- /dev/null +++ b/share/mk/bsd.symver.mk @@ -0,0 +1,47 @@ +# $FreeBSD$ + +.if !target(__<bsd.symver.mk>__) +__<bsd.symver.mk>__: + +.include <bsd.init.mk> + +# Generate the version map given the version definitions +# and symbol maps. +.if ${MK_SYMVER} == "yes" && !empty(VERSION_DEF) && !empty(SYMBOL_MAPS) +# Find the awk script that generates the version map. +VERSION_GEN?= version_gen.awk +VERSION_MAP?= Version.map + +CLEANFILES+= ${VERSION_MAP} + +# Compute the make's -m path. +_mpath= +_oarg= +.for _arg in ${.MAKEFLAGS} +.if ${_oarg} == "-m" +_mpath+= ${_arg} +.endif +_oarg= ${_arg} +.endfor +_mpath+= /usr/share/mk + +# Look up ${VERSION_GEN} in ${_mpath}. +_vgen= +.for path in ${_mpath} +.if empty(_vgen) +.if exists(${path}/${VERSION_GEN}) +_vgen= ${path}/${VERSION_GEN} +.endif +.endif +.endfor +.if empty(_vgen) +.error ${VERSION_GEN} not found in the search path. +.endif + +# Run the symbol maps through the C preprocessor before passing +# them to the symbol version generator. +${VERSION_MAP}: ${VERSION_DEF} ${_vgen} ${SYMBOL_MAPS} + cat ${SYMBOL_MAPS} | ${CPP} - - \ + | awk -v vfile=${VERSION_DEF} -f ${_vgen} > ${.TARGET} +.endif # !empty(VERSION_DEF) && !empty(SYMBOL_MAPS) +.endif # !target(__<bsd.symver.mk>__) diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk new file mode 100644 index 0000000..72dfa61 --- /dev/null +++ b/share/mk/bsd.sys.mk @@ -0,0 +1,147 @@ +# $FreeBSD$ +# +# This file contains common settings used for building FreeBSD +# sources. + +# Enable various levels of compiler warning checks. These may be +# overridden (e.g. if using a non-gcc compiler) by defining NO_WARNS. + +# for GCC: http://gcc.gnu.org/onlinedocs/gcc-4.2.1/gcc/Warning-Options.html + +.include <bsd.compiler.mk> + +# the default is gnu99 for now +CSTD?= gnu99 + +.if ${CSTD} == "k&r" +CFLAGS+= -traditional +.elif ${CSTD} == "c89" || ${CSTD} == "c90" +CFLAGS+= -std=iso9899:1990 +.elif ${CSTD} == "c94" || ${CSTD} == "c95" +CFLAGS+= -std=iso9899:199409 +.elif ${CSTD} == "c99" +CFLAGS+= -std=iso9899:1999 +.else # CSTD +CFLAGS+= -std=${CSTD} +.endif # CSTD +.if !defined(NO_WARNS) +# -pedantic is problematic because it also imposes namespace restrictions +#CFLAGS+= -pedantic +.if defined(WARNS) +.if ${WARNS} >= 1 +CWARNFLAGS+= -Wsystem-headers +.if !defined(NO_WERROR) && (${COMPILER_TYPE} != "clang" \ + || !defined(NO_WERROR.clang)) +CWARNFLAGS+= -Werror +.endif # !NO_WERROR && (!CLANG || !NO_WERROR.clang) +.endif # WARNS >= 1 +.if ${WARNS} >= 2 +CWARNFLAGS+= -Wall -Wno-format-y2k +.endif # WARNS >= 2 +.if ${WARNS} >= 3 +CWARNFLAGS+= -W -Wno-unused-parameter -Wstrict-prototypes\ + -Wmissing-prototypes -Wpointer-arith +.endif # WARNS >= 3 +.if ${WARNS} >= 4 +CWARNFLAGS+= -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow\ + -Wunused-parameter +.if !defined(NO_WCAST_ALIGN) && (${COMPILER_TYPE} != "clang" \ + || !defined(NO_WCAST_ALIGN.clang)) +CWARNFLAGS+= -Wcast-align +.endif # !NO_WCAST_ALIGN && (!CLANG || !NO_WCAST_ALIGN.clang) +.endif # WARNS >= 4 +# BDECFLAGS +.if ${WARNS} >= 6 +CWARNFLAGS+= -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls\ + -Wold-style-definition +.if ${COMPILER_TYPE} == "clang" && !defined(EARLY_BUILD) && \ + !defined(NO_WMISSING_VARIABLE_DECLARATIONS) +CWARNFLAGS+= -Wmissing-variable-declarations +.endif +.endif # WARNS >= 6 +.if ${WARNS} >= 2 && ${WARNS} <= 4 +# XXX Delete -Wuninitialized by default for now -- the compiler doesn't +# XXX always get it right. +CWARNFLAGS+= -Wno-uninitialized +.endif # WARNS >=2 && WARNS <= 4 +CWARNFLAGS+= -Wno-pointer-sign +# Clang has more warnings enabled by default, and when using -Wall, so if WARNS +# is set to low values, these have to be disabled explicitly. +.if ${COMPILER_TYPE} == "clang" && !defined(EARLY_BUILD) +.if ${WARNS} <= 6 +CWARNFLAGS+= -Wno-empty-body -Wno-string-plus-int +.endif # WARNS <= 6 +.if ${WARNS} <= 3 +CWARNFLAGS+= -Wno-tautological-compare -Wno-unused-value\ + -Wno-parentheses-equality -Wno-unused-function -Wno-conversion +.endif # WARNS <= 3 +.if ${WARNS} <= 2 +CWARNFLAGS+= -Wno-switch -Wno-switch-enum -Wno-knr-promoted-parameter +.endif # WARNS <= 2 +.if ${WARNS} <= 1 +CWARNFLAGS+= -Wno-parentheses +.endif # WARNS <= 1 +.if defined(NO_WARRAY_BOUNDS) +CWARNFLAGS+= -Wno-array-bounds +.endif # NO_WARRAY_BOUNDS +.endif # CLANG +.endif # WARNS + +.if defined(FORMAT_AUDIT) +WFORMAT= 1 +.endif # FORMAT_AUDIT +.if defined(WFORMAT) +.if ${WFORMAT} > 0 +#CWARNFLAGS+= -Wformat-nonliteral -Wformat-security -Wno-format-extra-args +CWARNFLAGS+= -Wformat=2 -Wno-format-extra-args +.if ${COMPILER_TYPE} == "clang" && !defined(EARLY_BUILD) +.if ${WARNS} <= 3 +CWARNFLAGS+= -Wno-format-nonliteral +.endif # WARNS <= 3 +.endif # CLANG +.if !defined(NO_WERROR) && (${COMPILER_TYPE} != "clang" \ + || !defined(NO_WERROR.clang)) +CWARNFLAGS+= -Werror +.endif # !NO_WERROR && (!CLANG || !NO_WERROR.clang) +.endif # WFORMAT > 0 +.endif # WFORMAT +.if defined(NO_WFORMAT) || (${COMPILER_TYPE} == "clang" && defined(NO_WFORMAT.clang)) +CWARNFLAGS+= -Wno-format +.endif # NO_WFORMAT || (CLANG && NO_WFORMAT.clang) +.endif # !NO_WARNS + +.if defined(IGNORE_PRAGMA) +CWARNFLAGS+= -Wno-unknown-pragmas +.endif # IGNORE_PRAGMA + +.if ${COMPILER_TYPE} == "clang" && !defined(EARLY_BUILD) +CLANG_NO_IAS= -no-integrated-as +CLANG_OPT_SMALL= -mstack-alignment=8 -mllvm -inline-threshold=3\ + -mllvm -enable-load-pre=false -mllvm -simplifycfg-dup-ret +CFLAGS+= -Qunused-arguments +.endif # CLANG + +.if ${MK_SSP} != "no" && ${MACHINE_CPUARCH} != "ia64" && \ + ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips" +# Don't use -Wstack-protector as it breaks world with -Werror. +SSP_CFLAGS?= -fstack-protector +CFLAGS+= ${SSP_CFLAGS} +.endif # SSP && !IA64 && !ARM && !MIPS + +# Allow user-specified additional warning flags +CFLAGS+= ${CWARNFLAGS} + + +# Tell bmake not to mistake standard targets for things to be searched for +# or expect to ever be up-to-date. +PHONY_NOTMAIN = afterdepend afterinstall all beforedepend beforeinstall \ + beforelinking build build-tools buildfiles buildincludes \ + checkdpadd clean cleandepend cleandir cleanobj configure \ + depend dependall distclean distribute exe extract fetch \ + html includes install installfiles installincludes lint \ + obj objlink objs objwarn patch realall realdepend \ + realinstall regress subdir-all subdir-depend subdir-install \ + tags whereobj + +.PHONY: ${PHONY_NOTMAIN} +.NOTMAIN: ${PHONY_NOTMAIN} diff --git a/share/mk/bsd.test.mk b/share/mk/bsd.test.mk new file mode 100644 index 0000000..a75298f --- /dev/null +++ b/share/mk/bsd.test.mk @@ -0,0 +1,79 @@ +# $NetBSD: bsd.test.mk,v 1.21 2012/08/25 22:21:16 jmmv Exp $ +# $FreeBSD$ + +.include <bsd.init.mk> + +.if defined(TESTS_C) +PROGS+= ${TESTS_C} +.for _T in ${TESTS_C} +BINDIR.${_T}= ${TESTSDIR} +MAN.${_T}?= # empty +.endfor +.endif + +.if defined(TESTS_CXX) +PROGS_CXX+= ${TESTS_CXX} +PROGS+= ${TESTS_CXX} +.for _T in ${TESTS_CXX} +BINDIR.${_T}= ${TESTSDIR} +MAN.${_T}?= # empty +.endfor +.endif + +.if defined(TESTS_SH) +SCRIPTS+= ${TESTS_SH} +.for _T in ${TESTS_SH} +SCRIPTSDIR_${_T}= ${TESTSDIR} +.endfor +.endif + +TESTSBASE?= ${DESTDIR}/usr/tests + +# it is rare for test cases to have man pages +.if !defined(MAN) +WITHOUT_MAN=yes +.export WITHOUT_MAN +.endif + +# tell progs.mk we might want to install things +PROG_VARS+= BINDIR +PROGS_TARGETS+= install + +.if !empty(PROGS) || !empty(PROGS_CXX) || !empty(SCRIPTS) +.include <bsd.progs.mk> +.endif + +beforetest: .PHONY +.if defined(TESTSDIR) +.if ${TESTSDIR} == ${TESTSBASE} +# Forbid running from ${TESTSBASE}. It can cause false positives/negatives and +# it does not cover all the tests (e.g. it misses testing software in external). + @echo "*** Sorry, you cannot use make test from src/tests. Install the" + @echo "*** tests into their final location and run them from ${TESTSBASE}" + @false +.else + @echo "*** Using this test does not preclude you from running the tests" + @echo "*** installed in ${TESTSBASE}. This test run may raise false" + @echo "*** positives and/or false negatives." +.endif +.else + @echo "*** No TESTSDIR defined; nothing to do." + @false +.endif + @echo + +.if !target(realtest) +realtest: .PHONY + @echo "$@ not defined; skipping" +.endif + +test: .PHONY +.ORDER: beforetest realtest +test: beforetest realtest + +.if target(aftertest) +.ORDER: realtest aftertest +test: aftertest +.endif + +.include <bsd.obj.mk> diff --git a/share/mk/sys.mk b/share/mk/sys.mk new file mode 100644 index 0000000..c534cea --- /dev/null +++ b/share/mk/sys.mk @@ -0,0 +1,358 @@ +# from: @(#)sys.mk 8.2 (Berkeley) 3/21/94 +# $FreeBSD$ + +unix ?= We run FreeBSD, not UNIX. +.FreeBSD ?= true + +.if !defined(%POSIX) +# +# MACHINE_CPUARCH defines a collection of MACHINE_ARCH. Machines with +# the same MACHINE_ARCH can run each other's binaries, so it necessarily +# has word size and endian swizzled in. However, support files for +# these machines often are shared amongst all combinations of size +# and/or endian. This is called MACHINE_CPU in NetBSD, but that's used +# for something different in FreeBSD. +# +MACHINE_CPUARCH=${MACHINE_ARCH:C/mips(n32|64)?(el)?/mips/:C/arm(v6)?(eb)?/arm/:C/powerpc64/powerpc/} +.endif + +# Set any local definitions first. Place this early, but it needs +# MACHINE_CPUARCH to be defined. +.sinclude <local.sys.mk> + +# If the special target .POSIX appears (without prerequisites or +# commands) before the first noncomment line in the makefile, make shall +# process the makefile as specified by the Posix 1003.2 specification. +# make(1) sets the special macro %POSIX in this case (to the actual +# value "1003.2", for what it's worth). +# +# The rules below use this macro to distinguish between Posix-compliant +# and default behaviour. + +.if defined(%POSIX) +.SUFFIXES: .o .c .y .l .a .sh .f +.else +.SUFFIXES: .out .a .ln .o .c .cc .cpp .cxx .C .m .F .f .e .r .y .l .S .asm .s .cl .p .h .sh +.endif + +AR ?= ar +.if defined(%POSIX) +ARFLAGS ?= -rv +.else +ARFLAGS ?= cru +.endif +RANLIB ?= ranlib + +AS ?= as +AFLAGS ?= +ACFLAGS ?= + +.if defined(%POSIX) +CC ?= c89 +CFLAGS ?= -O +.else +CC ?= cc +.if ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "mips" +CFLAGS ?= -O -pipe +.else +CFLAGS ?= -O2 -pipe +.endif +.if defined(NO_STRICT_ALIASING) +CFLAGS += -fno-strict-aliasing +.endif +.endif +PO_CFLAGS ?= ${CFLAGS} + +# C Type Format data is required for DTrace +CTFFLAGS ?= -L VERSION + +CTFCONVERT ?= ctfconvert +CTFMERGE ?= ctfmerge +DTRACE ?= dtrace +.if defined(CFLAGS) && (${CFLAGS:M-g} != "") +CTFFLAGS += -g +.else +# XXX: What to do here? Is removing the CFLAGS part completely ok here? +# For now comment it out to not compile with -g unconditionally. +#CFLAGS += -g +.endif + +CXX ?= c++ +CXXFLAGS ?= ${CFLAGS:N-std=*:N-Wnested-externs:N-W*-prototypes:N-Wno-pointer-sign:N-Wold-style-definition} +PO_CXXFLAGS ?= ${CXXFLAGS} + +CPP ?= cpp + +.if empty(.MAKEFLAGS:M-s) +ECHO ?= echo +ECHODIR ?= echo +.else +ECHO ?= true +.if ${.MAKEFLAGS:M-s} == "-s" +ECHODIR ?= echo +.else +ECHODIR ?= true +.endif +.endif + +.if defined(.PARSEDIR) +# _+_ appears to be a workaround for the special src .MAKE not working. +# setting it to + interferes with -N +_+_ ?= +.elif !empty(.MAKEFLAGS:M-n) && ${.MAKEFLAGS:M-n} == "-n" +# the check above matches only a single -n, so -n -n will result +# in _+_ = + +_+_ ?= +.else +_+_ ?= + +.endif + +.if defined(%POSIX) +FC ?= fort77 +FFLAGS ?= -O 1 +.else +FC ?= f77 +FFLAGS ?= -O +.endif +EFLAGS ?= + +INSTALL ?= install + +LEX ?= lex +LFLAGS ?= + +LD ?= ld +LDFLAGS ?= + +LINT ?= lint +LINTFLAGS ?= -cghapbx +LINTKERNFLAGS ?= ${LINTFLAGS} +LINTOBJFLAGS ?= -cghapbxu -i +LINTOBJKERNFLAGS?= ${LINTOBJFLAGS} +LINTLIBFLAGS ?= -cghapbxu -C ${LIB} + +MAKE ?= make + +.if !defined(%POSIX) +NM ?= nm + +OBJC ?= cc +OBJCFLAGS ?= ${OBJCINCLUDES} ${CFLAGS} -Wno-import + +OBJCOPY ?= objcopy + +PC ?= pc +PFLAGS ?= + +RC ?= f77 +RFLAGS ?= +.endif + +SHELL ?= sh + +YACC ?= yacc +.if defined(%POSIX) +YFLAGS ?= +.else +YFLAGS ?= -d +.endif + +.if defined(%POSIX) + +# Posix 1003.2 mandated rules +# +# Quoted directly from the Posix 1003.2 draft, only the macros +# $@, $< and $* have been replaced by ${.TARGET}, ${.IMPSRC}, and +# ${.PREFIX}, resp. + +# SINGLE SUFFIX RULES +.c: + ${CC} ${CFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC} + ${CTFCONVERT_CMD} + +.f: + ${FC} ${FFLAGS} ${LDFLAGS} -o ${.TARGET} ${.IMPSRC} + ${CTFCONVERT_CMD} + +.sh: + cp -f ${.IMPSRC} ${.TARGET} + chmod a+x ${.TARGET} + +# DOUBLE SUFFIX RULES + +.c.o: + ${CC} ${CFLAGS} -c ${.IMPSRC} + ${CTFCONVERT_CMD} + +.f.o: + ${FC} ${FFLAGS} -c ${.IMPSRC} + ${CTFCONVERT_CMD} + +.y.o: + ${YACC} ${YFLAGS} ${.IMPSRC} + ${CC} ${CFLAGS} -c y.tab.c + rm -f y.tab.c + mv y.tab.o ${.TARGET} + ${CTFCONVERT_CMD} + +.l.o: + ${LEX} ${LFLAGS} ${.IMPSRC} + ${CC} ${CFLAGS} -c lex.yy.c + rm -f lex.yy.c + mv lex.yy.o ${.TARGET} + ${CTFCONVERT_CMD} + +.y.c: + ${YACC} ${YFLAGS} ${.IMPSRC} + mv y.tab.c ${.TARGET} + +.l.c: + ${LEX} ${LFLAGS} ${.IMPSRC} + mv lex.yy.c ${.TARGET} + +.c.a: + ${CC} ${CFLAGS} -c ${.IMPSRC} + ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o + rm -f ${.PREFIX}.o + +.f.a: + ${FC} ${FFLAGS} -c ${.IMPSRC} + ${AR} ${ARFLAGS} ${.TARGET} ${.PREFIX}.o + rm -f ${.PREFIX}.o + +.else + +# non-Posix rule set + +.sh: + cp -fp ${.IMPSRC} ${.TARGET} + chmod a+x ${.TARGET} + +.c.ln: + ${LINT} ${LINTOBJFLAGS} ${CFLAGS:M-[DIU]*} ${.IMPSRC} || \ + touch ${.TARGET} + +.cc.ln .C.ln .cpp.ln .cxx.ln: + ${LINT} ${LINTOBJFLAGS} ${CXXFLAGS:M-[DIU]*} ${.IMPSRC} || \ + touch ${.TARGET} + +.c: + ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} + ${CTFCONVERT_CMD} + +.c.o: + ${CC} ${CFLAGS} -c ${.IMPSRC} + ${CTFCONVERT_CMD} + +.cc .cpp .cxx .C: + ${CXX} ${CXXFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} + +.cc.o .cpp.o .cxx.o .C.o: + ${CXX} ${CXXFLAGS} -c ${.IMPSRC} + +.m.o: + ${OBJC} ${OBJCFLAGS} -c ${.IMPSRC} + ${CTFCONVERT_CMD} + +.p.o: + ${PC} ${PFLAGS} -c ${.IMPSRC} + ${CTFCONVERT_CMD} + +.e .r .F .f: + ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} \ + -o ${.TARGET} + +.e.o .r.o .F.o .f.o: + ${FC} ${RFLAGS} ${EFLAGS} ${FFLAGS} -c ${.IMPSRC} + +.S.o: + ${CC} ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} + ${CTFCONVERT_CMD} + +.asm.o: + ${CC} -x assembler-with-cpp ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} + ${CTFCONVERT_CMD} + +.s.o: + ${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC} + ${CTFCONVERT_CMD} + +# XXX not -j safe +.y.o: + ${YACC} ${YFLAGS} ${.IMPSRC} + ${CC} ${CFLAGS} -c y.tab.c -o ${.TARGET} + rm -f y.tab.c + ${CTFCONVERT_CMD} + +.l.o: + ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c + ${CC} ${CFLAGS} -c ${.PREFIX}.tmp.c -o ${.TARGET} + rm -f ${.PREFIX}.tmp.c + ${CTFCONVERT_CMD} + +# XXX not -j safe +.y.c: + ${YACC} ${YFLAGS} ${.IMPSRC} + mv y.tab.c ${.TARGET} + +.l.c: + ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.TARGET} + +.s.out .c.out .o.out: + ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET} + ${CTFCONVERT_CMD} + +.f.out .F.out .r.out .e.out: + ${FC} ${EFLAGS} ${RFLAGS} ${FFLAGS} ${LDFLAGS} ${.IMPSRC} \ + ${LDLIBS} -o ${.TARGET} + rm -f ${.PREFIX}.o + ${CTFCONVERT_CMD} + +# XXX not -j safe +.y.out: + ${YACC} ${YFLAGS} ${.IMPSRC} + ${CC} ${CFLAGS} ${LDFLAGS} y.tab.c ${LDLIBS} -ly -o ${.TARGET} + rm -f y.tab.c + ${CTFCONVERT_CMD} + +.l.out: + ${LEX} -t ${LFLAGS} ${.IMPSRC} > ${.PREFIX}.tmp.c + ${CC} ${CFLAGS} ${LDFLAGS} ${.PREFIX}.tmp.c ${LDLIBS} -ll -o ${.TARGET} + rm -f ${.PREFIX}.tmp.c + ${CTFCONVERT_CMD} + +# FreeBSD build pollution. Hide it in the non-POSIX part of the ifdef. +__MAKE_CONF?=/etc/make.conf +.if exists(${__MAKE_CONF}) +.include "${__MAKE_CONF}" +.endif + +.if defined(__MAKE_SHELL) && !empty(__MAKE_SHELL) +SHELL= ${__MAKE_SHELL} +.SHELL: path=${__MAKE_SHELL} +.endif + +# Default executable format +# XXX hint for bsd.port.mk +OBJFORMAT?= elf + +# Tell bmake to expand -V VAR by default +.MAKE.EXPAND_VARIABLES= yes + +# Tell bmake the makefile preference +.MAKE.MAKEFILE_PREFERENCE= BSDmakefile makefile Makefile + +.if !defined(.PARSEDIR) +# We are not bmake, which is more aggressive about searching .PATH +# It is sometime necessary to curb its enthusiasm with .NOPATH +# The following allows us to quietly ignore .NOPATH when not using bmake. +.NOTMAIN: .NOPATH +.NOPATH: + +# Toggle on warnings +.WARN: dirsyntax +.endif + +.endif + +.include <bsd.cpu.mk> diff --git a/share/mk/version_gen.awk b/share/mk/version_gen.awk new file mode 100644 index 0000000..93fbc4f --- /dev/null +++ b/share/mk/version_gen.awk @@ -0,0 +1,249 @@ +# +# Copyright (C) 2006 Daniel M. Eischen. 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 AUTHOR 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 AUTHOR 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. +# +# $FreeBSD$ +# + +# +# Make a list of all the library versions listed in the master file. +# +# versions[] - array indexed by version name, contains number +# of symbols (+ 1) found for each version. +# successors[] - array index by version name, contains successor +# version name. +# symbols[][] - array index by [version name, symbol index], contains +# names of symbols defined for each version. +# names[] - array index is symbol name and value is its first version seen, +# used to check for duplicate symbols and warn about them. +# +BEGIN { + brackets = 0; + errors = warns = 0; + version_count = 0; + current_version = ""; + stderr = "/dev/stderr"; + while (getline < vfile) { + # Strip comments. + sub("#.*$", "", $0); + + # Strip leading and trailing whitespace. + sub("^[ \t]+", "", $0); + sub("[ \t]+$", "", $0); + + if (/^[a-zA-Z0-9._]+[ \t]*{$/) { + # Strip brace. + sub("{", "", $1); + brackets++; + symver = $1; + versions[symver] = 1; + successors[symver] = ""; + generated[symver] = 0; + version_count++; + } + else if (/^}[ \t]*[a-zA-Z0-9._]+[ \t]*;$/) { + v = $1 != "}" ? $1 : $2; + # Strip brace. + sub("}", "", v); + # Strip semicolon. + sub(";", "", v); + if (symver == "") { + printf("File %s: Unmatched bracket.\n", + vfile) > stderr; + errors++; + } + else if (versions[v] != 1) { + printf("File %s: `%s' has unknown " \ + "successor `%s'.\n", + vfile, symver, v) > stderr; + errors++; + } + else + successors[symver] = v; + brackets--; + } + else if (/^}[ \t]*;$/) { + if (symver == "") { + printf("File %s: Unmatched bracket.\n", + vfile) > stderr; + errors++; + } + # No successor + brackets--; + } + else if (/^}$/) { + printf("File %s: Missing final semicolon.\n", + vfile) > stderr; + errors++; + } + else if (/^$/) + ; # Ignore blank lines. + else { + printf("File %s: Unknown directive: `%s'.\n", + vfile, $0) > stderr; + errors++; + } + } + brackets = 0; +} + +{ + # Set meaningful filename for diagnostics. + filename = FILENAME != "" ? FILENAME : "<stdin>"; + + # Delete comments, preceding and trailing whitespace, then + # consume blank lines. + sub("#.*$", "", $0); + sub("^[ \t]+", "", $0); + sub("[ \t]+$", "", $0); + if ($0 == "") + next; +} + +/^[a-zA-Z0-9._]+[ \t]*{$/ { + # Strip bracket from version name. + sub("{", "", $1); + if (current_version != "") { + printf("File %s, line %d: Illegal nesting detected.\n", + filename, FNR) > stderr; + errors++; + } + else if (versions[$1] == 0) { + printf("File %s, line %d: Undefined " \ + "library version `%s'.\n", filename, FNR, $1) > stderr; + errors++; + # Remove this entry from the versions. + delete versions[$1]; + } + else + current_version = $1; + brackets++; + next; +} + +/^[a-zA-Z0-9._]+[ \t]*;$/ { + # Strip semicolon. + sub(";", "", $1); + if (current_version != "") { + count = versions[current_version]; + versions[current_version]++; + symbols[current_version, count] = $1; + if ($1 in names && names[$1] != current_version) { + # + # A graver case when a dup symbol appears under + # different versions in the map. That can result + # in subtle problems with the library later. + # + printf("File %s, line %d: Duplicated symbol `%s' " \ + "in version `%s', first seen in `%s'. " \ + "Did you forget to move it to ObsoleteVersions?\n", + filename, FNR, $1, + current_version, names[$1]) > stderr; + errors++; + } + else if (names[$1] == current_version) { + # + # A harmless case: a dup symbol with the same version. + # + printf("File %s, line %d: warning: " \ + "Duplicated symbol `%s' in version `%s'.\n", + filename, FNR, $1, current_version) > stderr; + warns++; + } + else + names[$1] = current_version; + } + else { + printf("File %s, line %d: Symbol `%s' outside version scope.\n", + filename, FNR, $1) > stderr; + errors++; + } + next; +} + +/^}[ \t]*;$/ { + brackets--; + if (brackets < 0) { + printf("File %s, line %d: Unmatched bracket.\n", + filename, FNR, $1) > stderr; + errors++; + brackets = 0; # Reset + } + current_version = ""; + next; +} + + +{ + printf("File %s, line %d: Unknown directive: `%s'.\n", + filename, FNR, $0) > stderr; + errors++; +} + +function print_version(v) +{ + # This function is recursive, so return if this version + # has already been printed. Otherwise, if there is an + # ancestral version, recursively print its symbols before + # printing the symbols for this version. + # + if (generated[v] == 1) + return; + if (successors[v] != "") + print_version(successors[v]); + + printf("%s {\n", v); + + # The version count is always one more that actual, + # so the loop ranges from 1 to n-1. + # + for (i = 1; i < versions[v]; i++) { + if (i == 1) + printf("global:\n"); + printf("\t%s;\n", symbols[v, i]); + } + + version_count--; + if (version_count == 0) { + printf("local:\n"); + printf("\t*;\n"); + } + if (successors[v] == "") + printf("};\n"); + else + printf("} %s;\n", successors[v]); + printf("\n"); + + generated[v] = 1; + } + +END { + if (errors) { + printf("%d error(s) total.\n", errors) > stderr; + exit(1); + } + # OK, no errors. + for (v in versions) { + print_version(v); + } +} |