bmake-20150418
This commit is contained in:
parent
e25a89e485
commit
bee1aeb88e
1735
20150418/ChangeLog
Normal file
1735
20150418/ChangeLog
Normal file
File diff suppressed because it is too large
Load Diff
165
20150418/FILES
Normal file
165
20150418/FILES
Normal file
@ -0,0 +1,165 @@
|
||||
ChangeLog
|
||||
FILES
|
||||
Makefile
|
||||
Makefile.config.in
|
||||
PSD.doc/Makefile
|
||||
PSD.doc/tutorial.ms
|
||||
README
|
||||
aclocal.m4
|
||||
arch.c
|
||||
bmake.1
|
||||
bmake.cat1
|
||||
boot-strap
|
||||
bsd.after-import.mk
|
||||
buf.c
|
||||
buf.h
|
||||
compat.c
|
||||
cond.c
|
||||
config.h.in
|
||||
configure
|
||||
configure.in
|
||||
dir.c
|
||||
dir.h
|
||||
dirname.c
|
||||
find_lib.sh
|
||||
for.c
|
||||
getopt.c
|
||||
hash.c
|
||||
hash.h
|
||||
install-sh
|
||||
job.c
|
||||
job.h
|
||||
lst.h
|
||||
lst.lib/Makefile
|
||||
lst.lib/lstAppend.c
|
||||
lst.lib/lstAtEnd.c
|
||||
lst.lib/lstAtFront.c
|
||||
lst.lib/lstClose.c
|
||||
lst.lib/lstConcat.c
|
||||
lst.lib/lstDatum.c
|
||||
lst.lib/lstDeQueue.c
|
||||
lst.lib/lstDestroy.c
|
||||
lst.lib/lstDupl.c
|
||||
lst.lib/lstEnQueue.c
|
||||
lst.lib/lstFind.c
|
||||
lst.lib/lstFindFrom.c
|
||||
lst.lib/lstFirst.c
|
||||
lst.lib/lstForEach.c
|
||||
lst.lib/lstForEachFrom.c
|
||||
lst.lib/lstInit.c
|
||||
lst.lib/lstInsert.c
|
||||
lst.lib/lstInt.h
|
||||
lst.lib/lstIsAtEnd.c
|
||||
lst.lib/lstIsEmpty.c
|
||||
lst.lib/lstLast.c
|
||||
lst.lib/lstMember.c
|
||||
lst.lib/lstNext.c
|
||||
lst.lib/lstOpen.c
|
||||
lst.lib/lstPrev.c
|
||||
lst.lib/lstRemove.c
|
||||
lst.lib/lstReplace.c
|
||||
lst.lib/lstSucc.c
|
||||
machine.sh
|
||||
main.c
|
||||
make-bootstrap.sh.in
|
||||
make-conf.h
|
||||
make.1
|
||||
make.c
|
||||
make.h
|
||||
make_malloc.c
|
||||
make_malloc.h
|
||||
makefile.in
|
||||
meta.c
|
||||
meta.h
|
||||
missing/sys/cdefs.h
|
||||
mkdeps.sh
|
||||
nonints.h
|
||||
os.sh
|
||||
parse.c
|
||||
pathnames.h
|
||||
ranlib.h
|
||||
realpath.c
|
||||
setenv.c
|
||||
sigcompat.c
|
||||
sprite.h
|
||||
str.c
|
||||
stresep.c
|
||||
strlcpy.c
|
||||
strlist.c
|
||||
strlist.h
|
||||
suff.c
|
||||
targ.c
|
||||
trace.c
|
||||
trace.h
|
||||
unit-tests/Makefile.in
|
||||
unit-tests/comment.exp
|
||||
unit-tests/comment.mk
|
||||
unit-tests/cond1.exp
|
||||
unit-tests/cond1.mk
|
||||
unit-tests/doterror.exp
|
||||
unit-tests/doterror.mk
|
||||
unit-tests/dotwait.exp
|
||||
unit-tests/dotwait.mk
|
||||
unit-tests/error.exp
|
||||
unit-tests/error.mk
|
||||
unit-tests/escape.exp
|
||||
unit-tests/escape.mk
|
||||
unit-tests/export-all.exp
|
||||
unit-tests/export-all.mk
|
||||
unit-tests/export-env.exp
|
||||
unit-tests/export-env.mk
|
||||
unit-tests/export.exp
|
||||
unit-tests/export.mk
|
||||
unit-tests/forloop.exp
|
||||
unit-tests/forloop.mk
|
||||
unit-tests/forsubst.exp
|
||||
unit-tests/forsubst.mk
|
||||
unit-tests/hash.exp
|
||||
unit-tests/hash.mk
|
||||
unit-tests/impsrc.exp
|
||||
unit-tests/impsrc.mk
|
||||
unit-tests/misc.exp
|
||||
unit-tests/misc.mk
|
||||
unit-tests/moderrs.exp
|
||||
unit-tests/moderrs.mk
|
||||
unit-tests/modmatch.exp
|
||||
unit-tests/modmatch.mk
|
||||
unit-tests/modmisc.exp
|
||||
unit-tests/modmisc.mk
|
||||
unit-tests/modorder.exp
|
||||
unit-tests/modorder.mk
|
||||
unit-tests/modts.exp
|
||||
unit-tests/modts.mk
|
||||
unit-tests/modword.exp
|
||||
unit-tests/modword.mk
|
||||
unit-tests/order.exp
|
||||
unit-tests/order.mk
|
||||
unit-tests/phony-end.exp
|
||||
unit-tests/phony-end.mk
|
||||
unit-tests/posix.exp
|
||||
unit-tests/posix.mk
|
||||
unit-tests/posix1.exp
|
||||
unit-tests/posix1.mk
|
||||
unit-tests/qequals.exp
|
||||
unit-tests/qequals.mk
|
||||
unit-tests/suffixes.exp
|
||||
unit-tests/suffixes.mk
|
||||
unit-tests/sunshcmd.exp
|
||||
unit-tests/sunshcmd.mk
|
||||
unit-tests/sysv.exp
|
||||
unit-tests/sysv.mk
|
||||
unit-tests/ternary.exp
|
||||
unit-tests/ternary.mk
|
||||
unit-tests/unexport-env.exp
|
||||
unit-tests/unexport-env.mk
|
||||
unit-tests/unexport.exp
|
||||
unit-tests/unexport.mk
|
||||
unit-tests/varcmd.exp
|
||||
unit-tests/varcmd.mk
|
||||
unit-tests/varmisc.exp
|
||||
unit-tests/varmisc.mk
|
||||
unit-tests/varshell.exp
|
||||
unit-tests/varshell.mk
|
||||
util.c
|
||||
var.c
|
||||
wait.h
|
221
20150418/Makefile
Normal file
221
20150418/Makefile
Normal file
@ -0,0 +1,221 @@
|
||||
# $Id: Makefile,v 1.36 2015/04/18 19:58:53 sjg Exp $
|
||||
|
||||
# Base version on src date
|
||||
MAKE_VERSION= 20150418
|
||||
|
||||
PROG= bmake
|
||||
|
||||
SRCS= \
|
||||
arch.c \
|
||||
buf.c \
|
||||
compat.c \
|
||||
cond.c \
|
||||
dir.c \
|
||||
for.c \
|
||||
hash.c \
|
||||
job.c \
|
||||
main.c \
|
||||
make.c \
|
||||
make_malloc.c \
|
||||
meta.c \
|
||||
parse.c \
|
||||
str.c \
|
||||
strlist.c \
|
||||
suff.c \
|
||||
targ.c \
|
||||
trace.c \
|
||||
util.c \
|
||||
var.c
|
||||
|
||||
# from lst.lib/
|
||||
SRCS+= \
|
||||
lstAppend.c \
|
||||
lstAtEnd.c \
|
||||
lstAtFront.c \
|
||||
lstClose.c \
|
||||
lstConcat.c \
|
||||
lstDatum.c \
|
||||
lstDeQueue.c \
|
||||
lstDestroy.c \
|
||||
lstDupl.c \
|
||||
lstEnQueue.c \
|
||||
lstFind.c \
|
||||
lstFindFrom.c \
|
||||
lstFirst.c \
|
||||
lstForEach.c \
|
||||
lstForEachFrom.c \
|
||||
lstInit.c \
|
||||
lstInsert.c \
|
||||
lstIsAtEnd.c \
|
||||
lstIsEmpty.c \
|
||||
lstLast.c \
|
||||
lstMember.c \
|
||||
lstNext.c \
|
||||
lstOpen.c \
|
||||
lstPrev.c \
|
||||
lstRemove.c \
|
||||
lstReplace.c \
|
||||
lstSucc.c
|
||||
|
||||
# this file gets generated by configure
|
||||
.-include "Makefile.config"
|
||||
|
||||
.if !empty(LIBOBJS)
|
||||
SRCS+= ${LIBOBJS:T:.o=.c}
|
||||
.endif
|
||||
|
||||
# just in case
|
||||
prefix?= /usr
|
||||
srcdir?= ${.CURDIR}
|
||||
|
||||
DEFAULT_SYS_PATH?= ${prefix}/share/mk
|
||||
|
||||
CPPFLAGS+= -DUSE_META
|
||||
CFLAGS+= ${CPPFLAGS}
|
||||
CFLAGS+= -D_PATH_DEFSYSPATH=\"${DEFAULT_SYS_PATH}\"
|
||||
CFLAGS+= -I. -I${srcdir} ${XDEFS} -DMAKE_NATIVE
|
||||
CFLAGS+= ${COPTS.${.ALLSRC:M*.c:T:u}}
|
||||
COPTS.main.c+= "-DMAKE_VERSION=\"${MAKE_VERSION}\""
|
||||
|
||||
# meta mode can be useful even without filemon
|
||||
FILEMON_H ?= /usr/include/dev/filemon/filemon.h
|
||||
.if exists(${FILEMON_H}) && ${FILEMON_H:T} == "filemon.h"
|
||||
COPTS.meta.c += -DHAVE_FILEMON_H -I${FILEMON_H:H}
|
||||
.endif
|
||||
|
||||
.PATH: ${srcdir}
|
||||
.PATH: ${srcdir}/lst.lib
|
||||
|
||||
.if make(obj) || make(clean)
|
||||
SUBDIR+= unit-tests
|
||||
.endif
|
||||
|
||||
# start-delete1 for bsd.after-import.mk
|
||||
# we skip a lot of this when building as part of FreeBSD etc.
|
||||
|
||||
# list of OS's which are derrived from BSD4.4
|
||||
BSD44_LIST= NetBSD FreeBSD OpenBSD DragonFly
|
||||
# we are...
|
||||
OS!= uname -s
|
||||
# are we 4.4BSD ?
|
||||
isBSD44:=${BSD44_LIST:M${OS}}
|
||||
|
||||
.if ${isBSD44} == ""
|
||||
MANTARGET= cat
|
||||
INSTALL?=${srcdir}/install-sh
|
||||
.if (${MACHINE} == "sun386")
|
||||
# even I don't have one of these anymore :-)
|
||||
CFLAGS+= -DPORTAR
|
||||
.elif (${MACHINE} != "sunos")
|
||||
SRCS+= sigcompat.c
|
||||
CFLAGS+= -DSIGNAL_FLAGS=SA_RESTART
|
||||
.endif
|
||||
.else
|
||||
MANTARGET?= man
|
||||
.endif
|
||||
|
||||
# turn this on by default - ignored if we are root
|
||||
WITH_INSTALL_AS_USER=
|
||||
|
||||
# suppress with -DWITHOUT_*
|
||||
OPTIONS_DEFAULT_YES+= \
|
||||
AUTOCONF_MK \
|
||||
INSTALL_MK \
|
||||
PROG_LINK
|
||||
|
||||
OPTIONS_DEFAULT_NO+= \
|
||||
PROG_VERSION
|
||||
|
||||
# process options now
|
||||
.include <own.mk>
|
||||
|
||||
.if ${MK_PROG_VERSION} == "yes"
|
||||
PROG_NAME= ${PROG}-${MAKE_VERSION}
|
||||
.if ${MK_PROG_LINK} == "yes"
|
||||
SYMLINKS+= ${PROG}-${MAKE_VERSION} ${BINDIR}/${PROG}
|
||||
.endif
|
||||
.endif
|
||||
|
||||
EXTRACT_MAN=no
|
||||
# end-delete1
|
||||
|
||||
MAN= ${PROG}.1
|
||||
MAN1= ${MAN}
|
||||
|
||||
.if (${PROG} != "make")
|
||||
CLEANFILES+= my.history
|
||||
.if make(${MAN}) || !exists(${srcdir}/${MAN})
|
||||
my.history: ${MAKEFILE}
|
||||
@(echo ".Nm"; \
|
||||
echo "is derived from NetBSD"; \
|
||||
echo ".Xr make 1 ."; \
|
||||
echo "It uses autoconf to facilitate portability to other platforms."; \
|
||||
echo ".Pp") > $@
|
||||
|
||||
.NOPATH: ${MAN}
|
||||
${MAN}: make.1 my.history
|
||||
@echo making $@
|
||||
@sed -e 's/^.Nx/NetBSD/' -e '/^.Nm/s/make/${PROG}/' \
|
||||
-e '/^.Sh HISTORY/rmy.history' \
|
||||
-e '/^.Sh HISTORY/,$$s,^.Nm,make,' ${srcdir}/make.1 > $@
|
||||
|
||||
all beforeinstall: ${MAN}
|
||||
_mfromdir=.
|
||||
.endif
|
||||
.endif
|
||||
|
||||
MANTARGET?= cat
|
||||
MANDEST?= ${MANDIR}/${MANTARGET}1
|
||||
|
||||
.if ${MANTARGET} == "cat"
|
||||
_mfromdir=${srcdir}
|
||||
.endif
|
||||
|
||||
.include <prog.mk>
|
||||
|
||||
CPPFLAGS+= -DMAKE_NATIVE -DHAVE_CONFIG_H
|
||||
COPTS.var.c += -Wno-cast-qual
|
||||
COPTS.job.c += -Wno-format-nonliteral
|
||||
COPTS.parse.c += -Wno-format-nonliteral
|
||||
COPTS.var.c += -Wno-format-nonliteral
|
||||
|
||||
# Force these
|
||||
SHAREDIR= ${SHAREDIR.bmake:U${prefix}/share}
|
||||
BINDIR= ${BINDIR.bmake:U${prefix}/bin}
|
||||
MANDIR= ${MANDIR.bmake:U${SHAREDIR}/man}
|
||||
|
||||
.if !exists(.depend)
|
||||
${OBJS}: config.h
|
||||
.endif
|
||||
|
||||
# make sure that MAKE_VERSION gets updated.
|
||||
main.o: ${SRCS} ${MAKEFILE}
|
||||
|
||||
# start-delete2 for bsd.after-import.mk
|
||||
.if ${MK_AUTOCONF_MK} == "yes"
|
||||
.include <autoconf.mk>
|
||||
.endif
|
||||
SHARE_MK?=${SHAREDIR}/mk
|
||||
MKSRC=${srcdir}/mk
|
||||
INSTALL?=${srcdir}/install-sh
|
||||
|
||||
.if ${MK_INSTALL_MK} == "yes"
|
||||
install: install-mk
|
||||
.endif
|
||||
|
||||
beforeinstall:
|
||||
test -d ${DESTDIR}${BINDIR} || ${INSTALL} -m 775 -d ${DESTDIR}${BINDIR}
|
||||
test -d ${DESTDIR}${MANDEST} || ${INSTALL} -m 775 -d ${DESTDIR}${MANDEST}
|
||||
|
||||
install-mk:
|
||||
.if exists(${MKSRC}/install-mk)
|
||||
test -d ${DESTDIR}${SHARE_MK} || ${INSTALL} -m 775 -d ${DESTDIR}${SHARE_MK}
|
||||
sh ${MKSRC}/install-mk -v -m 644 ${DESTDIR}${SHARE_MK}
|
||||
.else
|
||||
@echo need to unpack mk.tar.gz under ${srcdir} or set MKSRC; false
|
||||
.endif
|
||||
# end-delete2
|
||||
|
||||
# A simple unit-test driver to help catch regressions
|
||||
accept test:
|
||||
cd ${.CURDIR}/unit-tests && MAKEFLAGS= ${.MAKE} -r -m / TEST_MAKE=${TEST_MAKE:U${.OBJDIR}/${PROG:T}} ${.TARGET}
|
20
20150418/Makefile.config.in
Normal file
20
20150418/Makefile.config.in
Normal file
@ -0,0 +1,20 @@
|
||||
# things set by configure
|
||||
|
||||
prefix= @prefix@
|
||||
srcdir= @srcdir@
|
||||
CC?= @CC@
|
||||
MACHINE= @machine@
|
||||
MACHINE_ARCH= @machine_arch@
|
||||
DEFAULT_SYS_PATH= @default_sys_path@
|
||||
|
||||
CPPFLAGS+= @CPPFLAGS@
|
||||
CFLAGS+= ${CPPFLAGS} @DEFS@
|
||||
LDFLAGS= @LDFLAGS@
|
||||
LIBOBJS= @LIBOBJS@
|
||||
LDADD= @LIBS@
|
||||
USE_META= @use_meta@
|
||||
FILEMON_H= @filemon_h@
|
||||
BMAKE_PATH_MAX?= @bmake_path_max@
|
||||
# used if MAXPATHLEN not defined
|
||||
CPPFLAGS+= -DBMAKE_PATH_MAX=${BMAKE_PATH_MAX}
|
||||
|
10
20150418/PSD.doc/Makefile
Normal file
10
20150418/PSD.doc/Makefile
Normal file
@ -0,0 +1,10 @@
|
||||
# $NetBSD: Makefile,v 1.4 2014/07/05 19:22:43 dholland Exp $
|
||||
# @(#)Makefile 8.1 (Berkeley) 8/14/93
|
||||
|
||||
SECTION=reference/ref1
|
||||
ARTICLE=make
|
||||
SRCS= tutorial.ms
|
||||
MACROS= -ms
|
||||
EXTRAHTMLFILES=make1.png make2.png
|
||||
|
||||
.include <bsd.doc.mk>
|
3783
20150418/PSD.doc/tutorial.ms
Normal file
3783
20150418/PSD.doc/tutorial.ms
Normal file
File diff suppressed because it is too large
Load Diff
47
20150418/README
Normal file
47
20150418/README
Normal file
@ -0,0 +1,47 @@
|
||||
bmake
|
||||
|
||||
This directory contains a port of the BSD make tool (from NetBSD)
|
||||
I have run it on SunOS,Solaris,HP-UX,AIX,IRIX,FreeBSD and Linux.
|
||||
|
||||
Version 3 was re-worked from scratch to better facilitate
|
||||
importing newer make(1) versions from NetBSD. The original code base
|
||||
was NetBSD-1.0, so version 3 was built by doing a fresh import of the
|
||||
NetBSD-1.0 usr.bin/make, adding the autoconf and other portability
|
||||
patches to sync it with bmake v2, and then NetBSD's make
|
||||
of Feb 20, 2000 was imported and conflicts dealt with.
|
||||
NetBSD's make was again imported on June 6 and December 15, 2000.
|
||||
|
||||
In 2003 bmake switched to a date based version (first was 20030714)
|
||||
which generally represents the date it was last merged with NetBSD's
|
||||
make. Since then, NetBSD's make is imported within a week of any
|
||||
interesting changes, so that bmake tracks it very closely.
|
||||
|
||||
Building:
|
||||
|
||||
The preferred way to bootstrap bmake is:
|
||||
|
||||
./bmake/boot-strap
|
||||
|
||||
there are a number of args - most of which get passed to configure,
|
||||
eg.
|
||||
|
||||
./bmake/boot-strap --prefix=/opt
|
||||
|
||||
see the boot-strap script for details.
|
||||
|
||||
To make much use of bmake you will need the bsd.*.mk macros or my
|
||||
portable *.mk macros. See
|
||||
http://www.crufty.net/ftp/pub/sjg/mk.tar.gz
|
||||
which will be links to the latest versions.
|
||||
|
||||
On a non-BSD system, you would want to unpack mk[-YYYYmmdd].tar.gz in
|
||||
the same directory as bmake (so ./mk and ./bmake exist), and
|
||||
./bmake/boot-strap will do the rest.
|
||||
|
||||
If you want to do it all by hand then read boot-strap first to get the
|
||||
idea.
|
||||
|
||||
Even if you have an earlier version of bmake installed, use boot-strap
|
||||
to ensure that all goes well.
|
||||
|
||||
--sjg
|
77
20150418/aclocal.m4
vendored
Normal file
77
20150418/aclocal.m4
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
dnl RCSid:
|
||||
dnl $Id: aclocal.m4,v 1.5 2003/03/06 21:21:30 sjg Exp $
|
||||
dnl
|
||||
|
||||
dnl
|
||||
dnl AC_CHECK_HEADER_HAS(HEADER, PATTERN, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]))
|
||||
|
||||
AC_DEFUN(AC_CHECK_HEADER_HAS,
|
||||
[dnl first check if header exists and if so, see if it contains PATTERN
|
||||
ac_has_hdr=`echo "ac_cv_header_$1" | sed 'y%./+-%__p_%'`
|
||||
ac_has_it=`echo "ac_cv_header_$1"_$2 | sed 'y%./+-%__p_%'`
|
||||
if eval "test \"`echo x'$'$ac_has_hdr`\" = x"; then
|
||||
AC_CHECK_HEADER($1)
|
||||
fi
|
||||
if eval "test \"`echo '$'$ac_has_hdr`\" = yes"; then
|
||||
ac_x=HAVE_`echo "$1" | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
|
||||
AC_DEFINE_UNQUOTED($ac_x)
|
||||
AC_MSG_CHECKING([if $1 has $2])
|
||||
AC_CACHE_VAL($ac_has_it,
|
||||
[eval $ac_has_it=no
|
||||
AC_EGREP_HEADER($2, $1, eval "$ac_has_it=yes")])
|
||||
|
||||
if eval "test \"`echo '$'$ac_has_it`\" = yes"; then
|
||||
AC_MSG_RESULT(yes)
|
||||
ac_x=HAVE_`echo "$1"_$2 | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
|
||||
AC_DEFINE_UNQUOTED($ac_x)
|
||||
ifelse([$3], , :, [$3])
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
ifelse([$4], , , [$4
|
||||
])dnl
|
||||
fi
|
||||
fi
|
||||
])
|
||||
|
||||
dnl AC_EGREP(PATTERN, FILE, ACTION-IF-FOUND [,
|
||||
dnl ACTION-IF-NOT-FOUND])
|
||||
AC_DEFUN(AC_EGREP,
|
||||
[
|
||||
dnl Prevent m4 from eating character classes:
|
||||
changequote(, )dnl
|
||||
if egrep "$1" $2 >/dev/null 2>&1; then
|
||||
changequote([, ])dnl
|
||||
ifelse([$3], , :, [$3])
|
||||
ifelse([$4], , , [else
|
||||
$4
|
||||
])dnl
|
||||
fi
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl Test for __attribute__
|
||||
dnl
|
||||
|
||||
AC_DEFUN(AC_C___ATTRIBUTE__, [
|
||||
AC_MSG_CHECKING(for __attribute__)
|
||||
AC_CACHE_VAL(ac_cv___attribute__, [
|
||||
AC_TRY_COMPILE([
|
||||
#include <stdlib.h>
|
||||
],
|
||||
[
|
||||
static void foo(void) __attribute__ ((noreturn));
|
||||
|
||||
static void
|
||||
foo(void)
|
||||
{
|
||||
exit(1);
|
||||
}
|
||||
],
|
||||
ac_cv___attribute__=yes,
|
||||
ac_cv___attribute__=no)])
|
||||
if test "$ac_cv___attribute__" = "yes"; then
|
||||
AC_DEFINE(HAVE___ATTRIBUTE__, 1, [define if your compiler has __attribute__])
|
||||
fi
|
||||
AC_MSG_RESULT($ac_cv___attribute__)
|
||||
])
|
||||
|
1403
20150418/arch.c
Normal file
1403
20150418/arch.c
Normal file
File diff suppressed because it is too large
Load Diff
2279
20150418/bmake.1
Normal file
2279
20150418/bmake.1
Normal file
File diff suppressed because it is too large
Load Diff
1452
20150418/bmake.cat1
Normal file
1452
20150418/bmake.cat1
Normal file
File diff suppressed because it is too large
Load Diff
462
20150418/boot-strap
Executable file
462
20150418/boot-strap
Executable file
@ -0,0 +1,462 @@
|
||||
:
|
||||
# NAME:
|
||||
# boot-strap
|
||||
#
|
||||
# SYNOPSIS:
|
||||
# boot-strap ["options"]
|
||||
# boot-strap --prefix=/opt --install
|
||||
# boot-strap --prefix=$HOME --install-host-target -DWITH_PROG_VERSION
|
||||
# boot-strap ["options"] op=build
|
||||
# boot-strap ["options"] op=install
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# This script is used to configure/build bmake it builds for
|
||||
# each host-target in a different subdir to keep the src clean.
|
||||
# There is no requirement for an existing make(1).
|
||||
#
|
||||
# On successful completion if no '--install' flag is given,
|
||||
# it echos a command to do installation.
|
||||
#
|
||||
# The variable "op" defaults to 'all', and is affected by
|
||||
# '--install' flag as above.
|
||||
# Other values include:
|
||||
#
|
||||
# configure
|
||||
# Just run 'configure'
|
||||
#
|
||||
# build
|
||||
# If 'configure' has not been done, do it, then
|
||||
# run the build script, and finally 'test'.
|
||||
#
|
||||
# install
|
||||
# If 'build' has not been done, do it, 'test' then
|
||||
# install.
|
||||
#
|
||||
# clean
|
||||
# attempt to clean up
|
||||
#
|
||||
# test
|
||||
# run the unit-tests. Done automatically after 'build'
|
||||
# and before 'install'.
|
||||
#
|
||||
# The above are leveraged by a trivial makefile for the benefit
|
||||
# of those that have './configure; make; make install' baked
|
||||
# into them.
|
||||
#
|
||||
# Options:
|
||||
#
|
||||
# -c "rc"
|
||||
# Pick up settings from "rc".
|
||||
# We look for '.bmake-boot-strap.rc' before processing
|
||||
# options (unless SKIP_RC is set in environment).
|
||||
#
|
||||
# --share "share_dir"
|
||||
# Where to put man pages and mk files.
|
||||
# If $prefix ends in $HOST_TARGET, and $prefix/../share
|
||||
# exits, the default will be that rather than $prefix/share.
|
||||
#
|
||||
# --mksrc "mksrc"
|
||||
# Indicate where the mk files can be found.
|
||||
# Default is $Mydir/mk
|
||||
#
|
||||
# --install
|
||||
# If build and test work, run bmake install.
|
||||
# BINDIR=$prefix/bin
|
||||
# SHAREDIR=$prefix/share
|
||||
#
|
||||
# --install-host-target
|
||||
# As for '--install' but BINDIR=$prefix/$HOST_TARGET/bin
|
||||
# This is useful when $prefix/ is shared by multiple
|
||||
# machines.
|
||||
#
|
||||
# Flags relevant when installing:
|
||||
#
|
||||
# -DWITHOUT_INSTALL_MK
|
||||
# Skip installing mk files.
|
||||
# By default they will be installed to $prefix/share/mk
|
||||
#
|
||||
# -DWITH_PROG_VERSION
|
||||
# Install 'bmake' as 'bmake-$MAKE_VERSION'
|
||||
# A symlink will be made as 'bmake' unless
|
||||
# -DWITHOUT_PROG_LINK is set.
|
||||
#
|
||||
# Possibly useful configure_args:
|
||||
#
|
||||
# --without-meta
|
||||
# disable use of meta mode.
|
||||
#
|
||||
# --without-filemon
|
||||
# disable use of filemon(9) which is currently only
|
||||
# available for NetBSD and FreeBSD.
|
||||
#
|
||||
# --with-filemon="path/to/filemon.h"
|
||||
# enables use of filemon(9) by meta mode.
|
||||
#
|
||||
# --with-machine="machine"
|
||||
# set "machine" to override that determined by
|
||||
# machine.sh
|
||||
#
|
||||
# --with-force-machine="machine"
|
||||
# force "machine" even if uname(3) provides a value.
|
||||
#
|
||||
# --with-machine_arch="machine_arch"
|
||||
# set "machine_arch" to override that determined by
|
||||
# machine.sh
|
||||
#
|
||||
# --with-default-sys-path="syspath"
|
||||
# set an explicit default "syspath" which is where bmake
|
||||
# will look for sys.mk and friends.
|
||||
#
|
||||
# AUTHOR:
|
||||
# Simon J. Gerraty <sjg@crufty.net>
|
||||
|
||||
# RCSid:
|
||||
# $Id: boot-strap,v 1.45 2014/04/05 22:56:54 sjg Exp $
|
||||
#
|
||||
# @(#) Copyright (c) 2001 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
|
||||
#
|
||||
|
||||
Mydir=`dirname $0`
|
||||
. "$Mydir/os.sh"
|
||||
case "$Mydir" in
|
||||
/*) ;;
|
||||
*) Mydir=`cd "$Mydir" && 'pwd'`;;
|
||||
esac
|
||||
|
||||
Usage() {
|
||||
[ "$1" ] && echo "ERROR: $@" >&2
|
||||
echo "Usage:" >&2
|
||||
echo "$0 [--<configure_arg> ...][<prefix>][--install]" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
Error() {
|
||||
echo "ERROR: $@" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
source_rc() {
|
||||
rc="$1"; shift
|
||||
for d in ${*:-""}
|
||||
do
|
||||
r="${d:+$d/}$rc"
|
||||
[ -f "$r" -a -s "$r" ] || continue
|
||||
echo "NOTE: reading $r"
|
||||
. "$r"
|
||||
break
|
||||
done
|
||||
}
|
||||
|
||||
cmd_args="$@"
|
||||
|
||||
# clear some things from the environment that we care about
|
||||
unset MAKEOBJDIR MAKEOBJDIRPREFIX
|
||||
|
||||
# --install[-host-target] will set this
|
||||
INSTALL_PREFIX=
|
||||
# other things we pass to install step
|
||||
INSTALL_ARGS=
|
||||
CONFIGURE_ARGS=
|
||||
MAKESYSPATH=
|
||||
# pick a useful default prefix (for me at least ;-)
|
||||
for prefix in /opt/$HOST_TARGET "$HOME/$HOST_TARGET" /usr/pkg /usr/local ""
|
||||
do
|
||||
[ -d "${prefix:-.}" ] || continue
|
||||
case "$prefix" in
|
||||
*/$HOST_TARGET)
|
||||
p=`dirname $prefix`
|
||||
if [ -d $p/share ]; then
|
||||
INSTALL_BIN=$HOST_TARGET/bin
|
||||
prefix=$p
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
echo "NOTE: default prefix=$prefix ${INSTALL_BIN:+INSTALL_BIN=$INSTALL_BIN}"
|
||||
break
|
||||
done
|
||||
srcdir=$Mydir
|
||||
mksrc=$Mydir/mk
|
||||
objdir=
|
||||
quiet=:
|
||||
|
||||
${SKIP_RC:+:} source_rc .bmake-boot-strap.rc . "$Mydir/.." "$HOME"
|
||||
|
||||
get_optarg() {
|
||||
expr "x$1" : "x[^=]*=\\(.*\\)"
|
||||
}
|
||||
|
||||
here=`'pwd'`
|
||||
if [ $here = $Mydir ]; then
|
||||
# avoid pollution
|
||||
OBJROOT=../
|
||||
fi
|
||||
|
||||
op=all
|
||||
BMAKE=
|
||||
|
||||
while :
|
||||
do
|
||||
case "$1" in
|
||||
--) shift; break;;
|
||||
--help) sed -n -e "1d;/RCSid/,\$d" -e '/^#\.[a-z]/d' -e '/^#/s,^# *,,p' $0; exit 0;;
|
||||
--prefix) prefix="$2"; shift;;
|
||||
--prefix=*) prefix=`get_optarg "$1"`;;
|
||||
--src=*) srcdir=`get_optarg "$1"`;;
|
||||
--with-mksrc=*|--mksrc=*) mksrc=`get_optarg "$1"`;;
|
||||
--share=*) share_dir=`get_optarg "$1"`;;
|
||||
--share) share_dir="$2"; shift;;
|
||||
--with-default-sys-path=*)
|
||||
CONFIGURE_ARGS="$1";;
|
||||
--with-default-sys-path)
|
||||
CONFIGURE_ARGS="$1 $2";;
|
||||
--install) INSTALL_PREFIX=${INSTALL_PREFIX:-$prefix};;
|
||||
--install-host-target)
|
||||
INSTALL_PREFIX=${INSTALL_PREFIX:-$prefix}
|
||||
INSTALL_BIN=$HOST_TARGET/bin;;
|
||||
--install-destdir=*) INSTALL_DESTDIR=`get_optarg "$1"`;;
|
||||
--install-prefix=*) INSTALL_PREFIX=`get_optarg "$1"`;;
|
||||
-DWITH*) INSTALL_ARGS="$INSTALL_ARGS $1";;
|
||||
-s|--src) srcdir="$2"; shift;;
|
||||
-m|--mksrc) mksrc="$2"; shift;;
|
||||
-o|--objdir) objdir="$2"; shift;;
|
||||
-q) quiet=;;
|
||||
-c) source_rc "$2"; shift;;
|
||||
--*) CONFIGURE_ARGS="$CONFIGURE_ARGS $1";;
|
||||
*=*) eval "$1"; export `expr "x$1" : "x\\(.[^=]*\\)=.*"`;;
|
||||
*) break;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
AddConfigure() {
|
||||
case " $CONFIGURE_ARGS " in
|
||||
*" $1"*) ;;
|
||||
*) CONFIGURE_ARGS="$CONFIGURE_ARGS $1$2";;
|
||||
esac
|
||||
}
|
||||
|
||||
GetDir() {
|
||||
match="$1"
|
||||
shift
|
||||
fmatch="$1"
|
||||
shift
|
||||
for dir in $*
|
||||
do
|
||||
[ -d "$dir" ] || continue
|
||||
case "/$dir/" in
|
||||
*$match*) ;;
|
||||
*) continue;;
|
||||
esac
|
||||
case "$fmatch" in
|
||||
.) ;;
|
||||
*) [ -s $dir/$fmatch ] || continue;;
|
||||
esac
|
||||
case "$dir/" in
|
||||
*./*) cd "$dir" && 'pwd';;
|
||||
/*) echo $dir;;
|
||||
*) cd "$dir" && 'pwd';;
|
||||
esac
|
||||
break
|
||||
done
|
||||
}
|
||||
|
||||
FindHereOrAbove() {
|
||||
(
|
||||
_t=-s
|
||||
while :
|
||||
do
|
||||
case "$1" in
|
||||
-C) cd "$2"; shift; shift;;
|
||||
-?) _t=$1; shift;;
|
||||
*) break;;
|
||||
esac
|
||||
done
|
||||
case "$1" in
|
||||
/*) # we shouldn't be here
|
||||
[ $_t "$1" ] && echo "$1"
|
||||
return
|
||||
;;
|
||||
.../*) want=`echo "$1" | sed 's,^.../*,,'`;;
|
||||
*) want="$1";;
|
||||
esac
|
||||
here=`'pwd'`
|
||||
while :
|
||||
do
|
||||
if [ $_t "./$want" ]; then
|
||||
echo "$here/$want"
|
||||
return
|
||||
fi
|
||||
cd ..
|
||||
here=`'pwd'`
|
||||
case "$here" in
|
||||
/) return;;
|
||||
esac
|
||||
done
|
||||
)
|
||||
}
|
||||
|
||||
# is $1 missing from $2 (or PATH) ?
|
||||
no_path() {
|
||||
eval "__p=\$${2:-PATH}"
|
||||
case ":$__p:" in *:"$1":*) return 1;; *) return 0;; esac
|
||||
}
|
||||
|
||||
# if $1 exists and is not in path, append it
|
||||
add_path () {
|
||||
case "$1" in
|
||||
-?) t=$1; shift;;
|
||||
*) t=-d;;
|
||||
esac
|
||||
case "$2,$1" in
|
||||
MAKESYSPATH,.../*) ;;
|
||||
*) [ $t ${1:-.} ] || return;;
|
||||
esac
|
||||
no_path $* && eval ${2:-PATH}="$__p${__p:+:}$1"
|
||||
}
|
||||
|
||||
|
||||
srcdir=`GetDir /bmake make-bootstrap.sh.in "$srcdir" "$2" "$Mydir" ./bmake* "$Mydir"/../bmake*`
|
||||
[ -d "${srcdir:-/dev/null}" ] || Usage
|
||||
case "$mksrc" in
|
||||
none|-) # we ignore this now
|
||||
mksrc=$Mydir/mk
|
||||
;;
|
||||
.../*) # find here or above
|
||||
mksrc=`FindHereOrAbove -C "$Mydir" -s "$mksrc/sys.mk"`
|
||||
# that found a file
|
||||
mksrc=`dirname $mksrc`
|
||||
;;
|
||||
*) # guess we want mksrc...
|
||||
mksrc=`GetDir /mk sys.mk "$mksrc" "$3" ./mk* "$srcdir"/mk* "$srcdir"/../mk*`
|
||||
[ -d "${mksrc:-/dev/null}" ] || Usage "Use '-m none' to build without mksrc"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Ok, get to work...
|
||||
objdir="${objdir:-$OBJROOT$HOST_TARGET}"
|
||||
[ -d "$objdir" ] || mkdir -p "$objdir"
|
||||
[ -d "$objdir" ] || mkdir "$objdir"
|
||||
cd "$objdir" || exit 1
|
||||
# make it absolute
|
||||
objdir=`'pwd'`
|
||||
|
||||
ShareDir() {
|
||||
case "/$1" in
|
||||
/) [ -d /share ] || return;;
|
||||
*/$HOST_TARGET)
|
||||
if [ -d "$1/../share" ]; then
|
||||
echo `dirname "$1"`/share
|
||||
return
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
echo $1/share
|
||||
}
|
||||
|
||||
# make it easy to force prefix to use $HOST_TARGET
|
||||
: looking at "$prefix"
|
||||
case "$prefix" in
|
||||
*/host?target) prefix=`echo "$prefix" | sed "s,host.target,${HOST_TARGET},"`;;
|
||||
esac
|
||||
|
||||
share_dir="${share_dir:-`ShareDir $prefix`}"
|
||||
|
||||
AddConfigure --prefix= "$prefix"
|
||||
case "$CONFIGURE_ARGS" in
|
||||
*--with-*-sys-path*) ;; # skip
|
||||
*) [ "$share_dir" ] && AddConfigure --with-default-sys-path= "$share_dir/mk";;
|
||||
esac
|
||||
if [ "$mksrc" ]; then
|
||||
AddConfigure --with-mksrc= "$mksrc"
|
||||
# not all cc's support this
|
||||
CFLAGS_MF= CFLAGS_MD=
|
||||
export CFLAGS_MF CFLAGS_MD
|
||||
fi
|
||||
|
||||
# this makes it easy to run the bmake we just built
|
||||
# the :tA dance is needed because 'pwd' and even /bin/pwd
|
||||
# may not give the same result as realpath().
|
||||
Bmake() {
|
||||
(
|
||||
cd $Mydir &&
|
||||
MAKESYSPATH=$mksrc SRCTOP=$Mydir OBJTOP=$objdir \
|
||||
MAKEOBJDIR='${.CURDIR:S,${SRCTOP:tA},${OBJTOP:tA},}' \
|
||||
${BMAKE:-$objdir/bmake} -f $Mydir/Makefile "$@"
|
||||
)
|
||||
}
|
||||
|
||||
# make sure test below uses the same diff that configure did
|
||||
TOOL_DIFF=`type diff | sed 's,[()],,g;s,^[^/][^/]*,,;q'`
|
||||
export TOOL_DIFF
|
||||
|
||||
op_configure() {
|
||||
$srcdir/configure $CONFIGURE_ARGS || exit 1
|
||||
}
|
||||
|
||||
op_build() {
|
||||
[ -s make-bootstrap.sh ] || op_configure
|
||||
chmod 755 make-bootstrap.sh || exit 1
|
||||
./make-bootstrap.sh || exit 1
|
||||
case "$op" in
|
||||
build) op_test;;
|
||||
esac
|
||||
}
|
||||
|
||||
op_test() {
|
||||
[ -x bmake ] || op_build
|
||||
Bmake test || exit 1
|
||||
}
|
||||
|
||||
op_clean() {
|
||||
if [ -x bmake ]; then
|
||||
ln bmake bmake$$
|
||||
BMAKE=$objdir/bmake$$ Bmake clean
|
||||
rm -f bmake$$
|
||||
elif [ $objdir != $srcdir ]; then
|
||||
rm -rf *
|
||||
fi
|
||||
}
|
||||
|
||||
op_install() {
|
||||
op_test
|
||||
case "$INSTALL_PREFIX,$INSTALL_BIN,$prefix" in
|
||||
,$HOST_TARGET/bin,*/$HOST_TARGET)
|
||||
INSTALL_PREFIX=`dirname $prefix`
|
||||
;;
|
||||
esac
|
||||
INSTALL_PREFIX=${INSTALL_PREFIX:-$prefix}
|
||||
Bmake install prefix=$INSTALL_PREFIX BINDIR=$INSTALL_PREFIX/${INSTALL_BIN:-bin} ${INSTALL_DESTDIR:+DESTDIR=$INSTALL_DESTDIR} $INSTALL_ARGS || exit 1
|
||||
}
|
||||
|
||||
op_all() {
|
||||
rm -f make-bootstrap.sh bmake *.o
|
||||
if [ -n "$INSTALL_PREFIX" ]; then
|
||||
op_install
|
||||
else
|
||||
op_test
|
||||
MAKE_VERSION=`sed -n '/^MAKE_VERSION/ { s,.*= *,,;p; }' $srcdir/Makefile`
|
||||
echo You can install by running:
|
||||
echo
|
||||
echo $0 $cmd_args op=install
|
||||
echo
|
||||
echo "Use --install-prefix=/something to install somewhere other than $prefix"
|
||||
echo "Use --install-destdir=/somewhere to set DESTDIR during install"
|
||||
echo "Use --install-host-target to use INSTALL_BIN=$HOST_TARGET/bin"
|
||||
echo "Use -DWITH_PROG_VERSION to install as bmake-$MAKE_VERSION"
|
||||
echo "Use -DWITHOUT_PROG_LINK to suppress bmake -> bmake-$MAKE_VERSION symlink"
|
||||
echo "Use -DWITHOUT_INSTALL_MK to skip installing files to $prefix/share/mk"
|
||||
fi
|
||||
}
|
||||
|
||||
op_$op
|
||||
exit 0
|
111
20150418/bsd.after-import.mk
Normal file
111
20150418/bsd.after-import.mk
Normal file
@ -0,0 +1,111 @@
|
||||
# $Id: bsd.after-import.mk,v 1.12 2014/02/14 23:45:49 sjg Exp $
|
||||
|
||||
# This makefile is for use when integrating bmake into a BSD build
|
||||
# system. Use this makefile after importing bmake.
|
||||
# It will bootstrap the new version,
|
||||
# capture the generated files we need, and add an after-import
|
||||
# target to allow the process to be easily repeated.
|
||||
|
||||
# The goal is to allow the benefits of autoconf without
|
||||
# the overhead of running configure.
|
||||
|
||||
all: _makefile
|
||||
all: after-import
|
||||
|
||||
# we rely on bmake
|
||||
.if !defined(.PARSEDIR)
|
||||
.error this makefile requires bmake
|
||||
.endif
|
||||
|
||||
_this := ${MAKEFILE:tA}
|
||||
BMAKE_SRC := ${.PARSEDIR}
|
||||
|
||||
# it helps to know where the top of the tree is.
|
||||
.if !defined(SRCTOP)
|
||||
srctop := ${.MAKE.MAKEFILES:M*src/share/mk/sys.mk:H:H:H}
|
||||
.if empty(srctop)
|
||||
# likely locations?
|
||||
.for d in contrib/bmake external/bsd/bmake/dist
|
||||
.if ${BMAKE_SRC:M*/$d} != ""
|
||||
srctop := ${BMAKE_SRC:tA:S,/$d,,}
|
||||
.endif
|
||||
.endfor
|
||||
.endif
|
||||
.if !empty(srctop)
|
||||
SRCTOP := ${srctop}
|
||||
.endif
|
||||
.endif
|
||||
|
||||
# This lets us match what boot-strap does
|
||||
.if !defined(HOST_OS)
|
||||
HOST_OS!= uname
|
||||
.endif
|
||||
|
||||
BOOTSTRAP_ARGS = \
|
||||
--prefix /usr \
|
||||
--share /usr/share
|
||||
|
||||
.if !empty(DEFAULT_SYS_PATH)
|
||||
BOOTSTRAP_ARGS += --with-default-sys-path='${DEFAULT_SYS_PATH}'
|
||||
.endif
|
||||
|
||||
# run boot-strap with minimal influence
|
||||
bootstrap: ${BMAKE_SRC}/boot-strap ${MAKEFILE}
|
||||
HOME=/ ${BMAKE_SRC}/boot-strap -o ${HOST_OS} ${BOOTSTRAP_ARGS} ${BOOTSTRAP_XTRAS}
|
||||
touch ${.TARGET}
|
||||
|
||||
# Makefiles need a little more tweaking than say config.h
|
||||
MAKEFILE_SED = sed -e '/^MACHINE/d' \
|
||||
-e '/^PROG/ { s,=,?=,;s,bmake,$${.CURDIR:T},; }' \
|
||||
-e 's,^.-include,.sinclude,' \
|
||||
-e '/^\..*include *</ { s,<,<bsd.,;/autoconf/d; }' \
|
||||
-e 's,${SRCTOP},$${SRCTOP},g'
|
||||
|
||||
# These are the simple files we want to capture
|
||||
configured_files= config.h Makefile.config unit-tests/Makefile
|
||||
|
||||
after-import: bootstrap ${MAKEFILE}
|
||||
.for f in ${configured_files:M*.[ch]}
|
||||
@echo Capturing $f
|
||||
@mkdir -p ${${.CURDIR}/$f:L:H}
|
||||
@(echo '/* $$${HOST_OS}$$ */'; cat ${HOST_OS}/$f) > ${.CURDIR}/$f
|
||||
.endfor
|
||||
.for f in ${configured_files:M*Makefile*}
|
||||
@echo Capturing $f
|
||||
@mkdir -p ${${.CURDIR}/$f:L:H}
|
||||
@(echo '# This is a generated file, do NOT edit!'; \
|
||||
echo '# See ${_this:S,${SRCTOP}/,,}'; \
|
||||
echo '#'; echo '# $$${HOST_OS}$$'; echo; \
|
||||
echo 'SRCTOP?= $${.CURDIR:${${.CURDIR}/$f:L:H:S,${SRCTOP}/,,:C,[^/]+,H,g:S,/,:,g}}'; echo; \
|
||||
${MAKEFILE_SED} ${HOST_OS}/$f ) > ${.CURDIR}/$f
|
||||
.endfor
|
||||
|
||||
# this needs the most work
|
||||
_makefile: bootstrap ${MAKEFILE}
|
||||
@echo Generating ${.CURDIR}/Makefile
|
||||
@(echo '# This is a generated file, do NOT edit!'; \
|
||||
echo '# See ${_this:S,${SRCTOP}/,,}'; \
|
||||
echo '#'; echo '# $$${HOST_OS}$$'; \
|
||||
echo; echo '.sinclude "Makefile.inc"'; \
|
||||
echo; echo 'SRCTOP?= $${.CURDIR:${.CURDIR:S,${SRCTOP}/,,:C,[^/]+,H,g:S,/,:,g}}'; \
|
||||
echo; echo '# look here first for config.h'; \
|
||||
echo 'CFLAGS+= -I$${.CURDIR}'; echo; \
|
||||
echo '# for after-import'; \
|
||||
echo 'CLEANDIRS+= ${HOST_OS}'; \
|
||||
echo 'CLEANFILES+= bootstrap'; echo; \
|
||||
${MAKEFILE_SED} \
|
||||
${1 2:L:@n@-e '/start-delete$n/,/end-delete$n/d'@} \
|
||||
${BMAKE_SRC}/Makefile; \
|
||||
echo; echo '# override some simple things'; \
|
||||
echo 'BINDIR= /usr/bin'; \
|
||||
echo 'MANDIR= ${MANDIR:U/usr/share/man}'; \
|
||||
echo; echo '# make sure we get this'; \
|
||||
echo 'CFLAGS+= $${COPTS.$${.IMPSRC:T}}'; \
|
||||
echo; echo 'after-import: ${_this:S,${SRCTOP},\${SRCTOP},}'; \
|
||||
echo ' cd $${.CURDIR} && $${.MAKE} -f ${_this:S,${SRCTOP},\${SRCTOP},}'; \
|
||||
echo ) > ${.TARGET}
|
||||
@cmp -s ${.TARGET} ${.CURDIR}/Makefile || \
|
||||
mv ${.TARGET} ${.CURDIR}/Makefile
|
||||
|
||||
.include <bsd.obj.mk>
|
||||
|
291
20150418/buf.c
Normal file
291
20150418/buf.c
Normal file
@ -0,0 +1,291 @@
|
||||
/* $NetBSD: buf.c,v 1.25 2012/04/24 20:26:58 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989 by Adam de Boor
|
||||
* Copyright (c) 1989 by Berkeley Softworks
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: buf.c,v 1.25 2012/04/24 20:26:58 sjg Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)buf.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: buf.c,v 1.25 2012/04/24 20:26:58 sjg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
/*-
|
||||
* buf.c --
|
||||
* Functions for automatically-expanded buffers.
|
||||
*/
|
||||
|
||||
#include "make.h"
|
||||
#include "buf.h"
|
||||
|
||||
#ifndef max
|
||||
#define max(a,b) ((a) > (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#define BUF_DEF_SIZE 256 /* Default buffer size */
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Buf_Expand_1 --
|
||||
* Extend buffer for single byte add.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Buf_Expand_1(Buffer *bp)
|
||||
{
|
||||
bp->size += max(bp->size, 16);
|
||||
bp->buffer = bmake_realloc(bp->buffer, bp->size);
|
||||
}
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Buf_AddBytes --
|
||||
* Add a number of bytes to the buffer.
|
||||
*
|
||||
* Results:
|
||||
* None.
|
||||
*
|
||||
* Side Effects:
|
||||
* Guess what?
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Buf_AddBytes(Buffer *bp, int numBytes, const Byte *bytesPtr)
|
||||
{
|
||||
int count = bp->count;
|
||||
Byte *ptr;
|
||||
|
||||
if (__predict_false(count + numBytes >= bp->size)) {
|
||||
bp->size += max(bp->size, numBytes + 16);
|
||||
bp->buffer = bmake_realloc(bp->buffer, bp->size);
|
||||
}
|
||||
|
||||
ptr = bp->buffer + count;
|
||||
bp->count = count + numBytes;
|
||||
ptr[numBytes] = 0;
|
||||
memcpy(ptr, bytesPtr, numBytes);
|
||||
}
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Buf_GetAll --
|
||||
* Get all the available data at once.
|
||||
*
|
||||
* Results:
|
||||
* A pointer to the data and the number of bytes available.
|
||||
*
|
||||
* Side Effects:
|
||||
* None.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
Byte *
|
||||
Buf_GetAll(Buffer *bp, int *numBytesPtr)
|
||||
{
|
||||
|
||||
if (numBytesPtr != NULL)
|
||||
*numBytesPtr = bp->count;
|
||||
|
||||
return (bp->buffer);
|
||||
}
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Buf_Empty --
|
||||
* Throw away bytes in a buffer.
|
||||
*
|
||||
* Results:
|
||||
* None.
|
||||
*
|
||||
* Side Effects:
|
||||
* The bytes are discarded.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Buf_Empty(Buffer *bp)
|
||||
{
|
||||
|
||||
bp->count = 0;
|
||||
*bp->buffer = 0;
|
||||
}
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Buf_Init --
|
||||
* Initialize a buffer. If no initial size is given, a reasonable
|
||||
* default is used.
|
||||
*
|
||||
* Input:
|
||||
* size Initial size for the buffer
|
||||
*
|
||||
* Results:
|
||||
* A buffer to be given to other functions in this library.
|
||||
*
|
||||
* Side Effects:
|
||||
* The buffer is created, the space allocated and pointers
|
||||
* initialized.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Buf_Init(Buffer *bp, int size)
|
||||
{
|
||||
if (size <= 0) {
|
||||
size = BUF_DEF_SIZE;
|
||||
}
|
||||
bp->size = size;
|
||||
bp->count = 0;
|
||||
bp->buffer = bmake_malloc(size);
|
||||
*bp->buffer = 0;
|
||||
}
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Buf_Destroy --
|
||||
* Nuke a buffer and all its resources.
|
||||
*
|
||||
* Input:
|
||||
* buf Buffer to destroy
|
||||
* freeData TRUE if the data should be destroyed
|
||||
*
|
||||
* Results:
|
||||
* Data buffer, NULL if freed
|
||||
*
|
||||
* Side Effects:
|
||||
* The buffer is freed.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
Byte *
|
||||
Buf_Destroy(Buffer *buf, Boolean freeData)
|
||||
{
|
||||
Byte *data;
|
||||
|
||||
data = buf->buffer;
|
||||
if (freeData) {
|
||||
free(data);
|
||||
data = NULL;
|
||||
}
|
||||
|
||||
buf->size = 0;
|
||||
buf->count = 0;
|
||||
buf->buffer = NULL;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Buf_DestroyCompact --
|
||||
* Nuke a buffer and return its data.
|
||||
*
|
||||
* Input:
|
||||
* buf Buffer to destroy
|
||||
*
|
||||
* Results:
|
||||
* Data buffer
|
||||
*
|
||||
* Side Effects:
|
||||
* If the buffer size is much greater than its content,
|
||||
* a new buffer will be allocated and the old one freed.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef BUF_COMPACT_LIMIT
|
||||
# define BUF_COMPACT_LIMIT 128 /* worthwhile saving */
|
||||
#endif
|
||||
|
||||
Byte *
|
||||
Buf_DestroyCompact(Buffer *buf)
|
||||
{
|
||||
#if BUF_COMPACT_LIMIT > 0
|
||||
Byte *data;
|
||||
|
||||
if (buf->size - buf->count >= BUF_COMPACT_LIMIT) {
|
||||
/* We trust realloc to be smart */
|
||||
data = bmake_realloc(buf->buffer, buf->count + 1);
|
||||
if (data) {
|
||||
data[buf->count] = 0;
|
||||
Buf_Destroy(buf, FALSE);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Buf_Destroy(buf, FALSE);
|
||||
}
|
119
20150418/buf.h
Normal file
119
20150418/buf.h
Normal file
@ -0,0 +1,119 @@
|
||||
/* $NetBSD: buf.h,v 1.17 2012/04/24 20:26:58 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)buf.h 8.1 (Berkeley) 6/6/93
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989 by Adam de Boor
|
||||
* Copyright (c) 1989 by Berkeley Softworks
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)buf.h 8.1 (Berkeley) 6/6/93
|
||||
*/
|
||||
|
||||
/*-
|
||||
* buf.h --
|
||||
* Header for users of the buf library.
|
||||
*/
|
||||
|
||||
#ifndef _BUF_H
|
||||
#define _BUF_H
|
||||
|
||||
typedef char Byte;
|
||||
|
||||
typedef struct Buffer {
|
||||
int size; /* Current size of the buffer */
|
||||
int count; /* Number of bytes in buffer */
|
||||
Byte *buffer; /* The buffer itself (zero terminated) */
|
||||
} Buffer;
|
||||
|
||||
/* If we aren't on netbsd, __predict_false() might not be defined. */
|
||||
#ifndef __predict_false
|
||||
#define __predict_false(x) (x)
|
||||
#endif
|
||||
|
||||
/* Buf_AddByte adds a single byte to a buffer. */
|
||||
#define Buf_AddByte(bp, byte) do { \
|
||||
int _count = ++(bp)->count; \
|
||||
char *_ptr; \
|
||||
if (__predict_false(_count >= (bp)->size)) \
|
||||
Buf_Expand_1(bp); \
|
||||
_ptr = (bp)->buffer + _count; \
|
||||
_ptr[-1] = (byte); \
|
||||
_ptr[0] = 0; \
|
||||
} while (0)
|
||||
|
||||
#define BUF_ERROR 256
|
||||
|
||||
#define Buf_Size(bp) ((bp)->count)
|
||||
|
||||
void Buf_Expand_1(Buffer *);
|
||||
void Buf_AddBytes(Buffer *, int, const Byte *);
|
||||
Byte *Buf_GetAll(Buffer *, int *);
|
||||
void Buf_Empty(Buffer *);
|
||||
void Buf_Init(Buffer *, int);
|
||||
Byte *Buf_Destroy(Buffer *, Boolean);
|
||||
Byte *Buf_DestroyCompact(Buffer *);
|
||||
|
||||
#endif /* _BUF_H */
|
767
20150418/compat.c
Normal file
767
20150418/compat.c
Normal file
@ -0,0 +1,767 @@
|
||||
/* $NetBSD: compat.c,v 1.96 2014/09/07 20:55:34 joerg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989 by Adam de Boor
|
||||
* Copyright (c) 1989 by Berkeley Softworks
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: compat.c,v 1.96 2014/09/07 20:55:34 joerg Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: compat.c,v 1.96 2014/09/07 20:55:34 joerg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
/*-
|
||||
* compat.c --
|
||||
* The routines in this file implement the full-compatibility
|
||||
* mode of PMake. Most of the special functionality of PMake
|
||||
* is available in this mode. Things not supported:
|
||||
* - different shells.
|
||||
* - friendly variable substitution.
|
||||
*
|
||||
* Interface:
|
||||
* Compat_Run Initialize things for this module and recreate
|
||||
* thems as need creatin'
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include "wait.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "make.h"
|
||||
#include "hash.h"
|
||||
#include "dir.h"
|
||||
#include "job.h"
|
||||
#include "pathnames.h"
|
||||
|
||||
/*
|
||||
* The following array is used to make a fast determination of which
|
||||
* characters are interpreted specially by the shell. If a command
|
||||
* contains any of these characters, it is executed by the shell, not
|
||||
* directly by us.
|
||||
*/
|
||||
|
||||
static char meta[256];
|
||||
|
||||
static GNode *curTarg = NULL;
|
||||
static GNode *ENDNode;
|
||||
static void CompatInterrupt(int);
|
||||
|
||||
static void
|
||||
Compat_Init(void)
|
||||
{
|
||||
const char *cp;
|
||||
|
||||
Shell_Init(); /* setup default shell */
|
||||
|
||||
for (cp = "~#=|^(){};&<>*?[]:$`\\\n"; *cp != '\0'; cp++) {
|
||||
meta[(unsigned char) *cp] = 1;
|
||||
}
|
||||
/*
|
||||
* The null character serves as a sentinel in the string.
|
||||
*/
|
||||
meta[0] = 1;
|
||||
}
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* CompatInterrupt --
|
||||
* Interrupt the creation of the current target and remove it if
|
||||
* it ain't precious.
|
||||
*
|
||||
* Results:
|
||||
* None.
|
||||
*
|
||||
* Side Effects:
|
||||
* The target is removed and the process exits. If .INTERRUPT exists,
|
||||
* its commands are run first WITH INTERRUPTS IGNORED..
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static void
|
||||
CompatInterrupt(int signo)
|
||||
{
|
||||
GNode *gn;
|
||||
|
||||
if ((curTarg != NULL) && !Targ_Precious (curTarg)) {
|
||||
char *p1;
|
||||
char *file = Var_Value(TARGET, curTarg, &p1);
|
||||
|
||||
if (!noExecute && eunlink(file) != -1) {
|
||||
Error("*** %s removed", file);
|
||||
}
|
||||
if (p1)
|
||||
free(p1);
|
||||
|
||||
/*
|
||||
* Run .INTERRUPT only if hit with interrupt signal
|
||||
*/
|
||||
if (signo == SIGINT) {
|
||||
gn = Targ_FindNode(".INTERRUPT", TARG_NOCREATE);
|
||||
if (gn != NULL) {
|
||||
Compat_Make(gn, gn);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (signo == SIGQUIT)
|
||||
_exit(signo);
|
||||
bmake_signal(signo, SIG_DFL);
|
||||
kill(myPid, signo);
|
||||
}
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* CompatRunCommand --
|
||||
* Execute the next command for a target. If the command returns an
|
||||
* error, the node's made field is set to ERROR and creation stops.
|
||||
*
|
||||
* Input:
|
||||
* cmdp Command to execute
|
||||
* gnp Node from which the command came
|
||||
*
|
||||
* Results:
|
||||
* 0 if the command succeeded, 1 if an error occurred.
|
||||
*
|
||||
* Side Effects:
|
||||
* The node's 'made' field may be set to ERROR.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
CompatRunCommand(void *cmdp, void *gnp)
|
||||
{
|
||||
char *cmdStart; /* Start of expanded command */
|
||||
char *cp, *bp;
|
||||
Boolean silent, /* Don't print command */
|
||||
doIt; /* Execute even if -n */
|
||||
volatile Boolean errCheck; /* Check errors */
|
||||
WAIT_T reason; /* Reason for child's death */
|
||||
int status; /* Description of child's death */
|
||||
pid_t cpid; /* Child actually found */
|
||||
pid_t retstat; /* Result of wait */
|
||||
LstNode cmdNode; /* Node where current command is located */
|
||||
const char ** volatile av; /* Argument vector for thing to exec */
|
||||
char ** volatile mav;/* Copy of the argument vector for freeing */
|
||||
int argc; /* Number of arguments in av or 0 if not
|
||||
* dynamically allocated */
|
||||
Boolean local; /* TRUE if command should be executed
|
||||
* locally */
|
||||
Boolean useShell; /* TRUE if command should be executed
|
||||
* using a shell */
|
||||
char * volatile cmd = (char *)cmdp;
|
||||
GNode *gn = (GNode *)gnp;
|
||||
|
||||
silent = gn->type & OP_SILENT;
|
||||
errCheck = !(gn->type & OP_IGNORE);
|
||||
doIt = FALSE;
|
||||
|
||||
cmdNode = Lst_Member(gn->commands, cmd);
|
||||
cmdStart = Var_Subst(NULL, cmd, gn, FALSE);
|
||||
|
||||
/*
|
||||
* brk_string will return an argv with a NULL in av[0], thus causing
|
||||
* execvp to choke and die horribly. Besides, how can we execute a null
|
||||
* command? In any case, we warn the user that the command expanded to
|
||||
* nothing (is this the right thing to do?).
|
||||
*/
|
||||
|
||||
if (*cmdStart == '\0') {
|
||||
free(cmdStart);
|
||||
return(0);
|
||||
}
|
||||
cmd = cmdStart;
|
||||
Lst_Replace(cmdNode, cmdStart);
|
||||
|
||||
if ((gn->type & OP_SAVE_CMDS) && (gn != ENDNode)) {
|
||||
(void)Lst_AtEnd(ENDNode->commands, cmdStart);
|
||||
return(0);
|
||||
}
|
||||
if (strcmp(cmdStart, "...") == 0) {
|
||||
gn->type |= OP_SAVE_CMDS;
|
||||
return(0);
|
||||
}
|
||||
|
||||
while ((*cmd == '@') || (*cmd == '-') || (*cmd == '+')) {
|
||||
switch (*cmd) {
|
||||
case '@':
|
||||
silent = DEBUG(LOUD) ? FALSE : TRUE;
|
||||
break;
|
||||
case '-':
|
||||
errCheck = FALSE;
|
||||
break;
|
||||
case '+':
|
||||
doIt = TRUE;
|
||||
if (!meta[0]) /* we came here from jobs */
|
||||
Compat_Init();
|
||||
break;
|
||||
}
|
||||
cmd++;
|
||||
}
|
||||
|
||||
while (isspace((unsigned char)*cmd))
|
||||
cmd++;
|
||||
|
||||
/*
|
||||
* If we did not end up with a command, just skip it.
|
||||
*/
|
||||
if (!*cmd)
|
||||
return (0);
|
||||
|
||||
#if !defined(MAKE_NATIVE)
|
||||
/*
|
||||
* In a non-native build, the host environment might be weird enough
|
||||
* that it's necessary to go through a shell to get the correct
|
||||
* behaviour. Or perhaps the shell has been replaced with something
|
||||
* that does extra logging, and that should not be bypassed.
|
||||
*/
|
||||
useShell = TRUE;
|
||||
#else
|
||||
/*
|
||||
* Search for meta characters in the command. If there are no meta
|
||||
* characters, there's no need to execute a shell to execute the
|
||||
* command.
|
||||
*/
|
||||
for (cp = cmd; !meta[(unsigned char)*cp]; cp++) {
|
||||
continue;
|
||||
}
|
||||
useShell = (*cp != '\0');
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Print the command before echoing if we're not supposed to be quiet for
|
||||
* this one. We also print the command if -n given.
|
||||
*/
|
||||
if (!silent || NoExecute(gn)) {
|
||||
printf("%s\n", cmd);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
/*
|
||||
* If we're not supposed to execute any commands, this is as far as
|
||||
* we go...
|
||||
*/
|
||||
if (!doIt && NoExecute(gn)) {
|
||||
return (0);
|
||||
}
|
||||
if (DEBUG(JOB))
|
||||
fprintf(debug_file, "Execute: '%s'\n", cmd);
|
||||
|
||||
again:
|
||||
if (useShell) {
|
||||
/*
|
||||
* We need to pass the command off to the shell, typically
|
||||
* because the command contains a "meta" character.
|
||||
*/
|
||||
static const char *shargv[5];
|
||||
int shargc;
|
||||
|
||||
shargc = 0;
|
||||
shargv[shargc++] = shellPath;
|
||||
/*
|
||||
* The following work for any of the builtin shell specs.
|
||||
*/
|
||||
if (errCheck && shellErrFlag) {
|
||||
shargv[shargc++] = shellErrFlag;
|
||||
}
|
||||
if (DEBUG(SHELL))
|
||||
shargv[shargc++] = "-xc";
|
||||
else
|
||||
shargv[shargc++] = "-c";
|
||||
shargv[shargc++] = cmd;
|
||||
shargv[shargc++] = NULL;
|
||||
av = shargv;
|
||||
argc = 0;
|
||||
bp = NULL;
|
||||
mav = NULL;
|
||||
} else {
|
||||
/*
|
||||
* No meta-characters, so no need to exec a shell. Break the command
|
||||
* into words to form an argument vector we can execute.
|
||||
*/
|
||||
mav = brk_string(cmd, &argc, TRUE, &bp);
|
||||
if (mav == NULL) {
|
||||
useShell = 1;
|
||||
goto again;
|
||||
}
|
||||
av = (void *)mav;
|
||||
}
|
||||
|
||||
local = TRUE;
|
||||
|
||||
#ifdef USE_META
|
||||
if (useMeta) {
|
||||
meta_compat_start();
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Fork and execute the single command. If the fork fails, we abort.
|
||||
*/
|
||||
cpid = vFork();
|
||||
if (cpid < 0) {
|
||||
Fatal("Could not fork");
|
||||
}
|
||||
if (cpid == 0) {
|
||||
Var_ExportVars();
|
||||
#ifdef USE_META
|
||||
if (useMeta) {
|
||||
meta_compat_child();
|
||||
}
|
||||
#endif
|
||||
if (local)
|
||||
(void)execvp(av[0], (char *const *)UNCONST(av));
|
||||
else
|
||||
(void)execv(av[0], (char *const *)UNCONST(av));
|
||||
execError("exec", av[0]);
|
||||
_exit(1);
|
||||
}
|
||||
if (mav)
|
||||
free(mav);
|
||||
if (bp)
|
||||
free(bp);
|
||||
Lst_Replace(cmdNode, NULL);
|
||||
|
||||
#ifdef USE_META
|
||||
if (useMeta) {
|
||||
meta_compat_parent();
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The child is off and running. Now all we can do is wait...
|
||||
*/
|
||||
while (1) {
|
||||
|
||||
while ((retstat = wait(&reason)) != cpid) {
|
||||
if (retstat > 0)
|
||||
JobReapChild(retstat, reason, FALSE); /* not ours? */
|
||||
if (retstat == -1 && errno != EINTR) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (retstat > -1) {
|
||||
if (WIFSTOPPED(reason)) {
|
||||
status = WSTOPSIG(reason); /* stopped */
|
||||
} else if (WIFEXITED(reason)) {
|
||||
status = WEXITSTATUS(reason); /* exited */
|
||||
#if defined(USE_META) && defined(USE_FILEMON_ONCE)
|
||||
if (useMeta) {
|
||||
meta_cmd_finish(NULL);
|
||||
}
|
||||
#endif
|
||||
if (status != 0) {
|
||||
if (DEBUG(ERROR)) {
|
||||
fprintf(debug_file, "\n*** Failed target: %s\n*** Failed command: ",
|
||||
gn->name);
|
||||
for (cp = cmd; *cp; ) {
|
||||
if (isspace((unsigned char)*cp)) {
|
||||
fprintf(debug_file, " ");
|
||||
while (isspace((unsigned char)*cp))
|
||||
cp++;
|
||||
} else {
|
||||
fprintf(debug_file, "%c", *cp);
|
||||
cp++;
|
||||
}
|
||||
}
|
||||
fprintf(debug_file, "\n");
|
||||
}
|
||||
printf("*** Error code %d", status);
|
||||
}
|
||||
} else {
|
||||
status = WTERMSIG(reason); /* signaled */
|
||||
printf("*** Signal %d", status);
|
||||
}
|
||||
|
||||
|
||||
if (!WIFEXITED(reason) || (status != 0)) {
|
||||
if (errCheck) {
|
||||
#ifdef USE_META
|
||||
if (useMeta) {
|
||||
meta_job_error(NULL, gn, 0, status);
|
||||
}
|
||||
#endif
|
||||
gn->made = ERROR;
|
||||
if (keepgoing) {
|
||||
/*
|
||||
* Abort the current target, but let others
|
||||
* continue.
|
||||
*/
|
||||
printf(" (continuing)\n");
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Continue executing commands for this target.
|
||||
* If we return 0, this will happen...
|
||||
*/
|
||||
printf(" (ignored)\n");
|
||||
status = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
Fatal("error in wait: %d: %s", retstat, strerror(errno));
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
}
|
||||
free(cmdStart);
|
||||
|
||||
return (status);
|
||||
}
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Compat_Make --
|
||||
* Make a target.
|
||||
*
|
||||
* Input:
|
||||
* gnp The node to make
|
||||
* pgnp Parent to abort if necessary
|
||||
*
|
||||
* Results:
|
||||
* 0
|
||||
*
|
||||
* Side Effects:
|
||||
* If an error is detected and not being ignored, the process exits.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
Compat_Make(void *gnp, void *pgnp)
|
||||
{
|
||||
GNode *gn = (GNode *)gnp;
|
||||
GNode *pgn = (GNode *)pgnp;
|
||||
|
||||
if (!meta[0]) /* we came here from jobs */
|
||||
Compat_Init();
|
||||
if (gn->made == UNMADE && (gn == pgn || (pgn->type & OP_MADE) == 0)) {
|
||||
/*
|
||||
* First mark ourselves to be made, then apply whatever transformations
|
||||
* the suffix module thinks are necessary. Once that's done, we can
|
||||
* descend and make all our children. If any of them has an error
|
||||
* but the -k flag was given, our 'make' field will be set FALSE again.
|
||||
* This is our signal to not attempt to do anything but abort our
|
||||
* parent as well.
|
||||
*/
|
||||
gn->flags |= REMAKE;
|
||||
gn->made = BEINGMADE;
|
||||
if ((gn->type & OP_MADE) == 0)
|
||||
Suff_FindDeps(gn);
|
||||
Lst_ForEach(gn->children, Compat_Make, gn);
|
||||
if ((gn->flags & REMAKE) == 0) {
|
||||
gn->made = ABORTED;
|
||||
pgn->flags &= ~REMAKE;
|
||||
goto cohorts;
|
||||
}
|
||||
|
||||
if (Lst_Member(gn->iParents, pgn) != NULL) {
|
||||
char *p1;
|
||||
Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), pgn, 0);
|
||||
if (p1)
|
||||
free(p1);
|
||||
}
|
||||
|
||||
/*
|
||||
* All the children were made ok. Now cmgn->mtime contains the
|
||||
* modification time of the newest child, we need to find out if we
|
||||
* exist and when we were modified last. The criteria for datedness
|
||||
* are defined by the Make_OODate function.
|
||||
*/
|
||||
if (DEBUG(MAKE)) {
|
||||
fprintf(debug_file, "Examining %s...", gn->name);
|
||||
}
|
||||
if (! Make_OODate(gn)) {
|
||||
gn->made = UPTODATE;
|
||||
if (DEBUG(MAKE)) {
|
||||
fprintf(debug_file, "up-to-date.\n");
|
||||
}
|
||||
goto cohorts;
|
||||
} else if (DEBUG(MAKE)) {
|
||||
fprintf(debug_file, "out-of-date.\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* If the user is just seeing if something is out-of-date, exit now
|
||||
* to tell him/her "yes".
|
||||
*/
|
||||
if (queryFlag) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* We need to be re-made. We also have to make sure we've got a $?
|
||||
* variable. To be nice, we also define the $> variable using
|
||||
* Make_DoAllVar().
|
||||
*/
|
||||
Make_DoAllVar(gn);
|
||||
|
||||
/*
|
||||
* Alter our type to tell if errors should be ignored or things
|
||||
* should not be printed so CompatRunCommand knows what to do.
|
||||
*/
|
||||
if (Targ_Ignore(gn)) {
|
||||
gn->type |= OP_IGNORE;
|
||||
}
|
||||
if (Targ_Silent(gn)) {
|
||||
gn->type |= OP_SILENT;
|
||||
}
|
||||
|
||||
if (Job_CheckCommands(gn, Fatal)) {
|
||||
/*
|
||||
* Our commands are ok, but we still have to worry about the -t
|
||||
* flag...
|
||||
*/
|
||||
if (!touchFlag || (gn->type & OP_MAKE)) {
|
||||
curTarg = gn;
|
||||
#ifdef USE_META
|
||||
if (useMeta && !NoExecute(gn)) {
|
||||
meta_job_start(NULL, gn);
|
||||
}
|
||||
#endif
|
||||
Lst_ForEach(gn->commands, CompatRunCommand, gn);
|
||||
curTarg = NULL;
|
||||
} else {
|
||||
Job_Touch(gn, gn->type & OP_SILENT);
|
||||
}
|
||||
} else {
|
||||
gn->made = ERROR;
|
||||
}
|
||||
#ifdef USE_META
|
||||
if (useMeta && !NoExecute(gn)) {
|
||||
meta_job_finish(NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (gn->made != ERROR) {
|
||||
/*
|
||||
* If the node was made successfully, mark it so, update
|
||||
* its modification time and timestamp all its parents. Note
|
||||
* that for .ZEROTIME targets, the timestamping isn't done.
|
||||
* This is to keep its state from affecting that of its parent.
|
||||
*/
|
||||
gn->made = MADE;
|
||||
pgn->flags |= Make_Recheck(gn) == 0 ? FORCE : 0;
|
||||
if (!(gn->type & OP_EXEC)) {
|
||||
pgn->flags |= CHILDMADE;
|
||||
Make_TimeStamp(pgn, gn);
|
||||
}
|
||||
} else if (keepgoing) {
|
||||
pgn->flags &= ~REMAKE;
|
||||
} else {
|
||||
PrintOnError(gn, "\n\nStop.");
|
||||
exit(1);
|
||||
}
|
||||
} else if (gn->made == ERROR) {
|
||||
/*
|
||||
* Already had an error when making this beastie. Tell the parent
|
||||
* to abort.
|
||||
*/
|
||||
pgn->flags &= ~REMAKE;
|
||||
} else {
|
||||
if (Lst_Member(gn->iParents, pgn) != NULL) {
|
||||
char *p1;
|
||||
Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), pgn, 0);
|
||||
if (p1)
|
||||
free(p1);
|
||||
}
|
||||
switch(gn->made) {
|
||||
case BEINGMADE:
|
||||
Error("Graph cycles through %s", gn->name);
|
||||
gn->made = ERROR;
|
||||
pgn->flags &= ~REMAKE;
|
||||
break;
|
||||
case MADE:
|
||||
if ((gn->type & OP_EXEC) == 0) {
|
||||
pgn->flags |= CHILDMADE;
|
||||
Make_TimeStamp(pgn, gn);
|
||||
}
|
||||
break;
|
||||
case UPTODATE:
|
||||
if ((gn->type & OP_EXEC) == 0) {
|
||||
Make_TimeStamp(pgn, gn);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
cohorts:
|
||||
Lst_ForEach(gn->cohorts, Compat_Make, pgnp);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Compat_Run --
|
||||
* Initialize this mode and start making.
|
||||
*
|
||||
* Input:
|
||||
* targs List of target nodes to re-create
|
||||
*
|
||||
* Results:
|
||||
* None.
|
||||
*
|
||||
* Side Effects:
|
||||
* Guess what?
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Compat_Run(Lst targs)
|
||||
{
|
||||
GNode *gn = NULL;/* Current root target */
|
||||
int errors; /* Number of targets not remade due to errors */
|
||||
|
||||
Compat_Init();
|
||||
|
||||
if (bmake_signal(SIGINT, SIG_IGN) != SIG_IGN) {
|
||||
bmake_signal(SIGINT, CompatInterrupt);
|
||||
}
|
||||
if (bmake_signal(SIGTERM, SIG_IGN) != SIG_IGN) {
|
||||
bmake_signal(SIGTERM, CompatInterrupt);
|
||||
}
|
||||
if (bmake_signal(SIGHUP, SIG_IGN) != SIG_IGN) {
|
||||
bmake_signal(SIGHUP, CompatInterrupt);
|
||||
}
|
||||
if (bmake_signal(SIGQUIT, SIG_IGN) != SIG_IGN) {
|
||||
bmake_signal(SIGQUIT, CompatInterrupt);
|
||||
}
|
||||
|
||||
ENDNode = Targ_FindNode(".END", TARG_CREATE);
|
||||
ENDNode->type = OP_SPECIAL;
|
||||
/*
|
||||
* If the user has defined a .BEGIN target, execute the commands attached
|
||||
* to it.
|
||||
*/
|
||||
if (!queryFlag) {
|
||||
gn = Targ_FindNode(".BEGIN", TARG_NOCREATE);
|
||||
if (gn != NULL) {
|
||||
Compat_Make(gn, gn);
|
||||
if (gn->made == ERROR) {
|
||||
PrintOnError(gn, "\n\nStop.");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Expand .USE nodes right now, because they can modify the structure
|
||||
* of the tree.
|
||||
*/
|
||||
Make_ExpandUse(targs);
|
||||
|
||||
/*
|
||||
* For each entry in the list of targets to create, call Compat_Make on
|
||||
* it to create the thing. Compat_Make will leave the 'made' field of gn
|
||||
* in one of several states:
|
||||
* UPTODATE gn was already up-to-date
|
||||
* MADE gn was recreated successfully
|
||||
* ERROR An error occurred while gn was being created
|
||||
* ABORTED gn was not remade because one of its inferiors
|
||||
* could not be made due to errors.
|
||||
*/
|
||||
errors = 0;
|
||||
while (!Lst_IsEmpty (targs)) {
|
||||
gn = (GNode *)Lst_DeQueue(targs);
|
||||
Compat_Make(gn, gn);
|
||||
|
||||
if (gn->made == UPTODATE) {
|
||||
printf("`%s' is up to date.\n", gn->name);
|
||||
} else if (gn->made == ABORTED) {
|
||||
printf("`%s' not remade because of errors.\n", gn->name);
|
||||
errors += 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If the user has defined a .END target, run its commands.
|
||||
*/
|
||||
if (errors == 0) {
|
||||
Compat_Make(ENDNode, ENDNode);
|
||||
if (gn->made == ERROR) {
|
||||
PrintOnError(gn, "\n\nStop.");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
1413
20150418/cond.c
Normal file
1413
20150418/cond.c
Normal file
File diff suppressed because it is too large
Load Diff
323
20150418/config.h.in
Normal file
323
20150418/config.h.in
Normal file
@ -0,0 +1,323 @@
|
||||
/* config.h.in. Generated from configure.in by autoheader. */
|
||||
|
||||
/* Define if building universal (internal helper macro) */
|
||||
#undef AC_APPLE_UNIVERSAL_BUILD
|
||||
|
||||
/* Path of default shell */
|
||||
#undef DEFSHELL_CUSTOM
|
||||
|
||||
/* Shell spec to use by default */
|
||||
#undef DEFSHELL_INDEX
|
||||
|
||||
/* Define to 1 if you have the <ar.h> header file. */
|
||||
#undef HAVE_AR_H
|
||||
|
||||
/* Define to 1 if you have the declaration of `sys_siglist', and to 0 if you
|
||||
don't. */
|
||||
#undef HAVE_DECL_SYS_SIGLIST
|
||||
|
||||
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
|
||||
*/
|
||||
#undef HAVE_DIRENT_H
|
||||
|
||||
/* Define to 1 if you have the `dirname' function. */
|
||||
#undef HAVE_DIRNAME
|
||||
|
||||
/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
|
||||
#undef HAVE_DOPRNT
|
||||
|
||||
/* Define to 1 if you have the `err' function. */
|
||||
#undef HAVE_ERR
|
||||
|
||||
/* Define to 1 if you have the `errx' function. */
|
||||
#undef HAVE_ERRX
|
||||
|
||||
/* Define to 1 if you have the <err.h> header file. */
|
||||
#undef HAVE_ERR_H
|
||||
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#undef HAVE_FCNTL_H
|
||||
|
||||
/* Define to 1 if you have the `fork' function. */
|
||||
#undef HAVE_FORK
|
||||
|
||||
/* Define to 1 if you have the `getcwd' function. */
|
||||
#undef HAVE_GETCWD
|
||||
|
||||
/* Define to 1 if you have the `getenv' function. */
|
||||
#undef HAVE_GETENV
|
||||
|
||||
/* Define to 1 if you have the `getopt' function. */
|
||||
#undef HAVE_GETOPT
|
||||
|
||||
/* Define to 1 if you have the `getwd' function. */
|
||||
#undef HAVE_GETWD
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the `killpg' function. */
|
||||
#undef HAVE_KILLPG
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if you have the `mmap' function. */
|
||||
#undef HAVE_MMAP
|
||||
|
||||
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
|
||||
#undef HAVE_NDIR_H
|
||||
|
||||
/* Define to 1 if you have the <paths.h> header file. */
|
||||
#undef HAVE_PATHS_H
|
||||
|
||||
/* Define to 1 if you have the <poll.h> header file. */
|
||||
#undef HAVE_POLL_H
|
||||
|
||||
/* Define to 1 if you have the `putenv' function. */
|
||||
#undef HAVE_PUTENV
|
||||
|
||||
/* Define to 1 if you have the <ranlib.h> header file. */
|
||||
#undef HAVE_RANLIB_H
|
||||
|
||||
/* Define to 1 if you have the `realpath' function. */
|
||||
#undef HAVE_REALPATH
|
||||
|
||||
/* Define to 1 if you have the `select' function. */
|
||||
#undef HAVE_SELECT
|
||||
|
||||
/* Define to 1 if you have the `setenv' function. */
|
||||
#undef HAVE_SETENV
|
||||
|
||||
/* Define to 1 if you have the `setpgid' function. */
|
||||
#undef HAVE_SETPGID
|
||||
|
||||
/* Define to 1 if you have the `setsid' function. */
|
||||
#undef HAVE_SETSID
|
||||
|
||||
/* Define to 1 if you have the `sigaction' function. */
|
||||
#undef HAVE_SIGACTION
|
||||
|
||||
/* Define to 1 if you have the `sigvec' function. */
|
||||
#undef HAVE_SIGVEC
|
||||
|
||||
/* Define to 1 if you have the `snprintf' function. */
|
||||
#undef HAVE_SNPRINTF
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Define to 1 if you have the `strerror' function. */
|
||||
#undef HAVE_STRERROR
|
||||
|
||||
/* Define to 1 if you have the `stresep' function. */
|
||||
#undef HAVE_STRESEP
|
||||
|
||||
/* Define to 1 if you have the `strftime' function. */
|
||||
#undef HAVE_STRFTIME
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
/* Define to 1 if you have the `strlcpy' function. */
|
||||
#undef HAVE_STRLCPY
|
||||
|
||||
/* Define to 1 if you have the `strsep' function. */
|
||||
#undef HAVE_STRSEP
|
||||
|
||||
/* Define to 1 if you have the `strtod' function. */
|
||||
#undef HAVE_STRTOD
|
||||
|
||||
/* Define to 1 if you have the `strtol' function. */
|
||||
#undef HAVE_STRTOL
|
||||
|
||||
/* Define to 1 if `struct stat' is a member of `st_rdev'. */
|
||||
#undef HAVE_STRUCT_STAT_ST_RDEV
|
||||
|
||||
/* Define to 1 if your `struct stat' has `st_rdev'. Deprecated, use
|
||||
`HAVE_STRUCT_STAT_ST_RDEV' instead. */
|
||||
#undef HAVE_ST_RDEV
|
||||
|
||||
/* Define to 1 if you have the `sysctl' function. */
|
||||
#undef HAVE_SYSCTL
|
||||
|
||||
/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
|
||||
*/
|
||||
#undef HAVE_SYS_DIR_H
|
||||
|
||||
/* Define to 1 if you have the <sys/mman.h> header file. */
|
||||
#undef HAVE_SYS_MMAN_H
|
||||
|
||||
/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
|
||||
*/
|
||||
#undef HAVE_SYS_NDIR_H
|
||||
|
||||
/* Define to 1 if you have the <sys/select.h> header file. */
|
||||
#undef HAVE_SYS_SELECT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/socket.h> header file. */
|
||||
#undef HAVE_SYS_SOCKET_H
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/sysctl.h> header file. */
|
||||
#undef HAVE_SYS_SYSCTL_H
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#undef HAVE_SYS_TIME_H
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
/* Define to 1 if you have the <sys/uio.h> header file. */
|
||||
#undef HAVE_SYS_UIO_H
|
||||
|
||||
/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
|
||||
#undef HAVE_SYS_WAIT_H
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define to 1 if you have the `unsetenv' function. */
|
||||
#undef HAVE_UNSETENV
|
||||
|
||||
/* Define to 1 if you have the <utime.h> header file. */
|
||||
#undef HAVE_UTIME_H
|
||||
|
||||
/* Define to 1 if you have the `vfork' function. */
|
||||
#undef HAVE_VFORK
|
||||
|
||||
/* Define to 1 if you have the <vfork.h> header file. */
|
||||
#undef HAVE_VFORK_H
|
||||
|
||||
/* Define to 1 if you have the `vprintf' function. */
|
||||
#undef HAVE_VPRINTF
|
||||
|
||||
/* Define to 1 if you have the `vsnprintf' function. */
|
||||
#undef HAVE_VSNPRINTF
|
||||
|
||||
/* Define to 1 if you have the `wait3' function. */
|
||||
#undef HAVE_WAIT3
|
||||
|
||||
/* Define to 1 if you have the `wait4' function. */
|
||||
#undef HAVE_WAIT4
|
||||
|
||||
/* Define to 1 if you have the `waitpid' function. */
|
||||
#undef HAVE_WAITPID
|
||||
|
||||
/* Define to 1 if you have the `warn' function. */
|
||||
#undef HAVE_WARN
|
||||
|
||||
/* Define to 1 if you have the `warnx' function. */
|
||||
#undef HAVE_WARNX
|
||||
|
||||
/* Define to 1 if `fork' works. */
|
||||
#undef HAVE_WORKING_FORK
|
||||
|
||||
/* Define to 1 if `vfork' works. */
|
||||
#undef HAVE_WORKING_VFORK
|
||||
|
||||
/* define if your compiler has __attribute__ */
|
||||
#undef HAVE___ATTRIBUTE__
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#undef PACKAGE_NAME
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#undef PACKAGE_STRING
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#undef PACKAGE_URL
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* Define as the return type of signal handlers (`int' or `void'). */
|
||||
#undef RETSIGTYPE
|
||||
|
||||
/* Define to 1 if the `S_IS*' macros in <sys/stat.h> do not work properly. */
|
||||
#undef STAT_MACROS_BROKEN
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
|
||||
#undef TIME_WITH_SYS_TIME
|
||||
|
||||
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
|
||||
#undef TM_IN_SYS_TIME
|
||||
|
||||
/* Enable extensions on AIX 3, Interix. */
|
||||
#ifndef _ALL_SOURCE
|
||||
# undef _ALL_SOURCE
|
||||
#endif
|
||||
/* Enable GNU extensions on systems that have them. */
|
||||
#ifndef _GNU_SOURCE
|
||||
# undef _GNU_SOURCE
|
||||
#endif
|
||||
/* Enable threading extensions on Solaris. */
|
||||
#ifndef _POSIX_PTHREAD_SEMANTICS
|
||||
# undef _POSIX_PTHREAD_SEMANTICS
|
||||
#endif
|
||||
/* Enable extensions on HP NonStop. */
|
||||
#ifndef _TANDEM_SOURCE
|
||||
# undef _TANDEM_SOURCE
|
||||
#endif
|
||||
/* Enable general extensions on Solaris. */
|
||||
#ifndef __EXTENSIONS__
|
||||
# undef __EXTENSIONS__
|
||||
#endif
|
||||
|
||||
|
||||
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
|
||||
significant byte first (like Motorola and SPARC, unlike Intel). */
|
||||
#if defined AC_APPLE_UNIVERSAL_BUILD
|
||||
# if defined __BIG_ENDIAN__
|
||||
# define WORDS_BIGENDIAN 1
|
||||
# endif
|
||||
#else
|
||||
# ifndef WORDS_BIGENDIAN
|
||||
# undef WORDS_BIGENDIAN
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Define to 1 if on MINIX. */
|
||||
#undef _MINIX
|
||||
|
||||
/* Define to 2 if the system does not provide POSIX.1 features except with
|
||||
this defined. */
|
||||
#undef _POSIX_1_SOURCE
|
||||
|
||||
/* Define to 1 if you need to in order for `stat' and other things to work. */
|
||||
#undef _POSIX_SOURCE
|
||||
|
||||
/* C99 function name */
|
||||
#undef __func__
|
||||
|
||||
/* Define to empty if `const' does not conform to ANSI C. */
|
||||
#undef const
|
||||
|
||||
/* Define to `long int' if <sys/types.h> does not define. */
|
||||
#undef off_t
|
||||
|
||||
/* Define to `int' if <sys/types.h> does not define. */
|
||||
#undef pid_t
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
#undef size_t
|
||||
|
||||
/* Define as `fork' if `vfork' does not work. */
|
||||
#undef vfork
|
7172
20150418/configure
vendored
Executable file
7172
20150418/configure
vendored
Executable file
File diff suppressed because it is too large
Load Diff
388
20150418/configure.in
Normal file
388
20150418/configure.in
Normal file
@ -0,0 +1,388 @@
|
||||
dnl
|
||||
dnl RCSid:
|
||||
dnl $Id: configure.in,v 1.53 2014/11/06 01:49:40 sjg Exp $
|
||||
dnl
|
||||
dnl Process this file with autoconf to produce a configure script
|
||||
dnl
|
||||
AC_PREREQ(2.50)
|
||||
AC_INIT([bmake], [20140214], [sjg@NetBSD.org])
|
||||
AC_CONFIG_HEADERS(config.h)
|
||||
|
||||
dnl make srcdir absolute
|
||||
case "$srcdir" in
|
||||
/*) ;;
|
||||
*) srcdir=`cd $srcdir && pwd`;;
|
||||
esac
|
||||
|
||||
dnl
|
||||
AC_ARG_WITH(defshell,
|
||||
[ --with-defshell=SHELL use SHELL by default - must be sh compatible, use sh or ksh to pick the internal definitions],
|
||||
[case "${withval}" in
|
||||
yes) AC_MSG_ERROR(bad value ${withval} given for bmake DEFSHELL) ;;
|
||||
no) ;;
|
||||
*) case "$with_defshell" in
|
||||
sh) DEFSHELL_INDEX=DEFSHELL_INDEX_SH;; # it's the default anyway
|
||||
ksh) DEFSHELL_INDEX=DEFSHELL_INDEX_KSH;;
|
||||
csh) DEFSHELL_INDEX=DEFSHELL_INDEX_CSH;; # kidding right?
|
||||
*) defshell_path=$with_defshell;; # better be sh compatible!
|
||||
esac
|
||||
;;
|
||||
esac])
|
||||
dnl
|
||||
use_meta=yes
|
||||
AC_ARG_WITH(meta,
|
||||
[ --without-meta dissable use of meta-mode],
|
||||
[case "${withval}" in
|
||||
yes|no) use_meta=${withval};;
|
||||
*) AC_MSG_ERROR(bad value ${withval} given for meta) ;;
|
||||
esac])
|
||||
dnl
|
||||
AC_ARG_WITH(filemon,
|
||||
[ --with-filemon=path/filemon.h indicate path to filemon.h for meta-mode],
|
||||
[ case "/${withval}" in
|
||||
/no|*/filemon.h) filemon_h="${withval}";;
|
||||
*/filemon*) filemon_h="${withval}/filemon.h";;
|
||||
*) AC_MSG_ERROR(bad value ${withval} given for filemon) ;;
|
||||
esac],
|
||||
[
|
||||
OS=`uname -s`
|
||||
for d in "/usr/include/dev/filemon" "$prefix/include/dev/filemon" "$srcdir/filemon" "$srcdir/../filemon" "$srcdir/../../sys/dev/filemon"
|
||||
do
|
||||
for x in "/$OS" ""
|
||||
do
|
||||
filemon_h="$d$x/filemon.h"
|
||||
test -s "$filemon_h" && break
|
||||
done
|
||||
test -s "$filemon_h" && break
|
||||
done
|
||||
test -s "${filemon_h:-/dev/null}" || filemon_h=no
|
||||
])
|
||||
dnl echo "Note: use_meta=$use_meta filemon_h=$filemon_h" >&6
|
||||
case "$use_meta" in
|
||||
yes)
|
||||
case "$filemon_h" in
|
||||
*.h) echo "Using: filemon=$filemon_h" >&6;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
dnl
|
||||
dnl Check for OS problems
|
||||
dnl Solaris's signal.h only privides sigset_t etc if one of
|
||||
dnl _EXTENSIONS_ _POSIX_C_SOURCE or _XOPEN_SOURCE are defined.
|
||||
dnl The later two seem to cause more problems than they solve so if we
|
||||
dnl see _EXTENSIONS_ we use it.
|
||||
AC_USE_SYSTEM_EXTENSIONS
|
||||
dnl Checks for programs.
|
||||
AC_PROG_CC
|
||||
AC_PROG_GCC_TRADITIONAL
|
||||
AC_PROG_INSTALL
|
||||
dnl Executable suffix - normally empty; .exe on os2.
|
||||
AC_SUBST(ac_exe_suffix)dnl
|
||||
dnl
|
||||
dnl Hurd refuses to define PATH_MAX or MAXPATHLEN
|
||||
if test -x /usr/bin/getconf; then
|
||||
bmake_path_max=`getconf PATH_MAX / 2> /dev/null`
|
||||
# only a numeric response is useful
|
||||
test ${bmake_path_max:-0} -gt 0 2> /dev/null || bmake_path_max=
|
||||
fi
|
||||
bmake_path_max=${bmake_path_max:-1024}
|
||||
if test $bmake_path_max -gt 1024; then
|
||||
# this is all we expect
|
||||
bmake_path_max=1024
|
||||
fi
|
||||
echo "Using: BMAKE_PATH_MAX=$bmake_path_max" >&6
|
||||
AC_SUBST(bmake_path_max)dnl
|
||||
dnl
|
||||
dnl AC_C_CROSS
|
||||
dnl
|
||||
|
||||
dnl Checks for header files.
|
||||
AC_HEADER_STDC
|
||||
AC_HEADER_SYS_WAIT
|
||||
AC_HEADER_DIRENT
|
||||
dnl Keep this list sorted
|
||||
AC_CHECK_HEADERS( \
|
||||
ar.h \
|
||||
err.h \
|
||||
fcntl.h \
|
||||
paths.h \
|
||||
poll.h \
|
||||
ranlib.h \
|
||||
string.h \
|
||||
sys/mman.h \
|
||||
sys/select.h \
|
||||
sys/socket.h \
|
||||
sys/sysctl.h \
|
||||
sys/time.h \
|
||||
sys/uio.h \
|
||||
unistd.h \
|
||||
utime.h \
|
||||
)
|
||||
|
||||
dnl Both *BSD and Linux have sys/cdefs.h, most do not.
|
||||
dnl If it is missing, we add -I${srcdir}/missing to CFLAGS
|
||||
dnl also if sys/cdefs.h does not have __RCSID we need to use ours
|
||||
dnl but we need to include the host's one too *sigh*
|
||||
AC_CHECK_HEADER(sys/cdefs.h,
|
||||
echo $ECHO_N "checking whether sys/cdefs.h is compatible... $ECHO_C" >&6
|
||||
AC_EGREP_CPP(yes,
|
||||
[#include <sys/cdefs.h>
|
||||
#ifdef __RCSID
|
||||
yes
|
||||
#endif
|
||||
],
|
||||
echo yes >&6,
|
||||
echo no >&6; CPPFLAGS="${CPPFLAGS} -I`cd ${srcdir}/missing && pwd` -DNEED_HOST_CDEFS_H"),
|
||||
CPPFLAGS="${CPPFLAGS} -I`cd ${srcdir}/missing && pwd`")
|
||||
|
||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_C___ATTRIBUTE__
|
||||
AC_C_BIGENDIAN
|
||||
AC_C_CONST
|
||||
AC_TYPE_OFF_T
|
||||
AC_TYPE_PID_T
|
||||
AC_TYPE_SIZE_T
|
||||
AC_DECL_SYS_SIGLIST
|
||||
AC_HEADER_TIME
|
||||
AC_STRUCT_TM
|
||||
|
||||
dnl Checks for library functions.
|
||||
AC_TYPE_SIGNAL
|
||||
AC_FUNC_VFORK
|
||||
AC_FUNC_VPRINTF
|
||||
AC_FUNC_WAIT3
|
||||
dnl Keep this list sorted
|
||||
AC_CHECK_FUNCS( \
|
||||
err \
|
||||
errx \
|
||||
getcwd \
|
||||
getenv \
|
||||
getopt \
|
||||
getwd \
|
||||
killpg \
|
||||
mmap \
|
||||
putenv \
|
||||
select \
|
||||
setenv \
|
||||
setpgid \
|
||||
setsid \
|
||||
sigaction \
|
||||
sigvec \
|
||||
snprintf \
|
||||
strerror \
|
||||
strftime \
|
||||
strsep \
|
||||
strtod \
|
||||
strtol \
|
||||
sysctl \
|
||||
unsetenv \
|
||||
vsnprintf \
|
||||
wait3 \
|
||||
wait4 \
|
||||
waitpid \
|
||||
warn \
|
||||
warnx \
|
||||
)
|
||||
|
||||
dnl functions which we may need to provide
|
||||
AC_REPLACE_FUNCS( \
|
||||
realpath \
|
||||
dirname \
|
||||
stresep \
|
||||
strlcpy \
|
||||
)
|
||||
|
||||
AC_CHECK_LIB([util], [emalloc],
|
||||
[ AC_CHECK_LIB([util], [erealloc],
|
||||
[ AC_CHECK_LIB([util], [estrdup],
|
||||
[ AC_CHECK_LIB([util], [estrndup],
|
||||
[ LIBS="$LIBS -lutil"
|
||||
CPPFLAGS="$CPPFLAGS -DUSE_EMALLOC" ])])])])
|
||||
|
||||
dnl
|
||||
dnl Structures
|
||||
dnl
|
||||
AC_HEADER_STAT
|
||||
AC_STRUCT_ST_RDEV
|
||||
dnl
|
||||
echo "checking if compiler supports __func__" >&6
|
||||
AC_LANG(C)
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[[const char *func = __func__;]])],,
|
||||
AC_DEFINE(__func__, __FUNCTION__, C99 function name))
|
||||
dnl
|
||||
dnl we want this for unit-tests/Makefile
|
||||
echo $ECHO_N "checking if diff -u works... $ECHO_C" >&6
|
||||
if diff -u /dev/null /dev/null > /dev/null 2>&1; then
|
||||
diff_u=-u
|
||||
echo yes >&6
|
||||
else
|
||||
diff_u=
|
||||
echo no >&6
|
||||
fi
|
||||
dnl
|
||||
dnl AC_* don't quite cut it.
|
||||
dnl
|
||||
echo "checking for MACHINE & MACHINE_ARCH..." >&6
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#include "confdefs.h"
|
||||
#include <sys/param.h>
|
||||
#ifdef MACHINE
|
||||
machine=MACHINE
|
||||
#endif
|
||||
#ifdef MACHINE_ARCH
|
||||
machine_arch=MACHINE_ARCH
|
||||
#endif
|
||||
EOF
|
||||
|
||||
default_machine=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 |
|
||||
egrep machine= | tr -d ' "'`
|
||||
rm -rf conftest*
|
||||
if test "$default_machine"; then
|
||||
eval "$default_machine"
|
||||
fi
|
||||
machine=${machine:-`$srcdir/machine.sh`}
|
||||
machine_arch=${machine_arch:-`$srcdir/machine.sh arch`}
|
||||
echo "defaults: MACHINE=$machine, MACHINE_ARCH=$machine_arch" 1>&6
|
||||
dnl
|
||||
dnl now allow overrides
|
||||
dnl
|
||||
AC_ARG_WITH(machine,
|
||||
[ --with-machine=MACHINE explicitly set MACHINE],
|
||||
[case "${withval}" in
|
||||
yes) AC_MSG_ERROR(bad value ${withval} given for bmake MACHINE) ;;
|
||||
no) ;;
|
||||
generic) machine=`$srcdir/machine.sh`;;
|
||||
*) machine=$with_machine;;
|
||||
esac])
|
||||
force_machine=
|
||||
AC_ARG_WITH(force_machine,
|
||||
[ --with-force-machine=MACHINE set FORCE_MACHINE],
|
||||
[case "${withval}" in
|
||||
yes) force_machine=FORCE_;;
|
||||
no) ;;
|
||||
*) force_machine=FORCE_; machine=$with_force_machine;;
|
||||
esac])
|
||||
dnl
|
||||
force_machine_arch=
|
||||
AC_ARG_WITH(force_machine_arch,
|
||||
[ --with-force-machine-arch=MACHINE set FORCE_MACHINE_ARCH],
|
||||
[case "${withval}" in
|
||||
yes) force_machine_arch=FORCE_;;
|
||||
no) ;;
|
||||
*) force_machine_arch=FORCE_; machine_arch=$with_force_machine;;
|
||||
esac])
|
||||
dnl
|
||||
AC_ARG_WITH(machine_arch,
|
||||
[ --with-machine_arch=MACHINE_ARCH explicitly set MACHINE_ARCH],
|
||||
[case "${withval}" in
|
||||
yes) AC_MSG_ERROR(bad value ${withval} given for bmake MACHINE_ARCH) ;;
|
||||
no) ;;
|
||||
*) machine_arch=$with_machine_arch;;
|
||||
esac])
|
||||
dnl
|
||||
dnl Tell them what we ended up with
|
||||
dnl
|
||||
echo "Using: ${force_machine}MACHINE=$machine, MACHINE_ARCH=$machine_arch" 1>&6
|
||||
dnl
|
||||
dnl Allow folk to control _PATH_DEFSYSPATH
|
||||
dnl
|
||||
default_sys_path=\${prefix}/share/mk
|
||||
AC_ARG_WITH(default-sys-path,
|
||||
[ --with-default-sys-path=PATH:DIR:LIST use an explicit _PATH_DEFSYSPATH
|
||||
MAKESYSPATH is a ':' separated list of directories
|
||||
that bmake will search for system .mk files.
|
||||
_PATH_DEFSYSPATH is its default value.],
|
||||
[case "${withval}" in
|
||||
yes) AC_MSG_ERROR(bad value ${withval} given for bmake _PATH_DEFSYSPATH) ;;
|
||||
no) ;;
|
||||
*) default_sys_path="$with_default_sys_path"
|
||||
;;
|
||||
esac])
|
||||
dnl
|
||||
dnl Some folk don't like this one
|
||||
dnl
|
||||
AC_ARG_WITH(path-objdirprefix,
|
||||
[ --with-path-objdirprefix=PATH override _PATH_OBJDIRPREFIX],
|
||||
[case "${withval}" in
|
||||
yes) AC_MSG_ERROR(bad value ${withval} given for bmake _PATH_OBJDIRPREFIX) ;;
|
||||
no) CPPFLAGS="$CPPFLAGS -DNO_PATH_OBJDIRPREFIX" ;;
|
||||
*) CPPFLAGS="$CPPFLAGS \"-D_PATH_OBJDIRPREFIX=\\\"$with_path-objdir\\\"\"" ;;
|
||||
esac])
|
||||
dnl
|
||||
dnl And this can be handy to do with out.
|
||||
dnl
|
||||
AC_ARG_ENABLE(pwd-override,
|
||||
[ --disable-pwd-override disable \$PWD overriding getcwd()],
|
||||
[case "${enableval}" in
|
||||
yes) ;;
|
||||
no) CPPFLAGS="$CPPFLAGS -DNO_PWD_OVERRIDE" ;;
|
||||
*) AC_MSG_ERROR(bad value ${enableval} given for pwd-override option) ;;
|
||||
esac])
|
||||
dnl
|
||||
dnl Just for grins
|
||||
dnl
|
||||
AC_ARG_ENABLE(check-make-chdir,
|
||||
[ --disable-check-make-chdir disable make trying to guess
|
||||
when it should automatically cd \${.CURDIR}],
|
||||
[case "${enableval}" in
|
||||
yes) ;;
|
||||
no) CPPFLAGS="$CPPFLAGS -DNO_CHECK_MAKE_CHDIR" ;;
|
||||
*) AC_MSG_ERROR(bad value ${enableval} given for check-make-chdir option) ;;
|
||||
esac])
|
||||
dnl
|
||||
dnl On non-BSD systems, bootstrap won't work without mk
|
||||
dnl
|
||||
AC_ARG_WITH(mksrc,
|
||||
[ --with-mksrc=PATH tell makefile.boot where to find mk src],
|
||||
[case "${withval}" in
|
||||
""|yes|no) ;;
|
||||
*) test -s $withval/install-mk && mksrc=$withval ||
|
||||
AC_MSG_ERROR(bad value ${withval} given for mksrc cannot find install-mk)
|
||||
;;
|
||||
esac
|
||||
])
|
||||
dnl
|
||||
dnl Now make sure we have a value
|
||||
dnl
|
||||
srcdir=`cd $srcdir && pwd`
|
||||
for mksrc in $mksrc $srcdir/mk $srcdir/../mk mk
|
||||
do
|
||||
test -s $mksrc/install-mk || continue
|
||||
mksrc=`cd $mksrc && pwd`
|
||||
break
|
||||
done
|
||||
mksrc=`echo $mksrc | sed "s,$srcdir,\\\${srcdir},"`
|
||||
echo "Using: MKSRC=$mksrc" 1>&6
|
||||
dnl On some systems we want a different default shell by default
|
||||
if test -x /usr/xpg4/bin/sh; then
|
||||
defshell_path=${defshell_path:-/usr/xpg4/bin/sh}
|
||||
fi
|
||||
if test -n "$defshell_path"; then
|
||||
echo "Using: SHELL=$defshell_path" >&6
|
||||
AC_DEFINE_UNQUOTED(DEFSHELL_CUSTOM, "$defshell_path", Path of default shell)
|
||||
fi
|
||||
if test -n "$DEFSHELL_INDEX"; then
|
||||
AC_DEFINE_UNQUOTED(DEFSHELL_INDEX, $DEFSHELL_INDEX, Shell spec to use by default)
|
||||
fi
|
||||
dnl
|
||||
AC_SUBST(machine)
|
||||
AC_SUBST(force_machine)
|
||||
AC_SUBST(machine_arch)
|
||||
AC_SUBST(mksrc)
|
||||
AC_SUBST(default_sys_path)
|
||||
AC_SUBST(INSTALL)
|
||||
AC_SUBST(GCC)
|
||||
AC_SUBST(diff_u)
|
||||
AC_SUBST(use_meta)
|
||||
AC_SUBST(filemon_h)
|
||||
AC_OUTPUT(makefile Makefile.config make-bootstrap.sh unit-tests/Makefile)
|
||||
|
||||
cat <<EOF
|
||||
|
||||
You can now run
|
||||
|
||||
sh ./make-bootstrap.sh
|
||||
|
||||
to produce a fully functional bmake.
|
||||
|
||||
EOF
|
1805
20150418/dir.c
Normal file
1805
20150418/dir.c
Normal file
File diff suppressed because it is too large
Load Diff
108
20150418/dir.h
Normal file
108
20150418/dir.h
Normal file
@ -0,0 +1,108 @@
|
||||
/* $NetBSD: dir.h,v 1.15 2012/04/07 18:29:08 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)dir.h 8.1 (Berkeley) 6/6/93
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989 by Adam de Boor
|
||||
* Copyright (c) 1989 by Berkeley Softworks
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)dir.h 8.1 (Berkeley) 6/6/93
|
||||
*/
|
||||
|
||||
/* dir.h --
|
||||
*/
|
||||
|
||||
#ifndef _DIR
|
||||
#define _DIR
|
||||
|
||||
typedef struct Path {
|
||||
char *name; /* Name of directory */
|
||||
int refCount; /* Number of paths with this directory */
|
||||
int hits; /* the number of times a file in this
|
||||
* directory has been found */
|
||||
Hash_Table files; /* Hash table of files in directory */
|
||||
} Path;
|
||||
|
||||
void Dir_Init(const char *);
|
||||
void Dir_InitCur(const char *);
|
||||
void Dir_InitDot(void);
|
||||
void Dir_End(void);
|
||||
void Dir_SetPATH(void);
|
||||
Boolean Dir_HasWildcards(char *);
|
||||
void Dir_Expand(const char *, Lst, Lst);
|
||||
char *Dir_FindFile(const char *, Lst);
|
||||
int Dir_FindHereOrAbove(char *, char *, char *, int);
|
||||
int Dir_MTime(GNode *, Boolean);
|
||||
Path *Dir_AddDir(Lst, const char *);
|
||||
char *Dir_MakeFlags(const char *, Lst);
|
||||
void Dir_ClearPath(Lst);
|
||||
void Dir_Concat(Lst, Lst);
|
||||
void Dir_PrintDirectories(void);
|
||||
void Dir_PrintPath(Lst);
|
||||
void Dir_Destroy(void *);
|
||||
void * Dir_CopyDir(void *);
|
||||
|
||||
#endif /* _DIR */
|
95
20150418/dirname.c
Normal file
95
20150418/dirname.c
Normal file
@ -0,0 +1,95 @@
|
||||
/* $NetBSD: dirname.c,v 1.11 2009/11/24 13:34:20 tnozaki Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997, 2002 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Klaus Klein and Jason R. Thorpe.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#ifndef HAVE_DIRNAME
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#ifdef HAVE_LIMITS_H
|
||||
#include <limits.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
#ifndef PATH_MAX
|
||||
# define PATH_MAX 1024
|
||||
#endif
|
||||
|
||||
char *
|
||||
dirname(char *path)
|
||||
{
|
||||
static char result[PATH_MAX];
|
||||
const char *lastp;
|
||||
size_t len;
|
||||
|
||||
/*
|
||||
* If `path' is a null pointer or points to an empty string,
|
||||
* return a pointer to the string ".".
|
||||
*/
|
||||
if ((path == NULL) || (*path == '\0'))
|
||||
goto singledot;
|
||||
|
||||
|
||||
/* Strip trailing slashes, if any. */
|
||||
lastp = path + strlen(path) - 1;
|
||||
while (lastp != path && *lastp == '/')
|
||||
lastp--;
|
||||
|
||||
/* Terminate path at the last occurence of '/'. */
|
||||
do {
|
||||
if (*lastp == '/') {
|
||||
/* Strip trailing slashes, if any. */
|
||||
while (lastp != path && *lastp == '/')
|
||||
lastp--;
|
||||
|
||||
/* ...and copy the result into the result buffer. */
|
||||
len = (lastp - path) + 1 /* last char */;
|
||||
if (len > (PATH_MAX - 1))
|
||||
len = PATH_MAX - 1;
|
||||
|
||||
memcpy(result, path, len);
|
||||
result[len] = '\0';
|
||||
|
||||
return (result);
|
||||
}
|
||||
} while (--lastp >= path);
|
||||
|
||||
/* No /'s found, return a pointer to the string ".". */
|
||||
singledot:
|
||||
result[0] = '.';
|
||||
result[1] = '\0';
|
||||
|
||||
return (result);
|
||||
}
|
||||
#endif
|
13
20150418/find_lib.sh
Executable file
13
20150418/find_lib.sh
Executable file
@ -0,0 +1,13 @@
|
||||
:
|
||||
re=$1; shift
|
||||
|
||||
for lib in $*
|
||||
do
|
||||
found=`nm $lib | egrep "$re"`
|
||||
case "$found" in
|
||||
"") ;;
|
||||
*) echo "$lib: $found";;
|
||||
esac
|
||||
done
|
||||
|
||||
|
496
20150418/for.c
Normal file
496
20150418/for.c
Normal file
@ -0,0 +1,496 @@
|
||||
/* $NetBSD: for.c,v 1.49 2012/06/03 04:29:40 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: for.c,v 1.49 2012/06/03 04:29:40 sjg Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)for.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: for.c,v 1.49 2012/06/03 04:29:40 sjg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
/*-
|
||||
* for.c --
|
||||
* Functions to handle loops in a makefile.
|
||||
*
|
||||
* Interface:
|
||||
* For_Eval Evaluate the loop in the passed line.
|
||||
* For_Run Run accumulated loop
|
||||
*
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "make.h"
|
||||
#include "hash.h"
|
||||
#include "dir.h"
|
||||
#include "buf.h"
|
||||
#include "strlist.h"
|
||||
|
||||
#define FOR_SUB_ESCAPE_CHAR 1
|
||||
#define FOR_SUB_ESCAPE_BRACE 2
|
||||
#define FOR_SUB_ESCAPE_PAREN 4
|
||||
|
||||
/*
|
||||
* For statements are of the form:
|
||||
*
|
||||
* .for <variable> in <varlist>
|
||||
* ...
|
||||
* .endfor
|
||||
*
|
||||
* The trick is to look for the matching end inside for for loop
|
||||
* To do that, we count the current nesting level of the for loops.
|
||||
* and the .endfor statements, accumulating all the statements between
|
||||
* the initial .for loop and the matching .endfor;
|
||||
* then we evaluate the for loop for each variable in the varlist.
|
||||
*
|
||||
* Note that any nested fors are just passed through; they get handled
|
||||
* recursively in For_Eval when we're expanding the enclosing for in
|
||||
* For_Run.
|
||||
*/
|
||||
|
||||
static int forLevel = 0; /* Nesting level */
|
||||
|
||||
/*
|
||||
* State of a for loop.
|
||||
*/
|
||||
typedef struct _For {
|
||||
Buffer buf; /* Body of loop */
|
||||
strlist_t vars; /* Iteration variables */
|
||||
strlist_t items; /* Substitution items */
|
||||
char *parse_buf;
|
||||
int short_var;
|
||||
int sub_next;
|
||||
} For;
|
||||
|
||||
static For *accumFor; /* Loop being accumulated */
|
||||
|
||||
|
||||
|
||||
static char *
|
||||
make_str(const char *ptr, int len)
|
||||
{
|
||||
char *new_ptr;
|
||||
|
||||
new_ptr = bmake_malloc(len + 1);
|
||||
memcpy(new_ptr, ptr, len);
|
||||
new_ptr[len] = 0;
|
||||
return new_ptr;
|
||||
}
|
||||
|
||||
static void
|
||||
For_Free(For *arg)
|
||||
{
|
||||
Buf_Destroy(&arg->buf, TRUE);
|
||||
strlist_clean(&arg->vars);
|
||||
strlist_clean(&arg->items);
|
||||
free(arg->parse_buf);
|
||||
|
||||
free(arg);
|
||||
}
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* For_Eval --
|
||||
* Evaluate the for loop in the passed line. The line
|
||||
* looks like this:
|
||||
* .for <variable> in <varlist>
|
||||
*
|
||||
* Input:
|
||||
* line Line to parse
|
||||
*
|
||||
* Results:
|
||||
* 0: Not a .for statement, parse the line
|
||||
* 1: We found a for loop
|
||||
* -1: A .for statement with a bad syntax error, discard.
|
||||
*
|
||||
* Side Effects:
|
||||
* None.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
For_Eval(char *line)
|
||||
{
|
||||
For *new_for;
|
||||
char *ptr = line, *sub;
|
||||
int len;
|
||||
int escapes;
|
||||
unsigned char ch;
|
||||
char **words, *word_buf;
|
||||
int n, nwords;
|
||||
|
||||
/* Skip the '.' and any following whitespace */
|
||||
for (ptr++; *ptr && isspace((unsigned char) *ptr); ptr++)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* If we are not in a for loop quickly determine if the statement is
|
||||
* a for.
|
||||
*/
|
||||
if (ptr[0] != 'f' || ptr[1] != 'o' || ptr[2] != 'r' ||
|
||||
!isspace((unsigned char) ptr[3])) {
|
||||
if (ptr[0] == 'e' && strncmp(ptr+1, "ndfor", 5) == 0) {
|
||||
Parse_Error(PARSE_FATAL, "for-less endfor");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
ptr += 3;
|
||||
|
||||
/*
|
||||
* we found a for loop, and now we are going to parse it.
|
||||
*/
|
||||
|
||||
new_for = bmake_malloc(sizeof *new_for);
|
||||
memset(new_for, 0, sizeof *new_for);
|
||||
|
||||
/* Grab the variables. Terminate on "in". */
|
||||
for (;; ptr += len) {
|
||||
while (*ptr && isspace((unsigned char) *ptr))
|
||||
ptr++;
|
||||
if (*ptr == '\0') {
|
||||
Parse_Error(PARSE_FATAL, "missing `in' in for");
|
||||
For_Free(new_for);
|
||||
return -1;
|
||||
}
|
||||
for (len = 1; ptr[len] && !isspace((unsigned char)ptr[len]); len++)
|
||||
continue;
|
||||
if (len == 2 && ptr[0] == 'i' && ptr[1] == 'n') {
|
||||
ptr += 2;
|
||||
break;
|
||||
}
|
||||
if (len == 1)
|
||||
new_for->short_var = 1;
|
||||
strlist_add_str(&new_for->vars, make_str(ptr, len), len);
|
||||
}
|
||||
|
||||
if (strlist_num(&new_for->vars) == 0) {
|
||||
Parse_Error(PARSE_FATAL, "no iteration variables in for");
|
||||
For_Free(new_for);
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (*ptr && isspace((unsigned char) *ptr))
|
||||
ptr++;
|
||||
|
||||
/*
|
||||
* Make a list with the remaining words
|
||||
* The values are substituted as ${:U<value>...} so we must \ escape
|
||||
* characters that break that syntax.
|
||||
* Variables are fully expanded - so it is safe for escape $.
|
||||
* We can't do the escapes here - because we don't know whether
|
||||
* we are substuting into ${...} or $(...).
|
||||
*/
|
||||
sub = Var_Subst(NULL, ptr, VAR_GLOBAL, FALSE);
|
||||
|
||||
/*
|
||||
* Split into words allowing for quoted strings.
|
||||
*/
|
||||
words = brk_string(sub, &nwords, FALSE, &word_buf);
|
||||
|
||||
free(sub);
|
||||
|
||||
if (words != NULL) {
|
||||
for (n = 0; n < nwords; n++) {
|
||||
ptr = words[n];
|
||||
if (!*ptr)
|
||||
continue;
|
||||
escapes = 0;
|
||||
while ((ch = *ptr++)) {
|
||||
switch(ch) {
|
||||
case ':':
|
||||
case '$':
|
||||
case '\\':
|
||||
escapes |= FOR_SUB_ESCAPE_CHAR;
|
||||
break;
|
||||
case ')':
|
||||
escapes |= FOR_SUB_ESCAPE_PAREN;
|
||||
break;
|
||||
case /*{*/ '}':
|
||||
escapes |= FOR_SUB_ESCAPE_BRACE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* We have to dup words[n] to maintain the semantics of
|
||||
* strlist.
|
||||
*/
|
||||
strlist_add_str(&new_for->items, bmake_strdup(words[n]), escapes);
|
||||
}
|
||||
|
||||
free(words);
|
||||
free(word_buf);
|
||||
|
||||
if ((len = strlist_num(&new_for->items)) > 0 &&
|
||||
len % (n = strlist_num(&new_for->vars))) {
|
||||
Parse_Error(PARSE_FATAL,
|
||||
"Wrong number of words (%d) in .for substitution list"
|
||||
" with %d vars", len, n);
|
||||
/*
|
||||
* Return 'success' so that the body of the .for loop is
|
||||
* accumulated.
|
||||
* Remove all items so that the loop doesn't iterate.
|
||||
*/
|
||||
strlist_clean(&new_for->items);
|
||||
}
|
||||
}
|
||||
|
||||
Buf_Init(&new_for->buf, 0);
|
||||
accumFor = new_for;
|
||||
forLevel = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add another line to a .for loop.
|
||||
* Returns 0 when the matching .endfor is reached.
|
||||
*/
|
||||
|
||||
int
|
||||
For_Accum(char *line)
|
||||
{
|
||||
char *ptr = line;
|
||||
|
||||
if (*ptr == '.') {
|
||||
|
||||
for (ptr++; *ptr && isspace((unsigned char) *ptr); ptr++)
|
||||
continue;
|
||||
|
||||
if (strncmp(ptr, "endfor", 6) == 0 &&
|
||||
(isspace((unsigned char) ptr[6]) || !ptr[6])) {
|
||||
if (DEBUG(FOR))
|
||||
(void)fprintf(debug_file, "For: end for %d\n", forLevel);
|
||||
if (--forLevel <= 0)
|
||||
return 0;
|
||||
} else if (strncmp(ptr, "for", 3) == 0 &&
|
||||
isspace((unsigned char) ptr[3])) {
|
||||
forLevel++;
|
||||
if (DEBUG(FOR))
|
||||
(void)fprintf(debug_file, "For: new loop %d\n", forLevel);
|
||||
}
|
||||
}
|
||||
|
||||
Buf_AddBytes(&accumFor->buf, strlen(line), line);
|
||||
Buf_AddByte(&accumFor->buf, '\n');
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* For_Run --
|
||||
* Run the for loop, imitating the actions of an include file
|
||||
*
|
||||
* Results:
|
||||
* None.
|
||||
*
|
||||
* Side Effects:
|
||||
* None.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static int
|
||||
for_var_len(const char *var)
|
||||
{
|
||||
char ch, var_start, var_end;
|
||||
int depth;
|
||||
int len;
|
||||
|
||||
var_start = *var;
|
||||
if (var_start == 0)
|
||||
/* just escape the $ */
|
||||
return 0;
|
||||
|
||||
if (var_start == '(')
|
||||
var_end = ')';
|
||||
else if (var_start == '{')
|
||||
var_end = '}';
|
||||
else
|
||||
/* Single char variable */
|
||||
return 1;
|
||||
|
||||
depth = 1;
|
||||
for (len = 1; (ch = var[len++]) != 0;) {
|
||||
if (ch == var_start)
|
||||
depth++;
|
||||
else if (ch == var_end && --depth == 0)
|
||||
return len;
|
||||
}
|
||||
|
||||
/* Variable end not found, escape the $ */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
for_substitute(Buffer *cmds, strlist_t *items, unsigned int item_no, char ech)
|
||||
{
|
||||
const char *item = strlist_str(items, item_no);
|
||||
int len;
|
||||
char ch;
|
||||
|
||||
/* If there were no escapes, or the only escape is the other variable
|
||||
* terminator, then just substitute the full string */
|
||||
if (!(strlist_info(items, item_no) &
|
||||
(ech == ')' ? ~FOR_SUB_ESCAPE_BRACE : ~FOR_SUB_ESCAPE_PAREN))) {
|
||||
Buf_AddBytes(cmds, strlen(item), item);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Escape ':', '$', '\\' and 'ech' - removed by :U processing */
|
||||
while ((ch = *item++) != 0) {
|
||||
if (ch == '$') {
|
||||
len = for_var_len(item);
|
||||
if (len != 0) {
|
||||
Buf_AddBytes(cmds, len + 1, item - 1);
|
||||
item += len;
|
||||
continue;
|
||||
}
|
||||
Buf_AddByte(cmds, '\\');
|
||||
} else if (ch == ':' || ch == '\\' || ch == ech)
|
||||
Buf_AddByte(cmds, '\\');
|
||||
Buf_AddByte(cmds, ch);
|
||||
}
|
||||
}
|
||||
|
||||
static char *
|
||||
For_Iterate(void *v_arg, size_t *ret_len)
|
||||
{
|
||||
For *arg = v_arg;
|
||||
int i, len;
|
||||
char *var;
|
||||
char *cp;
|
||||
char *cmd_cp;
|
||||
char *body_end;
|
||||
char ch;
|
||||
Buffer cmds;
|
||||
|
||||
if (arg->sub_next + strlist_num(&arg->vars) > strlist_num(&arg->items)) {
|
||||
/* No more iterations */
|
||||
For_Free(arg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
free(arg->parse_buf);
|
||||
arg->parse_buf = NULL;
|
||||
|
||||
/*
|
||||
* Scan the for loop body and replace references to the loop variables
|
||||
* with variable references that expand to the required text.
|
||||
* Using variable expansions ensures that the .for loop can't generate
|
||||
* syntax, and that the later parsing will still see a variable.
|
||||
* We assume that the null variable will never be defined.
|
||||
*
|
||||
* The detection of substitions of the loop control variable is naive.
|
||||
* Many of the modifiers use \ to escape $ (not $) so it is possible
|
||||
* to contrive a makefile where an unwanted substitution happens.
|
||||
*/
|
||||
|
||||
cmd_cp = Buf_GetAll(&arg->buf, &len);
|
||||
body_end = cmd_cp + len;
|
||||
Buf_Init(&cmds, len + 256);
|
||||
for (cp = cmd_cp; (cp = strchr(cp, '$')) != NULL;) {
|
||||
char ech;
|
||||
ch = *++cp;
|
||||
if ((ch == '(' && (ech = ')')) || (ch == '{' && (ech = '}'))) {
|
||||
cp++;
|
||||
/* Check variable name against the .for loop variables */
|
||||
STRLIST_FOREACH(var, &arg->vars, i) {
|
||||
len = strlist_info(&arg->vars, i);
|
||||
if (memcmp(cp, var, len) != 0)
|
||||
continue;
|
||||
if (cp[len] != ':' && cp[len] != ech && cp[len] != '\\')
|
||||
continue;
|
||||
/* Found a variable match. Replace with :U<value> */
|
||||
Buf_AddBytes(&cmds, cp - cmd_cp, cmd_cp);
|
||||
Buf_AddBytes(&cmds, 2, ":U");
|
||||
cp += len;
|
||||
cmd_cp = cp;
|
||||
for_substitute(&cmds, &arg->items, arg->sub_next + i, ech);
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (ch == 0)
|
||||
break;
|
||||
/* Probably a single character name, ignore $$ and stupid ones. {*/
|
||||
if (!arg->short_var || strchr("}):$", ch) != NULL) {
|
||||
cp++;
|
||||
continue;
|
||||
}
|
||||
STRLIST_FOREACH(var, &arg->vars, i) {
|
||||
if (var[0] != ch || var[1] != 0)
|
||||
continue;
|
||||
/* Found a variable match. Replace with ${:U<value>} */
|
||||
Buf_AddBytes(&cmds, cp - cmd_cp, cmd_cp);
|
||||
Buf_AddBytes(&cmds, 3, "{:U");
|
||||
cmd_cp = ++cp;
|
||||
for_substitute(&cmds, &arg->items, arg->sub_next + i, /*{*/ '}');
|
||||
Buf_AddBytes(&cmds, 1, "}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
Buf_AddBytes(&cmds, body_end - cmd_cp, cmd_cp);
|
||||
|
||||
cp = Buf_Destroy(&cmds, FALSE);
|
||||
if (DEBUG(FOR))
|
||||
(void)fprintf(debug_file, "For: loop body:\n%s", cp);
|
||||
|
||||
arg->sub_next += strlist_num(&arg->vars);
|
||||
|
||||
arg->parse_buf = cp;
|
||||
*ret_len = strlen(cp);
|
||||
return cp;
|
||||
}
|
||||
|
||||
void
|
||||
For_Run(int lineno)
|
||||
{
|
||||
For *arg;
|
||||
|
||||
arg = accumFor;
|
||||
accumFor = NULL;
|
||||
|
||||
if (strlist_num(&arg->items) == 0) {
|
||||
/* Nothing to expand - possibly due to an earlier syntax error. */
|
||||
For_Free(arg);
|
||||
return;
|
||||
}
|
||||
|
||||
Parse_SetInput(NULL, lineno, -1, For_Iterate, arg);
|
||||
}
|
179
20150418/getopt.c
Normal file
179
20150418/getopt.c
Normal file
@ -0,0 +1,179 @@
|
||||
/*
|
||||
* Copyright (c) 1987, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
#if !defined(HAVE_GETOPT) || defined(WANT_GETOPT_LONG) || defined(BROKEN_GETOPT)
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
/* static char sccsid[] = "from: @(#)getopt.c 8.2 (Berkeley) 4/2/94"; */
|
||||
static char *rcsid = "$Id: getopt.c,v 1.3 1999/01/08 02:14:18 sjg Exp $";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#define BADCH (int)'?'
|
||||
#define BADARG (int)':'
|
||||
#define EMSG ""
|
||||
|
||||
int opterr = 1, /* if error message should be printed */
|
||||
optind = 1, /* index into parent argv vector */
|
||||
optopt = BADCH, /* character checked for validity */
|
||||
optreset; /* reset getopt */
|
||||
char *optarg; /* argument associated with option */
|
||||
|
||||
/*
|
||||
* getopt --
|
||||
* Parse argc/argv argument vector.
|
||||
*/
|
||||
int
|
||||
getopt(nargc, nargv, ostr)
|
||||
int nargc;
|
||||
char * const *nargv;
|
||||
const char *ostr;
|
||||
{
|
||||
extern char *__progname;
|
||||
static char *place = EMSG; /* option letter processing */
|
||||
char *oli; /* option letter list index */
|
||||
|
||||
#ifndef BSD4_4
|
||||
if (!__progname) {
|
||||
if (__progname = strrchr(nargv[0], '/'))
|
||||
++__progname;
|
||||
else
|
||||
__progname = nargv[0];
|
||||
}
|
||||
#endif
|
||||
|
||||
if (optreset || !*place) { /* update scanning pointer */
|
||||
optreset = 0;
|
||||
if (optind >= nargc || *(place = nargv[optind]) != '-') {
|
||||
place = EMSG;
|
||||
return (-1);
|
||||
}
|
||||
if (place[1] && *++place == '-' /* found "--" */
|
||||
&& !place[1]) { /* and not "--foo" */
|
||||
++optind;
|
||||
place = EMSG;
|
||||
return (-1);
|
||||
}
|
||||
} /* option letter okay? */
|
||||
if ((optopt = (int)*place++) == (int)':' ||
|
||||
!(oli = strchr(ostr, optopt))) {
|
||||
/*
|
||||
* if the user didn't specify '-' as an option,
|
||||
* assume it means -1.
|
||||
*/
|
||||
if (optopt == (int)'-')
|
||||
return (-1);
|
||||
if (!*place)
|
||||
++optind;
|
||||
if (opterr && *ostr != ':')
|
||||
(void)fprintf(stderr,
|
||||
"%s: illegal option -- %c\n", __progname, optopt);
|
||||
return (BADCH);
|
||||
}
|
||||
if (*++oli != ':') { /* don't need argument */
|
||||
optarg = NULL;
|
||||
if (!*place)
|
||||
++optind;
|
||||
}
|
||||
else { /* need an argument */
|
||||
if (*place) /* no white space */
|
||||
optarg = place;
|
||||
else if (nargc <= ++optind) { /* no arg */
|
||||
place = EMSG;
|
||||
if (*ostr == ':')
|
||||
return (BADARG);
|
||||
if (opterr)
|
||||
(void)fprintf(stderr,
|
||||
"%s: option requires an argument -- %c\n",
|
||||
__progname, optopt);
|
||||
return (BADCH);
|
||||
}
|
||||
else /* white space */
|
||||
optarg = nargv[optind];
|
||||
place = EMSG;
|
||||
++optind;
|
||||
}
|
||||
return (optopt); /* dump back option letter */
|
||||
}
|
||||
#endif
|
||||
#ifdef MAIN
|
||||
#ifndef BSD4_4
|
||||
char *__progname;
|
||||
#endif
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
int c;
|
||||
char *opts = argv[1];
|
||||
|
||||
--argc;
|
||||
++argv;
|
||||
|
||||
while ((c = getopt(argc, argv, opts)) != EOF) {
|
||||
switch (c) {
|
||||
case '-':
|
||||
if (optarg)
|
||||
printf("--%s ", optarg);
|
||||
break;
|
||||
case '?':
|
||||
exit(1);
|
||||
break;
|
||||
default:
|
||||
if (optarg)
|
||||
printf("-%c %s ", c, optarg);
|
||||
else
|
||||
printf("-%c ", c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (optind < argc) {
|
||||
printf("-- ");
|
||||
for (; optind < argc; ++optind) {
|
||||
printf("%s ", argv[optind]);
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
exit(0);
|
||||
}
|
||||
#endif
|
466
20150418/hash.c
Normal file
466
20150418/hash.c
Normal file
@ -0,0 +1,466 @@
|
||||
/* $NetBSD: hash.c,v 1.20 2013/11/14 00:27:05 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989 by Adam de Boor
|
||||
* Copyright (c) 1989 by Berkeley Softworks
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: hash.c,v 1.20 2013/11/14 00:27:05 sjg Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)hash.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: hash.c,v 1.20 2013/11/14 00:27:05 sjg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
/* hash.c --
|
||||
*
|
||||
* This module contains routines to manipulate a hash table.
|
||||
* See hash.h for a definition of the structure of the hash
|
||||
* table. Hash tables grow automatically as the amount of
|
||||
* information increases.
|
||||
*/
|
||||
#include "sprite.h"
|
||||
#include "make.h"
|
||||
#include "hash.h"
|
||||
|
||||
/*
|
||||
* Forward references to local procedures that are used before they're
|
||||
* defined:
|
||||
*/
|
||||
|
||||
static void RebuildTable(Hash_Table *);
|
||||
|
||||
/*
|
||||
* The following defines the ratio of # entries to # buckets
|
||||
* at which we rebuild the table to make it larger.
|
||||
*/
|
||||
|
||||
#define rebuildLimit 3
|
||||
|
||||
/*
|
||||
*---------------------------------------------------------
|
||||
*
|
||||
* Hash_InitTable --
|
||||
*
|
||||
* This routine just sets up the hash table.
|
||||
*
|
||||
* Input:
|
||||
* t Structure to to hold table.
|
||||
* numBuckets How many buckets to create for starters. This
|
||||
* number is rounded up to a power of two. If
|
||||
* <= 0, a reasonable default is chosen. The
|
||||
* table will grow in size later as needed.
|
||||
*
|
||||
* Results:
|
||||
* None.
|
||||
*
|
||||
* Side Effects:
|
||||
* Memory is allocated for the initial bucket area.
|
||||
*
|
||||
*---------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Hash_InitTable(Hash_Table *t, int numBuckets)
|
||||
{
|
||||
int i;
|
||||
struct Hash_Entry **hp;
|
||||
|
||||
/*
|
||||
* Round up the size to a power of two.
|
||||
*/
|
||||
if (numBuckets <= 0)
|
||||
i = 16;
|
||||
else {
|
||||
for (i = 2; i < numBuckets; i <<= 1)
|
||||
continue;
|
||||
}
|
||||
t->numEntries = 0;
|
||||
t->size = i;
|
||||
t->mask = i - 1;
|
||||
t->bucketPtr = hp = bmake_malloc(sizeof(*hp) * i);
|
||||
while (--i >= 0)
|
||||
*hp++ = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
*---------------------------------------------------------
|
||||
*
|
||||
* Hash_DeleteTable --
|
||||
*
|
||||
* This routine removes everything from a hash table
|
||||
* and frees up the memory space it occupied (except for
|
||||
* the space in the Hash_Table structure).
|
||||
*
|
||||
* Results:
|
||||
* None.
|
||||
*
|
||||
* Side Effects:
|
||||
* Lots of memory is freed up.
|
||||
*
|
||||
*---------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Hash_DeleteTable(Hash_Table *t)
|
||||
{
|
||||
struct Hash_Entry **hp, *h, *nexth = NULL;
|
||||
int i;
|
||||
|
||||
for (hp = t->bucketPtr, i = t->size; --i >= 0;) {
|
||||
for (h = *hp++; h != NULL; h = nexth) {
|
||||
nexth = h->next;
|
||||
free(h);
|
||||
}
|
||||
}
|
||||
free(t->bucketPtr);
|
||||
|
||||
/*
|
||||
* Set up the hash table to cause memory faults on any future access
|
||||
* attempts until re-initialization.
|
||||
*/
|
||||
t->bucketPtr = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
*---------------------------------------------------------
|
||||
*
|
||||
* Hash_FindEntry --
|
||||
*
|
||||
* Searches a hash table for an entry corresponding to key.
|
||||
*
|
||||
* Input:
|
||||
* t Hash table to search.
|
||||
* key A hash key.
|
||||
*
|
||||
* Results:
|
||||
* The return value is a pointer to the entry for key,
|
||||
* if key was present in the table. If key was not
|
||||
* present, NULL is returned.
|
||||
*
|
||||
* Side Effects:
|
||||
* None.
|
||||
*
|
||||
*---------------------------------------------------------
|
||||
*/
|
||||
|
||||
Hash_Entry *
|
||||
Hash_FindEntry(Hash_Table *t, const char *key)
|
||||
{
|
||||
Hash_Entry *e;
|
||||
unsigned h;
|
||||
const char *p;
|
||||
|
||||
if (t == NULL || t->bucketPtr == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
for (h = 0, p = key; *p;)
|
||||
h = (h << 5) - h + *p++;
|
||||
p = key;
|
||||
for (e = t->bucketPtr[h & t->mask]; e != NULL; e = e->next)
|
||||
if (e->namehash == h && strcmp(e->name, p) == 0)
|
||||
return (e);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
*---------------------------------------------------------
|
||||
*
|
||||
* Hash_CreateEntry --
|
||||
*
|
||||
* Searches a hash table for an entry corresponding to
|
||||
* key. If no entry is found, then one is created.
|
||||
*
|
||||
* Input:
|
||||
* t Hash table to search.
|
||||
* key A hash key.
|
||||
* newPtr Filled in with TRUE if new entry created,
|
||||
* FALSE otherwise.
|
||||
*
|
||||
* Results:
|
||||
* The return value is a pointer to the entry. If *newPtr
|
||||
* isn't NULL, then *newPtr is filled in with TRUE if a
|
||||
* new entry was created, and FALSE if an entry already existed
|
||||
* with the given key.
|
||||
*
|
||||
* Side Effects:
|
||||
* Memory may be allocated, and the hash buckets may be modified.
|
||||
*---------------------------------------------------------
|
||||
*/
|
||||
|
||||
Hash_Entry *
|
||||
Hash_CreateEntry(Hash_Table *t, const char *key, Boolean *newPtr)
|
||||
{
|
||||
Hash_Entry *e;
|
||||
unsigned h;
|
||||
const char *p;
|
||||
int keylen;
|
||||
struct Hash_Entry **hp;
|
||||
|
||||
/*
|
||||
* Hash the key. As a side effect, save the length (strlen) of the
|
||||
* key in case we need to create the entry.
|
||||
*/
|
||||
for (h = 0, p = key; *p;)
|
||||
h = (h << 5) - h + *p++;
|
||||
keylen = p - key;
|
||||
p = key;
|
||||
for (e = t->bucketPtr[h & t->mask]; e != NULL; e = e->next) {
|
||||
if (e->namehash == h && strcmp(e->name, p) == 0) {
|
||||
if (newPtr != NULL)
|
||||
*newPtr = FALSE;
|
||||
return (e);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* The desired entry isn't there. Before allocating a new entry,
|
||||
* expand the table if necessary (and this changes the resulting
|
||||
* bucket chain).
|
||||
*/
|
||||
if (t->numEntries >= rebuildLimit * t->size)
|
||||
RebuildTable(t);
|
||||
e = bmake_malloc(sizeof(*e) + keylen);
|
||||
hp = &t->bucketPtr[h & t->mask];
|
||||
e->next = *hp;
|
||||
*hp = e;
|
||||
Hash_SetValue(e, NULL);
|
||||
e->namehash = h;
|
||||
(void)strcpy(e->name, p);
|
||||
t->numEntries++;
|
||||
|
||||
if (newPtr != NULL)
|
||||
*newPtr = TRUE;
|
||||
return (e);
|
||||
}
|
||||
|
||||
/*
|
||||
*---------------------------------------------------------
|
||||
*
|
||||
* Hash_DeleteEntry --
|
||||
*
|
||||
* Delete the given hash table entry and free memory associated with
|
||||
* it.
|
||||
*
|
||||
* Results:
|
||||
* None.
|
||||
*
|
||||
* Side Effects:
|
||||
* Hash chain that entry lives in is modified and memory is freed.
|
||||
*
|
||||
*---------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
Hash_DeleteEntry(Hash_Table *t, Hash_Entry *e)
|
||||
{
|
||||
Hash_Entry **hp, *p;
|
||||
|
||||
if (e == NULL)
|
||||
return;
|
||||
for (hp = &t->bucketPtr[e->namehash & t->mask];
|
||||
(p = *hp) != NULL; hp = &p->next) {
|
||||
if (p == e) {
|
||||
*hp = p->next;
|
||||
free(p);
|
||||
t->numEntries--;
|
||||
return;
|
||||
}
|
||||
}
|
||||
(void)write(2, "bad call to Hash_DeleteEntry\n", 29);
|
||||
abort();
|
||||
}
|
||||
|
||||
/*
|
||||
*---------------------------------------------------------
|
||||
*
|
||||
* Hash_EnumFirst --
|
||||
* This procedure sets things up for a complete search
|
||||
* of all entries recorded in the hash table.
|
||||
*
|
||||
* Input:
|
||||
* t Table to be searched.
|
||||
* searchPtr Area in which to keep state about search.
|
||||
*
|
||||
* Results:
|
||||
* The return value is the address of the first entry in
|
||||
* the hash table, or NULL if the table is empty.
|
||||
*
|
||||
* Side Effects:
|
||||
* The information in searchPtr is initialized so that successive
|
||||
* calls to Hash_Next will return successive HashEntry's
|
||||
* from the table.
|
||||
*
|
||||
*---------------------------------------------------------
|
||||
*/
|
||||
|
||||
Hash_Entry *
|
||||
Hash_EnumFirst(Hash_Table *t, Hash_Search *searchPtr)
|
||||
{
|
||||
searchPtr->tablePtr = t;
|
||||
searchPtr->nextIndex = 0;
|
||||
searchPtr->hashEntryPtr = NULL;
|
||||
return Hash_EnumNext(searchPtr);
|
||||
}
|
||||
|
||||
/*
|
||||
*---------------------------------------------------------
|
||||
*
|
||||
* Hash_EnumNext --
|
||||
* This procedure returns successive entries in the hash table.
|
||||
*
|
||||
* Input:
|
||||
* searchPtr Area used to keep state about search.
|
||||
*
|
||||
* Results:
|
||||
* The return value is a pointer to the next HashEntry
|
||||
* in the table, or NULL when the end of the table is
|
||||
* reached.
|
||||
*
|
||||
* Side Effects:
|
||||
* The information in searchPtr is modified to advance to the
|
||||
* next entry.
|
||||
*
|
||||
*---------------------------------------------------------
|
||||
*/
|
||||
|
||||
Hash_Entry *
|
||||
Hash_EnumNext(Hash_Search *searchPtr)
|
||||
{
|
||||
Hash_Entry *e;
|
||||
Hash_Table *t = searchPtr->tablePtr;
|
||||
|
||||
/*
|
||||
* The hashEntryPtr field points to the most recently returned
|
||||
* entry, or is nil if we are starting up. If not nil, we have
|
||||
* to start at the next one in the chain.
|
||||
*/
|
||||
e = searchPtr->hashEntryPtr;
|
||||
if (e != NULL)
|
||||
e = e->next;
|
||||
/*
|
||||
* If the chain ran out, or if we are starting up, we need to
|
||||
* find the next nonempty chain.
|
||||
*/
|
||||
while (e == NULL) {
|
||||
if (searchPtr->nextIndex >= t->size)
|
||||
return NULL;
|
||||
e = t->bucketPtr[searchPtr->nextIndex++];
|
||||
}
|
||||
searchPtr->hashEntryPtr = e;
|
||||
return (e);
|
||||
}
|
||||
|
||||
/*
|
||||
*---------------------------------------------------------
|
||||
*
|
||||
* RebuildTable --
|
||||
* This local routine makes a new hash table that
|
||||
* is larger than the old one.
|
||||
*
|
||||
* Results:
|
||||
* None.
|
||||
*
|
||||
* Side Effects:
|
||||
* The entire hash table is moved, so any bucket numbers
|
||||
* from the old table are invalid.
|
||||
*
|
||||
*---------------------------------------------------------
|
||||
*/
|
||||
|
||||
static void
|
||||
RebuildTable(Hash_Table *t)
|
||||
{
|
||||
Hash_Entry *e, *next = NULL, **hp, **xp;
|
||||
int i, mask;
|
||||
Hash_Entry **oldhp;
|
||||
int oldsize;
|
||||
|
||||
oldhp = t->bucketPtr;
|
||||
oldsize = i = t->size;
|
||||
i <<= 1;
|
||||
t->size = i;
|
||||
t->mask = mask = i - 1;
|
||||
t->bucketPtr = hp = bmake_malloc(sizeof(*hp) * i);
|
||||
while (--i >= 0)
|
||||
*hp++ = NULL;
|
||||
for (hp = oldhp, i = oldsize; --i >= 0;) {
|
||||
for (e = *hp++; e != NULL; e = next) {
|
||||
next = e->next;
|
||||
xp = &t->bucketPtr[e->namehash & mask];
|
||||
e->next = *xp;
|
||||
*xp = e;
|
||||
}
|
||||
}
|
||||
free(oldhp);
|
||||
}
|
154
20150418/hash.h
Normal file
154
20150418/hash.h
Normal file
@ -0,0 +1,154 @@
|
||||
/* $NetBSD: hash.h,v 1.10 2009/01/24 10:59:09 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)hash.h 8.1 (Berkeley) 6/6/93
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989 by Adam de Boor
|
||||
* Copyright (c) 1989 by Berkeley Softworks
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)hash.h 8.1 (Berkeley) 6/6/93
|
||||
*/
|
||||
|
||||
/* hash.h --
|
||||
*
|
||||
* This file contains definitions used by the hash module,
|
||||
* which maintains hash tables.
|
||||
*/
|
||||
|
||||
#ifndef _HASH
|
||||
#define _HASH
|
||||
|
||||
/*
|
||||
* The following defines one entry in the hash table.
|
||||
*/
|
||||
|
||||
typedef struct Hash_Entry {
|
||||
struct Hash_Entry *next; /* Used to link together all the
|
||||
* entries associated with the same
|
||||
* bucket. */
|
||||
union {
|
||||
void *clientPtr; /* Arbitrary pointer */
|
||||
time_t clientTime; /* Arbitrary Time */
|
||||
} clientInfo;
|
||||
unsigned namehash; /* hash value of key */
|
||||
char name[1]; /* key string */
|
||||
} Hash_Entry;
|
||||
|
||||
typedef struct Hash_Table {
|
||||
struct Hash_Entry **bucketPtr;/* Pointers to Hash_Entry, one
|
||||
* for each bucket in the table. */
|
||||
int size; /* Actual size of array. */
|
||||
int numEntries; /* Number of entries in the table. */
|
||||
int mask; /* Used to select bits for hashing. */
|
||||
} Hash_Table;
|
||||
|
||||
/*
|
||||
* The following structure is used by the searching routines
|
||||
* to record where we are in the search.
|
||||
*/
|
||||
|
||||
typedef struct Hash_Search {
|
||||
Hash_Table *tablePtr; /* Table being searched. */
|
||||
int nextIndex; /* Next bucket to check (after current). */
|
||||
Hash_Entry *hashEntryPtr; /* Next entry to check in current bucket. */
|
||||
} Hash_Search;
|
||||
|
||||
/*
|
||||
* Macros.
|
||||
*/
|
||||
|
||||
/*
|
||||
* void * Hash_GetValue(h)
|
||||
* Hash_Entry *h;
|
||||
*/
|
||||
|
||||
#define Hash_GetValue(h) ((h)->clientInfo.clientPtr)
|
||||
#define Hash_GetTimeValue(h) ((h)->clientInfo.clientTime)
|
||||
|
||||
/*
|
||||
* Hash_SetValue(h, val);
|
||||
* Hash_Entry *h;
|
||||
* char *val;
|
||||
*/
|
||||
|
||||
#define Hash_SetValue(h, val) ((h)->clientInfo.clientPtr = (val))
|
||||
#define Hash_SetTimeValue(h, val) ((h)->clientInfo.clientTime = (val))
|
||||
|
||||
/*
|
||||
* Hash_Size(n) returns the number of words in an object of n bytes
|
||||
*/
|
||||
|
||||
#define Hash_Size(n) (((n) + sizeof (int) - 1) / sizeof (int))
|
||||
|
||||
void Hash_InitTable(Hash_Table *, int);
|
||||
void Hash_DeleteTable(Hash_Table *);
|
||||
Hash_Entry *Hash_FindEntry(Hash_Table *, const char *);
|
||||
Hash_Entry *Hash_CreateEntry(Hash_Table *, const char *, Boolean *);
|
||||
void Hash_DeleteEntry(Hash_Table *, Hash_Entry *);
|
||||
Hash_Entry *Hash_EnumFirst(Hash_Table *, Hash_Search *);
|
||||
Hash_Entry *Hash_EnumNext(Hash_Search *);
|
||||
|
||||
#endif /* _HASH */
|
201
20150418/install-sh
Executable file
201
20150418/install-sh
Executable file
@ -0,0 +1,201 @@
|
||||
:
|
||||
# NAME:
|
||||
# install.sh - portable version of install(1)
|
||||
#
|
||||
# SYNOPSIS:
|
||||
# install [-CNcs] [-f flags] [-i errs] [-o owner] [-g group] [-m mode] file1 file2 ...
|
||||
# install -d [-i errs] [-o owner] [-g group] [-m mode] directory ...
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# Compatible with BSD install(1). Except that '-c' is always
|
||||
# true and we always move an already installed target aside as
|
||||
# this is important on many systems. Recent BSD install(1)
|
||||
# versions have a '-b' option for this.
|
||||
#
|
||||
#
|
||||
# OPTIONS:
|
||||
# -b move previous target file aside (always true).
|
||||
#
|
||||
# -B "suffix"
|
||||
# use "suffix" instead of .old for saving existing target.
|
||||
#
|
||||
# -c copy rather than move the file into place (always true).
|
||||
#
|
||||
# -C compare. Only install if target is missing or
|
||||
# different.
|
||||
#
|
||||
# -N newer. Only install if target is missing or older.
|
||||
#
|
||||
# -s strip target
|
||||
#
|
||||
# -o "owner"
|
||||
# make target owned by "owner"
|
||||
#
|
||||
# -g "group"
|
||||
# make target group owned by "group"
|
||||
#
|
||||
# -m "mode"
|
||||
# set permissions to "mode"
|
||||
#
|
||||
# -f "flags"
|
||||
# Pass "flags" onto chflags(1)
|
||||
#
|
||||
# -i "errs"
|
||||
# Ignore errors from steps indicated by "errs" (``s,o,g,m'').
|
||||
#
|
||||
# BUGS:
|
||||
# The '-i' option is to save your sanity when 'bsd.prog.mk'
|
||||
# insists on haveing a '-o' "owner" option which is doomed to
|
||||
# fail on many systems. We ignore '-b', '-B' and '-c' options.
|
||||
#
|
||||
# AUTHOR:
|
||||
# Simon J. Gerraty <sjg@quick.com.au>
|
||||
#
|
||||
|
||||
# RCSid:
|
||||
# $Id: install-sh,v 1.18 2001/03/16 17:33:02 sjg Exp $
|
||||
#
|
||||
# @(#) Copyright (c) 1993 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@quick.com.au
|
||||
#
|
||||
|
||||
set -- `getopt B:bpxCNcsdo:g:m:i:f: $*`
|
||||
|
||||
Mydir=`dirname $0`
|
||||
[ -s $Mydir/.installrc ] && . $Mydir/.installrc
|
||||
|
||||
owner=:
|
||||
group=:
|
||||
mode=:
|
||||
strip=:
|
||||
mkdirs=
|
||||
compare=:
|
||||
newer=:
|
||||
chflags=:
|
||||
LS1=
|
||||
CP_P=
|
||||
|
||||
while [ $# -gt 1 ]
|
||||
do
|
||||
case $1 in
|
||||
--) shift; break;;
|
||||
-p) CP_P=-p;;
|
||||
-x) set -x;;
|
||||
-B) OLD_EXT=$2; shift;;
|
||||
-C) compare=Different;;
|
||||
-N) newer=Newer;
|
||||
# check if /bin/ls supports -1
|
||||
/bin/ls -1 $0 >/dev/null 2>&1 && LS1=1
|
||||
;;
|
||||
-o) owner="${CHOWN:-chown} $2 "; shift;;
|
||||
-g) group="${CHGRP:-chgrp} $2 "; shift;;
|
||||
-m) mode="${CHMOD:-chmod} $2 "; shift;;
|
||||
-s) strip=${STRIP:-strip};;
|
||||
-d) mkdirs="mkdir -p";;
|
||||
-i) ignore_err="$ignore_err$2"; shift;;
|
||||
-f) chflags="${CHFLAGS:-chflags} $2 "; shift;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
Newer() {
|
||||
n=`/bin/ls -t$LS1 $* 2>/dev/null | head -1`
|
||||
[ $1 = $n ]
|
||||
}
|
||||
|
||||
Different() {
|
||||
cmp -s $*
|
||||
[ $? != 0 ]
|
||||
}
|
||||
|
||||
Err() {
|
||||
case "$ignore_err" in
|
||||
*$1*) ;;
|
||||
*) exit 1;;
|
||||
esac
|
||||
}
|
||||
|
||||
Setem() {
|
||||
# the order is important
|
||||
if [ ! -d $1 ]; then
|
||||
$strip $1 || Err s
|
||||
fi
|
||||
$group $1 || Err g
|
||||
$owner $1 || Err o
|
||||
$mode $1 || Err m
|
||||
$chflags $1 || Err f
|
||||
return 0
|
||||
}
|
||||
|
||||
# a bug in HP-UX's /bin/sh, means we need to re-set $*
|
||||
# after any calls to add_path()
|
||||
args="$*"
|
||||
|
||||
# all this just for chown!
|
||||
add_path () { [ -d $1 ] && eval ${2:-PATH}="\$${2:-PATH}:$1"; }
|
||||
add_path /etc
|
||||
add_path /usr/etc
|
||||
add_path /sbin
|
||||
add_path /usr/sbin
|
||||
|
||||
# restore saved $*
|
||||
set -- $args
|
||||
|
||||
# make directories if needed
|
||||
# and ensure mode etc are as desired
|
||||
if [ "$mkdirs" ]; then
|
||||
for d in $*
|
||||
do
|
||||
[ ! -d $d ] && $mkdirs $d
|
||||
Setem $d
|
||||
done
|
||||
exit 0 # that's all we do
|
||||
fi
|
||||
|
||||
# install files
|
||||
if [ $# -gt 2 ]; then
|
||||
dest_dir=yes
|
||||
elif [ $# -eq 1 ]; then
|
||||
echo "what should I do with $*?" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# get list of files
|
||||
while [ $# -gt 1 ]
|
||||
do
|
||||
files="$files $1"
|
||||
shift
|
||||
done
|
||||
# last one is dest
|
||||
dest=$1
|
||||
shift
|
||||
|
||||
|
||||
if [ "$dest_dir" = yes -a ! -d $dest ]; then
|
||||
echo "no directory $dest" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for f in $files
|
||||
do
|
||||
b=`basename $f`
|
||||
if [ -d $dest ]; then
|
||||
t=$dest/$b
|
||||
else
|
||||
t=$dest
|
||||
fi
|
||||
$newer $f $t || continue
|
||||
$compare $f $t || continue
|
||||
[ -f $t ] && { mv -f $t $t.old || exit 1; }
|
||||
{ cp $CP_P $f $t && Setem $t; } || exit 1
|
||||
done
|
||||
exit 0
|
3054
20150418/job.c
Normal file
3054
20150418/job.c
Normal file
File diff suppressed because it is too large
Load Diff
274
20150418/job.h
Normal file
274
20150418/job.h
Normal file
@ -0,0 +1,274 @@
|
||||
/* $NetBSD: job.h,v 1.42 2013/07/05 22:14:56 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)job.h 8.1 (Berkeley) 6/6/93
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989 by Adam de Boor
|
||||
* Copyright (c) 1989 by Berkeley Softworks
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)job.h 8.1 (Berkeley) 6/6/93
|
||||
*/
|
||||
|
||||
/*-
|
||||
* job.h --
|
||||
* Definitions pertaining to the running of jobs in parallel mode.
|
||||
*/
|
||||
#ifndef _JOB_H_
|
||||
#define _JOB_H_
|
||||
|
||||
#define TMPPAT "makeXXXXXX" /* relative to tmpdir */
|
||||
|
||||
#ifdef USE_SELECT
|
||||
/*
|
||||
* Emulate poll() in terms of select(). This is not a complete
|
||||
* emulation but it is sufficient for make's purposes.
|
||||
*/
|
||||
|
||||
#define poll emul_poll
|
||||
#define pollfd emul_pollfd
|
||||
|
||||
struct emul_pollfd {
|
||||
int fd;
|
||||
short events;
|
||||
short revents;
|
||||
};
|
||||
|
||||
#define POLLIN 0x0001
|
||||
#define POLLOUT 0x0004
|
||||
|
||||
int
|
||||
emul_poll(struct pollfd *fd, int nfd, int timeout);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The POLL_MSEC constant determines the maximum number of milliseconds spent
|
||||
* in poll before coming out to see if a child has finished.
|
||||
*/
|
||||
#define POLL_MSEC 5000
|
||||
|
||||
|
||||
/*-
|
||||
* Job Table definitions.
|
||||
*
|
||||
* Each job has several things associated with it:
|
||||
* 1) The process id of the child shell
|
||||
* 2) The graph node describing the target being made by this job
|
||||
* 3) A LstNode for the first command to be saved after the job
|
||||
* completes. This is NULL if there was no "..." in the job's
|
||||
* commands.
|
||||
* 4) An FILE* for writing out the commands. This is only
|
||||
* used before the job is actually started.
|
||||
* 5) The output is being caught via a pipe and
|
||||
* the descriptors of our pipe, an array in which output is line
|
||||
* buffered and the current position in that buffer are all
|
||||
* maintained for each job.
|
||||
* 6) A word of flags which determine how the module handles errors,
|
||||
* echoing, etc. for the job
|
||||
*
|
||||
* When a job is finished, the Make_Update function is called on each of the
|
||||
* parents of the node which was just remade. This takes care of the upward
|
||||
* traversal of the dependency graph.
|
||||
*/
|
||||
struct pollfd;
|
||||
|
||||
|
||||
#ifdef USE_META
|
||||
# include "meta.h"
|
||||
#endif
|
||||
|
||||
#define JOB_BUFSIZE 1024
|
||||
typedef struct Job {
|
||||
int pid; /* The child's process ID */
|
||||
GNode *node; /* The target the child is making */
|
||||
LstNode tailCmds; /* The node of the first command to be
|
||||
* saved when the job has been run */
|
||||
FILE *cmdFILE; /* When creating the shell script, this is
|
||||
* where the commands go */
|
||||
int exit_status; /* from wait4() in signal handler */
|
||||
char job_state; /* status of the job entry */
|
||||
#define JOB_ST_FREE 0 /* Job is available */
|
||||
#define JOB_ST_SETUP 1 /* Job is allocated but otherwise invalid */
|
||||
#define JOB_ST_RUNNING 3 /* Job is running, pid valid */
|
||||
#define JOB_ST_FINISHED 4 /* Job is done (ie after SIGCHILD) */
|
||||
char job_suspended;
|
||||
short flags; /* Flags to control treatment of job */
|
||||
#define JOB_IGNERR 0x001 /* Ignore non-zero exits */
|
||||
#define JOB_SILENT 0x002 /* no output */
|
||||
#define JOB_SPECIAL 0x004 /* Target is a special one. i.e. run it locally
|
||||
* if we can't export it and maxLocal is 0 */
|
||||
#define JOB_IGNDOTS 0x008 /* Ignore "..." lines when processing
|
||||
* commands */
|
||||
#define JOB_TRACED 0x400 /* we've sent 'set -x' */
|
||||
|
||||
int jobPipe[2]; /* Pipe for readind output from job */
|
||||
struct pollfd *inPollfd; /* pollfd associated with inPipe */
|
||||
char outBuf[JOB_BUFSIZE + 1];
|
||||
/* Buffer for storing the output of the
|
||||
* job, line by line */
|
||||
int curPos; /* Current position in op_outBuf */
|
||||
|
||||
#ifdef USE_META
|
||||
struct BuildMon bm;
|
||||
#endif
|
||||
} Job;
|
||||
|
||||
#define inPipe jobPipe[0]
|
||||
#define outPipe jobPipe[1]
|
||||
|
||||
|
||||
/*-
|
||||
* Shell Specifications:
|
||||
* Each shell type has associated with it the following information:
|
||||
* 1) The string which must match the last character of the shell name
|
||||
* for the shell to be considered of this type. The longest match
|
||||
* wins.
|
||||
* 2) A command to issue to turn off echoing of command lines
|
||||
* 3) A command to issue to turn echoing back on again
|
||||
* 4) What the shell prints, and its length, when given the echo-off
|
||||
* command. This line will not be printed when received from the shell
|
||||
* 5) A boolean to tell if the shell has the ability to control
|
||||
* error checking for individual commands.
|
||||
* 6) The string to turn this checking on.
|
||||
* 7) The string to turn it off.
|
||||
* 8) The command-flag to give to cause the shell to start echoing
|
||||
* commands right away.
|
||||
* 9) The command-flag to cause the shell to Lib_Exit when an error is
|
||||
* detected in one of the commands.
|
||||
*
|
||||
* Some special stuff goes on if a shell doesn't have error control. In such
|
||||
* a case, errCheck becomes a printf template for echoing the command,
|
||||
* should echoing be on and ignErr becomes another printf template for
|
||||
* executing the command while ignoring the return status. Finally errOut
|
||||
* is a printf template for running the command and causing the shell to
|
||||
* exit on error. If any of these strings are empty when hasErrCtl is FALSE,
|
||||
* the command will be executed anyway as is and if it causes an error, so be
|
||||
* it. Any templates setup to echo the command will escape any '$ ` \ "'i
|
||||
* characters in the command string to avoid common problems with
|
||||
* echo "%s\n" as a template.
|
||||
*/
|
||||
typedef struct Shell {
|
||||
const char *name; /* the name of the shell. For Bourne and C
|
||||
* shells, this is used only to find the
|
||||
* shell description when used as the single
|
||||
* source of a .SHELL target. For user-defined
|
||||
* shells, this is the full path of the shell.
|
||||
*/
|
||||
Boolean hasEchoCtl; /* True if both echoOff and echoOn defined */
|
||||
const char *echoOff; /* command to turn off echo */
|
||||
const char *echoOn; /* command to turn it back on again */
|
||||
const char *noPrint; /* command to skip when printing output from
|
||||
* shell. This is usually the command which
|
||||
* was executed to turn off echoing */
|
||||
int noPLen; /* length of noPrint command */
|
||||
Boolean hasErrCtl; /* set if can control error checking for
|
||||
* individual commands */
|
||||
const char *errCheck; /* string to turn error checking on */
|
||||
const char *ignErr; /* string to turn off error checking */
|
||||
const char *errOut; /* string to use for testing exit code */
|
||||
const char *newline; /* string literal that results in a newline
|
||||
* character when it appears outside of any
|
||||
* 'quote' or "quote" characters */
|
||||
char commentChar; /* character used by shell for comment lines */
|
||||
|
||||
/*
|
||||
* command-line flags
|
||||
*/
|
||||
const char *echo; /* echo commands */
|
||||
const char *exit; /* exit on error */
|
||||
} Shell;
|
||||
|
||||
extern const char *shellPath;
|
||||
extern const char *shellName;
|
||||
extern char *shellErrFlag;
|
||||
|
||||
extern int jobTokensRunning; /* tokens currently "out" */
|
||||
extern int maxJobs; /* Max jobs we can run */
|
||||
|
||||
void Shell_Init(void);
|
||||
const char *Shell_GetNewline(void);
|
||||
void Job_Touch(GNode *, Boolean);
|
||||
Boolean Job_CheckCommands(GNode *, void (*abortProc )(const char *, ...));
|
||||
#define CATCH_BLOCK 1
|
||||
void Job_CatchChildren(void);
|
||||
void Job_CatchOutput(void);
|
||||
void Job_Make(GNode *);
|
||||
void Job_Init(void);
|
||||
Boolean Job_Full(void);
|
||||
Boolean Job_Empty(void);
|
||||
ReturnStatus Job_ParseShell(char *);
|
||||
int Job_Finish(void);
|
||||
void Job_End(void);
|
||||
void Job_Wait(void);
|
||||
void Job_AbortAll(void);
|
||||
void JobFlagForMigration(int);
|
||||
void Job_TokenReturn(void);
|
||||
Boolean Job_TokenWithdraw(void);
|
||||
void Job_ServerStart(int, int, int);
|
||||
void Job_SetPrefix(void);
|
||||
Boolean Job_RunTarget(const char *, const char *);
|
||||
|
||||
#endif /* _JOB_H_ */
|
189
20150418/lst.h
Normal file
189
20150418/lst.h
Normal file
@ -0,0 +1,189 @@
|
||||
/* $NetBSD: lst.h,v 1.20 2014/09/07 20:55:34 joerg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)lst.h 8.1 (Berkeley) 6/6/93
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989 by Adam de Boor
|
||||
* Copyright (c) 1989 by Berkeley Softworks
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)lst.h 8.1 (Berkeley) 6/6/93
|
||||
*/
|
||||
|
||||
/*-
|
||||
* lst.h --
|
||||
* Header for using the list library
|
||||
*/
|
||||
#ifndef _LST_H_
|
||||
#define _LST_H_
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "sprite.h"
|
||||
|
||||
/*
|
||||
* basic typedef. This is what the Lst_ functions handle
|
||||
*/
|
||||
|
||||
typedef struct List *Lst;
|
||||
typedef struct ListNode *LstNode;
|
||||
|
||||
typedef void *DuplicateProc(void *);
|
||||
typedef void FreeProc(void *);
|
||||
|
||||
#define LST_CONCNEW 0 /* create new LstNode's when using Lst_Concat */
|
||||
#define LST_CONCLINK 1 /* relink LstNode's when using Lst_Concat */
|
||||
|
||||
/*
|
||||
* Creation/destruction functions
|
||||
*/
|
||||
/* Create a new list */
|
||||
Lst Lst_Init(Boolean);
|
||||
/* Duplicate an existing list */
|
||||
Lst Lst_Duplicate(Lst, DuplicateProc *);
|
||||
/* Destroy an old one */
|
||||
void Lst_Destroy(Lst, FreeProc *);
|
||||
/* True if list is empty */
|
||||
Boolean Lst_IsEmpty(Lst);
|
||||
|
||||
/*
|
||||
* Functions to modify a list
|
||||
*/
|
||||
/* Insert an element before another */
|
||||
ReturnStatus Lst_InsertBefore(Lst, LstNode, void *);
|
||||
/* Insert an element after another */
|
||||
ReturnStatus Lst_InsertAfter(Lst, LstNode, void *);
|
||||
/* Place an element at the front of a lst. */
|
||||
ReturnStatus Lst_AtFront(Lst, void *);
|
||||
/* Place an element at the end of a lst. */
|
||||
ReturnStatus Lst_AtEnd(Lst, void *);
|
||||
/* Remove an element */
|
||||
ReturnStatus Lst_Remove(Lst, LstNode);
|
||||
/* Replace a node with a new value */
|
||||
ReturnStatus Lst_Replace(LstNode, void *);
|
||||
/* Concatenate two lists */
|
||||
ReturnStatus Lst_Concat(Lst, Lst, int);
|
||||
|
||||
/*
|
||||
* Node-specific functions
|
||||
*/
|
||||
/* Return first element in list */
|
||||
LstNode Lst_First(Lst);
|
||||
/* Return last element in list */
|
||||
LstNode Lst_Last(Lst);
|
||||
/* Return successor to given element */
|
||||
LstNode Lst_Succ(LstNode);
|
||||
/* Return predecessor to given element */
|
||||
LstNode Lst_Prev(LstNode);
|
||||
/* Get datum from LstNode */
|
||||
void *Lst_Datum(LstNode);
|
||||
|
||||
/*
|
||||
* Functions for entire lists
|
||||
*/
|
||||
/* Find an element in a list */
|
||||
LstNode Lst_Find(Lst, const void *, int (*)(const void *, const void *));
|
||||
/* Find an element starting from somewhere */
|
||||
LstNode Lst_FindFrom(Lst, LstNode, const void *,
|
||||
int (*cProc)(const void *, const void *));
|
||||
/*
|
||||
* See if the given datum is on the list. Returns the LstNode containing
|
||||
* the datum
|
||||
*/
|
||||
LstNode Lst_Member(Lst, void *);
|
||||
/* Apply a function to all elements of a lst */
|
||||
int Lst_ForEach(Lst, int (*)(void *, void *), void *);
|
||||
/*
|
||||
* Apply a function to all elements of a lst starting from a certain point.
|
||||
* If the list is circular, the application will wrap around to the
|
||||
* beginning of the list again.
|
||||
*/
|
||||
int Lst_ForEachFrom(Lst, LstNode, int (*)(void *, void *),
|
||||
void *);
|
||||
/*
|
||||
* these functions are for dealing with a list as a table, of sorts.
|
||||
* An idea of the "current element" is kept and used by all the functions
|
||||
* between Lst_Open() and Lst_Close().
|
||||
*/
|
||||
/* Open the list */
|
||||
ReturnStatus Lst_Open(Lst);
|
||||
/* Next element please */
|
||||
LstNode Lst_Next(Lst);
|
||||
/* Done yet? */
|
||||
Boolean Lst_IsAtEnd(Lst);
|
||||
/* Finish table access */
|
||||
void Lst_Close(Lst);
|
||||
|
||||
/*
|
||||
* for using the list as a queue
|
||||
*/
|
||||
/* Place an element at tail of queue */
|
||||
ReturnStatus Lst_EnQueue(Lst, void *);
|
||||
/* Remove an element from head of queue */
|
||||
void *Lst_DeQueue(Lst);
|
||||
|
||||
#endif /* _LST_H_ */
|
0
20150418/lst.lib/Makefile
Normal file
0
20150418/lst.lib/Makefile
Normal file
122
20150418/lst.lib/lstAppend.c
Normal file
122
20150418/lst.lib/lstAppend.c
Normal file
@ -0,0 +1,122 @@
|
||||
/* $NetBSD: lstAppend.c,v 1.14 2009/01/23 21:26:30 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: lstAppend.c,v 1.14 2009/01/23 21:26:30 dsl Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)lstAppend.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: lstAppend.c,v 1.14 2009/01/23 21:26:30 dsl Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
/*-
|
||||
* LstAppend.c --
|
||||
* Add a new node with a new datum after an existing node
|
||||
*/
|
||||
|
||||
#include "lstInt.h"
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Lst_InsertAfter --
|
||||
* Create a new node and add it to the given list after the given node.
|
||||
*
|
||||
* Input:
|
||||
* l affected list
|
||||
* ln node after which to append the datum
|
||||
* d said datum
|
||||
*
|
||||
* Results:
|
||||
* SUCCESS if all went well.
|
||||
*
|
||||
* Side Effects:
|
||||
* A new ListNode is created and linked in to the List. The lastPtr
|
||||
* field of the List will be altered if ln is the last node in the
|
||||
* list. lastPtr and firstPtr will alter if the list was empty and
|
||||
* ln was NULL.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
ReturnStatus
|
||||
Lst_InsertAfter(Lst l, LstNode ln, void *d)
|
||||
{
|
||||
List list;
|
||||
ListNode lNode;
|
||||
ListNode nLNode;
|
||||
|
||||
if (LstValid (l) && (ln == NULL && LstIsEmpty (l))) {
|
||||
goto ok;
|
||||
}
|
||||
|
||||
if (!LstValid (l) || LstIsEmpty (l) || ! LstNodeValid (ln, l)) {
|
||||
return (FAILURE);
|
||||
}
|
||||
ok:
|
||||
|
||||
list = l;
|
||||
lNode = ln;
|
||||
|
||||
PAlloc (nLNode, ListNode);
|
||||
nLNode->datum = d;
|
||||
nLNode->useCount = nLNode->flags = 0;
|
||||
|
||||
if (lNode == NULL) {
|
||||
if (list->isCirc) {
|
||||
nLNode->nextPtr = nLNode->prevPtr = nLNode;
|
||||
} else {
|
||||
nLNode->nextPtr = nLNode->prevPtr = NULL;
|
||||
}
|
||||
list->firstPtr = list->lastPtr = nLNode;
|
||||
} else {
|
||||
nLNode->prevPtr = lNode;
|
||||
nLNode->nextPtr = lNode->nextPtr;
|
||||
|
||||
lNode->nextPtr = nLNode;
|
||||
if (nLNode->nextPtr != NULL) {
|
||||
nLNode->nextPtr->prevPtr = nLNode;
|
||||
}
|
||||
|
||||
if (lNode == list->lastPtr) {
|
||||
list->lastPtr = nLNode;
|
||||
}
|
||||
}
|
||||
|
||||
return (SUCCESS);
|
||||
}
|
||||
|
79
20150418/lst.lib/lstAtEnd.c
Normal file
79
20150418/lst.lib/lstAtEnd.c
Normal file
@ -0,0 +1,79 @@
|
||||
/* $NetBSD: lstAtEnd.c,v 1.13 2009/01/23 21:26:30 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: lstAtEnd.c,v 1.13 2009/01/23 21:26:30 dsl Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)lstAtEnd.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: lstAtEnd.c,v 1.13 2009/01/23 21:26:30 dsl Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
/*-
|
||||
* LstAtEnd.c --
|
||||
* Add a node at the end of the list
|
||||
*/
|
||||
|
||||
#include "lstInt.h"
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Lst_AtEnd --
|
||||
* Add a node to the end of the given list
|
||||
*
|
||||
* Input:
|
||||
* l List to which to add the datum
|
||||
* d Datum to add
|
||||
*
|
||||
* Results:
|
||||
* SUCCESS if life is good.
|
||||
*
|
||||
* Side Effects:
|
||||
* A new ListNode is created and added to the list.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
ReturnStatus
|
||||
Lst_AtEnd(Lst l, void *d)
|
||||
{
|
||||
LstNode end;
|
||||
|
||||
end = Lst_Last(l);
|
||||
return (Lst_InsertAfter(l, end, d));
|
||||
}
|
76
20150418/lst.lib/lstAtFront.c
Normal file
76
20150418/lst.lib/lstAtFront.c
Normal file
@ -0,0 +1,76 @@
|
||||
/* $NetBSD: lstAtFront.c,v 1.13 2009/01/23 21:26:30 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: lstAtFront.c,v 1.13 2009/01/23 21:26:30 dsl Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)lstAtFront.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: lstAtFront.c,v 1.13 2009/01/23 21:26:30 dsl Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
/*-
|
||||
* LstAtFront.c --
|
||||
* Add a node at the front of the list
|
||||
*/
|
||||
|
||||
#include "lstInt.h"
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Lst_AtFront --
|
||||
* Place a piece of data at the front of a list
|
||||
*
|
||||
* Results:
|
||||
* SUCCESS or FAILURE
|
||||
*
|
||||
* Side Effects:
|
||||
* A new ListNode is created and stuck at the front of the list.
|
||||
* hence, firstPtr (and possible lastPtr) in the list are altered.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
ReturnStatus
|
||||
Lst_AtFront(Lst l, void *d)
|
||||
{
|
||||
LstNode front;
|
||||
|
||||
front = Lst_First(l);
|
||||
return (Lst_InsertBefore(l, front, d));
|
||||
}
|
86
20150418/lst.lib/lstClose.c
Normal file
86
20150418/lst.lib/lstClose.c
Normal file
@ -0,0 +1,86 @@
|
||||
/* $NetBSD: lstClose.c,v 1.11 2006/10/27 21:37:25 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: lstClose.c,v 1.11 2006/10/27 21:37:25 dsl Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)lstClose.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: lstClose.c,v 1.11 2006/10/27 21:37:25 dsl Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
/*-
|
||||
* LstClose.c --
|
||||
* Close a list for sequential access.
|
||||
* The sequential functions access the list in a slightly different way.
|
||||
* CurPtr points to their idea of the current node in the list and they
|
||||
* access the list based on it. Because the list is circular, Lst_Next
|
||||
* and Lst_Prev will go around the list forever. Lst_IsAtEnd must be
|
||||
* used to determine when to stop.
|
||||
*/
|
||||
|
||||
#include "lstInt.h"
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Lst_Close --
|
||||
* Close a list which was opened for sequential access.
|
||||
*
|
||||
* Input:
|
||||
* l The list to close
|
||||
*
|
||||
* Results:
|
||||
* None.
|
||||
*
|
||||
* Side Effects:
|
||||
* The list is closed.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Lst_Close(Lst l)
|
||||
{
|
||||
List list = l;
|
||||
|
||||
if (LstValid(l) == TRUE) {
|
||||
list->isOpen = FALSE;
|
||||
list->atEnd = Unknown;
|
||||
}
|
||||
}
|
||||
|
185
20150418/lst.lib/lstConcat.c
Normal file
185
20150418/lst.lib/lstConcat.c
Normal file
@ -0,0 +1,185 @@
|
||||
/* $NetBSD: lstConcat.c,v 1.16 2008/12/13 15:19:29 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: lstConcat.c,v 1.16 2008/12/13 15:19:29 dsl Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)lstConcat.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: lstConcat.c,v 1.16 2008/12/13 15:19:29 dsl Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
/*-
|
||||
* listConcat.c --
|
||||
* Function to concatentate two lists.
|
||||
*/
|
||||
|
||||
#include "lstInt.h"
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Lst_Concat --
|
||||
* Concatenate two lists. New elements are created to hold the data
|
||||
* elements, if specified, but the elements themselves are not copied.
|
||||
* If the elements should be duplicated to avoid confusion with another
|
||||
* list, the Lst_Duplicate function should be called first.
|
||||
* If LST_CONCLINK is specified, the second list is destroyed since
|
||||
* its pointers have been corrupted and the list is no longer useable.
|
||||
*
|
||||
* Input:
|
||||
* l1 The list to which l2 is to be appended
|
||||
* l2 The list to append to l1
|
||||
* flags LST_CONCNEW if LstNode's should be duplicated
|
||||
* LST_CONCLINK if should just be relinked
|
||||
*
|
||||
* Results:
|
||||
* SUCCESS if all went well. FAILURE otherwise.
|
||||
*
|
||||
* Side Effects:
|
||||
* New elements are created and appended the first list.
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
ReturnStatus
|
||||
Lst_Concat(Lst l1, Lst l2, int flags)
|
||||
{
|
||||
ListNode ln; /* original LstNode */
|
||||
ListNode nln; /* new LstNode */
|
||||
ListNode last; /* the last element in the list. Keeps
|
||||
* bookkeeping until the end */
|
||||
List list1 = l1;
|
||||
List list2 = l2;
|
||||
|
||||
if (!LstValid (l1) || !LstValid (l2)) {
|
||||
return (FAILURE);
|
||||
}
|
||||
|
||||
if (flags == LST_CONCLINK) {
|
||||
if (list2->firstPtr != NULL) {
|
||||
/*
|
||||
* We set the nextPtr of the
|
||||
* last element of list two to be NIL to make the loop easier and
|
||||
* so we don't need an extra case should the first list turn
|
||||
* out to be non-circular -- the final element will already point
|
||||
* to NIL space and the first element will be untouched if it
|
||||
* existed before and will also point to NIL space if it didn't.
|
||||
*/
|
||||
list2->lastPtr->nextPtr = NULL;
|
||||
/*
|
||||
* So long as the second list isn't empty, we just link the
|
||||
* first element of the second list to the last element of the
|
||||
* first list. If the first list isn't empty, we then link the
|
||||
* last element of the list to the first element of the second list
|
||||
* The last element of the second list, if it exists, then becomes
|
||||
* the last element of the first list.
|
||||
*/
|
||||
list2->firstPtr->prevPtr = list1->lastPtr;
|
||||
if (list1->lastPtr != NULL) {
|
||||
list1->lastPtr->nextPtr = list2->firstPtr;
|
||||
} else {
|
||||
list1->firstPtr = list2->firstPtr;
|
||||
}
|
||||
list1->lastPtr = list2->lastPtr;
|
||||
}
|
||||
if (list1->isCirc && list1->firstPtr != NULL) {
|
||||
/*
|
||||
* If the first list is supposed to be circular and it is (now)
|
||||
* non-empty, we must make sure it's circular by linking the
|
||||
* first element to the last and vice versa
|
||||
*/
|
||||
list1->firstPtr->prevPtr = list1->lastPtr;
|
||||
list1->lastPtr->nextPtr = list1->firstPtr;
|
||||
}
|
||||
free(l2);
|
||||
} else if (list2->firstPtr != NULL) {
|
||||
/*
|
||||
* We set the nextPtr of the last element of list 2 to be nil to make
|
||||
* the loop less difficult. The loop simply goes through the entire
|
||||
* second list creating new LstNodes and filling in the nextPtr, and
|
||||
* prevPtr to fit into l1 and its datum field from the
|
||||
* datum field of the corresponding element in l2. The 'last' node
|
||||
* follows the last of the new nodes along until the entire l2 has
|
||||
* been appended. Only then does the bookkeeping catch up with the
|
||||
* changes. During the first iteration of the loop, if 'last' is nil,
|
||||
* the first list must have been empty so the newly-created node is
|
||||
* made the first node of the list.
|
||||
*/
|
||||
list2->lastPtr->nextPtr = NULL;
|
||||
for (last = list1->lastPtr, ln = list2->firstPtr;
|
||||
ln != NULL;
|
||||
ln = ln->nextPtr)
|
||||
{
|
||||
PAlloc (nln, ListNode);
|
||||
nln->datum = ln->datum;
|
||||
if (last != NULL) {
|
||||
last->nextPtr = nln;
|
||||
} else {
|
||||
list1->firstPtr = nln;
|
||||
}
|
||||
nln->prevPtr = last;
|
||||
nln->flags = nln->useCount = 0;
|
||||
last = nln;
|
||||
}
|
||||
|
||||
/*
|
||||
* Finish bookkeeping. The last new element becomes the last element
|
||||
* of list one.
|
||||
*/
|
||||
list1->lastPtr = last;
|
||||
|
||||
/*
|
||||
* The circularity of both list one and list two must be corrected
|
||||
* for -- list one because of the new nodes added to it; list two
|
||||
* because of the alteration of list2->lastPtr's nextPtr to ease the
|
||||
* above for loop.
|
||||
*/
|
||||
if (list1->isCirc) {
|
||||
list1->lastPtr->nextPtr = list1->firstPtr;
|
||||
list1->firstPtr->prevPtr = list1->lastPtr;
|
||||
} else {
|
||||
last->nextPtr = NULL;
|
||||
}
|
||||
|
||||
if (list2->isCirc) {
|
||||
list2->lastPtr->nextPtr = list2->firstPtr;
|
||||
}
|
||||
}
|
||||
|
||||
return (SUCCESS);
|
||||
}
|
||||
|
77
20150418/lst.lib/lstDatum.c
Normal file
77
20150418/lst.lib/lstDatum.c
Normal file
@ -0,0 +1,77 @@
|
||||
/* $NetBSD: lstDatum.c,v 1.13 2009/01/23 21:26:30 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: lstDatum.c,v 1.13 2009/01/23 21:26:30 dsl Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)lstDatum.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: lstDatum.c,v 1.13 2009/01/23 21:26:30 dsl Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
/*-
|
||||
* LstDatum.c --
|
||||
* Return the datum associated with a list node.
|
||||
*/
|
||||
|
||||
#include "lstInt.h"
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Lst_Datum --
|
||||
* Return the datum stored in the given node.
|
||||
*
|
||||
* Results:
|
||||
* The datum or NULL if the node is invalid.
|
||||
*
|
||||
* Side Effects:
|
||||
* None.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void *
|
||||
Lst_Datum(LstNode ln)
|
||||
{
|
||||
if (ln != NULL) {
|
||||
return ((ln)->datum);
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
87
20150418/lst.lib/lstDeQueue.c
Normal file
87
20150418/lst.lib/lstDeQueue.c
Normal file
@ -0,0 +1,87 @@
|
||||
/* $NetBSD: lstDeQueue.c,v 1.14 2009/01/23 21:26:30 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: lstDeQueue.c,v 1.14 2009/01/23 21:26:30 dsl Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)lstDeQueue.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: lstDeQueue.c,v 1.14 2009/01/23 21:26:30 dsl Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
/*-
|
||||
* LstDeQueue.c --
|
||||
* Remove the node and return its datum from the head of the list
|
||||
*/
|
||||
|
||||
#include "lstInt.h"
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Lst_DeQueue --
|
||||
* Remove and return the datum at the head of the given list.
|
||||
*
|
||||
* Results:
|
||||
* The datum in the node at the head or NULL if the list
|
||||
* is empty.
|
||||
*
|
||||
* Side Effects:
|
||||
* The head node is removed from the list.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void *
|
||||
Lst_DeQueue(Lst l)
|
||||
{
|
||||
void *rd;
|
||||
ListNode tln;
|
||||
|
||||
tln = Lst_First(l);
|
||||
if (tln == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rd = tln->datum;
|
||||
if (Lst_Remove(l, tln) == FAILURE) {
|
||||
return NULL;
|
||||
} else {
|
||||
return (rd);
|
||||
}
|
||||
}
|
||||
|
101
20150418/lst.lib/lstDestroy.c
Normal file
101
20150418/lst.lib/lstDestroy.c
Normal file
@ -0,0 +1,101 @@
|
||||
/* $NetBSD: lstDestroy.c,v 1.16 2008/12/13 15:19:29 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: lstDestroy.c,v 1.16 2008/12/13 15:19:29 dsl Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)lstDestroy.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: lstDestroy.c,v 1.16 2008/12/13 15:19:29 dsl Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
/*-
|
||||
* LstDestroy.c --
|
||||
* Nuke a list and all its resources
|
||||
*/
|
||||
|
||||
#include "lstInt.h"
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Lst_Destroy --
|
||||
* Destroy a list and free all its resources. If the freeProc is
|
||||
* given, it is called with the datum from each node in turn before
|
||||
* the node is freed.
|
||||
*
|
||||
* Results:
|
||||
* None.
|
||||
*
|
||||
* Side Effects:
|
||||
* The given list is freed in its entirety.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
void
|
||||
Lst_Destroy(Lst list, FreeProc *freeProc)
|
||||
{
|
||||
ListNode ln;
|
||||
ListNode tln = NULL;
|
||||
|
||||
if (list == NULL)
|
||||
return;
|
||||
|
||||
/* To ease scanning */
|
||||
if (list->lastPtr != NULL)
|
||||
list->lastPtr->nextPtr = NULL;
|
||||
else {
|
||||
free(list);
|
||||
return;
|
||||
}
|
||||
|
||||
if (freeProc) {
|
||||
for (ln = list->firstPtr; ln != NULL; ln = tln) {
|
||||
tln = ln->nextPtr;
|
||||
freeProc(ln->datum);
|
||||
free(ln);
|
||||
}
|
||||
} else {
|
||||
for (ln = list->firstPtr; ln != NULL; ln = tln) {
|
||||
tln = ln->nextPtr;
|
||||
free(ln);
|
||||
}
|
||||
}
|
||||
|
||||
free(list);
|
||||
}
|
107
20150418/lst.lib/lstDupl.c
Normal file
107
20150418/lst.lib/lstDupl.c
Normal file
@ -0,0 +1,107 @@
|
||||
/* $NetBSD: lstDupl.c,v 1.16 2009/01/23 21:26:30 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: lstDupl.c,v 1.16 2009/01/23 21:26:30 dsl Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)lstDupl.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: lstDupl.c,v 1.16 2009/01/23 21:26:30 dsl Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
/*-
|
||||
* listDupl.c --
|
||||
* Duplicate a list. This includes duplicating the individual
|
||||
* elements.
|
||||
*/
|
||||
|
||||
#include "lstInt.h"
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Lst_Duplicate --
|
||||
* Duplicate an entire list. If a function to copy a void *is
|
||||
* given, the individual client elements will be duplicated as well.
|
||||
*
|
||||
* Input:
|
||||
* l the list to duplicate
|
||||
* copyProc A function to duplicate each void *
|
||||
*
|
||||
* Results:
|
||||
* The new Lst structure or NULL if failure.
|
||||
*
|
||||
* Side Effects:
|
||||
* A new list is created.
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
Lst
|
||||
Lst_Duplicate(Lst l, DuplicateProc *copyProc)
|
||||
{
|
||||
Lst nl;
|
||||
ListNode ln;
|
||||
List list = l;
|
||||
|
||||
if (!LstValid (l)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
nl = Lst_Init(list->isCirc);
|
||||
if (nl == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ln = list->firstPtr;
|
||||
while (ln != NULL) {
|
||||
if (copyProc != NULL) {
|
||||
if (Lst_AtEnd(nl, copyProc(ln->datum)) == FAILURE) {
|
||||
return NULL;
|
||||
}
|
||||
} else if (Lst_AtEnd(nl, ln->datum) == FAILURE) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (list->isCirc && ln == list->lastPtr) {
|
||||
ln = NULL;
|
||||
} else {
|
||||
ln = ln->nextPtr;
|
||||
}
|
||||
}
|
||||
|
||||
return (nl);
|
||||
}
|
78
20150418/lst.lib/lstEnQueue.c
Normal file
78
20150418/lst.lib/lstEnQueue.c
Normal file
@ -0,0 +1,78 @@
|
||||
/* $NetBSD: lstEnQueue.c,v 1.13 2009/01/23 21:26:30 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: lstEnQueue.c,v 1.13 2009/01/23 21:26:30 dsl Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)lstEnQueue.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: lstEnQueue.c,v 1.13 2009/01/23 21:26:30 dsl Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
/*-
|
||||
* LstEnQueue.c--
|
||||
* Treat the list as a queue and place a datum at its end
|
||||
*/
|
||||
|
||||
#include "lstInt.h"
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Lst_EnQueue --
|
||||
* Add the datum to the tail of the given list.
|
||||
*
|
||||
* Results:
|
||||
* SUCCESS or FAILURE as returned by Lst_InsertAfter.
|
||||
*
|
||||
* Side Effects:
|
||||
* the lastPtr field is altered all the time and the firstPtr field
|
||||
* will be altered if the list used to be empty.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
ReturnStatus
|
||||
Lst_EnQueue(Lst l, void *d)
|
||||
{
|
||||
if (LstValid (l) == FALSE) {
|
||||
return (FAILURE);
|
||||
}
|
||||
|
||||
return (Lst_InsertAfter(l, Lst_Last(l), d));
|
||||
}
|
||||
|
74
20150418/lst.lib/lstFind.c
Normal file
74
20150418/lst.lib/lstFind.c
Normal file
@ -0,0 +1,74 @@
|
||||
/* $NetBSD: lstFind.c,v 1.15 2009/01/23 21:58:28 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: lstFind.c,v 1.15 2009/01/23 21:58:28 dsl Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)lstFind.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: lstFind.c,v 1.15 2009/01/23 21:58:28 dsl Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
/*-
|
||||
* LstFind.c --
|
||||
* Find a node on a list.
|
||||
*/
|
||||
|
||||
#include "lstInt.h"
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Lst_Find --
|
||||
* Find a node on the given list using the given comparison function
|
||||
* and the given datum.
|
||||
*
|
||||
* Results:
|
||||
* The found node or NULL if none matches.
|
||||
*
|
||||
* Side Effects:
|
||||
* None.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
LstNode
|
||||
Lst_Find(Lst l, const void *d, int (*cProc)(const void *, const void *))
|
||||
{
|
||||
return (Lst_FindFrom(l, Lst_First(l), d, cProc));
|
||||
}
|
||||
|
90
20150418/lst.lib/lstFindFrom.c
Normal file
90
20150418/lst.lib/lstFindFrom.c
Normal file
@ -0,0 +1,90 @@
|
||||
/* $NetBSD: lstFindFrom.c,v 1.15 2009/01/23 21:58:28 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: lstFindFrom.c,v 1.15 2009/01/23 21:58:28 dsl Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)lstFindFrom.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: lstFindFrom.c,v 1.15 2009/01/23 21:58:28 dsl Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
/*-
|
||||
* LstFindFrom.c --
|
||||
* Find a node on a list from a given starting point. Used by Lst_Find.
|
||||
*/
|
||||
|
||||
#include "lstInt.h"
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Lst_FindFrom --
|
||||
* Search for a node starting and ending with the given one on the
|
||||
* given list using the passed datum and comparison function to
|
||||
* determine when it has been found.
|
||||
*
|
||||
* Results:
|
||||
* The found node or NULL
|
||||
*
|
||||
* Side Effects:
|
||||
* None.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
LstNode
|
||||
Lst_FindFrom(Lst l, LstNode ln, const void *d,
|
||||
int (*cProc)(const void *, const void *))
|
||||
{
|
||||
ListNode tln;
|
||||
|
||||
if (!LstValid (l) || LstIsEmpty (l) || !LstNodeValid (ln, l)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tln = ln;
|
||||
|
||||
do {
|
||||
if ((*cProc)(tln->datum, d) == 0)
|
||||
return (tln);
|
||||
tln = tln->nextPtr;
|
||||
} while (tln != ln && tln != NULL);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
77
20150418/lst.lib/lstFirst.c
Normal file
77
20150418/lst.lib/lstFirst.c
Normal file
@ -0,0 +1,77 @@
|
||||
/* $NetBSD: lstFirst.c,v 1.12 2008/12/13 15:19:29 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: lstFirst.c,v 1.12 2008/12/13 15:19:29 dsl Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)lstFirst.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: lstFirst.c,v 1.12 2008/12/13 15:19:29 dsl Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
/*-
|
||||
* LstFirst.c --
|
||||
* Return the first node of a list
|
||||
*/
|
||||
|
||||
#include "lstInt.h"
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Lst_First --
|
||||
* Return the first node on the given list.
|
||||
*
|
||||
* Results:
|
||||
* The first node or NULL if the list is empty.
|
||||
*
|
||||
* Side Effects:
|
||||
* None.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
LstNode
|
||||
Lst_First(Lst l)
|
||||
{
|
||||
if (!LstValid (l) || LstIsEmpty (l)) {
|
||||
return NULL;
|
||||
} else {
|
||||
return (l->firstPtr);
|
||||
}
|
||||
}
|
||||
|
76
20150418/lst.lib/lstForEach.c
Normal file
76
20150418/lst.lib/lstForEach.c
Normal file
@ -0,0 +1,76 @@
|
||||
/* $NetBSD: lstForEach.c,v 1.13 2009/01/23 21:26:30 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: lstForEach.c,v 1.13 2009/01/23 21:26:30 dsl Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)lstForEach.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: lstForEach.c,v 1.13 2009/01/23 21:26:30 dsl Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
/*-
|
||||
* LstForeach.c --
|
||||
* Perform a given function on all elements of a list.
|
||||
*/
|
||||
|
||||
#include "lstInt.h"
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Lst_ForEach --
|
||||
* Apply the given function to each element of the given list. The
|
||||
* function should return 0 if Lst_ForEach should continue and non-
|
||||
* zero if it should abort.
|
||||
*
|
||||
* Results:
|
||||
* None.
|
||||
*
|
||||
* Side Effects:
|
||||
* Only those created by the passed-in function.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
/*VARARGS2*/
|
||||
int
|
||||
Lst_ForEach(Lst l, int (*proc)(void *, void *), void *d)
|
||||
{
|
||||
return Lst_ForEachFrom(l, Lst_First(l), proc, d);
|
||||
}
|
||||
|
125
20150418/lst.lib/lstForEachFrom.c
Normal file
125
20150418/lst.lib/lstForEachFrom.c
Normal file
@ -0,0 +1,125 @@
|
||||
/* $NetBSD: lstForEachFrom.c,v 1.17 2009/01/23 21:26:30 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: lstForEachFrom.c,v 1.17 2009/01/23 21:26:30 dsl Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)lstForEachFrom.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: lstForEachFrom.c,v 1.17 2009/01/23 21:26:30 dsl Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
/*-
|
||||
* lstForEachFrom.c --
|
||||
* Perform a given function on all elements of a list starting from
|
||||
* a given point.
|
||||
*/
|
||||
|
||||
#include "lstInt.h"
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Lst_ForEachFrom --
|
||||
* Apply the given function to each element of the given list. The
|
||||
* function should return 0 if traversal should continue and non-
|
||||
* zero if it should abort.
|
||||
*
|
||||
* Results:
|
||||
* None.
|
||||
*
|
||||
* Side Effects:
|
||||
* Only those created by the passed-in function.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
/*VARARGS2*/
|
||||
int
|
||||
Lst_ForEachFrom(Lst l, LstNode ln, int (*proc)(void *, void *),
|
||||
void *d)
|
||||
{
|
||||
ListNode tln = ln;
|
||||
List list = l;
|
||||
ListNode next;
|
||||
Boolean done;
|
||||
int result;
|
||||
|
||||
if (!LstValid (list) || LstIsEmpty (list)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
do {
|
||||
/*
|
||||
* Take care of having the current element deleted out from under
|
||||
* us.
|
||||
*/
|
||||
|
||||
next = tln->nextPtr;
|
||||
|
||||
/*
|
||||
* We're done with the traversal if
|
||||
* - the next node to examine is the first in the queue or
|
||||
* doesn't exist and
|
||||
* - nothing's been added after the current node (check this
|
||||
* after proc() has been called).
|
||||
*/
|
||||
done = (next == NULL || next == list->firstPtr);
|
||||
|
||||
(void) tln->useCount++;
|
||||
result = (*proc) (tln->datum, d);
|
||||
(void) tln->useCount--;
|
||||
|
||||
/*
|
||||
* Now check whether a node has been added.
|
||||
* Note: this doesn't work if this node was deleted before
|
||||
* the new node was added.
|
||||
*/
|
||||
if (next != tln->nextPtr) {
|
||||
next = tln->nextPtr;
|
||||
done = 0;
|
||||
}
|
||||
|
||||
if (tln->flags & LN_DELETED) {
|
||||
free((char *)tln);
|
||||
}
|
||||
tln = next;
|
||||
} while (!result && !LstIsEmpty(list) && !done);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
85
20150418/lst.lib/lstInit.c
Normal file
85
20150418/lst.lib/lstInit.c
Normal file
@ -0,0 +1,85 @@
|
||||
/* $NetBSD: lstInit.c,v 1.12 2008/12/13 15:19:29 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: lstInit.c,v 1.12 2008/12/13 15:19:29 dsl Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)lstInit.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: lstInit.c,v 1.12 2008/12/13 15:19:29 dsl Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
/*-
|
||||
* init.c --
|
||||
* Initialize a new linked list.
|
||||
*/
|
||||
|
||||
#include "lstInt.h"
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Lst_Init --
|
||||
* Create and initialize a new list.
|
||||
*
|
||||
* Input:
|
||||
* circ TRUE if the list should be made circular
|
||||
*
|
||||
* Results:
|
||||
* The created list.
|
||||
*
|
||||
* Side Effects:
|
||||
* A list is created, what else?
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
Lst
|
||||
Lst_Init(Boolean circ)
|
||||
{
|
||||
List nList;
|
||||
|
||||
PAlloc (nList, List);
|
||||
|
||||
nList->firstPtr = NULL;
|
||||
nList->lastPtr = NULL;
|
||||
nList->isOpen = FALSE;
|
||||
nList->isCirc = circ;
|
||||
nList->atEnd = Unknown;
|
||||
|
||||
return (nList);
|
||||
}
|
122
20150418/lst.lib/lstInsert.c
Normal file
122
20150418/lst.lib/lstInsert.c
Normal file
@ -0,0 +1,122 @@
|
||||
/* $NetBSD: lstInsert.c,v 1.14 2009/01/23 21:26:30 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: lstInsert.c,v 1.14 2009/01/23 21:26:30 dsl Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)lstInsert.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: lstInsert.c,v 1.14 2009/01/23 21:26:30 dsl Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
/*-
|
||||
* LstInsert.c --
|
||||
* Insert a new datum before an old one
|
||||
*/
|
||||
|
||||
#include "lstInt.h"
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Lst_InsertBefore --
|
||||
* Insert a new node with the given piece of data before the given
|
||||
* node in the given list.
|
||||
*
|
||||
* Input:
|
||||
* l list to manipulate
|
||||
* ln node before which to insert d
|
||||
* d datum to be inserted
|
||||
*
|
||||
* Results:
|
||||
* SUCCESS or FAILURE.
|
||||
*
|
||||
* Side Effects:
|
||||
* the firstPtr field will be changed if ln is the first node in the
|
||||
* list.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
ReturnStatus
|
||||
Lst_InsertBefore(Lst l, LstNode ln, void *d)
|
||||
{
|
||||
ListNode nLNode; /* new lnode for d */
|
||||
ListNode lNode = ln;
|
||||
List list = l;
|
||||
|
||||
|
||||
/*
|
||||
* check validity of arguments
|
||||
*/
|
||||
if (LstValid (l) && (LstIsEmpty (l) && ln == NULL))
|
||||
goto ok;
|
||||
|
||||
if (!LstValid (l) || LstIsEmpty (l) || !LstNodeValid (ln, l)) {
|
||||
return (FAILURE);
|
||||
}
|
||||
|
||||
ok:
|
||||
PAlloc (nLNode, ListNode);
|
||||
|
||||
nLNode->datum = d;
|
||||
nLNode->useCount = nLNode->flags = 0;
|
||||
|
||||
if (ln == NULL) {
|
||||
if (list->isCirc) {
|
||||
nLNode->prevPtr = nLNode->nextPtr = nLNode;
|
||||
} else {
|
||||
nLNode->prevPtr = nLNode->nextPtr = NULL;
|
||||
}
|
||||
list->firstPtr = list->lastPtr = nLNode;
|
||||
} else {
|
||||
nLNode->prevPtr = lNode->prevPtr;
|
||||
nLNode->nextPtr = lNode;
|
||||
|
||||
if (nLNode->prevPtr != NULL) {
|
||||
nLNode->prevPtr->nextPtr = nLNode;
|
||||
}
|
||||
lNode->prevPtr = nLNode;
|
||||
|
||||
if (lNode == list->firstPtr) {
|
||||
list->firstPtr = nLNode;
|
||||
}
|
||||
}
|
||||
|
||||
return (SUCCESS);
|
||||
}
|
||||
|
105
20150418/lst.lib/lstInt.h
Normal file
105
20150418/lst.lib/lstInt.h
Normal file
@ -0,0 +1,105 @@
|
||||
/* $NetBSD: lstInt.h,v 1.22 2014/09/07 20:55:34 joerg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)lstInt.h 8.1 (Berkeley) 6/6/93
|
||||
*/
|
||||
|
||||
/*-
|
||||
* lstInt.h --
|
||||
* Internals for the list library
|
||||
*/
|
||||
#ifndef _LSTINT_H_
|
||||
#define _LSTINT_H_
|
||||
|
||||
#include "../lst.h"
|
||||
#include "../make_malloc.h"
|
||||
|
||||
typedef struct ListNode {
|
||||
struct ListNode *prevPtr; /* previous element in list */
|
||||
struct ListNode *nextPtr; /* next in list */
|
||||
unsigned int useCount:8, /* Count of functions using the node.
|
||||
* node may not be deleted until count
|
||||
* goes to 0 */
|
||||
flags:8; /* Node status flags */
|
||||
void *datum; /* datum associated with this element */
|
||||
} *ListNode;
|
||||
/*
|
||||
* Flags required for synchronization
|
||||
*/
|
||||
#define LN_DELETED 0x0001 /* List node should be removed when done */
|
||||
|
||||
typedef enum {
|
||||
Head, Middle, Tail, Unknown
|
||||
} Where;
|
||||
|
||||
typedef struct List {
|
||||
ListNode firstPtr; /* first node in list */
|
||||
ListNode lastPtr; /* last node in list */
|
||||
Boolean isCirc; /* true if the list should be considered
|
||||
* circular */
|
||||
/*
|
||||
* fields for sequential access
|
||||
*/
|
||||
Where atEnd; /* Where in the list the last access was */
|
||||
Boolean isOpen; /* true if list has been Lst_Open'ed */
|
||||
ListNode curPtr; /* current node, if open. NULL if
|
||||
* *just* opened */
|
||||
ListNode prevPtr; /* Previous node, if open. Used by
|
||||
* Lst_Remove */
|
||||
} *List;
|
||||
|
||||
/*
|
||||
* PAlloc (var, ptype) --
|
||||
* Allocate a pointer-typedef structure 'ptype' into the variable 'var'
|
||||
*/
|
||||
#define PAlloc(var,ptype) var = (ptype) bmake_malloc(sizeof *(var))
|
||||
|
||||
/*
|
||||
* LstValid (l) --
|
||||
* Return TRUE if the list l is valid
|
||||
*/
|
||||
#define LstValid(l) ((Lst)(l) != NULL)
|
||||
|
||||
/*
|
||||
* LstNodeValid (ln, l) --
|
||||
* Return TRUE if the LstNode ln is valid with respect to l
|
||||
*/
|
||||
#define LstNodeValid(ln, l) ((ln) != NULL)
|
||||
|
||||
/*
|
||||
* LstIsEmpty (l) --
|
||||
* TRUE if the list l is empty.
|
||||
*/
|
||||
#define LstIsEmpty(l) (((List)(l))->firstPtr == NULL)
|
||||
|
||||
#endif /* _LSTINT_H_ */
|
87
20150418/lst.lib/lstIsAtEnd.c
Normal file
87
20150418/lst.lib/lstIsAtEnd.c
Normal file
@ -0,0 +1,87 @@
|
||||
/* $NetBSD: lstIsAtEnd.c,v 1.13 2008/02/15 21:29:50 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: lstIsAtEnd.c,v 1.13 2008/02/15 21:29:50 christos Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)lstIsAtEnd.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: lstIsAtEnd.c,v 1.13 2008/02/15 21:29:50 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
/*-
|
||||
* LstIsAtEnd.c --
|
||||
* Tell if the current node is at the end of the list.
|
||||
* The sequential functions access the list in a slightly different way.
|
||||
* CurPtr points to their idea of the current node in the list and they
|
||||
* access the list based on it. Because the list is circular, Lst_Next
|
||||
* and Lst_Prev will go around the list forever. Lst_IsAtEnd must be
|
||||
* used to determine when to stop.
|
||||
*/
|
||||
|
||||
#include "lstInt.h"
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Lst_IsAtEnd --
|
||||
* Return true if have reached the end of the given list.
|
||||
*
|
||||
* Results:
|
||||
* TRUE if at the end of the list (this includes the list not being
|
||||
* open or being invalid) or FALSE if not. We return TRUE if the list
|
||||
* is invalid or unopend so as to cause the caller to exit its loop
|
||||
* asap, the assumption being that the loop is of the form
|
||||
* while (!Lst_IsAtEnd (l)) {
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* Side Effects:
|
||||
* None.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
Boolean
|
||||
Lst_IsAtEnd(Lst l)
|
||||
{
|
||||
List list = l;
|
||||
|
||||
return (!LstValid (l) || !list->isOpen ||
|
||||
(list->atEnd == Head) || (list->atEnd == Tail));
|
||||
}
|
||||
|
75
20150418/lst.lib/lstIsEmpty.c
Normal file
75
20150418/lst.lib/lstIsEmpty.c
Normal file
@ -0,0 +1,75 @@
|
||||
/* $NetBSD: lstIsEmpty.c,v 1.11 2008/12/13 15:19:29 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: lstIsEmpty.c,v 1.11 2008/12/13 15:19:29 dsl Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)lstIsEmpty.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: lstIsEmpty.c,v 1.11 2008/12/13 15:19:29 dsl Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
/*-
|
||||
* LstIsEmpty.c --
|
||||
* A single function to decide if a list is empty
|
||||
*/
|
||||
|
||||
#include "lstInt.h"
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Lst_IsEmpty --
|
||||
* Return TRUE if the given list is empty.
|
||||
*
|
||||
* Results:
|
||||
* TRUE if the list is empty, FALSE otherwise.
|
||||
*
|
||||
* Side Effects:
|
||||
* None.
|
||||
*
|
||||
* A list is considered empty if its firstPtr == NULL (or if
|
||||
* the list itself is NULL).
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
Boolean
|
||||
Lst_IsEmpty(Lst l)
|
||||
{
|
||||
return ( ! LstValid (l) || LstIsEmpty(l));
|
||||
}
|
||||
|
77
20150418/lst.lib/lstLast.c
Normal file
77
20150418/lst.lib/lstLast.c
Normal file
@ -0,0 +1,77 @@
|
||||
/* $NetBSD: lstLast.c,v 1.12 2008/12/13 15:19:29 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: lstLast.c,v 1.12 2008/12/13 15:19:29 dsl Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)lstLast.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: lstLast.c,v 1.12 2008/12/13 15:19:29 dsl Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
/*-
|
||||
* LstLast.c --
|
||||
* Return the last element of a list
|
||||
*/
|
||||
|
||||
#include "lstInt.h"
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Lst_Last --
|
||||
* Return the last node on the list l.
|
||||
*
|
||||
* Results:
|
||||
* The requested node or NULL if the list is empty.
|
||||
*
|
||||
* Side Effects:
|
||||
* None.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
LstNode
|
||||
Lst_Last(Lst l)
|
||||
{
|
||||
if (!LstValid(l) || LstIsEmpty (l)) {
|
||||
return NULL;
|
||||
} else {
|
||||
return (l->lastPtr);
|
||||
}
|
||||
}
|
||||
|
77
20150418/lst.lib/lstMember.c
Normal file
77
20150418/lst.lib/lstMember.c
Normal file
@ -0,0 +1,77 @@
|
||||
/* $NetBSD: lstMember.c,v 1.14 2013/11/14 00:01:28 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: lstMember.c,v 1.14 2013/11/14 00:01:28 sjg Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)lstMember.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: lstMember.c,v 1.14 2013/11/14 00:01:28 sjg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
/*-
|
||||
* lstMember.c --
|
||||
* See if a given datum is on a given list.
|
||||
*/
|
||||
|
||||
#include "lstInt.h"
|
||||
|
||||
LstNode
|
||||
Lst_Member(Lst l, void *d)
|
||||
{
|
||||
List list = l;
|
||||
ListNode lNode;
|
||||
|
||||
if (list == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
lNode = list->firstPtr;
|
||||
if (lNode == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
do {
|
||||
if (lNode->datum == d) {
|
||||
return lNode;
|
||||
}
|
||||
lNode = lNode->nextPtr;
|
||||
} while (lNode != NULL && lNode != list->firstPtr);
|
||||
|
||||
return NULL;
|
||||
}
|
120
20150418/lst.lib/lstNext.c
Normal file
120
20150418/lst.lib/lstNext.c
Normal file
@ -0,0 +1,120 @@
|
||||
/* $NetBSD: lstNext.c,v 1.12 2008/12/13 15:19:29 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: lstNext.c,v 1.12 2008/12/13 15:19:29 dsl Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)lstNext.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: lstNext.c,v 1.12 2008/12/13 15:19:29 dsl Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
/*-
|
||||
* LstNext.c --
|
||||
* Return the next node for a list.
|
||||
* The sequential functions access the list in a slightly different way.
|
||||
* CurPtr points to their idea of the current node in the list and they
|
||||
* access the list based on it. Because the list is circular, Lst_Next
|
||||
* and Lst_Prev will go around the list forever. Lst_IsAtEnd must be
|
||||
* used to determine when to stop.
|
||||
*/
|
||||
|
||||
#include "lstInt.h"
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Lst_Next --
|
||||
* Return the next node for the given list.
|
||||
*
|
||||
* Results:
|
||||
* The next node or NULL if the list has yet to be opened. Also
|
||||
* if the list is non-circular and the end has been reached, NULL
|
||||
* is returned.
|
||||
*
|
||||
* Side Effects:
|
||||
* the curPtr field is updated.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
LstNode
|
||||
Lst_Next(Lst l)
|
||||
{
|
||||
ListNode tln;
|
||||
List list = l;
|
||||
|
||||
if ((LstValid (l) == FALSE) ||
|
||||
(list->isOpen == FALSE)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
list->prevPtr = list->curPtr;
|
||||
|
||||
if (list->curPtr == NULL) {
|
||||
if (list->atEnd == Unknown) {
|
||||
/*
|
||||
* If we're just starting out, atEnd will be Unknown.
|
||||
* Then we want to start this thing off in the right
|
||||
* direction -- at the start with atEnd being Middle.
|
||||
*/
|
||||
list->curPtr = tln = list->firstPtr;
|
||||
list->atEnd = Middle;
|
||||
} else {
|
||||
tln = NULL;
|
||||
list->atEnd = Tail;
|
||||
}
|
||||
} else {
|
||||
tln = list->curPtr->nextPtr;
|
||||
list->curPtr = tln;
|
||||
|
||||
if (tln == list->firstPtr || tln == NULL) {
|
||||
/*
|
||||
* If back at the front, then we've hit the end...
|
||||
*/
|
||||
list->atEnd = Tail;
|
||||
} else {
|
||||
/*
|
||||
* Reset to Middle if gone past first.
|
||||
*/
|
||||
list->atEnd = Middle;
|
||||
}
|
||||
}
|
||||
|
||||
return (tln);
|
||||
}
|
||||
|
87
20150418/lst.lib/lstOpen.c
Normal file
87
20150418/lst.lib/lstOpen.c
Normal file
@ -0,0 +1,87 @@
|
||||
/* $NetBSD: lstOpen.c,v 1.12 2008/12/13 15:19:29 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: lstOpen.c,v 1.12 2008/12/13 15:19:29 dsl Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)lstOpen.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: lstOpen.c,v 1.12 2008/12/13 15:19:29 dsl Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
/*-
|
||||
* LstOpen.c --
|
||||
* Open a list for sequential access. The sequential functions access the
|
||||
* list in a slightly different way. CurPtr points to their idea of the
|
||||
* current node in the list and they access the list based on it.
|
||||
* If the list is circular, Lst_Next and Lst_Prev will go around
|
||||
* the list forever. Lst_IsAtEnd must be used to determine when to stop.
|
||||
*/
|
||||
|
||||
#include "lstInt.h"
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Lst_Open --
|
||||
* Open a list for sequential access. A list can still be searched,
|
||||
* etc., without confusing these functions.
|
||||
*
|
||||
* Results:
|
||||
* SUCCESS or FAILURE.
|
||||
*
|
||||
* Side Effects:
|
||||
* isOpen is set TRUE and curPtr is set to NULL so the
|
||||
* other sequential functions no it was just opened and can choose
|
||||
* the first element accessed based on this.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
ReturnStatus
|
||||
Lst_Open(Lst l)
|
||||
{
|
||||
if (LstValid (l) == FALSE) {
|
||||
return (FAILURE);
|
||||
}
|
||||
(l)->isOpen = TRUE;
|
||||
(l)->atEnd = LstIsEmpty (l) ? Head : Unknown;
|
||||
(l)->curPtr = NULL;
|
||||
|
||||
return (SUCCESS);
|
||||
}
|
||||
|
79
20150418/lst.lib/lstPrev.c
Normal file
79
20150418/lst.lib/lstPrev.c
Normal file
@ -0,0 +1,79 @@
|
||||
/* $NetBSD: lstPrev.c,v 1.3 2008/12/13 15:19:29 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: lstPrev.c,v 1.3 2008/12/13 15:19:29 dsl Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)lstSucc.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: lstPrev.c,v 1.3 2008/12/13 15:19:29 dsl Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
/*-
|
||||
* LstPrev.c --
|
||||
* return the predecessor to a given node
|
||||
*/
|
||||
|
||||
#include "lstInt.h"
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Lst_Prev --
|
||||
* Return the predecessor to the given node on its list.
|
||||
*
|
||||
* Results:
|
||||
* The predecessor of the node, if it exists (note that on a circular
|
||||
* list, if the node is the only one in the list, it is its own
|
||||
* predecessor).
|
||||
*
|
||||
* Side Effects:
|
||||
* None.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
LstNode
|
||||
Lst_Prev(LstNode ln)
|
||||
{
|
||||
if (ln == NULL) {
|
||||
return NULL;
|
||||
} else {
|
||||
return (ln->prevPtr);
|
||||
}
|
||||
}
|
||||
|
136
20150418/lst.lib/lstRemove.c
Normal file
136
20150418/lst.lib/lstRemove.c
Normal file
@ -0,0 +1,136 @@
|
||||
/* $NetBSD: lstRemove.c,v 1.16 2014/09/07 20:55:34 joerg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: lstRemove.c,v 1.16 2014/09/07 20:55:34 joerg Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)lstRemove.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: lstRemove.c,v 1.16 2014/09/07 20:55:34 joerg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
/*-
|
||||
* LstRemove.c --
|
||||
* Remove an element from a list
|
||||
*/
|
||||
|
||||
#include "lstInt.h"
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Lst_Remove --
|
||||
* Remove the given node from the given list.
|
||||
*
|
||||
* Results:
|
||||
* SUCCESS or FAILURE.
|
||||
*
|
||||
* Side Effects:
|
||||
* The list's firstPtr will be set to NULL if ln is the last
|
||||
* node on the list. firsPtr and lastPtr will be altered if ln is
|
||||
* either the first or last node, respectively, on the list.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
ReturnStatus
|
||||
Lst_Remove(Lst l, LstNode ln)
|
||||
{
|
||||
List list = l;
|
||||
ListNode lNode = ln;
|
||||
|
||||
if (!LstValid (l) ||
|
||||
!LstNodeValid (ln, l)) {
|
||||
return (FAILURE);
|
||||
}
|
||||
|
||||
/*
|
||||
* unlink it from the list
|
||||
*/
|
||||
if (lNode->nextPtr != NULL) {
|
||||
lNode->nextPtr->prevPtr = lNode->prevPtr;
|
||||
}
|
||||
if (lNode->prevPtr != NULL) {
|
||||
lNode->prevPtr->nextPtr = lNode->nextPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* if either the firstPtr or lastPtr of the list point to this node,
|
||||
* adjust them accordingly
|
||||
*/
|
||||
if (list->firstPtr == lNode) {
|
||||
list->firstPtr = lNode->nextPtr;
|
||||
}
|
||||
if (list->lastPtr == lNode) {
|
||||
list->lastPtr = lNode->prevPtr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Sequential access stuff. If the node we're removing is the current
|
||||
* node in the list, reset the current node to the previous one. If the
|
||||
* previous one was non-existent (prevPtr == NULL), we set the
|
||||
* end to be Unknown, since it is.
|
||||
*/
|
||||
if (list->isOpen && (list->curPtr == lNode)) {
|
||||
list->curPtr = list->prevPtr;
|
||||
if (list->curPtr == NULL) {
|
||||
list->atEnd = Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* the only way firstPtr can still point to ln is if ln is the last
|
||||
* node on the list (the list is circular, so lNode->nextptr == lNode in
|
||||
* this case). The list is, therefore, empty and is marked as such
|
||||
*/
|
||||
if (list->firstPtr == lNode) {
|
||||
list->firstPtr = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* note that the datum is unmolested. The caller must free it as
|
||||
* necessary and as expected.
|
||||
*/
|
||||
if (lNode->useCount == 0) {
|
||||
free(ln);
|
||||
} else {
|
||||
lNode->flags |= LN_DELETED;
|
||||
}
|
||||
|
||||
return (SUCCESS);
|
||||
}
|
||||
|
78
20150418/lst.lib/lstReplace.c
Normal file
78
20150418/lst.lib/lstReplace.c
Normal file
@ -0,0 +1,78 @@
|
||||
/* $NetBSD: lstReplace.c,v 1.13 2009/01/23 21:26:30 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: lstReplace.c,v 1.13 2009/01/23 21:26:30 dsl Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)lstReplace.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: lstReplace.c,v 1.13 2009/01/23 21:26:30 dsl Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
/*-
|
||||
* LstReplace.c --
|
||||
* Replace the datum in a node with a new datum
|
||||
*/
|
||||
|
||||
#include "lstInt.h"
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Lst_Replace --
|
||||
* Replace the datum in the given node with the new datum
|
||||
*
|
||||
* Results:
|
||||
* SUCCESS or FAILURE.
|
||||
*
|
||||
* Side Effects:
|
||||
* The datum field fo the node is altered.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
ReturnStatus
|
||||
Lst_Replace(LstNode ln, void *d)
|
||||
{
|
||||
if (ln == NULL) {
|
||||
return (FAILURE);
|
||||
} else {
|
||||
(ln)->datum = d;
|
||||
return (SUCCESS);
|
||||
}
|
||||
}
|
||||
|
79
20150418/lst.lib/lstSucc.c
Normal file
79
20150418/lst.lib/lstSucc.c
Normal file
@ -0,0 +1,79 @@
|
||||
/* $NetBSD: lstSucc.c,v 1.13 2008/12/13 15:19:29 dsl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: lstSucc.c,v 1.13 2008/12/13 15:19:29 dsl Exp $";
|
||||
#else
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)lstSucc.c 8.1 (Berkeley) 6/6/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: lstSucc.c,v 1.13 2008/12/13 15:19:29 dsl Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
||||
/*-
|
||||
* LstSucc.c --
|
||||
* return the successor to a given node
|
||||
*/
|
||||
|
||||
#include "lstInt.h"
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Lst_Succ --
|
||||
* Return the successor to the given node on its list.
|
||||
*
|
||||
* Results:
|
||||
* The successor of the node, if it exists (note that on a circular
|
||||
* list, if the node is the only one in the list, it is its own
|
||||
* successor).
|
||||
*
|
||||
* Side Effects:
|
||||
* None.
|
||||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
LstNode
|
||||
Lst_Succ(LstNode ln)
|
||||
{
|
||||
if (ln == NULL) {
|
||||
return NULL;
|
||||
} else {
|
||||
return (ln->nextPtr);
|
||||
}
|
||||
}
|
||||
|
96
20150418/machine.sh
Executable file
96
20150418/machine.sh
Executable file
@ -0,0 +1,96 @@
|
||||
:
|
||||
# derrived from /etc/rc_d/os.sh
|
||||
|
||||
# RCSid:
|
||||
# $Id: machine.sh,v 1.16 2010/10/17 00:05:51 sjg Exp $
|
||||
#
|
||||
# @(#) Copyright (c) 1994-2002 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
|
||||
#
|
||||
|
||||
OS=`uname`
|
||||
OSREL=`uname -r`
|
||||
OSMAJOR=`IFS=.; set $OSREL; echo $1`
|
||||
machine=`uname -p 2>/dev/null || uname -m`
|
||||
MACHINE=
|
||||
|
||||
# there is at least one case of `uname -p` outputting
|
||||
# a bunch of usless drivel
|
||||
case "$machine" in
|
||||
unknown|*[!A-Za-z0-9_-]*)
|
||||
machine=`uname -m`
|
||||
;;
|
||||
esac
|
||||
|
||||
# Great! Solaris keeps moving arch(1)
|
||||
# we need this here, and it is not always available...
|
||||
Which() {
|
||||
# some shells cannot correctly handle `IFS`
|
||||
# in conjunction with the for loop.
|
||||
_dirs=`IFS=:; echo ${2:-$PATH}`
|
||||
for d in $_dirs
|
||||
do
|
||||
test -x $d/$1 && { echo $d/$1; break; }
|
||||
done
|
||||
}
|
||||
|
||||
case $OS in
|
||||
OpenBSD)
|
||||
MACHINE=$OS$OSMAJOR.$machine
|
||||
arch=`Which arch /usr/bin:/usr/ucb:$PATH`
|
||||
MACHINE_ARCH=`$arch -s`;
|
||||
;;
|
||||
*BSD)
|
||||
MACHINE=$OS$OSMAJOR.$machine
|
||||
;;
|
||||
SunOS)
|
||||
arch=`Which arch /usr/bin:/usr/ucb:$PATH`
|
||||
test "$arch" && machine_arch=`$arch`
|
||||
|
||||
case "$OSREL" in
|
||||
4.0*) MACHINE_ARCH=$machine_arch MACHINE=$machine_arch;;
|
||||
4*) MACHINE_ARCH=$machine_arch;;
|
||||
esac
|
||||
;;
|
||||
HP-UX)
|
||||
MACHINE_ARCH=`IFS="/-."; set $machine; echo $1`
|
||||
;;
|
||||
Interix)
|
||||
MACHINE=i386
|
||||
MACHINE_ARCH=i386
|
||||
;;
|
||||
UnixWare)
|
||||
OSREL=`uname -v`
|
||||
OSMAJOR=`IFS=.; set $OSREL; echo $1`
|
||||
MACHINE_ARCH=`uname -m`
|
||||
;;
|
||||
Linux)
|
||||
case "$machine" in
|
||||
i?86) MACHINE_ARCH=i386;;# does anyone really care about 686 vs 586?
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
||||
MACHINE=${MACHINE:-$OS$OSMAJOR}
|
||||
MACHINE_ARCH=${MACHINE_ARCH:-$machine}
|
||||
|
||||
(
|
||||
case "$0" in
|
||||
arch*) echo $MACHINE_ARCH;;
|
||||
*)
|
||||
case "$1" in
|
||||
"") echo $MACHINE;;
|
||||
*) echo $MACHINE_ARCH;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
) | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
|
2023
20150418/main.c
Normal file
2023
20150418/main.c
Normal file
File diff suppressed because it is too large
Load Diff
84
20150418/make-bootstrap.sh.in
Executable file
84
20150418/make-bootstrap.sh.in
Executable file
@ -0,0 +1,84 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
srcdir=@srcdir@
|
||||
|
||||
DEFAULT_SYS_PATH="@default_sys_path@"
|
||||
|
||||
case "@use_meta@" in
|
||||
yes) XDEFS="-DUSE_META ${XDEFS}";;
|
||||
esac
|
||||
|
||||
CC="@CC@"
|
||||
CFLAGS="@CFLAGS@ -I. -I${srcdir} @DEFS@ @CPPFLAGS@ -DMAKE_NATIVE ${XDEFS} -DBMAKE_PATH_MAX=@bmake_path_max@"
|
||||
|
||||
MAKE_VERSION=`sed -n '/^MAKE_VERSION=/s,.*=[^0-9]*,,p' $srcdir/Makefile`
|
||||
|
||||
MDEFS="-DMAKE_VERSION=\"$MAKE_VERSION\" \
|
||||
-D@force_machine@MACHINE=\"@machine@\" -DMACHINE_ARCH=\"@machine_arch@\" \
|
||||
-D_PATH_DEFSYSPATH=\"${DEFAULT_SYS_PATH}\""
|
||||
|
||||
|
||||
LDFLAGS="@LDFLAGS@"
|
||||
LIBS="@LIBS@"
|
||||
|
||||
do_compile2() {
|
||||
obj="$1"; shift
|
||||
src="$1"; shift
|
||||
echo ${CC} -c ${CFLAGS} "$@" -o "$obj" "$src"
|
||||
${CC} -c ${CFLAGS} "$@" -o "$obj" "$src"
|
||||
}
|
||||
|
||||
do_compile() {
|
||||
obj="$1"; shift
|
||||
src=`basename "$obj" .o`.c
|
||||
|
||||
for d in "$srcdir" "$srcdir/lst.lib"
|
||||
do
|
||||
test -s "$d/$src" || continue
|
||||
|
||||
do_compile2 "$obj" "$d/$src" "$@" || exit 1
|
||||
return
|
||||
done
|
||||
echo "Unknown object file '$obj'" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
do_link() {
|
||||
output="$1"; shift
|
||||
echo ${CC} ${LDSTATIC} ${LDFLAGS} -o "$output" "$@" ${LIBS}
|
||||
${CC} ${LDSTATIC} ${LDFLAGS} -o "$output" "$@" ${LIBS}
|
||||
}
|
||||
|
||||
BASE_OBJECTS="arch.o buf.o compat.o cond.o dir.o for.o getopt hash.o \
|
||||
job.o make.o make_malloc.o parse.o sigcompat.o str.o strlist.o \
|
||||
suff.o targ.o trace.o var.o util.o"
|
||||
|
||||
LST_OBJECTS="lstAppend.o lstDupl.o lstInit.o lstOpen.o \
|
||||
lstAtEnd.o lstEnQueue.o lstInsert.o lstAtFront.o lstIsAtEnd.o \
|
||||
lstClose.o lstFind.o lstIsEmpty.o lstRemove.o lstConcat.o \
|
||||
lstFindFrom.o lstLast.o lstReplace.o lstFirst.o lstDatum.o \
|
||||
lstForEach.o lstMember.o lstSucc.o lstDeQueue.o lstForEachFrom.o \
|
||||
lstDestroy.o lstNext.o lstPrev.o"
|
||||
|
||||
LIB_OBJECTS="@LIBOBJS@"
|
||||
|
||||
do_compile main.o ${MDEFS}
|
||||
|
||||
for o in ${BASE_OBJECTS} ${LST_OBJECTS} ${LIB_OBJECTS}
|
||||
do
|
||||
do_compile "$o"
|
||||
done
|
||||
|
||||
case "@use_meta@" in
|
||||
yes)
|
||||
case "@filemon_h@" in
|
||||
*/filemon.h) FDEFS="-DHAVE_FILEMON_H -I`dirname @filemon_h@`";;
|
||||
esac
|
||||
do_compile meta.o ${FDEFS}
|
||||
BASE_OBJECTS="meta.o ${BASE_OBJECTS}"
|
||||
;;
|
||||
esac
|
||||
|
||||
do_link bmake main.o ${BASE_OBJECTS} ${LST_OBJECTS} ${LIB_OBJECTS}
|
162
20150418/make-conf.h
Normal file
162
20150418/make-conf.h
Normal file
@ -0,0 +1,162 @@
|
||||
/* $NetBSD: config.h,v 1.21 2012/03/31 00:12:24 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)config.h 8.1 (Berkeley) 6/6/93
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989 by Adam de Boor
|
||||
* Copyright (c) 1989 by Berkeley Softworks
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)config.h 8.1 (Berkeley) 6/6/93
|
||||
*/
|
||||
|
||||
/*
|
||||
* DEFMAXJOBS
|
||||
* DEFMAXLOCAL
|
||||
* These control the default concurrency. On no occasion will more
|
||||
* than DEFMAXJOBS targets be created at once (locally or remotely)
|
||||
* DEFMAXLOCAL is the highest number of targets which will be
|
||||
* created on the local machine at once. Note that if you set this
|
||||
* to 0, nothing will ever happen...
|
||||
*/
|
||||
#define DEFMAXJOBS 4
|
||||
#define DEFMAXLOCAL 1
|
||||
|
||||
/*
|
||||
* INCLUDES
|
||||
* LIBRARIES
|
||||
* These control the handling of the .INCLUDES and .LIBS variables.
|
||||
* If INCLUDES is defined, the .INCLUDES variable will be filled
|
||||
* from the search paths of those suffixes which are marked by
|
||||
* .INCLUDES dependency lines. Similarly for LIBRARIES and .LIBS
|
||||
* See suff.c for more details.
|
||||
*/
|
||||
#define INCLUDES
|
||||
#define LIBRARIES
|
||||
|
||||
/*
|
||||
* LIBSUFF
|
||||
* Is the suffix used to denote libraries and is used by the Suff module
|
||||
* to find the search path on which to seek any -l<xx> targets.
|
||||
*
|
||||
* RECHECK
|
||||
* If defined, Make_Update will check a target for its current
|
||||
* modification time after it has been re-made, setting it to the
|
||||
* starting time of the make only if the target still doesn't exist.
|
||||
* Unfortunately, under NFS the modification time often doesn't
|
||||
* get updated in time, so a target will appear to not have been
|
||||
* re-made, causing later targets to appear up-to-date. On systems
|
||||
* that don't have this problem, you should defined this. Under
|
||||
* NFS you probably should not, unless you aren't exporting jobs.
|
||||
*/
|
||||
#define LIBSUFF ".a"
|
||||
#define RECHECK
|
||||
|
||||
/*
|
||||
* POSIX
|
||||
* Adhere to the POSIX 1003.2 draft for the make(1) program.
|
||||
* - Use MAKEFLAGS instead of MAKE to pick arguments from the
|
||||
* environment.
|
||||
* - Allow empty command lines if starting with tab.
|
||||
*/
|
||||
#define POSIX
|
||||
|
||||
/*
|
||||
* SYSVINCLUDE
|
||||
* Recognize system V like include directives [include "filename"]
|
||||
* SYSVVARSUB
|
||||
* Recognize system V like ${VAR:x=y} variable substitutions
|
||||
*/
|
||||
#define SYSVINCLUDE
|
||||
#define SYSVVARSUB
|
||||
|
||||
/*
|
||||
* GMAKEEXPORT
|
||||
* Recognize gmake like variable export directives [export <VAR>=<VALUE>]
|
||||
*/
|
||||
#define GMAKEEXPORT
|
||||
|
||||
/*
|
||||
* SUNSHCMD
|
||||
* Recognize SunOS and Solaris:
|
||||
* VAR :sh= CMD # Assign VAR to the command substitution of CMD
|
||||
* ${VAR:sh} # Return the command substitution of the value
|
||||
* # of ${VAR}
|
||||
*/
|
||||
#define SUNSHCMD
|
||||
|
||||
/*
|
||||
* USE_IOVEC
|
||||
* We have writev(2)
|
||||
*/
|
||||
#ifdef HAVE_SYS_UIO_H
|
||||
# define USE_IOVEC
|
||||
#endif
|
||||
|
||||
#if defined(MAKE_NATIVE) && !defined(__ELF__)
|
||||
# ifndef RANLIBMAG
|
||||
# define RANLIBMAG "__.SYMDEF"
|
||||
# endif
|
||||
#endif
|
2274
20150418/make.1
Normal file
2274
20150418/make.1
Normal file
File diff suppressed because it is too large
Load Diff
1561
20150418/make.c
Normal file
1561
20150418/make.c
Normal file
File diff suppressed because it is too large
Load Diff
526
20150418/make.h
Normal file
526
20150418/make.h
Normal file
@ -0,0 +1,526 @@
|
||||
/* $NetBSD: make.h,v 1.95 2014/09/07 20:55:34 joerg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)make.h 8.3 (Berkeley) 6/13/95
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989 by Berkeley Softworks
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Adam de Boor.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)make.h 8.3 (Berkeley) 6/13/95
|
||||
*/
|
||||
|
||||
/*-
|
||||
* make.h --
|
||||
* The global definitions for pmake
|
||||
*/
|
||||
|
||||
#ifndef _MAKE_H_
|
||||
#define _MAKE_H_
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#else
|
||||
#include <strings.h>
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define MAKE_GNUC_PREREQ(x, y) \
|
||||
((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) || \
|
||||
(__GNUC__ > (x)))
|
||||
#else /* defined(__GNUC__) */
|
||||
#define MAKE_GNUC_PREREQ(x, y) 0
|
||||
#endif /* defined(__GNUC__) */
|
||||
|
||||
#if MAKE_GNUC_PREREQ(2, 7)
|
||||
#define MAKE_ATTR_UNUSED __attribute__((__unused__))
|
||||
#else
|
||||
#define MAKE_ATTR_UNUSED /* delete */
|
||||
#endif
|
||||
|
||||
#if MAKE_GNUC_PREREQ(2, 5)
|
||||
#define MAKE_ATTR_DEAD __attribute__((__noreturn__))
|
||||
#elif defined(__GNUC__)
|
||||
#define MAKE_ATTR_DEAD __volatile
|
||||
#else
|
||||
#define MAKE_ATTR_DEAD /* delete */
|
||||
#endif
|
||||
|
||||
#if MAKE_GNUC_PREREQ(2, 7)
|
||||
#define MAKE_ATTR_PRINTFLIKE(fmtarg, firstvararg) \
|
||||
__attribute__((__format__ (__printf__, fmtarg, firstvararg)))
|
||||
#else
|
||||
#define MAKE_ATTR_PRINTFLIKE(fmtarg, firstvararg) /* delete */
|
||||
#endif
|
||||
|
||||
#include "sprite.h"
|
||||
#include "lst.h"
|
||||
#include "hash.h"
|
||||
#include "make-conf.h"
|
||||
#include "buf.h"
|
||||
#include "make_malloc.h"
|
||||
|
||||
/*
|
||||
* some vendors don't have this --sjg
|
||||
*/
|
||||
#if defined(S_IFDIR) && !defined(S_ISDIR)
|
||||
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||
#endif
|
||||
|
||||
#if defined(sun) && (defined(__svr4__) || defined(__SVR4))
|
||||
#define POSIX_SIGNALS
|
||||
#endif
|
||||
|
||||
/*-
|
||||
* The structure for an individual graph node. Each node has several
|
||||
* pieces of data associated with it.
|
||||
* 1) the name of the target it describes
|
||||
* 2) the location of the target file in the file system.
|
||||
* 3) the type of operator used to define its sources (qv. parse.c)
|
||||
* 4) whether it is involved in this invocation of make
|
||||
* 5) whether the target has been remade
|
||||
* 6) whether any of its children has been remade
|
||||
* 7) the number of its children that are, as yet, unmade
|
||||
* 8) its modification time
|
||||
* 9) the modification time of its youngest child (qv. make.c)
|
||||
* 10) a list of nodes for which this is a source (parents)
|
||||
* 11) a list of nodes on which this depends (children)
|
||||
* 12) a list of nodes that depend on this, as gleaned from the
|
||||
* transformation rules (iParents)
|
||||
* 13) a list of ancestor nodes, which includes parents, iParents,
|
||||
* and recursive parents of parents
|
||||
* 14) a list of nodes of the same name created by the :: operator
|
||||
* 15) a list of nodes that must be made (if they're made) before
|
||||
* this node can be, but that do not enter into the datedness of
|
||||
* this node.
|
||||
* 16) a list of nodes that must be made (if they're made) before
|
||||
* this node or any child of this node can be, but that do not
|
||||
* enter into the datedness of this node.
|
||||
* 17) a list of nodes that must be made (if they're made) after
|
||||
* this node is, but that do not depend on this node, in the
|
||||
* normal sense.
|
||||
* 18) a Lst of ``local'' variables that are specific to this target
|
||||
* and this target only (qv. var.c [$@ $< $?, etc.])
|
||||
* 19) a Lst of strings that are commands to be given to a shell
|
||||
* to create this target.
|
||||
*/
|
||||
typedef struct GNode {
|
||||
char *name; /* The target's name */
|
||||
char *uname; /* The unexpanded name of a .USE node */
|
||||
char *path; /* The full pathname of the file */
|
||||
int type; /* Its type (see the OP flags, below) */
|
||||
|
||||
int flags;
|
||||
#define REMAKE 0x1 /* this target needs to be (re)made */
|
||||
#define CHILDMADE 0x2 /* children of this target were made */
|
||||
#define FORCE 0x4 /* children don't exist, and we pretend made */
|
||||
#define DONE_WAIT 0x8 /* Set by Make_ProcessWait() */
|
||||
#define DONE_ORDER 0x10 /* Build requested by .ORDER processing */
|
||||
#define FROM_DEPEND 0x20 /* Node created from .depend */
|
||||
#define DONE_ALLSRC 0x40 /* We do it once only */
|
||||
#define CYCLE 0x1000 /* Used by MakePrintStatus */
|
||||
#define DONECYCLE 0x2000 /* Used by MakePrintStatus */
|
||||
enum enum_made {
|
||||
UNMADE, DEFERRED, REQUESTED, BEINGMADE,
|
||||
MADE, UPTODATE, ERROR, ABORTED
|
||||
} made; /* Set to reflect the state of processing
|
||||
* on this node:
|
||||
* UNMADE - Not examined yet
|
||||
* DEFERRED - Examined once (building child)
|
||||
* REQUESTED - on toBeMade list
|
||||
* BEINGMADE - Target is already being made.
|
||||
* Indicates a cycle in the graph.
|
||||
* MADE - Was out-of-date and has been made
|
||||
* UPTODATE - Was already up-to-date
|
||||
* ERROR - An error occurred while it was being
|
||||
* made (used only in compat mode)
|
||||
* ABORTED - The target was aborted due to
|
||||
* an error making an inferior (compat).
|
||||
*/
|
||||
int unmade; /* The number of unmade children */
|
||||
|
||||
time_t mtime; /* Its modification time */
|
||||
struct GNode *cmgn; /* The youngest child */
|
||||
|
||||
Lst iParents; /* Links to parents for which this is an
|
||||
* implied source, if any */
|
||||
Lst cohorts; /* Other nodes for the :: operator */
|
||||
Lst parents; /* Nodes that depend on this one */
|
||||
Lst children; /* Nodes on which this one depends */
|
||||
Lst order_pred; /* .ORDER nodes we need made */
|
||||
Lst order_succ; /* .ORDER nodes who need us */
|
||||
|
||||
char cohort_num[8]; /* #n for this cohort */
|
||||
int unmade_cohorts;/* # of unmade instances on the
|
||||
cohorts list */
|
||||
struct GNode *centurion; /* Pointer to the first instance of a ::
|
||||
node; only set when on a cohorts list */
|
||||
unsigned int checked; /* Last time we tried to makle this node */
|
||||
|
||||
Hash_Table context; /* The local variables */
|
||||
Lst commands; /* Creation commands */
|
||||
|
||||
struct _Suff *suffix; /* Suffix for the node (determined by
|
||||
* Suff_FindDeps and opaque to everyone
|
||||
* but the Suff module) */
|
||||
const char *fname; /* filename where the GNode got defined */
|
||||
int lineno; /* line number where the GNode got defined */
|
||||
} GNode;
|
||||
|
||||
/*
|
||||
* The OP_ constants are used when parsing a dependency line as a way of
|
||||
* communicating to other parts of the program the way in which a target
|
||||
* should be made. These constants are bitwise-OR'ed together and
|
||||
* placed in the 'type' field of each node. Any node that has
|
||||
* a 'type' field which satisfies the OP_NOP function was never never on
|
||||
* the lefthand side of an operator, though it may have been on the
|
||||
* righthand side...
|
||||
*/
|
||||
#define OP_DEPENDS 0x00000001 /* Execution of commands depends on
|
||||
* kids (:) */
|
||||
#define OP_FORCE 0x00000002 /* Always execute commands (!) */
|
||||
#define OP_DOUBLEDEP 0x00000004 /* Execution of commands depends on kids
|
||||
* per line (::) */
|
||||
#define OP_OPMASK (OP_DEPENDS|OP_FORCE|OP_DOUBLEDEP)
|
||||
|
||||
#define OP_OPTIONAL 0x00000008 /* Don't care if the target doesn't
|
||||
* exist and can't be created */
|
||||
#define OP_USE 0x00000010 /* Use associated commands for parents */
|
||||
#define OP_EXEC 0x00000020 /* Target is never out of date, but always
|
||||
* execute commands anyway. Its time
|
||||
* doesn't matter, so it has none...sort
|
||||
* of */
|
||||
#define OP_IGNORE 0x00000040 /* Ignore errors when creating the node */
|
||||
#define OP_PRECIOUS 0x00000080 /* Don't remove the target when
|
||||
* interrupted */
|
||||
#define OP_SILENT 0x00000100 /* Don't echo commands when executed */
|
||||
#define OP_MAKE 0x00000200 /* Target is a recursive make so its
|
||||
* commands should always be executed when
|
||||
* it is out of date, regardless of the
|
||||
* state of the -n or -t flags */
|
||||
#define OP_JOIN 0x00000400 /* Target is out-of-date only if any of its
|
||||
* children was out-of-date */
|
||||
#define OP_MADE 0x00000800 /* Assume the children of the node have
|
||||
* been already made */
|
||||
#define OP_SPECIAL 0x00001000 /* Special .BEGIN, .END, .INTERRUPT */
|
||||
#define OP_USEBEFORE 0x00002000 /* Like .USE, only prepend commands */
|
||||
#define OP_INVISIBLE 0x00004000 /* The node is invisible to its parents.
|
||||
* I.e. it doesn't show up in the parents's
|
||||
* local variables. */
|
||||
#define OP_NOTMAIN 0x00008000 /* The node is exempt from normal 'main
|
||||
* target' processing in parse.c */
|
||||
#define OP_PHONY 0x00010000 /* Not a file target; run always */
|
||||
#define OP_NOPATH 0x00020000 /* Don't search for file in the path */
|
||||
#define OP_WAIT 0x00040000 /* .WAIT phony node */
|
||||
#define OP_NOMETA 0x00080000 /* .NOMETA do not create a .meta file */
|
||||
#define OP_META 0x00100000 /* .META we _do_ want a .meta file */
|
||||
#define OP_NOMETA_CMP 0x00200000 /* Do not compare commands in .meta file */
|
||||
#define OP_SUBMAKE 0x00400000 /* Possibly a submake node */
|
||||
/* Attributes applied by PMake */
|
||||
#define OP_TRANSFORM 0x80000000 /* The node is a transformation rule */
|
||||
#define OP_MEMBER 0x40000000 /* Target is a member of an archive */
|
||||
#define OP_LIB 0x20000000 /* Target is a library */
|
||||
#define OP_ARCHV 0x10000000 /* Target is an archive construct */
|
||||
#define OP_HAS_COMMANDS 0x08000000 /* Target has all the commands it should.
|
||||
* Used when parsing to catch multiple
|
||||
* commands for a target */
|
||||
#define OP_SAVE_CMDS 0x04000000 /* Saving commands on .END (Compat) */
|
||||
#define OP_DEPS_FOUND 0x02000000 /* Already processed by Suff_FindDeps */
|
||||
#define OP_MARK 0x01000000 /* Node found while expanding .ALLSRC */
|
||||
|
||||
#define NoExecute(gn) ((gn->type & OP_MAKE) ? noRecursiveExecute : noExecute)
|
||||
/*
|
||||
* OP_NOP will return TRUE if the node with the given type was not the
|
||||
* object of a dependency operator
|
||||
*/
|
||||
#define OP_NOP(t) (((t) & OP_OPMASK) == 0x00000000)
|
||||
|
||||
#define OP_NOTARGET (OP_NOTMAIN|OP_USE|OP_EXEC|OP_TRANSFORM)
|
||||
|
||||
/*
|
||||
* The TARG_ constants are used when calling the Targ_FindNode and
|
||||
* Targ_FindList functions in targ.c. They simply tell the functions what to
|
||||
* do if the desired node(s) is (are) not found. If the TARG_CREATE constant
|
||||
* is given, a new, empty node will be created for the target, placed in the
|
||||
* table of all targets and its address returned. If TARG_NOCREATE is given,
|
||||
* a NULL pointer will be returned.
|
||||
*/
|
||||
#define TARG_NOCREATE 0x00 /* don't create it */
|
||||
#define TARG_CREATE 0x01 /* create node if not found */
|
||||
#define TARG_NOHASH 0x02 /* don't look in/add to hash table */
|
||||
|
||||
/*
|
||||
* These constants are all used by the Str_Concat function to decide how the
|
||||
* final string should look. If STR_ADDSPACE is given, a space will be
|
||||
* placed between the two strings. If STR_ADDSLASH is given, a '/' will
|
||||
* be used instead of a space. If neither is given, no intervening characters
|
||||
* will be placed between the two strings in the final output. If the
|
||||
* STR_DOFREE bit is set, the two input strings will be freed before
|
||||
* Str_Concat returns.
|
||||
*/
|
||||
#define STR_ADDSPACE 0x01 /* add a space when Str_Concat'ing */
|
||||
#define STR_ADDSLASH 0x02 /* add a slash when Str_Concat'ing */
|
||||
|
||||
/*
|
||||
* Error levels for parsing. PARSE_FATAL means the process cannot continue
|
||||
* once the makefile has been parsed. PARSE_WARNING means it can. Passed
|
||||
* as the first argument to Parse_Error.
|
||||
*/
|
||||
#define PARSE_WARNING 2
|
||||
#define PARSE_FATAL 1
|
||||
|
||||
/*
|
||||
* Values returned by Cond_Eval.
|
||||
*/
|
||||
#define COND_PARSE 0 /* Parse the next lines */
|
||||
#define COND_SKIP 1 /* Skip the next lines */
|
||||
#define COND_INVALID 2 /* Not a conditional statement */
|
||||
|
||||
/*
|
||||
* Definitions for the "local" variables. Used only for clarity.
|
||||
*/
|
||||
#define TARGET "@" /* Target of dependency */
|
||||
#define OODATE "?" /* All out-of-date sources */
|
||||
#define ALLSRC ">" /* All sources */
|
||||
#define IMPSRC "<" /* Source implied by transformation */
|
||||
#define PREFIX "*" /* Common prefix */
|
||||
#define ARCHIVE "!" /* Archive in "archive(member)" syntax */
|
||||
#define MEMBER "%" /* Member in "archive(member)" syntax */
|
||||
|
||||
#define FTARGET "@F" /* file part of TARGET */
|
||||
#define DTARGET "@D" /* directory part of TARGET */
|
||||
#define FIMPSRC "<F" /* file part of IMPSRC */
|
||||
#define DIMPSRC "<D" /* directory part of IMPSRC */
|
||||
#define FPREFIX "*F" /* file part of PREFIX */
|
||||
#define DPREFIX "*D" /* directory part of PREFIX */
|
||||
|
||||
/*
|
||||
* Global Variables
|
||||
*/
|
||||
extern Lst create; /* The list of target names specified on the
|
||||
* command line. used to resolve #if
|
||||
* make(...) statements */
|
||||
extern Lst dirSearchPath; /* The list of directories to search when
|
||||
* looking for targets */
|
||||
|
||||
extern Boolean compatMake; /* True if we are make compatible */
|
||||
extern Boolean ignoreErrors; /* True if should ignore all errors */
|
||||
extern Boolean beSilent; /* True if should print no commands */
|
||||
extern Boolean noExecute; /* True if should execute nothing */
|
||||
extern Boolean noRecursiveExecute; /* True if should execute nothing */
|
||||
extern Boolean allPrecious; /* True if every target is precious */
|
||||
extern Boolean keepgoing; /* True if should continue on unaffected
|
||||
* portions of the graph when have an error
|
||||
* in one portion */
|
||||
extern Boolean touchFlag; /* TRUE if targets should just be 'touched'
|
||||
* if out of date. Set by the -t flag */
|
||||
extern Boolean queryFlag; /* TRUE if we aren't supposed to really make
|
||||
* anything, just see if the targets are out-
|
||||
* of-date */
|
||||
extern Boolean doing_depend; /* TRUE if processing .depend */
|
||||
|
||||
extern Boolean checkEnvFirst; /* TRUE if environment should be searched for
|
||||
* variables before the global context */
|
||||
extern Boolean jobServer; /* a jobServer already exists */
|
||||
|
||||
extern Boolean parseWarnFatal; /* TRUE if makefile parsing warnings are
|
||||
* treated as errors */
|
||||
|
||||
extern Boolean varNoExportEnv; /* TRUE if we should not export variables
|
||||
* set on the command line to the env. */
|
||||
|
||||
extern GNode *DEFAULT; /* .DEFAULT rule */
|
||||
|
||||
extern GNode *VAR_INTERNAL; /* Variables defined internally by make
|
||||
* which should not override those set by
|
||||
* makefiles.
|
||||
*/
|
||||
extern GNode *VAR_GLOBAL; /* Variables defined in a global context, e.g
|
||||
* in the Makefile itself */
|
||||
extern GNode *VAR_CMD; /* Variables defined on the command line */
|
||||
extern GNode *VAR_FOR; /* Iteration variables */
|
||||
extern char var_Error[]; /* Value returned by Var_Parse when an error
|
||||
* is encountered. It actually points to
|
||||
* an empty string, so naive callers needn't
|
||||
* worry about it. */
|
||||
|
||||
extern time_t now; /* The time at the start of this whole
|
||||
* process */
|
||||
|
||||
extern Boolean oldVars; /* Do old-style variable substitution */
|
||||
|
||||
extern Lst sysIncPath; /* The system include path. */
|
||||
extern Lst defIncPath; /* The default include path. */
|
||||
|
||||
extern char curdir[]; /* Startup directory */
|
||||
extern char *progname; /* The program name */
|
||||
extern char *makeDependfile; /* .depend */
|
||||
extern char **savedEnv; /* if we replaced environ this will be non-NULL */
|
||||
|
||||
/*
|
||||
* We cannot vfork() in a child of vfork().
|
||||
* Most systems do not enforce this but some do.
|
||||
*/
|
||||
#define vFork() ((getpid() == myPid) ? vfork() : fork())
|
||||
extern pid_t myPid;
|
||||
|
||||
#define MAKEFLAGS ".MAKEFLAGS"
|
||||
#define MAKEOVERRIDES ".MAKEOVERRIDES"
|
||||
#define MAKE_JOB_PREFIX ".MAKE.JOB.PREFIX" /* prefix for job target output */
|
||||
#define MAKE_EXPORTED ".MAKE.EXPORTED" /* variables we export */
|
||||
#define MAKE_MAKEFILES ".MAKE.MAKEFILES" /* all the makefiles we read */
|
||||
#define MAKE_LEVEL ".MAKE.LEVEL" /* recursion level */
|
||||
#define MAKEFILE_PREFERENCE ".MAKE.MAKEFILE_PREFERENCE"
|
||||
#define MAKE_DEPENDFILE ".MAKE.DEPENDFILE" /* .depend */
|
||||
#define MAKE_MODE ".MAKE.MODE"
|
||||
#ifndef MAKE_LEVEL_ENV
|
||||
# define MAKE_LEVEL_ENV "MAKELEVEL"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* debug control:
|
||||
* There is one bit per module. It is up to the module what debug
|
||||
* information to print.
|
||||
*/
|
||||
FILE *debug_file; /* Output written here - default stdout */
|
||||
extern int debug;
|
||||
#define DEBUG_ARCH 0x00001
|
||||
#define DEBUG_COND 0x00002
|
||||
#define DEBUG_DIR 0x00004
|
||||
#define DEBUG_GRAPH1 0x00008
|
||||
#define DEBUG_GRAPH2 0x00010
|
||||
#define DEBUG_JOB 0x00020
|
||||
#define DEBUG_MAKE 0x00040
|
||||
#define DEBUG_SUFF 0x00080
|
||||
#define DEBUG_TARG 0x00100
|
||||
#define DEBUG_VAR 0x00200
|
||||
#define DEBUG_FOR 0x00400
|
||||
#define DEBUG_SHELL 0x00800
|
||||
#define DEBUG_ERROR 0x01000
|
||||
#define DEBUG_LOUD 0x02000
|
||||
#define DEBUG_META 0x04000
|
||||
|
||||
#define DEBUG_GRAPH3 0x10000
|
||||
#define DEBUG_SCRIPT 0x20000
|
||||
#define DEBUG_PARSE 0x40000
|
||||
#define DEBUG_CWD 0x80000
|
||||
|
||||
#define CONCAT(a,b) a##b
|
||||
|
||||
#define DEBUG(module) (debug & CONCAT(DEBUG_,module))
|
||||
|
||||
#include "nonints.h"
|
||||
|
||||
int Make_TimeStamp(GNode *, GNode *);
|
||||
Boolean Make_OODate(GNode *);
|
||||
void Make_ExpandUse(Lst);
|
||||
time_t Make_Recheck(GNode *);
|
||||
void Make_HandleUse(GNode *, GNode *);
|
||||
void Make_Update(GNode *);
|
||||
void Make_DoAllVar(GNode *);
|
||||
Boolean Make_Run(Lst);
|
||||
char * Check_Cwd_Cmd(const char *);
|
||||
void Check_Cwd(const char **);
|
||||
void PrintOnError(GNode *, const char *);
|
||||
void Main_ExportMAKEFLAGS(Boolean);
|
||||
Boolean Main_SetObjdir(const char *);
|
||||
int mkTempFile(const char *, char **);
|
||||
int str2Lst_Append(Lst, char *, const char *);
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define UNCONST(ptr) ({ \
|
||||
union __unconst { \
|
||||
const void *__cp; \
|
||||
void *__p; \
|
||||
} __d; \
|
||||
__d.__cp = ptr, __d.__p; })
|
||||
#else
|
||||
#define UNCONST(ptr) (void *)(ptr)
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a, b) ((a < b) ? a : b)
|
||||
#endif
|
||||
#ifndef MAX
|
||||
#define MAX(a, b) ((a > b) ? a : b)
|
||||
#endif
|
||||
|
||||
#ifndef MAXPATHLEN
|
||||
#define MAXPATHLEN BMAKE_PATH_MAX
|
||||
#endif
|
||||
|
||||
#endif /* _MAKE_H_ */
|
119
20150418/make_malloc.c
Normal file
119
20150418/make_malloc.c
Normal file
@ -0,0 +1,119 @@
|
||||
/* $NetBSD: make_malloc.c,v 1.10 2012/06/20 17:46:28 sjg Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef MAKE_NATIVE
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: make_malloc.c,v 1.10 2012/06/20 17:46:28 sjg Exp $");
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "make.h"
|
||||
|
||||
#ifndef USE_EMALLOC
|
||||
static void enomem(void) MAKE_ATTR_DEAD;
|
||||
|
||||
/*
|
||||
* enomem --
|
||||
* die when out of memory.
|
||||
*/
|
||||
static void
|
||||
enomem(void)
|
||||
{
|
||||
(void)fprintf(stderr, "%s: %s.\n", progname, strerror(ENOMEM));
|
||||
exit(2);
|
||||
}
|
||||
|
||||
/*
|
||||
* bmake_malloc --
|
||||
* malloc, but die on error.
|
||||
*/
|
||||
void *
|
||||
bmake_malloc(size_t len)
|
||||
{
|
||||
void *p;
|
||||
|
||||
if ((p = malloc(len)) == NULL)
|
||||
enomem();
|
||||
return(p);
|
||||
}
|
||||
|
||||
/*
|
||||
* bmake_strdup --
|
||||
* strdup, but die on error.
|
||||
*/
|
||||
char *
|
||||
bmake_strdup(const char *str)
|
||||
{
|
||||
size_t len;
|
||||
char *p;
|
||||
|
||||
len = strlen(str) + 1;
|
||||
if ((p = malloc(len)) == NULL)
|
||||
enomem();
|
||||
return memcpy(p, str, len);
|
||||
}
|
||||
|
||||
/*
|
||||
* bmake_strndup --
|
||||
* strndup, but die on error.
|
||||
*/
|
||||
char *
|
||||
bmake_strndup(const char *str, size_t max_len)
|
||||
{
|
||||
size_t len;
|
||||
char *p;
|
||||
|
||||
if (str == NULL)
|
||||
return NULL;
|
||||
|
||||
len = strlen(str);
|
||||
if (len > max_len)
|
||||
len = max_len;
|
||||
p = bmake_malloc(len + 1);
|
||||
memcpy(p, str, len);
|
||||
p[len] = '\0';
|
||||
|
||||
return(p);
|
||||
}
|
||||
|
||||
/*
|
||||
* bmake_realloc --
|
||||
* realloc, but die on error.
|
||||
*/
|
||||
void *
|
||||
bmake_realloc(void *ptr, size_t size)
|
||||
{
|
||||
if ((ptr = realloc(ptr, size)) == NULL)
|
||||
enomem();
|
||||
return(ptr);
|
||||
}
|
||||
#endif
|
41
20150418/make_malloc.h
Normal file
41
20150418/make_malloc.h
Normal file
@ -0,0 +1,41 @@
|
||||
/* $NetBSD: make_malloc.h,v 1.4 2009/01/24 14:43:29 dsl Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef USE_EMALLOC
|
||||
void *bmake_malloc(size_t);
|
||||
void *bmake_realloc(void *, size_t);
|
||||
char *bmake_strdup(const char *);
|
||||
char *bmake_strndup(const char *, size_t);
|
||||
#else
|
||||
#include <util.h>
|
||||
#define bmake_malloc(x) emalloc(x)
|
||||
#define bmake_realloc(x,y) erealloc(x,y)
|
||||
#define bmake_strdup(x) estrdup(x)
|
||||
#define bmake_strndup(x,y) estrndup(x,y)
|
||||
#endif
|
||||
|
14
20150418/makefile.in
Normal file
14
20150418/makefile.in
Normal file
@ -0,0 +1,14 @@
|
||||
# $Id: makefile.in,v 1.1 2012/12/28 21:28:19 sjg Exp $
|
||||
|
||||
# a simple makefile for those who don't like anything beyond:
|
||||
# ./configure; make; make install
|
||||
|
||||
prefix= @prefix@
|
||||
srcdir= @srcdir@
|
||||
|
||||
all: build
|
||||
|
||||
build clean install test:
|
||||
${srcdir}/boot-strap --prefix=${prefix} -o . op=$@
|
||||
|
||||
|
1462
20150418/meta.c
Normal file
1462
20150418/meta.c
Normal file
File diff suppressed because it is too large
Load Diff
55
20150418/meta.h
Normal file
55
20150418/meta.h
Normal file
@ -0,0 +1,55 @@
|
||||
/* $NetBSD: meta.h,v 1.3 2013/03/23 05:31:29 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Things needed for 'meta' mode.
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 2009-2010, Juniper Networks, Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
|
||||
* OWNER 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.
|
||||
*/
|
||||
|
||||
typedef struct BuildMon {
|
||||
char meta_fname[MAXPATHLEN];
|
||||
int filemon_fd;
|
||||
int mon_fd;
|
||||
FILE *mfp;
|
||||
} BuildMon;
|
||||
|
||||
extern Boolean useMeta;
|
||||
|
||||
struct Job; /* not defined yet */
|
||||
void meta_init(void);
|
||||
void meta_mode_init(const char *);
|
||||
void meta_job_start(struct Job *, GNode *);
|
||||
void meta_job_child(struct Job *);
|
||||
void meta_job_error(struct Job *, GNode *, int, int);
|
||||
void meta_job_output(struct Job *, char *, const char *);
|
||||
void meta_cmd_finish(void *);
|
||||
void meta_job_finish(struct Job *);
|
||||
Boolean meta_oodate(GNode *, Boolean);
|
||||
void meta_compat_start(void);
|
||||
void meta_compat_child(void);
|
||||
void meta_compat_parent(void);
|
942
20150418/mk/ChangeLog
Normal file
942
20150418/mk/ChangeLog
Normal file
@ -0,0 +1,942 @@
|
||||
2015-04-16 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): 20150411
|
||||
bump version
|
||||
|
||||
* own.mk: put AUTO_OBJ in OPTIONS_DEFAULT_NO rather than YES.
|
||||
it is here mainly for documentation purposes, since
|
||||
if using auto.obj.mk it is better done via sys.mk
|
||||
|
||||
2015-04-01 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): 20150401
|
||||
|
||||
* meta2deps.sh: support @list
|
||||
|
||||
* meta2deps.py: updates from Juniper
|
||||
o add EXCLUDES
|
||||
o skip bogus input files.
|
||||
o treat 'M' and 'L' as both an 'R' and a 'W'
|
||||
|
||||
2015-03-03 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): 20150303
|
||||
|
||||
* dirdeps.mk: if MK_DIRDEPS_CACHE is yes, use dirdeps-cache
|
||||
which is built via sub-make so we have a .meta file to tell if
|
||||
it is out-of-date.
|
||||
The dirdeps-cache contains the same dependency rules that we
|
||||
normaly construct on the fly.
|
||||
This adds a few seconds overhead when the cache is out of date,
|
||||
but for a large target, the savings can be significant (10-20min).
|
||||
|
||||
2014-11-18 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): 20141118
|
||||
|
||||
* meta.stage.mk: add stale_staged
|
||||
|
||||
* dirdeps.mk (_DIRDEP_USE_LEVEL): allow this to be tweaked
|
||||
only useful under very rare conditions such as
|
||||
FreeBSD's make universe.
|
||||
|
||||
* auto.obj.mk: Allow MK_AUTO_OBJ to set MKOBJDIRS=auto
|
||||
|
||||
2014-11-11 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): 20141111
|
||||
|
||||
* mkopt.sh: use consistent semantics for _mk_opt and _mk_opts
|
||||
|
||||
2014-11-09 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* FILES: include mkopt.sh which allows handling options in shell
|
||||
scripts in a manner compatible with options.mk
|
||||
|
||||
2014-10-12 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* meta.stage.mk: ensure only _STAGED_DIRS under objroot are used
|
||||
for GENDIRDEPS_FILTER to avoid surprises.
|
||||
|
||||
2014-10-10 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* dirdeps.mk (NSkipHostDir): this needs SRCTOP prepended since by
|
||||
the time it is applied to __depdirs they have.
|
||||
|
||||
* dirdeps.mk fix filtering of _machines since M_dep_qual_fixes
|
||||
expects patterns like *.${MACHINE}
|
||||
|
||||
* cython.mk (pyprefix?): use pyprefix to find python bits
|
||||
since prefix might be something else (where we install our
|
||||
stuff)
|
||||
|
||||
2014-09-11 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): 20140911
|
||||
|
||||
* dirdeps.mk: add bootstrap target to simplify adding support for
|
||||
new MACHINE.
|
||||
|
||||
2014-09-01 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* gendirdeps.mk: Add handling of GENDIRDEPS_FILTER_DIR_VARS and
|
||||
GENDIRDEPS_FILTER_VARS to make it easier to produce sharable
|
||||
Makefile.depend files.
|
||||
|
||||
2014-08-28 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): 20140828
|
||||
|
||||
* cython.mk: capture logic for building python extension modules
|
||||
with Cython.
|
||||
|
||||
2014-08-08 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* meta.stage.mk (_STAGE_AS_BASENAME_USE): Add StageAs variant
|
||||
|
||||
2014-08-02 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): 20140801
|
||||
|
||||
* dep.mk: use explicit MKDEP_MK rather than overload MKDEP to
|
||||
identify the autodep.mk variant.
|
||||
|
||||
* sys.dependfile.mk: delete .MAKE.DEPENDFILE if its
|
||||
initial value does not match .MAKE.DEPENDFILE_PREFIX
|
||||
|
||||
* meta.autodep.mk: if _bootstrap_dirdeps add RELDIR to DIRDEPS
|
||||
|
||||
2014-05-22 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): 20140522
|
||||
|
||||
* lib.mk: use CC to link shlib for linux too
|
||||
patch from Brendan MacDonell
|
||||
|
||||
2014-05-05 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* meta.autodep.mk: add _reldir_{finish,failed} for gathering stats
|
||||
if WITH_META_STATS is defined.
|
||||
|
||||
2014-05-02 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* dirdeps.mk: accept -DWITHOUT_DIRDEPS (same a as -DNO_DIRDEPS)
|
||||
to supress dirdeps outside of .CURDIR.
|
||||
|
||||
2014-04-05 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* Fix spelling errors - patch from Pedro Giffuni
|
||||
|
||||
2014-03-14 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): 20140314
|
||||
|
||||
* dirdeps.mk (beforedirdeps): a handy hook
|
||||
|
||||
* dirdeps.mk (DIRDEP_MAKE): allow the actual command we run
|
||||
to visit leaf dirs to be intercepted (eg. for distributed
|
||||
build).
|
||||
|
||||
* dirdeps.mk (__depdirs): ensure // don't sneak in
|
||||
|
||||
* gendirdeps.mk (DIRDEPS): ensure // don't sneak in
|
||||
|
||||
|
||||
2014-02-21 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* rst2htm.mk (RST2PDF): add support for rst2pdf
|
||||
|
||||
2014-02-14 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version
|
||||
* dirdeps.mk (_last_dependfile): use .INCLUDEDFROMFILE if
|
||||
available.
|
||||
|
||||
2014-02-10 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* options.mk: avoid :U so this isn't bmake dependent
|
||||
|
||||
2014-02-09 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* options.mk: cleanup and simplify semanitcs
|
||||
NO_* dominates all, if both WITH_* and WITHOUT_*
|
||||
are defined then result is DOMINATE_* which defaults to "no".
|
||||
Ie. WITHOUT_ normally wins.
|
||||
|
||||
2013-12-12 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version
|
||||
* meta2deps.py: convert to print function for python3 compat.
|
||||
we also need to open files with mode 'r' rather than 'rb'
|
||||
otherwise we get bytes instead of strings.
|
||||
|
||||
2013-10-10 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version
|
||||
|
||||
* dirdeps.mk: when TARGET_SPEC_VARS is more than just MACHINE
|
||||
apply the same filtering (M_dep_qual_fixes) when setting _machines
|
||||
as _build_dirs.
|
||||
Also fix the filtering of Makefile.depend files - for reporting
|
||||
what we are looking for (M_dep_qual_fixes can get confused by
|
||||
Makefile.depend)
|
||||
Add some more debug info.
|
||||
|
||||
2013-09-04 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* gendirdeps.mk (_objtops): fix typo also
|
||||
while processing M2D_OBJROOTS to gather qualdir_list
|
||||
qualify $ql with loop iterator to ensure correct results.
|
||||
|
||||
2013-08-01 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): 20130801
|
||||
* libs.mk: update to match progs.mk
|
||||
|
||||
2013-07-26 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): 20130726
|
||||
some updates from Juniper and FreeBSD
|
||||
o meta2deps.py: indicate file and line number when we hit parse
|
||||
errors
|
||||
also allow @file to provide huge list of .meta files.
|
||||
* meta2deps.py: add try_parse() to cleanup the above.
|
||||
|
||||
2013-07-16 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): 20130716
|
||||
* own.mk: add GPROG as an option
|
||||
* prog.mk: honor MK_GPROF==yes
|
||||
|
||||
2013-05-10 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): 20130505
|
||||
* gendirdeps.mk, meta2deps.py, meta2deps.sh: handle $TARGET_SPEC
|
||||
for when $MACHINE isn't enough for objdir distinction.
|
||||
Bring meta2deps.sh closer to par with meta2deps.py.
|
||||
|
||||
2013-04-18 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* meta.stage.mk: set INSTALL to STAGE_INSTALL when making 'all'
|
||||
also if the target 'beforeinstall' exists, make it depend on
|
||||
.dirdep (incase it uses STAGE_INSTALL).
|
||||
|
||||
2013-04-17 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): 20130401 ;-)
|
||||
* meta.stage.mk (STAGE_INSTALL_SH): add stage-install.sh as
|
||||
wrapper around install(1).
|
||||
* options.mk (OPTION_PREFIX): Allow a prefix other than MK_
|
||||
|
||||
2013-03-30 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* meta2deps.py (MetaFile.__init__): ensure self.cwd is initialized.
|
||||
* install-mk (MK_VERSION): bump version
|
||||
|
||||
2013-03-21 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version
|
||||
* gendirdeps.mk: do not apply :tA to DPADD entries, since we lose
|
||||
any trailing /., rather apply :tA only when needed.
|
||||
* gendirdeps.mk: better mimic meta2deps handling of .dirdep files.
|
||||
* meta.stage.mk (LN_CP_SCRIPT): Add LnCp to do the ln||cp dance
|
||||
consistently.
|
||||
* dirdeps.mk: better describe the dance in sys.mk for TARGET_SPEC.
|
||||
|
||||
2013-03-18 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* gendirdeps.mk: revert the dance around .MAKE.DEPENDFILE_DEFAULT
|
||||
it is simpler to just not update when say building for "host"
|
||||
(where we know we apply filters to DIRDEPS), and using a
|
||||
non-machine qualified dependfile.
|
||||
|
||||
2013-03-16 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* dirdeps.mk: improve DIRDEPS filtering by allowing DEP_SKIP_DIR
|
||||
and DEP_DIRDEPS_FILTER to vary by DEP_MACHINE and DEP_TARGET_SPEC
|
||||
* gendirdeps.mk: ensure _objroot has trailing / if it needs it.
|
||||
* meta2deps.py: if machine is "host", then also trim
|
||||
self.host_target from any OBJROOTS.
|
||||
|
||||
|
||||
2013-03-11 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* gendirdeps.mk: if .MAKE.DEPENDFILE_DEFAULT is not machine
|
||||
qualified but _DEPENDFILE is, and .MAKE.DEPENDFILE_DEFAULT exists
|
||||
but _DEPENDFILE does not, compare the new _DEPENDFILE against
|
||||
.MAKE.DEPENDFILE_DEFAULT and discard if the same.
|
||||
|
||||
2013-03-08 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* meta.stage.mk: use STAGE_TARGETS to control .ORDER
|
||||
and hook to all: via staging:
|
||||
|
||||
2013-03-07 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* sys.dependfile.mk (.MAKE.DEPENDFILE_DEFAULT):
|
||||
use a separate variable for the default .MAKE.DEPENDFILE value
|
||||
so that it can be controlled independently of
|
||||
.MAKE.DEPENDFILE_PREFERENCE
|
||||
|
||||
* meta.stage.mk: throw error if cp fails etc.
|
||||
Stage*() return early if passed no args.
|
||||
.ORDER stage_*
|
||||
|
||||
2013-03-03 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version
|
||||
* gendirdeps.mk: handle multiple M2D_OBJROOTS better.
|
||||
|
||||
2013-02-10 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20130210
|
||||
* import latest dirdeps.mk, gendirdeps.mk and meta2deps.py
|
||||
from Juniper.
|
||||
o dirdeps.mk now fully supports TARGET_SPEC consisting of more
|
||||
than just MACHINE.
|
||||
o no longer use DEP_MACHINE from Makefile.depend* so remove it.
|
||||
|
||||
2013-01-23 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20130123
|
||||
* meta.stage.mk: add stage_links (hard links).
|
||||
if doing hard links, we add dest to link as well.
|
||||
Default the stage dir for [sym]links to STAGE_OBJTOP since
|
||||
these are typically specified as absolute paths.
|
||||
Add -m "mode" flag to StageFiles and StageAs.
|
||||
|
||||
2012-11-11 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20121111
|
||||
* autoconf.mk: avoid meta mode seeing changed commands for config.status
|
||||
* meta.autodep.mk: pass resolved MAKESYSPATH to gendirdeps
|
||||
in case we were found via .../mk
|
||||
* sys.clean-env.mk: move it from examples, we and others use it
|
||||
"as is".
|
||||
* FILES: add srctop.mk and options.mk
|
||||
* own.mk: convert to using options.mk
|
||||
which is modeled after FreeBSD's handling of MK_*
|
||||
but more flexible.
|
||||
This allows MK_* for boolean knobs to not be confused
|
||||
with MK* which can be commands.
|
||||
|
||||
* examples/sys.clean-env.mk: add WITH[OUT]_ to
|
||||
MAKE_ENV_SAVE_PREFIX_LIST.
|
||||
Mention that HOME=/var/empty might be a good idea.
|
||||
|
||||
2012-11-08 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* sys.dependfile.mk: if not depend file exists, $MACHINE
|
||||
specific ones are supported but not the default,
|
||||
check if any exist and follow suit.
|
||||
|
||||
2012-11-06 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20121106
|
||||
|
||||
2012-11-05 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* import latest dirdeps.mk and meta2deps.py from Juniper.
|
||||
* progs.mk: add MAN and CXXFLAGS to PROG_VARS
|
||||
also add PROGS_TARGETS and pass on PROG_CXX if it seems
|
||||
appropriate.
|
||||
|
||||
2012-11-04 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* meta.stage.mk: update CLEANFILES
|
||||
remove redundant cp of .dirdep from STAGE_AS_SCRIPT.
|
||||
* progs.mk: Add LDADD to PROG_VARS
|
||||
|
||||
2012-10-12 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* meta.stage.mk (STAGE_DIR_FILTER): track dirs we stage to in
|
||||
_STAGED_DIRS so that these can be turned into filters for
|
||||
GENDIRDEPS_FILTER.
|
||||
|
||||
2012-10-10 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20121010
|
||||
* meta.stage.mk (STAGE_DIRDEP_SCRIPT): check that an existing
|
||||
target.dirdep matches .dirdep
|
||||
|
||||
2012-08-08 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20120808
|
||||
* import latest meta2deps.py from Juniper.
|
||||
|
||||
2012-07-11 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20120711
|
||||
* dep.mk: add explicit dependencies on SRCS after applying
|
||||
SRCS_DEP_FILTER
|
||||
* meta.autodep.mk: add explicit dependencies on SRCS after
|
||||
applying SRCS_DEP_FILTER
|
||||
* meta.autodep.mk: ensure GENDIRDEPS_FILTER is exported if needed.
|
||||
|
||||
2012-06-26 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20120626
|
||||
* meta.sys.mk: ignore PYTHON if it does not exist
|
||||
compare ${.MAKE.DEPENDFILE:E} against ${MACHINE} is more reliable.
|
||||
* meta.stage.mk: examine .MAKE.DEPENDFILE_PREFERENCE for any
|
||||
entries ending in .${MACHINE} to decide if qualified _dirdep is
|
||||
needed.
|
||||
* gendirdeps.mk: only produce unqualified deps if no
|
||||
.MAKE.DEPENDFILE_PREFERENCE ends in .${MACHINE}
|
||||
* meta.subdir.mk: apply SUBDIREPS_FILTER
|
||||
|
||||
2012-04-20 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20120420
|
||||
* add sys.dependfile.mk so we can experiment with
|
||||
.MAKE.DEPENDFILE_PREFERENCE
|
||||
* meta.autodep.mk: _DEPENDFILE is precious!
|
||||
|
||||
2012-03-15 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20120315
|
||||
* install-new.mk: avoid being interrupted
|
||||
|
||||
2012-02-26 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* man.mk: MAN might have multiple values so be careful with exists().
|
||||
|
||||
2012-01-19 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20120112
|
||||
* fix examples/sys.clean-env.mk so that MAKEOBJDIR is handled
|
||||
as: MAKEOBJDIR='${.CURDIR:S,${SRCTOP},${OBJTOP},}'
|
||||
|
||||
2011-12-03 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20111201
|
||||
* import dirdeps.mk from Juniper sjg@
|
||||
o more consistent handling of DEP_MACHINE, especially when
|
||||
dealing with an odd Makefile.depend, when normally using
|
||||
Makefile.depend.${MACHINE}
|
||||
|
||||
2011-11-22 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20111122
|
||||
* meta.autodep.mk: add some debug output, be more crisp about
|
||||
updating. Use ${.ALLTARGETS:M*.o} as a clue for .depend
|
||||
|
||||
2011-11-13 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20111111
|
||||
it's too cool to miss
|
||||
* import meta* updates from Juniper sjg@
|
||||
o dirdeps.mk set DEP_MACHINE for Makefile.depend (when we are
|
||||
normally using Makefile.depend.${MACHINE}), handy for
|
||||
read-only manually maintained dependencies.
|
||||
o meta2deps.py add a clear 'ERROR:' token if an exception is raised.
|
||||
o gendirdeps.mk if ERROR: from meta2deps.py do not update
|
||||
anything.
|
||||
|
||||
2011-10-30 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-new.mk separate the cmp and copy logic to its own function.
|
||||
|
||||
2011-10-28 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20111028
|
||||
* sys.mk: include auto.obj.mk if MKOBJDIRS is set to auto
|
||||
* subdir.mk: ensure _SUBDIRUSE is provided
|
||||
* meta.autodep.mk: remove dependency of gendirdeps.mk on auto.obj.mk
|
||||
* meta.subdir.mk: always allow for Makefile.depend
|
||||
|
||||
2011-10-10 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20111010
|
||||
o minor tweak to *dirdeps.mk from Juniper sjg@
|
||||
|
||||
2011-10-01 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20111001
|
||||
o add meta2deps.py from Juniper sjg@
|
||||
o tweak gendirdeps.mk to work with meta2deps.py when not
|
||||
cross-building
|
||||
* autoconf.mk: add autoconf-input as a hook for regenerating
|
||||
AUTOCONF_INPUTS (configure).
|
||||
|
||||
2011-08-24 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* meta.autodep.mk: if we do not have OBJS, .depend isn't a useful
|
||||
trigger for updating Makefile.depend*
|
||||
|
||||
2011-08-08 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20110808
|
||||
* obj.mk: minor cleanup
|
||||
* auto.obj.mk: improve description of Mkdirs and honor NO_OBJ too.
|
||||
|
||||
2011-08-01 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* auto.obj.mk (.OBJDIR): throw an error if we cannot use the
|
||||
specified dir.
|
||||
|
||||
2011-06-28 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* meta.autodep.mk: if XMAKE_META_FILE is set
|
||||
the makefile uses a foreign make, and so dependencies
|
||||
can only be gathered from a clean tree build.
|
||||
|
||||
2011-06-24 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20110622
|
||||
* meta.autodep.mk: improve bootstraping
|
||||
|
||||
2011-06-10 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* yacc.mk: handle the corner case of .c being removed
|
||||
while .h remains.
|
||||
|
||||
2011-06-08 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* yacc.mk: do .y.h and .y.c separately
|
||||
|
||||
2011-06-04 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20110606
|
||||
* don't store SRC_DIRDEPS in Makefile.depend* by default
|
||||
not everyone needs it.
|
||||
|
||||
2011-05-04 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20110505
|
||||
first release including meta mode makefiles
|
||||
|
||||
2011-05-02 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* meta.stage.mk: add STAGE_AS_SETS and stage_as
|
||||
for things that need to be staged with different names.
|
||||
|
||||
2011-05-01 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* meta.stage.mk: add notion of STAGE_SETS
|
||||
so a makefile can stage to multiple dirs
|
||||
|
||||
2011-04-03 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* rst2htm.mk: convert rst to s5 (slides) or plain html depending
|
||||
on target name.
|
||||
|
||||
2011-03-30 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20110330
|
||||
|
||||
2011-03-29 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* sys.mk (_DEBUG_MAKE_FLAGS): use indirection so that DEBUG_MAKE_FLAGS0
|
||||
can be used to debug level 0 only and DEBUG_MAKE_FLAGS for the rest.
|
||||
* sys.mk: re-define M_whence in terms of M_type.
|
||||
M_type is useful for checking if something is a builtin.
|
||||
|
||||
2011-03-16 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* meta.stage.mk: add stage_symlinks and leverage StageLinks for
|
||||
stage_libs
|
||||
|
||||
2011-03-10 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* dirdeps.mk: correct value for _depdir_files depends on
|
||||
.MAKE.DEPENDFILE
|
||||
Add our copyright - just to make it clear we have frobbed this
|
||||
quite a bit.
|
||||
DEP_MACHINE needs to be set to MACHINE each time, if using only
|
||||
Makefile.depend (cf. Makefile.depend.${MACHINE})
|
||||
|
||||
* meta.stage.mk: meta mode version of staging
|
||||
|
||||
* init.mk, final.mk: include local.*.mk to simplify customization
|
||||
|
||||
2011-03-03 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* auto.obj.mk: just because we are doing mk destroy, we should
|
||||
still set .OBJDIR correctly if it exists.
|
||||
|
||||
* install-mk (mksrc): do not exclude meta.sys.mk
|
||||
|
||||
2011-03-01 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* host-target.mk: set/export _HOST_ARCH etc separately,
|
||||
catch junk resulting from uname -p, so we can find sys/Linux.mk
|
||||
correctly.
|
||||
|
||||
2011-02-18 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* meta.sys.mk: throw an error if /dev/filemon is missing and we
|
||||
expected to be updating Makefile.depend*
|
||||
|
||||
2011-02-14 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20110214
|
||||
* meta.subdir.mk: add support for -DBOOTSTRAP_DEPENDFILES
|
||||
|
||||
2010-09-25 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* meta.sys.mk: not valid for older bmake
|
||||
|
||||
2010-09-24 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20100919
|
||||
include dirdeps.mk et al from Juniper Networks,
|
||||
for meta mode - requires filemon(9).
|
||||
* sys.mk, subdir.mk: Add hooks for meta mode.
|
||||
we do this as meta.sys.mk, meta.autodep.mk and meta.subdir.mk
|
||||
to make turning it on/off simple.
|
||||
|
||||
2010-06-16 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20100616
|
||||
* fix typo in sys.mk
|
||||
|
||||
2010-06-12 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20100612
|
||||
* lib.mk: remove duplicate addition to SOBJS
|
||||
|
||||
2010-06-10 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* sys.mk: Add a means of selectively turning on debug flags.
|
||||
Eg. DEBUG_MAKE_FLAGS=-dv DEBUG_MAKE_DIRS="*lib/sjg"
|
||||
will act as if we did make -dv if .CURDIR ends in lib/sjg
|
||||
DEBUG_MAKE_SYS_DIRS does the same thing, but we set the flags at
|
||||
the start of sys.mk rather than the end.
|
||||
This only makes sense for leaf dirs, so we check that
|
||||
.MAKE.LEVEL > 0
|
||||
|
||||
2010-06-09 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20100608
|
||||
* sys.mk: include sys.env.mk later so it can use M_ListToSkip et al.
|
||||
* examples/sys.clean-env.mk: require MAKE_VERIONS >= 20100606
|
||||
also make it easier for folk to tweak
|
||||
|
||||
2010-06-08 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20100606
|
||||
do not install examples/*
|
||||
* FILES: add examples/sys.clean-env.mk
|
||||
* examples/sys.clean-env.mk: use .export-env to handle MAKEOBJDIR
|
||||
this requires bmake-20100606 or later to work.
|
||||
|
||||
2010-05-13 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* sys.mk (M_tA): better simulate the result of :tA if not available.
|
||||
|
||||
2010-05-04 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* sys.mk: canonicalize MAKE_VERSION
|
||||
old versions reported bmake-<src-date> build-<build-date>
|
||||
whereas we only care about <src-date>
|
||||
|
||||
2010-04-25 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk: just warn about FORCE_{BSD,SYS}_MK being ignored
|
||||
* lib.mk: we only build the shared lib if SHLIB_FULLVERSION
|
||||
is !empty
|
||||
|
||||
2010-04-22 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* dpadd.mk: use LDADD_* if defined.
|
||||
|
||||
2010-04-21 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20100420
|
||||
* sys/NetBSD.mk: add MACHINE_CPU to keep netbsd makefiles happy
|
||||
* autoconf.mk allow AUTO_AUTOCONF
|
||||
|
||||
2010-04-19 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* obj.mk: add objwarn to keep freebsd makefiles happy
|
||||
* auto.obj.mk: ensure Mkdirs is available.
|
||||
* FILES: add auto.dep.mk - a simpler version of autodep.mk
|
||||
* dep.mk: auto.dep.mk does not do 'make depend' so ignore it if
|
||||
asked to do that.
|
||||
fix/simplify the tests for when to run mkdep.
|
||||
* auto.dep.mk: add some explanation of how/what we do.
|
||||
* autodep.mk: skip the .OPTIONAL frobbing of .depend
|
||||
bmake's FROM_DEPEND flag makes it redundant.
|
||||
|
||||
2010-04-13 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20100404
|
||||
* subdir.mk: protect from multiple inclusion using _SUBDIRUSE.
|
||||
* obj.mk: protect from multiple inclusion even as bsd.obj.mk
|
||||
Also create a target _SUBDIRUSE so that we can be used without
|
||||
subdir.mk
|
||||
|
||||
2010-04-12 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* dep.mk: use <> when .including so can override.
|
||||
|
||||
2010-01-11 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* lib.mk (SHLIB_LINKS): ensure a string comparison.
|
||||
|
||||
2010-01-04 Simon J. Gerraty <sjg@bad.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20100102
|
||||
* own.mk: ensure PRINTOBJDIR works
|
||||
* autoconf.mk: pass on CONFIGURE_ARGS
|
||||
* init.mk: handle COPTS.${.IMPSRC:T} etc.
|
||||
* lib.mk: allow sys.mk to control SHLIB_FULLVERSION
|
||||
fix handling of symlinks for darwin
|
||||
* libnames.mk: add DSHLIBEXT for libs which only exist as shared.
|
||||
* man.mk: suppress chown when not root.
|
||||
* rst2htm.mk: allow srcs from multiple locations.
|
||||
* sys.mk: M_whence, stop after 1st line of output.
|
||||
* sys/Darwin.mk: Use .dylib for DSHLIBEXT and HOST_LIBEXT
|
||||
* sys/SunOS.mk: we need to export PATH
|
||||
|
||||
2009-12-23 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version
|
||||
include rst2htm.mk
|
||||
|
||||
2009-12-17 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* sys.mk,libnames.mk add .-include <local.*>
|
||||
this allows local customization without the need to edit the
|
||||
distributed files.
|
||||
|
||||
2009-12-14 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* dpadd.mk (__dpadd_libdirs): order -L's to avoid picking up
|
||||
older versions already installed.
|
||||
|
||||
2009-12-13 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* stage.mk (.stage-install): generalize lib.mk's .libinstall
|
||||
* rules.mk rules for generic Makefile.
|
||||
* inc.mk install for includes.
|
||||
|
||||
2009-12-11 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* sys/NetBSD.mk (MAKE_VERSION): some of our *.mk want to check
|
||||
this, so provide it if using native make.
|
||||
|
||||
2009-12-10 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* FILES: move all the platform *.sys.mk files to sys/*.mk
|
||||
* Rename Generic.sys.mk to sys.mk - we always want it.
|
||||
|
||||
2009-11-17 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version
|
||||
* host-target.mk: only export the expensive stuff
|
||||
* Generic.sys.mk (sys_mk): for SunOS we need to look for
|
||||
${HOST_OS}.${HOST_OSMAJOR} too!
|
||||
|
||||
2009-11-07 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version
|
||||
* lib.mk: if sys.mk doesn't give us an lorder, don't use it.
|
||||
based on patch from Greg Olszewski.
|
||||
* Generic.sys.mk: if we have nothing to work with
|
||||
set LORDER etc only if we can find it.
|
||||
|
||||
2009-09-08 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version
|
||||
* man.mk: cleanman: remove CLEANMAN if defined.
|
||||
|
||||
2009-09-04 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* SunOS.5.sys.mk (CC): Use ?= like the other *sys.mk
|
||||
|
||||
2009-07-17 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version
|
||||
include auto.obj.mk
|
||||
|
||||
|
||||
2009-03-26 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* prog.mk,lib.mk: ensure test of USE_DPADD_MK doesn't fail.
|
||||
|
||||
2008-11-11 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version
|
||||
man.mk: ensure we generate *.cat1 etc in .
|
||||
|
||||
2008-07-16 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version
|
||||
add prlist.mk
|
||||
|
||||
2007-11-25 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* Generic.sys.mk: Allow os specific sys.mk to be in a
|
||||
subdir of ${.PARSEDIR}
|
||||
|
||||
2007-11-22 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version
|
||||
* general cleanup
|
||||
* dpadd.mk introduce DPMAGIC_LIBS_*
|
||||
|
||||
2007-04-30 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version
|
||||
|
||||
* libs.mk, progs.mk, autodep.mk: allow for per lib/prog
|
||||
depend files and ensure clean is called for each lib/prog.
|
||||
|
||||
2007-03-27 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* autodep.mk (.depend): delete lines that do not start with
|
||||
space and do not contain ':'
|
||||
|
||||
2007-02-16 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* autodep.mk (.depend): gcc may wrap lines if pathnames are long
|
||||
so make sure the transform for .OPTIONAL copes.
|
||||
|
||||
2007-02-03 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version
|
||||
|
||||
* own.mk: make sure RM and LN are defined.
|
||||
|
||||
* obj.mk: fix a typo, and objlink target.
|
||||
|
||||
2006-12-30 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version
|
||||
* added libs.mk - analogous to progs.mk
|
||||
make both of them always inlcude {lib,prog}.mk
|
||||
|
||||
2006-12-28 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* progs.mk: add a means of building multiple apps in one dir.
|
||||
|
||||
2006-11-26 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20061126
|
||||
|
||||
* warnings.mk: detect invalid WARNINGS_SET
|
||||
|
||||
* warnings.mk: use ${.TARGET:T:R}.o when looking for target
|
||||
specific warnings.
|
||||
|
||||
* For .cc sources, turn off warnings that g++ vomits on.
|
||||
|
||||
2006-11-08 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* own.mk: if __initialized__ target doesn't exist and we are
|
||||
FreeBSD we got here directly from sys.mk
|
||||
|
||||
2006-11-06 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20061106
|
||||
add scripts.mk
|
||||
|
||||
2006-03-18 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20060318
|
||||
|
||||
* autodep.mk: avoid := when modifying OBJS into __dependsrcs
|
||||
|
||||
2006-03-02 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20060302
|
||||
* autodep.mk: use -MF et al to help gcc+ccache DTRT.
|
||||
|
||||
2006-03-01 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20060301
|
||||
* autodep.mk (.depend):
|
||||
if MAKE_VERSION is newer than 20050530 we can make .END depend on
|
||||
.depend and make .depend depend on __depsrcs that exist.
|
||||
* dpadd.mk: add SRC_PATHADD
|
||||
|
||||
2005-11-04 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20051104
|
||||
* prog.mk: remove all the LIBC?= junk, use
|
||||
.-include libnames.mk instead (none by default).
|
||||
also if USE_DPADD_MK is set, include that.
|
||||
|
||||
2005-10-09 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20051001
|
||||
Add UnixWare.sys.mk from Klaus Heinz.
|
||||
|
||||
2005-04-05 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* install-mk: always install *.sys.mk and if need be symlink one
|
||||
to sys.mk
|
||||
|
||||
2005-03-22 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* subdir.mk, own.mk: use .MAKE rather than MAKE
|
||||
|
||||
2004-02-15 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* own.mk: don't use NetBSD's _SRC_TOP_ it can
|
||||
cause confusion. Also don't take just 'mk' as a
|
||||
srctop indicator.
|
||||
|
||||
2004-02-14 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* warnings.mk: overhauled, now very powerful.
|
||||
|
||||
2004-02-03 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* Generic.sys.mk: need to use ${.PARSEDIR} with exists().
|
||||
|
||||
2004-02-01 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): bump version to 20040201
|
||||
* extract HOST_TARGET stuff to host-target.mk so own.mk and
|
||||
Generic.sys.mk can share.
|
||||
* fix typo in autodep.mk _SUBDIRUSE not _SUBDIR.
|
||||
|
||||
2003-09-30 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): 20030930
|
||||
* rename generic.sys.mk to Generic.sys.mk
|
||||
so that it does not get installed (unless being used as sys.mk)
|
||||
* set OS and ROOT_GROUP for those that we know the value.
|
||||
for others (eg. Generic.sys.mk) wrap the != in an .ifndef so
|
||||
we don't do it again for each sub-make.
|
||||
|
||||
2003-09-28 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* install-mk (MK_VERSION): 20030928
|
||||
Add some extra *.sys.mk from bootstrap-pkgsrc
|
||||
some of these likely still need work.
|
||||
Make everything default to root:wheel ownership,
|
||||
sys.mk can set ROOT_GROUP accordingly.
|
||||
|
||||
2003-08-07 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* install-mk: if FORCE_BSD_MK={cp,ln} use the ones in SYS_MK_DIR
|
||||
not the portable ones.
|
||||
|
||||
2003-07-31 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* install-mk: add ability to use cp -f when updating
|
||||
destination .mk files. Also now possible to play games with
|
||||
FORCE_SYS_MK=ln etc on *BSD machines to link /usr/share/mk/sys.mk
|
||||
into dest - not recommended unless you seriously want to.
|
||||
|
||||
2003-07-28 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* own.mk (IMPFLAGS): add support for COPTS.${IMPSRC:T} etc
|
||||
for semi-compatability with NetBSD.
|
||||
|
||||
2003-07-23 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* install-mk: add a version indicator
|
||||
|
||||
2003-07-22 Simon J. Gerraty <sjg@void.crufty.net>
|
||||
|
||||
* prog.mk: don't try and use ${LIBCRT0} if its /dev/null
|
||||
|
||||
* install-mk: Allow FORCE_SYS_MK to come from env
|
||||
|
||||
|
||||
|
65
20150418/mk/FILES
Normal file
65
20150418/mk/FILES
Normal file
@ -0,0 +1,65 @@
|
||||
ChangeLog
|
||||
FILES
|
||||
README
|
||||
auto.obj.mk
|
||||
autoconf.mk
|
||||
autodep.mk
|
||||
auto.dep.mk
|
||||
cython.mk
|
||||
dep.mk
|
||||
doc.mk
|
||||
dpadd.mk
|
||||
final.mk
|
||||
host-target.mk
|
||||
host.libnames.mk
|
||||
inc.mk
|
||||
init.mk
|
||||
install-mk
|
||||
java.mk
|
||||
lib.mk
|
||||
libnames.mk
|
||||
libs.mk
|
||||
links.mk
|
||||
man.mk
|
||||
manifest.mk
|
||||
mk-files.txt
|
||||
mkopt.sh
|
||||
nls.mk
|
||||
obj.mk
|
||||
options.mk
|
||||
own.mk
|
||||
prlist.mk
|
||||
prog.mk
|
||||
progs.mk
|
||||
rst2htm.mk
|
||||
scripts.mk
|
||||
srctop.mk
|
||||
stage-install.sh
|
||||
subdir.mk
|
||||
sys.mk
|
||||
sys.clean-env.mk
|
||||
sys.dependfile.mk
|
||||
sys/AIX.mk
|
||||
sys/Darwin.mk
|
||||
sys/Generic.mk
|
||||
sys/HP-UX.mk
|
||||
sys/IRIX.mk
|
||||
sys/Linux.mk
|
||||
sys/NetBSD.mk
|
||||
sys/OSF1.mk
|
||||
sys/OpenBSD.mk
|
||||
sys/SunOS.mk
|
||||
sys/UnixWare.mk
|
||||
target-flags.mk
|
||||
warnings.mk
|
||||
whats.mk
|
||||
yacc.mk
|
||||
dirdeps.mk
|
||||
gendirdeps.mk
|
||||
install-new.mk
|
||||
meta2deps.py
|
||||
meta2deps.sh
|
||||
meta.sys.mk
|
||||
meta.autodep.mk
|
||||
meta.stage.mk
|
||||
meta.subdir.mk
|
401
20150418/mk/README
Normal file
401
20150418/mk/README
Normal file
@ -0,0 +1,401 @@
|
||||
# $Id: README,v 1.1 1997/03/11 07:27:15 sjg Exp $
|
||||
|
||||
This directory contains some macro's derrived from the NetBSD bsd.*.mk
|
||||
macros. They have the same names but without the bsd., separate macro
|
||||
files are needed to ensure we can make them do what we want for
|
||||
builing things outside of /usr/src. Nearly all the comments below
|
||||
apply.
|
||||
|
||||
# $NetBSD: bsd.README,v 1.18 1997/01/13 00:54:23 mark Exp $
|
||||
# @(#)bsd.README 5.1 (Berkeley) 5/11/90
|
||||
|
||||
This is the README file for the new make "include" files for the BSD
|
||||
source tree. The files are installed in /usr/share/mk, and are, by
|
||||
convention, named with the suffix ".mk".
|
||||
|
||||
Note, this file is not intended to replace reading through the .mk
|
||||
files for anything tricky.
|
||||
|
||||
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
|
||||
RANDOM THINGS WORTH KNOWING:
|
||||
|
||||
The files are simply 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 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 a single target:
|
||||
|
||||
maninstall:
|
||||
Install the manual pages and their links.
|
||||
|
||||
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 source tree configuration parameters,
|
||||
such as the owners, groups, etc. for both manual pages and binaries, and
|
||||
a few global "feature configuration" parameters.
|
||||
|
||||
It has no targets.
|
||||
|
||||
To get system-specific configuration parameters, bsd.own.mk will try to
|
||||
include the file specified by the "MAKECONF" variable. If MAKECONF is not
|
||||
set, or no such file exists, the system make configuration file, /etc/mk.conf
|
||||
is included. These files may define any of the variables described below.
|
||||
|
||||
bsd.own.mk sets the following variables, if they are not already defined
|
||||
(defaults are in brackets):
|
||||
|
||||
BSDSRCDIR The real path to the system sources, so that 'make obj'
|
||||
will work correctly. [/usr/src]
|
||||
|
||||
BSDOBJDIR The real path to the system 'obj' tree, so that 'make obj'
|
||||
will work correctly. [/usr/obj]
|
||||
|
||||
BINGRP Binary group. [bin]
|
||||
|
||||
BINOWN Binary owner. [bin]
|
||||
|
||||
BINMODE Binary mode. [555]
|
||||
|
||||
NONBINMODE Mode for non-executable files. [444]
|
||||
|
||||
MANDIR Base path for manual installation. [/usr/share/man/cat]
|
||||
|
||||
MANGRP Manual group. [bin]
|
||||
|
||||
MANOWN Manual owner. [bin]
|
||||
|
||||
MANMODE Manual mode. [${NONBINMODE}]
|
||||
|
||||
LIBDIR Base path for library installation. [/usr/lib]
|
||||
|
||||
LINTLIBDIR Base path for lint(1) library installation. [/usr/libdata/lint]
|
||||
|
||||
LIBGRP Library group. [${BINGRP}]
|
||||
|
||||
LIBOWN Library owner. [${BINOWN}]
|
||||
|
||||
LIBMODE Library mode. [${NONBINMODE}]
|
||||
|
||||
DOCDIR Base path for system documentation (e.g. PSD, USD, etc.)
|
||||
installation. [/usr/share/doc]
|
||||
|
||||
DOCGRP Documentation group. [bin]
|
||||
|
||||
DOCOWN Documentation owner. [bin]
|
||||
|
||||
DOCMODE Documentation mode. [${NONBINMODE}]
|
||||
|
||||
NLSDIR Base path for National Language Support files installation.
|
||||
[/usr/share/nls]
|
||||
|
||||
NLSGRP National Language Support files group. [bin]
|
||||
|
||||
NLSOWN National Language Support files owner. [bin]
|
||||
|
||||
NLSMODE National Language Support files mode. [${NONBINMODE}]
|
||||
|
||||
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 knob. [-s]
|
||||
|
||||
COPY The flag passed to the install program to cause the binary
|
||||
to be copied rather than moved. This is to be used when
|
||||
building our own install script so that the entire system
|
||||
can either be installed with copies, or with moves using
|
||||
a single knob. [-c]
|
||||
|
||||
Additionally, the following variables may be set by bsd.own.mk or in a
|
||||
make configuration file to modify the behaviour of the system build
|
||||
process (default values are in brackets along with comments, if set by
|
||||
bsd.own.mk):
|
||||
|
||||
EXPORTABLE_SYSTEM
|
||||
Do not build /usr/src/domestic, even if it is present.
|
||||
|
||||
SKEY Compile in support for S/key authentication. [yes, set
|
||||
unconditionally]
|
||||
|
||||
KERBEROS Compile in support for Kerberos 4 authentication.
|
||||
|
||||
KERBEROS5 Compile in support for Kerberos 5 authentication.
|
||||
|
||||
MANZ Compress manual pages at installation time.
|
||||
|
||||
SYS_INCLUDE Copy or symlink kernel include files into /usr/include.
|
||||
Possible values are "symlinks" or "copies" (which is
|
||||
the same as the variable being unset).
|
||||
|
||||
NOPROFILE Do not build profiled versions of system libraries
|
||||
|
||||
NOPIC Do not build PIC versions of system libraries, and
|
||||
do not build shared libraries. [set if ${MACHINE_ARCH}
|
||||
is "mips", "vax", "alpha" or "arm32", unset otherwise.]
|
||||
|
||||
NOLINT Do not build lint libraries. [set, set unconditionally]
|
||||
|
||||
bsd.own.mk 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 eight targets:
|
||||
|
||||
all:
|
||||
build the program and its manual page
|
||||
clean:
|
||||
remove the program, any object files and the files a.out,
|
||||
Errs, errs, mklog, and core.
|
||||
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.
|
||||
includes:
|
||||
install any header files.
|
||||
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 for the clean and cleandir targets.
|
||||
|
||||
COPTS Additional flags to the compiler when creating C objects.
|
||||
|
||||
HIDEGAME If HIDEGAME is defined, the binary is installed in
|
||||
/usr/games/hide, and a symbolic link is created to
|
||||
/usr/games/dm.
|
||||
|
||||
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.
|
||||
|
||||
SRCS List of source files to build the program. If PROG is not
|
||||
defined, it's assumed to be ${PROG}.c.
|
||||
|
||||
DPADD Additional dependencies for the program. Usually used for
|
||||
libraries. For example, to depend on the compatibility and
|
||||
utility libraries use:
|
||||
|
||||
DPADD+=${LIBCOMPAT} ${LIBUTIL}
|
||||
|
||||
The following libraries are predefined for DPADD:
|
||||
|
||||
LIBC /lib/libc.a
|
||||
LIBCOMPAT /usr/lib/libcompat.a
|
||||
LIBCRYPT /usr/lib/libcrypt.a
|
||||
LIBCURSES /usr/lib/libcurses.a
|
||||
LIBDBM /usr/lib/libdbm.a
|
||||
LIBDES /usr/lib/libdes.a
|
||||
LIBL /usr/lib/libl.a
|
||||
LIBKDB /usr/lib/libkdb.a
|
||||
LIBKRB /usr/lib/libkrb.a
|
||||
LIBKVM /usr/lib/libkvm.a
|
||||
LIBM /usr/lib/libm.a
|
||||
LIBMP /usr/lib/libmp.a
|
||||
LIBPC /usr/lib/libpc.a
|
||||
LIBPLOT /usr/lib/libplot.a
|
||||
LIBRPC /usr/lib/sunrpc.a
|
||||
LIBTERM /usr/lib/libterm.a
|
||||
LIBUTIL /usr/lib/libutil.a
|
||||
|
||||
SHAREDSTRINGS If defined, a new .c.o rule is used that results in shared
|
||||
strings, using xstr(1). Note that this will not work with
|
||||
parallel makes.
|
||||
|
||||
STRIP The flag passed to the install program to cause the binary
|
||||
to be stripped.
|
||||
|
||||
SUBDIR A list of subdirectories that should be built as well.
|
||||
Each of the targets will execute the same target in the
|
||||
subdirectories.
|
||||
|
||||
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:
|
||||
|
||||
NOMAN= noman
|
||||
|
||||
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 eight targets as <bsd.prog.mk>: all,
|
||||
clean, cleandir, depend, includes, 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.sys.mk> is used by <bsd.prog.mk> and
|
||||
<bsd.lib.mk>. It contains overrides that are used when building
|
||||
the NetBSD source tree. For instance, if "PARALLEL" is defined by
|
||||
the program/library Makefile, it includes a set of rules for lex and
|
||||
yacc that allow multiple lex and yacc targets to be built in parallel.
|
||||
|
||||
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
|
||||
The include file <bsd.lib.mk> has support for building libraries. It has
|
||||
the same eight targets as <bsd.prog.mk>: all, clean, cleandir, depend,
|
||||
includes, 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:
|
||||
|
||||
LIB The name of the library to build.
|
||||
|
||||
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.)
|
||||
|
||||
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 when made.
|
64
20150418/mk/auto.dep.mk
Normal file
64
20150418/mk/auto.dep.mk
Normal file
@ -0,0 +1,64 @@
|
||||
#
|
||||
# RCSid:
|
||||
# $Id: auto.dep.mk,v 1.3 2014/08/04 05:19:10 sjg Exp $
|
||||
#
|
||||
# @(#) Copyright (c) 2010, 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
|
||||
#
|
||||
|
||||
# This module provides automagic dependency generation along the
|
||||
# lines suggested in the GNU make.info
|
||||
|
||||
# set MKDEP_MK=auto.dep.mk and dep.mk will include us
|
||||
|
||||
# This version differs from autodep.mk, in that
|
||||
# we use ${.TARGET:T}.d rather than ${.TARGET:T:R}.d
|
||||
# this makes it simpler to get the args to -MF and -MT right
|
||||
# and ensure we can simply include all the .d files.
|
||||
#
|
||||
# However suffix rules do not work with something like .o.d so we
|
||||
# don't even try to handle 'make depend' gracefully.
|
||||
# dep.mk will handle that itself.
|
||||
#
|
||||
.if !target(__${.PARSEFILE}__)
|
||||
__${.PARSEFILE}__:
|
||||
|
||||
# this what bmake > 20100401 will look for
|
||||
.MAKE.DEPENDFILE ?= .depend
|
||||
|
||||
# set this to -MMD to ignore /usr/include
|
||||
# actually it ignores <> so may not be a great idea
|
||||
CFLAGS_MD ?= -MD
|
||||
# -MF etc not available on all gcc versions.
|
||||
CFLAGS_MF ?= -MF ${.TARGET:T}.d -MT ${.TARGET:T}
|
||||
CFLAGS += ${CFLAGS_MD} ${CFLAGS_MF}
|
||||
CXXFLAGS += ${CFLAGS_MD} ${CFLAGS_MF}
|
||||
|
||||
CLEANFILES += .depend ${.MAKE.DEPENDFILE} *.d
|
||||
|
||||
# skip generating dependfile for misc targets
|
||||
.if ${.TARGETS:Uall:M*all} != ""
|
||||
.END: ${.MAKE.DEPENDFILE}
|
||||
.endif
|
||||
|
||||
# doing 'make depend' isn't a big win with this model
|
||||
.if !target(depend)
|
||||
depend: ${.MAKE.DEPENDFILE}
|
||||
.endif
|
||||
|
||||
# this is trivial
|
||||
${.MAKE.DEPENDFILE}: ${OBJS} ${POBJS} ${SOBJS}
|
||||
-@for f in ${.ALLSRC:M*o:T:O:u:%=%.d}; do \
|
||||
echo ".-include \"$$f\""; \
|
||||
done > $@
|
||||
|
||||
.endif
|
61
20150418/mk/auto.obj.mk
Normal file
61
20150418/mk/auto.obj.mk
Normal file
@ -0,0 +1,61 @@
|
||||
# $Id: auto.obj.mk,v 1.10 2015/04/16 16:59:00 sjg Exp $
|
||||
#
|
||||
# @(#) Copyright (c) 2004, 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
|
||||
#
|
||||
|
||||
ECHO_TRACE ?= echo
|
||||
|
||||
.ifndef Mkdirs
|
||||
# A race condition in some versions of mkdir, means that it can bail
|
||||
# if another process made a dir that mkdir expected to.
|
||||
# We repeat the mkdir -p a number of times to try and work around this.
|
||||
# We stop looping as soon as the dir exists.
|
||||
# If we get to the end of the loop, a plain mkdir will issue an error.
|
||||
Mkdirs= Mkdirs() { \
|
||||
for d in $$*; do \
|
||||
for i in 1 2 3 4 5 6; do \
|
||||
mkdir -p $$d; \
|
||||
test -d $$d && return 0; \
|
||||
done > /dev/null 2>&1; \
|
||||
mkdir $$d || exit $$?; \
|
||||
done; }
|
||||
.endif
|
||||
|
||||
# if MKOBJDIRS is set to auto (and NOOBJ isn't defined) do some magic...
|
||||
# This will automatically create objdirs as needed.
|
||||
# Skip it if we are just doing 'clean'.
|
||||
.if ${MK_AUTO_OBJ:Uno} == "yes"
|
||||
MKOBJDIRS= auto
|
||||
.endif
|
||||
.if !defined(NOOBJ) && !defined(NO_OBJ) && ${MKOBJDIRS:Uno} == auto
|
||||
# Use __objdir here so it is easier to tweak without impacting
|
||||
# the logic.
|
||||
__objdir?= ${MAKEOBJDIR}
|
||||
__objdir:= ${__objdir:tA}
|
||||
.if ${.OBJDIR} != ${__objdir}
|
||||
# We need to chdir, make the directory if needed
|
||||
.if !exists(${__objdir}/) && \
|
||||
(${.TARGETS} == "" || ${.TARGETS:Nclean*:N*clean:Ndestroy*} != "")
|
||||
# This will actually make it...
|
||||
__objdir_made != echo ${__objdir}/; umask ${OBJDIR_UMASK:U002}; \
|
||||
${ECHO_TRACE} "[Creating objdir ${__objdir}...]" >&2; \
|
||||
${Mkdirs}; Mkdirs ${__objdir}
|
||||
__objdir:= ${__objdir:tA}
|
||||
.endif
|
||||
# This causes make to use the specified directory as .OBJDIR
|
||||
.OBJDIR: ${__objdir}
|
||||
.if ${.OBJDIR} != ${__objdir} && ${__objdir_made:Uno:M${__objdir}/*} != ""
|
||||
.error could not use ${__objdir}: .OBJDIR=${.OBJDIR}
|
||||
.endif
|
||||
.endif
|
||||
.endif
|
78
20150418/mk/autoconf.mk
Normal file
78
20150418/mk/autoconf.mk
Normal file
@ -0,0 +1,78 @@
|
||||
# $Id: autoconf.mk,v 1.8 2012/11/19 05:37:48 sjg Exp $
|
||||
#
|
||||
# @(#) Copyright (c) 1996-2009, 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
|
||||
#
|
||||
|
||||
.NOPATH: config.h config.status
|
||||
|
||||
.if !target(config.h)
|
||||
config.h: ${.CURDIR}/config.h.in config.status
|
||||
./config.status
|
||||
.endif
|
||||
|
||||
.if !target(config.status)
|
||||
# avoid the targets behaving differently
|
||||
.if exists(${.OBJDIR}/config.status)
|
||||
config.status: config.recheck
|
||||
.else
|
||||
config.status: config.gen
|
||||
.endif
|
||||
|
||||
config.recheck: config.h.in ${.CURDIR}/configure
|
||||
./config.status --recheck
|
||||
@touch $@
|
||||
|
||||
config.gen: config.h.in ${.CURDIR}/configure
|
||||
CC="${CC} ${CCMODE}" ${.CURDIR}/configure --no-create ${CONFIGURE_ARGS}
|
||||
@touch $@ config.recheck
|
||||
|
||||
CLEANFILES+= config.recheck config.gen config.status *.meta
|
||||
.endif
|
||||
|
||||
# avoid things blowing up if these are not here...
|
||||
# this is not quite per the autoconf manual,
|
||||
# and is extremely convoluted - but all utterly necessary!
|
||||
|
||||
.if make(autoconf-in) || make(configure) || make(config.h.in) || ${AUTO_AUTOCONF:Uno:tl} == "yes"
|
||||
AUTOCONF ?= autoconf
|
||||
AUTOHEADER ?= autoheader
|
||||
|
||||
# expand it to a full path
|
||||
AUTOCONF := ${AUTOCONF:${M_whence}}
|
||||
|
||||
.if exists(${AUTOCONF})
|
||||
|
||||
.PRECIOUS: configure config.h.in config.status
|
||||
|
||||
ACLOCAL =
|
||||
ACCONFIG =
|
||||
|
||||
.if exists(${.CURDIR}/aclocal.m4)
|
||||
ACLOCAL += aclocal.m4
|
||||
.endif
|
||||
# use of acconfig.h is deprecated!
|
||||
.if exists(${.CURDIR}/acconfig.h)
|
||||
ACCONFIG += acconfig.h
|
||||
.endif
|
||||
|
||||
config.h.in: ${.CURDIR}/configure.in ${ACCONFIG}
|
||||
(cd ${.CURDIR} && ${AUTOHEADER})
|
||||
|
||||
configure: ${.CURDIR}/configure.in ${ACLOCAL}
|
||||
(cd ${.CURDIR} && ${AUTOCONF})
|
||||
|
||||
AUTOCONF_INPUTS += configure
|
||||
autoconf-input: ${AUTOCONF_INPUTS}
|
||||
|
||||
.endif
|
||||
.endif
|
211
20150418/mk/autodep.mk
Normal file
211
20150418/mk/autodep.mk
Normal file
@ -0,0 +1,211 @@
|
||||
#
|
||||
# RCSid:
|
||||
# $Id: autodep.mk,v 1.34 2014/08/04 05:12:27 sjg Exp $
|
||||
#
|
||||
# @(#) Copyright (c) 1999-2010, 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
|
||||
|
||||
# This module provides automagic dependency generation along the
|
||||
# lines suggested in the GNU make.info
|
||||
# The depend target is mainly for backwards compatibility,
|
||||
# dependencies are normally updated as part of compilation.
|
||||
|
||||
.if !target(__${.PARSEFILE}__)
|
||||
__${.PARSEFILE}__:
|
||||
|
||||
DEPENDFILE?= .depend
|
||||
.for d in ${DEPENDFILE:N.depend}
|
||||
# bmake only groks .depend
|
||||
.-include "$d"
|
||||
.endfor
|
||||
|
||||
# it does nothing if SRCS is not defined or is empty
|
||||
.if defined(SRCS) && !empty(SRCS)
|
||||
DEPSRCS?=${SRCS}
|
||||
__depsrcs=${DEPSRCS:M*.c}
|
||||
__depsrcs+=${DEPSRCS:M*.y}
|
||||
__depsrcs+=${DEPSRCS:M*.l}
|
||||
__depsrcs+=${DEPSRCS:M*.s}
|
||||
__depsrcs+=${DEPSRCS:M*.S}
|
||||
__depsrcs+=${DEPSRCS:M*.cc}
|
||||
__depsrcs+=${DEPSRCS:M*.cpp}
|
||||
__depsrcs+=${DEPSRCS:M*.C}
|
||||
__depsrcs+=${DEPSRCS:M*.cxx}
|
||||
__depsrcs+=${DEPSRCS:M*.pc}
|
||||
|
||||
.for s in ${__depsrcs}
|
||||
${s:T:R}.d: $s
|
||||
.endfor
|
||||
|
||||
__depsrcs:=${__depsrcs:T:R:S/$/.d/g}
|
||||
# we also need to handle makefiles where the .d's from __depsrcs
|
||||
# don't match those from OBJS
|
||||
# we avoid using := here, since the modifier applied to OBJS
|
||||
# can cause trouble if there are any undefined vars in OBJS.
|
||||
__dependsrcsx?= ${__depsrcs} ${OBJS:S/.o/.d/}
|
||||
__dependsrcs= ${__dependsrcsx:O:u}
|
||||
|
||||
# clean up any .c files we may have generated
|
||||
#__gensrcs:= ${DEPSRCS:M*.y} ${DEPSRCS:M*.l}
|
||||
#CLEANFILES+= ${__gensrcs:T:R:S/$/.c/g}
|
||||
|
||||
# set this to -MMD to ignore /usr/include
|
||||
# actually it ignores <> so may not be a great idea
|
||||
CFLAGS_MD?=-MD
|
||||
# -MF etc not available on all gcc versions.
|
||||
# we "fix" the .o later
|
||||
CFLAGS_MF?=-MF ${.TARGET:T:R}.d -MT ${.TARGET:T:R}.o
|
||||
CFLAGS+= ${CFLAGS_MD} ${CFLAGS_MF}
|
||||
RM?= rm
|
||||
|
||||
# watch out for people who don't use CPPFLAGS
|
||||
CPPFLAGS_MD=${CFLAGS:M-[IUD]*} ${CPPFLAGS}
|
||||
CXXFLAGS_MD=${CXXFLAGS:M-[IUD]*} ${CPPFLAGS}
|
||||
|
||||
# just in case these need to be different
|
||||
CC_MD?=${CC}
|
||||
CXX_MD?=${CXX}
|
||||
|
||||
# so we can do an explicit make depend, but not otherwise
|
||||
.if make(depend)
|
||||
.SUFFIXES: .d
|
||||
|
||||
.if empty(CFLAGS_MD)
|
||||
.y.d:
|
||||
@echo updating dependencies for $<
|
||||
@${YACC} ${YFLAGS} $<
|
||||
@${SHELL} -ec "${CC_MD} -M ${CPPFLAGS_MD} y.tab.c | sed '/:/s/^/$@ /' > $@" || { ${RM} -f y.tab.c $@; false; }
|
||||
@${RM} -f y.tab.c
|
||||
|
||||
.l.d:
|
||||
@echo updating dependencies for $<
|
||||
${LEX} ${LFLAGS} $<
|
||||
@${SHELL} -ec "${CC_MD} -M ${CPPFLAGS_MD} lex.yy.c | sed '/:/s/^/$@ /' > $@" || { ${RM} -f lex.yy.c $@; false; }
|
||||
@${RM} -f lex.yy.c
|
||||
|
||||
.c.d:
|
||||
@echo updating dependencies for $<
|
||||
@${SHELL} -ec "${CC_MD} -M ${CPPFLAGS_MD} $< | sed '/:/s/^/$@ /' > $@" || { ${RM} -f $@; false; }
|
||||
|
||||
.s.d .S.d:
|
||||
@echo updating dependencies for $<
|
||||
@${SHELL} -ec "${CC_MD} -M ${CPPFLAGS_MD} ${AINC} $< | sed '/:/s/^/$@ /' > $@" || { ${RM} -f $@; false; }
|
||||
|
||||
.cc.d .cpp.d .C.d .cxx.d:
|
||||
@echo updating dependencies for $<
|
||||
@${SHELL} -ec "${CXX_MD} -M ${CXXFLAGS_MD} $< | sed '/:/s/^/$@ /' > $@" || { ${RM} -f $@; false; }
|
||||
.else
|
||||
.y.d:
|
||||
${YACC} ${YFLAGS} $<
|
||||
${CC_MD} ${CFLAGS_MD:S/D//} ${CPPFLAGS_MD} y.tab.c > $@ || { ${RM} -f y.tab.c $@; false; }
|
||||
${RM} -f y.tab.c
|
||||
|
||||
.l.d:
|
||||
${LEX} ${LFLAGS} $<
|
||||
${CC_MD} ${CFLAGS_MD:S/D//} ${CPPFLAGS_MD} lex.yy.c > $@ || { ${RM} -f lex.yy.c $@; false; }
|
||||
${RM} -f lex.yy.c
|
||||
|
||||
.c.d:
|
||||
${CC_MD} ${CFLAGS_MD:S/D//} ${CPPFLAGS_MD} $< > $@ || { ${RM} -f $@; false; }
|
||||
|
||||
.s.d .S.d:
|
||||
${CC_MD} ${CFLAGS_MD:S/D//} ${CPPFLAGS_MD} ${AINC} $< > $@ || { ${RM} -f $@; false; }
|
||||
|
||||
.cc.d .cpp.d .C.d .cxx.d:
|
||||
${CXX_MD} ${CFLAGS_MD:S/D//} ${CXXFLAGS_MD} $< > $@ || { ${RM} -f $@; false; }
|
||||
.endif
|
||||
|
||||
.if !target(depend)
|
||||
depend: beforedepend ${DEPENDFILE} afterdepend _SUBDIRUSE
|
||||
|
||||
${DEPENDFILE}: ${DEPSRCS} ${__dependsrcs}
|
||||
.NOPATH: ${__dependsrcs}
|
||||
.OPTIONAL: ${__dependsrcs}
|
||||
.endif
|
||||
.endif # make(depend)
|
||||
|
||||
.if empty(CFLAGS_MD)
|
||||
# make sure the .d's are generated/updated
|
||||
${PROG} ${_LIBS}: ${DEPENDFILE}
|
||||
.endif
|
||||
|
||||
.ORDER: beforedepend ${DEPENDFILE} afterdepend
|
||||
|
||||
.if ${.OBJDIR} != ${.CURDIR}
|
||||
__depfiles= *.d
|
||||
.else
|
||||
__depfiles= ${__dependsrcs}
|
||||
.endif
|
||||
|
||||
DEPCLEANFILES= ${DEPENDFILE} ${__depfiles} y.tab.d *.tmp.d
|
||||
|
||||
cleandir: cleanautodepend
|
||||
cleanautodepend:
|
||||
${RM} -f ${DEPCLEANFILES}
|
||||
|
||||
CLEANFILES+= ${DEPCLEANFILES}
|
||||
|
||||
.if defined(__dependsrcs) && !empty(__dependsrcs)
|
||||
.if make(depend) || !(make(clean*) || make(destroy*) || make(obj) || make(*install) || make(install-*))
|
||||
# this ensures we do the right thing if only building a shared or
|
||||
# profiled lib
|
||||
OBJ_EXTENSIONS?=.o .po .so .So
|
||||
MDLIB_SED= -e '/:/s,^\([^\.:]*\)\.[psS]*o,${OBJ_EXTENSIONS:S,^,\1,},'
|
||||
.ifdef NOMD_SED
|
||||
.ifdef LIB
|
||||
MD_SED=sed ${MDLIB_SED}
|
||||
.else
|
||||
MD_SED=cat
|
||||
.endif
|
||||
.else
|
||||
# arrange to put some variable names into ${DEPENDFILE}
|
||||
.ifdef LIB
|
||||
MD_SED=sed ${MDLIB_SED}
|
||||
.else
|
||||
MD_SED=sed
|
||||
.endif
|
||||
SUBST_DEPVARS+= SB TOP BACKING SRC SRCDIR BASE BASEDIR
|
||||
.for v in ${SUBST_DEPVARS}
|
||||
.if defined(${v}) && !empty(${v})
|
||||
MD_SED+= -e 's,${$v},$${$v},'
|
||||
.endif
|
||||
.endfor
|
||||
.endif
|
||||
.if (${MD_SED} == "sed")
|
||||
MD_SED=cat
|
||||
.endif
|
||||
|
||||
# this will be done whenever make finishes successfully
|
||||
.if ${MAKE_VERSION:U0:[1]:C/.*-//} < 20050530
|
||||
.END:
|
||||
.else
|
||||
.END: ${DEPENDFILE}
|
||||
# we do not want to trigger building .d's just use them if they exist
|
||||
${DEPENDFILE}: ${__dependsrcs:@d@${exists($d):?$d:}@}
|
||||
.endif
|
||||
-@${MD_SED} ${__depfiles} > ${DEPENDFILE}.new 2> /dev/null && \
|
||||
test -s ${DEPENDFILE}.new && mv ${DEPENDFILE}.new ${DEPENDFILE}; \
|
||||
${RM} -f ${DEPENDFILE}.new
|
||||
.endif
|
||||
.endif
|
||||
.else
|
||||
depend: beforedepend afterdepend _SUBDIRUSE
|
||||
.endif
|
||||
|
||||
.if !target(beforedepend)
|
||||
beforedepend:
|
||||
.endif
|
||||
.if !target(afterdepend)
|
||||
afterdepend:
|
||||
.endif
|
||||
|
||||
.endif
|
96
20150418/mk/cython.mk
Normal file
96
20150418/mk/cython.mk
Normal file
@ -0,0 +1,96 @@
|
||||
# RCSid:
|
||||
# $Id: cython.mk,v 1.6 2014/10/15 06:23:51 sjg Exp $
|
||||
#
|
||||
# @(#) Copyright (c) 2014, 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
|
||||
#
|
||||
|
||||
# this is what we build
|
||||
CYTHON_MODULE = ${CYTHON_MODULE_NAME}${CYTHON_PYVERSION}.so
|
||||
|
||||
CYTHON_MODULE_NAME?= it
|
||||
CYTHON_SRCS?= ${CYTHON_MODULE_NAME}.pyx
|
||||
|
||||
# this is where we save generated src
|
||||
CYTHON_SAVEGENDIR?= ${.CURDIR}/gen
|
||||
|
||||
# pyprefix is where python bits are
|
||||
# which may not be where we want to put ours (prefix)
|
||||
.if exists(/usr/pkg/include)
|
||||
pyprefix?= /usr/pkg
|
||||
.endif
|
||||
pyprefix?= /usr/local
|
||||
|
||||
PYTHON_VERSION?= 2.7
|
||||
PYTHON_H?= ${pyprefix}/include/python${PYTHON_VERSION}/Python.h
|
||||
PYVERSION:= ${PYTHON_VERSION:C,\..*,,}
|
||||
|
||||
# set this empty if you don't want to handle multiple versions
|
||||
.if !defined(CYTHON_PYVERSION)
|
||||
CYTHON_PYVERSION:= ${PYVERSION}
|
||||
.endif
|
||||
|
||||
CFLAGS+= -I${PYTHON_H:H}
|
||||
|
||||
CYTHON_GENSRCS= ${CYTHON_SRCS:R:S,$,${CYTHON_PYVERSION}.c,}
|
||||
SRCS+= ${CYTHON_GENSRCS}
|
||||
|
||||
.SUFFIXES: .pyx .c .So
|
||||
|
||||
CYTHON?= ${pyprefix}/bin/cython
|
||||
|
||||
# if we don't have cython we can use pre-generated srcs
|
||||
.if ${type ${CYTHON} 2> /dev/null || echo:L:sh:M/*} == ""
|
||||
.PATH: ${CYTHON_SAVEGENDIR}
|
||||
.else
|
||||
|
||||
.if !empty(CYTHON_PYVERSION)
|
||||
.for c in ${CYTHON_SRCS}
|
||||
${c:R}${CYTHON_PYVERSION}.${c:E}: $c
|
||||
ln -sf ${.ALLSRC:M*pyx} ${.TARGET}
|
||||
.endfor
|
||||
.endif
|
||||
|
||||
.pyx.c:
|
||||
${CYTHON} ${CYTHON_FLAGS} -${PYVERSION} -o ${.TARGET} ${.IMPSRC}
|
||||
|
||||
|
||||
save-gen: ${CYTHON_GENSRCS}
|
||||
mkdir -p ${CYTHON_SAVEGENDIR}
|
||||
cp -p ${.ALLSRC} ${CYTHON_SAVEGENDIR}
|
||||
|
||||
.endif
|
||||
|
||||
COMPILE.c?= ${CC} -c ${CFLAGS}
|
||||
|
||||
.c.So:
|
||||
${COMPILE.c} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}
|
||||
|
||||
${CYTHON_MODULE}: ${SRCS:S,.c,.So,}
|
||||
${CC} ${CC_SHARED:U-shared} -o ${.TARGET} ${.ALLSRC:M*.So} ${LDADD}
|
||||
|
||||
# conf.host_target() is limited to uname -m rather than uname -p
|
||||
_HOST_MACHINE!= uname -m
|
||||
.if ${HOST_TARGET:M*${_HOST_MACHINE}} == ""
|
||||
PY_HOST_TARGET:= ${HOST_TARGET:S,${_HOST_ARCH:U${uname -p:L:sh}}$,${_HOST_MACHINE},}
|
||||
.endif
|
||||
|
||||
MODULE_BINDIR?= ${.CURDIR:H}/${PY_HOST_TARGET:U${HOST_TARGET}}
|
||||
|
||||
build-cython-module: ${CYTHON_MODULE}
|
||||
|
||||
install-cython-module: ${CYTHON_MODULE}
|
||||
test -d ${DESTDIR}${MODULE_BINDIR} || \
|
||||
${INSTALL} -d ${DESTDIR}${MODULE_BINDIR}
|
||||
${INSTALL} -m 755 ${.ALLSRC} ${DESTDIR}${MODULE_BINDIR}
|
||||
|
||||
CLEANFILES+= *.So ${CYTHON_MODULE}
|
127
20150418/mk/dep.mk
Normal file
127
20150418/mk/dep.mk
Normal file
@ -0,0 +1,127 @@
|
||||
# $Id: dep.mk,v 1.17 2014/08/04 05:12:27 sjg Exp $
|
||||
|
||||
.if !target(__${.PARSEFILE}__)
|
||||
__${.PARSEFILE}__:
|
||||
|
||||
# handle Proc*C as well...
|
||||
.if defined(SRCS)
|
||||
.if !empty(SRCS:M*.pc)
|
||||
.include <proc.mk>
|
||||
.endif
|
||||
|
||||
# it would be nice to be able to query .SUFFIXES
|
||||
OBJ_EXTENSIONS+= .o .po .lo .So
|
||||
|
||||
# explicit dependencies help short-circuit .SUFFIX searches
|
||||
SRCS_DEP_FILTER+= N*.[hly]
|
||||
.for s in ${SRCS:${SRCS_DEP_FILTER:O:u:ts:}}
|
||||
.for e in ${OBJ_EXTENSIONS:O:u}
|
||||
.if !target(${s:T:R}$e)
|
||||
${s:T:R}$e: $s
|
||||
.endif
|
||||
.endfor
|
||||
.endfor
|
||||
.endif
|
||||
|
||||
.if exists(/usr/bin/mkdep)
|
||||
MKDEP_CMD?= mkdep
|
||||
.elif exists(/usr/local/share/bin/mkdeps.sh)
|
||||
MKDEP_CMD?= /usr/local/share/bin/mkdeps.sh -N
|
||||
.endif
|
||||
MKDEP_CMD?= mkdep
|
||||
|
||||
MKDEP ?= ${MKDEP_CMD}
|
||||
|
||||
.NOPATH: .depend
|
||||
|
||||
.if ${MKDEP_MK:Uno} == "auto.dep.mk" && make(depend)
|
||||
# auto.dep.mk does not "do" depend
|
||||
MK_AUTODEP= no
|
||||
.endif
|
||||
|
||||
.if ${MK_AUTODEP} == yes
|
||||
MKDEP_MK ?= autodep.mk
|
||||
.include <${MKDEP_MK}>
|
||||
.else
|
||||
MKDEP_ENV_VARS += CC CXX
|
||||
.for v in ${MKDEP_ENV_VARS:O:u}
|
||||
.if !empty($v)
|
||||
MKDEP_ENV += $v='${$v}'
|
||||
.endif
|
||||
.endfor
|
||||
|
||||
_MKDEP = ${MKDEP_ENV} ${MKDEP}
|
||||
|
||||
# some of the rules involve .h sources, so remove them from mkdep line
|
||||
.if !target(depend)
|
||||
depend: beforedepend .depend _SUBDIRUSE afterdepend
|
||||
|
||||
.if defined(SRCS)
|
||||
# libs can have too many SRCS for a single command line
|
||||
# so do them one at a time.
|
||||
.depend: ${SRCS} ${.PARSEDIR}/${.PASEFILE}
|
||||
@rm -f .depend
|
||||
.ifdef LIB
|
||||
@files="${.ALLSRC:M*.[sS]}"; \
|
||||
set -x; for f in $$files; do ${_MKDEP} -a ${MKDEPFLAGS} \
|
||||
${CFLAGS:M-[ID]*} ${CPPFLAGS} ${AINC} $$f; done
|
||||
@files="${.ALLSRC:M*.c} ${.ALLSRC:M*.pc:T:.pc=.c}"; \
|
||||
set -x; for f in $$files; do ${_MKDEP} -a ${MKDEPFLAGS} \
|
||||
${CFLAGS:M-[ID]*} ${CPPFLAGS} $$f; done
|
||||
@files="${.ALLSRC:M*.cc} ${.ALLSRC:M*.C} ${.ALLSRC:M*.cxx}"; \
|
||||
set -x; for f in $$files; do ${_MKDEP} -a ${MKDEPFLAGS} \
|
||||
${CXXFLAGS:M-[ID]*} ${CPPFLAGS} $$f; done
|
||||
.else
|
||||
@files="${.ALLSRC:M*.[Ss]}"; \
|
||||
case "$$files" in *.[Ss]*) \
|
||||
echo ${_MKDEP} -a ${MKDEPFLAGS} \
|
||||
${CFLAGS:M-[ID]*} ${CPPFLAGS} ${AINC} $$files; \
|
||||
${_MKDEP} -a ${MKDEPFLAGS} \
|
||||
${CFLAGS:M-[ID]*} ${CPPFLAGS} ${AINC} $$files;; \
|
||||
esac
|
||||
@files="${.ALLSRC:M*.c} ${.ALLSRC:M*.pc:T:.pc=.c}"; \
|
||||
case "$$files" in *.c*) \
|
||||
echo ${_MKDEP} -a ${MKDEPFLAGS} \
|
||||
${CFLAGS:M-[ID]*} ${CPPFLAGS} $$files; \
|
||||
${_MKDEP} -a ${MKDEPFLAGS} \
|
||||
${CFLAGS:M-[ID]*} ${CPPFLAGS} $$files;; \
|
||||
esac
|
||||
@files="${.ALLSRC:M*.cc} ${.ALLSRC:M*.C} ${.ALLSRC:M*.cxx}"; \
|
||||
case "$$files" in *.[Cc]*) \
|
||||
echo ${_MKDEP} -a ${MKDEPFLAGS} \
|
||||
${CXXFLAGS:M-[ID]*} ${CPPFLAGS} $$files; \
|
||||
${_MKDEP} -a ${MKDEPFLAGS} \
|
||||
${CXXFLAGS:M-[ID]*} ${CPPFLAGS} $$files;; \
|
||||
esac
|
||||
.endif
|
||||
.else
|
||||
.depend:
|
||||
.endif
|
||||
.if !target(beforedepend)
|
||||
beforedepend:
|
||||
.endif
|
||||
.if !target(afterdepend)
|
||||
afterdepend:
|
||||
.endif
|
||||
.endif
|
||||
.endif
|
||||
|
||||
.if !target(tags)
|
||||
.if defined(SRCS)
|
||||
tags: ${SRCS} _SUBDIRUSE
|
||||
-cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC:N*.h} | \
|
||||
sed "s;\${.CURDIR}/;;" > tags
|
||||
.else
|
||||
tags:
|
||||
.endif
|
||||
.endif
|
||||
|
||||
.if defined(SRCS)
|
||||
cleandir: cleandepend
|
||||
.if !target(cleandepend)
|
||||
cleandepend:
|
||||
rm -f .depend ${.CURDIR}/tags
|
||||
.endif
|
||||
.endif
|
||||
|
||||
.endif
|
642
20150418/mk/dirdeps.mk
Normal file
642
20150418/mk/dirdeps.mk
Normal file
@ -0,0 +1,642 @@
|
||||
# $Id: dirdeps.mk,v 1.49 2015/03/11 21:39:28 sjg Exp $
|
||||
|
||||
# Copyright (c) 2010-2013, Juniper Networks, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
|
||||
# OWNER 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.
|
||||
|
||||
# Much of the complexity here is for supporting cross-building.
|
||||
# If a tree does not support that, simply using plain Makefile.depend
|
||||
# should provide sufficient clue.
|
||||
# Otherwise the recommendation is to use Makefile.depend.${MACHINE}
|
||||
# as expected below.
|
||||
|
||||
# Note: this file gets multiply included.
|
||||
# This is what we do with DIRDEPS
|
||||
|
||||
# DIRDEPS:
|
||||
# This is a list of directories - relative to SRCTOP, it is
|
||||
# normally only of interest to .MAKE.LEVEL 0.
|
||||
# In some cases the entry may be qualified with a .<machine>
|
||||
# or .<target_spec> suffix (see TARGET_SPEC_VARS below),
|
||||
# for example to force building something for the pseudo
|
||||
# machines "host" or "common" regardless of current ${MACHINE}.
|
||||
#
|
||||
# All unqualified entries end up being qualified with .${TARGET_SPEC}
|
||||
# and partially qualified (if TARGET_SPEC_VARS has multiple
|
||||
# entries) are also expanded to a full .<target_spec>.
|
||||
# The _DIRDEP_USE target uses the suffix to set TARGET_SPEC
|
||||
# correctly when visiting each entry.
|
||||
#
|
||||
# The fully qualified directory entries are used to construct a
|
||||
# dependency graph that will drive the build later.
|
||||
#
|
||||
# Also, for each fully qualified directory target, we will search
|
||||
# using ${.MAKE.DEPENDFILE_PREFERENCE} to find additional
|
||||
# dependencies. We use Makefile.depend (default value for
|
||||
# .MAKE.DEPENDFILE_PREFIX) to refer to these makefiles to
|
||||
# distinguish them from others.
|
||||
#
|
||||
# Each Makefile.depend file sets DEP_RELDIR to be the
|
||||
# the RELDIR (path relative to SRCTOP) for its directory, and
|
||||
# since each Makefile.depend file includes dirdeps.mk, this
|
||||
# processing is recursive and results in .MAKE.LEVEL 0 learning the
|
||||
# dependencies of the tree wrt the initial directory (_DEP_RELDIR).
|
||||
#
|
||||
# BUILD_AT_LEVEL0
|
||||
# Indicates whether .MAKE.LEVEL 0 builds anything:
|
||||
# if "no" sub-makes are used to build everything,
|
||||
# if "yes" sub-makes are only used to build for other machines.
|
||||
# It is best to use "no", but this can require fixing some
|
||||
# makefiles to not do anything at .MAKE.LEVEL 0.
|
||||
#
|
||||
# TARGET_SPEC_VARS
|
||||
# The default value is just MACHINE, and for most environments
|
||||
# this is sufficient. The _DIRDEP_USE target actually sets
|
||||
# both MACHINE and TARGET_SPEC to the suffix of the current
|
||||
# target so that in the general case TARGET_SPEC can be ignored.
|
||||
#
|
||||
# If more than MACHINE is needed then sys.mk needs to decompose
|
||||
# TARGET_SPEC and set the relevant variables accordingly.
|
||||
# It is important that MACHINE be included in and actually be
|
||||
# the first member of TARGET_SPEC_VARS. This allows other
|
||||
# variables to be considered optional, and some of the treatment
|
||||
# below relies on MACHINE being the first entry.
|
||||
# Note: TARGET_SPEC cannot contain any '.'s so the target
|
||||
# triple used by compiler folk won't work (directly anyway).
|
||||
#
|
||||
# For example:
|
||||
#
|
||||
# # Always list MACHINE first,
|
||||
# # other variables might be optional.
|
||||
# TARGET_SPEC_VARS = MACHINE TARGET_OS
|
||||
# .if ${TARGET_SPEC:Uno:M*,*} != ""
|
||||
# _tspec := ${TARGET_SPEC:S/,/ /g}
|
||||
# MACHINE := ${_tspec:[1]}
|
||||
# TARGET_OS := ${_tspec:[2]}
|
||||
# # etc.
|
||||
# # We need to stop that TARGET_SPEC affecting any submakes
|
||||
# # and deal with MACHINE=${TARGET_SPEC} in the environment.
|
||||
# TARGET_SPEC =
|
||||
# # export but do not track
|
||||
# .export-env TARGET_SPEC
|
||||
# .export ${TARGET_SPEC_VARS}
|
||||
# .for v in ${TARGET_SPEC_VARS:O:u}
|
||||
# .if empty($v)
|
||||
# .undef $v
|
||||
# .endif
|
||||
# .endfor
|
||||
# .endif
|
||||
# # make sure we know what TARGET_SPEC is
|
||||
# # as we may need it to find Makefile.depend*
|
||||
# TARGET_SPEC = ${TARGET_SPEC_VARS:@v@${$v:U}@:ts,}
|
||||
#
|
||||
|
||||
# touch this at your peril
|
||||
_DIRDEP_USE_LEVEL?= 0
|
||||
.if ${.MAKE.LEVEL} == ${_DIRDEP_USE_LEVEL}
|
||||
# only the first instance is interested in all this
|
||||
|
||||
# First off, we want to know what ${MACHINE} to build for.
|
||||
# This can be complicated if we are using a mixture of ${MACHINE} specific
|
||||
# and non-specific Makefile.depend*
|
||||
|
||||
.if !target(_DIRDEP_USE)
|
||||
# do some setup we only need once
|
||||
_CURDIR ?= ${.CURDIR}
|
||||
_OBJDIR ?= ${.OBJDIR}
|
||||
|
||||
now_utc = ${%s:L:gmtime}
|
||||
.if !defined(start_utc)
|
||||
start_utc := ${now_utc}
|
||||
.endif
|
||||
|
||||
# make sure these are empty to start with
|
||||
_DEP_TARGET_SPEC =
|
||||
_DIRDEP_CHECKED =
|
||||
|
||||
# If TARGET_SPEC_VARS is other than just MACHINE
|
||||
# it should be set by sys.mk or similar by now.
|
||||
# TARGET_SPEC must not contain any '.'s.
|
||||
TARGET_SPEC_VARS ?= MACHINE
|
||||
# this is what we started with
|
||||
TARGET_SPEC = ${TARGET_SPEC_VARS:@v@${$v:U}@:ts,}
|
||||
# this is what we mostly use below
|
||||
DEP_TARGET_SPEC = ${TARGET_SPEC_VARS:S,^,DEP_,:@v@${$v:U}@:ts,}
|
||||
# make sure we have defaults
|
||||
.for v in ${TARGET_SPEC_VARS}
|
||||
DEP_$v ?= ${$v}
|
||||
.endfor
|
||||
|
||||
.if ${TARGET_SPEC_VARS:[#]} > 1
|
||||
# Ok, this gets more complex (putting it mildly).
|
||||
# In order to stay sane, we need to ensure that all the build_dirs
|
||||
# we compute below are fully qualified wrt DEP_TARGET_SPEC.
|
||||
# The makefiles may only partially specify (eg. MACHINE only),
|
||||
# so we need to construct a set of modifiers to fill in the gaps.
|
||||
# jot 10 should output 1 2 3 .. 10
|
||||
JOT ?= jot
|
||||
_tspec_x := ${${JOT} ${TARGET_SPEC_VARS:[#]}:L:sh}
|
||||
# this handles unqualified entries
|
||||
M_dep_qual_fixes = C;(/[^/.,]+)$$;\1.$${DEP_TARGET_SPEC};
|
||||
# there needs to be at least one item missing for these to make sense
|
||||
.for i in ${_tspec_x:[2..-1]}
|
||||
_tspec_m$i := ${TARGET_SPEC_VARS:[2..$i]:@w@[^,]+@:ts,}
|
||||
_tspec_a$i := ,${TARGET_SPEC_VARS:[$i..-1]:@v@$$$${DEP_$v}@:ts,}
|
||||
M_dep_qual_fixes += C;(\.${_tspec_m$i})$$;\1${_tspec_a$i};
|
||||
.endfor
|
||||
.else
|
||||
# A harmless? default.
|
||||
M_dep_qual_fixes = U
|
||||
.endif
|
||||
|
||||
.if !defined(.MAKE.DEPENDFILE_PREFERENCE)
|
||||
# .MAKE.DEPENDFILE_PREFERENCE makes the logic below neater?
|
||||
# you really want this set by sys.mk or similar
|
||||
.MAKE.DEPENDFILE_PREFERENCE = ${_CURDIR}/${.MAKE.DEPENDFILE:T}
|
||||
.if ${.MAKE.DEPENDFILE:E} == "${TARGET_SPEC}"
|
||||
.if ${TARGET_SPEC} != ${MACHINE}
|
||||
.MAKE.DEPENDFILE_PREFERENCE += ${_CURDIR}/${.MAKE.DEPENDFILE:T:R}.$${MACHINE}
|
||||
.endif
|
||||
.MAKE.DEPENDFILE_PREFERENCE += ${_CURDIR}/${.MAKE.DEPENDFILE:T:R}
|
||||
.endif
|
||||
.endif
|
||||
|
||||
_default_dependfile := ${.MAKE.DEPENDFILE_PREFERENCE:[1]:T}
|
||||
_machine_dependfiles := ${.MAKE.DEPENDFILE_PREFERENCE:T:M*${MACHINE}*}
|
||||
|
||||
# for machine specific dependfiles we require ${MACHINE} to be at the end
|
||||
# also for the sake of sanity we require a common prefix
|
||||
.if !defined(.MAKE.DEPENDFILE_PREFIX)
|
||||
# knowing .MAKE.DEPENDFILE_PREFIX helps
|
||||
.if !empty(_machine_dependfiles)
|
||||
.MAKE.DEPENDFILE_PREFIX := ${_machine_dependfiles:[1]:T:R}
|
||||
.else
|
||||
.MAKE.DEPENDFILE_PREFIX := ${_default_dependfile:T}
|
||||
.endif
|
||||
.endif
|
||||
|
||||
|
||||
# this is how we identify non-machine specific dependfiles
|
||||
N_notmachine := ${.MAKE.DEPENDFILE_PREFERENCE:E:N*${MACHINE}*:${M_ListToSkip}}
|
||||
|
||||
.endif # !target(_DIRDEP_USE)
|
||||
|
||||
# if we were included recursively _DEP_TARGET_SPEC should be valid.
|
||||
.if empty(_DEP_TARGET_SPEC)
|
||||
# we may or may not have included a dependfile yet
|
||||
.if defined(.INCLUDEDFROMFILE)
|
||||
_last_dependfile := ${.INCLUDEDFROMFILE:M${.MAKE.DEPENDFILE_PREFIX}*}
|
||||
.else
|
||||
_last_dependfile := ${.MAKE.MAKEFILES:M*/${.MAKE.DEPENDFILE_PREFIX}*:[-1]}
|
||||
.endif
|
||||
.if ${_debug_reldir:U0}
|
||||
.info ${DEP_RELDIR}.${DEP_TARGET_SPEC}: _last_dependfile='${_last_dependfile}'
|
||||
.endif
|
||||
|
||||
.if empty(_last_dependfile) || ${_last_dependfile:E:${N_notmachine}} == ""
|
||||
# this is all we have to work with
|
||||
DEP_MACHINE = ${TARGET_MACHINE:U${MACHINE}}
|
||||
_DEP_TARGET_SPEC := ${DEP_TARGET_SPEC}
|
||||
.else
|
||||
_DEP_TARGET_SPEC = ${_last_dependfile:${M_dep_qual_fixes:ts:}:E}
|
||||
.endif
|
||||
.if !empty(_last_dependfile)
|
||||
# record that we've read dependfile for this
|
||||
_DIRDEP_CHECKED += ${_CURDIR}.${TARGET_SPEC}
|
||||
.endif
|
||||
.endif
|
||||
|
||||
# by now _DEP_TARGET_SPEC should be set, parse it.
|
||||
.if ${TARGET_SPEC_VARS:[#]} > 1
|
||||
# we need to parse DEP_MACHINE may or may not contain more info
|
||||
_tspec := ${_DEP_TARGET_SPEC:S/,/ /g}
|
||||
.for i in ${_tspec_x}
|
||||
DEP_${TARGET_SPEC_VARS:[$i]} := ${_tspec:[$i]}
|
||||
.endfor
|
||||
.for v in ${TARGET_SPEC_VARS:O:u}
|
||||
.if empty(DEP_$v)
|
||||
.undef DEP_$v
|
||||
.endif
|
||||
.endfor
|
||||
.else
|
||||
DEP_MACHINE := ${_DEP_TARGET_SPEC}
|
||||
.endif
|
||||
|
||||
# pickup customizations
|
||||
# as below you can use !target(_DIRDEP_USE) to protect things
|
||||
# which should only be done once.
|
||||
.-include "local.dirdeps.mk"
|
||||
|
||||
# the first time we are included the _DIRDEP_USE target will not be defined
|
||||
# we can use this as a clue to do initialization and other one time things.
|
||||
.if !target(_DIRDEP_USE)
|
||||
# make sure this target exists
|
||||
dirdeps: beforedirdeps .WAIT
|
||||
beforedirdeps:
|
||||
|
||||
# We normally expect to be included by Makefile.depend.*
|
||||
# which sets the DEP_* macros below.
|
||||
DEP_RELDIR ?= ${RELDIR}
|
||||
|
||||
# this can cause lots of output!
|
||||
# set to a set of glob expressions that might match RELDIR
|
||||
DEBUG_DIRDEPS ?= no
|
||||
|
||||
# remember the initial value of DEP_RELDIR - we test for it below.
|
||||
_DEP_RELDIR := ${DEP_RELDIR}
|
||||
|
||||
# things we skip for host tools
|
||||
SKIP_HOSTDIR ?=
|
||||
|
||||
NSkipHostDir = ${SKIP_HOSTDIR:N*.host*:S,$,.host*,:N.host*:S,^,${SRCTOP}/,:${M_ListToSkip}}
|
||||
|
||||
# things we always skip
|
||||
# SKIP_DIRDEPS allows for adding entries on command line.
|
||||
SKIP_DIR += .host *.WAIT ${SKIP_DIRDEPS}
|
||||
SKIP_DIR.host += ${SKIP_HOSTDIR}
|
||||
|
||||
DEP_SKIP_DIR = ${SKIP_DIR} \
|
||||
${SKIP_DIR.${DEP_TARGET_SPEC}:U} \
|
||||
${SKIP_DIR.${DEP_MACHINE}:U} \
|
||||
${SKIP_DIRDEPS.${DEP_MACHINE}:U}
|
||||
|
||||
NSkipDir = ${DEP_SKIP_DIR:${M_ListToSkip}}
|
||||
|
||||
.if defined(NO_DIRDEPS) || defined(NODIRDEPS) || defined(WITHOUT_DIRDEPS)
|
||||
# confine ourselves to the original dir
|
||||
DIRDEPS_FILTER += M${_DEP_RELDIR}*
|
||||
.endif
|
||||
|
||||
# this is what we run below
|
||||
DIRDEP_MAKE?= ${.MAKE}
|
||||
|
||||
# we suppress SUBDIR when visiting the leaves
|
||||
# we assume sys.mk will set MACHINE_ARCH
|
||||
# you can add extras to DIRDEP_USE_ENV
|
||||
# if there is no makefile in the target directory, we skip it.
|
||||
_DIRDEP_USE: .USE .MAKE
|
||||
@for m in ${.MAKE.MAKEFILE_PREFERENCE}; do \
|
||||
test -s ${.TARGET:R}/$$m || continue; \
|
||||
echo "${TRACER}Checking ${.TARGET:R} for ${.TARGET:E} ..."; \
|
||||
MACHINE_ARCH= NO_SUBDIR=1 ${DIRDEP_USE_ENV} \
|
||||
TARGET_SPEC=${.TARGET:E} \
|
||||
MACHINE=${.TARGET:E} \
|
||||
${DIRDEP_MAKE} -C ${.TARGET:R} || exit 1; \
|
||||
break; \
|
||||
done
|
||||
|
||||
.ifdef ALL_MACHINES
|
||||
# this is how you limit it to only the machines we have been built for
|
||||
# previously.
|
||||
.if empty(ONLY_MACHINE_LIST)
|
||||
.if !empty(ALL_MACHINE_LIST)
|
||||
# ALL_MACHINE_LIST is the list of all legal machines - ignore anything else
|
||||
_machine_list != cd ${_CURDIR} && 'ls' -1 ${ALL_MACHINE_LIST:O:u:@m@${.MAKE.DEPENDFILE:T:R}.$m@} 2> /dev/null; echo
|
||||
.else
|
||||
_machine_list != 'ls' -1 ${_CURDIR}/${.MAKE.DEPENDFILE_PREFIX}.* 2> /dev/null; echo
|
||||
.endif
|
||||
_only_machines := ${_machine_list:${NIgnoreFiles:UN*.bak}:E:O:u}
|
||||
.else
|
||||
_only_machines := ${ONLY_MACHINE_LIST}
|
||||
.endif
|
||||
|
||||
.if empty(_only_machines)
|
||||
# we must be boot-strapping
|
||||
_only_machines := ${TARGET_MACHINE:U${ALL_MACHINE_LIST:U${DEP_MACHINE}}}
|
||||
.endif
|
||||
|
||||
.else # ! ALL_MACHINES
|
||||
# if ONLY_MACHINE_LIST is set, we are limited to that
|
||||
# if TARGET_MACHINE is set - it is really the same as ONLY_MACHINE_LIST
|
||||
# otherwise DEP_MACHINE is it - so DEP_MACHINE will match.
|
||||
_only_machines := ${ONLY_MACHINE_LIST:U${TARGET_MACHINE:U${DEP_MACHINE}}:M${DEP_MACHINE}}
|
||||
.endif
|
||||
|
||||
.if !empty(NOT_MACHINE_LIST)
|
||||
_only_machines := ${_only_machines:${NOT_MACHINE_LIST:${M_ListToSkip}}}
|
||||
.endif
|
||||
|
||||
# make sure we have a starting place?
|
||||
DIRDEPS ?= ${RELDIR}
|
||||
.endif # target
|
||||
|
||||
# if repeatedly building the same target,
|
||||
# we can avoid the overhead of re-computing the tree dependencies.
|
||||
MK_DIRDEPS_CACHE ?= no
|
||||
BUILD_DIRDEPS_CACHE ?= no
|
||||
BUILD_DIRDEPS ?= yes
|
||||
|
||||
.if !defined(NO_DIRDEPS)
|
||||
.if ${MK_DIRDEPS_CACHE} == "yes"
|
||||
# this is where we will cache all our work
|
||||
DIRDEPS_CACHE?= ${_OBJDIR}/dirdeps.cache${.TARGETS:Nall:O:u:ts-:S,^,.,:N.}
|
||||
|
||||
# just ensure this exists
|
||||
build-dirdeps:
|
||||
|
||||
M_oneperline = @x@\\${.newline} $$x@
|
||||
|
||||
.if ${BUILD_DIRDEPS_CACHE} == "no"
|
||||
.if !target(dirdeps-cached)
|
||||
# we do this via sub-make
|
||||
BUILD_DIRDEPS = no
|
||||
|
||||
dirdeps: dirdeps-cached
|
||||
dirdeps-cached: ${DIRDEPS_CACHE} .MAKE
|
||||
@echo "${TRACER}Using ${DIRDEPS_CACHE}"
|
||||
@MAKELEVEL=${.MAKE.LEVEL} ${.MAKE} -C ${_CURDIR} -f ${DIRDEPS_CACHE} \
|
||||
dirdeps MK_DIRDEPS_CACHE=no BUILD_DIRDEPS=no
|
||||
|
||||
# these should generally do
|
||||
BUILD_DIRDEPS_MAKEFILE ?= ${MAKEFILE}
|
||||
BUILD_DIRDEPS_TARGETS ?= ${.TARGETS}
|
||||
|
||||
# we need the .meta file to ensure we update if
|
||||
# any of the Makefile.depend* changed.
|
||||
# We do not want to compare the command line though.
|
||||
${DIRDEPS_CACHE}: .META .NOMETA_CMP
|
||||
+@{ echo '# Autogenerated - do NOT edit!'; echo; \
|
||||
echo 'BUILD_DIRDEPS=no'; echo; \
|
||||
echo '.include <dirdeps.mk>'; \
|
||||
} > ${.TARGET}.new
|
||||
+@MAKELEVEL=${.MAKE.LEVEL} DIRDEPS_CACHE=${DIRDEPS_CACHE} \
|
||||
DIRDEPS="${DIRDEPS}" \
|
||||
MAKEFLAGS= ${.MAKE} -C ${_CURDIR} -f ${BUILD_DIRDEPS_MAKEFILE} \
|
||||
${BUILD_DIRDEPS_TARGETS} BUILD_DIRDEPS_CACHE=yes \
|
||||
3>&1 1>&2 | sed 's,${SRCTOP},$${SRCTOP},g' >> ${.TARGET}.new && \
|
||||
mv ${.TARGET}.new ${.TARGET}
|
||||
|
||||
.endif
|
||||
.elif !target(_count_dirdeps)
|
||||
# we want to capture the dirdeps count in the cache
|
||||
.END: _count_dirdeps
|
||||
_count_dirdeps: .NOMETA
|
||||
@echo '.info $${.newline}$${TRACER}Makefiles read: total=${.MAKE.MAKEFILES:[#]} depend=${.MAKE.MAKEFILES:M*depend*:[#]} dirdeps=${.ALLTARGETS:M${SRCTOP}*:O:u:[#]}' >&3
|
||||
|
||||
.endif
|
||||
.endif
|
||||
.elif !target(_count_dirdeps)
|
||||
beforedirdeps: _count_dirdeps
|
||||
_count_dirdeps: .NOMETA
|
||||
@echo "${TRACER}Makefiles read: total=${.MAKE.MAKEFILES:[#]} depend=${.MAKE.MAKEFILES:M*depend*:[#]} dirdeps=${.ALLTARGETS:M${SRCTOP}*:O:u:[#]} seconds=`expr ${now_utc} - ${start_utc}`"
|
||||
|
||||
.endif
|
||||
.if ${BUILD_DIRDEPS} == "yes"
|
||||
.if ${DEBUG_DIRDEPS:@x@${DEP_RELDIR:M$x}${${DEP_RELDIR}.${DEP_MACHINE}:L:M$x}@} != ""
|
||||
_debug_reldir = 1
|
||||
.else
|
||||
_debug_reldir = 0
|
||||
.endif
|
||||
.if ${DEBUG_DIRDEPS:@x@${DEP_RELDIR:M$x}${${DEP_RELDIR}.depend:L:M$x}@} != ""
|
||||
_debug_search = 1
|
||||
.else
|
||||
_debug_search = 0
|
||||
.endif
|
||||
|
||||
# the rest is done repeatedly for every Makefile.depend we read.
|
||||
# if we are anything but the original dir we care only about the
|
||||
# machine type we were included for..
|
||||
|
||||
.if ${DEP_RELDIR} == "."
|
||||
_this_dir := ${SRCTOP}
|
||||
.else
|
||||
_this_dir := ${SRCTOP}/${DEP_RELDIR}
|
||||
.endif
|
||||
|
||||
# on rare occasions, there can be a need for extra help
|
||||
_dep_hack := ${_this_dir}/${.MAKE.DEPENDFILE_PREFIX}.inc
|
||||
.-include "${_dep_hack}"
|
||||
|
||||
.if ${DEP_RELDIR} != ${_DEP_RELDIR} || ${DEP_TARGET_SPEC} != ${TARGET_SPEC}
|
||||
# this should be all
|
||||
_machines := ${DEP_MACHINE}
|
||||
.else
|
||||
# this is the machine list we actually use below
|
||||
_machines := ${_only_machines}
|
||||
|
||||
.if defined(HOSTPROG) || ${DEP_MACHINE} == "host"
|
||||
# we need to build this guy's dependencies for host as well.
|
||||
_machines += host
|
||||
.endif
|
||||
|
||||
_machines := ${_machines:O:u}
|
||||
.endif
|
||||
|
||||
.if ${TARGET_SPEC_VARS:[#]} > 1
|
||||
# we need to tweak _machines
|
||||
_dm := ${DEP_MACHINE}
|
||||
# apply the same filtering that we do when qualifying DIRDEPS.
|
||||
# M_dep_qual_fixes expects .${MACHINE}* so add (and remove) '.'
|
||||
_machines := ${_machines:@DEP_MACHINE@${DEP_TARGET_SPEC}@:S,^,.,:${M_dep_qual_fixes:ts:}:O:u:S,^.,,}
|
||||
DEP_MACHINE := ${_dm}
|
||||
.endif
|
||||
|
||||
# reset each time through
|
||||
_build_dirs =
|
||||
|
||||
.if ${DEP_RELDIR} == ${_DEP_RELDIR}
|
||||
# pickup other machines for this dir if necessary
|
||||
.if ${BUILD_AT_LEVEL0:Uyes} == "no"
|
||||
_build_dirs += ${_machines:@m@${_CURDIR}.$m@}
|
||||
.else
|
||||
_build_dirs += ${_machines:N${DEP_TARGET_SPEC}:@m@${_CURDIR}.$m@}
|
||||
.if ${DEP_TARGET_SPEC} == ${TARGET_SPEC}
|
||||
# pickup local dependencies now
|
||||
.-include <.depend>
|
||||
.endif
|
||||
.endif
|
||||
.endif
|
||||
|
||||
.if ${_debug_reldir}
|
||||
.info ${DEP_RELDIR}.${DEP_TARGET_SPEC}: DIRDEPS='${DIRDEPS}'
|
||||
.info ${DEP_RELDIR}.${DEP_TARGET_SPEC}: _machines='${_machines}'
|
||||
.endif
|
||||
|
||||
.if !empty(DIRDEPS)
|
||||
# these we reset each time through as they can depend on DEP_MACHINE
|
||||
DEP_DIRDEPS_FILTER = \
|
||||
${DIRDEPS_FILTER.${DEP_TARGET_SPEC}:U} \
|
||||
${DIRDEPS_FILTER.${DEP_MACHINE}:U} \
|
||||
${DIRDEPS_FILTER:U}
|
||||
.if empty(DEP_DIRDEPS_FILTER)
|
||||
# something harmless
|
||||
DEP_DIRDEPS_FILTER = U
|
||||
.endif
|
||||
|
||||
# this is what we start with
|
||||
__depdirs := ${DIRDEPS:${NSkipDir}:${DEP_DIRDEPS_FILTER:ts:}:C,//+,/,g:O:u:@d@${SRCTOP}/$d@}
|
||||
|
||||
# some entries may be qualified with .<machine>
|
||||
# the :M*/*/*.* just tries to limit the dirs we check to likely ones.
|
||||
# the ${d:E:M*/*} ensures we don't consider junos/usr.sbin/mgd
|
||||
__qual_depdirs := ${__depdirs:M*/*/*.*:@d@${exists($d):?:${"${d:E:M*/*}":?:${exists(${d:R}):?$d:}}}@}
|
||||
__unqual_depdirs := ${__depdirs:${__qual_depdirs:Uno:${M_ListToSkip}}}
|
||||
|
||||
.if ${DEP_RELDIR} == ${_DEP_RELDIR}
|
||||
# if it was called out - we likely need it.
|
||||
__hostdpadd := ${DPADD:U.:M${HOST_OBJTOP}/*:S,${HOST_OBJTOP}/,,:H:${NSkipDir}:${DIRDEPS_FILTER:ts:}:S,$,.host,:N.*:@d@${SRCTOP}/$d@}
|
||||
__qual_depdirs += ${__hostdpadd}
|
||||
.endif
|
||||
|
||||
.if ${_debug_reldir}
|
||||
.info depdirs=${__depdirs}
|
||||
.info qualified=${__qual_depdirs}
|
||||
.info unqualified=${__unqual_depdirs}
|
||||
.endif
|
||||
|
||||
# _build_dirs is what we will feed to _DIRDEP_USE
|
||||
_build_dirs += \
|
||||
${__qual_depdirs:M*.host:${NSkipHostDir}:N.host} \
|
||||
${__qual_depdirs:N*.host} \
|
||||
${_machines:Mhost*:@m@${__unqual_depdirs:@d@$d.$m@}@:${NSkipHostDir}:N.host} \
|
||||
${_machines:Nhost*:@m@${__unqual_depdirs:@d@$d.$m@}@}
|
||||
|
||||
# qualify everything now
|
||||
_build_dirs := ${_build_dirs:${M_dep_qual_fixes:ts:}:O:u}
|
||||
|
||||
.endif # empty DIRDEPS
|
||||
|
||||
# Normally if doing make -V something,
|
||||
# we do not want to waste time chasing DIRDEPS
|
||||
# but if we want to count the number of Makefile.depend* read, we do.
|
||||
.if ${.MAKEFLAGS:M-V${_V_READ_DIRDEPS}} == ""
|
||||
.if !empty(_build_dirs)
|
||||
.if ${BUILD_DIRDEPS_CACHE} == "yes"
|
||||
x!= { echo; echo '\# ${DEP_RELDIR}.${DEP_TARGET_SPEC}'; \
|
||||
echo 'dirdeps: ${_build_dirs:${M_oneperline}}'; echo; } >&3; echo
|
||||
x!= { ${_build_dirs:@x@${target($x):?:echo '$x: _DIRDEP_USE';}@} echo; } >&3; echo
|
||||
.else
|
||||
# this makes it all happen
|
||||
dirdeps: ${_build_dirs}
|
||||
.endif
|
||||
${_build_dirs}: _DIRDEP_USE
|
||||
|
||||
.if ${_debug_reldir}
|
||||
.info ${DEP_RELDIR}.${DEP_TARGET_SPEC}: needs: ${_build_dirs}
|
||||
.endif
|
||||
|
||||
# this builds the dependency graph
|
||||
.for m in ${_machines}
|
||||
# it would be nice to do :N${.TARGET}
|
||||
.if !empty(__qual_depdirs)
|
||||
.for q in ${__qual_depdirs:${M_dep_qual_fixes:ts:}:E:O:u:N$m}
|
||||
.if ${_debug_reldir} || ${DEBUG_DIRDEPS:@x@${${DEP_RELDIR}.$m:L:M$x}${${DEP_RELDIR}.$q:L:M$x}@} != ""
|
||||
.info ${DEP_RELDIR}.$m: graph: ${_build_dirs:M*.$q}
|
||||
.endif
|
||||
.if ${BUILD_DIRDEPS_CACHE} == "yes"
|
||||
x!= { echo; echo '${_this_dir}.$m: ${_build_dirs:M*.$q:${M_oneperline}}'; echo; } >&3; echo
|
||||
.else
|
||||
${_this_dir}.$m: ${_build_dirs:M*.$q}
|
||||
.endif
|
||||
.endfor
|
||||
.endif
|
||||
.if ${_debug_reldir}
|
||||
.info ${DEP_RELDIR}.$m: graph: ${_build_dirs:M*.$m:N${_this_dir}.$m}
|
||||
.endif
|
||||
.if ${BUILD_DIRDEPS_CACHE} == "yes"
|
||||
x!= { echo; echo '${_this_dir}.$m: ${_build_dirs:M*.$m:N${_this_dir}.$m:${M_oneperline}}'; echo; } >&3; echo
|
||||
.else
|
||||
${_this_dir}.$m: ${_build_dirs:M*.$m:N${_this_dir}.$m}
|
||||
.endif
|
||||
.endfor
|
||||
|
||||
.endif
|
||||
|
||||
# Now find more dependencies - and recurse.
|
||||
.for d in ${_build_dirs}
|
||||
.if ${_DIRDEP_CHECKED:M$d} == ""
|
||||
# once only
|
||||
_DIRDEP_CHECKED += $d
|
||||
.if ${_debug_search}
|
||||
.info checking $d
|
||||
.endif
|
||||
# Note: _build_dirs is fully qualifed so d:R is always the directory
|
||||
.if exists(${d:R})
|
||||
# Warning: there is an assumption here that MACHINE is always
|
||||
# the first entry in TARGET_SPEC_VARS.
|
||||
# If TARGET_SPEC and MACHINE are insufficient, you have a problem.
|
||||
_m := ${.MAKE.DEPENDFILE_PREFERENCE:T:S;${TARGET_SPEC}$;${d:E};:S;${MACHINE};${d:E:C/,.*//};:@m@${exists(${d:R}/$m):?${d:R}/$m:}@:[1]}
|
||||
.if !empty(_m)
|
||||
# M_dep_qual_fixes isn't geared to Makefile.depend
|
||||
_qm := ${_m:C;(\.depend)$;\1.${d:E};:${M_dep_qual_fixes:ts:}}
|
||||
.if ${_debug_search}
|
||||
.info Looking for ${_qm}
|
||||
.endif
|
||||
# we pass _DEP_TARGET_SPEC to tell the next step what we want
|
||||
_DEP_TARGET_SPEC := ${d:E}
|
||||
# some makefiles may still look at this
|
||||
_DEP_MACHINE := ${d:E:C/,.*//}
|
||||
.if ${_debug_reldir} && ${_qm} != ${_m}
|
||||
.info loading ${_m} for ${d:E}
|
||||
.endif
|
||||
.include <${_m}>
|
||||
.endif
|
||||
.endif
|
||||
.endif
|
||||
.endfor
|
||||
|
||||
.endif # -V
|
||||
.endif # BUILD_DIRDEPS
|
||||
|
||||
.elif ${.MAKE.LEVEL} > 42
|
||||
.error You should have stopped recursing by now.
|
||||
.else
|
||||
_DEP_RELDIR := ${DEP_RELDIR}
|
||||
# pickup local dependencies
|
||||
.-include <.depend>
|
||||
.endif
|
||||
|
||||
# bootstrapping new dependencies made easy?
|
||||
.if make(bootstrap*) && !target(bootstrap)
|
||||
|
||||
.if exists(${.CURDIR}/${.MAKE.DEPENDFILE:T})
|
||||
# stop here
|
||||
${.TARGETS:Mboot*}:
|
||||
.else
|
||||
# find a Makefile.depend to use as _src
|
||||
_src != cd ${.CURDIR} && for m in ${.MAKE.DEPENDFILE_PREFERENCE:T:S,${MACHINE},*,}; do test -s $$m || continue; echo $$m; break; done; echo
|
||||
.if empty(_src)
|
||||
.error cannot find any of ${.MAKE.DEPENDFILE_PREFERENCE:T}
|
||||
.endif
|
||||
|
||||
_src?= ${.MAKE.DEPENDFILE:T}
|
||||
|
||||
bootstrap-this: .NOTMAIN
|
||||
@echo Bootstrapping ${RELDIR}/${.MAKE.DEPENDFILE:T} from ${_src:T}
|
||||
(cd ${.CURDIR} && sed 's,${_src:E},${MACHINE},g' ${_src} > ${.MAKE.DEPENDFILE:T})
|
||||
|
||||
bootstrap: bootstrap-recurse
|
||||
bootstrap-recurse: bootstrap-this
|
||||
|
||||
_mf := ${.PARSEFILE}
|
||||
bootstrap-recurse: .NOTMAIN .MAKE
|
||||
@cd ${SRCTOP} && \
|
||||
for d in `cd ${RELDIR} && ${.MAKE} -B -f ${"${.MAKEFLAGS:M-n}":?${_src}:${.MAKE.DEPENDFILE:T}} -V DIRDEPS`; do \
|
||||
test -d $$d || d=$${d%.*}; \
|
||||
test -d $$d || continue; \
|
||||
echo "Checking $$d for bootstrap ..."; \
|
||||
(cd $$d && ${.MAKE} -f ${_mf} bootstrap-recurse); \
|
||||
done
|
||||
|
||||
.endif
|
||||
.endif
|
63
20150418/mk/doc.mk
Normal file
63
20150418/mk/doc.mk
Normal file
@ -0,0 +1,63 @@
|
||||
# $Id: doc.mk,v 1.4 2012/11/11 22:37:02 sjg Exp $
|
||||
|
||||
.if !target(__${.PARSEFILE}__)
|
||||
__${.PARSEFILE}__:
|
||||
|
||||
BIB?= bib
|
||||
EQN?= eqn
|
||||
GREMLIN?= grn
|
||||
GRIND?= vgrind -f
|
||||
INDXBIB?= indxbib
|
||||
PIC?= pic
|
||||
REFER?= refer
|
||||
ROFF?= groff -M/usr/share/tmac ${MACROS} ${PAGES}
|
||||
SOELIM?= soelim
|
||||
TBL?= tbl
|
||||
|
||||
.PATH: ${.CURDIR}
|
||||
|
||||
.if !target(all)
|
||||
.MAIN: all
|
||||
all: paper.ps
|
||||
.endif
|
||||
|
||||
.if !target(paper.ps)
|
||||
paper.ps: ${SRCS}
|
||||
${ROFF} ${SRCS} > ${.TARGET}
|
||||
.endif
|
||||
|
||||
.if !target(print)
|
||||
print: paper.ps
|
||||
lpr -P${PRINTER} paper.ps
|
||||
.endif
|
||||
|
||||
.if !target(manpages)
|
||||
manpages:
|
||||
.endif
|
||||
|
||||
.if !target(obj)
|
||||
obj:
|
||||
.endif
|
||||
|
||||
clean cleandir:
|
||||
rm -f paper.* [eE]rrs mklog ${CLEANFILES}
|
||||
|
||||
.if ${MK_DOC} == "no"
|
||||
install:
|
||||
.else
|
||||
FILES?= ${SRCS}
|
||||
install:
|
||||
${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 444 \
|
||||
Makefile ${FILES} ${EXTRA} ${DESTDIR}${BINDIR}/${DIR}
|
||||
.endif
|
||||
|
||||
spell: ${SRCS}
|
||||
spell ${SRCS} | sort | comm -23 - spell.ok > paper.spell
|
||||
|
||||
BINDIR?= /usr/share/doc
|
||||
BINGRP?= bin
|
||||
BINOWN?= bin
|
||||
BINMODE?= 444
|
||||
|
||||
.include <own.mk>
|
||||
.endif
|
196
20150418/mk/dpadd.mk
Normal file
196
20150418/mk/dpadd.mk
Normal file
@ -0,0 +1,196 @@
|
||||
# $Id: dpadd.mk,v 1.19 2014/04/05 22:56:54 sjg Exp $
|
||||
#
|
||||
# @(#) Copyright (c) 2004, 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
|
||||
#
|
||||
|
||||
.if !target(__${.PARSEFILE}__)
|
||||
__${.PARSEFILE}__:
|
||||
|
||||
# sometimes we play games with .CURDIR etc
|
||||
# _* hold the original values of .*
|
||||
_OBJDIR?= ${.OBJDIR}
|
||||
_CURDIR?= ${.CURDIR}
|
||||
|
||||
# DPLIBS helps us ensure we keep DPADD and LDADD in sync
|
||||
DPLIBS+= ${DPLIBS_LAST}
|
||||
DPADD+= ${DPLIBS}
|
||||
.for __lib in ${DPLIBS:T:R}
|
||||
LDADD+= ${LDADD_${__lib}:U${__lib:T:R:S/lib/-l/:C/\.so.*//}}
|
||||
.endfor
|
||||
|
||||
# DPADD can contain things other than libs
|
||||
__dpadd_libs = ${DPADD:M*/lib*}
|
||||
|
||||
# some libs have dependencies...
|
||||
# DPLIBS_* allows bsd.libnames.mk to flag libs which must be included
|
||||
# in DPADD for a given library.
|
||||
.for __lib in ${__dpadd_libs:@d@${DPLIBS_${d:T:R}}@}
|
||||
.if "${DPADD:M${__lib}}" == ""
|
||||
DPADD+= ${__lib}
|
||||
LDADD+= ${LDADD_${__lib}:U${__lib:T:R:S/lib/-l/:C/\.so.*//}}
|
||||
.endif
|
||||
.endfor
|
||||
# Last of all... for libc and libgcc
|
||||
DPADD+= ${DPADD_LAST}
|
||||
|
||||
# Convert DPADD into -I and -L options and add them to CPPFLAGS and LDADD
|
||||
# For the -I's convert the path to a relative one. For separate objdirs
|
||||
# the DPADD paths will be to the obj tree so we need to subst anyway.
|
||||
|
||||
# If USE_PROFILE is yes, then check for profiled versions of libs
|
||||
# and use them.
|
||||
|
||||
USE_PROFILE?=no
|
||||
.if defined(LIBDL) && exists(${LIBDL})
|
||||
.if defined(PROG) && (make(${PROG}_p) || ${USE_PROFILE} == yes) && \
|
||||
defined(LDFLAGS) && ${LDFLAGS:M-export-dynamic}
|
||||
# building profiled version of a prog that needs dlopen to work
|
||||
DPLIBS+= ${LIBDL}
|
||||
.endif
|
||||
.endif
|
||||
|
||||
.if defined(LIBDMALLOC) && exists(${LIBDMALLOC})
|
||||
.if defined(USE_DMALLOC) && ${USE_DMALLOC} != no
|
||||
.if !defined(NO_DMALLOC)
|
||||
CPPFLAGS+= -DUSE_DMALLOC
|
||||
.endif
|
||||
DPLIBS+= ${LIBDMALLOC}
|
||||
.endif
|
||||
.endif
|
||||
|
||||
# Order -L's to search ours first.
|
||||
# Avoids picking up old versions already installed.
|
||||
__dpadd_libdirs := ${__dpadd_libs:R:H:S/^/-L/g:O:u:N-L}
|
||||
LDADD += ${__dpadd_libdirs:M-L${OBJTOP}/*}
|
||||
LDADD += ${__dpadd_libdirs:N-L${OBJTOP}/*}
|
||||
|
||||
.if ${.CURDIR} == ${SRCTOP}
|
||||
RELDIR=.
|
||||
RELTOP=.
|
||||
.else
|
||||
RELDIR?= ${.CURDIR:S,${SRCTOP}/,,}
|
||||
.if ${RELDIR} == ${.CURDIR}
|
||||
RELDIR?= ${.OBJDIR:S,${OBJTOP}/,,}
|
||||
.endif
|
||||
RELTOP?= ${RELDIR:C,[^/]+,..,g}
|
||||
.endif
|
||||
RELOBJTOP?= ${OBJTOP}
|
||||
RELSRCTOP?= ${SRCTOP}
|
||||
|
||||
.if !make(dpadd)
|
||||
.ifdef LIB
|
||||
# Each lib is its own src_lib, we want to include it in SRC_LIBS
|
||||
# so that the correct INCLUDES_* will be picked up automatically.
|
||||
SRC_LIBS+= ${_OBJDIR}/lib${LIB}.a
|
||||
.endif
|
||||
.endif
|
||||
|
||||
#
|
||||
# This little bit of magic, assumes that SRC_libfoo will be
|
||||
# set if it cannot be correctly derrived from ${LIBFOO}
|
||||
# Note that SRC_libfoo and INCLUDES_libfoo should be named for the
|
||||
# actual library name not the variable name that might refer to it.
|
||||
# 99% of the time the two are the same, but the DPADD logic
|
||||
# only has the library name available, so stick to that.
|
||||
#
|
||||
|
||||
SRC_LIBS?=
|
||||
__dpadd_libs += ${SRC_LIBS}
|
||||
DPMAGIC_LIBS += ${__dpadd_libs} \
|
||||
${__dpadd_libs:@d@${DPMAGIC_LIBS_${d:T:R}}@}
|
||||
|
||||
.for __lib in ${DPMAGIC_LIBS:O:u}
|
||||
#
|
||||
# if SRC_libfoo is not set, then we assume that the srcdir corresponding
|
||||
# to where we found the library is correct.
|
||||
#
|
||||
SRC_${__lib:T:R} ?= ${__lib:H:S,${OBJTOP},${RELSRCTOP},}
|
||||
#
|
||||
# This is a no-brainer but just to be complete...
|
||||
#
|
||||
OBJ_${__lib:T:R} ?= ${__lib:H:S,${OBJTOP},${RELOBJTOP},}
|
||||
#
|
||||
# If INCLUDES_libfoo is not set, then we'll use ${SRC_libfoo}/h if it exists,
|
||||
# else just ${SRC_libfoo}.
|
||||
#
|
||||
INCLUDES_${__lib:T:R}?= -I${exists(${SRC_${__lib:T:R}}/h):?${SRC_${__lib:T:R}}/h:${SRC_${__lib:T:R}}}
|
||||
|
||||
.endfor
|
||||
|
||||
# Now for the bits we actually need
|
||||
__dpadd_incs=
|
||||
.for __lib in ${__dpadd_libs:u}
|
||||
.if (make(${PROG}_p) || defined(NEED_GPROF)) && exists(${__lib:R}_p.a)
|
||||
__ldadd=-l${__lib:T:R:S,lib,,}
|
||||
LDADD := ${LDADD:S,^${__ldadd}$,${__ldadd}_p,g}
|
||||
.endif
|
||||
|
||||
#
|
||||
# Some libs generate headers, so we potentially need both
|
||||
# the src dir and the obj dir.
|
||||
# If ${INCLUDES_libfoo} contains a word ending in /h, we assume that either
|
||||
# 1. it does not generate headers or
|
||||
# 2. INCLUDES_libfoo will have been set correctly
|
||||
# XXX it gets ugly avoiding duplicates...
|
||||
# use :? to ensure .for does not prevent correct evaluation
|
||||
#
|
||||
# We take care of duplicate suppression later.
|
||||
__dpadd_incs += ${"${INCLUDES_${__lib:T:R}:M*/h}":? :-I${OBJ_${__lib:T:R}}}
|
||||
__dpadd_incs += ${INCLUDES_${__lib:T:R}}
|
||||
.endfor
|
||||
|
||||
#
|
||||
# eliminate any duplicates - but don't mess with the order
|
||||
# force evaluation now - to avoid giving make a headache
|
||||
#
|
||||
.for t in CFLAGS CXXFLAGS
|
||||
# avoid duplicates
|
||||
__$t_incs:=${$t:M-I*:O:u}
|
||||
.for i in ${__dpadd_incs}
|
||||
.if "${__$t_incs:M$i}" == ""
|
||||
$t+= $i
|
||||
__$t_incs+= $i
|
||||
.endif
|
||||
.endfor
|
||||
.endfor
|
||||
|
||||
# This target is used to gather a list of
|
||||
# dir: ${DPADD}
|
||||
# entries
|
||||
.if make(*dpadd*)
|
||||
# allow overrides
|
||||
.-include "dpadd++.mk"
|
||||
|
||||
.if !target(dpadd)
|
||||
dpadd: .NOTMAIN
|
||||
.if defined(DPADD) && ${DPADD} != ""
|
||||
@echo "${RELDIR}: ${DPADD:S,${OBJTOP}/,,}"
|
||||
.endif
|
||||
.endif
|
||||
.endif
|
||||
|
||||
.ifdef SRC_PATHADD
|
||||
# We don't want to assume that we need to .PATH every element of
|
||||
# SRC_LIBS, but the Makefile cannot do
|
||||
# .PATH: ${SRC_libfoo}
|
||||
# since the value of SRC_libfoo must be available at the time .PATH:
|
||||
# is read - and we only just worked it out.
|
||||
# Further, they can't wait until after include of {lib,prog}.mk as
|
||||
# the .PATH is needed before then.
|
||||
# So we let the Makefile do
|
||||
# SRC_PATHADD+= ${SRC_libfoo}
|
||||
# and we defer the .PATH: until now so that SRC_libfoo will be available.
|
||||
.PATH: ${SRC_PATHADD}
|
||||
.endif
|
||||
|
||||
.endif
|
14
20150418/mk/final.mk
Normal file
14
20150418/mk/final.mk
Normal file
@ -0,0 +1,14 @@
|
||||
# $Id: final.mk,v 1.5 2011/03/11 05:22:38 sjg Exp $
|
||||
|
||||
.if !target(__${.PARSEFILE}__)
|
||||
__${.PARSEFILE}__:
|
||||
|
||||
# provide a hook for folk who want to do scary stuff
|
||||
.-include "${.CURDIR}/../Makefile-final.inc"
|
||||
|
||||
.if !empty(STAGE)
|
||||
.-include <stage.mk>
|
||||
.endif
|
||||
|
||||
.-include <local.final.mk>
|
||||
.endif
|
348
20150418/mk/gendirdeps.mk
Normal file
348
20150418/mk/gendirdeps.mk
Normal file
@ -0,0 +1,348 @@
|
||||
# $Id: gendirdeps.mk,v 1.26 2014/09/05 04:40:52 sjg Exp $
|
||||
|
||||
# Copyright (c) 2010-2013, Juniper Networks, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
|
||||
# OWNER 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.
|
||||
|
||||
#
|
||||
# This makefile [re]generates ${.MAKE.DEPENDFILE}
|
||||
#
|
||||
|
||||
.include <install-new.mk>
|
||||
|
||||
# Assumptions:
|
||||
# RELDIR is the relative path from ${SRCTOP} to ${_CURDIR}
|
||||
# (SRCTOP is ${SB}/src)
|
||||
# _CURDIR is the absolute version of ${.CURDIR}
|
||||
# _OBJDIR is the absolute version of ${.OBJDIR}
|
||||
# _objroot is realpath of ${_OBJTOP} without ${MACHINE}
|
||||
# this may be different from _OBJROOT if $SB/obj is a
|
||||
# symlink to another filesystem.
|
||||
# _objroot must be a prefix match for _objtop
|
||||
|
||||
.MAIN: all
|
||||
|
||||
# keep this simple
|
||||
.MAKE.MODE = compat
|
||||
|
||||
all:
|
||||
|
||||
_CURDIR ?= ${.CURDIR}
|
||||
_OBJDIR ?= ${.OBJDIR}
|
||||
_OBJTOP ?= ${OBJTOP}
|
||||
_OBJROOT ?= ${OBJROOT:U${_OBJTOP}}
|
||||
.if ${_OBJROOT:M*/}
|
||||
_slash=/
|
||||
.else
|
||||
_slash=
|
||||
.endif
|
||||
_objroot ?= ${_OBJROOT:tA}${_slash}
|
||||
|
||||
_this = ${.PARSEDIR}/${.PARSEFILE}
|
||||
|
||||
# remember what to make
|
||||
_DEPENDFILE := ${_CURDIR}/${.MAKE.DEPENDFILE:T}
|
||||
|
||||
# We do _not_ want to read our own output!
|
||||
.MAKE.DEPENDFILE = /dev/null
|
||||
|
||||
# caller should have set this
|
||||
META_FILES ?= ${.MAKE.META.FILES}
|
||||
|
||||
.if !empty(META_FILES)
|
||||
|
||||
.if ${.MAKE.LEVEL} > 0 && !empty(GENDIRDEPS_FILTER)
|
||||
# so we can compare below
|
||||
.-include <${_DEPENDFILE}>
|
||||
# yes, I mean :U with no value
|
||||
_DIRDEPS := ${DIRDEPS:U:O:u}
|
||||
.endif
|
||||
|
||||
META_FILES := ${META_FILES:T:O:u}
|
||||
.export META_FILES
|
||||
|
||||
# pickup customizations
|
||||
.-include "local.gendirdeps.mk"
|
||||
|
||||
# these are actually prefixes that we'll skip
|
||||
# they should all be absolute paths
|
||||
SKIP_GENDIRDEPS ?=
|
||||
.if !empty(SKIP_GENDIRDEPS)
|
||||
_skip_gendirdeps = egrep -v '^(${SKIP_GENDIRDEPS:O:u:ts|})' |
|
||||
.else
|
||||
_skip_gendirdeps =
|
||||
.endif
|
||||
|
||||
# Below we will turn _{VAR} into ${VAR} which keeps this simple
|
||||
# GENDIRDEPS_FILTER_DIR_VARS is a list of dirs to be substiuted for.
|
||||
# GENDIRDEPS_FILTER_VARS is more general.
|
||||
# In each case order matters.
|
||||
.if !empty(GENDIRDEPS_FILTER_DIR_VARS)
|
||||
GENDIRDEPS_FILTER += ${GENDIRDEPS_FILTER_DIR_VARS:@v@S,${$v},_{${v}},@}
|
||||
.endif
|
||||
.if !empty(GENDIRDEPS_FILTER_VARS)
|
||||
GENDIRDEPS_FILTER += ${GENDIRDEPS_FILTER_VARS:@v@S,/${$v}/,/_{${v}}/,@:NS,//,*:u}
|
||||
.endif
|
||||
|
||||
# this (*should* be set in meta.sys.mk)
|
||||
# is the script that extracts what we want.
|
||||
META2DEPS ?= ${.PARSEDIR}/meta2deps.sh
|
||||
META2DEPS := ${META2DEPS}
|
||||
|
||||
.if ${DEBUG_GENDIRDEPS:Uno:@x@${RELDIR:M$x}@} != "" && ${DEBUG_GENDIRDEPS:Uno:Mmeta2d*} != ""
|
||||
_time = time
|
||||
_sh_x = sh -x
|
||||
_py_d = -ddd
|
||||
.else
|
||||
_time =
|
||||
_sh_x =
|
||||
_py_d =
|
||||
.endif
|
||||
|
||||
.if ${META2DEPS:E} == "py"
|
||||
# we can afford to do this all the time.
|
||||
DPDEPS ?= no
|
||||
META2DEPS_CMD = ${_time} ${PYTHON} ${META2DEPS} ${_py_d}
|
||||
.if ${DPDEPS:tl} != "no"
|
||||
META2DEPS_CMD += -D ${DPDEPS}
|
||||
.endif
|
||||
META2DEPS_FILTER = sed 's,^src:,${SRCTOP}/,;s,^\([^/]\),${OBJTOP}/\1,' |
|
||||
.elif ${META2DEPS:E} == "sh"
|
||||
META2DEPS_CMD = ${_time} ${_sh_x} ${META2DEPS} OBJTOP=${_OBJTOP}
|
||||
.else
|
||||
META2DEPS_CMD ?= ${META2DEPS}
|
||||
.endif
|
||||
|
||||
.if ${TARGET_OBJ_SPEC:U${MACHINE}} != ${MACHINE}
|
||||
META2DEPS_CMD += -T ${TARGET_OBJ_SPEC}
|
||||
.endif
|
||||
META2DEPS_CMD += \
|
||||
-R ${RELDIR} -H ${HOST_TARGET} \
|
||||
${M2D_OBJROOTS:O:u:@o@-O $o@}
|
||||
|
||||
|
||||
M2D_OBJROOTS += ${OBJTOP} ${_OBJROOT} ${_objroot}
|
||||
.if defined(SB_OBJROOT)
|
||||
M2D_OBJROOTS += ${SB_OBJROOT}
|
||||
.endif
|
||||
.if ${.MAKE.DEPENDFILE_PREFERENCE:U${.MAKE.DEPENDFILE}:M*.${MACHINE}} == ""
|
||||
# meta2deps.py only groks objroot
|
||||
# so we need to give it what it expects
|
||||
# and tell it not to add machine qualifiers
|
||||
META2DEPS_ARGS += MACHINE=none
|
||||
.endif
|
||||
.if defined(SB_BACKING_SB)
|
||||
META2DEPS_CMD += -S ${SB_BACKING_SB}/src
|
||||
M2D_OBJROOTS += ${SB_BACKING_SB}/${SB_OBJPREFIX}
|
||||
.endif
|
||||
|
||||
# we are only interested in the dirs
|
||||
# sepecifically those we read something from.
|
||||
# we canonicalize them to keep things simple
|
||||
# if we are using a split-fs sandbox, it gets a little messier.
|
||||
_objtop := ${_OBJTOP:tA}
|
||||
dir_list != cd ${_OBJDIR} && \
|
||||
${META2DEPS_CMD} MACHINE=${MACHINE} \
|
||||
SRCTOP=${SRCTOP} RELDIR=${RELDIR} CURDIR=${_CURDIR} \
|
||||
${META2DEPS_ARGS} \
|
||||
${META_FILES:O:u} | ${META2DEPS_FILTER} ${_skip_gendirdeps} \
|
||||
sed 's,//*$$,,;s,\.${HOST_TARGET}$$,.host,'
|
||||
|
||||
.if ${dir_list:M*ERROR\:*} != ""
|
||||
.warning ${dir_list:tW:C,.*(ERROR),\1,}
|
||||
.warning Skipping ${_DEPENDFILE:S,${SRCTOP}/,,}
|
||||
# we are not going to update anything
|
||||
.else
|
||||
dpadd_dir_list=
|
||||
.if !empty(DPADD)
|
||||
_nonlibs := ${DPADD:T:Nlib*:N*include}
|
||||
.if !empty(_nonlibs)
|
||||
ddep_list =
|
||||
.for f in ${_nonlibs:@x@${DPADD:M*/$x}@}
|
||||
.if exists($f.dirdep)
|
||||
ddep_list += $f.dirdep
|
||||
.elif exists(${f:H}.dirdep)
|
||||
ddep_list += ${f:H}.dirdep
|
||||
.else
|
||||
dir_list += ${f:H:tA}
|
||||
dpadd_dir_list += ${f:H:tA}
|
||||
.endif
|
||||
.endfor
|
||||
.if !empty(ddep_list)
|
||||
ddeps != cat ${ddep_list:O:u} | ${META2DEPS_FILTER} ${_skip_gendirdeps} \
|
||||
sed 's,//*$$,,;s,\.${HOST_TARGET}$$,.host,;s,\.${MACHINE}$$,,'
|
||||
|
||||
.if ${DEBUG_GENDIRDEPS:Uno:@x@${RELDIR:M$x}@} != ""
|
||||
.info ${RELDIR}: raw_dir_list='${dir_list}'
|
||||
.info ${RELDIR}: ddeps='${ddeps}'
|
||||
.endif
|
||||
dir_list += ${ddeps}
|
||||
.endif
|
||||
.endif
|
||||
.endif
|
||||
|
||||
# DIRDEPS represent things that had to have been built first
|
||||
# so they should all be undir OBJTOP.
|
||||
# Note that ${_OBJTOP}/bsd/include/machine will get reported
|
||||
# to us as $SRCTOP/bsd/sys/$MACHINE_ARCH/include meaning we
|
||||
# will want to visit bsd/include
|
||||
# so we add
|
||||
# ${"${dir_list:M*bsd/sys/${MACHINE_ARCH}/include}":?bsd/include:}
|
||||
# to GENDIRDEPS_DIR_LIST_XTRAS
|
||||
_objtops = ${OBJTOP} ${_OBJTOP} ${_objtop}
|
||||
_objtops := ${_objtops:O:u}
|
||||
dirdep_list = \
|
||||
${_objtops:@o@${dir_list:M$o*/*:C,$o[^/]*/,,}@} \
|
||||
${GENDIRDEPS_DIR_LIST_XTRAS}
|
||||
|
||||
# sort longest first
|
||||
M2D_OBJROOTS := ${M2D_OBJROOTS:O:u:[-1..1]}
|
||||
|
||||
# anything we use from an object dir other than ours
|
||||
# needs to be qualified with its .<machine> suffix
|
||||
# (we used the pseudo machine "host" for the HOST_TARGET).
|
||||
skip_ql= ${SRCTOP}* ${_objtops:@o@$o*@}
|
||||
.for o in ${M2D_OBJROOTS:${skip_ql:${M_ListToSkip}}}
|
||||
# we need := so only skip_ql to this point applies
|
||||
ql.$o := ${dir_list:${skip_ql:${M_ListToSkip}}:M$o*/*/*:C,$o([^/]+)/(.*),\2.\1,:S,.${HOST_TARGET},.host,}
|
||||
qualdir_list += ${ql.$o}
|
||||
.if ${DEBUG_GENDIRDEPS:Uno:@x@${RELDIR:M$x}@} != ""
|
||||
.info ${RELDIR}: o=$o ${ql.$o qualdir_list:L:@v@$v=${$v}@}
|
||||
.endif
|
||||
skip_ql+= $o*
|
||||
.endfor
|
||||
|
||||
dirdep_list := ${dirdep_list:O:u}
|
||||
qualdir_list := ${qualdir_list:N*.${MACHINE}:O:u}
|
||||
|
||||
DIRDEPS = \
|
||||
${dirdep_list:N${RELDIR}:N${RELDIR}/*} \
|
||||
${qualdir_list:N${RELDIR}.*:N${RELDIR}/*}
|
||||
|
||||
# We only consider things below $RELDIR/ if they have a makefile.
|
||||
# This is the same test that _DIRDEP_USE applies.
|
||||
# We have do a double test with dirdep_list as it _may_ contain
|
||||
# qualified dirs - if we got anything from a stage dir.
|
||||
# qualdir_list we know are all qualified.
|
||||
# It would be nice do peform this check for all of DIRDEPS,
|
||||
# but we cannot assume that all of the tree is present,
|
||||
# in fact we can only assume that RELDIR is.
|
||||
DIRDEPS += \
|
||||
${dirdep_list:M${RELDIR}/*:@d@${.MAKE.MAKEFILE_PREFERENCE:@m@${exists(${SRCTOP}/$d/$m):?$d:${exists(${SRCTOP}/${d:R}/$m):?$d:}}@}@} \
|
||||
${qualdir_list:M${RELDIR}/*:@d@${.MAKE.MAKEFILE_PREFERENCE:@m@${exists(${SRCTOP}/${d:R}/$m):?$d:}@}@}
|
||||
|
||||
DIRDEPS := ${DIRDEPS:${GENDIRDEPS_FILTER:UNno:ts:}:C,//+,/,g:O:u}
|
||||
|
||||
.if ${DEBUG_GENDIRDEPS:Uno:@x@${RELDIR:M$x}@} != ""
|
||||
.info ${RELDIR}: M2D_OBJROOTS=${M2D_OBJROOTS}
|
||||
.info ${RELDIR}: dir_list='${dir_list}'
|
||||
.info ${RELDIR}: dpadd_dir_list='${dpadd_dir_list}'
|
||||
.info ${RELDIR}: dirdep_list='${dirdep_list}'
|
||||
.info ${RELDIR}: qualdir_list='${qualdir_list}'
|
||||
.info ${RELDIR}: SKIP_GENDIRDEPS='${SKIP_GENDIRDEPS}'
|
||||
.info ${RELDIR}: GENDIRDEPS_FILTER='${GENDIRDEPS_FILTER}'
|
||||
.info ${RELDIR}: FORCE_DPADD='${DPADD}'
|
||||
.info ${RELDIR}: DIRDEPS='${DIRDEPS}'
|
||||
.endif
|
||||
|
||||
# SRC_DIRDEPS is for checkout logic
|
||||
src_dirdep_list = \
|
||||
${dir_list:M${SRCTOP}/*:S,${SRCTOP}/,,}
|
||||
|
||||
SRC_DIRDEPS = \
|
||||
${src_dirdep_list:N${RELDIR}:N${RELDIR}/*:C,(/h)/.*,,}
|
||||
|
||||
SRC_DIRDEPS := ${SRC_DIRDEPS:${GENDIRDEPS_SRC_FILTER:UN/*:ts:}:C,//+,/,g:O:u}
|
||||
|
||||
# if you want to capture SRC_DIRDEPS in .MAKE.DEPENDFILE put
|
||||
# SRC_DIRDEPS_FILE = ${_DEPENDFILE}
|
||||
# in local.gendirdeps.mk
|
||||
.if ${SRC_DIRDEPS_FILE:Uno:tl} != "no"
|
||||
ECHO_SRC_DIRDEPS = echo 'SRC_DIRDEPS = \'; echo '${SRC_DIRDEPS:@d@ $d \\${.newline}@}'; echo;
|
||||
|
||||
.if ${SRC_DIRDEPS_FILE:T} == ${_DEPENDFILE:T}
|
||||
_include_src_dirdeps = ${ECHO_SRC_DIRDEPS}
|
||||
.else
|
||||
all: ${SRC_DIRDEPS_FILE}
|
||||
.if !target(${SRC_DIRDEPS_FILE})
|
||||
${SRC_DIRDEPS_FILE}: ${META_FILES} ${_this} ${META2DEPS}
|
||||
@(${ECHO_SRC_DIRDEPS}) > $@
|
||||
.endif
|
||||
.endif
|
||||
.endif
|
||||
_include_src_dirdeps ?=
|
||||
|
||||
all: ${_DEPENDFILE}
|
||||
|
||||
# if this is going to exist it would be there by now
|
||||
.if !exists(.depend)
|
||||
CAT_DEPEND = /dev/null
|
||||
.endif
|
||||
CAT_DEPEND ?= .depend
|
||||
|
||||
.if !empty(_DIRDEPS) && ${DIRDEPS} != ${_DIRDEPS}
|
||||
# we may have changed a filter
|
||||
.PHONY: ${_DEPENDFILE}
|
||||
.endif
|
||||
|
||||
# 'cat .depend' should suffice, but if we are mixing build modes
|
||||
# .depend may contain things we don't want.
|
||||
# The sed command at the end of the stream, allows for the filters
|
||||
# to output _{VAR} tokens which we will turn into proper ${VAR} references.
|
||||
${_DEPENDFILE}: ${CAT_DEPEND:M.depend} ${META_FILES:O:u:@m@${exists($m):?$m:}@} ${_this} ${META2DEPS}
|
||||
@(echo '# Autogenerated - do NOT edit!'; echo; \
|
||||
echo 'DEP_RELDIR := $${_PARSEDIR:S,$${SRCTOP}/,,}'; echo; \
|
||||
echo 'DIRDEPS = \'; \
|
||||
echo '${DIRDEPS:@d@ $d \\${.newline}@}'; echo; \
|
||||
${_include_src_dirdeps} \
|
||||
echo '.include <dirdeps.mk>'; \
|
||||
echo; \
|
||||
echo '.if $${DEP_RELDIR} == $${_DEP_RELDIR}'; \
|
||||
echo '# local dependencies - needed for -jN in clean tree'; \
|
||||
[ -s ${CAT_DEPEND} ] && { grep : ${CAT_DEPEND} | grep -v '[/\\]'; }; \
|
||||
echo '.endif' ) | sed 's,_\([{(]\),$$\1,g' > $@.new${.MAKE.PID}
|
||||
@${InstallNew}; InstallNew -s $@.new${.MAKE.PID}
|
||||
|
||||
.endif # meta2deps failed
|
||||
.elif !empty(SUBDIR)
|
||||
|
||||
DIRDEPS := ${SUBDIR:S,^,${RELDIR}/,:O:u}
|
||||
|
||||
all: ${_DEPENDFILE}
|
||||
|
||||
${_DEPENDFILE}: ${MAKEFILE} ${_this}
|
||||
@(echo '# Autogenerated - do NOT edit!'; echo; \
|
||||
echo 'DEP_RELDIR := $${_PARSEDIR:S,$${SRCTOP}/,,}'; echo; \
|
||||
echo 'DIRDEPS = \'; \
|
||||
echo '${DIRDEPS:@d@ $d \\${.newline}@}'; echo; \
|
||||
echo '.include <dirdeps.mk>'; \
|
||||
echo ) | sed 's,_\([{(]\),$$\1,g' > $@.new
|
||||
@${InstallNew}; InstallNew $@.new
|
||||
|
||||
.else
|
||||
|
||||
# nothing to do
|
||||
all ${_DEPENDFILE}:
|
||||
|
||||
.endif
|
||||
${_DEPENDFILE}: .PRECIOUS
|
35
20150418/mk/host-target.mk
Normal file
35
20150418/mk/host-target.mk
Normal file
@ -0,0 +1,35 @@
|
||||
# RCSid:
|
||||
# $Id: host-target.mk,v 1.7 2014/05/16 17:54:52 sjg Exp $
|
||||
|
||||
# Host platform information; may be overridden
|
||||
.if !defined(_HOST_OSNAME)
|
||||
_HOST_OSNAME != uname -s
|
||||
.export _HOST_OSNAME
|
||||
.endif
|
||||
.if !defined(_HOST_OSREL)
|
||||
_HOST_OSREL != uname -r
|
||||
.export _HOST_OSREL
|
||||
.endif
|
||||
.if !defined(_HOST_ARCH)
|
||||
_HOST_ARCH != uname -p 2>/dev/null || uname -m
|
||||
# uname -p may produce garbage on linux
|
||||
.if ${_HOST_ARCH:[\#]} > 1
|
||||
_HOST_ARCH != uname -m
|
||||
.endif
|
||||
.export _HOST_ARCH
|
||||
.endif
|
||||
.if !defined(HOST_MACHINE)
|
||||
HOST_MACHINE != uname -m
|
||||
.export HOST_MACHINE
|
||||
.endif
|
||||
|
||||
HOST_OSMAJOR := ${_HOST_OSREL:C/[^0-9].*//}
|
||||
HOST_OSTYPE := ${_HOST_OSNAME}-${_HOST_OSREL:C/\([^\)]*\)//}-${_HOST_ARCH}
|
||||
HOST_OS := ${_HOST_OSNAME}
|
||||
host_os := ${_HOST_OSNAME:tl}
|
||||
HOST_TARGET := ${host_os}${HOST_OSMAJOR}-${_HOST_ARCH}
|
||||
|
||||
# tr is insanely non-portable, accommodate the lowest common denominator
|
||||
TR ?= tr
|
||||
toLower = ${TR} 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'
|
||||
toUpper = ${TR} 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
29
20150418/mk/host.libnames.mk
Normal file
29
20150418/mk/host.libnames.mk
Normal file
@ -0,0 +1,29 @@
|
||||
# $Id: host.libnames.mk,v 1.4 2010/01/11 23:01:31 sjg Exp $
|
||||
#
|
||||
# @(#) Copyright (c) 2007-2009, 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
|
||||
#
|
||||
|
||||
|
||||
DLIBEXT ?= .a
|
||||
DSHLIBEXT ?= ${DLIBEXT}
|
||||
HOST_LIBEXT ?= ${DSHLIBEXT}
|
||||
HOST_LIBDIRS ?= /usr/lib /lib
|
||||
HOST_LIBS ?=
|
||||
|
||||
.for x in ${HOST_LIBS:O:u}
|
||||
.for d in ${HOST_LIBDIRS}
|
||||
.if exists($d/lib$x${HOST_LIBEXT})
|
||||
LIB${x:tu} ?= $d/lib$x${HOST_LIBEXT}
|
||||
.endif
|
||||
.endfor
|
||||
.endfor
|
35
20150418/mk/inc.mk
Normal file
35
20150418/mk/inc.mk
Normal file
@ -0,0 +1,35 @@
|
||||
# $Id: inc.mk,v 1.3 2011/03/11 05:23:05 sjg Exp $
|
||||
#
|
||||
# @(#) Copyright (c) 2008, 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
|
||||
#
|
||||
|
||||
.include <init.mk>
|
||||
|
||||
includes: ${INCS}
|
||||
|
||||
.if !empty(LIBOWN)
|
||||
INC_INSTALL_OWN ?= -o ${LIBOWN} -g ${LIBGRP}
|
||||
.endif
|
||||
INCMODE ?= 444
|
||||
INC_COPY ?= -C
|
||||
INCSDIR ?= ${INCDIR}
|
||||
|
||||
realinstall: incinstall
|
||||
.if !target(incinstall)
|
||||
incinstall:
|
||||
.if !empty(INCS)
|
||||
[ -d ${DESTDIR}${INCSDIR} ] || \
|
||||
${INSTALL} -d ${INC_INSTALL_OWN} -m 775 ${DESTDIR}${INCSDIR}
|
||||
${INSTALL} ${INC_COPY} ${INC_INSTALL_OWN} -m ${INCMODE} ${INCS} ${DESTDIR}${INCSDIR}
|
||||
.endif
|
||||
.endif
|
50
20150418/mk/init.mk
Normal file
50
20150418/mk/init.mk
Normal file
@ -0,0 +1,50 @@
|
||||
# $Id: init.mk,v 1.9 2013/07/18 05:46:24 sjg Exp $
|
||||
#
|
||||
# @(#) Copyright (c) 2002, 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
|
||||
#
|
||||
|
||||
.if !target(__${.PARSEFILE}__)
|
||||
__${.PARSEFILE}__:
|
||||
|
||||
.if ${MAKE_VERSION:U0} > 20100408
|
||||
_this_mk_dir := ${.PARSEDIR:tA}
|
||||
.else
|
||||
_this_mk_dir := ${.PARSEDIR}
|
||||
.endif
|
||||
|
||||
.-include <local.init.mk>
|
||||
.-include "${.CURDIR:H}/Makefile.inc"
|
||||
.include <own.mk>
|
||||
|
||||
.MAIN: all
|
||||
|
||||
.if !empty(WARNINGS_SET) || !empty(WARNINGS_SET_${MACHINE_ARCH})
|
||||
.include <warnings.mk>
|
||||
.endif
|
||||
|
||||
COPTS += ${COPTS.${.IMPSRC:T}}
|
||||
CPPFLAGS += ${CPPFLAGS.${.IMPSRC:T}}
|
||||
CPUFLAGS += ${CPUFLAGS.${.IMPSRC:T}}
|
||||
|
||||
CC_PG?= -pg
|
||||
CXX_PG?= ${CC_PG}
|
||||
CC_PIC?= -DPIC
|
||||
CXX_PIC?= ${CC_PIC}
|
||||
PROFFLAGS?= -DGPROF -DPROF
|
||||
|
||||
.if ${.MAKE.LEVEL:U1} == 0 && ${BUILD_AT_LEVEL0:Uyes:tl} == "no"
|
||||
# this tells lib.mk and prog.mk to not actually build anything
|
||||
_SKIP_BUILD = not building at level 0
|
||||
.endif
|
||||
|
||||
.endif
|
185
20150418/mk/install-mk
Normal file
185
20150418/mk/install-mk
Normal file
@ -0,0 +1,185 @@
|
||||
:
|
||||
# NAME:
|
||||
# install-mk - install mk files
|
||||
#
|
||||
# SYNOPSIS:
|
||||
# install-mk [options] [var=val] [dest]
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# This tool installs mk files in a semi-intelligent manner into
|
||||
# "dest".
|
||||
#
|
||||
# Options:
|
||||
#
|
||||
# -n just say what we want to do, but don't touch anything.
|
||||
#
|
||||
# -f use -f when copying sys,mk.
|
||||
#
|
||||
# -v be verbose
|
||||
#
|
||||
# -q be quiet
|
||||
#
|
||||
# -m "mode"
|
||||
# Use "mode" for installed files (444).
|
||||
#
|
||||
# -o "owner"
|
||||
# Use "owner" for installed files.
|
||||
#
|
||||
# -g "group"
|
||||
# Use "group" for installed files.
|
||||
#
|
||||
# var=val
|
||||
# Set "var" to "val". See below.
|
||||
#
|
||||
# All our *.mk files are copied to "dest" with appropriate
|
||||
# ownership and permissions.
|
||||
#
|
||||
# By default if a sys.mk can be found in a standard location
|
||||
# (that bmake will find) then no sys.mk will be put in "dest".
|
||||
#
|
||||
# SKIP_SYS_MK:
|
||||
# If set, we will avoid installing our 'sys.mk'
|
||||
# This is probably a bad idea.
|
||||
#
|
||||
# SKIP_BSD_MK:
|
||||
# If set, we will skip making bsd.*.mk links to *.mk
|
||||
#
|
||||
# sys.mk:
|
||||
#
|
||||
# By default (and provided we are not installing to the system
|
||||
# mk dir - '/usr/share/mk') we install our own 'sys.mk' which
|
||||
# includes a sys specific file, or a generic one.
|
||||
#
|
||||
#
|
||||
# AUTHOR:
|
||||
# Simon J. Gerraty <sjg@crufty.net>
|
||||
|
||||
# RCSid:
|
||||
# $Id: install-mk,v 1.109 2015/04/16 16:59:00 sjg Exp $
|
||||
#
|
||||
# @(#) Copyright (c) 1994 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
|
||||
#
|
||||
|
||||
MK_VERSION=20150411
|
||||
OWNER=
|
||||
GROUP=
|
||||
MODE=444
|
||||
BINMODE=555
|
||||
ECHO=:
|
||||
SKIP=
|
||||
cp_f=-f
|
||||
|
||||
while :
|
||||
do
|
||||
case "$1" in
|
||||
*=*) eval "$1"; shift;;
|
||||
+f) cp_f=; shift;;
|
||||
-f) cp_f=-f; shift;;
|
||||
-m) MODE=$2; shift 2;;
|
||||
-o) OWNER=$2; shift 2;;
|
||||
-g) GROUP=$2; shift 2;;
|
||||
-v) ECHO=echo; shift;;
|
||||
-q) ECHO=:; shift;;
|
||||
-n) ECHO=echo SKIP=:; shift;;
|
||||
--) shift; break;;
|
||||
*) break;;
|
||||
esac
|
||||
done
|
||||
|
||||
case $# in
|
||||
0) echo "$0 [options] <destination> [<os>]"
|
||||
echo "eg."
|
||||
echo "$0 -o bin -g bin -m 444 /usr/local/share/mk"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
dest=$1
|
||||
os=${2:-`uname`}
|
||||
osrel=${3:-`uname -r`}
|
||||
|
||||
Do() {
|
||||
$ECHO "$@"
|
||||
$SKIP "$@"
|
||||
}
|
||||
|
||||
Error() {
|
||||
echo "ERROR: $@" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
Warning() {
|
||||
echo "WARNING: $@" >&2
|
||||
}
|
||||
|
||||
[ "$FORCE_SYS_MK" ] && Warning "ignoring: FORCE_{BSD,SYS}_MK (no longer supported)"
|
||||
|
||||
SYS_MK_DIR=${SYS_MK_DIR:-/usr/share/mk}
|
||||
SYS_MK=${SYS_MK:-$SYS_MK_DIR/sys.mk}
|
||||
|
||||
realpath() {
|
||||
[ -d $1 ] && cd $1 && 'pwd' && return
|
||||
echo $1
|
||||
}
|
||||
|
||||
if [ -s $SYS_MK -a -d $dest ]; then
|
||||
# if this is a BSD system we don't want to touch $SYS_MK
|
||||
dest=`realpath $dest`
|
||||
sys_mk_dir=`realpath $SYS_MK_DIR`
|
||||
if [ $dest = $sys_mk_dir ]; then
|
||||
case "$os" in
|
||||
*BSD*) SKIP_SYS_MK=:
|
||||
SKIP_BSD_MK=:
|
||||
;;
|
||||
*) # could be fake?
|
||||
if [ ! -d $dest/sys -a ! -s $dest/Generic.sys.mk ]; then
|
||||
SKIP_SYS_MK=: # play safe
|
||||
SKIP_BSD_MK=:
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
|
||||
[ -d $dest/sys ] || Do mkdir -p $dest/sys
|
||||
[ -d $dest/sys ] || Do mkdir $dest/sys || exit 1
|
||||
[ -z "$SKIP" ] && dest=`realpath $dest`
|
||||
|
||||
cd `dirname $0`
|
||||
mksrc=`'pwd'`
|
||||
if [ $mksrc = $dest ]; then
|
||||
SKIP_MKFILES=:
|
||||
else
|
||||
# we do not install the examples
|
||||
mk_files=`grep '^[a-z].*\.mk' FILES | egrep -v '(examples/|^sys\.mk|sys/)'`
|
||||
mk_scripts=`egrep '^[a-z].*\.(sh|py)' FILES | egrep -v '/'`
|
||||
sys_mk_files=`grep 'sys/.*\.mk' FILES`
|
||||
SKIP_MKFILES=
|
||||
[ -z "$SKIP_SYS_MK" ] && mk_files="sys.mk $mk_files"
|
||||
fi
|
||||
$SKIP_MKFILES Do cp $cp_f $mk_files $dest
|
||||
$SKIP_MKFILES Do cp $cp_f $sys_mk_files $dest/sys
|
||||
$SKIP_MKFILES Do cp $cp_f $mk_scripts $dest
|
||||
$SKIP cd $dest
|
||||
$SKIP_MKFILES Do chmod $MODE $mk_files $sys_mk_files
|
||||
$SKIP_MKFILES Do chmod $BINMODE $mk_scripts
|
||||
[ "$GROUP" ] && $SKIP_MKFILES Do chgrp $GROUP $mk_files $sys_mk_files
|
||||
[ "$OWNER" ] && $SKIP_MKFILES Do chown $OWNER $mk_files $sys_mk_files
|
||||
# if this is a BSD system the bsd.*.mk should exist and be used.
|
||||
if [ -z "$SKIP_BSD_MK" ]; then
|
||||
for f in dep doc init lib links man nls obj own prog subdir
|
||||
do
|
||||
b=bsd.$f.mk
|
||||
[ -s $b ] || Do ln -s $f.mk $b
|
||||
done
|
||||
fi
|
||||
exit 0
|
53
20150418/mk/install-new.mk
Normal file
53
20150418/mk/install-new.mk
Normal file
@ -0,0 +1,53 @@
|
||||
# $Id: install-new.mk,v 1.3 2012/03/24 18:25:49 sjg Exp $
|
||||
#
|
||||
# @(#) Copyright (c) 2009, 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
|
||||
#
|
||||
|
||||
.if !defined(InstallNew)
|
||||
|
||||
# copy if src and target are different making a backup if desired
|
||||
CmpCp= CmpCp() { \
|
||||
src=$$1 target=$$2 _bak=$$3; \
|
||||
if ! test -s $$target || ! cmp -s $$target $$src; then \
|
||||
trap "" 1 2 3 15; \
|
||||
if test -s $$target; then \
|
||||
if test "x$$_bak" != x; then \
|
||||
rm -f $$target$$_bak; \
|
||||
mv $$target $$target$$_bak; \
|
||||
else \
|
||||
rm -f $$target; \
|
||||
fi; \
|
||||
fi; \
|
||||
cp $$src $$target; \
|
||||
fi; }
|
||||
|
||||
# If the .new file is different, we want it.
|
||||
# Note: this function will work as is for *.new$RANDOM"
|
||||
InstallNew= ${CmpCp}; InstallNew() { \
|
||||
_t=-e; _bak=; \
|
||||
while :; do \
|
||||
case "$$1" in \
|
||||
-?) _t=$$1; shift;; \
|
||||
--bak) _bak=$$2; shift 2;; \
|
||||
*) break;; \
|
||||
esac; \
|
||||
done; \
|
||||
for new in "$$@"; do \
|
||||
if test $$_t $$new; then \
|
||||
target=`expr $$new : '\(.*\).new'`; \
|
||||
CmpCp $$new $$target $$_bak; \
|
||||
fi; \
|
||||
rm -f $$new; \
|
||||
done; :; }
|
||||
|
||||
.endif
|
97
20150418/mk/java.mk
Normal file
97
20150418/mk/java.mk
Normal file
@ -0,0 +1,97 @@
|
||||
#
|
||||
# RCSid:
|
||||
# $Id: java.mk,v 1.14 2007/11/22 08:16:25 sjg Exp $
|
||||
|
||||
# @(#) Copyright (c) 1998-2001, 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
|
||||
#
|
||||
|
||||
.if !target(__${.PARSEFILE}__)
|
||||
__${.PARSEFILE}__:
|
||||
|
||||
.include <init.mk>
|
||||
|
||||
CLASSPATH?=.
|
||||
|
||||
.if defined(PROG)
|
||||
SRCS?= ${PROG:.class=.java}
|
||||
.endif
|
||||
.if !defined(SRCS) || empty(SRCS)
|
||||
SRCS!=cd ${.CURDIR} && echo *.java
|
||||
.endif
|
||||
.SUFFIXES: .class .java
|
||||
|
||||
CLEANFILES+= *.class
|
||||
|
||||
JAVAC?= javac
|
||||
JAVADOC?= javadoc
|
||||
|
||||
.if !target(docs)
|
||||
docs:
|
||||
${JAVADOC} ${JAVADOC_FLAGS} ${SRCS}
|
||||
.endif
|
||||
|
||||
.if defined(JAVADESTDIR) && !empty(JAVADESTDIR)
|
||||
JAVASRCDIR?=${JAVADESTDIR:H}/src
|
||||
__classdest:=${JAVADESTDIR}${.CURDIR:S,${JAVASRCDIR},,}/
|
||||
CLASSPATH:=${CLASSPATH}:${JAVADESTDIR}
|
||||
JAVAC_FLAGS+= -d ${JAVADESTDIR}
|
||||
.else
|
||||
__classdest=
|
||||
.endif
|
||||
|
||||
JAVAC_FLAGS+= ${JAVAC_DBG}
|
||||
|
||||
.if defined(MAKE_VERSION) && !defined(NO_CLASSES_COOKIE)
|
||||
# java works best by compiling a bunch of classes at once.
|
||||
# this lot does that but needs a recent netbsd make or
|
||||
# or its portable cousin bmake.
|
||||
.for __s in ${SRCS}
|
||||
__c:= ${__classdest}${__s:.java=.class}
|
||||
.if !target(${__c})
|
||||
# We need to do something to force __c's parent to be made.
|
||||
${__c}: ${__s}
|
||||
@rm -f ${.TARGET}
|
||||
.endif
|
||||
SRCS_${__c}=${__s}
|
||||
__classes:= ${__classes} ${__c}
|
||||
.endfor
|
||||
__classes_cookie=${__classdest}.classes.done
|
||||
CLEANFILES+= ${__classes} ${__classes_cookie}
|
||||
|
||||
${__classes_cookie}: ${__classes}
|
||||
CLASSPATH=${CLASSPATH} ${JAVAC} ${JAVAC_FLAGS} ${.OODATE:@c@${SRCS_$c}@}
|
||||
@touch ${.TARGET}
|
||||
|
||||
all: ${__classes_cookie}
|
||||
|
||||
.else
|
||||
# this will work with other BSD make's
|
||||
.for __s in ${SRCS}
|
||||
__c:= ${__classdest}${__s:.java=.class}
|
||||
${__c}: ${__s}
|
||||
CLASSPATH=${CLASSPATH} ${JAVAC} ${JAVAC_FLAGS} ${.OODATE}
|
||||
.endfor
|
||||
|
||||
all: ${SRCS:%.java=${__classdest}%.class}
|
||||
|
||||
.endif
|
||||
|
||||
.if !target(cleanjava)
|
||||
cleanjava:
|
||||
rm -f [Ee]rrs mklog core *.core ${PROG} ${CLEANFILES}
|
||||
|
||||
clean: cleanjava
|
||||
cleandir: cleanjava
|
||||
.endif
|
||||
|
||||
.endif
|
603
20150418/mk/lib.mk
Normal file
603
20150418/mk/lib.mk
Normal file
@ -0,0 +1,603 @@
|
||||
# $Id: lib.mk,v 1.51 2014/05/23 01:30:36 sjg Exp $
|
||||
|
||||
.if !target(__${.PARSEFILE}__)
|
||||
__${.PARSEFILE}__:
|
||||
|
||||
.include <init.mk>
|
||||
|
||||
.if ${OBJECT_FMT} == "ELF"
|
||||
NEED_SOLINKS?= yes
|
||||
.endif
|
||||
|
||||
.if exists(${.CURDIR}/shlib_version)
|
||||
SHLIB_MAJOR != . ${.CURDIR}/shlib_version ; echo $$major
|
||||
SHLIB_MINOR != . ${.CURDIR}/shlib_version ; echo $$minor
|
||||
.endif
|
||||
|
||||
print-shlib-major:
|
||||
.if defined(SHLIB_MAJOR) && ${MK_PIC} != "no"
|
||||
@echo ${SHLIB_MAJOR}
|
||||
.else
|
||||
@false
|
||||
.endif
|
||||
|
||||
print-shlib-minor:
|
||||
.if defined(SHLIB_MINOR) && ${MK_PIC} != "no"
|
||||
@echo ${SHLIB_MINOR}
|
||||
.else
|
||||
@false
|
||||
.endif
|
||||
|
||||
print-shlib-teeny:
|
||||
.if defined(SHLIB_TEENY) && ${MK_PIC} != "no"
|
||||
@echo ${SHLIB_TEENY}
|
||||
.else
|
||||
@false
|
||||
.endif
|
||||
|
||||
SHLIB_FULLVERSION ?= ${${SHLIB_MAJOR} ${SHLIB_MINOR} ${SHLIB_TEENY}:L:ts.}
|
||||
SHLIB_FULLVERSION := ${SHLIB_FULLVERSION}
|
||||
|
||||
# add additional suffixes not exported.
|
||||
# .po is used for profiling object files.
|
||||
# .so is used for PIC object files.
|
||||
.SUFFIXES: .out .a .ln .so .po .o .s .S .c .cc .C .m .F .f .r .y .l .cl .p .h
|
||||
.SUFFIXES: .sh .m4 .m
|
||||
|
||||
CFLAGS+= ${COPTS}
|
||||
|
||||
# Derrived from NetBSD-1.6
|
||||
|
||||
# Set PICFLAGS to cc flags for producing position-independent code,
|
||||
# if not already set. Includes -DPIC, if required.
|
||||
|
||||
# Data-driven table using make variables to control how shared libraries
|
||||
# are built for different platforms and object formats.
|
||||
# OBJECT_FMT: currently either "ELF" or "a.out", from <bsd.own.mk>
|
||||
# SHLIB_SOVERSION: version number to be compiled into a shared library
|
||||
# via -soname. Usually ${SHLIB_MAJOR} on ELF.
|
||||
# NetBSD/pmax used to use ${SHLIB_MAJOR}[.${SHLIB_MINOR}
|
||||
# [.${SHLIB_TEENY}]]
|
||||
# SHLIB_SHFLAGS: Flags to tell ${LD} to emit shared library.
|
||||
# with ELF, also set shared-lib version for ld.so.
|
||||
# SHLIB_LDSTARTFILE: support .o file, call C++ file-level constructors
|
||||
# SHLIB_LDENDFILE: support .o file, call C++ file-level destructors
|
||||
# FPICFLAGS: flags for ${FC} to compile .[fF] files to .so objects.
|
||||
# CPPICFLAGS: flags for ${CPP} to preprocess .[sS] files for ${AS}
|
||||
# CPICFLAGS: flags for ${CC} to compile .[cC] files to .so objects.
|
||||
# CAPICFLAGS flags for {$CC} to compiling .[Ss] files
|
||||
# (usually just ${CPPPICFLAGS} ${CPICFLAGS})
|
||||
# APICFLAGS: flags for ${AS} to assemble .[sS] to .so objects.
|
||||
|
||||
.if ${TARGET_OSNAME} == "NetBSD"
|
||||
.if ${MACHINE_ARCH} == "alpha"
|
||||
# Alpha-specific shared library flags
|
||||
FPICFLAGS ?= -fPIC
|
||||
CPICFLAGS ?= -fPIC -DPIC
|
||||
CPPPICFLAGS?= -DPIC
|
||||
CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
|
||||
APICFLAGS ?=
|
||||
.elif ${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb"
|
||||
# mips-specific shared library flags
|
||||
|
||||
# On mips, all libs are compiled with ABIcalls, not just sharedlibs.
|
||||
MKPICLIB= no
|
||||
|
||||
# so turn shlib PIC flags on for ${AS}.
|
||||
AINC+=-DABICALLS
|
||||
AFLAGS+= -fPIC
|
||||
AS+= -KPIC
|
||||
|
||||
.elif ${MACHINE_ARCH} == "vax" && ${OBJECT_FMT} == "ELF"
|
||||
# On the VAX, all object are PIC by default, not just sharedlibs.
|
||||
MKPICLIB= no
|
||||
|
||||
.elif (${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64") && \
|
||||
${OBJECT_FMT} == "ELF"
|
||||
# If you use -fPIC you need to define BIGPIC to turn on 32-bit
|
||||
# relocations in asm code
|
||||
FPICFLAGS ?= -fPIC
|
||||
CPICFLAGS ?= -fPIC -DPIC
|
||||
CPPPICFLAGS?= -DPIC -DBIGPIC
|
||||
CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
|
||||
APICFLAGS ?= -KPIC
|
||||
|
||||
.else
|
||||
|
||||
# Platform-independent flags for NetBSD a.out shared libraries
|
||||
SHLIB_SOVERSION=${SHLIB_FULLVERSION}
|
||||
SHLIB_SHFLAGS=
|
||||
FPICFLAGS ?= -fPIC
|
||||
CPICFLAGS?= -fPIC -DPIC
|
||||
CPPPICFLAGS?= -DPIC
|
||||
CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS}
|
||||
APICFLAGS?= -k
|
||||
|
||||
.endif
|
||||
|
||||
# Platform-independent linker flags for ELF shared libraries
|
||||
.if ${OBJECT_FMT} == "ELF"
|
||||
SHLIB_SOVERSION= ${SHLIB_MAJOR}
|
||||
SHLIB_SHFLAGS= -soname lib${LIB}.so.${SHLIB_SOVERSION}
|
||||
SHLIB_LDSTARTFILE?= /usr/lib/crtbeginS.o
|
||||
SHLIB_LDENDFILE?= /usr/lib/crtendS.o
|
||||
.endif
|
||||
|
||||
# for compatibility with the following
|
||||
CC_PIC?= ${CPICFLAGS}
|
||||
LD_shared=${SHLIB_SHFLAGS}
|
||||
|
||||
.endif # NetBSD
|
||||
|
||||
.if ${TARGET_OSNAME} == "FreeBSD"
|
||||
.if ${OBJECT_FMT} == "ELF"
|
||||
SHLIB_SOVERSION= ${SHLIB_MAJOR}
|
||||
SHLIB_SHFLAGS= -soname lib${LIB}.so.${SHLIB_SOVERSION}
|
||||
.else
|
||||
SHLIB_SHFLAGS= -assert pure-text
|
||||
.endif
|
||||
SHLIB_LDSTARTFILE=
|
||||
SHLIB_LDENDFILE=
|
||||
CC_PIC?= -fpic
|
||||
LD_shared=${SHLIB_SHFLAGS}
|
||||
|
||||
.endif # FreeBSD
|
||||
|
||||
MKPICLIB?= yes
|
||||
|
||||
# sys.mk can override these
|
||||
LD_X?=-X
|
||||
LD_x?=-x
|
||||
LD_r?=-r
|
||||
|
||||
# Non BSD machines will be using bmake.
|
||||
.if ${TARGET_OSNAME} == "SunOS"
|
||||
LD_shared=-assert pure-text
|
||||
.if ${OBJECT_FMT} == "ELF" || ${MACHINE} == "solaris"
|
||||
# Solaris
|
||||
LD_shared=-h lib${LIB}.so.${SHLIB_MAJOR} -G
|
||||
.endif
|
||||
.elif ${TARGET_OSNAME} == "HP-UX"
|
||||
LD_shared=-b
|
||||
LD_so=sl
|
||||
DLLIB=
|
||||
# HPsUX lorder does not grok anything but .o
|
||||
LD_sobjs=`${LORDER} ${OBJS} | ${TSORT} | sed 's,\.o,.so,'`
|
||||
LD_pobjs=`${LORDER} ${OBJS} | ${TSORT} | sed 's,\.o,.po,'`
|
||||
.elif ${TARGET_OSNAME} == "OSF1"
|
||||
LD_shared= -msym -shared -expect_unresolved '*'
|
||||
LD_solib= -all lib${LIB}_pic.a
|
||||
DLLIB=
|
||||
# lorder does not grok anything but .o
|
||||
LD_sobjs=`${LORDER} ${OBJS} | ${TSORT} | sed 's,\.o,.so,'`
|
||||
LD_pobjs=`${LORDER} ${OBJS} | ${TSORT} | sed 's,\.o,.po,'`
|
||||
AR_cq= -cqs
|
||||
.elif ${TARGET_OSNAME} == "FreeBSD"
|
||||
LD_solib= lib${LIB}_pic.a
|
||||
.elif ${TARGET_OSNAME} == "Linux"
|
||||
SHLIB_LD = ${CC}
|
||||
# this is ambiguous of course
|
||||
LD_shared=-shared -Wl,"-h lib${LIB}.so.${SHLIB_MAJOR}"
|
||||
LD_solib= -Wl,--whole-archive lib${LIB}_pic.a -Wl,--no-whole-archive
|
||||
# Linux uses GNU ld, which is a multi-pass linker
|
||||
# so we don't need to use lorder or tsort
|
||||
LD_objs = ${OBJS}
|
||||
LD_pobjs = ${POBJS}
|
||||
LD_sobjs = ${SOBJS}
|
||||
.elif ${TARGET_OSNAME} == "Darwin"
|
||||
SHLIB_LD = ${CC}
|
||||
SHLIB_INSTALL_VERSION ?= ${SHLIB_MAJOR}
|
||||
SHLIB_COMPATABILITY_VERSION ?= ${SHLIB_MAJOR}.${SHLIB_MINOR:U0}
|
||||
SHLIB_COMPATABILITY ?= \
|
||||
-compatibility_version ${SHLIB_COMPATABILITY_VERSION} \
|
||||
-current_version ${SHLIB_FULLVERSION}
|
||||
LD_shared = -dynamiclib \
|
||||
-flat_namespace -undefined suppress \
|
||||
-install_name ${LIBDIR}/lib${LIB}.${SHLIB_INSTALL_VERSION}.${LD_solink} \
|
||||
${SHLIB_COMPATABILITY}
|
||||
SHLIB_LINKS =
|
||||
.for v in ${SHLIB_COMPATABILITY_VERSION} ${SHLIB_INSTALL_VERSION}
|
||||
.if "$v" != "${SHLIB_FULLVERSION}"
|
||||
SHLIB_LINKS += lib${LIB}.$v.${LD_solink}
|
||||
.endif
|
||||
.endfor
|
||||
.if ${MK_LINKLIB} != "no"
|
||||
SHLIB_LINKS += lib${LIB}.${LD_solink}
|
||||
.endif
|
||||
|
||||
LD_so = ${SHLIB_FULLVERSION}.dylib
|
||||
LD_sobjs = ${SOBJS:O:u}
|
||||
LD_solib = ${LD_sobjs}
|
||||
SOLIB = ${LD_sobjs}
|
||||
LD_solink = dylib
|
||||
.if ${MACHINE_ARCH} == "i386"
|
||||
PICFLAG ?= -fPIC
|
||||
.else
|
||||
PICFLAG ?= -fPIC -fno-common
|
||||
.endif
|
||||
RANLIB = :
|
||||
.endif
|
||||
|
||||
SHLIB_LD ?= ${LD}
|
||||
|
||||
.if !empty(SHLIB_MAJOR)
|
||||
.if ${NEED_SOLINKS} && empty(SHLIB_LINKS)
|
||||
.if ${MK_LINKLIB} != "no"
|
||||
SHLIB_LINKS = lib${LIB}.${LD_solink}
|
||||
.endif
|
||||
.if "${SHLIB_FULLVERSION}" != "${SHLIB_MAJOR}"
|
||||
SHLIB_LINKS += lib${LIB}.${LD_solink}.${SHLIB_MAJOR}
|
||||
.endif
|
||||
.endif
|
||||
.endif
|
||||
|
||||
LIBTOOL?=libtool
|
||||
LD_shared ?= -Bshareable -Bforcearchive
|
||||
LD_so ?= so.${SHLIB_FULLVERSION}
|
||||
LD_solink ?= so
|
||||
.if empty(LORDER)
|
||||
LD_objs ?= ${OBJS}
|
||||
LD_pobjs ?= ${POBJS}
|
||||
LD_sobjs ?= ${SOBJS}
|
||||
.else
|
||||
LD_objs ?= `${LORDER} ${OBJS} | ${TSORT}`
|
||||
LD_sobjs ?= `${LORDER} ${SOBJS} | ${TSORT}`
|
||||
LD_pobjs ?= `${LORDER} ${POBJS} | ${TSORT}`
|
||||
.endif
|
||||
LD_solib ?= ${LD_sobjs}
|
||||
AR_cq ?= cq
|
||||
.if exists(/netbsd) && exists(${DESTDIR}/usr/lib/libdl.so)
|
||||
DLLIB ?= -ldl
|
||||
.endif
|
||||
|
||||
# some libs have lots of objects, and scanning all .o, .po and .So meta files
|
||||
# is a waste of time, this tells meta.autodep.mk to just pick one
|
||||
# (typically .So)
|
||||
# yes, 42 is a random number.
|
||||
.if ${MK_META_MODE} == "yes" && ${SRCS:Uno:[\#]} > 42
|
||||
OPTIMIZE_OBJECT_META_FILES ?= yes
|
||||
.endif
|
||||
|
||||
|
||||
.if ${MK_LIBTOOL} == "yes"
|
||||
# because libtool is so fascist about naming the object files,
|
||||
# we cannot (yet) build profiled libs
|
||||
MK_PROFILE=no
|
||||
_LIBS=lib${LIB}.a
|
||||
.if exists(${.CURDIR}/shlib_version)
|
||||
SHLIB_AGE != . ${.CURDIR}/shlib_version ; echo $$age
|
||||
.endif
|
||||
.else
|
||||
# for the normal .a we do not want to strip symbols
|
||||
.c.o:
|
||||
${COMPILE.c} ${.IMPSRC}
|
||||
|
||||
# for the normal .a we do not want to strip symbols
|
||||
.cc.o .C.o:
|
||||
${COMPILE.cc} ${.IMPSRC}
|
||||
|
||||
.S.o .s.o:
|
||||
@echo ${COMPILE.S} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC}
|
||||
@${COMPILE.S} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC}
|
||||
|
||||
.if (${LD_X} == "")
|
||||
.c.po:
|
||||
${COMPILE.c} ${CC_PG} ${PROFFLAGS} ${.IMPSRC} -o ${.TARGET}
|
||||
|
||||
.cc.po .C.po:
|
||||
${COMPILE.cc} -pg ${.IMPSRC} -o ${.TARGET}
|
||||
|
||||
.S.so .s.so:
|
||||
${COMPILE.S} ${PICFLAG} ${CC_PIC} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
|
||||
.else
|
||||
.c.po:
|
||||
@echo ${COMPILE.c} ${CC_PG} ${PROFFLAGS} ${.IMPSRC} -o ${.TARGET}
|
||||
@${COMPILE.c} ${CC_PG} ${PROFFLAGS} ${.IMPSRC} -o ${.TARGET}.o
|
||||
@${LD} ${LD_X} ${LD_r} ${.TARGET}.o -o ${.TARGET}
|
||||
@rm -f ${.TARGET}.o
|
||||
|
||||
.cc.po .C.po:
|
||||
@echo ${COMPILE.cc} ${CXX_PG} ${PROFFLAGS} ${.IMPSRC} -o ${.TARGET}
|
||||
@${COMPILE.cc} ${CXX_PG} ${.IMPSRC} -o ${.TARGET}.o
|
||||
@${LD} ${LD_X} ${LD_r} ${.TARGET}.o -o ${.TARGET}
|
||||
@rm -f ${.TARGET}.o
|
||||
|
||||
.S.so .s.so:
|
||||
@echo ${COMPILE.S} ${PICFLAG} ${CC_PIC} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
|
||||
@${COMPILE.S} ${PICFLAG} ${CC_PIC} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
|
||||
@${LD} ${LD_x} ${LD_r} ${.TARGET}.o -o ${.TARGET}
|
||||
@rm -f ${.TARGET}.o
|
||||
.endif
|
||||
|
||||
.if (${LD_x} == "")
|
||||
.c.so:
|
||||
${COMPILE.c} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}
|
||||
|
||||
.cc.so .C.so:
|
||||
${COMPILE.cc} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}
|
||||
|
||||
.S.po .s.po:
|
||||
${COMPILE.S} ${PROFFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
|
||||
.else
|
||||
|
||||
.c.so:
|
||||
@echo ${COMPILE.c} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}
|
||||
@${COMPILE.c} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}.o
|
||||
@${LD} ${LD_x} ${LD_r} ${.TARGET}.o -o ${.TARGET}
|
||||
@rm -f ${.TARGET}.o
|
||||
|
||||
.cc.so .C.so:
|
||||
@echo ${COMPILE.cc} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}
|
||||
@${COMPILE.cc} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}.o
|
||||
@${LD} ${LD_x} ${LD_r} ${.TARGET}.o -o ${.TARGET}
|
||||
@rm -f ${.TARGET}.o
|
||||
|
||||
.S.po .s.po:
|
||||
@echo ${COMPILE.S} ${PROFFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}
|
||||
@${COMPILE.S} ${PROFFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o
|
||||
@${LD} ${LD_X} ${LD_r} ${.TARGET}.o -o ${.TARGET}
|
||||
@rm -f ${.TARGET}.o
|
||||
|
||||
.endif
|
||||
.endif
|
||||
|
||||
.c.ln:
|
||||
${LINT} ${LINTFLAGS} ${CFLAGS:M-[IDU]*} -i ${.IMPSRC}
|
||||
|
||||
.if ${MK_LIBTOOL} != "yes"
|
||||
|
||||
.if !defined(PICFLAG)
|
||||
PICFLAG=-fpic
|
||||
.endif
|
||||
|
||||
_LIBS=
|
||||
|
||||
.if ${MK_ARCHIVE} != "no"
|
||||
_LIBS += lib${LIB}.a
|
||||
.endif
|
||||
|
||||
.if ${MK_PROFILE} != "no"
|
||||
_LIBS+=lib${LIB}_p.a
|
||||
POBJS+=${OBJS:.o=.po}
|
||||
.endif
|
||||
|
||||
.if ${MK_PIC} != "no"
|
||||
.if ${MK_PICLIB} == "no"
|
||||
SOLIB ?= lib${LIB}.a
|
||||
.else
|
||||
SOLIB=lib${LIB}_pic.a
|
||||
_LIBS+=${SOLIB}
|
||||
.endif
|
||||
.if !empty(SHLIB_FULLVERSION)
|
||||
_LIBS+=lib${LIB}.${LD_so}
|
||||
.endif
|
||||
.endif
|
||||
|
||||
.if ${MK_LINT} != "no"
|
||||
_LIBS+=llib-l${LIB}.ln
|
||||
.endif
|
||||
|
||||
# here is where you can define what LIB* are
|
||||
.-include <libnames.mk>
|
||||
.if ${MK_DPADD_MK} == "yes"
|
||||
# lots of cool magic, but might not suit everyone.
|
||||
.include <dpadd.mk>
|
||||
.endif
|
||||
|
||||
.if !defined(_SKIP_BUILD)
|
||||
all: prebuild .WAIT ${_LIBS}
|
||||
# a hook for things that must be done early
|
||||
prebuild:
|
||||
.if !defined(.PARSEDIR)
|
||||
# no-op is the best we can do if not bmake.
|
||||
.WAIT:
|
||||
.endif
|
||||
.endif
|
||||
all: _SUBDIRUSE
|
||||
|
||||
.for s in ${SRCS:N*.h:M*/*}
|
||||
${.o .so .po .lo:L:@o@${s:T:R}$o@}: $s
|
||||
.endfor
|
||||
|
||||
OBJS+= ${SRCS:T:N*.h:R:S/$/.o/g}
|
||||
.NOPATH: ${OBJS}
|
||||
|
||||
.if ${MK_LIBTOOL} == "yes"
|
||||
.if ${MK_PIC} == "no"
|
||||
LT_STATIC=-static
|
||||
.else
|
||||
LT_STATIC=
|
||||
.endif
|
||||
SHLIB_AGE?=0
|
||||
|
||||
# .lo's are created as a side effect
|
||||
.s.o .S.o .c.o:
|
||||
${LIBTOOL} --mode=compile ${CC} ${LT_STATIC} ${CFLAGS} ${CPPFLAGS} ${IMPFLAGS} -c ${.IMPSRC}
|
||||
|
||||
# can't really do profiled libs with libtool - its too fascist about
|
||||
# naming the output...
|
||||
lib${LIB}.a:: ${OBJS}
|
||||
@rm -f ${.TARGET}
|
||||
${LIBTOOL} --mode=link ${CC} ${LT_STATIC} -o ${.TARGET:.a=.la} ${OBJS:.o=.lo} -rpath ${SHLIBDIR}:/usr/lib -version-info ${SHLIB_MAJOR}:${SHLIB_MINOR}:${SHLIB_AGE}
|
||||
@ln .libs/${.TARGET} .
|
||||
|
||||
lib${LIB}.${LD_so}:: lib${LIB}.a
|
||||
@[ -s ${.TARGET}.${SHLIB_AGE} ] || { ln -s .libs/lib${LIB}.${LD_so}* . 2>/dev/null; : }
|
||||
@[ -s ${.TARGET} ] || ln -s ${.TARGET}.${SHLIB_AGE} ${.TARGET}
|
||||
|
||||
.else # MK_LIBTOOL=yes
|
||||
|
||||
lib${LIB}.a:: ${OBJS}
|
||||
@echo building standard ${LIB} library
|
||||
@rm -f ${.TARGET}
|
||||
@${AR} ${AR_cq} ${.TARGET} ${LD_objs}
|
||||
${RANLIB} ${.TARGET}
|
||||
|
||||
POBJS+= ${OBJS:.o=.po}
|
||||
.NOPATH: ${POBJS}
|
||||
lib${LIB}_p.a:: ${POBJS}
|
||||
@echo building profiled ${LIB} library
|
||||
@rm -f ${.TARGET}
|
||||
@${AR} ${AR_cq} ${.TARGET} ${LD_pobjs}
|
||||
${RANLIB} ${.TARGET}
|
||||
|
||||
SOBJS+= ${OBJS:.o=.so}
|
||||
.NOPATH: ${SOBJS}
|
||||
lib${LIB}_pic.a:: ${SOBJS}
|
||||
@echo building shared object ${LIB} library
|
||||
@rm -f ${.TARGET}
|
||||
@${AR} ${AR_cq} ${.TARGET} ${LD_sobjs}
|
||||
${RANLIB} ${.TARGET}
|
||||
|
||||
#SHLIB_LDADD?= ${LDADD}
|
||||
|
||||
# bound to be non-portable...
|
||||
# this is known to work for NetBSD 1.6 and FreeBSD 4.2
|
||||
lib${LIB}.${LD_so}: ${SOLIB} ${DPADD}
|
||||
@echo building shared ${LIB} library \(version ${SHLIB_FULLVERSION}\)
|
||||
@rm -f ${.TARGET}
|
||||
.if ${TARGET_OSNAME} == "NetBSD" || ${TARGET_OSNAME} == "FreeBSD"
|
||||
.if ${OBJECT_FMT} == "ELF"
|
||||
${SHLIB_LD} -x -shared ${SHLIB_SHFLAGS} -o ${.TARGET} \
|
||||
${SHLIB_LDSTARTFILE} \
|
||||
--whole-archive ${SOLIB} --no-whole-archive ${SHLIB_LDADD} \
|
||||
${SHLIB_LDENDFILE}
|
||||
.else
|
||||
${SHLIB_LD} ${LD_x} ${LD_shared} \
|
||||
-o ${.TARGET} ${SOLIB} ${SHLIB_LDADD}
|
||||
.endif
|
||||
.else
|
||||
${SHLIB_LD} -o ${.TARGET} ${LD_shared} ${LD_solib} ${DLLIB} ${SHLIB_LDADD}
|
||||
.endif
|
||||
.endif
|
||||
.if !empty(SHLIB_LINKS)
|
||||
rm -f ${SHLIB_LINKS}; ${SHLIB_LINKS:O:u:@x@ln -s ${.TARGET} $x;@}
|
||||
.endif
|
||||
|
||||
LOBJS+= ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
|
||||
.NOPATH: ${LOBJS}
|
||||
LLIBS?= -lc
|
||||
llib-l${LIB}.ln: ${LOBJS}
|
||||
@echo building llib-l${LIB}.ln
|
||||
@rm -f llib-l${LIB}.ln
|
||||
@${LINT} -C${LIB} ${LOBJS} ${LLIBS}
|
||||
|
||||
.if !target(clean)
|
||||
cleanlib: .PHONY
|
||||
rm -f a.out [Ee]rrs mklog core *.core ${CLEANFILES}
|
||||
rm -f lib${LIB}.a ${OBJS}
|
||||
rm -f lib${LIB}_p.a ${POBJS}
|
||||
rm -f lib${LIB}_pic.a lib${LIB}.so.*.* ${SOBJS}
|
||||
rm -f llib-l${LIB}.ln ${LOBJS}
|
||||
.if !empty(SHLIB_LINKS)
|
||||
rm -f ${SHLIB_LINKS}
|
||||
.endif
|
||||
|
||||
clean: _SUBDIRUSE cleanlib
|
||||
cleandir: _SUBDIRUSE cleanlib
|
||||
.else
|
||||
cleandir: _SUBDIRUSE clean
|
||||
.endif
|
||||
|
||||
.if defined(SRCS) && (!defined(MKDEP) || ${MKDEP} != autodep)
|
||||
afterdepend: .depend
|
||||
@(TMP=/tmp/_depend$$$$; \
|
||||
sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1.so \1.ln:/' \
|
||||
< .depend > $$TMP; \
|
||||
mv $$TMP .depend)
|
||||
.endif
|
||||
|
||||
.if !target(install)
|
||||
.if !target(beforeinstall)
|
||||
beforeinstall:
|
||||
.endif
|
||||
|
||||
.if !empty(LIBOWN)
|
||||
LIB_INSTALL_OWN ?= -o ${LIBOWN} -g ${LIBGRP}
|
||||
.endif
|
||||
|
||||
.include <links.mk>
|
||||
|
||||
.if !target(realinstall)
|
||||
realinstall: libinstall
|
||||
.endif
|
||||
.if !target(libinstall)
|
||||
libinstall:
|
||||
[ -d ${DESTDIR}/${LIBDIR} ] || \
|
||||
${INSTALL} -d ${LIB_INSTALL_OWN} -m 775 ${DESTDIR}${LIBDIR}
|
||||
.if ${MK_ARCHIVE} != "no"
|
||||
${INSTALL} ${COPY} ${LIB_INSTALL_OWN} -m 600 lib${LIB}.a \
|
||||
${DESTDIR}${LIBDIR}
|
||||
${RANLIB} ${DESTDIR}${LIBDIR}/lib${LIB}.a
|
||||
chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}.a
|
||||
.endif
|
||||
.if ${MK_PROFILE} != "no"
|
||||
${INSTALL} ${COPY} ${LIB_INSTALL_OWN} -m 600 \
|
||||
lib${LIB}_p.a ${DESTDIR}${LIBDIR}
|
||||
${RANLIB} ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
|
||||
chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
|
||||
.endif
|
||||
.if ${MK_PIC} != "no"
|
||||
.if ${MK_PICLIB} != "no"
|
||||
${INSTALL} ${COPY} ${LIB_INSTALL_OWN} -m 600 \
|
||||
lib${LIB}_pic.a ${DESTDIR}${LIBDIR}
|
||||
${RANLIB} ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
|
||||
chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
|
||||
.endif
|
||||
.if !empty(SHLIB_MAJOR)
|
||||
${INSTALL} ${COPY} ${LIB_INSTALL_OWN} -m ${LIBMODE} \
|
||||
lib${LIB}.${LD_so} ${DESTDIR}${LIBDIR}
|
||||
.if !empty(SHLIB_LINKS)
|
||||
(cd ${DESTDIR}${LIBDIR} && { rm -f ${SHLIB_LINKS}; ${SHLIB_LINKS:O:u:@x@ln -s lib${LIB}.${LD_so} $x;@} })
|
||||
.endif
|
||||
.endif
|
||||
.endif
|
||||
.if ${MK_LINT} != "no" && ${MK_LINKLIB} != "no" && !empty(LOBJS)
|
||||
${INSTALL} ${COPY} ${LIB_INSTALL_OWN} -m ${LIBMODE} \
|
||||
llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR}
|
||||
.endif
|
||||
.if defined(LINKS) && !empty(LINKS)
|
||||
@set ${LINKS}; ${_LINKS_SCRIPT}
|
||||
.endif
|
||||
.endif
|
||||
|
||||
install: maninstall _SUBDIRUSE
|
||||
maninstall: afterinstall
|
||||
afterinstall: realinstall
|
||||
realinstall: beforeinstall
|
||||
.endif
|
||||
|
||||
.if ${MK_MAN} != "no"
|
||||
.include <man.mk>
|
||||
.endif
|
||||
|
||||
.if ${MK_NLS} != "no"
|
||||
.include <nls.mk>
|
||||
.endif
|
||||
|
||||
.include <obj.mk>
|
||||
.include <inc.mk>
|
||||
.include <dep.mk>
|
||||
.include <subdir.mk>
|
||||
.endif
|
||||
|
||||
# during building we usually need/want to install libs somewhere central
|
||||
# note that we do NOT ch{own,grp} as that would likely fail at this point.
|
||||
# otherwise it is the same as realinstall
|
||||
# Note that we don't need this when using dpadd.mk
|
||||
.libinstall: ${_LIBS}
|
||||
test -d ${DESTDIR}${LIBDIR} || ${INSTALL} -d -m775 ${DESTDIR}${LIBDIR}
|
||||
.for _lib in ${_LIBS:M*.a}
|
||||
${INSTALL} ${COPY} -m 644 ${_lib} ${DESTDIR}${LIBDIR}
|
||||
${RANLIB} ${DESTDIR}${LIBDIR}/${_lib}
|
||||
.endfor
|
||||
.for _lib in ${_LIBS:M*.${LD_solink}*:O:u}
|
||||
${INSTALL} ${COPY} -m ${LIBMODE} ${_lib} ${DESTDIR}${LIBDIR}
|
||||
.if !empty(SHLIB_LINKS)
|
||||
(cd ${DESTDIR}${LIBDIR} && { ${SHLIB_LINKS:O:u:@x@ln -sf ${_lib} $x;@}; })
|
||||
.endif
|
||||
.endfor
|
||||
@touch ${.TARGET}
|
||||
|
||||
.include <final.mk>
|
||||
.endif
|
22
20150418/mk/libnames.mk
Normal file
22
20150418/mk/libnames.mk
Normal file
@ -0,0 +1,22 @@
|
||||
# $Id: libnames.mk,v 1.7 2009/12/25 07:34:03 sjg Exp $
|
||||
#
|
||||
# @(#) Copyright (c) 2007-2009, 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
|
||||
#
|
||||
|
||||
DLIBEXT ?= .a
|
||||
DSHLIBEXT ?= .so
|
||||
|
||||
.-include "local.libnames.mk"
|
||||
.-include "sjg.libnames.mk"
|
||||
.-include "fwall.libnames.mk"
|
||||
.-include "host.libnames.mk"
|
93
20150418/mk/libs.mk
Normal file
93
20150418/mk/libs.mk
Normal file
@ -0,0 +1,93 @@
|
||||
# $Id: libs.mk,v 1.3 2013/08/02 18:28:48 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(LIBS)
|
||||
|
||||
# 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_LIB
|
||||
UPDATE_DEPENDFILE_LIB = ${LIBS:[1]}
|
||||
.export UPDATE_DEPENDFILE_LIB
|
||||
.endif
|
||||
|
||||
.ifndef LIB
|
||||
# They may have asked us to build just one
|
||||
.for t in ${LIBS:R:T:S,^lib,,}
|
||||
.if make(lib$t)
|
||||
LIB?= $t
|
||||
lib$t: all
|
||||
.endif
|
||||
.endfor
|
||||
.endif
|
||||
|
||||
.if defined(LIB)
|
||||
# just one of many
|
||||
LIB_VARS += \
|
||||
LIBDIR \
|
||||
CFLAGS \
|
||||
COPTS \
|
||||
CPPFLAGS \
|
||||
CXXFLAGS \
|
||||
DPADD \
|
||||
DPLIBS \
|
||||
LDADD \
|
||||
LDFLAGS \
|
||||
MAN \
|
||||
SRCS
|
||||
|
||||
.for v in ${LIB_VARS:O:u}
|
||||
.if defined(${v}.${LIB}) || defined(${v}_${LIB})
|
||||
$v += ${${v}_${LIB}:U${${v}.${LIB}}}
|
||||
.endif
|
||||
.endfor
|
||||
|
||||
# for meta mode, there can be only one!
|
||||
.if ${LIB} == ${UPDATE_DEPENDFILE_LIB:Uno}
|
||||
UPDATE_DEPENDFILE ?= yes
|
||||
.endif
|
||||
UPDATE_DEPENDFILE ?= NO
|
||||
|
||||
# ensure that we don't clobber each other's dependencies
|
||||
DEPENDFILE?= .depend.${LIB}
|
||||
# lib.mk will do the rest
|
||||
.else
|
||||
all: ${LIBS:S,^lib,,:@t@lib$t.a@} .MAKE
|
||||
|
||||
# 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.]libs.mk
|
||||
.include <${.PARSEFILE:S,libs,lib,}>
|
||||
|
||||
.ifndef LIB
|
||||
# tell libs.mk we might want to install things
|
||||
LIBS_TARGETS+= cleandepend cleandir cleanobj depend install
|
||||
|
||||
.for b in ${LIBS:R:T:S,^lib,,}
|
||||
lib$b.a: ${SRCS} ${DPADD} ${SRCS_lib$b} ${DPADD_lib$b}
|
||||
(cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} LIB=$b)
|
||||
|
||||
.for t in ${LIBS_TARGETS:O:u}
|
||||
$b.$t: .PHONY .MAKE
|
||||
(cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} LIB=$b ${@:E})
|
||||
.endfor
|
||||
.endfor
|
||||
.endif
|
80
20150418/mk/links.mk
Normal file
80
20150418/mk/links.mk
Normal file
@ -0,0 +1,80 @@
|
||||
# $Id: links.mk,v 1.6 2014/09/29 17:14:40 sjg Exp $
|
||||
#
|
||||
# @(#) Copyright (c) 2005, 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
|
||||
#
|
||||
|
||||
# some platforms need something special
|
||||
LN?= ln
|
||||
ECHO?= echo
|
||||
|
||||
LINKS?=
|
||||
SYMLINKS?=
|
||||
|
||||
__SYMLINK_SCRIPT= \
|
||||
${ECHO} "$$t -> $$l"; \
|
||||
case `'ls' -l $$t 2> /dev/null` in \
|
||||
*"> $$l") ;; \
|
||||
*) \
|
||||
mkdir -p `dirname $$t`; \
|
||||
rm -f $$t; \
|
||||
${LN} -s $$l $$t;; \
|
||||
esac
|
||||
|
||||
|
||||
__LINK_SCRIPT= \
|
||||
${ECHO} "$$t -> $$l"; \
|
||||
mkdir -p `dirname $$t`; \
|
||||
rm -f $$t; \
|
||||
${LN} $$l $$t
|
||||
|
||||
_SYMLINKS_SCRIPT= \
|
||||
while test $$\# -ge 2; do \
|
||||
l=$$1; shift; \
|
||||
t=${DESTDIR}$$1; shift; \
|
||||
${__SYMLINK_SCRIPT}; \
|
||||
done; :;
|
||||
|
||||
_LINKS_SCRIPT= \
|
||||
while test $$\# -ge 2; do \
|
||||
l=${DESTDIR}$$1; shift; \
|
||||
t=${DESTDIR}$$1; shift; \
|
||||
${__LINK_SCRIPT}; \
|
||||
done; :;
|
||||
|
||||
_SYMLINKS_USE: .USE
|
||||
@set ${$@_SYMLINKS:U${SYMLINKS}}; ${_SYMLINKS_SCRIPT}
|
||||
|
||||
_LINKS_USE: .USE
|
||||
@set ${$@_LINKS:U${LINKS}}; ${_LINKS_SCRIPT}
|
||||
|
||||
|
||||
# sometimes we want to ensure DESTDIR is ignored
|
||||
_BUILD_SYMLINKS_SCRIPT= \
|
||||
while test $$\# -ge 2; do \
|
||||
l=$$1; shift; \
|
||||
t=$$1; shift; \
|
||||
${__SYMLINK_SCRIPT}; \
|
||||
done; :;
|
||||
|
||||
_BUILD_LINKS_SCRIPT= \
|
||||
while test $$\# -ge 2; do \
|
||||
l=$$1; shift; \
|
||||
t=$$1; shift; \
|
||||
${__LINK_SCRIPT}; \
|
||||
done; :;
|
||||
|
||||
_BUILD_SYMLINKS_USE: .USE
|
||||
@set ${$@_SYMLINKS:U${SYMLINKS}}; ${_BUILD_SYMLINKS_SCRIPT}
|
||||
|
||||
_BUILD_LINKS_USE: .USE
|
||||
@set ${$@_LINKS:U${LINKS}}; ${_BUILD_LINKS_SCRIPT}
|
137
20150418/mk/man.mk
Normal file
137
20150418/mk/man.mk
Normal file
@ -0,0 +1,137 @@
|
||||
# $Id: man.mk,v 1.20 2012/12/13 01:51:01 sjg Exp $
|
||||
|
||||
.if !target(__${.PARSEFILE}__)
|
||||
__${.PARSEFILE}__:
|
||||
|
||||
.include <init.mk>
|
||||
|
||||
# unlike bsd.man.mk we handle 3 approaches
|
||||
# 1. install unformated nroff (default)
|
||||
# 2. install formatted pages
|
||||
# 3. install formatted pages but with extension of .0
|
||||
# sadly we cannot rely on a shell that supports ${foo#...} and ${foo%...}
|
||||
# so we have to use sed(1).
|
||||
|
||||
# set MANTARGET=cat for formatted pages
|
||||
MANTARGET?= man
|
||||
# set this to .0 for same behavior as bsd.man.mk
|
||||
MCATEXT?=
|
||||
|
||||
NROFF?= nroff
|
||||
MANDIR?= /usr/share/man
|
||||
MANDOC?= man
|
||||
|
||||
.SUFFIXES: .1 .2 .3 .4 .5 .6 .7 .8 .9 .cat1 .cat2 .cat3 .cat4 .cat5 .cat6 \
|
||||
.cat7 .cat8 .cat9
|
||||
|
||||
.9.cat9 .8.cat8 .7.cat7 .6.cat6 .5.cat5 .4.cat4 .3.cat3 .2.cat2 .1.cat1:
|
||||
@echo "${NROFF} -${MANDOC} ${.IMPSRC} > ${.TARGET:T}"
|
||||
@${NROFF} -${MANDOC} ${.IMPSRC} > ${.TARGET:T} || ( rm -f ${.TARGET:T} ; false )
|
||||
|
||||
.if defined(MAN) && !empty(MAN)
|
||||
|
||||
# we use cmt2doc.pl to extract manpages from source
|
||||
# this is triggered by the setting of EXTRACT_MAN or MAN being set but
|
||||
# not existsing.
|
||||
|
||||
.if !exists(${MAN:[1]}) && !target(${MAN:[1]})
|
||||
.if defined(EXTRACT_MAN) && ${EXTRACT_MAN} == "no"
|
||||
MAN=
|
||||
.else
|
||||
.if exists(/usr/local/share/bin/cmt2doc.pl)
|
||||
CMT2DOC?= cmt2doc.pl
|
||||
CMT2DOC_OPTS?= ${CMT2DOC_ORGOPT} -pmS${.TARGET:E}
|
||||
.endif
|
||||
.ifdef CMT2DOC
|
||||
.c.8 .c.5 .c.3 .c.4 .c.1 \
|
||||
.cc.8 .cc.5 .cc.3 .cc.4 .cc.1 \
|
||||
.h.8 .h.5 .h.3 .h.4 .h.1 \
|
||||
.sh.8 .sh.5 .sh.3 .sh.4 .sh.1 \
|
||||
.pl.8 .pl.5 .pl.3 .pl.4 .pl.1:
|
||||
@echo "${CMT2DOC} ${.IMPSRC} > ${.TARGET:T}"
|
||||
@${CMT2DOC} ${CMT2DOC_OPTS} ${.IMPSRC} > ${.TARGET:T} || ( rm -f ${.TARGET:T} ; false )
|
||||
.else
|
||||
MAN=
|
||||
.endif
|
||||
.endif
|
||||
.endif
|
||||
|
||||
_mandir=${DESTDIR}${MANDIR}/${MANTARGET}`echo $$page | sed -e 's/.*\.cat/./' -e 's/.*\.//'`
|
||||
.if ${MANTARGET} == "cat"
|
||||
_mfromdir?=.
|
||||
MANALL= ${MAN:S/.1$/.cat1/g:S/.2$/.cat2/g:S/.3$/.cat3/g:S/.4$/.cat4/g:S/.5$/.cat5/g:S/.6$/.cat6/g:S/.7$/.cat7/g:S/.8$/.cat8/g:S/.9$/.cat9/g}
|
||||
.if ${MCATEXT} == ""
|
||||
_minstpage=`echo $$page | sed 's/\.cat/./'`
|
||||
.else
|
||||
_minstpage=`echo $$page | sed 's/\.cat.*//'`${MCATEXT}
|
||||
.endif
|
||||
.endif
|
||||
.if target(${MAN:[1]})
|
||||
_mfromdir?=.
|
||||
.endif
|
||||
_mfromdir?=${.CURDIR}
|
||||
MANALL?= ${MAN}
|
||||
_minstpage?=$${page}
|
||||
.endif
|
||||
|
||||
.if !empty(MANOWN)
|
||||
MAN_INSTALL_OWN ?= -o ${MANOWN} -g ${MANGRP}
|
||||
MAN_CHOWN ?= chown
|
||||
.else
|
||||
MAN_CHOWN = :
|
||||
.endif
|
||||
|
||||
MINSTALL= ${INSTALL} ${COPY} ${MAN_INSTALL_OWN} -m ${MANMODE}
|
||||
.if defined(MANZ)
|
||||
# chown and chmod are done afterward automatically
|
||||
MCOMPRESS= gzip -cf
|
||||
MCOMPRESSSUFFIX= .gz
|
||||
.endif
|
||||
|
||||
maninstall:
|
||||
.if defined(MANALL) && !empty(MANALL)
|
||||
@for page in ${MANALL:T}; do \
|
||||
test -s ${_mfromdir}/$$page || continue; \
|
||||
dir=${_mandir}; \
|
||||
test -d $$dir || ${INSTALL} -d ${MAN_INSTALL_OWN} -m 775 $$dir; \
|
||||
instpage=$${dir}${MANSUBDIR}/${_minstpage}${MCOMPRESSSUFFIX}; \
|
||||
if [ X"${MCOMPRESS}" = X ]; then \
|
||||
echo ${MINSTALL} ${_mfromdir}/$$page $$instpage; \
|
||||
${MINSTALL} ${_mfromdir}/$$page $$instpage; \
|
||||
else \
|
||||
rm -f $$instpage; \
|
||||
echo ${MCOMPRESS} ${_mfromdir}/$$page \> $$instpage; \
|
||||
${MCOMPRESS} ${_mfromdir}/$$page > $$instpage; \
|
||||
${MAN_CHOWN} ${MANOWN}:${MANGRP} $$instpage; \
|
||||
chmod ${MANMODE} $$instpage; \
|
||||
fi \
|
||||
done
|
||||
.if defined(MLINKS) && !empty(MLINKS)
|
||||
@set ${MLINKS}; \
|
||||
while test $$# -ge 2; do \
|
||||
page=$$1; \
|
||||
shift; \
|
||||
dir=${_mandir}; \
|
||||
l=${_minstpage}${MCOMPRESSSUFFIX}; \
|
||||
page=$$1; \
|
||||
shift; \
|
||||
dir=${_mandir}; \
|
||||
t=$${dir}${MANSUBDIR}/${_minstpage}${MCOMPRESSSUFFIX}; \
|
||||
echo $$t -\> $$l; \
|
||||
rm -f $$t; \
|
||||
ln -s $$l $$t; \
|
||||
done
|
||||
.endif
|
||||
.endif
|
||||
|
||||
.if defined(MANALL) && !empty(MANALL)
|
||||
manall: ${MANALL}
|
||||
all: manall
|
||||
.endif
|
||||
|
||||
.if defined(CLEANMAN) && !empty(CLEANMAN)
|
||||
cleandir: cleanman
|
||||
cleanman:
|
||||
rm -f ${CLEANMAN}
|
||||
.endif
|
||||
.endif
|
66
20150418/mk/manifest.mk
Normal file
66
20150418/mk/manifest.mk
Normal file
@ -0,0 +1,66 @@
|
||||
# $Id: manifest.mk,v 1.2 2014/10/31 18:06:17 sjg Exp $
|
||||
#
|
||||
# @(#) Copyright (c) 2014, 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
|
||||
#
|
||||
|
||||
# generate mtree style manifest supported by makefs in FreeBSD
|
||||
|
||||
# input looks like
|
||||
# MANIFEST= my.mtree
|
||||
# for each MANIFEST we have a list of dirs
|
||||
# ${MANIFEST}.DIRS += bin sbin usr/bin ...
|
||||
# for each dir we have a ${MANIFEST}.SRCS.$dir
|
||||
# that provides the absolute path to the contents
|
||||
# ${MANIFEST}.SRCS.bin += ${OBJTOP}/bin/sh/sh
|
||||
# ${MANIFEST}.SYMLINKS is a list of src target pairs
|
||||
# for each file/dir there are a number of attributes
|
||||
# UID GID MODE FLAGS
|
||||
# which can be set per dir, per file or we use defaults
|
||||
# eg.
|
||||
# MODE.sbin = 550
|
||||
# MODE.usr/sbin = 550
|
||||
# MODE.dirs = 555
|
||||
# means that sbin and usr/sbin get 550 all other dirs get 555
|
||||
# MODE.usr/bin/passwd = 4555
|
||||
# MODE.usr/bin.files = 555
|
||||
# MODE.usr/sbin.files = 500
|
||||
# means passwd gets 4555 other files in usr/bin get 555 and
|
||||
# files in usr/sbin get 500
|
||||
# STORE defaults to basename of src and target directory
|
||||
# but we can use
|
||||
# ${MANIFEST}.SRCS.sbin += ${OBJTOP}/bin/sh-static/sh-static
|
||||
# STORE.sbin/sh-static = sbin/sh
|
||||
#
|
||||
# the above is a little overkill but means we can easily adapt to
|
||||
# different formats
|
||||
|
||||
UID.dirs ?= 0
|
||||
GID.dirs ?= 0
|
||||
MODE.dirs ?= 775
|
||||
FLAGS.dirs ?=
|
||||
|
||||
UID.files ?= 0
|
||||
GID.files ?= 0
|
||||
MODE.files ?= 555
|
||||
|
||||
# a is attribute name d is dirname
|
||||
M_DIR_ATTR = L:@a@$${$$a.$$d:U$${$$a.dirs}}@
|
||||
# as above and s is set to the name we store f as
|
||||
M_FILE_ATTR = L:@a@$${$$a.$$s:U$${$$a.$$d.files:U$${$$a.files}}}@
|
||||
|
||||
# this produces the body of the manifest
|
||||
# there should typically be a header prefixed
|
||||
_GEN_MTREE_MANIFEST_USE: .USE
|
||||
@(${${.TARGET}.DIRS:O:u:@d@echo '$d type=dir uid=${UID:${M_DIR_ATTR}} gid=${GID:${M_DIR_ATTR}} mode=${MODE:${M_DIR_ATTR}} ${FLAGS:${M_DIR_ATTR}}';@} \
|
||||
${${.TARGET}.DIRS:O:u:@d@${${.TARGET}.SRCS.$d:O:u:@f@echo '${s::=${STORE.$d/${f:T}:U$d/${f:T}}}$s contents="$f" type=file uid=${UID:${M_FILE_ATTR}} gid=${GID:${M_FILE_ATTR}} mode=${MODE:${M_FILE_ATTR}} ${FLAGS:${M_FILE_ATTR}}';@}@} \
|
||||
set ${${.TARGET}.SYMLINKS}; while test $$# -ge 2; do echo "$$2 type=link link=$$1"; shift 2; done) > ${.TARGET}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user