├── CVS ├── Repository ├── Root └── Entries ├── mk ├── CVS │ ├── Repository │ ├── Root │ └── Entries ├── bsd.port.mk ├── bsd.port.arch.mk ├── bsd.port.subdir.mk ├── bsd.xorg.mk ├── bsd.xconf.mk ├── bsd.sys.mk ├── bsd.dep.mk ├── bsd.man.mk ├── bsd.obj.mk ├── bsd.subdir.mk ├── bsd.regress.mk ├── bsd.own.mk └── sys.mk ├── .travis.yml ├── expandchildren.h ├── cond_int.h ├── portable.h ├── README.md ├── location.h ├── lst_t.h ├── enginechoice.h ├── init.h ├── symtable.h ├── targequiv.h ├── cmd_exec.h ├── lstAddNew.c ├── parsevar.h ├── main.h ├── compat.h ├── lstRequeue.c ├── init.c ├── dump.h ├── timestamp.c ├── enginechoice.c ├── cond.h ├── pathnames.h ├── lstMember.c ├── make.h ├── for.h ├── lstInit.c ├── lstInt.h ├── parse.h ├── lstReplace.c ├── lstSucc.c ├── var_int.h ├── direxpand.h ├── memory.h ├── varname.c ├── arch.h ├── node_int.h ├── lstFindFrom.c ├── extern.h ├── varname.h ├── lstDeQueue.c ├── lstDupl.c ├── lstDestroy.c ├── error.h ├── lstForEachFrom.c ├── varmodifiers.h ├── ohash.h ├── timestamp.h ├── targ.h ├── regress.c ├── suff.h ├── lstRemove.c ├── str.h ├── lstConcatDestroy.c ├── lstAppend.c ├── stats.h ├── lstInsert.c ├── defines.h ├── garray.h ├── lstConcat.c ├── job.h ├── cmd_exec.c ├── lowparse.h ├── generate.c ├── memory.c ├── config.h ├── error.c ├── dir.h └── engine.h /CVS/Repository: -------------------------------------------------------------------------------- 1 | src/usr.bin/make 2 | -------------------------------------------------------------------------------- /mk/CVS/Repository: -------------------------------------------------------------------------------- 1 | src/share/mk 2 | -------------------------------------------------------------------------------- /CVS/Root: -------------------------------------------------------------------------------- 1 | anoncvs@ftp4.usa.openbsd.org:/cvs 2 | -------------------------------------------------------------------------------- /mk/CVS/Root: -------------------------------------------------------------------------------- 1 | anoncvs@anoncvs4.usa.openbsd.org:/cvs 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | os: 3 | - linux 4 | - osx 5 | compiler: 6 | - clang 7 | - gcc 8 | -------------------------------------------------------------------------------- /mk/bsd.port.mk: -------------------------------------------------------------------------------- 1 | .if !defined(BSD_OWN_MK) 2 | . include 3 | .endif 4 | PORTSDIR?= /usr/ports 5 | .include "${PORTSDIR}/infrastructure/mk/bsd.port.mk" 6 | -------------------------------------------------------------------------------- /mk/bsd.port.arch.mk: -------------------------------------------------------------------------------- 1 | .if !defined(BSD_OWN_MK) 2 | . include 3 | .endif 4 | PORTSDIR?= /usr/ports 5 | .include "${PORTSDIR}/infrastructure/mk/bsd.port.arch.mk" 6 | -------------------------------------------------------------------------------- /mk/bsd.port.subdir.mk: -------------------------------------------------------------------------------- 1 | .if !defined(BSD_OWN_MK) 2 | . include 3 | .endif 4 | PORTSDIR?= /usr/ports 5 | .include "${PORTSDIR}/infrastructure/mk/bsd.port.subdir.mk" 6 | -------------------------------------------------------------------------------- /mk/bsd.xorg.mk: -------------------------------------------------------------------------------- 1 | # $OpenBSD: bsd.xorg.mk,v 1.2 2006/12/31 10:38:18 matthieu Exp $ 2 | .include 3 | X11BASE?= /usr/X11R6 4 | X11ETC?= /etc/X11 5 | .if exists(${X11BASE}/share/mk/bsd.xorg.mk) 6 | . include "${X11BASE}/share/mk/bsd.xorg.mk" 7 | .endif 8 | -------------------------------------------------------------------------------- /mk/bsd.xconf.mk: -------------------------------------------------------------------------------- 1 | # $OpenBSD: bsd.xconf.mk,v 1.1 2008/03/25 23:35:56 matthieu Exp $ 2 | .include 3 | X11BASE?= /usr/X11R6 4 | X11ETC?= /etc/X11 5 | .if exists(${X11BASE}/share/mk/bsd.xconf.mk) 6 | . include "${X11BASE}/share/mk/bsd.xconf.mk" 7 | .endif 8 | -------------------------------------------------------------------------------- /mk/bsd.sys.mk: -------------------------------------------------------------------------------- 1 | # $OpenBSD: bsd.sys.mk,v 1.13 2017/07/09 14:04:50 espie Exp $ 2 | # $NetBSD: bsd.sys.mk,v 1.2 1995/12/13 01:25:07 cgd Exp $ 3 | # 4 | # Overrides used for OpenBSD source tree builds. 5 | 6 | #CFLAGS+= -Werror 7 | 8 | .if defined(DESTDIR) 9 | CPPFLAGS+= -nostdinc -idirafter ${DESTDIR}/usr/include 10 | CXXFLAGS+= -idirafter ${DESTDIR}/usr/include/g++ 11 | .endif 12 | 13 | .y.c: 14 | ${YACC.y} -o ${.TARGET} ${.IMPSRC} 15 | -------------------------------------------------------------------------------- /expandchildren.h: -------------------------------------------------------------------------------- 1 | #ifndef EXPANDCHILDREN_H 2 | #define EXPANDCHILDREN_H 3 | /* $OpenBSD: expandchildren.h,v 1.1 2020/01/13 14:05:21 espie Exp $ */ 4 | 5 | extern void LinkParent(GNode *, GNode *); 6 | 7 | /* partial expansion of children. */ 8 | extern void expand_children_from(GNode *, LstNode); 9 | /* expand_all_children(gn): 10 | * figure out all variable/wildcards expansions in gn. 11 | * TODO pretty sure this is independent from the main suff module. 12 | */ 13 | #define expand_all_children(gn) \ 14 | expand_children_from(gn, Lst_First(&(gn)->children)) 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /cond_int.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: cond_int.h,v 1.6 2010/07/19 19:46:44 espie Exp $ */ 2 | 3 | /* List of all keywords recognized by the make parser */ 4 | #define COND_IF "if" 5 | #define COND_IFDEF "ifdef" 6 | #define COND_IFNDEF "ifndef" 7 | #define COND_IFMAKE "ifmake" 8 | #define COND_IFNMAKE "ifnmake" 9 | #define COND_ELSE "else" 10 | #define COND_ELIF "elif" 11 | #define COND_ELIFDEF "elifdef" 12 | #define COND_ELIFNDEF "elifndef" 13 | #define COND_ELIFMAKE "elifmake" 14 | #define COND_ELIFNMAKE "elifnmake" 15 | #define COND_ENDIF "endif" 16 | #define COND_FOR "for" 17 | #define COND_ENDFOR "endfor" 18 | #define COND_INCLUDE "include" 19 | #define COND_UNDEF "undef" 20 | #define COND_POISON "poison" 21 | -------------------------------------------------------------------------------- /mk/CVS/Entries: -------------------------------------------------------------------------------- 1 | /Makefile/1.14/Mon Oct 26 10:43:42 2015// 2 | /bsd.README/1.85/Tue Sep 22 10:31:46 2020// 3 | /bsd.dep.mk/1.24/Tue Oct 17 19:31:56 2017// 4 | /bsd.lib.mk/1.101/Tue May 26 17:44:23 2020// 5 | /bsd.man.mk/1.42/Fri Jul 21 15:18:35 2017// 6 | /bsd.obj.mk/1.19/Tue Jan 24 03:22:13 2017// 7 | /bsd.own.mk/1.210/Sun May 2 22:32:31 2021// 8 | /bsd.port.arch.mk/1.1/Sat Sep 24 07:26:01 2011// 9 | /bsd.port.mk/1.95/Sat Sep 24 07:26:01 2011// 10 | /bsd.port.subdir.mk/1.9/Sat Sep 24 07:26:01 2011// 11 | /bsd.regress.mk/1.23/Thu Dec 17 14:54:15 2020// 12 | /bsd.subdir.mk/1.22/Sat Oct 8 09:43:46 2016// 13 | /bsd.sys.mk/1.13/Sun Jul 9 14:04:50 2017// 14 | /bsd.xconf.mk/1.1/Tue Mar 25 23:35:56 2008// 15 | /bsd.xorg.mk/1.2/Sun Dec 31 10:38:18 2006// 16 | /sys.mk/1.89/Sat Feb 6 21:26:19 2021// 17 | /bsd.prog.mk/1.83/Thu Jul 22 14:11:06 2021// 18 | D 19 | -------------------------------------------------------------------------------- /portable.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is was written by Brian Callahan 3 | * and released into the Public Domain. 4 | */ 5 | 6 | #include 7 | #include "ohash.h" 8 | 9 | #ifdef NEED_ASPRINTF 10 | int asprintf(char **, const char *, ...); 11 | #endif 12 | 13 | #ifdef NEED_FGETLN 14 | char *fgetln(FILE *, size_t *); 15 | #endif 16 | 17 | #ifdef NEED_REALLOCARRAY 18 | void *reallocarray(void *, size_t, size_t); 19 | #endif 20 | 21 | #ifdef NEED_STRLCPY 22 | size_t strlcpy(char *, const char *, size_t); 23 | #endif 24 | 25 | #ifdef NEED_STRTONUM 26 | long long strtonum(const char *, long long, long long, const char **); 27 | #endif 28 | 29 | #ifdef NEED_PROGNAME 30 | char *__progname; 31 | #endif 32 | 33 | #ifndef _NSIG 34 | #define _NSIG 33 35 | #endif 36 | 37 | #ifdef NEED_SYS_SIGNAME 38 | extern const char *const sys_signame[]; 39 | #endif 40 | 41 | #ifndef SIGINFO 42 | #define SIGINFO 29 43 | #endif 44 | 45 | /* From OpenBSD sys/time.h */ 46 | #ifndef timespeccmp 47 | #define timespeccmp(tsp, usp, cmp) \ 48 | (((tsp)->tv_sec == (usp)->tv_sec) ? \ 49 | ((tsp)->tv_nsec cmp (usp)->tv_nsec) : \ 50 | ((tsp)->tv_sec cmp (usp)->tv_sec)) 51 | #endif 52 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | make 2 | ==== 3 | `make`, or `omake`, is a portable version of the 4 | [OpenBSD](https://www.openbsd.org/) 5 | make program. 6 | It is currently synced with OpenBSD 6.9 -current as of July 22, 2021. 7 | 8 | This version of make is suitable for ensuring standard Make compliance, for 9 | older Unix machines that do not have a free Make or have a very old Make, or 10 | for users that do not need the bells and whistles of `bmake` or `GNU Make`. 11 | 12 | `make` has no dependencies other than libc. It is known to build and run on all 13 | *BSD flavors, Linux, Mac OS X, Cygwin, AIX, and Solaris. It is very likely to 14 | run on other Unix flavors; please let me know if you are using this on a Unix 15 | not listed here so that I may add it to the list. 16 | 17 | Compiling 18 | --------- 19 | To build, run: 20 | ``` 21 | $ ./configure 22 | $ make 23 | # make install 24 | ``` 25 | 26 | Working compilers 27 | ----------------- 28 | The following compilers are known to build `make`: 29 | * Clang 30 | * GCC 31 | * PCC 32 | * TinyCC 33 | * CParser 34 | * CompCert 35 | * lacc 36 | 37 | It is likely that any C99 compiler will work. 38 | 39 | Testing 40 | ------- 41 | Tested on Linux and Mac OS X using TravisCI. *BSD, Cygwin, AIX, and Solaris 42 | testing done manually. AIX 5.1L and Solaris 8 are used to help ensure backwards 43 | compatibility. 44 | 45 | Licensing 46 | --------- 47 | All C files other than `portable.c` are 2- and 3-clause BSD licensed. 48 | `portable.c` has a combination of Public Domain, ISC, and 3-clause BSD 49 | licensed code. 50 | -------------------------------------------------------------------------------- /location.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: location.h,v 1.1 2012/03/22 13:47:12 espie Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 2012 Marc Espie. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 16 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 19 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | struct Location_ { 29 | const char *fname; /* Name of file */ 30 | unsigned long lineno; /* Line number */ 31 | }; 32 | 33 | #define LOCATION_TYPE 34 | -------------------------------------------------------------------------------- /lst_t.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: lst_t.h,v 1.3 2010/07/19 19:46:44 espie Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 2001 Marc Espie. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 16 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 19 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | typedef struct List_ { 29 | LstNode firstPtr; /* first node in list */ 30 | LstNode lastPtr; /* last node in list */ 31 | } LIST; 32 | 33 | #define LIST_TYPE 34 | -------------------------------------------------------------------------------- /enginechoice.h: -------------------------------------------------------------------------------- 1 | #ifndef ENGINECHOICE_H 2 | #define ENGINECHOICE_H 3 | 4 | /* $OpenBSD: enginechoice.h,v 1.2 2021/03/04 09:32:49 espie Exp $ */ 5 | /* 6 | * Copyright (c) 2020 Marc Espie. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 21 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | extern void engine_run_list(Lst, bool *, bool *); 30 | extern void engine_node_updated(GNode *); 31 | extern void choose_engine(bool); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /mk/bsd.dep.mk: -------------------------------------------------------------------------------- 1 | # $OpenBSD: bsd.dep.mk,v 1.24 2017/10/17 19:31:56 naddy Exp $ 2 | # $NetBSD: bsd.dep.mk,v 1.12 1995/09/27 01:15:09 christos Exp $ 3 | 4 | .if !target(depend) 5 | depend: 6 | @: 7 | .endif 8 | 9 | # relies on DEPS defined by bsd.lib.mk and bsd.prog.mk 10 | .if defined(DEPS) && !empty(DEPS) 11 | # catch22: don't include potentially bogus files we are going to clean 12 | . if !(make(clean) || make(cleandir) || make(obj)) 13 | . for o in ${DEPS} 14 | sinclude $o 15 | . endfor 16 | . endif 17 | .endif 18 | 19 | CFLAGS += -MD -MP 20 | CXXFLAGS += -MD -MP 21 | 22 | # libraries need some special love 23 | DFLAGS += -MD -MP -MT $*.o -MT $*.po -MT $*.so -MT $*.do 24 | 25 | .if !target(tags) 26 | . if defined(SRCS) 27 | tags: ${SRCS} _SUBDIRUSE 28 | -cd ${.CURDIR}; ${CTAGS} -f /dev/stdout -d ${.ALLSRC:N*.h} | \ 29 | sed "s;\${.CURDIR}/;;" > tags 30 | . else 31 | tags: 32 | . endif 33 | .endif 34 | 35 | # explicitly tag most source files 36 | .for i in ${SRCS:N*.[hyl]:N*.sh} ${_LEXINTM} ${_YACCINTM} 37 | # assume libraries 38 | ${i:R:S/$/.o/} ${i:R:S/$/.po/} ${i:R:S/$/.so/} ${i:R:S/$/.do/}: $i 39 | .endfor 40 | 41 | # give us better rules for yacc 42 | 43 | .if ${YFLAGS:M-d} 44 | # loop may not trigger 45 | . for f in ${SRCS:M*.y} 46 | ${f:.y=.c} ${f:.y=.h}: $f 47 | ${YACC.y} -o ${f:.y=.c} ${.IMPSRC} 48 | . endfor 49 | CLEANFILES += ${SRCS:M*.y:.y=.h} 50 | .endif 51 | 52 | .if defined(SRCS) 53 | cleandir: cleandepend 54 | cleandepend: 55 | rm -f ${.CURDIR}/tags 56 | .endif 57 | 58 | CLEANFILES += ${DEPS} 59 | 60 | BUILDFIRST ?= 61 | BUILDAFTER ?= 62 | .if !empty(BUILDAFTER) 63 | . for i in ${BUILDFIRST} ${_LEXINTM} ${_YACCINTM} 64 | . if !exists($i) 65 | ${BUILDAFTER}: $i 66 | . endif 67 | . endfor 68 | .endif 69 | .PHONY: cleandepend 70 | -------------------------------------------------------------------------------- /init.h: -------------------------------------------------------------------------------- 1 | #ifndef INIT_H 2 | #define INIT_H 3 | /* $OpenBSD: init.h,v 1.3 2010/07/19 19:46:44 espie Exp $ */ 4 | 5 | /* 6 | * Copyright (c) 2001 Marc Espie. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 21 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | /* General init/cleanup functions. Handles all modules init/cleanup in 31 | * one single place. This also simplifies main's dependencies on other 32 | * modules. 33 | */ 34 | extern void Init(void); 35 | extern void End(void); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /symtable.h: -------------------------------------------------------------------------------- 1 | #ifndef SYMTABLE_H 2 | #define SYMTABLE_H 3 | /* $OpenBSD: symtable.h,v 1.5 2019/12/21 15:31:54 espie Exp $ */ 4 | 5 | /* 6 | * Copyright (c) 2001 Marc Espie. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 21 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #define LOCAL_SIZE 7 31 | 32 | /* SymTable is private to var.c, but is declared here to allow for 33 | local declaration of symbol tables 34 | */ 35 | struct SymTable_ { 36 | char *locals[LOCAL_SIZE]; 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /mk/bsd.man.mk: -------------------------------------------------------------------------------- 1 | # $OpenBSD: bsd.man.mk,v 1.42 2017/07/21 15:18:35 espie Exp $ 2 | # $NetBSD: bsd.man.mk,v 1.23 1996/02/10 07:49:33 jtc Exp $ 3 | # @(#)bsd.man.mk 5.2 (Berkeley) 5/11/90 4 | 5 | .if !target(.MAIN) 6 | . if exists(${.CURDIR}/../Makefile.inc) 7 | . include "${.CURDIR}/../Makefile.inc" 8 | . endif 9 | 10 | .MAIN: all 11 | .endif 12 | 13 | BEFOREMAN?= 14 | 15 | # Add / so that we don't have to specify it. 16 | .if defined(MANSUBDIR) && !empty(MANSUBDIR) 17 | MANSUBDIR:=${MANSUBDIR:S,^,/,:S,$,/,} 18 | .else 19 | MANSUBDIR=/ 20 | .endif 21 | 22 | # Files contained in ${BEFOREMAN} must be built before generating any 23 | # manual page source code. 24 | .for page in ${MAN} 25 | . if target(${page}) 26 | ${page}: ${BEFOREMAN} 27 | . endif 28 | .endfor 29 | 30 | # Install the real manuals. 31 | .for page in ${MAN} 32 | . for sub in ${MANSUBDIR} 33 | _MAN_INST=${DESTDIR}${MANDIR}${page:E}${sub}${page:T} 34 | ${_MAN_INST}: ${page} 35 | ${INSTALL} ${INSTALL_COPY} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \ 36 | ${.ALLSRC} ${.TARGET} 37 | 38 | maninstall: ${_MAN_INST} 39 | 40 | # XXX not really a phony target, but force installation each time 41 | # maninstall is run. 42 | .PHONY: ${_MAN_INST} 43 | . endfor 44 | .endfor 45 | 46 | # Install the manual hardlinks, if any. 47 | maninstall: 48 | .if defined(MLINKS) && !empty(MLINKS) 49 | . for sub in ${MANSUBDIR} 50 | . for lnk file in ${MLINKS} 51 | @l=${DESTDIR}${MANDIR}${lnk:E}${sub}${lnk}; \ 52 | t=${DESTDIR}${MANDIR}${file:E}${sub}${file}; \ 53 | echo $$t -\> $$l; \ 54 | rm -f $$t; ln $$l $$t; 55 | . endfor 56 | . endfor 57 | .endif 58 | 59 | # Explicitly list ${BEFOREMAN} to get it done even if ${MAN} is empty. 60 | all: ${BEFOREMAN} ${MAN} 61 | 62 | manlint: ${MAN} 63 | .if defined(MAN) && !empty(MAN) 64 | mandoc -Tlint ${.ALLSRC} 65 | .endif 66 | 67 | .PHONY: manlint 68 | -------------------------------------------------------------------------------- /targequiv.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: targequiv.h,v 1.2 2010/07/19 19:46:44 espie Exp $ */ 2 | /* 3 | * Copyright (c) 2007-2008 Marc Espie. 4 | * 5 | * Extensive code changes for the OpenBSD project. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 20 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #ifndef TARGEQUIV_H 29 | #define TARGEQUIV_H 30 | extern void look_harder_for_target(GNode *); 31 | extern void Targ_setdirs(const char *, const char *); 32 | extern bool is_sibling(GNode *, GNode *); 33 | extern void kludge_look_harder_for_target(GNode *); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /mk/bsd.obj.mk: -------------------------------------------------------------------------------- 1 | # $OpenBSD: bsd.obj.mk,v 1.19 2017/01/24 03:22:13 tb Exp $ 2 | # $NetBSD: bsd.obj.mk,v 1.9 1996/04/10 21:08:05 thorpej Exp $ 3 | 4 | .if !target(obj) 5 | . if defined(NOOBJ) 6 | obj: 7 | . else 8 | 9 | . if defined(MAKEOBJDIR) 10 | __objdir= ${MAKEOBJDIR} 11 | . else 12 | __objdir= obj 13 | . endif 14 | 15 | _SUBDIRUSE: 16 | 17 | obj! _SUBDIRUSE 18 | @cd ${.CURDIR}; \ 19 | umask ${WOBJUMASK}; \ 20 | here=`/bin/pwd`; bsdsrcdir=`cd ${BSDSRCDIR}; /bin/pwd`; \ 21 | subdir=$${here#$${bsdsrcdir}/}; \ 22 | if [[ `id -u` -eq 0 && ${BUILDUSER} != root ]]; then \ 23 | SETOWNER="chown -h ${BUILDUSER}:${WOBJGROUP}"; \ 24 | if [[ $$here != $$subdir ]]; then \ 25 | _mkdirs() { \ 26 | su ${BUILDUSER} -c "mkdir -p $$1"; \ 27 | }; \ 28 | MKDIRS=_mkdirs; \ 29 | fi; \ 30 | elif [[ `id` == *'('${WOBJGROUP}')'* && $$here == $$subdir ]]; then \ 31 | SETOWNER="chown :${WOBJGROUP}"; \ 32 | else \ 33 | SETOWNER=:; \ 34 | fi; \ 35 | [[ -z $$MKDIRS ]] && MKDIRS="mkdir -p"; \ 36 | if [[ $$here != $$subdir ]]; then \ 37 | dest=${BSDOBJDIR}/$$subdir ; \ 38 | echo "$$here/${__objdir} -> $$dest"; \ 39 | if [[ ! -L ${__objdir} || `readlink ${__objdir}` != $$dest ]]; \ 40 | then \ 41 | [[ -e ${__objdir} ]] && rm -rf ${__objdir}; \ 42 | ln -sf $$dest ${__objdir}; \ 43 | $$SETOWNER ${__objdir}; \ 44 | fi; \ 45 | if [[ -d ${BSDOBJDIR} ]]; then \ 46 | [[ -d $$dest ]] || $$MKDIRS $$dest; \ 47 | else \ 48 | if [[ -e ${BSDOBJDIR} ]]; then \ 49 | echo "${BSDOBJDIR} is not a directory"; \ 50 | else \ 51 | echo "${BSDOBJDIR} does not exist"; \ 52 | fi; \ 53 | fi; \ 54 | else \ 55 | dest=$$here/${__objdir} ; \ 56 | if [[ ! -d ${__objdir} ]]; then \ 57 | echo "making $$dest" ; \ 58 | $$MKDIRS $$dest; \ 59 | $$SETOWNER $$dest; \ 60 | fi ; \ 61 | fi; 62 | . endif 63 | .endif 64 | 65 | .include 66 | -------------------------------------------------------------------------------- /cmd_exec.h: -------------------------------------------------------------------------------- 1 | #ifndef CMD_EXEC_H 2 | #define CMD_EXEC_H 3 | /* $OpenBSD: cmd_exec.h,v 1.4 2010/07/19 19:46:43 espie Exp $ */ 4 | 5 | /* 6 | * Copyright (c) 2001 Marc Espie. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 21 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | /* output = Cmd_Exec(cmd, &err); 31 | * execute the command in cmd, return the output of that command as 32 | * a string. If an error occurs, Cmd_Exec returns an empty string, 33 | * and err is filled with the reason for the command failure. 34 | * The output result should always be freed by the caller. */ 35 | extern char *Cmd_Exec(const char *, char **); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /lstAddNew.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: lstAddNew.c,v 1.8 2010/07/19 19:46:44 espie Exp $ */ 2 | /* ex:ts=8 sw=4: 3 | */ 4 | 5 | /* 6 | * Copyright (c) 1999 Marc Espie. 7 | * 8 | * Code written for the OpenBSD project. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 23 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #include "lstInt.h" 33 | #include 34 | 35 | /* Add datum to the end of a list only if it wasn't there already. 36 | * Returns false if datum was already there. 37 | */ 38 | bool 39 | Lst_AddNew(Lst l, void *d) 40 | { 41 | if (Lst_Member(l, d) != NULL) 42 | return false; 43 | else { 44 | Lst_AtEnd(l, d); 45 | return true; 46 | } 47 | } 48 | 49 | -------------------------------------------------------------------------------- /parsevar.h: -------------------------------------------------------------------------------- 1 | #ifndef PARSEVAR_H 2 | #define PARSEVAR_H 3 | /* $OpenBSD: parsevar.h,v 1.5 2010/07/19 19:46:44 espie Exp $ */ 4 | /* 5 | * Copyright (c) 2001 Marc Espie. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 20 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /* parsevar 30 | * Functions to parse variable assignments 31 | */ 32 | 33 | /* wasvar = Parse_As_Var_Assignment(str); 34 | * Parses variable assignment str. 35 | * Returns false if this is something else. */ 36 | extern bool Parse_As_Var_Assignment(const char *); 37 | /* wasvar = Parse_CmdlineVar(str, ctxt); 38 | * Parses variable assignment str, given on the command line. 39 | * Returns false if this is something else. */ 40 | extern bool Parse_CmdlineVar(const char *); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /main.h: -------------------------------------------------------------------------------- 1 | #ifndef MAIN_H 2 | #define MAIN_H 3 | /* $OpenBSD: main.h,v 1.6 2020/01/13 14:51:50 espie Exp $ */ 4 | 5 | /* 6 | * Copyright (c) 2001 Marc Espie. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 21 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | /* main 30 | * User interface to make. 31 | */ 32 | /* Main_ParseArgLine(string); 33 | * Parse string as a line of arguments, and treats them as if they 34 | * were given at make's invocation. Used to implement .MFLAGS. */ 35 | extern void Main_ParseArgLine(const char *); 36 | 37 | /* List of target names given on the command line. Needed to resolve 38 | * .if make(...) statements. */ 39 | extern Lst create; 40 | 41 | /* set_notparallel(): used to influence running mode from parse.c */ 42 | extern void set_notparallel(void); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /compat.h: -------------------------------------------------------------------------------- 1 | #ifndef COMPAT_H 2 | #define COMPAT_H 3 | /* $OpenBSD: compat.h,v 1.5 2020/01/13 15:41:53 espie Exp $ */ 4 | 5 | /* 6 | * Copyright (c) 2001 Marc Espie. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 21 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | /* compat 31 | * The routines in this module implement the full-compatibility 32 | * mode of PMake. Most of the special functionality of PMake 33 | * is available in this mode. Things not supported: 34 | * - different shells. 35 | * - friendly variable substitution. 36 | */ 37 | 38 | /* Compat_Run(to_create, &has_errors, &out_of_date); 39 | * Run the actual make engine, to create targets that need to, 40 | * return info about what we did. */ 41 | extern void Compat_Run(Lst, bool *, bool *); 42 | extern void Compat_Init(void); 43 | extern void Compat_Update(GNode *); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /lstRequeue.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: lstRequeue.c,v 1.1 2008/01/12 13:05:57 espie Exp $ */ 2 | /* 3 | * Copyright (c) 2008 Marc Espie. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 15 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 18 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | #include "lstInt.h" 27 | #include 28 | 29 | 30 | /* Lst_Requeue(l, ln): takes node ln from the list and requeue it at front. 31 | */ 32 | void 33 | Lst_Requeue(Lst l, LstNode ln) 34 | { 35 | 36 | /* already at front */ 37 | if (l->firstPtr == ln) 38 | return; 39 | /* unlink element */ 40 | if (ln->nextPtr != NULL) 41 | ln->nextPtr->prevPtr = ln->prevPtr; 42 | if (ln->prevPtr != NULL) 43 | ln->prevPtr->nextPtr = ln->nextPtr; 44 | 45 | if (l->lastPtr == ln) 46 | l->lastPtr = ln->prevPtr; 47 | 48 | /* relink at front */ 49 | ln->nextPtr = l->firstPtr; 50 | ln->prevPtr = NULL; 51 | l->firstPtr->prevPtr = ln; 52 | l->firstPtr = ln; 53 | } 54 | 55 | -------------------------------------------------------------------------------- /init.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: init.c,v 1.8 2020/01/16 16:07:18 espie Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 2001 Marc Espie. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 16 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 19 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #include 28 | #include "defines.h" 29 | #include "config.h" 30 | #include "init.h" 31 | #include "timestamp.h" 32 | #include "stats.h" 33 | #include "dir.h" 34 | #include "parse.h" 35 | #include "var.h" 36 | #include "arch.h" 37 | #include "targ.h" 38 | #include "suff.h" 39 | #include "job.h" 40 | 41 | void 42 | Init(void) 43 | { 44 | Sigset_Init(); 45 | Init_Timestamp(); 46 | Init_Stats(); 47 | Targ_Init(); 48 | Dir_Init(); /* Initialize directory structures so -I flags 49 | * can be processed correctly */ 50 | Parse_Init(); /* Need to initialize the paths of #include 51 | * directories */ 52 | Var_Init(); /* As well as the lists of variables for 53 | * parsing arguments */ 54 | Arch_Init(); 55 | Suff_Init(); 56 | } 57 | -------------------------------------------------------------------------------- /dump.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: dump.h,v 1.3 2015/01/23 22:35:57 espie Exp $ */ 2 | #ifndef _DUMP_H_ 3 | #define _DUMP_H_ 4 | 5 | /* 6 | * Copyright (c) 2012 Marc Espie. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 21 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | /* implementation of -p option */ 30 | extern void dump_data(void); 31 | 32 | /* and of graph debugging options */ 33 | extern void post_mortem(void); 34 | 35 | struct ohash; 36 | /* utility functions for both var and targ */ 37 | 38 | 39 | /* t = sort_ohash_by_name(h): 40 | * returns a NULL terminated array holding hash entries, sorted by name. 41 | * free(t) when done with it. 42 | */ 43 | extern void *sort_ohash_by_name(struct ohash *); 44 | /* t = sort_ohash(h, cmp_f); 45 | * returns a NULL terminated array holding hash entries, pass comparison 46 | * function. 47 | * free(t) when done with it. 48 | */ 49 | extern void *sort_ohash(struct ohash *, int (*)(const void *, const void *)); 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /timestamp.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: timestamp.c,v 1.10 2013/05/22 12:14:08 espie Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 2001 Marc Espie. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 16 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 19 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | #include 28 | #include 29 | #include 30 | #include "config.h" 31 | #include "defines.h" 32 | #include "timestamp.h" 33 | 34 | 35 | struct timespec starttime; 36 | 37 | int 38 | set_times(const char *f) 39 | { 40 | return utimes(f, NULL); 41 | } 42 | 43 | #define PLACEHOLDER "XXXXXXXXX " 44 | char * 45 | time_to_string(struct timespec *t) 46 | { 47 | struct tm *parts; 48 | static char buf[128]; 49 | char *s; 50 | 51 | parts = localtime(&t->tv_sec); 52 | strftime(buf, sizeof buf, "%H:%M:%S." PLACEHOLDER "%b %d, %Y", parts); 53 | s = strstr(buf, PLACEHOLDER); 54 | if (s) { 55 | snprintf(s, sizeof(PLACEHOLDER), "%09ld", t->tv_nsec); 56 | s[9] = ' '; 57 | } 58 | buf[sizeof(buf) - 1] = '\0'; 59 | return buf; 60 | } 61 | 62 | -------------------------------------------------------------------------------- /enginechoice.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: enginechoice.c,v 1.3 2021/03/04 09:34:30 espie Exp $ */ 2 | /* 3 | * Copyright (c) 2020 Marc Espie. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 15 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 18 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | #include "config.h" 27 | #include "defines.h" 28 | #include "compat.h" 29 | #include "make.h" 30 | #include "enginechoice.h" 31 | 32 | struct engine { 33 | void (*run_list)(Lst, bool *, bool *); 34 | void (*node_updated)(GNode *); 35 | void (*init)(void); 36 | } 37 | compat_engine = { Compat_Run, Compat_Update, Compat_Init }, 38 | parallel_engine = { Make_Run, Make_Update, Make_Init }, 39 | *engine; 40 | 41 | void 42 | choose_engine(bool compat) 43 | { 44 | engine = compat ? &compat_engine: ¶llel_engine; 45 | engine->init(); 46 | } 47 | 48 | void 49 | engine_run_list(Lst l, bool *has_errors, bool *out_of_date) 50 | { 51 | engine->run_list(l, has_errors, out_of_date); 52 | } 53 | 54 | void 55 | engine_node_updated(GNode *gn) 56 | { 57 | engine->node_updated(gn); 58 | } 59 | -------------------------------------------------------------------------------- /cond.h: -------------------------------------------------------------------------------- 1 | #ifndef COND_H 2 | #define COND_H 3 | /* $OpenBSD: cond.h,v 1.5 2010/07/19 19:46:44 espie Exp $ */ 4 | 5 | /* 6 | * Copyright (c) 2001 Marc Espie. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 21 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | /* cond 31 | * Parse Makefile conditionals. 32 | */ 33 | 34 | /* Values returned by Cond_Eval. */ 35 | #define COND_PARSE 0 /* Parse the next lines */ 36 | #define COND_SKIP 1 /* Skip the next lines */ 37 | #define COND_INVALID 2 /* Not a conditional statement */ 38 | #define COND_ISFOR 3 39 | #define COND_ISUNDEF 4 40 | #define COND_ISINCLUDE 5 41 | #define COND_ISPOISON 6 42 | 43 | /* whattodo = Cond_Eval(line); 44 | * Parses a conditional expression (without the leading dot), 45 | * and returns a decision value. 46 | * State is kept internally, since conditionals nest. */ 47 | extern int Cond_Eval(const char *); 48 | 49 | /* Cond_End(); 50 | * To call at end of parsing, checks that all conditionals were 51 | * closed. */ 52 | extern void Cond_End(void); 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /pathnames.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: pathnames.h,v 1.13 2019/08/22 19:37:30 espie Exp $ */ 2 | /* $NetBSD: pathnames.h,v 1.6 1996/11/06 17:59:21 christos Exp $ */ 3 | 4 | /* 5 | * Copyright (c) 1990, 1993 6 | * The Regents of the University of California. All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 3. Neither the name of the University nor the names of its contributors 17 | * may be used to endorse or promote products derived from this software 18 | * without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | * 32 | * from: @(#)pathnames.h 5.2 (Berkeley) 6/1/90 33 | */ 34 | 35 | #include 36 | #ifndef _PATH_OBJDIR 37 | #define _PATH_OBJDIR "obj" 38 | #endif /* !_PATH_OBJDIR */ 39 | #ifndef _PATH_DEFSHELLDIR 40 | #define _PATH_DEFSHELLDIR "/bin" 41 | #endif /* !_PATH_DEFSHELLDIR */ 42 | #ifndef _PATH_DEFSYSMK 43 | #define _PATH_DEFSYSMK "sys.mk" 44 | #endif /* ! _PATH_DEFSYSMK */ 45 | #ifndef _PATH_DEFSYSPATH 46 | #define _PATH_DEFSYSPATH "/usr/share/mk" 47 | #endif /* ! _PATH_DEFSYSPATH */ 48 | -------------------------------------------------------------------------------- /lstMember.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: lstMember.c,v 1.17 2010/07/19 19:46:44 espie Exp $ */ 2 | /* $NetBSD: lstMember.c,v 1.5 1996/11/06 17:59:48 christos Exp $ */ 3 | 4 | /* 5 | * Copyright (c) 1988, 1989, 1990, 1993 6 | * The Regents of the University of California. All rights reserved. 7 | * 8 | * This code is derived from software contributed to Berkeley by 9 | * Adam de Boor. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions 13 | * are met: 14 | * 1. Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * 3. Neither the name of the University nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 | * SUCH DAMAGE. 34 | */ 35 | 36 | /*- 37 | * lstMember.c -- 38 | * See if a given datum is on a given list. 39 | */ 40 | 41 | #include "lstInt.h" 42 | #include 43 | 44 | LstNode 45 | Lst_Member(Lst l, void *d) 46 | { 47 | LstNode lNode; 48 | 49 | for (lNode = l->firstPtr; lNode != NULL; lNode = lNode->nextPtr) 50 | if (lNode->datum == d) 51 | return lNode; 52 | return NULL; 53 | } 54 | -------------------------------------------------------------------------------- /make.h: -------------------------------------------------------------------------------- 1 | #ifndef _MAKE_H_ 2 | #define _MAKE_H_ 3 | 4 | /* $OpenBSD: make.h,v 1.40 2020/01/13 15:41:53 espie Exp $ */ 5 | /* $NetBSD: make.h,v 1.15 1997/03/10 21:20:00 christos Exp $ */ 6 | 7 | /* 8 | * Copyright (c) 1988, 1989, 1990, 1993 9 | * The Regents of the University of California. All rights reserved. 10 | * Copyright (c) 1989 by Berkeley Softworks 11 | * All rights reserved. 12 | * 13 | * This code is derived from software contributed to Berkeley by 14 | * Adam de Boor. 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted provided that the following conditions 18 | * are met: 19 | * 1. Redistributions of source code must retain the above copyright 20 | * notice, this list of conditions and the following disclaimer. 21 | * 2. Redistributions in binary form must reproduce the above copyright 22 | * notice, this list of conditions and the following disclaimer in the 23 | * documentation and/or other materials provided with the distribution. 24 | * 3. Neither the name of the University nor the names of its contributors 25 | * may be used to endorse or promote products derived from this software 26 | * without specific prior written permission. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 29 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 37 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38 | * SUCH DAMAGE. 39 | * 40 | * from: @(#)make.h 8.3 (Berkeley) 6/13/95 41 | */ 42 | 43 | extern void Make_Update(GNode *); 44 | extern void Make_Run(Lst, bool *, bool *); 45 | extern void Make_Init(void); 46 | extern long random_delay; 47 | extern bool nothing_left_to_build(void); 48 | 49 | #endif /* _MAKE_H_ */ 50 | -------------------------------------------------------------------------------- /for.h: -------------------------------------------------------------------------------- 1 | #ifndef FOR_H 2 | #define FOR_H 3 | /* $OpenBSD: for.h,v 1.5 2010/07/19 19:46:44 espie Exp $ */ 4 | /* 5 | * Copyright (c) 2001 Marc Espie. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 20 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | 30 | /* 31 | * for 32 | * Functions to handle loops in a makefile. 33 | */ 34 | 35 | struct For_; 36 | typedef struct For_ For; 37 | /* handle = For_Eval(line); 38 | * Evaluate for loop in line, and returns an opaque handle. 39 | * Loop lines are parsed as 40 | * ... in 41 | * assuming .for has been parsed by previous modules. 42 | * Returns NULL if this does not parse as a for loop after all. */ 43 | extern For *For_Eval(const char *); 44 | 45 | /* finished = For_Accumulate(handle, line); 46 | * Accumulate lines in a loop, until we find the matching .endfor. */ 47 | extern bool For_Accumulate(For *, const char *); 48 | 49 | /* For_Run(handle); 50 | * Runs the complete for loop, pushing back expanded lines to reparse 51 | * using Parse_FromString. */ 52 | extern void For_Run(For *); 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /lstInit.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: lstInit.c,v 1.19 2010/07/19 19:46:44 espie Exp $ */ 2 | /* $NetBSD: lstInit.c,v 1.5 1996/11/06 17:59:43 christos Exp $ */ 3 | 4 | /* 5 | * Copyright (c) 1988, 1989, 1990, 1993 6 | * The Regents of the University of California. All rights reserved. 7 | * 8 | * This code is derived from software contributed to Berkeley by 9 | * Adam de Boor. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions 13 | * are met: 14 | * 1. Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * 3. Neither the name of the University nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 | * SUCH DAMAGE. 34 | */ 35 | 36 | /*- 37 | * init.c -- 38 | * Initialize a new linked list. 39 | */ 40 | 41 | #include "lstInt.h" 42 | #include 43 | 44 | /*- 45 | *----------------------------------------------------------------------- 46 | * Lst_Init -- 47 | * Create and initialize a new list. 48 | *----------------------------------------------------------------------- 49 | */ 50 | void 51 | Lst_Init(Lst l) 52 | { 53 | l->firstPtr = NULL; 54 | l->lastPtr = NULL; 55 | } 56 | 57 | -------------------------------------------------------------------------------- /lstInt.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: lstInt.h,v 1.15 2010/07/19 19:46:44 espie Exp $ */ 2 | /* $NetBSD: lstInt.h,v 1.7 1996/11/06 17:59:44 christos Exp $ */ 3 | 4 | /* 5 | * Copyright (c) 1988, 1989, 1990, 1993 6 | * The Regents of the University of California. All rights reserved. 7 | * 8 | * This code is derived from software contributed to Berkeley by 9 | * Adam de Boor. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions 13 | * are met: 14 | * 1. Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * 3. Neither the name of the University nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 | * SUCH DAMAGE. 34 | * 35 | * from: @(#)lstInt.h 8.1 (Berkeley) 6/6/93 36 | */ 37 | 38 | /*- 39 | * lstInt.h -- 40 | * Internals for the list library 41 | */ 42 | #ifndef _LSTINT_H_ 43 | #define _LSTINT_H_ 44 | 45 | #include "config.h" 46 | #include "defines.h" 47 | #include "lst.h" 48 | 49 | /* 50 | * PAlloc(var, ptype) -- 51 | * Allocate a pointer-typedef structure 'ptype' into the variable 'var' 52 | */ 53 | #define PAlloc(var,ptype) var = (ptype) emalloc (sizeof (*var)) 54 | 55 | #endif /* _LSTINT_H_ */ 56 | -------------------------------------------------------------------------------- /parse.h: -------------------------------------------------------------------------------- 1 | #ifndef PARSE_H 2 | #define PARSE_H 3 | /* $OpenBSD: parse.h,v 1.7 2015/11/29 09:17:12 espie Exp $ */ 4 | /* 5 | * Copyright (c) 2001 Marc Espie. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 20 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /* parse 30 | * Functions to parse Makefiles and fragments. 31 | */ 32 | 33 | extern void Parse_Init(void); 34 | extern void Parse_End(void); 35 | extern Lst systemIncludePath; 36 | extern Lst userIncludePath; 37 | 38 | /* Parse_File(filename, filehandle); 39 | * Parses stream filehandle, use filename when reporting error 40 | * messages. Builds a graph of GNode and Suffixes. This modules 41 | * acquires ownership of the filename and filehandle, and will 42 | * free/close them when it sees fit. */ 43 | extern void Parse_File(const char *, FILE *); 44 | 45 | /* Parse_AddIncludeDir(dir); 46 | * Adds directory dir to user include"" path (copy the string). */ 47 | extern void Parse_AddIncludeDir(const char *); 48 | 49 | /* Parse_MainName(lst); 50 | * Adds set of main targets to create to list lst. Errors out if no 51 | * target exists. */ 52 | extern void Parse_MainName(Lst); 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /lstReplace.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: lstReplace.c,v 1.18 2010/07/19 19:46:44 espie Exp $ */ 2 | /* $NetBSD: lstReplace.c,v 1.5 1996/11/06 17:59:51 christos Exp $ */ 3 | 4 | /* 5 | * Copyright (c) 1988, 1989, 1990, 1993 6 | * The Regents of the University of California. All rights reserved. 7 | * 8 | * This code is derived from software contributed to Berkeley by 9 | * Adam de Boor. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions 13 | * are met: 14 | * 1. Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * 3. Neither the name of the University nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 | * SUCH DAMAGE. 34 | */ 35 | 36 | /*- 37 | * LstReplace.c -- 38 | * Replace the datum in a node with a new datum 39 | */ 40 | 41 | #include "lstInt.h" 42 | #include 43 | 44 | /*- 45 | *----------------------------------------------------------------------- 46 | * Lst_Replace -- 47 | * Replace the datum in the given node with the new datum 48 | *----------------------------------------------------------------------- 49 | */ 50 | void 51 | Lst_Replace(LstNode ln, void *d) 52 | { 53 | if (ln != NULL) 54 | ln->datum = d; 55 | } 56 | 57 | -------------------------------------------------------------------------------- /lstSucc.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: lstSucc.c,v 1.17 2010/07/19 19:46:44 espie Exp $ */ 2 | /* $NetBSD: lstSucc.c,v 1.5 1996/11/06 17:59:52 christos Exp $ */ 3 | 4 | /* 5 | * Copyright (c) 1988, 1989, 1990, 1993 6 | * The Regents of the University of California. All rights reserved. 7 | * 8 | * This code is derived from software contributed to Berkeley by 9 | * Adam de Boor. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions 13 | * are met: 14 | * 1. Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * 3. Neither the name of the University nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 | * SUCH DAMAGE. 34 | */ 35 | 36 | /*- 37 | * LstSucc.c -- 38 | * return the successor to a given node 39 | */ 40 | 41 | #include "lstInt.h" 42 | #include 43 | 44 | /*- 45 | *----------------------------------------------------------------------- 46 | * Lst_Succ -- 47 | * Return the successor to the given node on its list. 48 | * 49 | * Results: 50 | * The successor of the node, if it exists. 51 | * 52 | *----------------------------------------------------------------------- 53 | */ 54 | LstNode 55 | Lst_Succ(LstNode ln) 56 | { 57 | if (ln == NULL) 58 | return NULL; 59 | else 60 | return ln->nextPtr; 61 | } 62 | 63 | -------------------------------------------------------------------------------- /var_int.h: -------------------------------------------------------------------------------- 1 | #ifndef VAR_INT_H 2 | #define VAR_INT_H 3 | /* $OpenBSD: var_int.h,v 1.2 2010/07/19 19:46:44 espie Exp $ */ 4 | /* 5 | * Copyright (c) 2001 Marc Espie. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 20 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /* Special variable names for hashing */ 30 | #define TARGET "@" /* Target of dependency */ 31 | #define OODATE "?" /* All out-of-date sources */ 32 | #define ALLSRC ">" /* All sources */ 33 | #define IMPSRC "<" /* Source implied by transformation */ 34 | #define PREFIX "*" /* Common prefix */ 35 | #define ARCHIVE "!" /* Archive in "archive(member)" syntax */ 36 | #define MEMBER "%" /* Member in "archive(member)" syntax */ 37 | #define LONGTARGET ".TARGET" 38 | #define LONGOODATE ".OODATE" 39 | #define LONGALLSRC ".ALLSRC" 40 | #define LONGIMPSRC ".IMPSRC" 41 | #define LONGPREFIX ".PREFIX" 42 | #define LONGARCHIVE ".ARCHIVE" 43 | #define LONGMEMBER ".MEMBER" 44 | 45 | /* System V extended variables (get directory/file part) */ 46 | #define FTARGET "@F" 47 | #define DTARGET "@D" 48 | #define FIMPSRC " 28 | #include "config.h" 29 | #include "defines.h" 30 | #include "var.h" 31 | #include "buf.h" 32 | #include "varname.h" 33 | 34 | const char * 35 | VarName_Get(const char *start, struct Name *name, SymTable *ctxt, bool err, 36 | const char *(*cont)(const char *)) 37 | { 38 | const char *p; 39 | size_t len; 40 | 41 | p = cont(start); 42 | /* If we don't want recursive variables, we skip over '$' */ 43 | if (!FEATURES(FEATURE_RECVARS)) { 44 | while (*p == '$') 45 | p = cont(p+1); 46 | } 47 | if (*p != '$') { 48 | name->s = start; 49 | name->e = p; 50 | name->tofree = false; 51 | return p; 52 | } else { 53 | BUFFER buf; 54 | Buf_Init(&buf, MAKE_BSIZE); 55 | for (;;) { 56 | Buf_Addi(&buf, start, p); 57 | if (*p != '$') { 58 | name->s = (const char *)Buf_Retrieve(&buf); 59 | name->e = name->s + Buf_Size(&buf); 60 | name->tofree = true; 61 | return p; 62 | } 63 | start = p; 64 | Var_ParseBuffer(&buf, start, ctxt, err, &len); 65 | start += len; 66 | p = cont(start); 67 | } 68 | } 69 | } 70 | 71 | void 72 | VarName_Free(struct Name *name) 73 | { 74 | if (name->tofree) 75 | free((char *)name->s); 76 | } 77 | 78 | -------------------------------------------------------------------------------- /mk/bsd.subdir.mk: -------------------------------------------------------------------------------- 1 | # $OpenBSD: bsd.subdir.mk,v 1.22 2016/10/08 09:43:46 schwarze Exp $ 2 | # $NetBSD: bsd.subdir.mk,v 1.11 1996/04/04 02:05:06 jtc Exp $ 3 | # @(#)bsd.subdir.mk 5.9 (Berkeley) 2/1/91 4 | 5 | .if !target(.MAIN) 6 | .MAIN: all 7 | .endif 8 | 9 | # Make sure this is defined 10 | SKIPDIR?= 11 | 12 | _SUBDIRUSE: .USE 13 | .if defined(SUBDIR) 14 | @for entry in ${SUBDIR}; do \ 15 | set -e; if test -d ${.CURDIR}/$${entry}.${MACHINE}; then \ 16 | _newdir_="$${entry}.${MACHINE}"; \ 17 | else \ 18 | _newdir_="$${entry}"; \ 19 | fi; \ 20 | if test X"${_THISDIR_}" = X""; then \ 21 | _nextdir_="$${_newdir_}"; \ 22 | else \ 23 | _nextdir_="$${_THISDIR_}/$${_newdir_}"; \ 24 | fi; \ 25 | _makefile_spec_=""; \ 26 | if [ -e ${.CURDIR}/$${_newdir_}/Makefile.bsd-wrapper ]; then \ 27 | _makefile_spec_="-f Makefile.bsd-wrapper"; \ 28 | fi; \ 29 | subskipdir=''; \ 30 | for skipdir in ${SKIPDIR}; do \ 31 | subentry=$${skipdir#$${entry}}; \ 32 | if [ X$${subentry} != X$${skipdir} ]; then \ 33 | if [ X$${subentry} = X ]; then \ 34 | echo "($${_nextdir_} skipped)"; \ 35 | break; \ 36 | fi; \ 37 | subskipdir="$${subskipdir} $${subentry#/}"; \ 38 | fi; \ 39 | done; \ 40 | if [ X$${skipdir} = X -o X$${subentry} != X ]; then \ 41 | echo "===> $${_nextdir_}"; \ 42 | ${MAKE} -C ${.CURDIR}/$${_newdir_} \ 43 | SKIPDIR="$${subskipdir}" \ 44 | $${_makefile_spec_} _THISDIR_="$${_nextdir_}" \ 45 | ${MAKE_FLAGS} \ 46 | ${.TARGET:S/^real//}; \ 47 | fi; \ 48 | done 49 | 50 | ${SUBDIR}:: 51 | @set -e; if test -d ${.CURDIR}/${.TARGET}.${MACHINE}; then \ 52 | _newdir_=${.TARGET}.${MACHINE}; \ 53 | else \ 54 | _newdir_=${.TARGET}; \ 55 | fi; \ 56 | _makefile_spec_=""; \ 57 | if [ -f ${.CURDIR}/$${_newdir_}/Makefile.bsd-wrapper ]; then \ 58 | _makefile_spec_="-f Makefile.bsd-wrapper"; \ 59 | fi; \ 60 | echo "===> $${_newdir_}"; \ 61 | exec ${MAKE} -C ${.CURDIR}/$${_newdir_} ${MAKE_FLAGS} \ 62 | $${_makefile_spec_} _THISDIR_="$${_newdir_}" all 63 | .endif 64 | 65 | .if !target(install) 66 | . if !target(beforeinstall) 67 | beforeinstall: 68 | . endif 69 | . if !target(afterinstall) 70 | afterinstall: 71 | . endif 72 | install: maninstall 73 | maninstall: afterinstall 74 | afterinstall: realinstall 75 | realinstall: beforeinstall _SUBDIRUSE 76 | .endif 77 | 78 | 79 | .for t in all cleandir includes depend obj tags manlint 80 | . if !target($t) 81 | $t: _SUBDIRUSE 82 | . endif 83 | .endfor 84 | .if !target(regress) && empty(.TARGETS:Mall) 85 | regress: _SUBDIRUSE 86 | .endif 87 | .if !target(clean) && empty(.TARGETS:Mcleandir) 88 | clean: _SUBDIRUSE 89 | .endif 90 | 91 | .if !defined(BSD_OWN_MK) 92 | . include 93 | .endif 94 | -------------------------------------------------------------------------------- /arch.h: -------------------------------------------------------------------------------- 1 | #ifndef ARCH_H 2 | #define ARCH_H 3 | /* $OpenBSD: arch.h,v 1.8 2013/04/23 14:32:53 espie Exp $ */ 4 | 5 | /* 6 | * Copyright (c) 2001 Marc Espie. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 21 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | /*- 31 | * arch -- 32 | * Functions to manipulate libraries, archives and their members. 33 | */ 34 | 35 | #include 36 | 37 | /* Initialization and cleanup */ 38 | extern void Arch_Init(void); 39 | 40 | /* ok = Arch_ParseArchive(&begin, nodeLst, ctxt); 41 | * Given an archive specification, add list of corresponding GNodes to 42 | * nodeLst, one for each member in the spec. 43 | * false is returned if the specification is invalid for some reason. 44 | * Side-effect: begin is bumped to the end of the specification. */ 45 | extern bool Arch_ParseArchive(const char **, Lst, SymTable *); 46 | /* Arch_Touch(node); 47 | * Alter the modification time of the archive member described by node 48 | * to the current time. */ 49 | extern void Arch_Touch(GNode *); 50 | /* stamp = Arch_MTime(node); 51 | * Find the modification time of a member of an archive *in the 52 | * archive*, and returns it. 53 | * The time is also stored in the member's GNode. */ 54 | extern struct timespec Arch_MTime(GNode *); 55 | /* stamp = Arch_MemMTime(node); 56 | * Find the modification time of a member of an archive and returns it. 57 | * To use when the member only exists within the archive. */ 58 | extern struct timespec Arch_MemMTime(GNode *); 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /node_int.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: node_int.h,v 1.4 2012/10/09 19:45:34 espie Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 2007 Marc Espie. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 16 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 19 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | 29 | /* List of all nodes recognized by the make parser */ 30 | #define NODE_DEFAULT ".DEFAULT" 31 | #define NODE_EXEC ".EXEC" 32 | #define NODE_IGNORE ".IGNORE" 33 | #define NODE_INCLUDES ".INCLUDES" 34 | #define NODE_INVISIBLE ".INVISIBLE" 35 | #define NODE_JOIN ".JOIN" 36 | #define NODE_LIBS ".LIBS" 37 | #define NODE_MADE ".MADE" 38 | #define NODE_MAIN ".MAIN" 39 | #define NODE_MAKE ".MAKE" 40 | #define NODE_MAKEFLAGS ".MAKEFLAGS" 41 | #define NODE_MFLAGS ".MFLAGS" 42 | #define NODE_NOTMAIN ".NOTMAIN" 43 | #define NODE_NOTPARALLEL ".NOTPARALLEL" 44 | #define NODE_NO_PARALLEL ".NOPARALLEL" 45 | #define NODE_NULL ".NULL" 46 | #define NODE_OPTIONAL ".OPTIONAL" 47 | #define NODE_ORDER ".ORDER" 48 | #define NODE_PARALLEL ".PARALLEL" 49 | #define NODE_PATH ".PATH" 50 | #define NODE_PHONY ".PHONY" 51 | #define NODE_PRECIOUS ".PRECIOUS" 52 | #define NODE_RECURSIVE ".RECURSIVE" 53 | #define NODE_SILENT ".SILENT" 54 | #define NODE_SINGLESHELL ".SINGLESHELL" 55 | #define NODE_SUFFIXES ".SUFFIXES" 56 | #define NODE_USE ".USE" 57 | #define NODE_WAIT ".WAIT" 58 | 59 | #define NODE_BEGIN ".BEGIN" 60 | #define NODE_END ".END" 61 | #define NODE_INTERRUPT ".INTERRUPT" 62 | #define NODE_CHEAP ".CHEAP" 63 | #define NODE_EXPENSIVE ".EXPENSIVE" 64 | #define NODE_POSIX ".POSIX" 65 | #define NODE_SCCS_GET ".SCCS_GET" 66 | -------------------------------------------------------------------------------- /lstFindFrom.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: lstFindFrom.c,v 1.19 2015/10/14 13:50:22 espie Exp $ */ 2 | /* $NetBSD: lstFindFrom.c,v 1.6 1996/11/06 17:59:40 christos Exp $ */ 3 | 4 | /* 5 | * Copyright (c) 1988, 1989, 1990, 1993 6 | * The Regents of the University of California. All rights reserved. 7 | * 8 | * This code is derived from software contributed to Berkeley by 9 | * Adam de Boor. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions 13 | * are met: 14 | * 1. Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * 3. Neither the name of the University nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 | * SUCH DAMAGE. 34 | */ 35 | 36 | /*- 37 | * LstFindFrom.c -- 38 | * Find a node on a list from a given starting point. Used by Lst_Find. 39 | */ 40 | 41 | #include "lstInt.h" 42 | #include 43 | 44 | /*- 45 | *----------------------------------------------------------------------- 46 | * Lst_FindFrom -- 47 | * Search for a node starting and ending with the given one on the 48 | * given list using the passed datum and comparison function to 49 | * determine when it has been found. 50 | * 51 | * Results: 52 | * The found node or NULL 53 | *----------------------------------------------------------------------- 54 | */ 55 | LstNode 56 | Lst_FindFrom(LstNode ln, FindProc cProc, void *d) 57 | { 58 | LstNode tln; 59 | 60 | for (tln = ln; tln != NULL; tln = tln->nextPtr) 61 | if (!(*cProc)(tln->datum, d)) 62 | return tln; 63 | 64 | return NULL; 65 | } 66 | 67 | -------------------------------------------------------------------------------- /extern.h: -------------------------------------------------------------------------------- 1 | #ifndef EXTERN_H 2 | #define EXTERN_H 3 | 4 | /* $OpenBSD: extern.h,v 1.44 2020/01/13 14:51:50 espie Exp $ */ 5 | /* $NetBSD: nonints.h,v 1.12 1996/11/06 17:59:19 christos Exp $ */ 6 | 7 | /*- 8 | * Copyright (c) 1988, 1989, 1990, 1993 9 | * The Regents of the University of California. All rights reserved. 10 | * Copyright (c) 1989 by Berkeley Softworks 11 | * All rights reserved. 12 | * 13 | * This code is derived from software contributed to Berkeley by 14 | * Adam de Boor. 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted provided that the following conditions 18 | * are met: 19 | * 1. Redistributions of source code must retain the above copyright 20 | * notice, this list of conditions and the following disclaimer. 21 | * 2. Redistributions in binary form must reproduce the above copyright 22 | * notice, this list of conditions and the following disclaimer in the 23 | * documentation and/or other materials provided with the distribution. 24 | * 3. Neither the name of the University nor the names of its contributors 25 | * may be used to endorse or promote products derived from this software 26 | * without specific prior written permission. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 29 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 37 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38 | * SUCH DAMAGE. 39 | * 40 | * from: @(#)nonints.h 8.3 (Berkeley) 3/19/94 41 | */ 42 | 43 | extern bool ignoreErrors; /* True if should ignore all errors */ 44 | extern bool beSilent; /* True if should print no commands */ 45 | extern bool noExecute; /* True if should execute nothing */ 46 | extern bool allPrecious; /* True if every target is precious */ 47 | extern bool keepgoing; /* True if should continue on unaffected 48 | * portions of the graph when have an error 49 | * in one portion */ 50 | extern bool touchFlag; /* true if targets should just be 'touched' 51 | * if out of date. Set by the -t flag */ 52 | extern bool queryFlag; /* true if we aren't supposed to really make 53 | * anything, just see if the targets are out- 54 | * of-date */ 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /varname.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: varname.h,v 1.4 2010/07/19 19:30:38 espie Exp $ */ 2 | #ifndef VARNAME_H 3 | #define VARNAME_H 4 | /* 5 | * Copyright (c) 2001 Marc Espie. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 20 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /* varname - 30 | * Handles variable names in recursive situations, e.g., 31 | * to expand ${A${BC}}. 32 | */ 33 | 34 | /* Used to store temporary names, e.g., after $ expansion. */ 35 | struct Name { 36 | const char *s; /* Start of name. */ 37 | const char *e; /* End of name. */ 38 | bool tofree; /* Needs freeing after use ? */ 39 | }; 40 | 41 | /* endpos = VarName_Get(startpos, &name, ctxt, undef_is_bad, cont_function); 42 | * Gets a variable name from startpos, storing the result into name. 43 | * Recursive names are expanded from context ctxt. Boolean 44 | * undef_is_bad governs whether undefined variables should trigger a 45 | * parse error. To parse its argument efficiently, VarName_Get 46 | * uses cont_function(pos), which should return the position of the 47 | * next $ in string, or the position where the variable spec ends (as 48 | * differing modules have different requirements wrt variable spec 49 | * endings). Returns the position where the variable spec finally 50 | * ends. Name result might be a copy, or not. */ 51 | extern const char *VarName_Get(const char *, struct Name *, SymTable *, 52 | bool, const char *(*)(const char *)); 53 | /* VarName_Free(name); 54 | * Frees a variable name filled by VarName_Get(). */ 55 | extern void VarName_Free(struct Name *); 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /lstDeQueue.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: lstDeQueue.c,v 1.19 2010/07/19 19:46:44 espie Exp $ */ 2 | /* $NetBSD: lstDeQueue.c,v 1.5 1996/11/06 17:59:36 christos Exp $ */ 3 | 4 | /* 5 | * Copyright (c) 1988, 1989, 1990, 1993 6 | * The Regents of the University of California. All rights reserved. 7 | * 8 | * This code is derived from software contributed to Berkeley by 9 | * Adam de Boor. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions 13 | * are met: 14 | * 1. Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * 3. Neither the name of the University nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 | * SUCH DAMAGE. 34 | */ 35 | 36 | /*- 37 | * LstDeQueue.c -- 38 | * Remove the node and return its datum from the head of the list 39 | */ 40 | 41 | #include "lstInt.h" 42 | #include 43 | 44 | /*- 45 | *----------------------------------------------------------------------- 46 | * Lst_DeQueue -- 47 | * Remove and return the datum at the head of the given list. 48 | * 49 | * Results: 50 | * The datum in the node at the head or NULL if the list is empty. 51 | * 52 | * Side Effects: 53 | * The head node is removed from the list. 54 | *----------------------------------------------------------------------- 55 | */ 56 | void * 57 | Lst_DeQueue(Lst l) 58 | { 59 | void *rd; 60 | LstNode tln; 61 | 62 | tln = l->firstPtr; 63 | if (tln == NULL) 64 | return NULL; 65 | 66 | rd = tln->datum; 67 | l->firstPtr = tln->nextPtr; 68 | if (l->firstPtr) 69 | l->firstPtr->prevPtr = NULL; 70 | else 71 | l->lastPtr = NULL; 72 | free(tln); 73 | return rd; 74 | } 75 | 76 | -------------------------------------------------------------------------------- /lstDupl.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: lstDupl.c,v 1.22 2010/07/19 19:46:44 espie Exp $ */ 2 | /* $NetBSD: lstDupl.c,v 1.6 1996/11/06 17:59:37 christos Exp $ */ 3 | 4 | /* 5 | * Copyright (c) 1988, 1989, 1990, 1993 6 | * The Regents of the University of California. All rights reserved. 7 | * 8 | * This code is derived from software contributed to Berkeley by 9 | * Adam de Boor. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions 13 | * are met: 14 | * 1. Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * 3. Neither the name of the University nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 | * SUCH DAMAGE. 34 | */ 35 | 36 | /*- 37 | * listDupl.c -- 38 | * Duplicate a list. This includes duplicating the individual 39 | * elements. 40 | */ 41 | 42 | #include "lstInt.h" 43 | #include 44 | 45 | /*- 46 | *----------------------------------------------------------------------- 47 | * Lst_Clone -- 48 | * Duplicate an entire list. If a function to copy a void * is 49 | * given, the individual client elements will be duplicated as well. 50 | * 51 | * Results: 52 | * returns the new list. 53 | * 54 | * Side Effects: 55 | * The new list is created. 56 | *----------------------------------------------------------------------- 57 | */ 58 | Lst 59 | Lst_Clone(Lst nl, Lst l, DuplicateProc copyProc) 60 | { 61 | LstNode ln; 62 | 63 | Lst_Init(nl); 64 | 65 | for (ln = l->firstPtr; ln != NULL; ln = ln->nextPtr) { 66 | if (copyProc != NOCOPY) 67 | Lst_AtEnd(nl, (*copyProc)(ln->datum)); 68 | else 69 | Lst_AtEnd(nl, ln->datum); 70 | } 71 | return nl; 72 | } 73 | 74 | -------------------------------------------------------------------------------- /lstDestroy.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: lstDestroy.c,v 1.20 2010/07/19 19:46:44 espie Exp $ */ 2 | /* $NetBSD: lstDestroy.c,v 1.6 1996/11/06 17:59:37 christos Exp $ */ 3 | 4 | /* 5 | * Copyright (c) 1988, 1989, 1990, 1993 6 | * The Regents of the University of California. All rights reserved. 7 | * 8 | * This code is derived from software contributed to Berkeley by 9 | * Adam de Boor. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions 13 | * are met: 14 | * 1. Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * 3. Neither the name of the University nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 | * SUCH DAMAGE. 34 | */ 35 | 36 | /*- 37 | * LstDestroy.c -- 38 | * Nuke a list and all its resources 39 | */ 40 | 41 | #include "lstInt.h" 42 | #include 43 | 44 | /*- 45 | *----------------------------------------------------------------------- 46 | * Lst_Destroy -- 47 | * Destroy a list and free all its resources. If the freeProc is 48 | * given, it is called with the datum from each node in turn before 49 | * the node is freed. 50 | * 51 | * Side Effects: 52 | * The given list is freed in its entirety. 53 | * 54 | *----------------------------------------------------------------------- 55 | */ 56 | void 57 | Lst_Destroy(Lst l, SimpleProc freeProc) 58 | { 59 | LstNode ln; 60 | LstNode tln; 61 | 62 | if (freeProc) { 63 | for (ln = l->firstPtr; ln != NULL; ln = tln) { 64 | tln = ln->nextPtr; 65 | (*freeProc)(ln->datum); 66 | free(ln); 67 | } 68 | } else { 69 | for (ln = l->firstPtr; ln != NULL; ln = tln) { 70 | tln = ln->nextPtr; 71 | free(ln); 72 | } 73 | } 74 | } 75 | 76 | -------------------------------------------------------------------------------- /error.h: -------------------------------------------------------------------------------- 1 | #ifndef ERROR_H 2 | #define ERROR_H 3 | /* $OpenBSD: error.h,v 1.13 2015/09/27 16:58:16 guenther Exp $ */ 4 | 5 | /* 6 | * Copyright (c) 2001 Marc Espie. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 21 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | /* Error Print a tagged error message. The global 30 | * MAKE variable must have been defined. This 31 | * takes a format string and two optional 32 | * arguments for it. 33 | * 34 | * Fatal Print an error message and exit. Also takes 35 | * a format string and two arguments. 36 | * 37 | * Punt Aborts all jobs and exits with a message. Also 38 | * takes a format string and two arguments. 39 | * 40 | * Finish Finish things up by printing the number of 41 | * errors which occurred, as passed to it, and 42 | * exiting. 43 | */ 44 | extern void Error(const char *, ...) 45 | __attribute__((__format__ (printf, 1, 2))); 46 | extern void Fatal(const char *, ...) 47 | __attribute__((__format__ (printf, 1, 2))); 48 | extern void Punt(const char *, ...) 49 | __attribute__((__format__ (printf, 1, 2))); 50 | extern void Finish(void); 51 | 52 | /* 53 | * Error levels for parsing. PARSE_FATAL means the process cannot continue 54 | * once the makefile has been parsed. PARSE_WARNING means it can. Passed 55 | * as the first argument to Parse_Error. 56 | */ 57 | #define PARSE_WARNING 2 58 | #define PARSE_FATAL 1 59 | extern void Parse_Error(int, const char *, ...) 60 | __attribute__((__format__ (printf, 2, 3))); 61 | extern int fatal_errors; 62 | /* Needed for fatal errors: we have to know whether we must abort other jobs 63 | * or not */ 64 | extern bool supervise_jobs; 65 | #endif 66 | -------------------------------------------------------------------------------- /lstForEachFrom.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: lstForEachFrom.c,v 1.20 2015/10/14 13:52:11 espie Exp $ */ 2 | /* $NetBSD: lstForEachFrom.c,v 1.5 1996/11/06 17:59:42 christos Exp $ */ 3 | 4 | /* 5 | * Copyright (c) 1988, 1989, 1990, 1993 6 | * The Regents of the University of California. All rights reserved. 7 | * 8 | * This code is derived from software contributed to Berkeley by 9 | * Adam de Boor. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions 13 | * are met: 14 | * 1. Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * 3. Neither the name of the University nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 | * SUCH DAMAGE. 34 | */ 35 | 36 | /*- 37 | * lstForEachFrom.c -- 38 | * Perform a given function on all elements of a list starting from 39 | * a given point. 40 | */ 41 | 42 | #include "lstInt.h" 43 | #include 44 | 45 | /*- 46 | *----------------------------------------------------------------------- 47 | * Lst_ForEachFrom -- 48 | * Apply the given function to each element of the given list. The 49 | * function should return 0 if traversal should continue and non- 50 | * zero if it should abort. 51 | * 52 | * Side Effects: 53 | * Only those created by the passed-in function. 54 | *----------------------------------------------------------------------- 55 | */ 56 | void 57 | Lst_ForEachFrom(LstNode ln, ForEachProc proc, void *d) 58 | { 59 | LstNode tln; 60 | 61 | for (tln = ln; tln != NULL; tln = tln->nextPtr) 62 | (*proc)(tln->datum, d); 63 | } 64 | 65 | void 66 | Lst_Every(Lst l, SimpleProc proc) 67 | { 68 | LstNode tln; 69 | 70 | for (tln = l->firstPtr; tln != NULL; tln = tln->nextPtr) 71 | (*proc)(tln->datum); 72 | } 73 | -------------------------------------------------------------------------------- /varmodifiers.h: -------------------------------------------------------------------------------- 1 | #ifndef VARMODIFIERS_H 2 | #define VARMODIFIERS_H 3 | 4 | /* $OpenBSD: varmodifiers.h,v 1.12 2010/07/19 19:46:44 espie Exp $ */ 5 | 6 | /* 7 | * Copyright (c) 1999 Marc Espie. 8 | * 9 | * Extensive code changes for the OpenBSD project. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions 13 | * are met: 14 | * 1. Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 24 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | 33 | /* VarModifiers_Init(); 34 | * Set up varmodifiers internal table according to selected features. 35 | * This can be called several times without harm. */ 36 | extern void VarModifiers_Init(void); 37 | 38 | 39 | /* result = VarModifiers_Apply(val, name, ctxt, undef_is_bad, 40 | * &should_free, &modstart, paren); 41 | * Applies variable modifiers starting at modstart (including :), 42 | * using parenthesis paren, to value val. 43 | * Variables in spec are taken from context ctxt. 44 | * If undef_is_bad, error occurs if undefined variables are mentioned. 45 | * modstart is advanced past the end of the spec. 46 | * name holds the name of the corresponding variable, as some ODE 47 | * modifiers need it. 48 | * 49 | * If both val and name are NULL, VarModifiers_Apply just parses the 50 | * modifiers specification, as it can't apply it to anything. */ 51 | extern char *VarModifiers_Apply(char *, const struct Name *, SymTable *, 52 | bool, bool *, const char **, int); 53 | 54 | /* Direct interface to specific modifiers used under special circumstances. */ 55 | /* tails = Var_GetTail(string); 56 | * Returns the tail of list of words in string (needed for SysV locals). */ 57 | extern char *Var_GetTail(char *); 58 | /* heads = Var_GetHead(string); 59 | * Returns the head of list of words in string. */ 60 | /* XXX this does not replace foo with ., as (sun) System V make does. 61 | * Should it ? */ 62 | extern char *Var_GetHead(char *); 63 | #endif 64 | -------------------------------------------------------------------------------- /ohash.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: ohash.h,v 1.2 2014/06/02 18:52:03 deraadt Exp $ */ 2 | 3 | /* Copyright (c) 1999, 2004 Marc Espie 4 | * 5 | * Permission to use, copy, modify, and distribute this software for any 6 | * purpose with or without fee is hereby granted, provided that the above 7 | * copyright notice and this permission notice appear in all copies. 8 | * 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | */ 17 | 18 | #ifndef OHASH_H 19 | #define OHASH_H 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | /* Open hashing support. 27 | * Open hashing was chosen because it is much lighter than other hash 28 | * techniques, and more efficient in most cases. 29 | */ 30 | 31 | /* user-visible data structure */ 32 | struct ohash_info { 33 | ptrdiff_t key_offset; 34 | void *data; /* user data */ 35 | void *(*calloc)(size_t, size_t, void *); 36 | void (*free)(void *, void *); 37 | void *(*alloc)(size_t, void *); 38 | }; 39 | 40 | struct _ohash_record; 41 | 42 | /* private structure. It's there just so you can do a sizeof */ 43 | struct ohash { 44 | struct _ohash_record *t; 45 | struct ohash_info info; 46 | unsigned int size; 47 | unsigned int total; 48 | unsigned int deleted; 49 | }; 50 | 51 | /* For this to be tweakable, we use small primitives, and leave part of the 52 | * logic to the client application. e.g., hashing is left to the client 53 | * application. We also provide a simple table entry lookup that yields 54 | * a hashing table index (opaque) to be used in find/insert/remove. 55 | * The keys are stored at a known position in the client data. 56 | */ 57 | __BEGIN_DECLS 58 | void ohash_init(struct ohash *, unsigned, struct ohash_info *); 59 | void ohash_delete(struct ohash *); 60 | 61 | unsigned int ohash_lookup_interval(struct ohash *, const char *, 62 | const char *, uint32_t); 63 | unsigned int ohash_lookup_memory(struct ohash *, const char *, 64 | size_t, uint32_t); 65 | void *ohash_find(struct ohash *, unsigned int); 66 | void *ohash_remove(struct ohash *, unsigned int); 67 | void *ohash_insert(struct ohash *, unsigned int, void *); 68 | void *ohash_first(struct ohash *, unsigned int *); 69 | void *ohash_next(struct ohash *, unsigned int *); 70 | unsigned int ohash_entries(struct ohash *); 71 | 72 | void *ohash_create_entry(struct ohash_info *, const char *, const char **); 73 | uint32_t ohash_interval(const char *, const char **); 74 | 75 | unsigned int ohash_qlookupi(struct ohash *, const char *, const char **); 76 | unsigned int ohash_qlookup(struct ohash *, const char *); 77 | __END_DECLS 78 | #endif 79 | -------------------------------------------------------------------------------- /timestamp.h: -------------------------------------------------------------------------------- 1 | #ifndef TIMESTAMP_H 2 | #define TIMESTAMP_H 3 | 4 | /* $OpenBSD: timestamp.h,v 1.10 2013/05/22 12:14:08 espie Exp $ */ 5 | 6 | /* 7 | * Copyright (c) 2001 Marc Espie. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 19 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 22 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | /* This module handles time stamps on files in a relatively high-level way. 32 | * Most of the interface is achieved through inlineable code. 33 | * 34 | * ts_set_out_of_date(t): set up t so that it is out-of-date. 35 | * b = is_out_of_date(t): check whether t is out-of-date. 36 | * ts_set_from_stat(s, t): grab date out of stat(2) buffer. 37 | * b = is_strictly_before(t1, t2): 38 | * check whether t1 is before t2. 39 | * ts_set_from_time_t(d, t): create timestamp from time_t. 40 | */ 41 | 42 | /* sysresult = set_times(name): set modification times on a file. 43 | * system call results. 44 | */ 45 | 46 | #define Init_Timestamp() clock_gettime(CLOCK_REALTIME, &starttime) 47 | 48 | #define TMIN (sizeof(time_t) == sizeof(int32_t) ? INT32_MIN : INT64_MIN) 49 | #define ts_set_out_of_date(t) (t).tv_sec = TMIN, (t).tv_nsec = 0 50 | #define is_out_of_date(t) ((t).tv_sec == TMIN && (t).tv_nsec == 0) 51 | 52 | #define ts_set_from_stat(s, t) \ 53 | do { \ 54 | (t).tv_sec = (s).st_mtime; \ 55 | (t).tv_nsec = 0; \ 56 | if (is_out_of_date(t)) \ 57 | (t).tv_nsec++; \ 58 | } while (0) 59 | #define is_strictly_before(t1, t2) timespeccmp(&(t1), &(t2), <) 60 | #define ts_set_from_time_t(d, t) \ 61 | do { \ 62 | (t).tv_sec = d; \ 63 | (t).tv_nsec = 0; \ 64 | if (is_out_of_date(t)) \ 65 | (t).tv_nsec++; \ 66 | } while (0) 67 | 68 | extern int set_times(const char *); 69 | 70 | extern struct timespec starttime; /* The time at the start 71 | * of this whole process */ 72 | extern char *time_to_string(struct timespec *); 73 | 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /targ.h: -------------------------------------------------------------------------------- 1 | #ifndef TARG_H 2 | #define TARG_H 3 | /* $OpenBSD: targ.h,v 1.15 2020/01/13 15:41:53 espie Exp $ */ 4 | 5 | /* 6 | * Copyright (c) 2001 Marc Espie. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 21 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | #include 31 | /* 32 | * The TARG_ constants are used when calling the Targ_FindNode functions. 33 | * They simply tell the function what to do if the desired node is not found. 34 | * If the TARG_CREATE constant is given, a new, empty node will be created 35 | * for the target, placed in the table of all targets and its address returned. 36 | * If TARG_NOCREATE is given, a NULL pointer will be returned. 37 | */ 38 | #define TARG_CREATE 0x01 /* create node if not found */ 39 | #define TARG_NOCREATE 0x00 /* don't create it */ 40 | 41 | extern void Targ_Init(void); 42 | extern GNode *Targ_NewGNi(const char *, const char *); 43 | #define Targ_NewGN(n) Targ_NewGNi(n, NULL); 44 | extern GNode *Targ_FindNodei(const char *, const char *, int); 45 | #define Targ_FindNode(n, i) Targ_FindNodei(n, NULL, i) 46 | 47 | 48 | 49 | /* helper for constant nodes */ 50 | extern GNode *Targ_mk_special_node(const char *, size_t, uint32_t, 51 | unsigned int, unsigned char, unsigned int); 52 | 53 | extern void Targ_FindList(Lst, Lst); 54 | extern bool Targ_Ignore(GNode *); 55 | extern bool Targ_Silent(GNode *); 56 | extern bool Targ_Precious(GNode *); 57 | extern void Targ_PrintCmd(void *); 58 | extern void Targ_PrintType(int); 59 | extern void Targ_PrintGraph(int); 60 | extern bool node_is_real(GNode *); 61 | 62 | extern GNode *begin_node, *end_node, *interrupt_node, *DEFAULT; 63 | struct ohash_info; 64 | 65 | extern struct ohash_info gnode_info; 66 | 67 | extern void Targ_setdirs(const char *, const char *); 68 | extern const char *status_to_string(GNode *); 69 | extern struct ohash *targets_hash(void); 70 | #endif 71 | -------------------------------------------------------------------------------- /regress.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: regress.c,v 1.8 2015/11/15 06:01:39 daniel Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1999 Marc Espie. 5 | * 6 | * Code written for the OpenBSD project. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 21 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | /* regression tests */ 31 | #include 32 | #include 33 | #include "defines.h" 34 | #include "str.h" 35 | 36 | int main(void); 37 | #define CHECK(s) \ 38 | do { \ 39 | printf("%-65s", #s); \ 40 | if (s) \ 41 | printf("ok\n"); \ 42 | else { \ 43 | printf("failed\n"); \ 44 | errors++; \ 45 | } \ 46 | } while (0); 47 | 48 | int 49 | main(void) 50 | { 51 | unsigned int errors = 0; 52 | 53 | CHECK(Str_Match("string", "string") == true); 54 | CHECK(Str_Match("string", "string2") == false); 55 | CHECK(Str_Match("string", "string*") == true); 56 | CHECK(Str_Match("Long string", "Lo*ng") == true); 57 | CHECK(Str_Match("Long string", "Lo*ng ") == false); 58 | CHECK(Str_Match("Long string", "Lo*ng *") == true); 59 | CHECK(Str_Match("string", "stri?g") == true); 60 | CHECK(Str_Match("str?ng", "str\\?ng") == true); 61 | CHECK(Str_Match("striiiing", "str?*ng") == true); 62 | CHECK(Str_Match("Very long string just to see", "******a****") == false); 63 | CHECK(Str_Match("d[abc?", "d\\[abc\\?") == true); 64 | CHECK(Str_Match("d[abc!", "d\\[abc\\?") == false); 65 | CHECK(Str_Match("dwabc?", "d\\[abc\\?") == false); 66 | CHECK(Str_Match("da0", "d[bcda]0") == true); 67 | CHECK(Str_Match("da0", "d[z-a]0") == true); 68 | CHECK(Str_Match("d-0", "d[-a-z]0") == true); 69 | CHECK(Str_Match("dy0", "d[a\\-z]0") == false); 70 | CHECK(Str_Match("d-0", "d[a\\-z]0") == true); 71 | CHECK(Str_Match("dz0", "d[a\\]z]0") == true); 72 | 73 | if (errors != 0) 74 | printf("Errors: %d\n", errors); 75 | return 0; 76 | } 77 | 78 | 79 | -------------------------------------------------------------------------------- /suff.h: -------------------------------------------------------------------------------- 1 | #ifndef SUFF_H 2 | #define SUFF_H 3 | /* $OpenBSD: suff.h,v 1.12 2020/01/13 14:05:21 espie Exp $ */ 4 | 5 | /* 6 | * Copyright (c) 2001-2019 Marc Espie. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 21 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | */ 29 | 30 | extern void Suff_Init(void); 31 | 32 | /* Suff_DisableAllSuffixes(): 33 | * disable current suffixes and the corresponding rules. 34 | * They may be re-activated by adding a suffix anew. */ 35 | extern void Suff_DisableAllSuffixes(void); 36 | /* gn = Suff_ParseAsTransform(line, eline): 37 | * Try parsing a [line,eline[ as a suffix transformation 38 | * (.a.b or .a). If successful, returns a gn we can add 39 | * commands to (this is actually a transform kept on a 40 | * separate hash from normal targets). Otherwise returns NULL. */ 41 | extern GNode *Suff_ParseAsTransform(const char *, const char *); 42 | /* Suff_AddSuffixi(name, ename): 43 | * add the passed string interval [name,ename[ as a known 44 | * suffix. */ 45 | extern void Suff_AddSuffixi(const char *, const char *); 46 | /* process_suffixes_after_makefile_is_read(): 47 | * finish setting up the transformation graph for Suff_FindDep 48 | * and the .PATH.sfx paths get the default path appended for 49 | * find_suffix_path(). */ 50 | extern void process_suffixes_after_makefile_is_read(void); 51 | /* Suff_FindDeps(gn): 52 | * find implicit dependencies for gn and fill out corresponding 53 | * fields. */ 54 | extern void Suff_FindDeps(GNode *); 55 | /* l = find_suffix_path(gn): 56 | * returns the path associated with a gn, either because of its 57 | * suffix, or the default path. */ 58 | extern Lst find_suffix_path(GNode *); 59 | /* Suff_PrintAll(): 60 | * displays all suffix information. */ 61 | extern void Suff_PrintAll(void); 62 | /* path = find_best_path(name): 63 | * find the best path for the name, according to known suffixes. 64 | */ 65 | extern Lst find_best_path(const char *name); 66 | #endif 67 | -------------------------------------------------------------------------------- /lstRemove.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: lstRemove.c,v 1.19 2010/07/19 19:46:44 espie Exp $ */ 2 | /* $NetBSD: lstRemove.c,v 1.5 1996/11/06 17:59:50 christos Exp $ */ 3 | 4 | /* 5 | * Copyright (c) 1988, 1989, 1990, 1993 6 | * The Regents of the University of California. All rights reserved. 7 | * 8 | * This code is derived from software contributed to Berkeley by 9 | * Adam de Boor. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions 13 | * are met: 14 | * 1. Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * 3. Neither the name of the University nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 | * SUCH DAMAGE. 34 | */ 35 | 36 | /*- 37 | * LstRemove.c -- 38 | * Remove an element from a list 39 | */ 40 | 41 | #include "lstInt.h" 42 | #include 43 | 44 | 45 | /*- 46 | *----------------------------------------------------------------------- 47 | * Lst_Remove -- 48 | * Remove the given node from the given list. 49 | * 50 | * Side Effects: 51 | * The list's firstPtr will be set to NULL if ln is the last 52 | * node on the list. firsPtr and lastPtr will be altered if ln is 53 | * either the first or last node, respectively, on the list. 54 | * 55 | *----------------------------------------------------------------------- 56 | */ 57 | void 58 | Lst_Remove(Lst l, LstNode ln) 59 | { 60 | if (ln == NULL) 61 | return; 62 | 63 | /* unlink it from the list */ 64 | if (ln->nextPtr != NULL) 65 | ln->nextPtr->prevPtr = ln->prevPtr; 66 | if (ln->prevPtr != NULL) 67 | ln->prevPtr->nextPtr = ln->nextPtr; 68 | 69 | /* if either the firstPtr or lastPtr of the list point to this node, 70 | * adjust them accordingly */ 71 | if (l->firstPtr == ln) 72 | l->firstPtr = ln->nextPtr; 73 | if (l->lastPtr == ln) 74 | l->lastPtr = ln->prevPtr; 75 | 76 | /* note that the datum is unmolested. The caller must free it as 77 | * necessary and as expected. */ 78 | free(ln); 79 | } 80 | 81 | -------------------------------------------------------------------------------- /str.h: -------------------------------------------------------------------------------- 1 | #ifndef STR_H 2 | #define STR_H 3 | /* $OpenBSD: str.h,v 1.2 2010/07/19 19:46:44 espie Exp $ */ 4 | /* 5 | * Copyright (c) 2001 Marc Espie. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 20 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | /* pos = Str_rchri(str, end, c); 30 | * strrchr on intervals. */ 31 | extern char *Str_rchri(const char *, const char *, int); 32 | 33 | /* copy = Str_concati(s1, e1, s2, e2, sep); 34 | * Concatenate strings s1/e1 and s2/e2, wedging separator sep if != 0. */ 35 | extern char *Str_concati(const char *, const char *, const char *, const char *, int); 36 | #define Str_concat(s1, s2, sep) Str_concati(s1, strchr(s1, '\0'), s2, strchr(s2, '\0'), sep) 37 | 38 | /* copy = Str_dupi(str, end); 39 | * strdup on intervals. */ 40 | extern char *Str_dupi(const char *, const char *); 41 | 42 | /* copy = escape_dupi(str, end, set); 43 | * copy string str/end. All escape sequences such as \c with c in set 44 | * are handled as well. */ 45 | extern char *escape_dupi(const char *, const char *, const char *); 46 | 47 | 48 | extern char **brk_string(const char *, int *, char **); 49 | 50 | 51 | /* Iterate through a string word by word, 52 | * without copying anything. 53 | * More light-weight than brk_string, handles \ ' " as well. 54 | * 55 | * position = s; 56 | * while ((begin = iterate_words(&position)) != NULL) { 57 | * do_something_with_word_interval(begin, position); 58 | * } 59 | */ 60 | extern const char *iterate_words(const char **); 61 | 62 | /* match = Str_Matchi(str, estr, pat, end); 63 | * Checks if string str/estr matches pattern pat/end */ 64 | extern bool Str_Matchi(const char *, const char *, const char *, const char *); 65 | #define Str_Match(string, pattern) \ 66 | Str_Matchi(string, strchr(string, '\0'), pattern, strchr(pattern, '\0')) 67 | 68 | extern const char *Str_SYSVMatch(const char *, const char *, size_t *); 69 | extern void Str_SYSVSubst(Buffer, const char *, const char *, size_t); 70 | #endif 71 | -------------------------------------------------------------------------------- /lstConcatDestroy.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: lstConcatDestroy.c,v 1.11 2010/07/19 19:46:44 espie Exp $ */ 2 | /* $NetBSD: lstConcat.c,v 1.6 1996/11/06 17:59:34 christos Exp $ */ 3 | 4 | /* 5 | * Copyright (c) 1988, 1989, 1990, 1993 6 | * The Regents of the University of California. All rights reserved. 7 | * 8 | * This code is derived from software contributed to Berkeley by 9 | * Adam de Boor. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions 13 | * are met: 14 | * 1. Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * 3. Neither the name of the University nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 | * SUCH DAMAGE. 34 | */ 35 | 36 | /*- 37 | * listConcat.c -- 38 | * Function to concatentate two lists. 39 | */ 40 | 41 | #include "lstInt.h" 42 | #include 43 | 44 | /*- 45 | *----------------------------------------------------------------------- 46 | * Lst_ConcatDestroy -- 47 | * Concatenate two lists. The elements of the second list are 48 | * destructively added to the first list. If the elements should 49 | * be duplicated to avoid confusion with another list, the 50 | * Lst_Duplicate function should be called first. 51 | * 52 | * Side Effects: 53 | * The second list is destroyed. 54 | *----------------------------------------------------------------------- 55 | */ 56 | void 57 | Lst_ConcatDestroy(Lst l1, Lst l2) 58 | { 59 | if (l2->firstPtr != NULL) { 60 | /* 61 | * So long as the second list isn't empty, we just link the 62 | * first element of the second list to the last element of the 63 | * first list. If the first list isn't empty, we then link the 64 | * last element of the list to the first element of the second 65 | * list The last element of the second list, if it exists, then 66 | * becomes the last element of the first list. 67 | */ 68 | l2->firstPtr->prevPtr = l1->lastPtr; 69 | if (l1->lastPtr != NULL) 70 | l1->lastPtr->nextPtr = l2->firstPtr; 71 | else 72 | l1->firstPtr = l2->firstPtr; 73 | l1->lastPtr = l2->lastPtr; 74 | } 75 | } 76 | 77 | -------------------------------------------------------------------------------- /lstAppend.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: lstAppend.c,v 1.21 2015/01/13 18:30:15 espie Exp $ */ 2 | /* $NetBSD: lstAppend.c,v 1.5 1996/11/06 17:59:31 christos Exp $ */ 3 | 4 | /* 5 | * Copyright (c) 1988, 1989, 1990, 1993 6 | * The Regents of the University of California. All rights reserved. 7 | * 8 | * This code is derived from software contributed to Berkeley by 9 | * Adam de Boor. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions 13 | * are met: 14 | * 1. Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * 3. Neither the name of the University nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 | * SUCH DAMAGE. 34 | */ 35 | 36 | /*- 37 | * LstAppend.c -- 38 | * Add a new node with a new datum after an existing node 39 | */ 40 | 41 | #include "lstInt.h" 42 | #include 43 | #include 44 | #include "memory.h" 45 | 46 | /*- 47 | *----------------------------------------------------------------------- 48 | * Lst_Append -- 49 | * Create a new node and add it to the given list after the given node. 50 | * 51 | * Side Effects: 52 | * A new ListNode is created and linked in to the List. The lastPtr 53 | * field of the List will be altered if ln is the last node in the 54 | * list. lastPtr and firstPtr will alter if the list was empty and 55 | * ln was NULL. 56 | * 57 | *----------------------------------------------------------------------- 58 | */ 59 | void 60 | Lst_Append(Lst l, LstNode after, void *d) 61 | { 62 | LstNode nLNode; 63 | 64 | PAlloc(nLNode, LstNode); 65 | nLNode->datum = d; 66 | 67 | nLNode->prevPtr = after; 68 | nLNode->nextPtr = after->nextPtr; 69 | 70 | after->nextPtr = nLNode; 71 | if (nLNode->nextPtr != NULL) 72 | nLNode->nextPtr->prevPtr = nLNode; 73 | 74 | if (after == l->lastPtr) 75 | l->lastPtr = nLNode; 76 | } 77 | 78 | void 79 | Lst_AtEnd(Lst l, void *d) 80 | { 81 | LstNode ln; 82 | 83 | PAlloc(ln, LstNode); 84 | ln->datum = d; 85 | 86 | ln->prevPtr = l->lastPtr; 87 | ln->nextPtr = NULL; 88 | if (l->lastPtr == NULL) 89 | l->firstPtr = ln; 90 | else 91 | l->lastPtr->nextPtr = ln; 92 | l->lastPtr = ln; 93 | } 94 | -------------------------------------------------------------------------------- /stats.h: -------------------------------------------------------------------------------- 1 | #ifndef STAT_H 2 | #define STAT_H 3 | /* $OpenBSD: stats.h,v 1.6 2010/07/19 19:46:44 espie Exp $ */ 4 | 5 | /* 6 | * Copyright (c) 1999 Marc Espie. 7 | * 8 | * Code written for the OpenBSD project. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 23 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | /* statistical information gathering */ 33 | 34 | #if defined(STATS_VAR_LOOKUP) || \ 35 | defined(STATS_GN_CREATION) || \ 36 | defined(STATS_BUF) || \ 37 | defined(STATS_HASH) || \ 38 | defined(STATS_GROW) || \ 39 | defined(STATS_SUFF) 40 | #define HAS_STATS 41 | #endif 42 | 43 | #ifdef HAS_STATS 44 | extern void Init_Stats(void); 45 | 46 | extern unsigned long *statarray; 47 | #define STAT_INVOCATIONS statarray[0] 48 | #define STAT_VAR_SEARCHES statarray[1] 49 | #define STAT_VAR_COUNT statarray[2] 50 | #define STAT_VAR_MAXCOUNT statarray[3] 51 | #define STAT_GN_COUNT statarray[4] 52 | #define STAT_TOTAL_BUFS statarray[5] 53 | #define STAT_DEFAULT_BUFS statarray[6] 54 | #define STAT_WEIRD_BUFS statarray[7] 55 | #define STAT_BUFS_EXPANSION statarray[8] 56 | #define STAT_WEIRD_INEFFICIENT statarray[9] 57 | #define STAT_VAR_HASH_CREATION statarray[10] 58 | #define STAT_VAR_FROM_ENV statarray[11] 59 | #define STAT_VAR_CREATION statarray[12] 60 | #define STAT_VAR_FIND statarray[13] 61 | #define STAT_HASH_CREATION statarray[14] 62 | #define STAT_HASH_ENTRIES statarray[15] 63 | #define STAT_HASH_EXPAND statarray[16] 64 | #define STAT_HASH_LOOKUP statarray[17] 65 | #define STAT_HASH_LENGTH statarray[18] 66 | #define STAT_HASH_SIZE statarray[19] 67 | #define STAT_HASH_POSITIVE statarray[20] 68 | #define STAT_USER_SECONDS statarray[21] 69 | #define STAT_USER_MS statarray[22] 70 | #define STAT_SYS_SECONDS statarray[23] 71 | #define STAT_SYS_MS statarray[24] 72 | #define STAT_VAR_HASH_MAXSIZE statarray[25] 73 | #define STAT_VAR_GHASH_MAXSIZE statarray[26] 74 | #define STAT_VAR_POWER statarray[27] 75 | #define STAT_GROWARRAY statarray[28] 76 | #define STAT_SUFF_LOOKUP_NAME statarray[29] 77 | #define STAT_TRANSFORM_LOOKUP_NAME statarray[30] 78 | 79 | #define STAT_NUMBER 32 80 | 81 | #else 82 | #define Init_Stats() 83 | #endif 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /CVS/Entries: -------------------------------------------------------------------------------- 1 | /config.h/1.20/Sat Oct 18 07:50:06 2014// 2 | /defines.h/1.15/Wed Oct 14 13:50:22 2015// 3 | /generate.c/1.18/Fri Oct 14 09:27:21 2016// 4 | /timestamp.h/1.10/Wed May 22 12:14:08 2013// 5 | /arch.c/1.91/Thu Jul 22 13:38:44 2021// 6 | /arch.h/1.8/Thu Jul 22 13:38:33 2021// 7 | /buf.c/1.29/Thu Jul 22 13:38:44 2021// 8 | /buf.h/1.24/Thu Jul 22 13:38:44 2021// 9 | /cmd_exec.c/1.11/Thu Jul 22 13:38:44 2021// 10 | /cmd_exec.h/1.4/Thu Jul 22 13:38:33 2021// 11 | /compat.c/1.93/Thu Jul 22 13:38:44 2021// 12 | /compat.h/1.5/Thu Jul 22 13:38:44 2021// 13 | /cond.c/1.54/Thu Jul 22 13:38:44 2021// 14 | /cond.h/1.5/Thu Jul 22 13:38:33 2021// 15 | /cond_int.h/1.6/Thu Jul 22 13:38:33 2021// 16 | /dir.c/1.68/Thu Jul 22 13:38:33 2021// 17 | /dir.h/1.29/Thu Jul 22 13:38:33 2021// 18 | /direxpand.c/1.8/Thu Jul 22 13:38:33 2021// 19 | /direxpand.h/1.2/Thu Jul 22 13:38:33 2021// 20 | /dump.c/1.12/Thu Jul 22 13:38:44 2021// 21 | /dump.h/1.3/Thu Jul 22 13:38:33 2021// 22 | /engine.c/1.69/Thu Jul 22 13:38:44 2021// 23 | /engine.h/1.17/Thu Jul 22 13:38:44 2021// 24 | /enginechoice.c/1.3/Thu Mar 4 09:34:30 2021// 25 | /enginechoice.h/1.2/Thu Mar 4 09:32:49 2021// 26 | /error.c/1.25/Thu Jul 22 13:38:33 2021// 27 | /error.h/1.13/Thu Jul 22 13:38:33 2021// 28 | /expandchildren.c/1.2/Sun Jan 26 12:41:21 2020// 29 | /expandchildren.h/1.1/Mon Jan 13 14:05:21 2020// 30 | /extern.h/1.44/Thu Jul 22 13:38:44 2021// 31 | /for.c/1.47/Thu Jul 22 13:38:44 2021// 32 | /for.h/1.5/Thu Jul 22 13:38:33 2021// 33 | /garray.h/1.10/Thu Jul 22 13:38:44 2021// 34 | /gnode.h/1.39/Thu Jul 22 13:38:44 2021// 35 | /init.c/1.8/Thu Jul 22 13:38:44 2021// 36 | /init.h/1.3/Thu Jul 22 13:38:33 2021// 37 | /job.h/1.38/Thu Jul 22 13:38:44 2021// 38 | /location.h/1.1/Thu Jul 22 13:38:33 2021// 39 | /lowparse.c/1.35/Thu Jul 22 13:38:33 2021// 40 | /lowparse.h/1.11/Thu Jul 22 13:38:33 2021// 41 | /main.c/1.127/Result of merge// 42 | /main.h/1.6/Thu Jul 22 13:38:44 2021// 43 | /make.1/1.133/Thu Jul 22 13:38:44 2021// 44 | /make.c/1.82/Thu Jul 22 13:38:44 2021// 45 | /make.h/1.40/Thu Jul 22 13:38:44 2021// 46 | /memory.c/1.11/Thu Jul 22 13:38:33 2021// 47 | /memory.h/1.10/Thu Jul 22 13:38:44 2021// 48 | /node_int.h/1.4/Thu Jul 22 13:38:33 2021// 49 | /parse.c/1.134/Thu Jul 22 13:38:44 2021// 50 | /parse.h/1.7/Thu Jul 22 13:38:33 2021// 51 | /parsevar.c/1.16/Thu Jul 22 13:38:33 2021// 52 | /parsevar.h/1.5/Thu Jul 22 13:38:33 2021// 53 | /pathnames.h/1.13/Thu Jul 22 13:38:44 2021// 54 | /regress.c/1.8/Thu Jul 22 13:38:33 2021// 55 | /stats.c/1.11/Thu Jul 22 13:38:33 2021// 56 | /stats.h/1.6/Thu Jul 22 13:38:33 2021// 57 | /str.c/1.32/Thu Jul 22 13:38:44 2021// 58 | /str.h/1.2/Thu Jul 22 13:38:33 2021// 59 | /suff.c/1.102/Thu Jul 22 13:38:44 2021// 60 | /suff.h/1.12/Thu Jul 22 13:38:44 2021// 61 | /symtable.h/1.5/Thu Jul 22 13:38:44 2021// 62 | /targ.c/1.85/Thu Jul 22 13:38:44 2021// 63 | /targequiv.c/1.9/Thu Jul 22 13:38:44 2021// 64 | /targequiv.h/1.2/Thu Jul 22 13:38:33 2021// 65 | /timestamp.c/1.10/Thu Jul 22 13:38:33 2021// 66 | /var.c/1.103/Thu Jul 22 13:38:44 2021// 67 | /var.h/1.20/Thu Jul 22 13:38:44 2021// 68 | /var_int.h/1.2/Thu Jul 22 13:38:33 2021// 69 | /varmodifiers.c/1.48/Thu Jul 22 13:38:44 2021// 70 | /varmodifiers.h/1.12/Thu Jul 22 13:38:33 2021// 71 | /varname.c/1.6/Thu Jul 22 13:38:33 2021// 72 | /varname.h/1.4/Thu Jul 22 13:38:33 2021// 73 | /targ.h/1.15/Thu Jul 22 13:41:12 2021// 74 | /job.c/1.162/Thu Jul 22 13:42:18 2021// 75 | /Makefile/1.64/Thu Jul 22 13:42:34 2021// 76 | D/PSD.doc//// 77 | D/lst.lib//// 78 | /lst.h/1.33/Thu Jul 22 14:06:58 2021// 79 | /lst_t.h/1.3/Thu Jul 22 14:07:39 2021// 80 | -------------------------------------------------------------------------------- /lstInsert.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: lstInsert.c,v 1.20 2010/07/19 19:46:44 espie Exp $ */ 2 | /* $NetBSD: lstInsert.c,v 1.5 1996/11/06 17:59:44 christos Exp $ */ 3 | 4 | /* 5 | * Copyright (c) 1988, 1989, 1990, 1993 6 | * The Regents of the University of California. All rights reserved. 7 | * 8 | * This code is derived from software contributed to Berkeley by 9 | * Adam de Boor. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions 13 | * are met: 14 | * 1. Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * 3. Neither the name of the University nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 | * SUCH DAMAGE. 34 | */ 35 | 36 | /*- 37 | * LstInsert.c -- 38 | * Insert a new datum before an old one 39 | */ 40 | 41 | #include "lstInt.h" 42 | #include 43 | #include 44 | #include "memory.h" 45 | 46 | /*- 47 | *----------------------------------------------------------------------- 48 | * Lst_Insert -- 49 | * Insert a new node with the given piece of data before the given 50 | * node in the given list. 51 | * 52 | * Side Effects: 53 | * the firstPtr field will be changed if ln is the first node in the 54 | * list. 55 | * 56 | *----------------------------------------------------------------------- 57 | */ 58 | void 59 | Lst_Insert(Lst l, LstNode before, void *d) 60 | { 61 | LstNode nLNode; 62 | 63 | 64 | if (before == NULL && !Lst_IsEmpty(l)) 65 | return; 66 | 67 | if (before != NULL && Lst_IsEmpty(l)) 68 | return; 69 | 70 | PAlloc(nLNode, LstNode); 71 | 72 | nLNode->datum = d; 73 | 74 | if (before == NULL) { 75 | nLNode->prevPtr = nLNode->nextPtr = NULL; 76 | l->firstPtr = l->lastPtr = nLNode; 77 | } else { 78 | nLNode->prevPtr = before->prevPtr; 79 | nLNode->nextPtr = before; 80 | 81 | if (nLNode->prevPtr != NULL) 82 | nLNode->prevPtr->nextPtr = nLNode; 83 | before->prevPtr = nLNode; 84 | 85 | if (before == l->firstPtr) 86 | l->firstPtr = nLNode; 87 | } 88 | } 89 | 90 | void 91 | Lst_AtFront(Lst l, void *d) 92 | { 93 | LstNode ln; 94 | 95 | PAlloc(ln, LstNode); 96 | ln->datum = d; 97 | 98 | ln->nextPtr = l->firstPtr; 99 | ln->prevPtr = NULL; 100 | if (l->firstPtr == NULL) 101 | l->lastPtr = ln; 102 | else 103 | l->firstPtr->prevPtr = ln; 104 | l->firstPtr = ln; 105 | } 106 | -------------------------------------------------------------------------------- /mk/bsd.regress.mk: -------------------------------------------------------------------------------- 1 | # $OpenBSD: bsd.regress.mk,v 1.23 2020/12/17 14:54:15 bluhm Exp $ 2 | # Documented in bsd.regress.mk(5) 3 | 4 | # No man pages for regression tests. 5 | NOMAN= 6 | 7 | # No installation. 8 | install: 9 | 10 | # If REGRESS_TARGETS is defined and PROG is not defined, set NOPROG 11 | .if defined(REGRESS_TARGETS) && !defined(PROG) 12 | NOPROG= 13 | .endif 14 | 15 | .include 16 | 17 | .MAIN: all 18 | all: regress 19 | 20 | # XXX - Need full path to REGRESS_LOG, otherwise there will be much pain. 21 | REGRESS_LOG?=/dev/null 22 | REGRESS_SKIP_TARGETS?= 23 | REGRESS_SKIP_SLOW?=no 24 | REGRESS_FAIL_EARLY?=no 25 | 26 | .if ! ${REGRESS_LOG:M/*} 27 | ERRORS += "Fatal: REGRESS_LOG=${REGRESS_LOG} is not an absolute path" 28 | .endif 29 | 30 | _REGRESS_NAME=${.CURDIR:S/${BSDSRCDIR}\/regress\///} 31 | _REGRESS_TMP?=/dev/null 32 | _REGRESS_OUT= | tee -a ${REGRESS_LOG} ${_REGRESS_TMP} 2>&1 > /dev/null 33 | 34 | .if defined(PROG) && !empty(PROG) 35 | run-regress-${PROG}: ${PROG} 36 | ./${PROG} 37 | .PHONY: run-regress-${PROG} 38 | .endif 39 | 40 | .if defined(PROG) && !defined(REGRESS_TARGETS) 41 | REGRESS_TARGETS=run-regress-${PROG} 42 | . if defined(REGRESS_SKIP) 43 | REGRESS_SKIP_TARGETS=run-regress-${PROG} 44 | . endif 45 | .endif 46 | 47 | .if defined(REGRESS_SLOW_TARGETS) && ${REGRESS_SKIP_SLOW:L} != no 48 | REGRESS_SKIP_TARGETS+=${REGRESS_SLOW_TARGETS} 49 | .endif 50 | 51 | .if ${REGRESS_FAIL_EARLY:L} != no 52 | _REGRESS_FAILED = false 53 | .else 54 | _REGRESS_FAILED = true 55 | .endif 56 | 57 | .if defined(REGRESS_ROOT_TARGETS) 58 | _ROOTUSER!=id -g 59 | SUDO?= 60 | . if (${_ROOTUSER} != 0) && empty(SUDO) 61 | REGRESS_SKIP_TARGETS+=${REGRESS_ROOT_TARGETS} 62 | . endif 63 | .endif 64 | 65 | REGRESS_EXPECTED_FAILURES?= 66 | REGRESS_SETUP?= 67 | REGRESS_SETUP_ONCE?= 68 | REGRESS_CLEANUP?= 69 | 70 | .if !empty(REGRESS_SETUP) 71 | ${REGRESS_TARGETS}: ${REGRESS_SETUP} 72 | .endif 73 | 74 | .if !empty(REGRESS_SETUP_ONCE) 75 | CLEANFILES+=${REGRESS_SETUP_ONCE:S/^/stamp-/} 76 | ${REGRESS_TARGETS}: ${REGRESS_SETUP_ONCE:S/^/stamp-/} 77 | ${REGRESS_SETUP_ONCE:S/^/stamp-/}: .SILENT 78 | echo '==== ${@:S/^stamp-//} ====' 79 | ${MAKE} -C ${.CURDIR} ${@:S/^stamp-//} 80 | date >$@ 81 | echo 82 | .endif 83 | 84 | regress: .SILENT 85 | .if !empty(REGRESS_SETUP_ONCE) 86 | rm -f ${REGRESS_SETUP_ONCE:S/^/stamp-/} 87 | ${MAKE} -C ${.CURDIR} ${REGRESS_SETUP_ONCE:S/^/stamp-/} 88 | .endif 89 | .for RT in ${REGRESS_TARGETS} 90 | echo '==== ${RT} ====' 91 | . if ${REGRESS_SKIP_TARGETS:M${RT}} 92 | echo -n "SKIP " ${_REGRESS_OUT} 93 | echo SKIPPED 94 | . elif ${REGRESS_EXPECTED_FAILURES:M${RT}} 95 | if ${MAKE} -C ${.CURDIR} ${RT}; then \ 96 | echo -n "XPASS " ${_REGRESS_OUT} ; \ 97 | echo UNEXPECTED_PASS; \ 98 | ${_REGRESS_FAILED}; \ 99 | else \ 100 | echo -n "XFAIL " ${_REGRESS_OUT} ; \ 101 | echo EXPECTED_FAIL; \ 102 | fi 103 | . else 104 | if ${MAKE} -C ${.CURDIR} ${RT}; then \ 105 | echo -n "SUCCESS " ${_REGRESS_OUT} ; \ 106 | else \ 107 | echo -n "FAIL " ${_REGRESS_OUT} ; \ 108 | echo FAILED ; \ 109 | ${_REGRESS_FAILED}; \ 110 | fi 111 | . endif 112 | echo ${_REGRESS_NAME}/${RT:S/^run-regress-//} ${_REGRESS_OUT} 113 | echo 114 | .endfor 115 | .for RT in ${REGRESS_CLEANUP} 116 | echo '==== ${RT} ====' 117 | ${MAKE} -C ${.CURDIR} ${RT} 118 | echo 119 | .endfor 120 | rm -f ${REGRESS_SETUP_ONCE:S/^/stamp-/} 121 | 122 | .if defined(ERRORS) 123 | .BEGIN: 124 | . for _m in ${ERRORS} 125 | @echo 1>&2 ${_m} 126 | . endfor 127 | . if !empty(ERRORS:M"Fatal\:*") || !empty(ERRORS:M'Fatal\:*') 128 | @exit 1 129 | . endif 130 | .endif 131 | 132 | .PHONY: regress 133 | -------------------------------------------------------------------------------- /defines.h: -------------------------------------------------------------------------------- 1 | #ifndef DEFINES_H 2 | #define DEFINES_H 3 | 4 | /* $OpenBSD: defines.h,v 1.15 2015/10/14 13:50:22 espie Exp $ */ 5 | 6 | /* 7 | * Copyright (c) 2001 Marc Espie. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 19 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 22 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | # include 32 | 33 | # include "portable.h" 34 | 35 | /* define common types in an opaque way */ 36 | struct GNode_; 37 | typedef struct GNode_ GNode; 38 | 39 | struct Location_; 40 | typedef struct Location_ Location; 41 | 42 | struct List_; 43 | typedef struct List_ *Lst; 44 | 45 | struct SymTable_; 46 | typedef struct SymTable_ SymTable; 47 | 48 | struct Buffer_; 49 | typedef struct Buffer_ *Buffer; 50 | 51 | struct Name; 52 | 53 | struct ListNode_; 54 | typedef struct ListNode_ *LstNode; 55 | 56 | struct Job_; 57 | typedef struct Job_ Job; 58 | 59 | struct Suff_; 60 | typedef struct Suff_ Suff; 61 | 62 | /* some useful defines for gcc */ 63 | 64 | #ifdef __GNUC__ 65 | # define UNUSED __attribute__((__unused__)) 66 | # define HAS_INLINES 67 | # define INLINE __inline__ 68 | #else 69 | # define UNUSED 70 | #endif 71 | 72 | #ifdef HAS_INLINES 73 | # ifndef INLINE 74 | # define INLINE inline 75 | # endif 76 | #endif 77 | 78 | /* 79 | * debug control: 80 | * There is one bit per module. It is up to the module what debug 81 | * information to print. 82 | */ 83 | extern int debug; 84 | #define DEBUG_ARCH 0x0001 85 | #define DEBUG_COND 0x0002 86 | #define DEBUG_DIR 0x0004 87 | #define DEBUG_GRAPH1 0x0008 88 | #define DEBUG_GRAPH2 0x0010 89 | #define DEBUG_JOB 0x0020 90 | #define DEBUG_MAKE 0x0040 91 | #define DEBUG_SUFF 0x0080 92 | #define DEBUG_TARG 0x0100 93 | #define DEBUG_VAR 0x0200 94 | #define DEBUG_FOR 0x0400 95 | #define DEBUG_LOUD 0x0800 96 | #define DEBUG_PARALLEL 0x1000 97 | #define DEBUG_NAME_MATCHING 0x2000 98 | #define DEBUG_QUICKDEATH 0x4000 99 | #define DEBUG_EXPENSIVE 0x8000 100 | #define DEBUG_KILL 0x10000 101 | #define DEBUG_HELDJOBS 0x20000 102 | #define DEBUG_DOUBLE 0x40000 103 | #define DEBUG_TARGGROUP 0x80000 104 | 105 | #define CONCAT(a,b) a##b 106 | 107 | #define DEBUG(module) (debug & CONCAT(DEBUG_,module)) 108 | 109 | #define ISLOWER(c) (islower((unsigned char)(c))) 110 | #define ISUPPER(c) (isupper((unsigned char)(c))) 111 | #define ISDIGIT(c) (isdigit((unsigned char)(c))) 112 | #define ISXDIGIT(c) (isxdigit((unsigned char)(c))) 113 | #define ISSPACE(c) (isspace((unsigned char)(c))) 114 | #define TOUPPER(c) (toupper((unsigned char)(c))) 115 | #define TOLOWER(c) (tolower((unsigned char)(c))) 116 | 117 | #endif 118 | -------------------------------------------------------------------------------- /garray.h: -------------------------------------------------------------------------------- 1 | #ifndef GARRAY_H 2 | #define GARRAY_H 3 | 4 | /* $OpenBSD: garray.h,v 1.10 2019/12/22 16:53:40 espie Exp $ */ 5 | /* Growable array implementation */ 6 | 7 | /* 8 | * Copyright (c) 2001 Marc Espie. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 23 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | struct growableArray { 33 | GNode **a; /* Only used for gnodes right now */ 34 | unsigned int size; /* Total max size */ 35 | unsigned int n; /* Current number of members */ 36 | }; 37 | 38 | #define AppendList2Array(l1, l2) \ 39 | do { \ 40 | LstNode ln; \ 41 | for (ln = Lst_First((l1)); ln != NULL; ln = Lst_Adv(ln))\ 42 | Array_AtEnd((l2), Lst_Datum(ln)); \ 43 | } while (0) 44 | 45 | #ifdef STATS_GROW 46 | #define MAY_INCREASE_STATS STAT_GROWARRAY++ 47 | #else 48 | #define MAY_INCREASE_STATS 49 | #endif 50 | 51 | #define Array_AtEnd(l, gn) \ 52 | do { \ 53 | if ((l)->n >= (l)->size) { \ 54 | (l)->size *= 2; \ 55 | (l)->a = ereallocarray((l)->a, \ 56 | (l)->size, sizeof(struct GNode *)); \ 57 | MAY_INCREASE_STATS; \ 58 | } \ 59 | (l)->a[(l)->n++] = (gn); \ 60 | } while (0) 61 | 62 | #define Array_Push(l, gn) Array_AtEnd(l, gn) 63 | 64 | #define Array_Pop(l) \ 65 | ((l)->n > 0 ? (l)->a[--(l)->n] : NULL) 66 | 67 | #define Array_PushNew(l, gn) \ 68 | do { \ 69 | unsigned int i; \ 70 | for (i = 0; i < (l)->n; i++) \ 71 | if ((l)->a[i] == (gn)) \ 72 | break; \ 73 | if (i == (l)->n) \ 74 | Array_Push(l, gn); \ 75 | } while (0) 76 | 77 | #define Array_Find(l, func, v) \ 78 | do { \ 79 | unsigned int i; \ 80 | for (i = 0; i < (l)->n; i++) \ 81 | if ((func)((l)->a[i], (v)) == 0)\ 82 | break; \ 83 | } while (0) 84 | 85 | #define Array_FindP(l, func, v) \ 86 | do { \ 87 | unsigned int i; \ 88 | for (i = 0; i < (l)->n; i++) \ 89 | if ((func)(&((l)->a[i]), (v)) == 0) \ 90 | break; \ 91 | } while (0) 92 | 93 | #define Array_ForEach(l, func, v) \ 94 | do { \ 95 | unsigned int i; \ 96 | for (i = 0; i < (l)->n; i++) \ 97 | (func)((l)->a[i], (v)); \ 98 | } while (0) 99 | 100 | #define Array_Every(l, func) \ 101 | do { \ 102 | unsigned int i; \ 103 | for (i = 0; i < (l)->n; i++) \ 104 | (func)((l)->a[i]); \ 105 | } while (0) 106 | 107 | #define Array_Init(l, sz) \ 108 | do { \ 109 | (l)->size = (sz); \ 110 | (l)->n = 0; \ 111 | (l)->a = ereallocarray(NULL, (l)->size, sizeof(GNode *)); \ 112 | } while (0) 113 | 114 | #define Array_Reset(l) \ 115 | do { \ 116 | (l)->n = 0; \ 117 | } while (0) 118 | 119 | #define Array_IsEmpty(l) ((l)->n == 0) 120 | 121 | #endif 122 | -------------------------------------------------------------------------------- /lstConcat.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: lstConcat.c,v 1.20 2010/07/19 19:46:44 espie Exp $ */ 2 | /* $NetBSD: lstConcat.c,v 1.6 1996/11/06 17:59:34 christos Exp $ */ 3 | 4 | /* 5 | * Copyright (c) 1988, 1989, 1990, 1993 6 | * The Regents of the University of California. All rights reserved. 7 | * 8 | * This code is derived from software contributed to Berkeley by 9 | * Adam de Boor. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions 13 | * are met: 14 | * 1. Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * 3. Neither the name of the University nor the names of its contributors 20 | * may be used to endorse or promote products derived from this software 21 | * without specific prior written permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 | * SUCH DAMAGE. 34 | */ 35 | 36 | /*- 37 | * listConcat.c -- 38 | * Function to copy a list and append it to another. 39 | */ 40 | 41 | #include "lstInt.h" 42 | #include 43 | #include 44 | #include "memory.h" 45 | 46 | /*- 47 | *----------------------------------------------------------------------- 48 | * Lst_Concat -- 49 | * Concatenate two lists. New elements are created to hold the data 50 | * elements but the elements themselves are not copied. 51 | * If the elements themselves should be duplicated to avoid 52 | * confusion with another list, the Lst_Duplicate function 53 | * should be called first. 54 | * 55 | * Side Effects: 56 | * New elements are created and appended to the first list. 57 | *----------------------------------------------------------------------- 58 | */ 59 | void 60 | Lst_Concat(Lst l1, Lst l2) 61 | { 62 | LstNode ln; /* original LstNode */ 63 | LstNode nln; /* new LstNode */ 64 | LstNode last; /* the last element in the list. Keeps 65 | * bookkeeping until the end */ 66 | if (l2->firstPtr != NULL) { 67 | /* The loop simply goes through the entire second list creating 68 | * new LstNodes and filling in the nextPtr, and prevPtr to fit 69 | * into l1 and its datum field from the datum field of the 70 | * corresponding element in l2. The 'last' node follows the 71 | * last of the new nodes along until the entire l2 has been 72 | * appended. Only then does the bookkeeping catch up with the 73 | * changes. During the first iteration of the loop, if 'last' 74 | * is NULL, the first list must have been empty so the 75 | * newly-created node is made the first node of the list. */ 76 | for (last = l1->lastPtr, ln = l2->firstPtr; ln != NULL; 77 | ln = ln->nextPtr) { 78 | PAlloc(nln, LstNode); 79 | nln->datum = ln->datum; 80 | if (last != NULL) 81 | last->nextPtr = nln; 82 | else 83 | l1->firstPtr = nln; 84 | nln->prevPtr = last; 85 | last = nln; 86 | } 87 | 88 | /* Finish bookkeeping. The last new element becomes the last 89 | * element of l1. */ 90 | l1->lastPtr = last; 91 | last->nextPtr = NULL; 92 | } 93 | } 94 | 95 | -------------------------------------------------------------------------------- /job.h: -------------------------------------------------------------------------------- 1 | #ifndef _JOB_H_ 2 | #define _JOB_H_ 3 | 4 | /* $OpenBSD: job.h,v 1.38 2020/06/03 12:41:39 espie Exp $ */ 5 | /* $NetBSD: job.h,v 1.5 1996/11/06 17:59:10 christos Exp $ */ 6 | 7 | /* 8 | * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. 9 | * Copyright (c) 1988, 1989 by Adam de Boor 10 | * Copyright (c) 1989 by Berkeley Softworks 11 | * All rights reserved. 12 | * 13 | * This code is derived from software contributed to Berkeley by 14 | * Adam de Boor. 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted provided that the following conditions 18 | * are met: 19 | * 1. Redistributions of source code must retain the above copyright 20 | * notice, this list of conditions and the following disclaimer. 21 | * 2. Redistributions in binary form must reproduce the above copyright 22 | * notice, this list of conditions and the following disclaimer in the 23 | * documentation and/or other materials provided with the distribution. 24 | * 3. Neither the name of the University nor the names of its contributors 25 | * may be used to endorse or promote products derived from this software 26 | * without specific prior written permission. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 29 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 37 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38 | * SUCH DAMAGE. 39 | * 40 | * from: @(#)job.h 8.1 (Berkeley) 6/6/93 41 | */ 42 | 43 | /*- 44 | * job.h -- 45 | * Definitions pertaining to the running of jobs. 46 | */ 47 | 48 | /* Job_Make(gn); 49 | * register a new job running commands associated with building gn. 50 | */ 51 | extern void Job_Make(GNode *); 52 | /* Job_Init(maxproc); 53 | * setup job handling framework 54 | */ 55 | extern void Job_Init(int); 56 | 57 | /* save signal mask at start */ 58 | extern void Sigset_Init(void); 59 | 60 | /* interface with the normal build in make.c */ 61 | /* okay = can_start_job(); 62 | * can we run new jobs right now ? 63 | */ 64 | extern bool can_start_job(void); 65 | 66 | /* finished = Job_Empty(); 67 | * wait until all jobs are finished after we build everything. 68 | */ 69 | extern bool Job_Empty(void); 70 | 71 | extern void Job_Wait(void); 72 | extern void Job_AbortAll(void); 73 | extern void print_errors(void); 74 | 75 | /* handle_running_jobs(); 76 | * wait until something happens, like a job finishing running a command 77 | * or a signal coming in. 78 | */ 79 | extern void handle_running_jobs(void); 80 | /* loop_handle_running_jobs(); 81 | * handle running jobs until they're finished. 82 | */ 83 | extern void loop_handle_running_jobs(void); 84 | extern void reset_signal_mask(void); 85 | 86 | /* handle_all_signals(); 87 | * if a signal was received, react accordingly. 88 | * By displaying STATUS info, or by aborting running jobs for a fatal 89 | * signals. Relies on Job_Init() for setting up handlers. 90 | */ 91 | extern void handle_all_signals(void); 92 | 93 | extern void determine_expensive_job(Job *); 94 | extern Job *runningJobs, *errorJobs, *availableJobs; 95 | extern void debug_job_printf(const char *, ...); 96 | extern void handle_one_job(Job *); 97 | extern int check_dying_signal(void); 98 | 99 | extern const char *basedirectory; 100 | 101 | extern bool sequential; /* True if we are running one single-job */ 102 | 103 | #endif /* _JOB_H_ */ 104 | -------------------------------------------------------------------------------- /cmd_exec.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: cmd_exec.c,v 1.11 2020/01/16 16:07:18 espie Exp $ */ 2 | /* 3 | * Copyright (c) 2001 Marc Espie. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 15 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 18 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include "config.h" 33 | #include "defines.h" 34 | #include "cmd_exec.h" 35 | #include "buf.h" 36 | #include "memory.h" 37 | #include "pathnames.h" 38 | #include "job.h" 39 | 40 | char * 41 | Cmd_Exec(const char *cmd, char **err) 42 | { 43 | char *args[4]; /* Args for invoking the shell */ 44 | int fds[2]; /* Pipe streams */ 45 | pid_t cpid; /* Child PID */ 46 | char *result; /* Result */ 47 | int status; /* Command exit status */ 48 | BUFFER buf; /* Buffer to store the result. */ 49 | char *cp; /* Pointer into result. */ 50 | ssize_t cc; /* Characters read from pipe. */ 51 | size_t length; /* Total length of result. */ 52 | 53 | 54 | *err = NULL; 55 | 56 | /* Set up arguments for the shell. */ 57 | args[0] = "sh"; 58 | args[1] = "-c"; 59 | args[2] = (char *)cmd; 60 | args[3] = NULL; 61 | 62 | /* Open a pipe for retrieving shell's output. */ 63 | if (pipe(fds) == -1) { 64 | *err = "Couldn't create pipe for \"%s\""; 65 | goto bad; 66 | } 67 | 68 | /* Fork */ 69 | switch (cpid = fork()) { 70 | case 0: 71 | reset_signal_mask(); 72 | /* Close input side of pipe */ 73 | (void)close(fds[0]); 74 | 75 | /* Duplicate the output stream to the shell's output, then 76 | * shut the extra thing down. Note we don't fetch the error 77 | * stream: user can use redirection to grab it as this goes 78 | * through /bin/sh. 79 | */ 80 | if (fds[1] != 1) { 81 | (void)dup2(fds[1], 1); 82 | (void)close(fds[1]); 83 | } 84 | 85 | (void)execv(_PATH_BSHELL, args); 86 | _exit(1); 87 | /*NOTREACHED*/ 88 | 89 | case -1: 90 | *err = "Couldn't exec \"%s\""; 91 | goto bad; 92 | 93 | default: 94 | /* No need for the writing half. */ 95 | (void)close(fds[1]); 96 | 97 | Buf_Init(&buf, MAKE_BSIZE); 98 | 99 | do { 100 | char grab[BUFSIZ]; 101 | 102 | cc = read(fds[0], grab, sizeof(grab)); 103 | if (cc > 0) 104 | Buf_AddChars(&buf, cc, grab); 105 | } while (cc > 0 || (cc == -1 && errno == EINTR)); 106 | 107 | /* Close the input side of the pipe. */ 108 | (void)close(fds[0]); 109 | 110 | /* Wait for the child to exit. */ 111 | while (waitpid(cpid, &status, 0) == -1 && errno == EINTR) 112 | continue; 113 | 114 | if (cc == -1) 115 | *err = "Couldn't read shell's output for \"%s\""; 116 | 117 | if (status) 118 | *err = "\"%s\" returned non-zero status"; 119 | 120 | length = Buf_Size(&buf); 121 | result = Buf_Retrieve(&buf); 122 | 123 | /* The result is null terminated, Convert newlines to spaces. */ 124 | cp = result + length - 1; 125 | 126 | if (cp >= result && *cp == '\n') 127 | /* A final newline is just stripped. */ 128 | *cp-- = '\0'; 129 | 130 | while (cp >= result) { 131 | if (*cp == '\n') 132 | *cp = ' '; 133 | cp--; 134 | } 135 | break; 136 | } 137 | return result; 138 | bad: 139 | return estrdup(""); 140 | } 141 | 142 | -------------------------------------------------------------------------------- /mk/bsd.own.mk: -------------------------------------------------------------------------------- 1 | # $OpenBSD: bsd.own.mk,v 1.210 2021/05/02 22:32:31 naddy Exp $ 2 | # $NetBSD: bsd.own.mk,v 1.24 1996/04/13 02:08:09 thorpej Exp $ 3 | 4 | # Host-specific overrides 5 | .if defined(MAKECONF) && exists(${MAKECONF}) 6 | .include "${MAKECONF}" 7 | .elif exists(/etc/mk.conf) 8 | .include "/etc/mk.conf" 9 | .endif 10 | 11 | # Set `WARNINGS' to `yes' to add appropriate warnings to each compilation 12 | WARNINGS?= no 13 | # Set `SKEY' to `yes' to build with support for S/key authentication. 14 | SKEY?= yes 15 | # Set `YP' to `yes' to build with support for NIS/YP. 16 | YP?= yes 17 | 18 | CLANG_ARCH=aarch64 amd64 arm i386 mips64 mips64el powerpc powerpc64 riscv64 sparc64 19 | GCC4_ARCH=alpha hppa sh sparc64 20 | GCC3_ARCH=m88k 21 | LLD_ARCH=aarch64 amd64 arm i386 powerpc64 riscv64 22 | 23 | # m88k: ? 24 | PIE_ARCH=aarch64 alpha amd64 arm hppa i386 mips64 mips64el powerpc powerpc64 riscv64 sh sparc64 25 | STATICPIE_ARCH=aarch64 alpha amd64 arm hppa i386 mips64 mips64el powerpc powerpc64 riscv64 sh sparc64 26 | 27 | .for _arch in ${MACHINE_ARCH} 28 | .if !empty(GCC3_ARCH:M${_arch}) 29 | COMPILER_VERSION?=gcc3 30 | .elif !empty(GCC4_ARCH:M${_arch}) 31 | COMPILER_VERSION?=gcc4 32 | .elif !empty(CLANG_ARCH:M${_arch}) 33 | COMPILER_VERSION?=clang 34 | .endif 35 | 36 | .if !empty(GCC3_ARCH:M${_arch}) 37 | BUILD_GCC3?=yes 38 | .else 39 | BUILD_GCC3?=no 40 | .endif 41 | .if !empty(GCC4_ARCH:M${_arch}) 42 | BUILD_GCC4?=yes 43 | .else 44 | BUILD_GCC4?=no 45 | .endif 46 | .if !empty(CLANG_ARCH:M${_arch}) 47 | BUILD_CLANG?=yes 48 | .else 49 | BUILD_CLANG?=no 50 | .endif 51 | 52 | .if !empty(LLD_ARCH:M${_arch}) 53 | LINKER_VERSION?=lld 54 | .else 55 | LINKER_VERSION?=bfd 56 | .endif 57 | 58 | .if !empty(STATICPIE_ARCH:M${_arch}) 59 | STATICPIE?=-pie 60 | .endif 61 | 62 | # Executables are always PIC on mips64. 63 | # Do not pass -fno-pie to the compiler because clang does not accept it. 64 | .if ${MACHINE_ARCH} == "mips64" || ${MACHINE_ARCH} == "mips64el" 65 | NOPIE_FLAGS?= 66 | .endif 67 | 68 | .if !empty(PIE_ARCH:M${_arch}) 69 | NOPIE_FLAGS?=-fno-pie 70 | NOPIE_LDFLAGS?=-nopie 71 | PIE_DEFAULT?=${DEFAULT_PIE_DEF} 72 | .else 73 | NOPIE_FLAGS?= 74 | PIE_DEFAULT?= 75 | .endif 76 | .endfor 77 | 78 | # where the system object and source trees are kept; can be configurable 79 | # by the user in case they want them in ~/foosrc and ~/fooobj, for example 80 | BSDSRCDIR?= /usr/src 81 | BSDOBJDIR?= /usr/obj 82 | 83 | BINGRP?= bin 84 | BINOWN?= root 85 | BINMODE?= 555 86 | NONBINMODE?= 444 87 | DIRMODE?= 755 88 | 89 | SHAREDIR?= /usr/share 90 | SHAREGRP?= bin 91 | SHAREOWN?= root 92 | SHAREMODE?= ${NONBINMODE} 93 | 94 | MANDIR?= /usr/share/man/man 95 | MANGRP?= bin 96 | MANOWN?= root 97 | MANMODE?= ${NONBINMODE} 98 | 99 | LIBDIR?= /usr/lib 100 | LIBGRP?= ${BINGRP} 101 | LIBOWN?= ${BINOWN} 102 | LIBMODE?= ${NONBINMODE} 103 | 104 | DOCDIR?= /usr/share/doc 105 | DOCGRP?= bin 106 | DOCOWN?= root 107 | DOCMODE?= ${NONBINMODE} 108 | 109 | LOCALEDIR?= /usr/share/locale 110 | LOCALEGRP?= wheel 111 | LOCALEOWN?= root 112 | LOCALEMODE?= ${NONBINMODE} 113 | 114 | .if !defined(CDIAGFLAGS) 115 | CDIAGFLAGS= -Wall -Wpointer-arith -Wuninitialized -Wstrict-prototypes 116 | CDIAGFLAGS+= -Wmissing-prototypes -Wunused -Wsign-compare 117 | CDIAGFLAGS+= -Wshadow 118 | . if ${COMPILER_VERSION} == "gcc4" 119 | CDIAGFLAGS+= -Wdeclaration-after-statement 120 | . endif 121 | .endif 122 | 123 | # Shared files for system gnu configure, not used yet 124 | GNUSYSTEM_AUX_DIR?=${BSDSRCDIR}/share/gnu 125 | 126 | INSTALL_COPY?= -c 127 | .ifndef DEBUG 128 | INSTALL_STRIP?= -s 129 | .endif 130 | 131 | STATIC?= -static ${STATICPIE} 132 | 133 | # Define SYS_INCLUDE to indicate whether you want symbolic links to the system 134 | # source (``symlinks''), or a separate copy (``copies''); (latter useful 135 | # in environments where it's not possible to keep /sys publicly readable) 136 | #SYS_INCLUDE= symlinks 137 | 138 | # pic relocation flags. 139 | .if ${MACHINE_ARCH} == "alpha" || ${MACHINE_ARCH} == "powerpc" || \ 140 | ${MACHINE_ARCH} == "sparc64" 141 | PICFLAG?=-fPIC 142 | .else 143 | PICFLAG?=-fpic 144 | .endif 145 | 146 | .if ${MACHINE_ARCH} == "alpha" || ${MACHINE_ARCH} == "powerpc" || \ 147 | ${MACHINE_ARCH} == "sparc64" 148 | # big PIE 149 | DEFAULT_PIE_DEF=-DPIE_DEFAULT=2 150 | .else 151 | # small pie 152 | DEFAULT_PIE_DEF=-DPIE_DEFAULT=1 153 | .endif 154 | 155 | # don't try to generate PROFILED versions of libraries on machines 156 | # which don't support profiling. 157 | .if 0 158 | NOPROFILE= 159 | .endif 160 | 161 | BUILDUSER?= build 162 | WOBJGROUP?= wobj 163 | WOBJUMASK?= 007 164 | 165 | BSD_OWN_MK=Done 166 | 167 | .PHONY: spell clean cleandir obj manpages print all \ 168 | depend beforedepend afterdepend cleandepend subdirdepend \ 169 | all cleanman includes \ 170 | beforeinstall realinstall maninstall afterinstall install 171 | -------------------------------------------------------------------------------- /lowparse.h: -------------------------------------------------------------------------------- 1 | #ifndef LOWPARSE_H 2 | #define LOWPARSE_H 3 | 4 | /* $OpenBSD: lowparse.h,v 1.11 2012/10/02 10:29:31 espie Exp $ */ 5 | 6 | /* 7 | * Copyright (c) 1999 Marc Espie. 8 | * 9 | * Extensive code changes for the OpenBSD project. 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions 13 | * are met: 14 | * 1. Redistributions of source code must retain the above copyright 15 | * notice, this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright 17 | * notice, this list of conditions and the following disclaimer in the 18 | * documentation and/or other materials provided with the distribution. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 24 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | */ 32 | /* low-level parsing module: 33 | * select input stream to parse, and do high-speed processing of 34 | * lines: skipping comments, handling continuation lines, or skipping 35 | * over dead conditionals. 36 | * 37 | * Basic template: 38 | * 39 | * Parse_Fromxxx(source); 40 | * do { 41 | * while ((line = Parse_ReadNormalLine(&buf)) != NULL) { 42 | * handle line, use Parse_Fromxxx to push includes, 43 | * Parse_ReadNextConditional to get over non-conditional lines. 44 | * or Parse_ReadUnparsedLine to handle special cases manually. 45 | * } 46 | * } while (Parse_NextFile()); 47 | */ 48 | 49 | /* Selection of input stream */ 50 | /* Parse_FromFile(filename, filehandle); 51 | * Push given filehandle on the input stack, using filename for diagnostic 52 | * messages. The module assumes ownership of the filehandle and of 53 | * the filename: provide copies if necessary. */ 54 | extern void Parse_FromFile(const char *, FILE *); 55 | /* Parse_FromString(str, lineno); 56 | * Push expanded string str on the input stack, assuming it starts at 57 | * lineno in the current file. This is used to reparse .for loops 58 | * after the variable has been expanded, hence no need to respecify 59 | * the filename. The module assumes ownership of the string: provide a 60 | * copy if necessary. */ 61 | extern void Parse_FromString(char *, unsigned long); 62 | 63 | /* Error reporting, and tagging of read structures. */ 64 | /* lineno = Parse_Getlineno(); 65 | * Returns the current lineno. */ 66 | extern unsigned long Parse_Getlineno(void); 67 | /* name = Parse_Getfilename(); 68 | * Returns the current filename. Safe to keep without copying. */ 69 | extern const char *Parse_Getfilename(void); 70 | 71 | /* Parse_FillLocation(origin) 72 | * Fill the location pointed by origin with the current location. */ 73 | extern void Parse_FillLocation(Location *); 74 | 75 | /* Parse_SetLocation(origin) 76 | * Set the "parse location" to a given origin. 77 | * Used for parse errors that occur during variable expansion at 78 | * runtime. 79 | */ 80 | extern void Parse_SetLocation(Location *); 81 | 82 | /* continue = Parse_NextFile(); 83 | * Advance parsing to the next file in the input stack. Returns true 84 | * if there is parsing left to do. 85 | */ 86 | extern bool Parse_NextFile(void); 87 | 88 | 89 | /* line = Parse_ReadNormalLine(buf); 90 | * Reads next line into buffer and return its contents. Handles line 91 | * continuation, remove extra blanks, and skip trivial comments. tabs at 92 | * beginning of line are left alone, to be able to recognize target 93 | * lines. */ 94 | extern char *Parse_ReadNormalLine(Buffer); 95 | 96 | /* line = ParseReadNextConditionalLine(buf); 97 | * Returns next conditional line, skipping over everything else. */ 98 | extern char *Parse_ReadNextConditionalLine(Buffer); 99 | /* line = ParseReadUnparsedLine(buf, type); 100 | * Reads line without parsing anything beyond continuations. 101 | * Handle special cases such as conditional lines, or lines that 102 | * need a reparse (loops). */ 103 | extern char *Parse_ReadUnparsedLine(Buffer, const char *); 104 | /* Parse_ReportErrors(); 105 | * At end of parsing, report on fatal errors. 106 | */ 107 | extern void Parse_ReportErrors(void); 108 | 109 | extern void Parse_setcurdir(const char *); 110 | #endif 111 | -------------------------------------------------------------------------------- /generate.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: generate.c,v 1.18 2016/10/14 09:27:21 natano Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 2001 Marc Espie. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 16 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 19 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | #include "stats.h" 36 | #include "cond_int.h" 37 | #include "var_int.h" 38 | #include "node_int.h" 39 | 40 | #include "portable.h" 41 | 42 | #define M(x) x, #x 43 | char *table_var[] = { 44 | M(TARGET), 45 | M(OODATE), 46 | M(ALLSRC), 47 | M(IMPSRC), 48 | M(PREFIX), 49 | M(ARCHIVE), 50 | M(MEMBER), 51 | M(LONGTARGET), 52 | M(LONGOODATE), 53 | M(LONGALLSRC), 54 | M(LONGIMPSRC), 55 | M(LONGPREFIX), 56 | M(LONGARCHIVE), 57 | M(LONGMEMBER), 58 | M(FTARGET), 59 | M(DTARGET), 60 | M(FPREFIX), 61 | M(DPREFIX), 62 | M(FARCHIVE), 63 | M(DARCHIVE), 64 | M(FMEMBER), 65 | M(DMEMBER), 66 | M(FIMPSRC), 67 | M(DIMPSRC), 68 | NULL 69 | }; 70 | 71 | char *table_cond[] = { 72 | M(COND_IF), 73 | M(COND_IFDEF), 74 | M(COND_IFNDEF), 75 | M(COND_IFMAKE), 76 | M(COND_IFNMAKE), 77 | M(COND_ELSE), 78 | M(COND_ELIF), 79 | M(COND_ELIFDEF), 80 | M(COND_ELIFNDEF), 81 | M(COND_ELIFMAKE), 82 | M(COND_ELIFNMAKE), 83 | M(COND_ENDIF), 84 | M(COND_FOR), 85 | M(COND_ENDFOR), 86 | M(COND_INCLUDE), 87 | M(COND_UNDEF), 88 | M(COND_POISON), 89 | NULL 90 | }; 91 | 92 | char *table_nodes[] = { 93 | M(NODE_DEFAULT), 94 | M(NODE_EXEC), 95 | M(NODE_IGNORE), 96 | M(NODE_INCLUDES), 97 | M(NODE_INVISIBLE), 98 | M(NODE_JOIN), 99 | M(NODE_LIBS), 100 | M(NODE_MADE), 101 | M(NODE_MAIN), 102 | M(NODE_MAKE), 103 | M(NODE_MAKEFLAGS), 104 | M(NODE_MFLAGS), 105 | M(NODE_NOTMAIN), 106 | M(NODE_NOTPARALLEL), 107 | M(NODE_NO_PARALLEL), 108 | M(NODE_NULL), 109 | M(NODE_OPTIONAL), 110 | M(NODE_ORDER), 111 | M(NODE_PARALLEL), 112 | M(NODE_PATH), 113 | M(NODE_PHONY), 114 | M(NODE_PRECIOUS), 115 | M(NODE_RECURSIVE), 116 | M(NODE_SILENT), 117 | M(NODE_SINGLESHELL), 118 | M(NODE_SUFFIXES), 119 | M(NODE_USE), 120 | M(NODE_WAIT), 121 | M(NODE_BEGIN), 122 | M(NODE_END), 123 | M(NODE_INTERRUPT), 124 | M(NODE_CHEAP), 125 | M(NODE_EXPENSIVE), 126 | M(NODE_POSIX), 127 | M(NODE_SCCS_GET), 128 | NULL 129 | }; 130 | 131 | 132 | char **table[] = { 133 | table_var, 134 | table_cond, 135 | table_nodes 136 | }; 137 | 138 | int 139 | main(int argc, char *argv[]) 140 | { 141 | uint32_t i; 142 | uint32_t v; 143 | uint32_t h; 144 | uint32_t slots; 145 | const char *errstr; 146 | const char *e; 147 | char **occupied; 148 | char **t; 149 | int tn; 150 | 151 | Init_Stats(); 152 | if (argc != 3) 153 | exit(1); 154 | 155 | tn = strtonum(argv[1], 1, INT_MAX, &errstr); 156 | if (errstr) 157 | exit(1); 158 | t = table[tn-1]; 159 | slots = strtonum(argv[2], 0, INT_MAX, &errstr); 160 | if (errstr) 161 | exit(1); 162 | if (slots) { 163 | occupied = calloc(slots, sizeof(char *)); 164 | if (!occupied) 165 | exit(1); 166 | } else 167 | occupied = NULL; 168 | 169 | printf("/* File created by generate %d %d, do not edit */\n", 170 | tn, slots); 171 | for (i = 0; t[i] != NULL; i++) { 172 | e = NULL; 173 | v = ohash_interval(t[i], &e); 174 | if (slots) { 175 | h = v % slots; 176 | if (occupied[h]) { 177 | fprintf(stderr, 178 | "Collision: %s / %s (%d)\n", occupied[h], 179 | t[i], h); 180 | exit(1); 181 | } 182 | occupied[h] = t[i]; 183 | } 184 | i++; 185 | printf("#define K_%s %u\n", t[i], v); 186 | } 187 | if (slots) 188 | printf("#define MAGICSLOTS%d %u\n", tn, slots); 189 | exit(0); 190 | } 191 | -------------------------------------------------------------------------------- /memory.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: memory.c,v 1.11 2014/05/18 08:08:50 espie Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1988, 1989, 1990, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * Copyright (c) 1989 by Berkeley Softworks 7 | * All rights reserved. 8 | * 9 | * This code is derived from software contributed to Berkeley by 10 | * Adam de Boor. 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions 14 | * are met: 15 | * 1. Redistributions of source code must retain the above copyright 16 | * notice, this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 3. Neither the name of the University nor the names of its contributors 21 | * may be used to endorse or promote products derived from this software 22 | * without specific prior written permission. 23 | * 24 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 | * SUCH DAMAGE. 35 | */ 36 | 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include "defines.h" 48 | #include "memory.h" 49 | 50 | static void enomem(size_t); 51 | static void enocmem(size_t, size_t); 52 | 53 | /* 54 | * emalloc -- 55 | * malloc, but die on error. 56 | */ 57 | void * 58 | emalloc(size_t size) 59 | { 60 | void *p; 61 | 62 | if ((p = malloc(size)) == NULL) 63 | enomem(size); 64 | return p; 65 | } 66 | 67 | /* 68 | * estrdup -- 69 | * strdup, but die on error. 70 | */ 71 | char * 72 | estrdup(const char *str) 73 | { 74 | char *p; 75 | size_t size; 76 | 77 | size = strlen(str) + 1; 78 | 79 | p = emalloc(size); 80 | memcpy(p, str, size); 81 | return p; 82 | } 83 | 84 | /* 85 | * erealloc -- 86 | * realloc, but die on error. 87 | */ 88 | void * 89 | erealloc(void *ptr, size_t size) 90 | { 91 | if ((ptr = realloc(ptr, size)) == NULL) 92 | enomem(size); 93 | return ptr; 94 | } 95 | 96 | void * 97 | ereallocarray(void *ptr, size_t s1, size_t s2) 98 | { 99 | if ((ptr = reallocarray(ptr, s1, s2)) == NULL) 100 | enocmem(s1, s2); 101 | return ptr; 102 | } 103 | 104 | /* Support routines for hash tables. */ 105 | void * 106 | hash_calloc(size_t n, size_t s, void *u UNUSED) 107 | { 108 | void *p; 109 | 110 | if ((p = calloc(n, s)) == NULL) 111 | enocmem(n, s); 112 | return p; 113 | } 114 | 115 | void 116 | hash_free(void *p, void *u UNUSED) 117 | { 118 | free(p); 119 | } 120 | 121 | void * 122 | element_alloc(size_t s, void *u UNUSED) 123 | { 124 | return emalloc(s); 125 | } 126 | 127 | 128 | 129 | /* 130 | * enomem -- 131 | * die when out of memory. 132 | */ 133 | void 134 | enomem(size_t size) 135 | { 136 | fprintf(stderr, "make: %s (%zu)\n", strerror(errno), size); 137 | exit(2); 138 | } 139 | 140 | void 141 | enocmem(size_t sz1, size_t sz2) 142 | { 143 | fprintf(stderr, "make: %s (%zu * %zu)\n", strerror(errno), sz1, sz2); 144 | exit(2); 145 | } 146 | /* 147 | * esetenv -- 148 | * change environment, die on error. 149 | */ 150 | void 151 | esetenv(const char *name, const char *value) 152 | { 153 | if (setenv(name, value, 1) == 0) 154 | return; 155 | 156 | fprintf(stderr, "make: setenv failed (%s)\n", strerror(errno)); 157 | exit(2); 158 | } 159 | 160 | 161 | /* 162 | * enunlink -- 163 | * Remove a file carefully, avoiding directories. 164 | */ 165 | int 166 | eunlink(const char *file) 167 | { 168 | struct stat st; 169 | 170 | if (lstat(file, &st) == -1) 171 | return -1; 172 | 173 | if (S_ISDIR(st.st_mode)) { 174 | errno = EISDIR; 175 | return -1; 176 | } 177 | return unlink(file); 178 | } 179 | 180 | void 181 | free_hash(struct ohash *h) 182 | { 183 | void *e; 184 | unsigned int i; 185 | 186 | for (e = ohash_first(h, &i); e != NULL; e = ohash_next(h, &i)) 187 | free(e); 188 | ohash_delete(h); 189 | } 190 | 191 | -------------------------------------------------------------------------------- /config.h: -------------------------------------------------------------------------------- 1 | #ifndef CONFIG_H 2 | #define CONFIG_H 3 | 4 | #include "portable.h" 5 | 6 | /* $OpenBSD: config.h,v 1.20 2014/10/18 07:50:06 espie Exp $ */ 7 | /* $NetBSD: config.h,v 1.7 1996/11/06 17:59:03 christos Exp $ */ 8 | 9 | /* 10 | * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. 11 | * Copyright (c) 1988, 1989 by Adam de Boor 12 | * Copyright (c) 1989 by Berkeley Softworks 13 | * All rights reserved. 14 | * 15 | * This code is derived from software contributed to Berkeley by 16 | * Adam de Boor. 17 | * 18 | * Redistribution and use in source and binary forms, with or without 19 | * modification, are permitted provided that the following conditions 20 | * are met: 21 | * 1. Redistributions of source code must retain the above copyright 22 | * notice, this list of conditions and the following disclaimer. 23 | * 2. Redistributions in binary form must reproduce the above copyright 24 | * notice, this list of conditions and the following disclaimer in the 25 | * documentation and/or other materials provided with the distribution. 26 | * 3. Neither the name of the University nor the names of its contributors 27 | * may be used to endorse or promote products derived from this software 28 | * without specific prior written permission. 29 | * 30 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 31 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 32 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 33 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 34 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 35 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 36 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 37 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 38 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 39 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 40 | * SUCH DAMAGE. 41 | * 42 | * from: @(#)config.h 8.1 (Berkeley) 6/6/93 43 | */ 44 | 45 | #define DEFSHELL 1 /* Bourne shell */ 46 | 47 | /* 48 | * DEFMAXJOBS 49 | * DEFMAXLOCAL 50 | * These control the default concurrency. On no occasion will more 51 | * than DEFMAXJOBS targets be created at once (locally or remotely) 52 | * DEFMAXLOCAL is the highest number of targets which will be 53 | * created on the local machine at once. Note that if you set this 54 | * to 0, nothing will ever happen... 55 | */ 56 | #define DEFMAXJOBS 4 57 | #define DEFMAXLOCAL 1 58 | 59 | /* 60 | * SYSVINCLUDE 61 | * Recognize system V like include directives [include "filename"] 62 | * SYSVVARSUB 63 | * Recognize system V like ${VAR:x=y} variable substitutions 64 | */ 65 | #define SYSVINCLUDE 66 | #define SYSVVARSUB 67 | 68 | /* 69 | * SUNSHCMD 70 | * Recognize SunOS and Solaris: 71 | * VAR :sh= CMD # Assign VAR to the command substitution of CMD 72 | * ${VAR:sh} # Return the command substitution of the value 73 | * # of ${VAR} 74 | */ 75 | #define SUNSHCMD 76 | 77 | #if !defined(__svr4__) && !defined(__SVR4) && !defined(__ELF__) 78 | # ifndef RANLIBMAG 79 | # define RANLIBMAG "__.SYMDEF" 80 | # endif 81 | #endif 82 | 83 | #ifdef HAS_EXTENDED_GETCWD 84 | #define dogetcwd() getcwd(NULL, 0) 85 | #else 86 | #define dogetcwd() getcwd(emalloc(PATH_MAX), PATH_MAX) 87 | #endif 88 | 89 | #ifdef SYSVINCLUDE 90 | #define DOFEATURE_SYSVINCLUDE FEATURE_SYSVINCLUDE 91 | #else 92 | #define DOFEATURE_SYSVINCLUDE 0 93 | #endif 94 | #ifdef SYSVVARSUB 95 | #define DOFEATURE_SYSVVARSUB FEATURE_SYSVVARSUB 96 | #else 97 | #define DOFEATURE_SYSVVARSUB 0 98 | #endif 99 | #ifdef SUNSHCMD 100 | #define DOFEATURE_SUNSHCMD FEATURE_SUNSHCMD 101 | #else 102 | #define DOFEATURE_SUNSHCMD 0 103 | #endif 104 | 105 | #ifndef DEFAULT_FEATURES 106 | #define DEFAULT_FEATURES (FEATURE_UPPERLOWER | DOFEATURE_SYSVVARSUB | DOFEATURE_SYSVINCLUDE | DOFEATURE_SUNSHCMD | FEATURE_RECVARS | FEATURE_CONDINCLUDE) 107 | #endif 108 | 109 | #define FEATURES(x) ((DEFAULT_FEATURES & (x)) != 0) 110 | #define FEATURE_ODE 1 111 | #define FEATURE_UNIQ 2 112 | #define FEATURE_SORT 4 113 | #define FEATURE_UPPERLOWER 8 114 | #define FEATURE_SYSVVARSUB 16 115 | #define FEATURE_SYSVINCLUDE 32 116 | #define FEATURE_SUNSHCMD 64 117 | #define FEATURE_RECVARS 128 118 | #define FEATURE_CONDINCLUDE 256 119 | #define FEATURE_ASSIGN 512 120 | #define FEATURE_EXECMOD 1024 121 | 122 | /* 123 | * There are several places where expandable buffers are used (parse.c and 124 | * var.c). This constant is merely the starting point for those buffers. If 125 | * lines tend to be much shorter than this, it would be best to reduce BSIZE. 126 | * If longer, it should be increased. Reducing it will cause more copying to 127 | * be done for longer lines, but will save space for shorter ones. In any 128 | * case, it ought to be a power of two simply because most storage allocation 129 | * schemes allocate in powers of two. 130 | */ 131 | #define MAKE_BSIZE 256 /* starting size for expandable buffers */ 132 | 133 | #endif 134 | -------------------------------------------------------------------------------- /mk/sys.mk: -------------------------------------------------------------------------------- 1 | # $OpenBSD: sys.mk,v 1.89 2021/02/06 21:26:19 deraadt Exp $ 2 | # $NetBSD: sys.mk,v 1.27 1996/04/10 05:47:19 mycroft Exp $ 3 | # @(#)sys.mk 5.11 (Berkeley) 3/13/91 4 | 5 | .if defined(EXTRA_SYS_MK_INCLUDES) 6 | .for __SYS_MK_INCLUDE in ${EXTRA_SYS_MK_INCLUDES} 7 | .include ${__SYS_MK_INCLUDE} 8 | .endfor 9 | .endif 10 | 11 | unix= We run OpenBSD. 12 | OSMAJOR= 6 13 | OSMINOR= 9 14 | OSREV= $(OSMAJOR).$(OSMINOR) 15 | OSrev= $(OSMAJOR)$(OSMINOR) 16 | 17 | .SUFFIXES: .out .a .o .c .cc .C .cxx .cpp .F .f .r .y .l .s .S .cl .p .h .sh .m4 18 | 19 | AR?= ar 20 | ARFLAGS?= r 21 | RANLIB?= ranlib 22 | LORDER?= lorder 23 | 24 | AS?= as 25 | AFLAGS?= ${DEBUG} 26 | COMPILE.s?= ${CC} ${AFLAGS} -c 27 | LINK.s?= ${CC} ${AFLAGS} ${LDFLAGS} 28 | COMPILE.S?= ${CC} ${AFLAGS} ${CPPFLAGS} -c 29 | LINK.S?= ${CC} ${AFLAGS} ${CPPFLAGS} ${LDFLAGS} 30 | 31 | CC?= cc 32 | 33 | PIPE?= -pipe 34 | 35 | CFLAGS?= -O2 ${PIPE} ${DEBUG} 36 | COMPILE.c?= ${CC} ${CFLAGS} ${CPPFLAGS} -c 37 | LINK.c?= ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} 38 | 39 | HOSTCC?= cc 40 | 41 | CXX?= c++ 42 | CXXFLAGS?= -O2 ${PIPE} ${DEBUG} 43 | COMPILE.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c 44 | LINK.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS} 45 | 46 | CPP?= cpp 47 | CPPFLAGS?= 48 | 49 | FC?= f77 50 | FFLAGS?= -O2 51 | RFLAGS?= 52 | COMPILE.f?= ${FC} ${FFLAGS} -c 53 | LINK.f?= ${FC} ${FFLAGS} ${LDFLAGS} 54 | COMPILE.F?= ${FC} ${FFLAGS} ${CPPFLAGS} -c 55 | LINK.F?= ${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS} 56 | COMPILE.r?= ${FC} ${FFLAGS} ${RFLAGS} -c 57 | LINK.r?= ${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS} 58 | 59 | LEX?= lex 60 | LFLAGS?= 61 | LEX.l?= ${LEX} ${LFLAGS} 62 | 63 | LD?= ld 64 | LDFLAGS+= ${DEBUG} 65 | 66 | MAKE?= make 67 | 68 | PC?= pc 69 | PFLAGS?= 70 | COMPILE.p?= ${PC} ${PFLAGS} ${CPPFLAGS} -c 71 | LINK.p?= ${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS} 72 | 73 | SHELL?= sh 74 | 75 | YACC?= yacc 76 | YFLAGS?= -d 77 | YACC.y?= ${YACC} ${YFLAGS} 78 | 79 | INSTALL?= install 80 | 81 | CTAGS?= /usr/bin/ctags 82 | 83 | # C 84 | .c: 85 | ${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} 86 | .c.o: 87 | ${COMPILE.c} ${.IMPSRC} 88 | .c.a: 89 | ${COMPILE.c} ${.IMPSRC} 90 | ${AR} ${ARFLAGS} $@ $*.o 91 | rm -f $*.o 92 | 93 | # C++ 94 | .cc: 95 | ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} 96 | .cc.o: 97 | ${COMPILE.cc} ${.IMPSRC} 98 | .cc.a: 99 | ${COMPILE.cc} ${.IMPSRC} 100 | ${AR} ${ARFLAGS} $@ $*.o 101 | rm -f $*.o 102 | 103 | .C: 104 | ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} 105 | .C.o: 106 | ${COMPILE.cc} ${.IMPSRC} 107 | .C.a: 108 | ${COMPILE.cc} ${.IMPSRC} 109 | ${AR} ${ARFLAGS} $@ $*.o 110 | rm -f $*.o 111 | 112 | .cxx: 113 | ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} 114 | .cxx.o: 115 | ${COMPILE.cc} ${.IMPSRC} 116 | .cxx.a: 117 | ${COMPILE.cc} ${.IMPSRC} 118 | ${AR} ${ARFLAGS} $@ $*.o 119 | rm -f $*.o 120 | 121 | .cpp: 122 | ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} 123 | .cpp.o: 124 | ${COMPILE.cc} ${.IMPSRC} 125 | .cpp.a: 126 | ${COMPILE.cc} ${.IMPSRC} 127 | ${AR} ${ARFLAGS} $@ $*.o 128 | rm -f $*.o 129 | 130 | # Fortran/Ratfor 131 | .f: 132 | ${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} 133 | .f.o: 134 | ${COMPILE.f} ${.IMPSRC} 135 | .f.a: 136 | ${COMPILE.f} ${.IMPSRC} 137 | ${AR} ${ARFLAGS} $@ $*.o 138 | rm -f $*.o 139 | 140 | .F: 141 | ${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} 142 | .F.o: 143 | ${COMPILE.F} ${.IMPSRC} 144 | .F.a: 145 | ${COMPILE.F} ${.IMPSRC} 146 | ${AR} ${ARFLAGS} $@ $*.o 147 | rm -f $*.o 148 | 149 | .r: 150 | ${LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} 151 | .r.o: 152 | ${COMPILE.r} ${.IMPSRC} 153 | .r.a: 154 | ${COMPILE.r} ${.IMPSRC} 155 | ${AR} ${ARFLAGS} $@ $*.o 156 | rm -f $*.o 157 | 158 | # Pascal 159 | .p: 160 | ${LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} 161 | .p.o: 162 | ${COMPILE.p} ${.IMPSRC} 163 | .p.a: 164 | ${COMPILE.p} ${.IMPSRC} 165 | ${AR} ${ARFLAGS} $@ $*.o 166 | rm -f $*.o 167 | 168 | # Assembly 169 | .s: 170 | ${LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} 171 | .s.o: 172 | ${COMPILE.s} ${.IMPSRC} 173 | .s.a: 174 | ${COMPILE.s} ${.IMPSRC} 175 | ${AR} ${ARFLAGS} $@ $*.o 176 | rm -f $*.o 177 | .S: 178 | ${LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} 179 | .S.o: 180 | ${COMPILE.S} ${.IMPSRC} 181 | .S.a: 182 | ${COMPILE.S} ${.IMPSRC} 183 | ${AR} ${ARFLAGS} $@ $*.o 184 | rm -f $*.o 185 | 186 | # Lex 187 | .l: 188 | ${LEX.l} -o lex.${.PREFIX}.c ${.IMPSRC} 189 | ${LINK.c} -o ${.TARGET} lex.${.PREFIX}.c ${LDLIBS} -ll 190 | rm -f lex.${.PREFIX}.c 191 | .l.c: 192 | ${LEX.l} -o ${.TARGET} ${.IMPSRC} 193 | .l.o: 194 | ${LEX.l} -o lex.${.PREFIX}.c ${.IMPSRC} 195 | ${COMPILE.c} -o ${.TARGET} lex.${.PREFIX}.c 196 | rm -f lex.${.PREFIX}.c 197 | if test -f ${.TARGET:R}.d; then sed -i -e 's,lex.${.PREFIX}.c,${.IMPSRC},' ${.TARGET:R}.d; fi 198 | 199 | # Yacc 200 | .y: 201 | ${YACC.y} ${.IMPSRC} 202 | ${LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS} 203 | rm -f y.tab.c 204 | .y.c: 205 | ${YACC.y} ${.IMPSRC} 206 | mv y.tab.c ${.TARGET} 207 | .y.o: 208 | ${YACC.y} ${.IMPSRC} 209 | ${COMPILE.c} -o ${.TARGET} y.tab.c 210 | rm -f y.tab.c 211 | if test -f ${.TARGET:R}.d; then sed -i -e 's,y.tab.c,${.IMPSRC},' ${.TARGET:R}.d; fi 212 | 213 | # Shell 214 | .sh: 215 | rm -f ${.TARGET} 216 | cp ${.IMPSRC} ${.TARGET} 217 | -------------------------------------------------------------------------------- /error.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: error.c,v 1.25 2015/09/27 16:58:16 guenther Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 2001 Marc Espie. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 16 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 19 | * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #include "config.h" 35 | #include "defines.h" 36 | #include "error.h" 37 | #include "job.h" 38 | #include "targ.h" 39 | #include "var.h" 40 | #ifndef LOCATION_TYPE 41 | #include "location.h" 42 | #endif 43 | 44 | #include "lowparse.h" 45 | #include "dump.h" 46 | 47 | int fatal_errors = 0; 48 | 49 | static void ParseVErrorInternal(const Location *, int, const char *, va_list) 50 | __attribute__((__format__ (printf, 3, 0))); 51 | /*- 52 | * Error -- 53 | * Print an error message given its format. 54 | */ 55 | void 56 | Error(const char *fmt, ...) 57 | { 58 | va_list ap; 59 | 60 | va_start(ap, fmt); 61 | (void)vfprintf(stderr, fmt, ap); 62 | va_end(ap); 63 | (void)fprintf(stderr, "\n"); 64 | } 65 | 66 | /*- 67 | * Fatal -- 68 | * Produce a Fatal error message. If jobs are running, waits for them 69 | * to finish. 70 | * 71 | * Side Effects: 72 | * The program exits 73 | */ 74 | void 75 | Fatal(const char *fmt, ...) 76 | { 77 | va_list ap; 78 | 79 | Job_Wait(); 80 | 81 | va_start(ap, fmt); 82 | (void)vfprintf(stderr, fmt, ap); 83 | va_end(ap); 84 | (void)fprintf(stderr, "\n"); 85 | 86 | if (DEBUG(GRAPH2)) 87 | post_mortem(); 88 | exit(2); /* Not 1 so -q can distinguish error */ 89 | } 90 | 91 | /* 92 | * Punt -- 93 | * Major exception once jobs are being created. Kills all jobs, prints 94 | * a message and exits. 95 | * 96 | * Side Effects: 97 | * All children are killed indiscriminately and the program Lib_Exits 98 | */ 99 | void 100 | Punt(const char *fmt, ...) 101 | { 102 | if (fmt) { 103 | va_list ap; 104 | 105 | va_start(ap, fmt); 106 | (void)fprintf(stderr, "make: "); 107 | (void)vfprintf(stderr, fmt, ap); 108 | va_end(ap); 109 | (void)fprintf(stderr, "\n"); 110 | } 111 | 112 | Job_AbortAll(); 113 | if (DEBUG(GRAPH2)) 114 | post_mortem(); 115 | exit(2); /* Not 1, so -q can distinguish error */ 116 | } 117 | 118 | /* 119 | * Finish -- 120 | * Called when aborting due to errors in command or fatal signal 121 | * 122 | * Side Effects: 123 | * The program exits 124 | */ 125 | void 126 | Finish() 127 | { 128 | Job_Wait(); 129 | print_errors(); 130 | if (DEBUG(GRAPH2)) 131 | post_mortem(); 132 | exit(2); /* Not 1 so -q can distinguish error */ 133 | } 134 | 135 | 136 | /*- 137 | * ParseVErrorInternal -- 138 | * Error message abort function for parsing. Prints out the context 139 | * of the error (line number and file) as well as the message with 140 | * two optional arguments. 141 | * 142 | * Side Effects: 143 | * "fatals" is incremented if the level is PARSE_FATAL. 144 | */ 145 | static void 146 | ParseVErrorInternal(const Location *origin, int type, const char *fmt, 147 | va_list ap) 148 | { 149 | static bool first = true; 150 | fprintf(stderr, "*** %s", 151 | type == PARSE_WARNING ? "Warning" : "Parse error"); 152 | if (first) { 153 | fprintf(stderr, " in %s: ", Var_Value(".CURDIR")); 154 | first = false; 155 | } else 156 | fprintf(stderr, ": "); 157 | vfprintf(stderr, fmt, ap); 158 | va_end(ap); 159 | if (origin->fname) 160 | fprintf(stderr, " (%s:%lu)", origin->fname, origin->lineno); 161 | fprintf(stderr, "\n"); 162 | if (type == PARSE_FATAL) 163 | fatal_errors ++; 164 | } 165 | 166 | /*- 167 | * Parse_Error -- 168 | * External interface to ParseVErrorInternal; uses the default filename 169 | * Line number. 170 | */ 171 | void 172 | Parse_Error(int type, const char *fmt, ...) 173 | { 174 | va_list ap; 175 | Location l; 176 | 177 | va_start(ap, fmt); 178 | Parse_FillLocation(&l); 179 | ParseVErrorInternal(&l, type, fmt, ap); 180 | va_end(ap); 181 | } 182 | -------------------------------------------------------------------------------- /dir.h: -------------------------------------------------------------------------------- 1 | #ifndef DIR_H 2 | #define DIR_H 3 | 4 | /* $OpenBSD: dir.h,v 1.29 2013/04/23 14:32:53 espie Exp $ */ 5 | /* $NetBSD: dir.h,v 1.4 1996/11/06 17:59:05 christos Exp $ */ 6 | 7 | /* 8 | * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. 9 | * Copyright (c) 1988, 1989 by Adam de Boor 10 | * Copyright (c) 1989 by Berkeley Softworks 11 | * All rights reserved. 12 | * 13 | * This code is derived from software contributed to Berkeley by 14 | * Adam de Boor. 15 | * 16 | * Redistribution and use in source and binary forms, with or without 17 | * modification, are permitted provided that the following conditions 18 | * are met: 19 | * 1. Redistributions of source code must retain the above copyright 20 | * notice, this list of conditions and the following disclaimer. 21 | * 2. Redistributions in binary form must reproduce the above copyright 22 | * notice, this list of conditions and the following disclaimer in the 23 | * documentation and/or other materials provided with the distribution. 24 | * 3. Neither the name of the University nor the names of its contributors 25 | * may be used to endorse or promote products derived from this software 26 | * without specific prior written permission. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 29 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 37 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38 | * SUCH DAMAGE. 39 | * 40 | * from: @(#)dir.h 8.1 (Berkeley) 6/6/93 41 | */ 42 | 43 | #include 44 | 45 | /* dir -- 46 | * Directory searching using wildcards and/or normal names... 47 | * Used both for source wildcarding in the Makefile and for finding 48 | * implicit sources. 49 | */ 50 | 51 | /* Dir_Init() 52 | * Initialize the module. 53 | */ 54 | extern void Dir_Init(void); 55 | 56 | /* 57 | * Manipulating paths. By convention, the empty path always allows for 58 | * finding files in the current directory. 59 | */ 60 | 61 | /* Dir_AddDiri(path, name, end); 62 | * Add directory (name, end) to a search path. 63 | */ 64 | extern void Dir_AddDiri(Lst, const char *, const char *); 65 | #define Dir_AddDir(l, n) Dir_AddDiri(l, n, NULL) 66 | 67 | /* Dir_Concat(p1, p2); 68 | * Concatenate two paths, adding dirs in p2 to the end of p1, but 69 | * avoiding duplicates. 70 | */ 71 | extern void Dir_Concat(Lst, Lst); 72 | 73 | /* Dir_Destroy(d); 74 | * Destroy a directory in a search path. 75 | */ 76 | extern void Dir_Destroy(void *); 77 | 78 | /* p2 = Dir_CopyDir(p); 79 | * Return a copy of a directory. Callback to duplicate search paths. 80 | */ 81 | extern void *Dir_CopyDir(void *); 82 | 83 | /* Dir_PrintPath(p); 84 | * Print the directory names along a given path. 85 | */ 86 | extern void Dir_PrintPath(Lst); 87 | 88 | 89 | /* 90 | * Handling file names, and looking them up in paths 91 | */ 92 | 93 | /* fullname = Dir_FindFileComplexi(name, end, path, checkCurdirFirst) 94 | * Searches for a file (name, end) on a given search path. If it exists, 95 | * return the fullname of the file, otherwise NULL. 96 | * The fullname is always a copy, and the caller is responsible for 97 | * free()ing it. 98 | * Looking for a simple name always looks in the current directory, 99 | * unless checkCurdirFirst is false. 100 | * For complex names, the current directory search only occurs for 101 | * paths with dot in them. 102 | */ 103 | extern char *Dir_FindFileComplexi(const char *, const char *, Lst, bool); 104 | #define Dir_FindFilei(n, e, p) Dir_FindFileComplexi(n, e, p, true) 105 | #define Dir_FindFileNoDoti(n, e, p) Dir_FindFileComplexi(n, e, p, false) 106 | #define Dir_FindFile(n, p) Dir_FindFilei(n, strchr(n, '\0'), p) 107 | #define Dir_FindFileNoDot(n, p) Dir_FindFileNoDoti(n, strchr(n, '\0'), p) 108 | 109 | /* stamp = Dir_MTime(gn); 110 | * Return the modification time of node gn, searching along 111 | * the default search path. 112 | * Side effect: the path and mtime fields of gn are filled in. 113 | * Return specific value if file can't be found, to be tested by 114 | * is_out_of_date(). 115 | */ 116 | extern struct timespec Dir_MTime(GNode *); 117 | 118 | 119 | 120 | 121 | /* 122 | * Misc 123 | */ 124 | 125 | /* List of directories to search when looking for targets. */ 126 | extern Lst defaultPath; 127 | 128 | 129 | /* communication between dir.c and direxpand.c */ 130 | struct PathEntry; 131 | extern struct PathEntry *dot; 132 | /* Handles wildcard expansion on a given directory. */ 133 | extern void Dir_MatchFilesi(const char *, const char *, struct PathEntry *, 134 | Lst); 135 | extern char *PathEntry_name(struct PathEntry *); 136 | #endif /* DIR_H */ 137 | -------------------------------------------------------------------------------- /engine.h: -------------------------------------------------------------------------------- 1 | #ifndef ENGINE_H 2 | #define ENGINE_H 3 | /* $OpenBSD: engine.h,v 1.17 2020/01/13 15:12:58 espie Exp $ */ 4 | 5 | /* 6 | * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. 7 | * Copyright (c) 1988, 1989 by Adam de Boor 8 | * Copyright (c) 1989 by Berkeley Softworks 9 | * All rights reserved. 10 | * 11 | * This code is derived from software contributed to Berkeley by 12 | * Adam de Boor. 13 | * 14 | * Redistribution and use in source and binary forms, with or without 15 | * modification, are permitted provided that the following conditions 16 | * are met: 17 | * 1. Redistributions of source code must retain the above copyright 18 | * notice, this list of conditions and the following disclaimer. 19 | * 2. Redistributions in binary form must reproduce the above copyright 20 | * notice, this list of conditions and the following disclaimer in the 21 | * documentation and/or other materials provided with the distribution. 22 | * 3. Neither the name of the University nor the names of its contributors 23 | * may be used to endorse or promote products derived from this software 24 | * without specific prior written permission. 25 | * 26 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 27 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 30 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 | * SUCH DAMAGE. 37 | * 38 | * from: @(#)job.h 8.1 (Berkeley) 6/6/93 39 | */ 40 | 41 | /* ok = node_find_valid_commands(node); 42 | * verify the integrity of a node's commands, pulling stuff off 43 | * .DEFAULT and other places if necessary. 44 | */ 45 | extern bool node_find_valid_commands(GNode *); 46 | 47 | /* node_failure(gn); 48 | * indicate we don't know how to make gn. 49 | * may continue with -k or if node was optional. 50 | */ 51 | extern void node_failure(GNode *); 52 | 53 | /* Job_Touch(node); 54 | * touch the path corresponding to a node or update the corresponding 55 | * archive object. 56 | */ 57 | extern void Job_Touch(GNode *); 58 | 59 | /* Make_TimeStamp(parent, child); 60 | * ensure parent is at least as recent as child. 61 | */ 62 | extern void Make_TimeStamp(GNode *, GNode *); 63 | 64 | /* Make_HandleUse(user_node, usee_node); 65 | * let user_node inherit the commands from usee_node 66 | */ 67 | extern void Make_HandleUse(GNode *, GNode *); 68 | 69 | /* old = Make_OODate(node); 70 | * check if a given node is out-of-date. 71 | */ 72 | extern bool Make_OODate(GNode *); 73 | 74 | /* Make_DoAllVar(node); 75 | * fill all dynamic variables for a node. 76 | */ 77 | extern void Make_DoAllVar(GNode *); 78 | 79 | /* status = run_gnode(gn): 80 | * fully run all commands of a node for compat mode. 81 | */ 82 | extern int run_gnode(GNode *); 83 | 84 | /*- 85 | * Job Table definitions. 86 | * 87 | * Each job has several things associated with it: 88 | * 1) The process id of the child shell 89 | * 2) The graph node describing the target of this job 90 | * 3) State associated to latest command run 91 | * 5) A word of flags which determine how the module handles errors, 92 | * echoing, etc. for the job 93 | * 94 | * The job "table" is kept as a linked Lst in 'jobs', with the number of 95 | * active jobs maintained in the 'nJobs' variable. At no time will this 96 | * exceed the value of 'maxJobs', initialized by the Job_Init function. 97 | * 98 | * When a job is finished, the Make_Update function is called on each of the 99 | * parents of the node which was just rebuilt. This takes care of the upward 100 | * traversal of the dependency graph. 101 | */ 102 | struct Job_ { 103 | struct Job_ *next; /* singly linked list */ 104 | pid_t pid; /* Current command process id */ 105 | Location *location; 106 | int code; /* exit status or signal code */ 107 | unsigned short exit_type; /* last child exit or signal */ 108 | #define JOB_EXIT_OKAY 0 109 | #define JOB_EXIT_BAD 1 110 | #define JOB_SIGNALED 2 111 | unsigned short flags; 112 | #define JOB_SILENT 0x001 /* Command was silent */ 113 | #define JOB_IS_EXPENSIVE 0x002 114 | #define JOB_LOST 0x004 /* sent signal to non-existing pid ? */ 115 | #define JOB_ERRCHECK 0x008 /* command wants errcheck */ 116 | #define JOB_KEEPERROR 0x010 /* should place job on error list */ 117 | LstNode next_cmd; /* Next command to run */ 118 | char *cmd; /* Last command run */ 119 | GNode *node; /* Target of this job */ 120 | }; 121 | 122 | /* Continuation-style running commands for the parallel engine */ 123 | 124 | /* job_attach_node(job, node): 125 | * attach a job to an allocated node, to be able to run commands 126 | */ 127 | extern void job_attach_node(Job *, GNode *); 128 | 129 | /* finished = job_run_next(job): 130 | * run next command for a job attached to a node. 131 | * return true when job is finished. 132 | */ 133 | extern bool job_run_next(Job *); 134 | 135 | /* handle_job_status(job, waitstatus): 136 | * process a wait return value corresponding to a job, display 137 | * messages and set job status accordingly. 138 | */ 139 | extern void handle_job_status(Job *, int); 140 | 141 | #endif 142 | --------------------------------------------------------------------------------