diff --git a/Makefile b/Makefile index f31a1df4a..c421c13ef 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # Master Makefile to compile everything in /usr/src except the system. -MAKE = exec make -$(MAKEFLAGS) +MAKE=make usage: @echo "" @@ -11,7 +11,7 @@ usage: @echo " make world # Compile everything (libraries & commands)" @echo " make includes # Install include files from src/" @echo " make libraries # Compile and install libraries" - @echo " make cmds # Compile all, commands, but don't install" + @echo " make commands # Compile all, commands, but don't install" @echo " make install # Compile and install commands" @echo " make depend # Generate required .depend files" @echo " make clean # Remove all compiler results" @@ -27,19 +27,19 @@ usage: # 'make install' target. # # etcfiles has to be done first. -world: includes depend libraries cmds install postinstall +world: includes depend libraries install postinstall includes: cd include && $(MAKE) install gcc libraries: - cd lib && $(MAKE) all install + cd lib && sh ack_build.sh obj depend all install -cmds: - if [ -f commands/Makefile ] ; then cd commands && $(MAKE) all; fi +gnu-libraries: + cd lib && sh gnu_build.sh obj depend all install -install:: - if [ -f commands/Makefile ] ; then cd commands && $(MAKE) install; fi +commands: + cd commands && $(MAKE) all depend:: mkdep kernel @@ -49,23 +49,33 @@ depend:: cd servers && $(MAKE) $@ cd drivers && $(MAKE) $@ - -clean:: - cd lib && $(MAKE) $@ - test ! -f commands/Makefile || { cd commands && $(MAKE) $@; } - etcfiles:: cd etc && $(MAKE) install -clean:: - cd test && $(MAKE) $@ +all:: + cd boot && $(MAKE) all + cd man && $(MAKE) all + cd commands && $(MAKE) all + cd tools && $(MAKE) all + cd servers && $(MAKE) all -all install clean:: - cd boot && $(MAKE) $@ - cd man && $(MAKE) $@ # First manpages, then commands - test ! -f commands/Makefile || { cd commands && $(MAKE) $@; } - cd tools && $(MAKE) $@ - cd servers && $(MAKE) $@ +install:: + cd boot && $(MAKE) all install + cd man && $(MAKE) all install + cd commands && $(MAKE) all install + cd tools && $(MAKE) all install + cd servers && $(MAKE) all install + +clean:: + cd boot && $(MAKE) clean + cd man && $(MAKE) clean + cd commands && $(MAKE) clean + cd tools && $(MAKE) clean + cd servers && $(MAKE) clean + cd lib && sh ack_build.sh clean + cd lib && sh gnu_build.sh clean + cd commands && $(MAKE) clean + cd test && $(MAKE) clean postinstall: cd etc && $(MAKE) $@ diff --git a/commands/ash/Makefile b/commands/ash/Makefile index 3acb338fe..f77087641 100644 --- a/commands/ash/Makefile +++ b/commands/ash/Makefile @@ -55,16 +55,16 @@ sh: $(OBJS) install: /usr/bin/ash /usr/bin/sh /bin/sh /bin/bigsh /usr/bin/ash: sh - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/sh: /usr/bin/ash - install -l $< $@ + install -l $> $@ /bin/sh: /usr/bin/ash - install -lcs $< $@ + install -lcs $> $@ /bin/bigsh: /usr/bin/ash - install -S 6600k -lcs $< $@ + install -S 6600k -lcs $> $@ clean: rm -f $(CLEANFILES) sh core @@ -111,6 +111,9 @@ mksyntax: mksyntax.c parser.h bltin/operators.h: bltin/mkexpr bltin/unary_op bltin/binary_op cd bltin && sh mkexpr unary_op binary_op +bltin/operators.c: bltin/mkexpr bltin/unary_op bltin/binary_op + cd bltin && sh mkexpr unary_op binary_op + # Dependencies you say? This will have to do. $(OBJS): error.h eval.h exec.h expand.h init.h input.h \ jobs.h machdep.h mail.h main.h memalloc.h mystring.h options.h \ diff --git a/commands/bmake/build.sh b/commands/bmake/build.sh deleted file mode 100755 index 4b80e12b4..000000000 --- a/commands/bmake/build.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -export PATH=$PATH:/usr/gnu/bin -make -f Makefile.boot clean -make -f Makefile.boot CFLAGS="-g -Wall -DHAVE_SETENV -DHAVE_STRERROR -DHAVE_STRDUP -DHAVE_STRFTIME -DHAVE_VSNPRINTF -D_GNU_SOURCE -DUSE_SELECT -DSYSV -D_POSIX_SOURCE" -#make -f Makefile.boot diff --git a/commands/bmake/main.c b/commands/bmake/main.c deleted file mode 100644 index 54f4e6744..000000000 --- a/commands/bmake/main.c +++ /dev/null @@ -1,1859 +0,0 @@ -/* $NetBSD: main.c,v 1.174 2009/09/09 17:09:49 sjg Exp $ */ - -/* - * Copyright (c) 1988, 1989, 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Adam de Boor. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * Copyright (c) 1989 by Berkeley Softworks - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Adam de Boor. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: main.c,v 1.174 2009/09/09 17:09:49 sjg Exp $"; -#else -#include -#ifndef lint -__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\ - The Regents of the University of California. All rights reserved."); -#endif /* not lint */ - -#ifndef lint -#if 0 -static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94"; -#else -__RCSID("$NetBSD: main.c,v 1.174 2009/09/09 17:09:49 sjg Exp $"); -#endif -#endif /* not lint */ -#endif - -/*- - * main.c -- - * The main file for this entire program. Exit routines etc - * reside here. - * - * Utility functions defined in this file: - * Main_ParseArgLine Takes a line of arguments, breaks them and - * treats them as if they were given when first - * invoked. Used by the parse module to implement - * the .MFLAGS target. - * - * Error Print a tagged error message. The global - * MAKE variable must have been defined. This - * takes a format string and two optional - * arguments for it. - * - * Fatal Print an error message and exit. Also takes - * a format string and two arguments. - * - * Punt Aborts all jobs and exits with a message. Also - * takes a format string and two arguments. - * - * Finish Finish things up by printing the number of - * errors which occurred, as passed to it, and - * exiting. - */ - -#include -#include -#include -#include -#include -#include -#ifdef MAKE_NATIVE -#include -#endif -#include - -#include -#include -#include -#include -#include -#include - -#include "make.h" -#include "hash.h" -#include "dir.h" -#include "job.h" -#include "pathnames.h" -#include "trace.h" - -#ifdef USE_IOVEC -#include -#endif - -#ifndef DEFMAXLOCAL -#define DEFMAXLOCAL DEFMAXJOBS -#endif /* DEFMAXLOCAL */ - -Lst create; /* Targets to be made */ -time_t now; /* Time at start of make */ -GNode *DEFAULT; /* .DEFAULT node */ -Boolean allPrecious; /* .PRECIOUS given on line by itself */ - -static Boolean noBuiltins; /* -r flag */ -static Lst makefiles; /* ordered list of makefiles to read */ -static Boolean printVars; /* print value of one or more vars */ -static Lst variables; /* list of variables to print */ -int maxJobs; /* -j argument */ -static int maxJobTokens; /* -j argument */ -Boolean compatMake; /* -B argument */ -int debug; /* -d argument */ -Boolean noExecute; /* -n flag */ -Boolean noRecursiveExecute; /* -N flag */ -Boolean keepgoing; /* -k flag */ -Boolean queryFlag; /* -q flag */ -Boolean touchFlag; /* -t flag */ -Boolean ignoreErrors; /* -i flag */ -Boolean beSilent; /* -s flag */ -Boolean oldVars; /* variable substitution style */ -Boolean checkEnvFirst; /* -e flag */ -Boolean parseWarnFatal; /* -W flag */ -Boolean jobServer; /* -J flag */ -static int jp_0 = -1, jp_1 = -1; /* ends of parent job pipe */ -Boolean varNoExportEnv; /* -X flag */ -Boolean doing_depend; /* Set while reading .depend */ -static Boolean jobsRunning; /* TRUE if the jobs might be running */ -static const char * tracefile; -static char * Check_Cwd_av(int, char **, int); -static void MainParseArgs(int, char **); -static int ReadMakefile(const void *, const void *); -static void usage(void); - -static Boolean ignorePWD; /* if we use -C, PWD is meaningless */ -static char curdir[MAXPATHLEN + 1]; /* startup directory */ -static char objdir[MAXPATHLEN + 1]; /* where we chdir'ed to */ -char *progname; /* the program name */ - -Boolean forceJobs = FALSE; - -extern Lst parseIncPath; - -static void -parse_debug_options(const char *argvalue) -{ - const char *modules; - const char *mode; - char *fname; - int len; - - for (modules = argvalue; *modules; ++modules) { - switch (*modules) { - case 'A': - debug = ~0; - break; - case 'a': - debug |= DEBUG_ARCH; - break; - case 'C': - debug |= DEBUG_CWD; - break; - case 'c': - debug |= DEBUG_COND; - break; - case 'd': - debug |= DEBUG_DIR; - break; - case 'e': - debug |= DEBUG_ERROR; - break; - case 'f': - debug |= DEBUG_FOR; - break; - case 'g': - if (modules[1] == '1') { - debug |= DEBUG_GRAPH1; - ++modules; - } - else if (modules[1] == '2') { - debug |= DEBUG_GRAPH2; - ++modules; - } - else if (modules[1] == '3') { - debug |= DEBUG_GRAPH3; - ++modules; - } - break; - case 'j': - debug |= DEBUG_JOB; - break; - case 'l': - debug |= DEBUG_LOUD; - break; - case 'm': - debug |= DEBUG_MAKE; - break; - case 'n': - debug |= DEBUG_SCRIPT; - break; - case 'p': - debug |= DEBUG_PARSE; - break; - case 's': - debug |= DEBUG_SUFF; - break; - case 't': - debug |= DEBUG_TARG; - break; - case 'v': - debug |= DEBUG_VAR; - break; - case 'x': - debug |= DEBUG_SHELL; - break; - case 'F': - if (debug_file != stdout && debug_file != stderr) - fclose(debug_file); - if (*++modules == '+') - mode = "a"; - else - mode = "w"; - if (strcmp(modules, "stdout") == 0) { - debug_file = stdout; - goto debug_setbuf; - } - if (strcmp(modules, "stderr") == 0) { - debug_file = stderr; - goto debug_setbuf; - } - len = strlen(modules); - fname = malloc(len + 20); - memcpy(fname, modules, len + 1); - /* Let the filename be modified by the pid */ - if (strcmp(fname + len - 3, ".%d") == 0) - snprintf(fname + len - 2, 20, "%d", getpid()); - debug_file = fopen(fname, mode); - if (!debug_file) { - fprintf(stderr, "Cannot open debug file %s\n", - fname); - usage(); - } - free(fname); - goto debug_setbuf; - default: - (void)fprintf(stderr, - "%s: illegal argument to d option -- %c\n", - progname, *modules); - usage(); - } - } -debug_setbuf: - /* - * Make the debug_file unbuffered, and make - * stdout line buffered (unless debugfile == stdout). - */ - setvbuf(debug_file, NULL, _IONBF, 0); - if (debug_file != stdout) { - setvbuf(stdout, NULL, _IOLBF, 0); - } -} - -/*- - * MainParseArgs -- - * Parse a given argument vector. Called from main() and from - * Main_ParseArgLine() when the .MAKEFLAGS target is used. - * - * XXX: Deal with command line overriding .MAKEFLAGS in makefile - * - * Results: - * None - * - * Side Effects: - * Various global and local flags will be set depending on the flags - * given - */ -static void -MainParseArgs(int argc, char **argv) -{ - char *p; - int c = '?'; - int arginc; - char *argvalue; - const char *getopt_def; - char *optscan; - Boolean inOption, dashDash = FALSE; - char found_path[MAXPATHLEN + 1]; /* for searching for sys.mk */ - -#define OPTFLAGS "BC:D:I:J:NST:V:WXd:ef:ij:km:nqrst" -/* Can't actually use getopt(3) because rescanning is not portable */ - - getopt_def = OPTFLAGS; -rearg: - inOption = FALSE; - optscan = NULL; - while(argc > 1) { - char *getopt_spec; - if(!inOption) - optscan = argv[1]; - c = *optscan++; - arginc = 0; - if(inOption) { - if(c == '\0') { - ++argv; - --argc; - inOption = FALSE; - continue; - } - } else { - if (c != '-' || dashDash) - break; - inOption = TRUE; - c = *optscan++; - } - /* '-' found at some earlier point */ - getopt_spec = strchr(getopt_def, c); - if(c != '\0' && getopt_spec != NULL && getopt_spec[1] == ':') { - /* - found, and should have an arg */ - inOption = FALSE; - arginc = 1; - argvalue = optscan; - if(*argvalue == '\0') { - if (argc < 3) - goto noarg; - argvalue = argv[2]; - arginc = 2; - } - } else { - argvalue = NULL; - } - switch(c) { - case '\0': - arginc = 1; - inOption = FALSE; - break; - case 'B': - compatMake = TRUE; - Var_Append(MAKEFLAGS, "-B", VAR_GLOBAL); - break; - case 'C': - if (chdir(argvalue) == -1) { - (void)fprintf(stderr, - "%s: chdir %s: %s\n", - progname, argvalue, - strerror(errno)); - exit(1); - } - ignorePWD = TRUE; - break; - case 'D': - if (argvalue == NULL || argvalue[0] == 0) goto noarg; - Var_Set(argvalue, "1", VAR_GLOBAL, 0); - Var_Append(MAKEFLAGS, "-D", VAR_GLOBAL); - Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL); - break; - case 'I': - if (argvalue == NULL) goto noarg; - Parse_AddIncludeDir(argvalue); - Var_Append(MAKEFLAGS, "-I", VAR_GLOBAL); - Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL); - break; - case 'J': - if (argvalue == NULL) goto noarg; - if (sscanf(argvalue, "%d,%d", &jp_0, &jp_1) != 2) { - (void)fprintf(stderr, - "%s: internal error -- J option malformed (%s)\n", - progname, argvalue); - usage(); - } - if ((fcntl(jp_0, F_GETFD, 0) < 0) || - (fcntl(jp_1, F_GETFD, 0) < 0)) { -#if 0 - (void)fprintf(stderr, - "%s: ###### warning -- J descriptors were closed!\n", - progname); - exit(2); -#endif - jp_0 = -1; - jp_1 = -1; - compatMake = TRUE; - } else { - Var_Append(MAKEFLAGS, "-J", VAR_GLOBAL); - Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL); - jobServer = TRUE; - } - break; - case 'N': - noExecute = TRUE; - noRecursiveExecute = TRUE; - Var_Append(MAKEFLAGS, "-N", VAR_GLOBAL); - break; - case 'S': - keepgoing = FALSE; - Var_Append(MAKEFLAGS, "-S", VAR_GLOBAL); - break; - case 'T': - if (argvalue == NULL) goto noarg; - tracefile = bmake_strdup(argvalue); - Var_Append(MAKEFLAGS, "-T", VAR_GLOBAL); - Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL); - break; - case 'V': - if (argvalue == NULL) goto noarg; - printVars = TRUE; - (void)Lst_AtEnd(variables, argvalue); - Var_Append(MAKEFLAGS, "-V", VAR_GLOBAL); - Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL); - break; - case 'W': - parseWarnFatal = TRUE; - break; - case 'X': - varNoExportEnv = TRUE; - Var_Append(MAKEFLAGS, "-X", VAR_GLOBAL); - break; - case 'd': - if (argvalue == NULL) goto noarg; - /* If '-d-opts' don't pass to children */ - if (argvalue[0] == '-') - argvalue++; - else { - Var_Append(MAKEFLAGS, "-d", VAR_GLOBAL); - Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL); - } - parse_debug_options(argvalue); - break; - case 'e': - checkEnvFirst = TRUE; - Var_Append(MAKEFLAGS, "-e", VAR_GLOBAL); - break; - case 'f': - if (argvalue == NULL) goto noarg; - (void)Lst_AtEnd(makefiles, argvalue); - break; - case 'i': - ignoreErrors = TRUE; - Var_Append(MAKEFLAGS, "-i", VAR_GLOBAL); - break; - case 'j': - if (argvalue == NULL) goto noarg; - forceJobs = TRUE; - maxJobs = strtol(argvalue, &p, 0); - if (*p != '\0' || maxJobs < 1) { - (void)fprintf(stderr, "%s: illegal argument to -j -- must be positive integer!\n", - progname); - exit(1); - } - Var_Append(MAKEFLAGS, "-j", VAR_GLOBAL); - Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL); - maxJobTokens = maxJobs; - break; - case 'k': - keepgoing = TRUE; - Var_Append(MAKEFLAGS, "-k", VAR_GLOBAL); - break; - case 'm': - if (argvalue == NULL) goto noarg; - /* look for magic parent directory search string */ - if (strncmp(".../", argvalue, 4) == 0) { - if (!Dir_FindHereOrAbove(curdir, argvalue+4, - found_path, sizeof(found_path))) - break; /* nothing doing */ - (void)Dir_AddDir(sysIncPath, found_path); - - } else { - (void)Dir_AddDir(sysIncPath, argvalue); - } - Var_Append(MAKEFLAGS, "-m", VAR_GLOBAL); - Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL); - break; - case 'n': - noExecute = TRUE; - Var_Append(MAKEFLAGS, "-n", VAR_GLOBAL); - break; - case 'q': - queryFlag = TRUE; - /* Kind of nonsensical, wot? */ - Var_Append(MAKEFLAGS, "-q", VAR_GLOBAL); - break; - case 'r': - noBuiltins = TRUE; - Var_Append(MAKEFLAGS, "-r", VAR_GLOBAL); - break; - case 's': - beSilent = TRUE; - Var_Append(MAKEFLAGS, "-s", VAR_GLOBAL); - break; - case 't': - touchFlag = TRUE; - Var_Append(MAKEFLAGS, "-t", VAR_GLOBAL); - break; - case '-': - dashDash = TRUE; - break; - default: - case '?': - usage(); - } - argv += arginc; - argc -= arginc; - } - - oldVars = TRUE; - - /* - * See if the rest of the arguments are variable assignments and - * perform them if so. Else take them to be targets and stuff them - * on the end of the "create" list. - */ - for (; argc > 1; ++argv, --argc) - if (Parse_IsVar(argv[1])) { - Parse_DoVar(argv[1], VAR_CMD); - } else { - if (!*argv[1]) - Punt("illegal (null) argument."); - if (*argv[1] == '-' && !dashDash) - goto rearg; - (void)Lst_AtEnd(create, bmake_strdup(argv[1])); - } - - return; -noarg: - (void)fprintf(stderr, "%s: option requires an argument -- %c\n", - progname, c); - usage(); -} - -/*- - * Main_ParseArgLine -- - * Used by the parse module when a .MFLAGS or .MAKEFLAGS target - * is encountered and by main() when reading the .MAKEFLAGS envariable. - * Takes a line of arguments and breaks it into its - * component words and passes those words and the number of them to the - * MainParseArgs function. - * The line should have all its leading whitespace removed. - * - * Input: - * line Line to fracture - * - * Results: - * None - * - * Side Effects: - * Only those that come from the various arguments. - */ -void -Main_ParseArgLine(const char *line) -{ - char **argv; /* Manufactured argument vector */ - int argc; /* Number of arguments in argv */ - char *args; /* Space used by the args */ - char *buf, *p1; - char *argv0 = Var_Value(".MAKE", VAR_GLOBAL, &p1); - size_t len; - - if (line == NULL) - return; - for (; *line == ' '; ++line) - continue; - if (!*line) - return; - - buf = bmake_malloc(len = strlen(line) + strlen(argv0) + 2); - (void)snprintf(buf, len, "%s %s", argv0, line); - if (p1) - free(p1); - - argv = brk_string(buf, &argc, TRUE, &args); - if (argv == NULL) { - Error("Unterminated quoted string [%s]", buf); - free(buf); - return; - } - free(buf); - MainParseArgs(argc, argv); - - free(args); - free(argv); -} - -Boolean -Main_SetObjdir(const char *path) -{ - struct stat sb; - char *p = NULL; - char buf[MAXPATHLEN + 1]; - Boolean rc = FALSE; - - /* expand variable substitutions */ - if (strchr(path, '$') != 0) { - snprintf(buf, MAXPATHLEN, "%s", path); - path = p = Var_Subst(NULL, buf, VAR_GLOBAL, 0); - } - - if (path[0] != '/') { - snprintf(buf, MAXPATHLEN, "%s/%s", curdir, path); - path = buf; - } - - /* look for the directory and try to chdir there */ - if (stat(path, &sb) == 0 && S_ISDIR(sb.st_mode)) { - if (chdir(path)) { - (void)fprintf(stderr, "make warning: %s: %s.\n", - path, strerror(errno)); - } else { - strncpy(objdir, path, MAXPATHLEN); - Var_Set(".OBJDIR", objdir, VAR_GLOBAL, 0); - setenv("PWD", objdir, 1); - Dir_InitDot(); - rc = TRUE; - } - } - - if (p) - free(p); - return rc; -} - -/*- - * ReadAllMakefiles -- - * wrapper around ReadMakefile() to read all. - * - * Results: - * TRUE if ok, FALSE on error - */ -static int -ReadAllMakefiles(const void *p, const void *q) -{ - return (ReadMakefile(p, q) == 0); -} - -#ifdef SIGINFO -/*ARGSUSED*/ -static void -siginfo(int signo) -{ - char dir[MAXPATHLEN]; - char str[2 * MAXPATHLEN]; - int len; - if (getcwd(dir, sizeof(dir)) == NULL) - return; - len = snprintf(str, sizeof(str), "%s: Working in: %s\n", progname, dir); - if (len > 0) - (void)write(STDERR_FILENO, str, (size_t)len); -} -#endif - -/*- - * main -- - * The main function, for obvious reasons. Initializes variables - * and a few modules, then parses the arguments give it in the - * environment and on the command line. Reads the system makefile - * followed by either Makefile, makefile or the file given by the - * -f argument. Sets the .MAKEFLAGS PMake variable based on all the - * flags it has received by then uses either the Make or the Compat - * module to create the initial list of targets. - * - * Results: - * If -q was given, exits -1 if anything was out-of-date. Else it exits - * 0. - * - * Side Effects: - * The program exits when done. Targets are created. etc. etc. etc. - */ -int -main(int argc, char **argv) -{ - Lst targs; /* target nodes to create -- passed to Make_Init */ - Boolean outOfDate = FALSE; /* FALSE if all targets up to date */ - struct stat sb, sa; - char *p1, *path, *pwd; - char mdpath[MAXPATHLEN]; - char *machine = getenv("MACHINE"); - const char *machine_arch = getenv("MACHINE_ARCH"); - char *syspath = getenv("MAKESYSPATH"); - Lst sysMkPath; /* Path of sys.mk */ - char *cp = NULL, *start; - /* avoid faults on read-only strings */ - static char defsyspath[] = _PATH_DEFSYSPATH; - char found_path[MAXPATHLEN + 1]; /* for searching for sys.mk */ - struct timeval rightnow; /* to initialize random seed */ -#ifdef MAKE_NATIVE - struct utsname utsname; -#endif - - /* default to writing debug to stderr */ - debug_file = stderr; - -#ifdef SIGINFO - (void)signal(SIGINFO, siginfo); -#endif - /* - * Set the seed to produce a different random sequence - * on each program execution. - */ - gettimeofday(&rightnow, NULL); - srandom(rightnow.tv_sec + rightnow.tv_usec); - - if ((progname = strrchr(argv[0], '/')) != NULL) - progname++; - else - progname = argv[0]; -#if defined(RLIMIT_NOFILE) && !defined(__minix) - /* - * get rid of resource limit on file descriptors - */ - { - struct rlimit rl; - if (getrlimit(RLIMIT_NOFILE, &rl) != -1 && - rl.rlim_cur != rl.rlim_max) { - rl.rlim_cur = rl.rlim_max; - (void)setrlimit(RLIMIT_NOFILE, &rl); - } - } -#endif - - /* - * Get the name of this type of MACHINE from utsname - * so we can share an executable for similar machines. - * (i.e. m68k: amiga hp300, mac68k, sun3, ...) - * - * Note that both MACHINE and MACHINE_ARCH are decided at - * run-time. - */ - if (!machine) { -#ifdef MAKE_NATIVE - if (uname(&utsname) == -1) { - (void)fprintf(stderr, "%s: uname failed (%s).\n", progname, - strerror(errno)); - exit(2); - } - machine = utsname.machine; -#else -#ifdef MAKE_MACHINE - machine = MAKE_MACHINE; -#else - machine = "unknown"; -#endif -#endif - } - - if (!machine_arch) { -#ifndef MACHINE_ARCH -#ifdef MAKE_MACHINE_ARCH - machine_arch = MAKE_MACHINE_ARCH; -#else - machine_arch = "unknown"; -#endif -#else - machine_arch = MACHINE_ARCH; -#endif - } - - /* - * Just in case MAKEOBJDIR wants us to do something tricky. - */ - Var_Init(); /* Initialize the lists of variables for - * parsing arguments */ - Var_Set("MACHINE", machine, VAR_GLOBAL, 0); - Var_Set("MACHINE_ARCH", machine_arch, VAR_GLOBAL, 0); -#ifdef MAKE_VERSION - Var_Set("MAKE_VERSION", MAKE_VERSION, VAR_GLOBAL, 0); -#endif - Var_Set(".newline", "\n", VAR_GLOBAL, 0); /* handy for :@ loops */ - - create = Lst_Init(FALSE); - makefiles = Lst_Init(FALSE); - printVars = FALSE; - variables = Lst_Init(FALSE); - beSilent = FALSE; /* Print commands as executed */ - ignoreErrors = FALSE; /* Pay attention to non-zero returns */ - noExecute = FALSE; /* Execute all commands */ - noRecursiveExecute = FALSE; /* Execute all .MAKE targets */ - keepgoing = FALSE; /* Stop on error */ - allPrecious = FALSE; /* Remove targets when interrupted */ - queryFlag = FALSE; /* This is not just a check-run */ - noBuiltins = FALSE; /* Read the built-in rules */ - touchFlag = FALSE; /* Actually update targets */ - debug = 0; /* No debug verbosity, please. */ - jobsRunning = FALSE; - - maxJobs = DEFMAXLOCAL; /* Set default local max concurrency */ - maxJobTokens = maxJobs; - compatMake = FALSE; /* No compat mode */ - ignorePWD = FALSE; - - /* - * Initialize the parsing, directory and variable modules to prepare - * for the reading of inclusion paths and variable settings on the - * command line - */ - - /* - * Initialize various variables. - * MAKE also gets this name, for compatibility - * .MAKEFLAGS gets set to the empty string just in case. - * MFLAGS also gets initialized empty, for compatibility. - */ - Parse_Init(); - Var_Set("MAKE", argv[0], VAR_GLOBAL, 0); - Var_Set(".MAKE", argv[0], VAR_GLOBAL, 0); - Var_Set(MAKEFLAGS, "", VAR_GLOBAL, 0); - Var_Set(MAKEOVERRIDES, "", VAR_GLOBAL, 0); - Var_Set("MFLAGS", "", VAR_GLOBAL, 0); - Var_Set(".ALLTARGETS", "", VAR_GLOBAL, 0); - - /* - * Set some other useful macros - */ - { - char tmp[64]; - const char *ep; - - if (!(ep = getenv(MAKE_LEVEL))) { - ep = "0"; - } - Var_Set(MAKE_LEVEL, ep, VAR_GLOBAL, 0); - snprintf(tmp, sizeof(tmp), "%u", getpid()); - Var_Set(".MAKE.PID", tmp, VAR_GLOBAL, 0); - snprintf(tmp, sizeof(tmp), "%u", getppid()); - Var_Set(".MAKE.PPID", tmp, VAR_GLOBAL, 0); - } - Job_SetPrefix(); - - /* - * First snag any flags out of the MAKE environment variable. - * (Note this is *not* MAKEFLAGS since /bin/make uses that and it's - * in a different format). - */ -#ifdef POSIX - Main_ParseArgLine(getenv("MAKEFLAGS")); -#else - Main_ParseArgLine(getenv("MAKE")); -#endif - - MainParseArgs(argc, argv); - - /* - * Find where we are (now) and take care of PWD for the automounter... - * All this code is so that we know where we are when we start up - * on a different machine with pmake. - */ - if (getcwd(curdir, MAXPATHLEN) == NULL) { - (void)fprintf(stderr, "%s: %s.\n", progname, strerror(errno)); - exit(2); - } - - if (stat(curdir, &sa) == -1) { - (void)fprintf(stderr, "%s: %s: %s.\n", - progname, curdir, strerror(errno)); - exit(2); - } - - /* - * Overriding getcwd() with $PWD totally breaks MAKEOBJDIRPREFIX - * since the value of curdir can vary depending on how we got - * here. Ie sitting at a shell prompt (shell that provides $PWD) - * or via subdir.mk in which case its likely a shell which does - * not provide it. - * So, to stop it breaking this case only, we ignore PWD if - * MAKEOBJDIRPREFIX is set or MAKEOBJDIR contains a transform. - */ - if (!ignorePWD && - (pwd = getenv("PWD")) != NULL && - getenv("MAKEOBJDIRPREFIX") == NULL) { - const char *makeobjdir = getenv("MAKEOBJDIR"); - - if (makeobjdir == NULL || !strchr(makeobjdir, '$')) { - if (stat(pwd, &sb) == 0 && sa.st_ino == sb.st_ino && - sa.st_dev == sb.st_dev) - (void)strncpy(curdir, pwd, MAXPATHLEN); - } - } - Var_Set(".CURDIR", curdir, VAR_GLOBAL, 0); - - /* - * Find the .OBJDIR. If MAKEOBJDIRPREFIX, or failing that, - * MAKEOBJDIR is set in the environment, try only that value - * and fall back to .CURDIR if it does not exist. - * - * Otherwise, try _PATH_OBJDIR.MACHINE, _PATH_OBJDIR, and - * finally _PATH_OBJDIRPREFIX`pwd`, in that order. If none - * of these paths exist, just use .CURDIR. - */ - Dir_Init(curdir); - (void)Main_SetObjdir(curdir); - - if ((path = getenv("MAKEOBJDIRPREFIX")) != NULL) { - (void)snprintf(mdpath, MAXPATHLEN, "%s%s", path, curdir); - (void)Main_SetObjdir(mdpath); - } else if ((path = getenv("MAKEOBJDIR")) != NULL) { - (void)Main_SetObjdir(path); - } else { - (void)snprintf(mdpath, MAXPATHLEN, "%s.%s", _PATH_OBJDIR, machine); - if (!Main_SetObjdir(mdpath) && !Main_SetObjdir(_PATH_OBJDIR)) { - (void)snprintf(mdpath, MAXPATHLEN, "%s%s", - _PATH_OBJDIRPREFIX, curdir); - (void)Main_SetObjdir(mdpath); - } - } - - /* - * Be compatible if user did not specify -j and did not explicitly - * turned compatibility on - */ - if (!compatMake && !forceJobs) { - compatMake = TRUE; - } - - /* - * Initialize archive, target and suffix modules in preparation for - * parsing the makefile(s) - */ - Arch_Init(); - Targ_Init(); - Suff_Init(); - Trace_Init(tracefile); - - DEFAULT = NULL; - (void)time(&now); - - Trace_Log(MAKESTART, NULL); - - /* - * Set up the .TARGETS variable to contain the list of targets to be - * created. If none specified, make the variable empty -- the parser - * will fill the thing in with the default or .MAIN target. - */ - if (!Lst_IsEmpty(create)) { - LstNode ln; - - for (ln = Lst_First(create); ln != NULL; - ln = Lst_Succ(ln)) { - char *name = (char *)Lst_Datum(ln); - - Var_Append(".TARGETS", name, VAR_GLOBAL); - } - } else - Var_Set(".TARGETS", "", VAR_GLOBAL, 0); - - - /* - * If no user-supplied system path was given (through the -m option) - * add the directories from the DEFSYSPATH (more than one may be given - * as dir1:...:dirn) to the system include path. - */ - if (syspath == NULL || *syspath == '\0') - syspath = defsyspath; - else - syspath = bmake_strdup(syspath); - - for (start = syspath; *start != '\0'; start = cp) { - for (cp = start; *cp != '\0' && *cp != ':'; cp++) - continue; - if (*cp == ':') { - *cp++ = '\0'; - } - /* look for magic parent directory search string */ - if (strncmp(".../", start, 4) != 0) { - (void)Dir_AddDir(defIncPath, start); - } else { - if (Dir_FindHereOrAbove(curdir, start+4, - found_path, sizeof(found_path))) { - (void)Dir_AddDir(defIncPath, found_path); - } - } - } - if (syspath != defsyspath) - free(syspath); - - /* - * Read in the built-in rules first, followed by the specified - * makefile, if it was (makefile != NULL), or the default - * makefile and Makefile, in that order, if it wasn't. - */ - if (!noBuiltins) { - LstNode ln; - - sysMkPath = Lst_Init(FALSE); - Dir_Expand(_PATH_DEFSYSMK, - Lst_IsEmpty(sysIncPath) ? defIncPath : sysIncPath, - sysMkPath); - if (Lst_IsEmpty(sysMkPath)) - Fatal("%s: no system rules (%s).", progname, - _PATH_DEFSYSMK); - ln = Lst_Find(sysMkPath, NULL, ReadMakefile); - if (ln == NULL) - Fatal("%s: cannot open %s.", progname, - (char *)Lst_Datum(ln)); - } - - if (!Lst_IsEmpty(makefiles)) { - LstNode ln; - - ln = Lst_Find(makefiles, NULL, ReadAllMakefiles); - if (ln != NULL) - Fatal("%s: cannot open %s.", progname, - (char *)Lst_Datum(ln)); - } else if (ReadMakefile("makefile", NULL) != 0) - (void)ReadMakefile("Makefile", NULL); - - /* In particular suppress .depend for '-r -V .OBJDIR -f /dev/null' */ - if (!noBuiltins || !printVars) { - doing_depend = TRUE; - (void)ReadMakefile(".depend", NULL); - doing_depend = FALSE; - } - - Var_Append("MFLAGS", Var_Value(MAKEFLAGS, VAR_GLOBAL, &p1), VAR_GLOBAL); - if (p1) - free(p1); - - if (!compatMake) - Job_ServerStart(maxJobTokens, jp_0, jp_1); - if (DEBUG(JOB)) - fprintf(debug_file, "job_pipe %d %d, maxjobs %d, tokens %d, compat %d\n", - jp_0, jp_1, maxJobs, maxJobTokens, compatMake); - - Main_ExportMAKEFLAGS(TRUE); /* initial export */ - - Check_Cwd_av(0, NULL, 0); /* initialize it */ - - - /* - * For compatibility, look at the directories in the VPATH variable - * and add them to the search path, if the variable is defined. The - * variable's value is in the same format as the PATH envariable, i.e. - * ::... - */ - if (Var_Exists("VPATH", VAR_CMD)) { - char *vpath, savec; - /* - * GCC stores string constants in read-only memory, but - * Var_Subst will want to write this thing, so store it - * in an array - */ - static char VPATH[] = "${VPATH}"; - - vpath = Var_Subst(NULL, VPATH, VAR_CMD, FALSE); - path = vpath; - do { - /* skip to end of directory */ - for (cp = path; *cp != ':' && *cp != '\0'; cp++) - continue; - /* Save terminator character so know when to stop */ - savec = *cp; - *cp = '\0'; - /* Add directory to search path */ - (void)Dir_AddDir(dirSearchPath, path); - *cp = savec; - path = cp + 1; - } while (savec == ':'); - free(vpath); - } - - /* - * Now that all search paths have been read for suffixes et al, it's - * time to add the default search path to their lists... - */ - Suff_DoPaths(); - - /* - * Propagate attributes through :: dependency lists. - */ - Targ_Propagate(); - - /* print the initial graph, if the user requested it */ - if (DEBUG(GRAPH1)) - Targ_PrintGraph(1); - - /* print the values of any variables requested by the user */ - if (printVars) { - LstNode ln; - - for (ln = Lst_First(variables); ln != NULL; - ln = Lst_Succ(ln)) { - char *var = (char *)Lst_Datum(ln); - char *value; - - if (strchr(var, '$')) { - value = p1 = Var_Subst(NULL, var, VAR_GLOBAL, 0); - } else { - value = Var_Value(var, VAR_GLOBAL, &p1); - } - printf("%s\n", value ? value : ""); - if (p1) - free(p1); - } - } else { - /* - * Have now read the entire graph and need to make a list of - * targets to create. If none was given on the command line, - * we consult the parsing module to find the main target(s) - * to create. - */ - if (Lst_IsEmpty(create)) - targs = Parse_MainName(); - else - targs = Targ_FindList(create, TARG_CREATE); - - if (!compatMake) { - /* - * Initialize job module before traversing the graph - * now that any .BEGIN and .END targets have been read. - * This is done only if the -q flag wasn't given - * (to prevent the .BEGIN from being executed should - * it exist). - */ - if (!queryFlag) { - Job_Init(); - jobsRunning = TRUE; - } - - /* Traverse the graph, checking on all the targets */ - outOfDate = Make_Run(targs); - } else { - /* - * Compat_Init will take care of creating all the - * targets as well as initializing the module. - */ - Compat_Run(targs); - } - } - -#ifdef CLEANUP - Lst_Destroy(targs, NULL); - Lst_Destroy(variables, NULL); - Lst_Destroy(makefiles, NULL); - Lst_Destroy(create, (FreeProc *)free); -#endif - - /* print the graph now it's been processed if the user requested it */ - if (DEBUG(GRAPH2)) - Targ_PrintGraph(2); - - Trace_Log(MAKEEND, 0); - - Suff_End(); - Targ_End(); - Arch_End(); - Var_End(); - Parse_End(); - Dir_End(); - Job_End(); - Trace_End(); - - return outOfDate ? 1 : 0; -} - -/*- - * ReadMakefile -- - * Open and parse the given makefile. - * - * Results: - * 0 if ok. -1 if couldn't open file. - * - * Side Effects: - * lots - */ -static int -ReadMakefile(const void *p, const void *q __unused) -{ - const char *fname = p; /* makefile to read */ - int fd; - size_t len = MAXPATHLEN; - char *name, *path = bmake_malloc(len); - int setMAKEFILE; - - if (!strcmp(fname, "-")) { - Parse_File("(stdin)", dup(fileno(stdin))); - Var_Set("MAKEFILE", "", VAR_GLOBAL, 0); - } else { - setMAKEFILE = strcmp(fname, ".depend"); - - /* if we've chdir'd, rebuild the path name */ - if (strcmp(curdir, objdir) && *fname != '/') { - size_t plen = strlen(curdir) + strlen(fname) + 2; - if (len < plen) - path = bmake_realloc(path, len = 2 * plen); - - (void)snprintf(path, len, "%s/%s", curdir, fname); - fd = open(path, O_RDONLY); - if (fd != -1) { - fname = path; - goto found; - } - - /* If curdir failed, try objdir (ala .depend) */ - plen = strlen(objdir) + strlen(fname) + 2; - if (len < plen) - path = bmake_realloc(path, len = 2 * plen); - (void)snprintf(path, len, "%s/%s", objdir, fname); - fd = open(path, O_RDONLY); - if (fd != -1) { - fname = path; - goto found; - } - } else { - fd = open(fname, O_RDONLY); - if (fd != -1) - goto found; - } - /* look in -I and system include directories. */ - name = Dir_FindFile(fname, parseIncPath); - if (!name) - name = Dir_FindFile(fname, - Lst_IsEmpty(sysIncPath) ? defIncPath : sysIncPath); - if (!name || (fd = open(name, O_RDONLY)) == -1) { - if (name) - free(name); - free(path); - return(-1); - } - fname = name; - /* - * set the MAKEFILE variable desired by System V fans -- the - * placement of the setting here means it gets set to the last - * makefile specified, as it is set by SysV make. - */ -found: - if (setMAKEFILE) - Var_Set("MAKEFILE", fname, VAR_GLOBAL, 0); - Parse_File(fname, fd); - } - free(path); - return(0); -} - - -/* - * If MAKEOBJDIRPREFIX is in use, make ends up not in .CURDIR - * in situations that would not arrise with ./obj (links or not). - * This tends to break things like: - * - * build: - * ${MAKE} includes - * - * This function spots when ${.MAKE:T} or ${.MAKE} is a command (as - * opposed to an argument) in a command line and if so returns - * ${.CURDIR} so caller can chdir() so that the assumptions made by - * the Makefile hold true. - * - * If ${.MAKE} does not contain any '/', then ${.MAKE:T} is skipped. - * - * The chdir() only happens in the child process, and does nothing if - * MAKEOBJDIRPREFIX and MAKEOBJDIR are not in the environment so it - * should not break anything. Also if NOCHECKMAKECHDIR is set we - * do nothing - to ensure historic semantics can be retained. - */ -static int Check_Cwd_Off = 0; - -static char * -Check_Cwd_av(int ac, char **av, int copy) -{ - static char *make[4]; - static char *cur_dir = NULL; - char **mp; - char *cp; - int is_cmd, next_cmd; - int i; - int n; - - if (Check_Cwd_Off) { - if (DEBUG(CWD)) - fprintf(debug_file, "check_cwd: check is off.\n"); - return NULL; - } - - if (make[0] == NULL) { - if (Var_Exists("NOCHECKMAKECHDIR", VAR_GLOBAL)) { - Check_Cwd_Off = 1; - if (DEBUG(CWD)) - fprintf(debug_file, "check_cwd: turning check off.\n"); - return NULL; - } - - make[1] = Var_Value(".MAKE", VAR_GLOBAL, &cp); - if ((make[0] = strrchr(make[1], '/')) == NULL) { - make[0] = make[1]; - make[1] = NULL; - } else - ++make[0]; - make[2] = NULL; - cur_dir = Var_Value(".CURDIR", VAR_GLOBAL, &cp); - } - if (ac == 0 || av == NULL) { - if (DEBUG(CWD)) - fprintf(debug_file, "check_cwd: empty command.\n"); - return NULL; /* initialization only */ - } - - if (getenv("MAKEOBJDIR") == NULL && - getenv("MAKEOBJDIRPREFIX") == NULL) { - if (DEBUG(CWD)) - fprintf(debug_file, "check_cwd: no obj dirs.\n"); - return NULL; - } - - - next_cmd = 1; - for (i = 0; i < ac; ++i) { - is_cmd = next_cmd; - - n = strlen(av[i]); - cp = &(av[i])[n - 1]; - if (strspn(av[i], "|&;") == (size_t)n) { - next_cmd = 1; - continue; - } else if (*cp == ';' || *cp == '&' || *cp == '|' || *cp == ')') { - next_cmd = 1; - if (copy) { - do { - *cp-- = '\0'; - } while (*cp == ';' || *cp == '&' || *cp == '|' || - *cp == ')' || *cp == '}') ; - } else { - /* - * XXX this should not happen. - */ - fprintf(stderr, "%s: WARNING: raw arg ends in shell meta '%s'\n", - progname, av[i]); - } - } else - next_cmd = 0; - - cp = av[i]; - if (*cp == ';' || *cp == '&' || *cp == '|') - is_cmd = 1; - - if (DEBUG(CWD)) - fprintf(debug_file, "av[%d] == %s '%s'", - i, (is_cmd) ? "cmd" : "arg", av[i]); - if (is_cmd != 0) { - if (*cp == '(' || *cp == '{' || - *cp == ';' || *cp == '&' || *cp == '|') { - do { - ++cp; - } while (*cp == '(' || *cp == '{' || - *cp == ';' || *cp == '&' || *cp == '|'); - if (*cp == '\0') { - next_cmd = 1; - continue; - } - } - if (strcmp(cp, "cd") == 0 || strcmp(cp, "chdir") == 0) { - if (DEBUG(CWD)) - fprintf(debug_file, " == cd, done.\n"); - return NULL; - } - for (mp = make; *mp != NULL; ++mp) { - n = strlen(*mp); - if (strcmp(cp, *mp) == 0) { - if (DEBUG(CWD)) - fprintf(debug_file, " %s == '%s', chdir(%s)\n", - cp, *mp, cur_dir); - return cur_dir; - } - } - } - if (DEBUG(CWD)) - fprintf(debug_file, "\n"); - } - return NULL; -} - -char * -Check_Cwd_Cmd(const char *cmd) -{ - char *cp, *bp; - char **av; - int ac; - - if (Check_Cwd_Off) - return NULL; - - if (cmd) { - av = brk_string(cmd, &ac, TRUE, &bp); - if (DEBUG(CWD)) - fprintf(debug_file, "splitting: '%s' -> %d words\n", - cmd, ac); - } else { - ac = 0; - av = NULL; - bp = NULL; - } - cp = Check_Cwd_av(ac, av, 1); - if (bp) - free(bp); - if (av) - free(av); - return cp; -} - -void -Check_Cwd(const char **argv) -{ - char *cp; - int ac; - - if (Check_Cwd_Off) - return; - - for (ac = 0; argv[ac] != NULL; ++ac) - /* NOTHING */; - if (ac == 3 && *argv[1] == '-') { - cp = Check_Cwd_Cmd(argv[2]); - } else { - cp = Check_Cwd_av(ac, UNCONST(argv), 0); - } - if (cp) { - chdir(cp); - } -} - -/*- - * Cmd_Exec -- - * Execute the command in cmd, and return the output of that command - * in a string. - * - * Results: - * A string containing the output of the command, or the empty string - * If errnum is not NULL, it contains the reason for the command failure - * - * Side Effects: - * The string must be freed by the caller. - */ -char * -Cmd_Exec(const char *cmd, const char **errnum) -{ - const char *args[4]; /* Args for invoking the shell */ - int fds[2]; /* Pipe streams */ - int cpid; /* Child PID */ - int pid; /* PID from wait() */ - char *res; /* result */ - int status; /* command exit status */ - Buffer buf; /* buffer to store the result */ - char *cp; - int cc; - - - *errnum = NULL; - - if (!shellName) - Shell_Init(); - /* - * Set up arguments for shell - */ - args[0] = shellName; - args[1] = "-c"; - args[2] = cmd; - args[3] = NULL; - - /* - * Open a pipe for fetching its output - */ - if (pipe(fds) == -1) { - *errnum = "Couldn't create pipe for \"%s\""; - goto bad; - } - - /* - * Fork - */ -#if defined(__minix) - switch (cpid = fork()) { -#else - switch (cpid = vfork()) { -#endif - case 0: - /* - * Close input side of pipe - */ - (void)close(fds[0]); - - /* - * Duplicate the output stream to the shell's output, then - * shut the extra thing down. Note we don't fetch the error - * stream...why not? Why? - */ - (void)dup2(fds[1], 1); - (void)close(fds[1]); - - Var_ExportVars(); - - (void)execv(shellPath, UNCONST(args)); - _exit(1); - /*NOTREACHED*/ - - case -1: - *errnum = "Couldn't exec \"%s\""; - goto bad; - - default: - /* - * No need for the writing half - */ - (void)close(fds[1]); - - Buf_Init(&buf, 0); - - do { - char result[BUFSIZ]; - cc = read(fds[0], result, sizeof(result)); - if (cc > 0) - Buf_AddBytes(&buf, cc, result); - } - while (cc > 0 || (cc == -1 && errno == EINTR)); - - /* - * Close the input side of the pipe. - */ - (void)close(fds[0]); - - /* - * Wait for the process to exit. - */ - while(((pid = waitpid(cpid, &status, 0)) != cpid) && (pid >= 0)) - continue; - - cc = Buf_Size(&buf); - res = Buf_Destroy(&buf, FALSE); - - if (cc == 0) - *errnum = "Couldn't read shell's output for \"%s\""; - - if (WIFSIGNALED(status)) - *errnum = "\"%s\" exited on a signal"; - else if (WEXITSTATUS(status) != 0) - *errnum = "\"%s\" returned non-zero status"; - - /* - * Null-terminate the result, convert newlines to spaces and - * install it in the variable. - */ - res[cc] = '\0'; - cp = &res[cc]; - - if (cc > 0 && *--cp == '\n') { - /* - * A final newline is just stripped - */ - *cp-- = '\0'; - } - while (cp >= res) { - if (*cp == '\n') { - *cp = ' '; - } - cp--; - } - break; - } - return res; -bad: - res = bmake_malloc(1); - *res = '\0'; - return res; -} - -/*- - * Error -- - * Print an error message given its format. - * - * Results: - * None. - * - * Side Effects: - * The message is printed. - */ -/* VARARGS */ -void -Error(const char *fmt, ...) -{ - va_list ap; - FILE *err_file; - - err_file = debug_file; - if (err_file == stdout) - err_file = stderr; - for (;;) { - va_start(ap, fmt); - fprintf(err_file, "%s: ", progname); - (void)vfprintf(err_file, fmt, ap); - va_end(ap); - (void)fprintf(err_file, "\n"); - (void)fflush(err_file); - if (err_file == stderr) - break; - err_file = stderr; - } -} - -/*- - * Fatal -- - * Produce a Fatal error message. If jobs are running, waits for them - * to finish. - * - * Results: - * None - * - * Side Effects: - * The program exits - */ -/* VARARGS */ -void -Fatal(const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - if (jobsRunning) - Job_Wait(); - - (void)vfprintf(stderr, fmt, ap); - va_end(ap); - (void)fprintf(stderr, "\n"); - (void)fflush(stderr); - - PrintOnError(NULL); - - if (DEBUG(GRAPH2) || DEBUG(GRAPH3)) - Targ_PrintGraph(2); - Trace_Log(MAKEERROR, 0); - exit(2); /* Not 1 so -q can distinguish error */ -} - -/* - * Punt -- - * Major exception once jobs are being created. Kills all jobs, prints - * a message and exits. - * - * Results: - * None - * - * Side Effects: - * All children are killed indiscriminately and the program Lib_Exits - */ -/* VARARGS */ -void -Punt(const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - (void)fprintf(stderr, "%s: ", progname); - (void)vfprintf(stderr, fmt, ap); - va_end(ap); - (void)fprintf(stderr, "\n"); - (void)fflush(stderr); - - PrintOnError(NULL); - - DieHorribly(); -} - -/*- - * DieHorribly -- - * Exit without giving a message. - * - * Results: - * None - * - * Side Effects: - * A big one... - */ -void -DieHorribly(void) -{ - if (jobsRunning) - Job_AbortAll(); - if (DEBUG(GRAPH2)) - Targ_PrintGraph(2); - Trace_Log(MAKEERROR, 0); - exit(2); /* Not 1, so -q can distinguish error */ -} - -/* - * Finish -- - * Called when aborting due to errors in child shell to signal - * abnormal exit. - * - * Results: - * None - * - * Side Effects: - * The program exits - */ -void -Finish(int errors) - /* number of errors encountered in Make_Make */ -{ - Fatal("%d error%s", errors, errors == 1 ? "" : "s"); -} - -/* - * enunlink -- - * Remove a file carefully, avoiding directories. - */ -int -eunlink(const char *file) -{ - struct stat st; - - if (lstat(file, &st) == -1) - return -1; - - if (S_ISDIR(st.st_mode)) { - errno = EISDIR; - return -1; - } - return unlink(file); -} - -/* - * execError -- - * Print why exec failed, avoiding stdio. - */ -void -execError(const char *af, const char *av) -{ -#ifdef USE_IOVEC - int i = 0; - struct iovec iov[8]; -#define IOADD(s) \ - (void)(iov[i].iov_base = UNCONST(s), \ - iov[i].iov_len = strlen(iov[i].iov_base), \ - i++) -#else -#define IOADD(void)write(2, s, strlen(s)) -#endif - - IOADD(progname); - IOADD(": "); - IOADD(af); - IOADD("("); - IOADD(av); - IOADD(") failed ("); - IOADD(strerror(errno)); - IOADD(")\n"); - -#ifdef USE_IOVEC - (void)writev(2, iov, 8); -#endif -} - -/* - * usage -- - * exit with usage message - */ -static void -usage(void) -{ - (void)fprintf(stderr, -"usage: %s [-BeikNnqrstWX] \n\ - [-C directory] [-D variable] [-d flags] [-f makefile]\n\ - [-I directory] [-J private] [-j max_jobs] [-m directory] [-T file]\n\ - [-V variable] [variable=value] [target ...]\n", progname); - exit(2); -} - - -int -PrintAddr(void *a, void *b) -{ - printf("%lx ", (unsigned long) a); - return b ? 0 : 0; -} - - - -void -PrintOnError(const char *s) -{ - char tmp[64]; - char *cp; - - if (s) - printf("%s", s); - - printf("\n%s: stopped in %s\n", progname, curdir); - strncpy(tmp, "${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'\n@}", - sizeof(tmp) - 1); - cp = Var_Subst(NULL, tmp, VAR_GLOBAL, 0); - if (cp) { - if (*cp) - printf("%s", cp); - free(cp); - } -} - -void -Main_ExportMAKEFLAGS(Boolean first) -{ - static int once = 1; - char tmp[64]; - char *s; - - if (once != first) - return; - once = 0; - - strncpy(tmp, "${.MAKEFLAGS} ${.MAKEOVERRIDES:O:u:@v@$v=${$v:Q}@}", - sizeof(tmp)); - s = Var_Subst(NULL, tmp, VAR_CMD, 0); - if (s && *s) { -#ifdef POSIX - setenv("MAKEFLAGS", s, 1); -#else - setenv("MAKE", s, 1); -#endif - } -} diff --git a/commands/bmake/make.c b/commands/bmake/make.c deleted file mode 100644 index aa8f8bcd7..000000000 --- a/commands/bmake/make.c +++ /dev/null @@ -1,1550 +0,0 @@ -/* $NetBSD: make.c,v 1.78 2009/01/23 21:26:30 dsl Exp $ */ - -/* - * Copyright (c) 1988, 1989, 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Adam de Boor. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * Copyright (c) 1989 by Berkeley Softworks - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Adam de Boor. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: make.c,v 1.78 2009/01/23 21:26:30 dsl Exp $"; -#else -#include -#ifndef lint -#if 0 -static char sccsid[] = "@(#)make.c 8.1 (Berkeley) 6/6/93"; -#else -__RCSID("$NetBSD: make.c,v 1.78 2009/01/23 21:26:30 dsl Exp $"); -#endif -#endif /* not lint */ -#endif - -/*- - * make.c -- - * The functions which perform the examination of targets and - * their suitability for creation - * - * Interface: - * Make_Run Initialize things for the module and recreate - * whatever needs recreating. Returns TRUE if - * work was (or would have been) done and FALSE - * otherwise. - * - * Make_Update Update all parents of a given child. Performs - * various bookkeeping chores like the updating - * of the cmtime field of the parent, filling - * of the IMPSRC context variable, etc. It will - * place the parent on the toBeMade queue if it - * should be. - * - * Make_TimeStamp Function to set the parent's cmtime field - * based on a child's modification time. - * - * Make_DoAllVar Set up the various local variables for a - * target, including the .ALLSRC variable, making - * sure that any variable that needs to exist - * at the very least has the empty value. - * - * Make_OODate Determine if a target is out-of-date. - * - * Make_HandleUse See if a child is a .USE node for a parent - * and perform the .USE actions if so. - * - * Make_ExpandUse Expand .USE nodes - */ - -#include "make.h" -#include "hash.h" -#include "dir.h" -#include "job.h" - -static unsigned int checked = 1;/* Sequence # to detect recursion */ -static Lst toBeMade; /* The current fringe of the graph. These - * are nodes which await examination by - * MakeOODate. It is added to by - * Make_Update and subtracted from by - * MakeStartJobs */ - -static int MakeAddChild(void *, void *); -static int MakeFindChild(void *, void *); -static int MakeUnmark(void *, void *); -static int MakeAddAllSrc(void *, void *); -static int MakeTimeStamp(void *, void *); -static int MakeHandleUse(void *, void *); -static Boolean MakeStartJobs(void); -static int MakePrintStatus(void *, void *); -static int MakeCheckOrder(void *, void *); -static int MakeBuildChild(void *, void *); -static int MakeBuildParent(void *, void *); - -static void -make_abort(GNode *gn, int line) -{ - static int two = 2; - - fprintf(debug_file, "make_abort from line %d\n", line); - Targ_PrintNode(gn, &two); - Lst_ForEach(toBeMade, Targ_PrintNode, &two); - Targ_PrintGraph(3); - abort(); -} - -/*- - *----------------------------------------------------------------------- - * Make_TimeStamp -- - * Set the cmtime field of a parent node based on the mtime stamp in its - * child. Called from MakeOODate via Lst_ForEach. - * - * Input: - * pgn the current parent - * cgn the child we've just examined - * - * Results: - * Always returns 0. - * - * Side Effects: - * The cmtime of the parent node will be changed if the mtime - * field of the child is greater than it. - *----------------------------------------------------------------------- - */ -int -Make_TimeStamp(GNode *pgn, GNode *cgn) -{ - if (cgn->mtime > pgn->cmtime) { - pgn->cmtime = cgn->mtime; - } - return (0); -} - -/* - * Input: - * pgn the current parent - * cgn the child we've just examined - * - */ -static int -MakeTimeStamp(void *pgn, void *cgn) -{ - return Make_TimeStamp((GNode *)pgn, (GNode *)cgn); -} - -/*- - *----------------------------------------------------------------------- - * Make_OODate -- - * See if a given node is out of date with respect to its sources. - * Used by Make_Run when deciding which nodes to place on the - * toBeMade queue initially and by Make_Update to screen out USE and - * EXEC nodes. In the latter case, however, any other sort of node - * must be considered out-of-date since at least one of its children - * will have been recreated. - * - * Input: - * gn the node to check - * - * Results: - * TRUE if the node is out of date. FALSE otherwise. - * - * Side Effects: - * The mtime field of the node and the cmtime field of its parents - * will/may be changed. - *----------------------------------------------------------------------- - */ -Boolean -Make_OODate(GNode *gn) -{ - Boolean oodate; - - /* - * Certain types of targets needn't even be sought as their datedness - * doesn't depend on their modification time... - */ - if ((gn->type & (OP_JOIN|OP_USE|OP_USEBEFORE|OP_EXEC)) == 0) { - (void)Dir_MTime(gn); - if (DEBUG(MAKE)) { - if (gn->mtime != 0) { - fprintf(debug_file, "modified %s...", Targ_FmtTime(gn->mtime)); - } else { - fprintf(debug_file, "non-existent..."); - } - } - } - - /* - * A target is remade in one of the following circumstances: - * its modification time is smaller than that of its youngest child - * and it would actually be run (has commands or type OP_NOP) - * it's the object of a force operator - * it has no children, was on the lhs of an operator and doesn't exist - * already. - * - * Libraries are only considered out-of-date if the archive module says - * they are. - * - * These weird rules are brought to you by Backward-Compatibility and - * the strange people who wrote 'Make'. - */ - if (gn->type & (OP_USE|OP_USEBEFORE)) { - /* - * If the node is a USE node it is *never* out of date - * no matter *what*. - */ - if (DEBUG(MAKE)) { - fprintf(debug_file, ".USE node..."); - } - oodate = FALSE; - } else if ((gn->type & OP_LIB) && - ((gn->mtime==0) || Arch_IsLib(gn))) { - if (DEBUG(MAKE)) { - fprintf(debug_file, "library..."); - } - - /* - * always out of date if no children and :: target - * or non-existent. - */ - oodate = (gn->mtime == 0 || Arch_LibOODate(gn) || - (gn->cmtime == 0 && (gn->type & OP_DOUBLEDEP))); - } else if (gn->type & OP_JOIN) { - /* - * A target with the .JOIN attribute is only considered - * out-of-date if any of its children was out-of-date. - */ - if (DEBUG(MAKE)) { - fprintf(debug_file, ".JOIN node..."); - } - if (DEBUG(MAKE)) { - fprintf(debug_file, "source %smade...", gn->flags & CHILDMADE ? "" : "not "); - } - oodate = (gn->flags & CHILDMADE) ? TRUE : FALSE; - } else if (gn->type & (OP_FORCE|OP_EXEC|OP_PHONY)) { - /* - * A node which is the object of the force (!) operator or which has - * the .EXEC attribute is always considered out-of-date. - */ - if (DEBUG(MAKE)) { - if (gn->type & OP_FORCE) { - fprintf(debug_file, "! operator..."); - } else if (gn->type & OP_PHONY) { - fprintf(debug_file, ".PHONY node..."); - } else { - fprintf(debug_file, ".EXEC node..."); - } - } - oodate = TRUE; - } else if (gn->mtime < gn->cmtime || - (gn->cmtime == 0 && - ((gn->mtime == 0 && !(gn->type & OP_OPTIONAL)) - || gn->type & OP_DOUBLEDEP))) - { - /* - * A node whose modification time is less than that of its - * youngest child or that has no children (cmtime == 0) and - * either doesn't exist (mtime == 0) and it isn't optional - * or was the object of a * :: operator is out-of-date. - * Why? Because that's the way Make does it. - */ - if (DEBUG(MAKE)) { - if (gn->mtime < gn->cmtime) { - fprintf(debug_file, "modified before source..."); - } else if (gn->mtime == 0) { - fprintf(debug_file, "non-existent and no sources..."); - } else { - fprintf(debug_file, ":: operator and no sources..."); - } - } - oodate = TRUE; - } else { - /* - * When a non-existing child with no sources - * (such as a typically used FORCE source) has been made and - * the target of the child (usually a directory) has the same - * timestamp as the timestamp just given to the non-existing child - * after it was considered made. - */ - if (DEBUG(MAKE)) { - if (gn->flags & FORCE) - fprintf(debug_file, "non existing child..."); - } - oodate = (gn->flags & FORCE) ? TRUE : FALSE; - } - - /* - * If the target isn't out-of-date, the parents need to know its - * modification time. Note that targets that appear to be out-of-date - * but aren't, because they have no commands and aren't of type OP_NOP, - * have their mtime stay below their children's mtime to keep parents from - * thinking they're out-of-date. - */ - if (!oodate) { - Lst_ForEach(gn->parents, MakeTimeStamp, gn); - } - - return (oodate); -} - -/*- - *----------------------------------------------------------------------- - * MakeAddChild -- - * Function used by Make_Run to add a child to the list l. - * It will only add the child if its make field is FALSE. - * - * Input: - * gnp the node to add - * lp the list to which to add it - * - * Results: - * Always returns 0 - * - * Side Effects: - * The given list is extended - *----------------------------------------------------------------------- - */ -static int -MakeAddChild(void *gnp, void *lp) -{ - GNode *gn = (GNode *)gnp; - Lst l = (Lst) lp; - - if ((gn->flags & REMAKE) == 0 && !(gn->type & (OP_USE|OP_USEBEFORE))) { - if (DEBUG(MAKE)) - fprintf(debug_file, "MakeAddChild: need to examine %s%s\n", - gn->name, gn->cohort_num); - (void)Lst_EnQueue(l, gn); - } - return (0); -} - -/*- - *----------------------------------------------------------------------- - * MakeFindChild -- - * Function used by Make_Run to find the pathname of a child - * that was already made. - * - * Input: - * gnp the node to find - * - * Results: - * Always returns 0 - * - * Side Effects: - * The path and mtime of the node and the cmtime of the parent are - * updated; the unmade children count of the parent is decremented. - *----------------------------------------------------------------------- - */ -static int -MakeFindChild(void *gnp, void *pgnp) -{ - GNode *gn = (GNode *)gnp; - GNode *pgn = (GNode *)pgnp; - - (void)Dir_MTime(gn); - Make_TimeStamp(pgn, gn); - pgn->unmade--; - - return (0); -} - -/*- - *----------------------------------------------------------------------- - * Make_HandleUse -- - * Function called by Make_Run and SuffApplyTransform on the downward - * pass to handle .USE and transformation nodes. It implements the - * .USE and transformation functionality by copying the node's commands, - * type flags and children to the parent node. - * - * A .USE node is much like an explicit transformation rule, except - * its commands are always added to the target node, even if the - * target already has commands. - * - * Input: - * cgn The .USE node - * pgn The target of the .USE node - * - * Results: - * none - * - * Side Effects: - * Children and commands may be added to the parent and the parent's - * type may be changed. - * - *----------------------------------------------------------------------- - */ -void -Make_HandleUse(GNode *cgn, GNode *pgn) -{ - LstNode ln; /* An element in the children list */ - -#ifdef DEBUG_SRC - if ((cgn->type & (OP_USE|OP_USEBEFORE|OP_TRANSFORM)) == 0) { - fprintf(debug_file, "Make_HandleUse: called for plain node %s\n", cgn->name); - return; - } -#endif - - if ((cgn->type & (OP_USE|OP_USEBEFORE)) || Lst_IsEmpty(pgn->commands)) { - if (cgn->type & OP_USEBEFORE) { - /* - * .USEBEFORE -- - * prepend the child's commands to the parent. - */ - Lst cmds = pgn->commands; - pgn->commands = Lst_Duplicate(cgn->commands, NULL); - (void)Lst_Concat(pgn->commands, cmds, LST_CONCNEW); - Lst_Destroy(cmds, NULL); - } else { - /* - * .USE or target has no commands -- - * append the child's commands to the parent. - */ - (void)Lst_Concat(pgn->commands, cgn->commands, LST_CONCNEW); - } - } - - if (Lst_Open(cgn->children) == SUCCESS) { - while ((ln = Lst_Next(cgn->children)) != NULL) { - GNode *tgn, *gn = (GNode *)Lst_Datum(ln); - - /* - * Expand variables in the .USE node's name - * and save the unexpanded form. - * We don't need to do this for commands. - * They get expanded properly when we execute. - */ - if (gn->uname == NULL) { - gn->uname = gn->name; - } else { - if (gn->name) - free(gn->name); - } - gn->name = Var_Subst(NULL, gn->uname, pgn, FALSE); - if (gn->name && gn->uname && strcmp(gn->name, gn->uname) != 0) { - /* See if we have a target for this node. */ - tgn = Targ_FindNode(gn->name, TARG_NOCREATE); - if (tgn != NULL) - gn = tgn; - } - - (void)Lst_AtEnd(pgn->children, gn); - (void)Lst_AtEnd(gn->parents, pgn); - pgn->unmade += 1; - } - Lst_Close(cgn->children); - } - - pgn->type |= cgn->type & ~(OP_OPMASK|OP_USE|OP_USEBEFORE|OP_TRANSFORM); -} - -/*- - *----------------------------------------------------------------------- - * MakeHandleUse -- - * Callback function for Lst_ForEach, used by Make_Run on the downward - * pass to handle .USE nodes. Should be called before the children - * are enqueued to be looked at by MakeAddChild. - * This function calls Make_HandleUse to copy the .USE node's commands, - * type flags and children to the parent node. - * - * Input: - * cgnp the child we've just examined - * pgnp the current parent - * - * Results: - * returns 0. - * - * Side Effects: - * After expansion, .USE child nodes are removed from the parent - * - *----------------------------------------------------------------------- - */ -static int -MakeHandleUse(void *cgnp, void *pgnp) -{ - GNode *cgn = (GNode *)cgnp; - GNode *pgn = (GNode *)pgnp; - LstNode ln; /* An element in the children list */ - int unmarked; - - unmarked = ((cgn->type & OP_MARK) == 0); - cgn->type |= OP_MARK; - - if ((cgn->type & (OP_USE|OP_USEBEFORE)) == 0) - return (0); - - if (unmarked) - Make_HandleUse(cgn, pgn); - - /* - * This child node is now "made", so we decrement the count of - * unmade children in the parent... We also remove the child - * from the parent's list to accurately reflect the number of decent - * children the parent has. This is used by Make_Run to decide - * whether to queue the parent or examine its children... - */ - if ((ln = Lst_Member(pgn->children, cgn)) != NULL) { - Lst_Remove(pgn->children, ln); - pgn->unmade--; - } - return (0); -} - - -/*- - *----------------------------------------------------------------------- - * Make_Recheck -- - * Check the modification time of a gnode, and update it as described - * in the comments below. - * - * Results: - * returns 0 if the gnode does not exist, or it's filesystem - * time if it does. - * - * Side Effects: - * the gnode's modification time and path name are affected. - * - *----------------------------------------------------------------------- - */ -time_t -Make_Recheck(GNode *gn) -{ - time_t mtime = Dir_MTime(gn); - -#ifndef RECHECK - /* - * We can't re-stat the thing, but we can at least take care of rules - * where a target depends on a source that actually creates the - * target, but only if it has changed, e.g. - * - * parse.h : parse.o - * - * parse.o : parse.y - * yacc -d parse.y - * cc -c y.tab.c - * mv y.tab.o parse.o - * cmp -s y.tab.h parse.h || mv y.tab.h parse.h - * - * In this case, if the definitions produced by yacc haven't changed - * from before, parse.h won't have been updated and gn->mtime will - * reflect the current modification time for parse.h. This is - * something of a kludge, I admit, but it's a useful one.. - * XXX: People like to use a rule like - * - * FRC: - * - * To force things that depend on FRC to be made, so we have to - * check for gn->children being empty as well... - */ - if (!Lst_IsEmpty(gn->commands) || Lst_IsEmpty(gn->children)) { - gn->mtime = now; - } -#else - /* - * This is what Make does and it's actually a good thing, as it - * allows rules like - * - * cmp -s y.tab.h parse.h || cp y.tab.h parse.h - * - * to function as intended. Unfortunately, thanks to the stateless - * nature of NFS (by which I mean the loose coupling of two clients - * using the same file from a common server), there are times - * when the modification time of a file created on a remote - * machine will not be modified before the local stat() implied by - * the Dir_MTime occurs, thus leading us to believe that the file - * is unchanged, wreaking havoc with files that depend on this one. - * - * I have decided it is better to make too much than to make too - * little, so this stuff is commented out unless you're sure it's ok. - * -- ardeb 1/12/88 - */ - /* - * Christos, 4/9/92: If we are saving commands pretend that - * the target is made now. Otherwise archives with ... rules - * don't work! - */ - if (NoExecute(gn) || (gn->type & OP_SAVE_CMDS) || - (mtime == 0 && !(gn->type & OP_WAIT))) { - if (DEBUG(MAKE)) { - fprintf(debug_file, " recheck(%s): update time from %s to now\n", - gn->name, Targ_FmtTime(gn->mtime)); - } - gn->mtime = now; - } - else { - if (DEBUG(MAKE)) { - fprintf(debug_file, " recheck(%s): current update time: %s\n", - gn->name, Targ_FmtTime(gn->mtime)); - } - } -#endif - return mtime; -} - -/*- - *----------------------------------------------------------------------- - * Make_Update -- - * Perform update on the parents of a node. Used by JobFinish once - * a node has been dealt with and by MakeStartJobs if it finds an - * up-to-date node. - * - * Input: - * cgn the child node - * - * Results: - * Always returns 0 - * - * Side Effects: - * The unmade field of pgn is decremented and pgn may be placed on - * the toBeMade queue if this field becomes 0. - * - * If the child was made, the parent's flag CHILDMADE field will be - * set true and its cmtime set to now. - * - * If the child is not up-to-date and still does not exist, - * set the FORCE flag on the parents. - * - * If the child wasn't made, the cmtime field of the parent will be - * altered if the child's mtime is big enough. - * - * Finally, if the child is the implied source for the parent, the - * parent's IMPSRC variable is set appropriately. - * - *----------------------------------------------------------------------- - */ -void -Make_Update(GNode *cgn) -{ - GNode *pgn; /* the parent node */ - char *cname; /* the child's name */ - LstNode ln; /* Element in parents and iParents lists */ - time_t mtime = -1; - char *p1; - Lst parents; - GNode *centurion; - - /* It is save to re-examine any nodes again */ - checked++; - - cname = Var_Value(TARGET, cgn, &p1); - if (p1) - free(p1); - - if (DEBUG(MAKE)) - fprintf(debug_file, "Make_Update: %s%s\n", cgn->name, cgn->cohort_num); - - /* - * If the child was actually made, see what its modification time is - * now -- some rules won't actually update the file. If the file still - * doesn't exist, make its mtime now. - */ - if (cgn->made != UPTODATE) { - mtime = Make_Recheck(cgn); - } - - /* - * If this is a `::' node, we must consult its first instance - * which is where all parents are linked. - */ - if ((centurion = cgn->centurion) != NULL) { - if (!Lst_IsEmpty(cgn->parents)) - Punt("%s%s: cohort has parents", cgn->name, cgn->cohort_num); - centurion->unmade_cohorts -= 1; - if (centurion->unmade_cohorts < 0) - Error("Graph cycles through centurion %s", centurion->name); - } else { - centurion = cgn; - } - parents = centurion->parents; - - /* If this was a .ORDER node, schedule the RHS */ - Lst_ForEach(centurion->order_succ, MakeBuildParent, Lst_First(toBeMade)); - - /* Now mark all the parents as having one less unmade child */ - if (Lst_Open(parents) == SUCCESS) { - while ((ln = Lst_Next(parents)) != NULL) { - pgn = (GNode *)Lst_Datum(ln); - if (DEBUG(MAKE)) - fprintf(debug_file, "inspect parent %s%s: flags %x, " - "type %x, made %d, unmade %d ", - pgn->name, pgn->cohort_num, pgn->flags, - pgn->type, pgn->made, pgn->unmade-1); - - if (!(pgn->flags & REMAKE)) { - /* This parent isn't needed */ - if (DEBUG(MAKE)) - fprintf(debug_file, "- not needed\n"); - continue; - } - if (mtime == 0 && !(cgn->type & OP_WAIT)) - pgn->flags |= FORCE; - - /* - * If the parent has the .MADE attribute, its timestamp got - * updated to that of its newest child, and its unmake - * child count got set to zero in Make_ExpandUse(). - * However other things might cause us to build one of its - * children - and so we mustn't do any processing here when - * the child build finishes. - */ - if (pgn->type & OP_MADE) { - if (DEBUG(MAKE)) - fprintf(debug_file, "- .MADE\n"); - continue; - } - - if ( ! (cgn->type & (OP_EXEC|OP_USE|OP_USEBEFORE))) { - if (cgn->made == MADE) - pgn->flags |= CHILDMADE; - (void)Make_TimeStamp(pgn, cgn); - } - - /* - * A parent must wait for the completion of all instances - * of a `::' dependency. - */ - if (centurion->unmade_cohorts != 0 || centurion->made < MADE) { - if (DEBUG(MAKE)) - fprintf(debug_file, - "- centurion made %d, %d unmade cohorts\n", - centurion->made, centurion->unmade_cohorts); - continue; - } - - /* One more child of this parent is now made */ - pgn->unmade -= 1; - if (pgn->unmade < 0) { - if (DEBUG(MAKE)) { - fprintf(debug_file, "Graph cycles through %s%s\n", - pgn->name, pgn->cohort_num); - Targ_PrintGraph(2); - } - Error("Graph cycles through %s%s", pgn->name, pgn->cohort_num); - } - - /* We must always rescan the parents of .WAIT and .ORDER nodes. */ - if (pgn->unmade != 0 && !(centurion->type & OP_WAIT) - && !(centurion->flags & DONE_ORDER)) { - if (DEBUG(MAKE)) - fprintf(debug_file, "- unmade children\n"); - continue; - } - if (pgn->made != DEFERRED) { - /* - * Either this parent is on a different branch of the tree, - * or it on the RHS of a .WAIT directive - * or it is already on the toBeMade list. - */ - if (DEBUG(MAKE)) - fprintf(debug_file, "- not deferred\n"); - continue; - } - if (pgn->order_pred - && Lst_ForEach(pgn->order_pred, MakeCheckOrder, 0)) { - /* A .ORDER rule stops us building this */ - continue; - } - if (DEBUG(MAKE)) { - static int two = 2; - fprintf(debug_file, "- %s%s made, schedule %s%s (made %d)\n", - cgn->name, cgn->cohort_num, - pgn->name, pgn->cohort_num, pgn->made); - Targ_PrintNode(pgn, &two); - } - /* Ok, we can schedule the parent again */ - pgn->made = REQUESTED; - (void)Lst_EnQueue(toBeMade, pgn); - } - Lst_Close(parents); - } - - /* - * Set the .PREFIX and .IMPSRC variables for all the implied parents - * of this node. - */ - if (Lst_Open(cgn->iParents) == SUCCESS) { - char *cpref = Var_Value(PREFIX, cgn, &p1); - - while ((ln = Lst_Next(cgn->iParents)) != NULL) { - pgn = (GNode *)Lst_Datum(ln); - if (pgn->flags & REMAKE) { - Var_Set(IMPSRC, cname, pgn, 0); - if (cpref != NULL) - Var_Set(PREFIX, cpref, pgn, 0); - } - } - if (p1) - free(p1); - Lst_Close(cgn->iParents); - } -} - -/*- - *----------------------------------------------------------------------- - * MakeAddAllSrc -- - * Add a child's name to the ALLSRC and OODATE variables of the given - * node. Called from Make_DoAllVar via Lst_ForEach. A child is added only - * if it has not been given the .EXEC, .USE or .INVISIBLE attributes. - * .EXEC and .USE children are very rarely going to be files, so... - * If the child is a .JOIN node, its ALLSRC is propagated to the parent. - * - * A child is added to the OODATE variable if its modification time is - * later than that of its parent, as defined by Make, except if the - * parent is a .JOIN node. In that case, it is only added to the OODATE - * variable if it was actually made (since .JOIN nodes don't have - * modification times, the comparison is rather unfair...).. - * - * Results: - * Always returns 0 - * - * Side Effects: - * The ALLSRC variable for the given node is extended. - *----------------------------------------------------------------------- - */ -static int -MakeUnmark(void *cgnp, void *pgnp __unused) -{ - GNode *cgn = (GNode *)cgnp; - - cgn->type &= ~OP_MARK; - return (0); -} - -/* - * Input: - * cgnp The child to add - * pgnp The parent to whose ALLSRC variable it should - * be added - * - */ -static int -MakeAddAllSrc(void *cgnp, void *pgnp) -{ - GNode *cgn = (GNode *)cgnp; - GNode *pgn = (GNode *)pgnp; - - if (cgn->type & OP_MARK) - return (0); - cgn->type |= OP_MARK; - - if ((cgn->type & (OP_EXEC|OP_USE|OP_USEBEFORE|OP_INVISIBLE)) == 0) { - char *child, *allsrc; - char *p1 = NULL, *p2 = NULL; - - if (cgn->type & OP_ARCHV) - child = Var_Value(MEMBER, cgn, &p1); - else - child = cgn->path ? cgn->path : cgn->name; - if (cgn->type & OP_JOIN) { - allsrc = Var_Value(ALLSRC, cgn, &p2); - } else { - allsrc = child; - } - if (allsrc != NULL) - Var_Append(ALLSRC, allsrc, pgn); - if (p2) - free(p2); - if (pgn->type & OP_JOIN) { - if (cgn->made == MADE) { - Var_Append(OODATE, child, pgn); - } - } else if ((pgn->mtime < cgn->mtime) || - (cgn->mtime >= now && cgn->made == MADE)) - { - /* - * It goes in the OODATE variable if the parent is younger than the - * child or if the child has been modified more recently than - * the start of the make. This is to keep pmake from getting - * confused if something else updates the parent after the - * make starts (shouldn't happen, I know, but sometimes it - * does). In such a case, if we've updated the kid, the parent - * is likely to have a modification time later than that of - * the kid and anything that relies on the OODATE variable will - * be hosed. - * - * XXX: This will cause all made children to go in the OODATE - * variable, even if they're not touched, if RECHECK isn't defined, - * since cgn->mtime is set to now in Make_Update. According to - * some people, this is good... - */ - Var_Append(OODATE, child, pgn); - } - if (p1) - free(p1); - } - return (0); -} - -/*- - *----------------------------------------------------------------------- - * Make_DoAllVar -- - * Set up the ALLSRC and OODATE variables. Sad to say, it must be - * done separately, rather than while traversing the graph. This is - * because Make defined OODATE to contain all sources whose modification - * times were later than that of the target, *not* those sources that - * were out-of-date. Since in both compatibility and native modes, - * the modification time of the parent isn't found until the child - * has been dealt with, we have to wait until now to fill in the - * variable. As for ALLSRC, the ordering is important and not - * guaranteed when in native mode, so it must be set here, too. - * - * Results: - * None - * - * Side Effects: - * The ALLSRC and OODATE variables of the given node is filled in. - * If the node is a .JOIN node, its TARGET variable will be set to - * match its ALLSRC variable. - *----------------------------------------------------------------------- - */ -void -Make_DoAllVar(GNode *gn) -{ - Lst_ForEach(gn->children, MakeUnmark, gn); - Lst_ForEach(gn->children, MakeAddAllSrc, gn); - - if (!Var_Exists (OODATE, gn)) { - Var_Set(OODATE, "", gn, 0); - } - if (!Var_Exists (ALLSRC, gn)) { - Var_Set(ALLSRC, "", gn, 0); - } - - if (gn->type & OP_JOIN) { - char *p1; - Var_Set(TARGET, Var_Value(ALLSRC, gn, &p1), gn, 0); - if (p1) - free(p1); - } -} - -/*- - *----------------------------------------------------------------------- - * MakeStartJobs -- - * Start as many jobs as possible. - * - * Results: - * If the query flag was given to pmake, no job will be started, - * but as soon as an out-of-date target is found, this function - * returns TRUE. At all other times, this function returns FALSE. - * - * Side Effects: - * Nodes are removed from the toBeMade queue and job table slots - * are filled. - * - *----------------------------------------------------------------------- - */ - -static int -MakeCheckOrder(void *v_bn, void *ignore __unused) -{ - GNode *bn = v_bn; - - if (bn->made >= MADE || !(bn->flags & REMAKE)) - return 0; - if (DEBUG(MAKE)) - fprintf(debug_file, "MakeCheckOrder: Waiting for .ORDER node %s%s\n", - bn->name, bn->cohort_num); - return 1; -} - -static int -MakeBuildChild(void *v_cn, void *toBeMade_next) -{ - GNode *cn = v_cn; - - if (DEBUG(MAKE)) - fprintf(debug_file, "MakeBuildChild: inspect %s%s, made %d, type %x\n", - cn->name, cn->cohort_num, cn->made, cn->type); - if (cn->made > DEFERRED) - return 0; - - /* If this node is on the RHS of a .ORDER, check LHSs. */ - if (cn->order_pred && Lst_ForEach(cn->order_pred, MakeCheckOrder, 0)) { - /* Can't build this (or anything else in this child list) yet */ - cn->made = DEFERRED; - return 1; - } - - if (DEBUG(MAKE)) - fprintf(debug_file, "MakeBuildChild: schedule %s%s\n", - cn->name, cn->cohort_num); - - cn->made = REQUESTED; - if (toBeMade_next == NULL) - Lst_AtEnd(toBeMade, cn); - else - Lst_InsertBefore(toBeMade, toBeMade_next, cn); - - if (cn->unmade_cohorts != 0) - Lst_ForEach(cn->cohorts, MakeBuildChild, toBeMade_next); - - /* - * If this node is a .WAIT node with unmade chlidren - * then don't add the next sibling. - */ - return cn->type & OP_WAIT && cn->unmade > 0; -} - -/* When a .ORDER RHS node completes we do this on each LHS */ -static int -MakeBuildParent(void *v_pn, void *toBeMade_next) -{ - GNode *pn = v_pn; - - if (pn->made != DEFERRED) - return 0; - - if (MakeBuildChild(pn, toBeMade_next) == 0) { - /* Mark so that when this node is built we reschedule its parents */ - pn->flags |= DONE_ORDER; - } - - return 0; -} - -static Boolean -MakeStartJobs(void) -{ - GNode *gn; - int have_token = 0; - - while (!Lst_IsEmpty (toBeMade)) { - /* Get token now to avoid cycling job-list when we only have 1 token */ - if (!have_token && !Job_TokenWithdraw()) - break; - have_token = 1; - - gn = (GNode *)Lst_DeQueue(toBeMade); - if (DEBUG(MAKE)) - fprintf(debug_file, "Examining %s%s...\n", - gn->name, gn->cohort_num); - - if (gn->made != REQUESTED) { - if (DEBUG(MAKE)) - fprintf(debug_file, "state %d\n", gn->made); - - make_abort(gn, __LINE__); - } - - if (gn->checked == checked) { - /* We've already looked at this node since a job finished... */ - if (DEBUG(MAKE)) - fprintf(debug_file, "already checked %s%s\n", - gn->name, gn->cohort_num); - gn->made = DEFERRED; - continue; - } - gn->checked = checked; - - if (gn->unmade != 0) { - /* - * We can't build this yet, add all unmade children to toBeMade, - * just before the current first element. - */ - gn->made = DEFERRED; - Lst_ForEach(gn->children, MakeBuildChild, Lst_First(toBeMade)); - /* and drop this node on the floor */ - if (DEBUG(MAKE)) - fprintf(debug_file, "dropped %s%s\n", gn->name, gn->cohort_num); - continue; - } - - gn->made = BEINGMADE; - if (Make_OODate(gn)) { - if (DEBUG(MAKE)) { - fprintf(debug_file, "out-of-date\n"); - } - if (queryFlag) { - return (TRUE); - } - Make_DoAllVar(gn); - Job_Make(gn); - have_token = 0; - } else { - if (DEBUG(MAKE)) { - fprintf(debug_file, "up-to-date\n"); - } - gn->made = UPTODATE; - if (gn->type & OP_JOIN) { - /* - * Even for an up-to-date .JOIN node, we need it to have its - * context variables so references to it get the correct - * value for .TARGET when building up the context variables - * of its parent(s)... - */ - Make_DoAllVar(gn); - } - Make_Update(gn); - } - } - - if (have_token) - Job_TokenReturn(); - - return (FALSE); -} - -/*- - *----------------------------------------------------------------------- - * MakePrintStatus -- - * Print the status of a top-level node, viz. it being up-to-date - * already or not created due to an error in a lower level. - * Callback function for Make_Run via Lst_ForEach. - * - * Input: - * gnp Node to examine - * cyclep True if gn->unmade being non-zero implies a - * cycle in the graph, not an error in an - * inferior. - * - * Results: - * Always returns 0. - * - * Side Effects: - * A message may be printed. - * - *----------------------------------------------------------------------- - */ -static int -MakePrintStatusOrder(void *ognp, void *gnp) -{ - GNode *ogn = ognp; - GNode *gn = gnp; - - if (!(ogn->flags & REMAKE) || ogn->made > REQUESTED) - /* not waiting for this one */ - return 0; - - printf(" `%s%s' has .ORDER dependency against %s%s " - "(made %d, flags %x, type %x)\n", - gn->name, gn->cohort_num, - ogn->name, ogn->cohort_num, ogn->made, ogn->flags, ogn->type); - if (DEBUG(MAKE) && debug_file != stdout) - fprintf(debug_file, " `%s%s' has .ORDER dependency against %s%s " - "(made %d, flags %x, type %x)\n", - gn->name, gn->cohort_num, - ogn->name, ogn->cohort_num, ogn->made, ogn->flags, ogn->type); - return 0; -} - -static int -MakePrintStatus(void *gnp, void *v_errors) -{ - GNode *gn = (GNode *)gnp; - int *errors = v_errors; - - if (gn->flags & DONECYCLE) - /* We've completely processed this node before, don't do it again. */ - return 0; - - if (gn->unmade == 0) { - gn->flags |= DONECYCLE; - switch (gn->made) { - case UPTODATE: - printf("`%s%s' is up to date.\n", gn->name, gn->cohort_num); - break; - case MADE: - break; - case UNMADE: - case DEFERRED: - case REQUESTED: - case BEINGMADE: - (*errors)++; - printf("`%s%s' was not built (made %d, flags %x, type %x)!\n", - gn->name, gn->cohort_num, gn->made, gn->flags, gn->type); - if (DEBUG(MAKE) && debug_file != stdout) - fprintf(debug_file, - "`%s%s' was not built (made %d, flags %x, type %x)!\n", - gn->name, gn->cohort_num, gn->made, gn->flags, gn->type); - /* Most likely problem is actually caused by .ORDER */ - Lst_ForEach(gn->order_pred, MakePrintStatusOrder, gn); - break; - default: - /* Errors - already counted */ - printf("`%s%s' not remade because of errors.\n", - gn->name, gn->cohort_num); - if (DEBUG(MAKE) && debug_file != stdout) - fprintf(debug_file, "`%s%s' not remade because of errors.\n", - gn->name, gn->cohort_num); - break; - } - return 0; - } - - if (DEBUG(MAKE)) - fprintf(debug_file, "MakePrintStatus: %s%s has %d unmade children\n", - gn->name, gn->cohort_num, gn->unmade); - /* - * If printing cycles and came to one that has unmade children, - * print out the cycle by recursing on its children. - */ - if (!(gn->flags & CYCLE)) { - /* Fist time we've seen this node, check all children */ - gn->flags |= CYCLE; - Lst_ForEach(gn->children, MakePrintStatus, errors); - /* Mark that this node needn't be processed again */ - gn->flags |= DONECYCLE; - return 0; - } - - /* Only output the error once per node */ - gn->flags |= DONECYCLE; - Error("Graph cycles through `%s%s'", gn->name, gn->cohort_num); - if ((*errors)++ > 100) - /* Abandon the whole error report */ - return 1; - - /* Reporting for our children will give the rest of the loop */ - Lst_ForEach(gn->children, MakePrintStatus, errors); - return 0; -} - - -/*- - *----------------------------------------------------------------------- - * Make_ExpandUse -- - * Expand .USE nodes and create a new targets list - * - * Input: - * targs the initial list of targets - * - * Side Effects: - *----------------------------------------------------------------------- - */ -void -Make_ExpandUse(Lst targs) -{ - GNode *gn; /* a temporary pointer */ - Lst examine; /* List of targets to examine */ - - examine = Lst_Duplicate(targs, NULL); - - /* - * Make an initial downward pass over the graph, marking nodes to be made - * as we go down. We call Suff_FindDeps to find where a node is and - * to get some children for it if it has none and also has no commands. - * If the node is a leaf, we stick it on the toBeMade queue to - * be looked at in a minute, otherwise we add its children to our queue - * and go on about our business. - */ - while (!Lst_IsEmpty (examine)) { - gn = (GNode *)Lst_DeQueue(examine); - - if (gn->flags & REMAKE) - /* We've looked at this one already */ - continue; - gn->flags |= REMAKE; - if (DEBUG(MAKE)) - fprintf(debug_file, "Make_ExpandUse: examine %s%s\n", - gn->name, gn->cohort_num); - - if ((gn->type & OP_DOUBLEDEP) && !Lst_IsEmpty (gn->cohorts)) { - /* Append all the 'cohorts' to the list of things to examine */ - Lst new; - new = Lst_Duplicate(gn->cohorts, NULL); - Lst_Concat(new, examine, LST_CONCLINK); - examine = new; - } - - /* - * Apply any .USE rules before looking for implicit dependencies - * to make sure everything has commands that should... - * Make sure that the TARGET is set, so that we can make - * expansions. - */ - if (gn->type & OP_ARCHV) { - char *eoa, *eon; - eoa = strchr(gn->name, '('); - eon = strchr(gn->name, ')'); - if (eoa == NULL || eon == NULL) - continue; - *eoa = '\0'; - *eon = '\0'; - Var_Set(MEMBER, eoa + 1, gn, 0); - Var_Set(ARCHIVE, gn->name, gn, 0); - *eoa = '('; - *eon = ')'; - } - - (void)Dir_MTime(gn); - Var_Set(TARGET, gn->path ? gn->path : gn->name, gn, 0); - Lst_ForEach(gn->children, MakeUnmark, gn); - Lst_ForEach(gn->children, MakeHandleUse, gn); - - if ((gn->type & OP_MADE) == 0) - Suff_FindDeps(gn); - else { - /* Pretend we made all this node's children */ - Lst_ForEach(gn->children, MakeFindChild, gn); - if (gn->unmade != 0) - printf("Warning: %s%s still has %d unmade children\n", - gn->name, gn->cohort_num, gn->unmade); - } - - if (gn->unmade != 0) - Lst_ForEach(gn->children, MakeAddChild, examine); - } - - Lst_Destroy(examine, NULL); -} - -/*- - *----------------------------------------------------------------------- - * Make_ProcessWait -- - * Convert .WAIT nodes into dependencies - * - * Input: - * targs the initial list of targets - * - *----------------------------------------------------------------------- - */ - -static int -link_parent(void *cnp, void *pnp) -{ - GNode *cn = cnp; - GNode *pn = pnp; - - Lst_AtEnd(pn->children, cn); - Lst_AtEnd(cn->parents, pn); - pn->unmade++; - return 0; -} - -static int -add_wait_dep(void *v_cn, void *v_wn) -{ - GNode *cn = v_cn; - GNode *wn = v_wn; - - if (cn == wn) - return 1; - - if (cn == NULL || wn == NULL) { - printf("bad wait dep %p %p\n", cn, wn); - exit(4); - } - if (DEBUG(MAKE)) - fprintf(debug_file, ".WAIT: add dependency %s%s -> %s\n", - cn->name, cn->cohort_num, wn->name); - - Lst_AtEnd(wn->children, cn); - wn->unmade++; - Lst_AtEnd(cn->parents, wn); - return 0; -} - -static void -Make_ProcessWait(Lst targs) -{ - GNode *pgn; /* 'parent' node we are examining */ - GNode *cgn; /* Each child in turn */ - LstNode owln; /* Previous .WAIT node */ - Lst examine; /* List of targets to examine */ - LstNode ln; - - /* - * We need all the nodes to have a common parent in order for the - * .WAIT and .ORDER scheduling to work. - * Perhaps this should be done earlier... - */ - - pgn = Targ_NewGN(".MAIN"); - pgn->flags = REMAKE; - pgn->type = OP_PHONY | OP_DEPENDS; - /* Get it displayed in the diag dumps */ - Lst_AtFront(Targ_List(), pgn); - - Lst_ForEach(targs, link_parent, pgn); - - /* Start building with the 'dummy' .MAIN' node */ - MakeBuildChild(pgn, NULL); - - examine = Lst_Init(FALSE); - Lst_AtEnd(examine, pgn); - - while (!Lst_IsEmpty (examine)) { - pgn = Lst_DeQueue(examine); - - /* We only want to process each child-list once */ - if (pgn->flags & DONE_WAIT) - continue; - pgn->flags |= DONE_WAIT; - if (DEBUG(MAKE)) - fprintf(debug_file, "Make_ProcessWait: examine %s\n", pgn->name); - - if ((pgn->type & OP_DOUBLEDEP) && !Lst_IsEmpty (pgn->cohorts)) { - /* Append all the 'cohorts' to the list of things to examine */ - Lst new; - new = Lst_Duplicate(pgn->cohorts, NULL); - Lst_Concat(new, examine, LST_CONCLINK); - examine = new; - } - - owln = Lst_First(pgn->children); - Lst_Open(pgn->children); - for (; (ln = Lst_Next(pgn->children)) != NULL; ) { - cgn = Lst_Datum(ln); - if (cgn->type & OP_WAIT) { - /* Make the .WAIT node depend on the previous children */ - Lst_ForEachFrom(pgn->children, owln, add_wait_dep, cgn); - owln = ln; - } else { - Lst_AtEnd(examine, cgn); - } - } - Lst_Close(pgn->children); - } - - Lst_Destroy(examine, NULL); -} - -/*- - *----------------------------------------------------------------------- - * Make_Run -- - * Initialize the nodes to remake and the list of nodes which are - * ready to be made by doing a breadth-first traversal of the graph - * starting from the nodes in the given list. Once this traversal - * is finished, all the 'leaves' of the graph are in the toBeMade - * queue. - * Using this queue and the Job module, work back up the graph, - * calling on MakeStartJobs to keep the job table as full as - * possible. - * - * Input: - * targs the initial list of targets - * - * Results: - * TRUE if work was done. FALSE otherwise. - * - * Side Effects: - * The make field of all nodes involved in the creation of the given - * targets is set to 1. The toBeMade list is set to contain all the - * 'leaves' of these subgraphs. - *----------------------------------------------------------------------- - */ -Boolean -Make_Run(Lst targs) -{ - int errors; /* Number of errors the Job module reports */ - - /* Start trying to make the current targets... */ - toBeMade = Lst_Init(FALSE); - - Make_ExpandUse(targs); - Make_ProcessWait(targs); - - if (DEBUG(MAKE)) { - fprintf(debug_file, "#***# full graph\n"); - Targ_PrintGraph(1); - } - - if (queryFlag) { - /* - * We wouldn't do any work unless we could start some jobs in the - * next loop... (we won't actually start any, of course, this is just - * to see if any of the targets was out of date) - */ - return (MakeStartJobs()); - } - /* - * Initialization. At the moment, no jobs are running and until some - * get started, nothing will happen since the remaining upward - * traversal of the graph is performed by the routines in job.c upon - * the finishing of a job. So we fill the Job table as much as we can - * before going into our loop. - */ - (void)MakeStartJobs(); - - /* - * Main Loop: The idea here is that the ending of jobs will take - * care of the maintenance of data structures and the waiting for output - * will cause us to be idle most of the time while our children run as - * much as possible. Because the job table is kept as full as possible, - * the only time when it will be empty is when all the jobs which need - * running have been run, so that is the end condition of this loop. - * Note that the Job module will exit if there were any errors unless the - * keepgoing flag was given. - */ - while (!Lst_IsEmpty(toBeMade) || jobTokensRunning > 0) { - Job_CatchOutput(); - (void)MakeStartJobs(); - } - - errors = Job_Finish(); - - /* - * Print the final status of each target. E.g. if it wasn't made - * because some inferior reported an error. - */ - if (DEBUG(MAKE)) - fprintf(debug_file, "done: errors %d\n", errors); - if (errors == 0) { - Lst_ForEach(targs, MakePrintStatus, &errors); - if (DEBUG(MAKE)) { - fprintf(debug_file, "done: errors %d\n", errors); - if (errors) - Targ_PrintGraph(4); - } - } - return errors != 0; -} diff --git a/commands/i386/acd.descr b/commands/i386/acd.descr index 36593e314..2d5ead0ec 100644 --- a/commands/i386/acd.descr +++ b/commands/i386/acd.descr @@ -74,18 +74,6 @@ if $PROGRAM = cc RTSO = -.c LIBS = $LIBS + -.c -arg -.mod -if $PROGRAM = m2 - ifndef RTSO - RTSO = -.mod - LIBS = $LIBS + -.mod - -arg -.p -if $PROGRAM = pc - ifndef RTSO - RTSO = -.p - LIBS = $LIBS + -.p - # Omit the runtime startoff, but keep the libraries. arg -.o RTSO = @@ -315,24 +303,6 @@ transform .i .k RTSO = -.c LIBS = $LIBS + -.c -# Compile Modula-2 source to EM-code. -transform .mod .k - ifhash $* - apply .c .i - $ACK_M2 $* $> - ifndef RTSO - RTSO = -.mod - LIBS = $LIBS + -.mod - -# Compile Pascal source to EM-code. -transform .p .k - ifhash $* - apply .c .i - $ACK_PC $* $> - ifndef RTSO - RTSO = -.p - LIBS = $LIBS + -.p - # Compact EM to readable EM. transform .k .e transform .m .e @@ -393,23 +363,13 @@ combine (.o .a) .out rtso = if $RTSO = -.c rtso = $A/$ARCH/crtso.o - if $RTSO = -.mod - rtso = $A/$ARCH/m2rtso.o - if $RTSO = -.p - rtso = $A/$ARCH/prtso.o - libm2 = ; libp = ; libd = ; libc = ; libfp = - if (-.mod - $LIBS) = () - libm2 = $A/$ARCH/libm2.a - libc = $A/$ARCH/libc.a - if (-.p - $LIBS) = () - libp = $A/$ARCH/libp.a - libc = $A/$ARCH/libc.a + libd = ; libc = ; libfp = if (-.c - $LIBS) = () libd = $A/$ARCH/libd.a libc = $A/$ARCH/libc.a if (-fsoft - $LIBS) = () libfp = $A/$ARCH/libfp.a - libs = $libm2 $libp $libd $libc $libfp $A/$ARCH/libe.a + libs = $libd $libc $libfp $A/$ARCH/libe.a ifndef OUT OUT = a.out if (-r - $MODEL) = () @@ -418,7 +378,7 @@ combine (.o .a) .out else # Combine to an executable. mktemp EXE - $ACK_LED $model -o $EXE $rtso $* $libs $A/$ARCH/end.a + $ACK_LED $model -o $EXE $rtso $* $libs $A/$ARCH/libend.a $ACK_CV -x -m$ARCH $EXE $OUT # Add object files to a library. diff --git a/commands/i86/Makefile b/commands/i86/Makefile index 4e69cbeb2..cfec0ed0c 100644 --- a/commands/i86/Makefile +++ b/commands/i86/Makefile @@ -11,13 +11,10 @@ cc: cc.c $(CCLD) -o $@ $? install -S 6kb $@ -install: /usr/bin/cc /usr/bin/m2 /usr/bin/pc +install: /usr/bin/cc /usr/bin/cc: cc install -cs -o bin $? $@ -/usr/bin/m2 /usr/bin/pc: /usr/bin/cc - install -l $? $@ - clean: rm -rf a.out core cc diff --git a/commands/make/Makefile b/commands/make/Makefile index 2e36c82bf..4f372146b 100644 --- a/commands/make/Makefile +++ b/commands/make/Makefile @@ -1,22 +1,54 @@ -# Makefile for make (!) +# $NetBSD: Makefile.boot,v 1.19 2009/01/24 11:59:39 dsl Exp $ +# +# a very simple makefile... +# +# You only want to use this if you aren't running NetBSD. +# +# modify MACHINE and MACHINE_ARCH as appropriate for your target architecture +# +#CC=gcc -O -g +CC=cc +CFLAGS=-g -Wall -DHAVE_SETENV -DHAVE_STRERROR -DHAVE_STRDUP -DHAVE_STRFTIME -DHAVE_VSNPRINTF -DUSE_SELECT -D_POSIX_SOURCE -D_MINIX -CFLAGS = -O -Dunix -D_MINIX -D_POSIX_SOURCE -CC = exec cc +.c.o: + ${CC} ${CFLAGS} -c $< -o $@ -OBJ = check.o input.o macro.o main.o make.o reader.o rules.o archive.o +MACHINE=i386 +MACHINE_ARCH=i386 +# tested on HP-UX 10.20 +#MAKE_MACHINE=hp700 +#MAKE_MACHINE_ARCH=hppa +CFLAGS+= -DTARGET_MACHINE=\"${MACHINE}\" \ + -DTARGET_MACHINE_ARCH=\"${MACHINE_ARCH}\" \ + -DMAKE_MACHINE=\"${MACHINE}\" +LIBS= -all: make +OBJ=arch.o buf.o compat.o cond.o dir.o for.o hash.o job.o main.o make.o \ + make_malloc.o parse.o str.o strlist.o suff.o targ.o trace.o var.o util.o -make : $(OBJ) - $(CC) -i -o make $(OBJ) - install -S 330k make +LIBOBJ= lst.lib/lstAppend.o lst.lib/lstAtEnd.o lst.lib/lstAtFront.o \ + lst.lib/lstClose.o lst.lib/lstConcat.o lst.lib/lstDatum.o \ + lst.lib/lstDeQueue.o lst.lib/lstDestroy.o lst.lib/lstDupl.o \ + lst.lib/lstEnQueue.o lst.lib/lstFind.o lst.lib/lstFindFrom.o \ + lst.lib/lstFirst.o lst.lib/lstForEach.o lst.lib/lstForEachFrom.o \ + lst.lib/lstInit.o lst.lib/lstInsert.o lst.lib/lstIsAtEnd.o \ + lst.lib/lstIsEmpty.o lst.lib/lstLast.o lst.lib/lstMember.o \ + lst.lib/lstNext.o lst.lib/lstOpen.o lst.lib/lstRemove.o \ + lst.lib/lstReplace.o lst.lib/lstSucc.o lst.lib/lstPrev.o -install: /usr/bin/make +all: make -/usr/bin/make: make +make: ${OBJ} ${LIBOBJ} +# @echo 'make of make and make.0 started.' + ${CC} ${CFLAGS} ${OBJ} ${LIBOBJ} -o make ${LIBS} + @ls -l $@ +# nroff -h -man make.1 > make.0 +# @echo 'make of make and make.0 completed.' + +install: /usr/bin/make + +/usr/bin/make: make install -c -o bin make $@ - -$(OBJ): h.h clean: - rm -f *.o *.bak core make + rm -f ${OBJ} ${LIBOBJ} ${PORTOBJ} make diff --git a/commands/bmake/Makefile.boot b/commands/make/Makefile.boot similarity index 100% rename from commands/bmake/Makefile.boot rename to commands/make/Makefile.boot diff --git a/commands/bmake/Makefile b/commands/make/Makefile.netbsd similarity index 100% rename from commands/bmake/Makefile rename to commands/make/Makefile.netbsd diff --git a/commands/bmake/PSD.doc/Makefile b/commands/make/PSD.doc/Makefile similarity index 100% rename from commands/bmake/PSD.doc/Makefile rename to commands/make/PSD.doc/Makefile diff --git a/commands/bmake/PSD.doc/tutorial.ms b/commands/make/PSD.doc/tutorial.ms similarity index 100% rename from commands/bmake/PSD.doc/tutorial.ms rename to commands/make/PSD.doc/tutorial.ms diff --git a/commands/bmake/arch.c b/commands/make/arch.c similarity index 100% rename from commands/bmake/arch.c rename to commands/make/arch.c diff --git a/commands/make/archive.c b/commands/make/archive.c deleted file mode 100644 index 530cb651c..000000000 --- a/commands/make/archive.c +++ /dev/null @@ -1,309 +0,0 @@ -/* archive.c - archive support Author: Kees J. Bot - * 13 Nov 1993 - */ -#include "h.h" - -#ifdef unix - -#include -#include - -#define arraysize(a) (sizeof(a) / sizeof((a)[0])) -#define arraylimit(a) ((a) + arraysize(a)) - -/* ASCII ar header. */ - -#define ASCII_ARMAG "!\n" -#define ASCII_SARMAG 8 -#define ASCII_ARFMAG "`\n" - -struct ascii_ar_hdr { - char ar_name[16]; - char ar_date[12]; - char ar_uid[6]; - char ar_gid[6]; - char ar_mode[8]; - char ar_size[10]; - char ar_fmag[2]; -}; - -/* ACK ar header. */ - -#define ACK_ARMAG 0177545 -#define ACK_AALMAG 0177454 - -struct ack_ar_hdr { - char ar_name[14]; - unsigned long ar_date; - unsigned char ar_uid; - unsigned char ar_gid; - unsigned short ar_mode; - unsigned long ar_size; -}; - -typedef struct archname { - struct archname *next; /* Next on the hash chain. */ - char name[16]; /* One archive entry. */ - time_t date; /* The timestamp. */ - /* (no need for other attibutes) */ -} archname_t; - -static size_t namelen; /* Max name length, 14 or 16. */ - -#define HASHSIZE (64 << sizeof(int)) - -static archname_t *nametab[HASHSIZE]; - -_PROTOTYPE( static int hash, (char *name) ); -_PROTOTYPE( static int searchtab, (char *name, time_t *date, int scan) ); -_PROTOTYPE( static void deltab, (void) ); -_PROTOTYPE( static long ar_atol, (char *s, size_t n) ); -_PROTOTYPE( static int read_ascii_archive, (int afd) ); -_PROTOTYPE( static int read_ack_archive, (int afd) ); - -static char *lpar, *rpar; /* Leave these at '(' and ')'. */ - -int is_archive_ref(name) char *name; -/* True if name is of the form "archive(file)". */ -{ - char *p = name; - - while (*p != 0 && *p != '(' && *p != ')') p++; - lpar = p; - if (*p++ != '(') return 0; - - while (*p != 0 && *p != '(' && *p != ')') p++; - rpar = p; - if (*p++ != ')') return 0; - - return *p == 0; -} - -static int hash(name) char *name; -/* Compute a hash value out of a name. */ -{ - unsigned h = 0; - unsigned char *p = (unsigned char *) name; - int n = namelen; - - while (*p != 0) { - h = h * 0x1111 + *p++; - if (--n == 0) break; - } - - return h % arraysize(nametab); -} - -static int searchtab(name, date, scan) char *name; time_t *date; int scan; -/* Enter a name to the table, or return the date of one already there. */ -{ - archname_t **pnp, *np; - int cmp = 1; - - pnp = &nametab[hash(name)]; - - while ((np = *pnp) != NULL - && (cmp = strncmp(name, np->name, namelen)) > 0) { - pnp= &np->next; - } - - if (cmp != 0) { - if (scan) { - errno = ENOENT; - return -1; - } - if ((np = (archname_t *) malloc(sizeof(*np))) == NULL) - fatal("No memory for archive name cache",(char *)0,0); - strncpy(np->name, name, namelen); - np->date = *date; - np->next = *pnp; - *pnp = np; - } - if (scan) *date = np->date; - return 0; -} - -static void deltab() -/* Delete the name cache, a different library is to be read. */ -{ - archname_t **pnp, *np, *junk; - - for (pnp = nametab; pnp < arraylimit(nametab); pnp++) { - for (np = *pnp; np != NULL; ) { - junk = np; - np = np->next; - free(junk); - } - *pnp = NULL; - } -} - -static long ar_atol(s, n) char *s; size_t n; -/* Transform a string into a number. Ignore the space padding. */ -{ - long l= 0; - - while (n > 0) { - if (*s != ' ') l= l * 10 + (*s - '0'); - s++; - n--; - } - return l; -} - -static int read_ascii_archive(afd) -int afd; -/* Read a modern ASCII type archive. */ -{ - struct ascii_ar_hdr hdr; - off_t pos= 8; - char *p; - time_t date; - - namelen = 16; - - for (;;) { - if (lseek(afd, pos, SEEK_SET) == -1) return -1; - - switch (read(afd, &hdr, sizeof(hdr))) { - case sizeof(hdr): - break; - case -1: - return -1; - default: - return 0; - } - - if (strncmp(hdr.ar_fmag, ASCII_ARFMAG, sizeof(hdr.ar_fmag)) != 0) { - errno= EINVAL; - return -1; - } - - /* Strings are space padded! */ - for (p= hdr.ar_name; p < hdr.ar_name + sizeof(hdr.ar_name); p++) { - if (*p == ' ') { - *p= 0; - break; - } - } - - /* Add a file to the cache. */ - date = ar_atol(hdr.ar_date, sizeof(hdr.ar_date)); - searchtab(hdr.ar_name, &date, 0); - - pos+= sizeof(hdr) + ar_atol(hdr.ar_size, sizeof(hdr.ar_size)); - pos= (pos + 1) & (~ (off_t) 1); - } -} - -static int read_ack_archive(afd) -int afd; -/* Read an ACK type archive. */ -{ - unsigned char raw_hdr[14 + 4 + 1 + 1 + 2 + 4]; - struct ack_ar_hdr hdr; - off_t pos= 2; - time_t date; - - namelen = 14; - - for (;;) { - if (lseek(afd, pos, SEEK_SET) == -1) return -1; - - switch (read(afd, raw_hdr, sizeof(raw_hdr))) { - case sizeof(raw_hdr): - break; - case -1: - return -1; - default: - return 0; - } - - /* Copy the useful fields from the raw bytes transforming PDP-11 - * style numbers to native format. - */ - memcpy(hdr.ar_name, raw_hdr + 0, 14); - hdr.ar_date= (long) raw_hdr[14 + 1] << 24 - | (long) raw_hdr[14 + 0] << 16 - | (long) raw_hdr[14 + 3] << 8 - | (long) raw_hdr[14 + 2] << 0; - hdr.ar_size= (long) raw_hdr[22 + 1] << 24 - | (long) raw_hdr[22 + 0] << 16 - | (long) raw_hdr[22 + 3] << 8 - | (long) raw_hdr[22 + 2] << 0; - - /* Add a file to the cache. */ - date = hdr.ar_date; - searchtab(hdr.ar_name, &date, 0); - - pos= (pos + 26 + hdr.ar_size + 1) & (~ (off_t) 1); - } -} - -int archive_stat(name, stp) char *name; struct stat *stp; -/* Search an archive for a file and return that file's stat info. */ -{ - int afd; - int r= -1; - char magic[8]; - char *file; - static dev_t ardev; - static ino_t arino = 0; - static time_t armtime; - - if (!is_archive_ref(name)) { errno = EINVAL; return -1; } - *lpar= 0; - *rpar= 0; - file= lpar + 1; - - if (stat(name, stp) < 0) goto bail_out; - - if (stp->st_ino != arino || stp->st_dev != ardev) { - /* Either the first (and probably only) library, or a different - * library. - */ - arino = stp->st_ino; - ardev = stp->st_dev; - armtime = stp->st_mtime; - deltab(); - - if ((afd= open(name, O_RDONLY)) < 0) goto bail_out; - - switch (read(afd, magic, sizeof(magic))) { - case 8: - if (strncmp(magic, ASCII_ARMAG, 8) == 0) { - r= read_ascii_archive(afd); - break; - } - if ((magic[0] & 0xFF) == ((ACK_AALMAG >> 0) & 0xFF) - && (magic[1] & 0xFF) == ((ACK_AALMAG >> 8) & 0xFF) - ) { - r= read_ack_archive(afd); - break; - } - /*FALL THROUGH*/ - default: - errno = EINVAL; - /*FALL THROUGH*/ - case -1: - /* r= -1 */; - } - { int e= errno; close(afd); errno= e; } - } else { - /* Library is cached. */ - r = 0; - } - - if (r == 0) { - /* Search the cache. */ - r = searchtab(file, &stp->st_mtime, 1); - if (stp->st_mtime > armtime) stp->st_mtime = armtime; - } - -bail_out: - /* Repair the name(file) thing. */ - *lpar= '('; - *rpar= ')'; - return r; -} -#endif diff --git a/commands/bmake/buf.c b/commands/make/buf.c similarity index 100% rename from commands/bmake/buf.c rename to commands/make/buf.c diff --git a/commands/bmake/buf.h b/commands/make/buf.h similarity index 100% rename from commands/bmake/buf.h rename to commands/make/buf.h diff --git a/commands/make/build b/commands/make/build deleted file mode 100755 index 3ee5f0395..000000000 --- a/commands/make/build +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -make clean -make && make install diff --git a/commands/make/check.c b/commands/make/check.c deleted file mode 100644 index 1ac62c990..000000000 --- a/commands/make/check.c +++ /dev/null @@ -1,128 +0,0 @@ -/************************************************************************* - * - * m a k e : c h e c k . c - * - * debugging stuff: Check structures for make. - *======================================================================== - * Edition history - * - * # Date Comments By - * --- -------- ---------------------------------------------------- --- - * 1 ?? ?? - * 2 23.08.89 adapted to new name tree structure RAL - * 3 30.08.89 indention changed PSH,RAL - * 4 06.09.89 prt output redirected to stdout RAL - * ------------ Version 2.0 released ------------------------------- RAL - * - *************************************************************************/ - -#include "h.h" - - -/* - * Prints out the structures as defined in memory. Good for check - * that you make file does what you want (and for debugging make). - */ -void prt() -{ - register struct name *np; - register struct depend *dp; - register struct line *lp; - register struct cmd *cp; - register struct macro *mp; - - register int i; - - for (mp = macrohead; mp; mp = mp->m_next) - printf("%s = %s\n", mp->m_name, mp->m_val); - - putchar('\n'); - - for (i = 0; i <= maxsuffarray ; i++) - for (np = suffparray[i]->n_next; np; np = np->n_next) - { - if (np->n_flag & N_DOUBLE) - printf("%s::\n", np->n_name); - else - printf("%s:\n", np->n_name); - if (np == firstname) - printf("(MAIN NAME)\n"); - for (lp = np->n_line; lp; lp = lp->l_next) - { - putchar(':'); - for (dp = lp->l_dep; dp; dp = dp->d_next) - printf(" %s", dp->d_name->n_name); - putchar('\n'); - - for (cp = lp->l_cmd; cp; cp = cp->c_next) -#ifdef os9 - printf("- %s\n", cp->c_cmd); -#else - printf("-\t%s\n", cp->c_cmd); -#endif - putchar('\n'); - } - putchar('\n'); - } -} - - -/* - * Recursive routine that does the actual checking. - */ -void check(np) -struct name *np; -{ - register struct depend *dp; - register struct line *lp; - - - if (np->n_flag & N_MARK) - fatal("Circular dependency from %s", np->n_name,0); - - np->n_flag |= N_MARK; - - for (lp = np->n_line; lp; lp = lp->l_next) - for (dp = lp->l_dep; dp; dp = dp->d_next) - check(dp->d_name); - - np->n_flag &= ~N_MARK; -} - - -/* - * Look for circular dependancies. - * ie. - * a: b - * b: a - * is a circular dep - */ -void circh() -{ - register struct name *np; - register int i; - - - for (i = 0; i <= maxsuffarray ; i++) - for (np = suffparray[i]->n_next; np; np = np->n_next) - check(np); -} - - -/* - * Check the target .PRECIOUS, and mark its dependentd as precious - */ -void precious() -{ - register struct depend *dp; - register struct line *lp; - register struct name *np; - - - if (!((np = newname(".PRECIOUS"))->n_flag & N_TARG)) - return; - - for (lp = np->n_line; lp; lp = lp->l_next) - for (dp = lp->l_dep; dp; dp = dp->d_next) - dp->d_name->n_flag |= N_PREC; -} diff --git a/commands/bmake/compat.c b/commands/make/compat.c similarity index 100% rename from commands/bmake/compat.c rename to commands/make/compat.c diff --git a/commands/bmake/cond.c b/commands/make/cond.c similarity index 100% rename from commands/bmake/cond.c rename to commands/make/cond.c diff --git a/commands/bmake/config.h b/commands/make/config.h similarity index 100% rename from commands/bmake/config.h rename to commands/make/config.h diff --git a/commands/bmake/dir.c b/commands/make/dir.c similarity index 100% rename from commands/bmake/dir.c rename to commands/make/dir.c diff --git a/commands/bmake/dir.h b/commands/make/dir.h similarity index 100% rename from commands/bmake/dir.h rename to commands/make/dir.h diff --git a/commands/bmake/for.c b/commands/make/for.c similarity index 100% rename from commands/bmake/for.c rename to commands/make/for.c diff --git a/commands/make/h.h b/commands/make/h.h deleted file mode 100644 index ed1072ca0..000000000 --- a/commands/make/h.h +++ /dev/null @@ -1,320 +0,0 @@ -/************************************************************************* - * - * m a k e : h . h - * - * include file for make - *======================================================================== - * Edition history - * - * # Date Comments By - * --- -------- ---------------------------------------------------- --- - * 1 ?? ?? - * 2 23.08.89 LZ increased,N_EXISTS added,suffix as macro added RAL - * 3 30.08.89 macro flags added, indention changed PSH,RAL - * 4 03.09.89 fixed LZ eliminated, struct str added,... RAL - * 5 06.09.89 TABCHAR,M_MAKE added RAL - * 6 09.09.89 tos support added, EXTERN,INIT,PARMS added PHH,RAL - * 7 17.09.89 __STDC__ added, make1 decl. fixed , N_EXEC added RAL - * ------------ Version 2.0 released ------------------------------- RAL - * - *************************************************************************/ - -#ifdef unix -#include -#include -#include -#include -#include -#include -#include -#include -#include -#endif - -#ifdef eon -#include -#include -#endif - -#ifdef os9 -#include -#include -#include -#include -#include -#endif - -#ifdef tos -struct DOSTIME {short time,date; }; /* time structure of TOS */ - -#ifdef LATTICE -#include -#include -#include -#include -#endif /* LATTICE */ - -#ifdef TURBO -#include -#include -#include -#endif /* TURBO */ - -#endif /* tos */ - -#include -#include -#include - -#ifdef eon -#define MNOENT ER_NOTF -#else -#define MNOENT ENOENT -#endif - -#ifndef uchar -#ifdef os9 -#define uchar char -#define void int -#define fputc putc -#else -#define uchar unsigned char -#endif -#endif - -#define bool uchar -#ifndef time_t -#define time_t long -#endif -#define TRUE (1) -#define FALSE (0) -#define max(a,b) ((a)>(b)?(a):(b)) - -#ifdef unix -#define DEFN1 "makefile" -#define DEFN2 "Makefile" -#endif -#ifdef eon -#define DEFN1 "makefile" -#define DEFN2 "Makefile" -#endif -#ifdef tos -#define DEFN1 "makefile." -#define DEFN2 (char *)0 -#endif -#ifdef os9 -#define DEFN1 "makefile" -#define DEFN2 (char *)0 -#endif - - -#ifdef os9 -#define TABCHAR ' ' -#else -#define TABCHAR '\t' -#endif - -#define LZ1 (2048) /* Initial input/expand string size */ -#define LZ2 (256) /* Initial input/expand string size */ - - - -/* - * A name. This represents a file, either to be made, or existant - */ - -struct name -{ - struct name *n_next; /* Next in the list of names */ - char *n_name; /* Called */ - struct line *n_line; /* Dependencies */ - time_t n_time; /* Modify time of this name */ - uchar n_flag; /* Info about the name */ -}; - -#define N_MARK 0x01 /* For cycle check */ -#define N_DONE 0x02 /* Name looked at */ -#define N_TARG 0x04 /* Name is a target */ -#define N_PREC 0x08 /* Target is precious */ -#define N_DOUBLE 0x10 /* Double colon target */ -#define N_EXISTS 0x20 /* File exists */ -#define N_ERROR 0x40 /* Error occured */ -#define N_EXEC 0x80 /* Commands executed */ - -/* - * Definition of a target line. - */ -struct line -{ - struct line *l_next; /* Next line (for ::) */ - struct depend *l_dep; /* Dependents for this line */ - struct cmd *l_cmd; /* Commands for this line */ -}; - - -/* - * List of dependents for a line - */ -struct depend -{ - struct depend *d_next; /* Next dependent */ - struct name *d_name; /* Name of dependent */ -}; - - -/* - * Commands for a line - */ -struct cmd -{ - struct cmd *c_next; /* Next command line */ - char *c_cmd; /* Command line */ -}; - - -/* - * Macro storage - */ -struct macro -{ - struct macro *m_next; /* Next variable */ - char *m_name; /* Called ... */ - char *m_val; /* Its value */ - uchar m_flag; /* Infinite loop check */ -}; - - -#define M_MARK 0x01 /* for infinite loop check */ -#define M_OVERRIDE 0x02 /* command-line override */ -#define M_MAKE 0x04 /* for MAKE macro */ - -/* - * String - */ -struct str -{ - char **ptr; /* ptr to real ptr. to string */ - int len; /* length of string */ - int pos; /* position */ -}; - - -/* Declaration, definition & initialization of variables */ - -#ifndef EXTERN -#define EXTERN extern -#endif - -#ifndef INIT -#define INIT(x) -#endif - -extern int errno; -extern char **environ; - -EXTERN char *myname; -EXTERN bool domake INIT(TRUE); /* Go through the motions option */ -EXTERN bool ignore INIT(FALSE); /* Ignore exit status option */ -EXTERN bool conterr INIT(FALSE); /* continue on errors */ -EXTERN bool silent INIT(FALSE); /* Silent option */ -EXTERN bool print INIT(FALSE); /* Print debuging information */ -EXTERN bool rules INIT(TRUE); /* Use inbuilt rules */ -EXTERN bool dotouch INIT(FALSE); /* Touch files instead of making */ -EXTERN bool quest INIT(FALSE); /* Question up-to-dateness of file */ -EXTERN bool useenv INIT(FALSE); /* Env. macro def. overwrite makefile def.*/ -EXTERN bool dbginfo INIT(FALSE); /* Print lot of debugging information */ -EXTERN bool ambigmac INIT(TRUE); /* guess undef. ambiguous macros (*,<) */ -EXTERN struct name *firstname; -EXTERN char *str1; -EXTERN char *str2; -EXTERN struct str str1s; -EXTERN struct str str2s; -EXTERN struct name **suffparray; /* ptr. to array of ptrs. to name chains */ -EXTERN int sizesuffarray INIT(20); /* size of suffarray */ -EXTERN int maxsuffarray INIT(0); /* last used entry in suffarray */ -EXTERN struct macro *macrohead; -EXTERN bool expmake; /* TRUE if $(MAKE) has been expanded */ -EXTERN char *makefile; /* The make file */ -EXTERN int lineno; - -#ifdef tos -#ifdef LATTICE -EXTERN int _mneed INIT(60000); /* VERY important for TOS with LATTICE C*/ -#endif /* LATTICE */ -#endif /* tos */ -#ifdef eon -#define MEMSPACE (16384) -EXTERN unsigned memspace = MEMSPACE; -#endif - -#define suffix(name) strrchr(name,(int)'.') - -EXTERN int _ctypech; -#define mylower(x) (islower(_ctypech=(x)) ? _ctypech :tolower(_ctypech)) -#define myupper(x) (isupper(_ctypech=(x)) ? _ctypech :toupper(_ctypech)) - -/* Prototypes. */ -struct sgtbuf; - -/* check.c */ -_PROTOTYPE(void prt, (void)); -_PROTOTYPE(void check, (struct name *np )); -_PROTOTYPE(void circh, (void)); -_PROTOTYPE(void precious, (void)); - -/* input.c */ -_PROTOTYPE(void init, (void)); -_PROTOTYPE(void strrealloc, (struct str *strs )); -_PROTOTYPE(struct name *newname, (char *name )); -_PROTOTYPE(struct name *testname, (char *name )); -_PROTOTYPE(struct depend *newdep, (struct name *np, struct depend *dp )); -_PROTOTYPE(struct cmd *newcmd, (char *str, struct cmd *cp )); -_PROTOTYPE(void newline, (struct name *np, struct depend *dp, struct cmd *cp, - int flag )); -_PROTOTYPE(void input, (FILE *fd )); - -/* macro.c */ -_PROTOTYPE(struct macro *getmp, (char *name )); -_PROTOTYPE(char *getmacro, (char *name )); -_PROTOTYPE(struct macro *setmacro, (char *name, char *val )); -_PROTOTYPE(struct macro *addmacro, (char *name, char *val )); -_PROTOTYPE(void setDFmacro, (char *name, char *val )); -_PROTOTYPE(void doexp, (struct str *to, char *from )); -_PROTOTYPE(void expand, (struct str *strs )); - -/* main.c */ -_PROTOTYPE(void main, (int argc, char **argv )); -_PROTOTYPE(void setoption, (char option )); -_PROTOTYPE(void usage, (void)); -_PROTOTYPE(void fatal, (char *msg, char *a1, int a2 )); - -/* make.c */ -_PROTOTYPE(int dosh, (char *string, char *shell )); -_PROTOTYPE(int makeold, (char *name )); -_PROTOTYPE(void docmds1, (struct name *np, struct line *lp )); -_PROTOTYPE(void docmds, (struct name *np )); -_PROTOTYPE(int Tosexec, (char *string )); -_PROTOTYPE(time_t mstonix, (unsigned int date, unsigned int time )); -_PROTOTYPE(void getmdate, (int fd, struct sgtbuf *tbp )); -_PROTOTYPE(time_t cnvtime, (struct sgtbuf *tbp )); -_PROTOTYPE(void modtime, (struct name *np )); -_PROTOTYPE(void touch, (struct name *np )); -_PROTOTYPE(int make, (struct name *np, int level )); -_PROTOTYPE(void make1, (struct name *np, struct line *lp, struct depend *qdp, - char *basename, char *inputname )); -_PROTOTYPE(void implmacros, (struct name *np, struct line *lp, - char **pbasename, char **pinputname )); -_PROTOTYPE(void dbgprint, (int level, struct name *np, char *comment )); - -/* reader.c */ -_PROTOTYPE(void error, (char *msg, char *a1 )); -_PROTOTYPE(bool getline, (struct str *strs, FILE *fd )); -_PROTOTYPE(char *gettok, (char **ptr )); - -/* rules.c */ -_PROTOTYPE(bool dyndep, (struct name *np, char **pbasename,char **pinputname)); -_PROTOTYPE(void makerules, (void)); - -/* archive.c */ -_PROTOTYPE(int is_archive_ref, (char *name)); -_PROTOTYPE(int archive_stat, (char *name, struct stat *stp)); diff --git a/commands/bmake/hash.c b/commands/make/hash.c similarity index 100% rename from commands/bmake/hash.c rename to commands/make/hash.c diff --git a/commands/bmake/hash.h b/commands/make/hash.h similarity index 100% rename from commands/bmake/hash.h rename to commands/make/hash.h diff --git a/commands/make/input.c b/commands/make/input.c deleted file mode 100644 index e167cc061..000000000 --- a/commands/make/input.c +++ /dev/null @@ -1,469 +0,0 @@ -/************************************************************************* - * - * m a k e : i n p u t . c - * - * Parse a makefile - *======================================================================== - * Edition history - * - * # Date Comments By - * --- -------- ---------------------------------------------------- --- - * 1 ?? ?? - * 2 23.08.89 new name tree structure introduced to speed up make, - * testname introduced to shrink the memory usage RAL - * 3 30.08.89 indention changed PSH,RAL - * 4 03.09.89 fixed LZ eliminated RAL - * 5 06.09.89 ; command added RAL - * ------------ Version 2.0 released ------------------------------- RAL - * - *************************************************************************/ - - -#include "h.h" - - -static struct name *lastrrp; -static struct name *freerp = (struct name *)NULL; - -void init() -{ - if( (suffparray = (struct name **) malloc( sizesuffarray * - sizeof(struct name *))) == (struct name **) NULL) - fatal("No memory for suffarray",(char *)0,0); - if ((*suffparray = (struct name *)malloc(sizeof (struct name))) - == (struct name *)0) - fatal("No memory for name",(char *)0,0); - (*suffparray)->n_next = (struct name *)0; - - if ((str1 = (char *) malloc(LZ1)) == ((char *)0)) - fatal("No memory for str1",(char *)0,0); - str1s.ptr = &str1; - str1s.len = LZ1; - if ((str2 = (char *) malloc(LZ2)) == (char *)0) - fatal("No memory for str2",(char *)0,0); - str2s.ptr = &str2; - str2s.len = LZ2; -} - -void strrealloc(strs) -struct str *strs; -{ - strs->len *= 2; - *strs->ptr = (char *) realloc(*strs->ptr, strs->len + 16); - if(*strs->ptr == (char *) NULL) - fatal("No memory for string reallocation",(char *)0,0); -} - -/* - * Intern a name. Return a pointer to the name struct - */ -struct name *newname(name) -char *name; -{ - register struct name *rp; - register struct name *rrp; - register char *cp; - - register int i; - register char *suff; /* ptr. to suffix in current name */ - register struct name **sp; /* ptr. to ptr. to chain of names */ - - if ( (suff = suffix(name)) != (char *)NULL) { - for (i = 1, sp = suffparray, sp++; - i <= maxsuffarray && strcmp(suff, (*sp)->n_name) != 0; - sp++,i++); - if (i > maxsuffarray) { - if ( i >= sizesuffarray) { /* must realloc suffarray */ - sizesuffarray *= 2; - if( (suffparray = (struct name **) realloc((char *) suffparray, - sizesuffarray * sizeof(struct name *))) == (struct name **) NULL) - fatal("No memory for suffarray",(char *)0,0); - } - maxsuffarray++; - sp = &suffparray[i]; - if ((*sp = (struct name *)malloc(sizeof (struct name))) - == (struct name *)0) - fatal("No memory for name",(char *)0,0); - (*sp)->n_next = (struct name *)0; - if ((cp = (char *) malloc(strlen(suff)+1)) == (char *)0) - fatal("No memory for name",(char *)0,0); - strcpy(cp, suff); - (*sp)->n_name = cp; - } - } - else - sp = suffparray; - - for ( rp = (*sp)->n_next, rrp = *sp; rp; rp = rp->n_next, rrp = rrp->n_next ) - if (strcmp(name, rp->n_name) == 0) return rp; - - if ( freerp == (struct name *)NULL) { - if ((rp = (struct name *)malloc(sizeof (struct name))) == (struct name *)0) - fatal("No memory for name",(char *)0,0); - } - else { - rp = freerp; - freerp = (struct name *)NULL; - } - rrp->n_next = rp; - rp->n_next = (struct name *)0; - if ((cp = (char *) malloc(strlen(name)+1)) == (char *)0) - fatal("No memory for name",(char *)0,0); - strcpy(cp, name); - rp->n_name = cp; - rp->n_line = (struct line *)0; - rp->n_time = (time_t)0; - rp->n_flag = 0; - lastrrp = rrp; - - return rp; -} - -/* - * Test a name. - * If the name already exists return the ptr. to its name structure. - * Else if the file exists 'intern' the name and return the ptr. - * Otherwise don't waste memory and return a NULL pointer - */ -struct name *testname(name) -char *name; -{ - register struct name *rp; - - lastrrp = (struct name *)NULL; - rp = newname( name); - if (rp->n_line || rp->n_flag & N_EXISTS) - return(rp); - modtime(rp); - if (rp->n_flag & N_EXISTS) - return(rp); - if (lastrrp != (struct name *)NULL) { - free (rp->n_name); - lastrrp->n_next = (struct name *)NULL; - freerp = rp; - } - return((struct name *)NULL); -} - - - -/* - * Add a dependant to the end of the supplied list of dependants. - * Return the new head pointer for that list. - */ -struct depend *newdep(np, dp) -struct name *np; -struct depend *dp; -{ - register struct depend *rp; - register struct depend *rrp; - - - if ((rp = (struct depend *)malloc(sizeof (struct depend))) - == (struct depend *)0) - fatal("No memory for dependant",(char *)0,0); - rp->d_next = (struct depend *)0; - rp->d_name = np; - - if (dp == (struct depend *)0) return rp; - - for (rrp = dp; rrp->d_next; rrp = rrp->d_next) ; - - rrp->d_next = rp; - - return dp; -} - - -/* - * Add a command to the end of the supplied list of commands. - * Return the new head pointer for that list. - */ -struct cmd *newcmd(str, cp) -char *str; -struct cmd *cp; -{ - register struct cmd *rp; - register struct cmd *rrp; - register char *rcp; - - - if (rcp = strrchr(str, '\n')) *rcp = '\0'; /* Loose newline */ - - while (isspace(*str)) str++; - - if (*str == '\0') return cp; /* If nothing left, the exit */ - - if ((rp = (struct cmd *)malloc(sizeof (struct cmd))) == (struct cmd *)0) - fatal("No memory for command",(char *)0,0); - rp->c_next = (struct cmd *)0; - if ((rcp = (char *) malloc(strlen(str)+1)) == (char *)0) - fatal("No memory for command",(char *)0,0); - strcpy(rcp, str); - rp->c_cmd = rcp; - - if (cp == (struct cmd *)0) return rp; - - for (rrp = cp; rrp->c_next; rrp = rrp->c_next) ; - - rrp->c_next = rp; - - return cp; -} - - -/* - * Add a new 'line' of stuff to a target. This check to see - * if commands already exist for the target. If flag is set, - * the line is a double colon target. - * - * Kludges: - * i) If the new name begins with a '.', and there are no dependents, - * then the target must cease to be a target. This is for .SUFFIXES. - * ii) If the new name begins with a '.', with no dependents and has - * commands, then replace the current commands. This is for - * redefining commands for a default rule. - * Neither of these free the space used by dependents or commands, - * since they could be used by another target. - */ - -void newline(np, dp, cp, flag) -struct name *np; -struct depend *dp; -struct cmd *cp; -int flag; -{ - bool hascmds = FALSE; /* Target has commands */ - register struct line *rp; - register struct line *rrp; - - - /* Handle the .SUFFIXES case */ - if (np->n_name[0] == '.' && !dp && !cp) { - for (rp = np->n_line; rp; rp = rrp) { - rrp = rp->l_next; - free(rp); - } - np->n_line = (struct line *)0; - np->n_flag &= ~N_TARG; - return; - } - - /* This loop must happen since rrp is used later. */ - for ( rp = np->n_line, rrp = (struct line *)0; rp; rrp = rp, rp = rp->l_next) - if (rp->l_cmd) hascmds = TRUE; - - if (hascmds && cp && !(np->n_flag & N_DOUBLE)) - /* Handle the implicit rules redefinition case */ - if (np->n_name[0] == '.' && dp == (struct depend *)0) { - np->n_line->l_cmd = cp; - return; - } - else - error("Commands defined twice for target %s", np->n_name); - if (np->n_flag & N_TARG) - if (!(np->n_flag & N_DOUBLE) != !flag) /* like xor */ - error("Inconsistent rules for target %s", np->n_name); - - if ((rp = (struct line *)malloc(sizeof (struct line))) == (struct line *)0) - fatal("No memory for line",(char *)0,0); - rp->l_next = (struct line *)0; - rp->l_dep = dp; - rp->l_cmd = cp; - - if (rrp) - rrp->l_next = rp; - else - np->n_line = rp; - - np->n_flag |= N_TARG; - if (flag) np->n_flag |= N_DOUBLE; -} - - -/* - * Parse input from the makefile, and construct a tree structure - * of it. - */ -void input(fd) -FILE *fd; -{ - char *p; /* General */ - char *q; - register char *a; - struct name *np; - struct depend *dp; - struct cmd *cp; - bool dbl; - - - if (getline(&str1s, fd)) return; /* Read the first line */ - - for(;;) { - if (*str1 == TABCHAR) /* Rules without targets */ - error("Rules not allowed here",(char *)0); - - p = str1; - - while (isspace(*p)) p++; /* Find first target */ - - - while (((q = strchr(p, '+')) != (char *)0) && - (q[1] == '=') && (p != q) && (q[-1] == '\\')) /* Find value */ - { - a = q - 1; /* Del \ chr; move rest back */ - p = q; - while(*a++ = *q++) - ; - } - - if (q != (char *)0 && q[1] == '=') { - - *q++ = '\0'; /* Separate name and val */ - *q++ = '\0'; /* Separate name and val */ - while (isspace(*q)) - q++; - if (p = strrchr(q, '\n')) - *p = '\0'; - - p = str1; - if ((a = gettok(&p)) == (char *)0) - error("No macro name",(char *)0); - - addmacro(a, q); - - if (getline(&str1s, fd)) - return; - continue; - } - - - while (((q = strchr(p, '=')) != (char *)0) && - (p != q) && (q[-1] == '\\')) /* Find value */ - { - a = q - 1; /* Del \ chr; move rest back */ - p = q; - while(*a++ = *q++) - ; - } - - if (q != (char *)0) { - - *q++ = '\0'; /* Separate name and val */ - while (isspace(*q)) - q++; - if (p = strrchr(q, '\n')) - *p = '\0'; - - p = str1; - if ((a = gettok(&p)) == (char *)0) - error("No macro name",(char *)0); - - setmacro(a, q); - - if (getline(&str1s, fd)) - return; - continue; - } - - /* include? */ - p = str1; - while (isspace(*p)) p++; - if (strncmp(p, "include", 7) == 0 && isspace(p[7])) { - char *old_makefile = makefile; - int old_lineno = lineno; - FILE *ifd; - - p += 8; - memmove(str1, p, strlen(p)+1); - expand(&str1s); - p = str1; - while (isspace(*p)) p++; - - if ((q = malloc(strlen(p)+1)) == (char *)0) - fatal("No memory for include",(char *)0,0); - - strcpy(q, p); - p = q; - while ((makefile = gettok(&q)) != (char *)0) { - if ((ifd = fopen(makefile, "r")) == (FILE *)0) - fatal("Can't open %s: %s", makefile, errno); - lineno = 0; - input(ifd); - fclose(ifd); - } - free(p); - makefile = old_makefile; - lineno = old_lineno; - - if (getline(&str1s, fd)) - return; - continue; - } - - /* Search for commands on target line --- do not expand them ! */ - q = str1; - cp = (struct cmd *)0; - if ((a = strchr(q, ';')) != (char *)0) { - *a++ = '\0'; /* Separate dependents and commands */ - if ( a) cp = newcmd(a, cp); - } - - expand(&str1s); - p = str1; - - while (isspace(*p)) p++; - - while (((q = strchr(p, ':')) != (char *)0) && - (p != q) && (q[-1] == '\\')) /* Find dependents */ - { - a = q - 1; /* Del \ chr; move rest back */ - p = q; - while(*a++ = *q++) ; - } - - if (q == (char *)0) - error("No targets provided",(char *)0); - - *q++ = '\0'; /* Separate targets and dependents */ - - if (*q == ':') { /* Double colon */ - dbl = 1; - q++; - } - else - dbl = 0; - - for (dp = (struct depend *)0; ((p = gettok(&q)) != (char *)0);) - /* get list of dep's */ - { - np = newname(p); /* Intern name */ - dp = newdep(np, dp); /* Add to dep list */ - } - - *((q = str1) + strlen(str1) + 1) = '\0'; - /* Need two nulls for gettok (Remember separation) */ - - if (getline(&str2s, fd) == FALSE) { /* Get commands */ - while (*str2 == TABCHAR) { - cp = newcmd(&str2[0], cp); - if (getline(&str2s, fd)) - break; - } - } - - while ((p = gettok(&q)) != (char *)0) /* Get list of targ's */ - { - np = newname(p); /* Intern name */ - newline(np, dp, cp, dbl); - if (!firstname && p[0] != '.') - firstname = np; - } - - if (feof(fd)) /* EOF? */ - return; - - while (strlen(str2) >= str1s.len) strrealloc(&str1s); - strcpy(str1, str2); - } -} diff --git a/commands/bmake/job.c b/commands/make/job.c similarity index 100% rename from commands/bmake/job.c rename to commands/make/job.c diff --git a/commands/bmake/job.h b/commands/make/job.h similarity index 100% rename from commands/bmake/job.h rename to commands/make/job.h diff --git a/commands/bmake/lst.h b/commands/make/lst.h similarity index 100% rename from commands/bmake/lst.h rename to commands/make/lst.h diff --git a/commands/bmake/lst.lib/Makefile b/commands/make/lst.lib/Makefile similarity index 100% rename from commands/bmake/lst.lib/Makefile rename to commands/make/lst.lib/Makefile diff --git a/commands/bmake/lst.lib/lstAppend.c b/commands/make/lst.lib/lstAppend.c similarity index 100% rename from commands/bmake/lst.lib/lstAppend.c rename to commands/make/lst.lib/lstAppend.c diff --git a/commands/bmake/lst.lib/lstAtEnd.c b/commands/make/lst.lib/lstAtEnd.c similarity index 100% rename from commands/bmake/lst.lib/lstAtEnd.c rename to commands/make/lst.lib/lstAtEnd.c diff --git a/commands/bmake/lst.lib/lstAtFront.c b/commands/make/lst.lib/lstAtFront.c similarity index 100% rename from commands/bmake/lst.lib/lstAtFront.c rename to commands/make/lst.lib/lstAtFront.c diff --git a/commands/bmake/lst.lib/lstClose.c b/commands/make/lst.lib/lstClose.c similarity index 100% rename from commands/bmake/lst.lib/lstClose.c rename to commands/make/lst.lib/lstClose.c diff --git a/commands/bmake/lst.lib/lstConcat.c b/commands/make/lst.lib/lstConcat.c similarity index 100% rename from commands/bmake/lst.lib/lstConcat.c rename to commands/make/lst.lib/lstConcat.c diff --git a/commands/bmake/lst.lib/lstDatum.c b/commands/make/lst.lib/lstDatum.c similarity index 100% rename from commands/bmake/lst.lib/lstDatum.c rename to commands/make/lst.lib/lstDatum.c diff --git a/commands/bmake/lst.lib/lstDeQueue.c b/commands/make/lst.lib/lstDeQueue.c similarity index 100% rename from commands/bmake/lst.lib/lstDeQueue.c rename to commands/make/lst.lib/lstDeQueue.c diff --git a/commands/bmake/lst.lib/lstDestroy.c b/commands/make/lst.lib/lstDestroy.c similarity index 100% rename from commands/bmake/lst.lib/lstDestroy.c rename to commands/make/lst.lib/lstDestroy.c diff --git a/commands/bmake/lst.lib/lstDupl.c b/commands/make/lst.lib/lstDupl.c similarity index 100% rename from commands/bmake/lst.lib/lstDupl.c rename to commands/make/lst.lib/lstDupl.c diff --git a/commands/bmake/lst.lib/lstEnQueue.c b/commands/make/lst.lib/lstEnQueue.c similarity index 100% rename from commands/bmake/lst.lib/lstEnQueue.c rename to commands/make/lst.lib/lstEnQueue.c diff --git a/commands/bmake/lst.lib/lstFind.c b/commands/make/lst.lib/lstFind.c similarity index 100% rename from commands/bmake/lst.lib/lstFind.c rename to commands/make/lst.lib/lstFind.c diff --git a/commands/bmake/lst.lib/lstFindFrom.c b/commands/make/lst.lib/lstFindFrom.c similarity index 100% rename from commands/bmake/lst.lib/lstFindFrom.c rename to commands/make/lst.lib/lstFindFrom.c diff --git a/commands/bmake/lst.lib/lstFirst.c b/commands/make/lst.lib/lstFirst.c similarity index 100% rename from commands/bmake/lst.lib/lstFirst.c rename to commands/make/lst.lib/lstFirst.c diff --git a/commands/bmake/lst.lib/lstForEach.c b/commands/make/lst.lib/lstForEach.c similarity index 100% rename from commands/bmake/lst.lib/lstForEach.c rename to commands/make/lst.lib/lstForEach.c diff --git a/commands/bmake/lst.lib/lstForEachFrom.c b/commands/make/lst.lib/lstForEachFrom.c similarity index 100% rename from commands/bmake/lst.lib/lstForEachFrom.c rename to commands/make/lst.lib/lstForEachFrom.c diff --git a/commands/bmake/lst.lib/lstInit.c b/commands/make/lst.lib/lstInit.c similarity index 100% rename from commands/bmake/lst.lib/lstInit.c rename to commands/make/lst.lib/lstInit.c diff --git a/commands/bmake/lst.lib/lstInsert.c b/commands/make/lst.lib/lstInsert.c similarity index 100% rename from commands/bmake/lst.lib/lstInsert.c rename to commands/make/lst.lib/lstInsert.c diff --git a/commands/bmake/lst.lib/lstInt.h b/commands/make/lst.lib/lstInt.h similarity index 100% rename from commands/bmake/lst.lib/lstInt.h rename to commands/make/lst.lib/lstInt.h diff --git a/commands/bmake/lst.lib/lstIsAtEnd.c b/commands/make/lst.lib/lstIsAtEnd.c similarity index 100% rename from commands/bmake/lst.lib/lstIsAtEnd.c rename to commands/make/lst.lib/lstIsAtEnd.c diff --git a/commands/bmake/lst.lib/lstIsEmpty.c b/commands/make/lst.lib/lstIsEmpty.c similarity index 100% rename from commands/bmake/lst.lib/lstIsEmpty.c rename to commands/make/lst.lib/lstIsEmpty.c diff --git a/commands/bmake/lst.lib/lstLast.c b/commands/make/lst.lib/lstLast.c similarity index 100% rename from commands/bmake/lst.lib/lstLast.c rename to commands/make/lst.lib/lstLast.c diff --git a/commands/bmake/lst.lib/lstMember.c b/commands/make/lst.lib/lstMember.c similarity index 100% rename from commands/bmake/lst.lib/lstMember.c rename to commands/make/lst.lib/lstMember.c diff --git a/commands/bmake/lst.lib/lstNext.c b/commands/make/lst.lib/lstNext.c similarity index 100% rename from commands/bmake/lst.lib/lstNext.c rename to commands/make/lst.lib/lstNext.c diff --git a/commands/bmake/lst.lib/lstOpen.c b/commands/make/lst.lib/lstOpen.c similarity index 100% rename from commands/bmake/lst.lib/lstOpen.c rename to commands/make/lst.lib/lstOpen.c diff --git a/commands/bmake/lst.lib/lstPrev.c b/commands/make/lst.lib/lstPrev.c similarity index 100% rename from commands/bmake/lst.lib/lstPrev.c rename to commands/make/lst.lib/lstPrev.c diff --git a/commands/bmake/lst.lib/lstRemove.c b/commands/make/lst.lib/lstRemove.c similarity index 100% rename from commands/bmake/lst.lib/lstRemove.c rename to commands/make/lst.lib/lstRemove.c diff --git a/commands/bmake/lst.lib/lstReplace.c b/commands/make/lst.lib/lstReplace.c similarity index 100% rename from commands/bmake/lst.lib/lstReplace.c rename to commands/make/lst.lib/lstReplace.c diff --git a/commands/bmake/lst.lib/lstSucc.c b/commands/make/lst.lib/lstSucc.c similarity index 100% rename from commands/bmake/lst.lib/lstSucc.c rename to commands/make/lst.lib/lstSucc.c diff --git a/commands/make/macro.c b/commands/make/macro.c deleted file mode 100644 index 5c7737d8b..000000000 --- a/commands/make/macro.c +++ /dev/null @@ -1,232 +0,0 @@ -/************************************************************************* - * - * m a k e : m a c r o . c - * - * Macro control for make - *======================================================================== - * Edition history - * - * # Date Comments By - * --- -------- ---------------------------------------------------- --- - * 1 ?? ?? - * 2 23.08.89 Error message corrected RAL - * 3 30.08.89 macro flags added, indention ch. PSH,RAL - * 4 03.09.89 fixed LZ eliminated, doexp(...) changed RAL - * 5 06.09.89 M_MAKE added, setDFmacro added RAL - * 6 20.09.89 work around for Minix PC ACK bug BE,RAL - * ------------ Version 2.0 released ------------------------------- RAL - * - *************************************************************************/ - -#include "h.h" - - -static char buf[256]; - -struct macro *getmp(name) -char *name; -{ - register struct macro *rp; - - for (rp = macrohead; rp; rp = rp->m_next) - if (strcmp(name, rp->m_name) == 0) - return rp; - return (struct macro *)0; -} - - -char *getmacro(name) -char *name; -{ - struct macro *mp; - - if (mp = getmp(name)) - return mp->m_val; -/* else*/ - return ""; -} - - -struct macro *addmacro(name, val) -char *name; -char *val; -{ - register struct macro *rp; - register char *cp; - int len_old_value; - - - /* Replace macro definition if it exists */ - for (rp = macrohead; rp; rp = rp->m_next) - if (strcmp(name, rp->m_name) == 0) { - if(rp->m_flag & M_OVERRIDE) return rp; /* mustn't change */ - break; - } - - if (!rp) /* If not defined, allocate space for new */ - { - fatal("Cannot add to a non-existing macro",(char *)0,0); - } - - len_old_value = strlen(rp->m_val); - if ((cp = (char *) malloc(len_old_value+1+strlen(val)+1)) == (char *)0) - fatal("No memory for macro",(char *)0,0); - strcpy(cp, rp->m_val); /* Copy in old value */ - cp[len_old_value] = ' '; - strcpy(cp+len_old_value+1, val); /* Copy in new value */ - free(rp->m_val); - rp->m_val = cp; - - return rp; -} - - - -struct macro *setmacro(name, val) -char *name; -char *val; -{ - register struct macro *rp; - register char *cp; - - - /* Replace macro definition if it exists */ - for (rp = macrohead; rp; rp = rp->m_next) - if (strcmp(name, rp->m_name) == 0) { - if(rp->m_flag & M_OVERRIDE) return rp; /* mustn't change */ - free(rp->m_val); /* Free space from old */ - break; - } - - if (!rp) /* If not defined, allocate space for new */ - { - if ((rp = (struct macro *)malloc(sizeof (struct macro))) - == (struct macro *)0) - fatal("No memory for macro",(char *)0,0); - - rp->m_next = macrohead; - macrohead = rp; - rp->m_flag = FALSE; - - if ((cp = (char *) malloc(strlen(name)+1)) == (char *)0) - fatal("No memory for macro",(char *)0,0); - strcpy(cp, name); - rp->m_name = cp; - } - - if ((cp = (char *) malloc(strlen(val)+1)) == (char *)0) - fatal("No memory for macro",(char *)0,0); - strcpy(cp, val); /* Copy in new value */ - rp->m_val = cp; - - return rp; -} - - -void setDFmacro(name, val) -char *name; -char *val; -{ - char *c,*tmp; - int len; - static char filename[]="@F"; - static char dirname[] ="@D"; - - setmacro(name,val); - *filename = *name; - *dirname = *name; - /* Null string -- not defined macro */ - if ( !(*val)) { - setmacro(filename,""); - setmacro(dirname,""); - return; - } - if (!(c = strrchr(val,(int)'/'))) { - setmacro(filename,val); - setmacro(dirname,"./"); - return; - } - setmacro(filename,c+1); - len = c - val + 1; - if((tmp = (char *) malloc(len + 1)) == (char *) 0) - fatal("No memory for tmp",(char *)0,0); - strncpy(tmp,val,len); - tmp[len] = '\0'; - setmacro(dirname,tmp); - free(tmp); - return; -} - -/* - * Do the dirty work for expand - */ -void doexp(to, from) -struct str *to; -char *from; -{ - register char *rp; - register char *p; - char *q; - struct macro *mp; - - - rp = from; - p = &(*to->ptr)[to->pos]; - while (*rp) { - if (*rp != '$') { - *p++ = *rp++; - to->pos++; - } - else { - q = buf; - if (*++rp == '{') - while (*++rp && *rp != '}') - *q++ = *rp; - else if (*rp == '(') - while (*++rp && *rp != ')') - *q++ = *rp; - else if (!*rp) { - *p++ = '$'; - to->pos++; - goto bail; - } - else - *q++ = *rp; - *q = '\0'; - if (*rp) - rp++; - if (!(mp = getmp(buf))) - mp = setmacro(buf, ""); - if (mp->m_flag & M_MARK) - fatal("Infinitely recursive macro %s", mp->m_name,0); - mp->m_flag |= M_MARK; - if ( mp->m_flag & M_MAKE) expmake = TRUE; - doexp(to, mp->m_val); - p = &(*to->ptr)[to->pos]; - mp->m_flag &= ~M_MARK; - } - bail: - if (to->pos >= to->len) { - strrealloc(to); - p = &(*to->ptr)[to->pos]; - } - } - *p = '\0'; -} - - -/* - * Expand any macros in str. - */ -void expand(strs) -struct str *strs; -{ - char *a; - - if ((a = (char *) malloc(strlen(*strs->ptr)+1)) == (char *)0) - fatal("No memory for temporary string",(char *)0,0); - strcpy(a, *strs->ptr); - strs->pos = 0; - doexp(strs, a); - free(a); -} diff --git a/commands/make/main.c b/commands/make/main.c index 5cde36f71..54f4e6744 100644 --- a/commands/make/main.c +++ b/commands/make/main.c @@ -1,288 +1,1859 @@ -/************************************************************************* - * - * m a k e : m a i n . c - * - *======================================================================== - * Edition history - * - * # Date Comments By - * --- -------- ---------------------------------------------------- --- - * 1 ?? ?? - * 2 01.07.89 strcmp(makefile,..) only if makefile a valid ptr. RAL - * 3 23.08.89 initname() added RAL - * 4 30.08.89 argument parsing impr., indention ch., macro fl. add.PSH,RAL - * 5 03.09.89 k-option added, initname -> init changed RAL - * 6 06.09.89 environment, MAKEFLAGS, e,d,a options added, RAL - * 7 09.09.89 tos support added, fatal args added, fopen makefile PHH,RAL - * 8 17.09.89 setoptions fixed for __STDC__ RAL - * ------------ Version 2.0 released ------------------------------- RAL - * - *************************************************************************/ +/* $NetBSD: main.c,v 1.174 2009/09/09 17:09:49 sjg Exp $ */ /* - * make: + * Copyright (c) 1988, 1989, 1990, 1993 + * The Regents of the University of California. All rights reserved. * - * -a try to guess undefined ambiguous macros (*,<) - * -d print debugging info - * -e environment macro def. overwrite makefile def. - * -f makefile name - * -i ignore exit status - * -k continue on errors - * -n pretend to make - * -p print all macros & targets - * -q question up-to-dateness of target. Return exit status 1 if not - * -r don't not use inbuilt rules - * -s make silently - * -t touch files instead of making them - * -m Change memory requirements (EON only) + * This code is derived from software contributed to Berkeley by + * Adam de Boor. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. */ -#define EXTERN -#define INIT(x) = x -#define INITARRAY -#include "h.h" +/* + * Copyright (c) 1989 by Berkeley Softworks + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Adam de Boor. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ -static char version[]= "2.0"; +#ifndef MAKE_NATIVE +static char rcsid[] = "$NetBSD: main.c,v 1.174 2009/09/09 17:09:49 sjg Exp $"; +#else +#include +#ifndef lint +__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\ + The Regents of the University of California. All rights reserved."); +#endif /* not lint */ -static FILE *ifd; /* Input file desciptor */ -static char *ptrmakeflags; +#ifndef lint +#if 0 +static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94"; +#else +__RCSID("$NetBSD: main.c,v 1.174 2009/09/09 17:09:49 sjg Exp $"); +#endif +#endif /* not lint */ +#endif -/* There must be enough 'space' for all possible flags ! */ -static char makeflags[] = "MAKEFLAGS= "; +/*- + * main.c -- + * The main file for this entire program. Exit routines etc + * reside here. + * + * Utility functions defined in this file: + * Main_ParseArgLine Takes a line of arguments, breaks them and + * treats them as if they were given when first + * invoked. Used by the parse module to implement + * the .MFLAGS target. + * + * Error Print a tagged error message. The global + * MAKE variable must have been defined. This + * takes a format string and two optional + * arguments for it. + * + * Fatal Print an error message and exit. Also takes + * a format string and two arguments. + * + * Punt Aborts all jobs and exits with a message. Also + * takes a format string and two arguments. + * + * Finish Finish things up by printing the number of + * errors which occurred, as passed to it, and + * exiting. + */ -void main(argc, argv) -int argc; -char **argv; +#include +#include +#include +#include +#include +#include +#ifdef MAKE_NATIVE +#include +#endif +#include + +#include +#include +#include +#include +#include +#include + +#include "make.h" +#include "hash.h" +#include "dir.h" +#include "job.h" +#include "pathnames.h" +#include "trace.h" + +#ifdef USE_IOVEC +#include +#endif + +#ifndef DEFMAXLOCAL +#define DEFMAXLOCAL DEFMAXJOBS +#endif /* DEFMAXLOCAL */ + +Lst create; /* Targets to be made */ +time_t now; /* Time at start of make */ +GNode *DEFAULT; /* .DEFAULT node */ +Boolean allPrecious; /* .PRECIOUS given on line by itself */ + +static Boolean noBuiltins; /* -r flag */ +static Lst makefiles; /* ordered list of makefiles to read */ +static Boolean printVars; /* print value of one or more vars */ +static Lst variables; /* list of variables to print */ +int maxJobs; /* -j argument */ +static int maxJobTokens; /* -j argument */ +Boolean compatMake; /* -B argument */ +int debug; /* -d argument */ +Boolean noExecute; /* -n flag */ +Boolean noRecursiveExecute; /* -N flag */ +Boolean keepgoing; /* -k flag */ +Boolean queryFlag; /* -q flag */ +Boolean touchFlag; /* -t flag */ +Boolean ignoreErrors; /* -i flag */ +Boolean beSilent; /* -s flag */ +Boolean oldVars; /* variable substitution style */ +Boolean checkEnvFirst; /* -e flag */ +Boolean parseWarnFatal; /* -W flag */ +Boolean jobServer; /* -J flag */ +static int jp_0 = -1, jp_1 = -1; /* ends of parent job pipe */ +Boolean varNoExportEnv; /* -X flag */ +Boolean doing_depend; /* Set while reading .depend */ +static Boolean jobsRunning; /* TRUE if the jobs might be running */ +static const char * tracefile; +static char * Check_Cwd_av(int, char **, int); +static void MainParseArgs(int, char **); +static int ReadMakefile(const void *, const void *); +static void usage(void); + +static Boolean ignorePWD; /* if we use -C, PWD is meaningless */ +static char curdir[MAXPATHLEN + 1]; /* startup directory */ +static char objdir[MAXPATHLEN + 1]; /* where we chdir'ed to */ +char *progname; /* the program name */ + +Boolean forceJobs = FALSE; + +extern Lst parseIncPath; + +static void +parse_debug_options(const char *argvalue) { - register char *p; /* For argument processing */ - int estat = 0; /* For question */ - register struct name *np; - struct macro *mp; - int targc; /* temporary for multiple scans */ - char **targv; - char **nargv; /* for removing items from argv */ - char **envp; /* enivironment ptr */ + const char *modules; + const char *mode; + char *fname; + int len; + for (modules = argvalue; *modules; ++modules) { + switch (*modules) { + case 'A': + debug = ~0; + break; + case 'a': + debug |= DEBUG_ARCH; + break; + case 'C': + debug |= DEBUG_CWD; + break; + case 'c': + debug |= DEBUG_COND; + break; + case 'd': + debug |= DEBUG_DIR; + break; + case 'e': + debug |= DEBUG_ERROR; + break; + case 'f': + debug |= DEBUG_FOR; + break; + case 'g': + if (modules[1] == '1') { + debug |= DEBUG_GRAPH1; + ++modules; + } + else if (modules[1] == '2') { + debug |= DEBUG_GRAPH2; + ++modules; + } + else if (modules[1] == '3') { + debug |= DEBUG_GRAPH3; + ++modules; + } + break; + case 'j': + debug |= DEBUG_JOB; + break; + case 'l': + debug |= DEBUG_LOUD; + break; + case 'm': + debug |= DEBUG_MAKE; + break; + case 'n': + debug |= DEBUG_SCRIPT; + break; + case 'p': + debug |= DEBUG_PARSE; + break; + case 's': + debug |= DEBUG_SUFF; + break; + case 't': + debug |= DEBUG_TARG; + break; + case 'v': + debug |= DEBUG_VAR; + break; + case 'x': + debug |= DEBUG_SHELL; + break; + case 'F': + if (debug_file != stdout && debug_file != stderr) + fclose(debug_file); + if (*++modules == '+') + mode = "a"; + else + mode = "w"; + if (strcmp(modules, "stdout") == 0) { + debug_file = stdout; + goto debug_setbuf; + } + if (strcmp(modules, "stderr") == 0) { + debug_file = stderr; + goto debug_setbuf; + } + len = strlen(modules); + fname = malloc(len + 20); + memcpy(fname, modules, len + 1); + /* Let the filename be modified by the pid */ + if (strcmp(fname + len - 3, ".%d") == 0) + snprintf(fname + len - 2, 20, "%d", getpid()); + debug_file = fopen(fname, mode); + if (!debug_file) { + fprintf(stderr, "Cannot open debug file %s\n", + fname); + usage(); + } + free(fname); + goto debug_setbuf; + default: + (void)fprintf(stderr, + "%s: illegal argument to d option -- %c\n", + progname, *modules); + usage(); + } + } +debug_setbuf: + /* + * Make the debug_file unbuffered, and make + * stdout line buffered (unless debugfile == stdout). + */ + setvbuf(debug_file, NULL, _IONBF, 0); + if (debug_file != stdout) { + setvbuf(stdout, NULL, _IOLBF, 0); + } +} - ptrmakeflags = &makeflags[10]; - myname = (argc-- < 1) ? "make" : *argv++; -#ifdef tos - myname = "Make"; -#endif +/*- + * MainParseArgs -- + * Parse a given argument vector. Called from main() and from + * Main_ParseArgLine() when the .MAKEFLAGS target is used. + * + * XXX: Deal with command line overriding .MAKEFLAGS in makefile + * + * Results: + * None + * + * Side Effects: + * Various global and local flags will be set depending on the flags + * given + */ +static void +MainParseArgs(int argc, char **argv) +{ + char *p; + int c = '?'; + int arginc; + char *argvalue; + const char *getopt_def; + char *optscan; + Boolean inOption, dashDash = FALSE; + char found_path[MAXPATHLEN + 1]; /* for searching for sys.mk */ - targc = argc; - targv = nargv = argv; - while (targc--) { - if((p = strchr(*targv, '=')) != (char *)NULL) { - *p = '\0'; - mp = setmacro(*targv, p + 1); - mp->m_flag |= M_OVERRIDE; - --argc; - } else - *nargv++ = *targv; +#define OPTFLAGS "BC:D:I:J:NST:V:WXd:ef:ij:km:nqrst" +/* Can't actually use getopt(3) because rescanning is not portable */ - ++targv; - } - - targc = argc; - targv = nargv = argv; - while (targc--) { - if (**targv == '-') { - --argc; - p = *targv++; - while (*++p != '\0') { - switch(mylower(*p)) { - case 'f': /* Alternate file name */ - if (*++p == '\0') { - --argc; - if (targc-- == 0) - usage(); - p = *targv++; - } - makefile = p; - goto end_of_args; -#ifdef eon - case 'm': /* Change space requirements */ - if (*++p == '\0') { - --argc; - if (targc-- <= 0) - usage(); - p = *targv++; - } - memspace = atoi(p); - goto end_of_args; -#endif - default : - setoption(*p); + getopt_def = OPTFLAGS; +rearg: + inOption = FALSE; + optscan = NULL; + while(argc > 1) { + char *getopt_spec; + if(!inOption) + optscan = argv[1]; + c = *optscan++; + arginc = 0; + if(inOption) { + if(c == '\0') { + ++argv; + --argc; + inOption = FALSE; + continue; + } + } else { + if (c != '-' || dashDash) break; + inOption = TRUE; + c = *optscan++; + } + /* '-' found at some earlier point */ + getopt_spec = strchr(getopt_def, c); + if(c != '\0' && getopt_spec != NULL && getopt_spec[1] == ':') { + /* - found, and should have an arg */ + inOption = FALSE; + arginc = 1; + argvalue = optscan; + if(*argvalue == '\0') { + if (argc < 3) + goto noarg; + argvalue = argv[2]; + arginc = 2; + } + } else { + argvalue = NULL; + } + switch(c) { + case '\0': + arginc = 1; + inOption = FALSE; + break; + case 'B': + compatMake = TRUE; + Var_Append(MAKEFLAGS, "-B", VAR_GLOBAL); + break; + case 'C': + if (chdir(argvalue) == -1) { + (void)fprintf(stderr, + "%s: chdir %s: %s\n", + progname, argvalue, + strerror(errno)); + exit(1); + } + ignorePWD = TRUE; + break; + case 'D': + if (argvalue == NULL || argvalue[0] == 0) goto noarg; + Var_Set(argvalue, "1", VAR_GLOBAL, 0); + Var_Append(MAKEFLAGS, "-D", VAR_GLOBAL); + Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL); + break; + case 'I': + if (argvalue == NULL) goto noarg; + Parse_AddIncludeDir(argvalue); + Var_Append(MAKEFLAGS, "-I", VAR_GLOBAL); + Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL); + break; + case 'J': + if (argvalue == NULL) goto noarg; + if (sscanf(argvalue, "%d,%d", &jp_0, &jp_1) != 2) { + (void)fprintf(stderr, + "%s: internal error -- J option malformed (%s)\n", + progname, argvalue); + usage(); + } + if ((fcntl(jp_0, F_GETFD, 0) < 0) || + (fcntl(jp_1, F_GETFD, 0) < 0)) { +#if 0 + (void)fprintf(stderr, + "%s: ###### warning -- J descriptors were closed!\n", + progname); + exit(2); +#endif + jp_0 = -1; + jp_1 = -1; + compatMake = TRUE; + } else { + Var_Append(MAKEFLAGS, "-J", VAR_GLOBAL); + Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL); + jobServer = TRUE; + } + break; + case 'N': + noExecute = TRUE; + noRecursiveExecute = TRUE; + Var_Append(MAKEFLAGS, "-N", VAR_GLOBAL); + break; + case 'S': + keepgoing = FALSE; + Var_Append(MAKEFLAGS, "-S", VAR_GLOBAL); + break; + case 'T': + if (argvalue == NULL) goto noarg; + tracefile = bmake_strdup(argvalue); + Var_Append(MAKEFLAGS, "-T", VAR_GLOBAL); + Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL); + break; + case 'V': + if (argvalue == NULL) goto noarg; + printVars = TRUE; + (void)Lst_AtEnd(variables, argvalue); + Var_Append(MAKEFLAGS, "-V", VAR_GLOBAL); + Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL); + break; + case 'W': + parseWarnFatal = TRUE; + break; + case 'X': + varNoExportEnv = TRUE; + Var_Append(MAKEFLAGS, "-X", VAR_GLOBAL); + break; + case 'd': + if (argvalue == NULL) goto noarg; + /* If '-d-opts' don't pass to children */ + if (argvalue[0] == '-') + argvalue++; + else { + Var_Append(MAKEFLAGS, "-d", VAR_GLOBAL); + Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL); + } + parse_debug_options(argvalue); + break; + case 'e': + checkEnvFirst = TRUE; + Var_Append(MAKEFLAGS, "-e", VAR_GLOBAL); + break; + case 'f': + if (argvalue == NULL) goto noarg; + (void)Lst_AtEnd(makefiles, argvalue); + break; + case 'i': + ignoreErrors = TRUE; + Var_Append(MAKEFLAGS, "-i", VAR_GLOBAL); + break; + case 'j': + if (argvalue == NULL) goto noarg; + forceJobs = TRUE; + maxJobs = strtol(argvalue, &p, 0); + if (*p != '\0' || maxJobs < 1) { + (void)fprintf(stderr, "%s: illegal argument to -j -- must be positive integer!\n", + progname); + exit(1); + } + Var_Append(MAKEFLAGS, "-j", VAR_GLOBAL); + Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL); + maxJobTokens = maxJobs; + break; + case 'k': + keepgoing = TRUE; + Var_Append(MAKEFLAGS, "-k", VAR_GLOBAL); + break; + case 'm': + if (argvalue == NULL) goto noarg; + /* look for magic parent directory search string */ + if (strncmp(".../", argvalue, 4) == 0) { + if (!Dir_FindHereOrAbove(curdir, argvalue+4, + found_path, sizeof(found_path))) + break; /* nothing doing */ + (void)Dir_AddDir(sysIncPath, found_path); + + } else { + (void)Dir_AddDir(sysIncPath, argvalue); + } + Var_Append(MAKEFLAGS, "-m", VAR_GLOBAL); + Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL); + break; + case 'n': + noExecute = TRUE; + Var_Append(MAKEFLAGS, "-n", VAR_GLOBAL); + break; + case 'q': + queryFlag = TRUE; + /* Kind of nonsensical, wot? */ + Var_Append(MAKEFLAGS, "-q", VAR_GLOBAL); + break; + case 'r': + noBuiltins = TRUE; + Var_Append(MAKEFLAGS, "-r", VAR_GLOBAL); + break; + case 's': + beSilent = TRUE; + Var_Append(MAKEFLAGS, "-s", VAR_GLOBAL); + break; + case 't': + touchFlag = TRUE; + Var_Append(MAKEFLAGS, "-t", VAR_GLOBAL); + break; + case '-': + dashDash = TRUE; + break; + default: + case '?': + usage(); + } + argv += arginc; + argc -= arginc; + } + + oldVars = TRUE; + + /* + * See if the rest of the arguments are variable assignments and + * perform them if so. Else take them to be targets and stuff them + * on the end of the "create" list. + */ + for (; argc > 1; ++argv, --argc) + if (Parse_IsVar(argv[1])) { + Parse_DoVar(argv[1], VAR_CMD); + } else { + if (!*argv[1]) + Punt("illegal (null) argument."); + if (*argv[1] == '-' && !dashDash) + goto rearg; + (void)Lst_AtEnd(create, bmake_strdup(argv[1])); + } + + return; +noarg: + (void)fprintf(stderr, "%s: option requires an argument -- %c\n", + progname, c); + usage(); +} + +/*- + * Main_ParseArgLine -- + * Used by the parse module when a .MFLAGS or .MAKEFLAGS target + * is encountered and by main() when reading the .MAKEFLAGS envariable. + * Takes a line of arguments and breaks it into its + * component words and passes those words and the number of them to the + * MainParseArgs function. + * The line should have all its leading whitespace removed. + * + * Input: + * line Line to fracture + * + * Results: + * None + * + * Side Effects: + * Only those that come from the various arguments. + */ +void +Main_ParseArgLine(const char *line) +{ + char **argv; /* Manufactured argument vector */ + int argc; /* Number of arguments in argv */ + char *args; /* Space used by the args */ + char *buf, *p1; + char *argv0 = Var_Value(".MAKE", VAR_GLOBAL, &p1); + size_t len; + + if (line == NULL) + return; + for (; *line == ' '; ++line) + continue; + if (!*line) + return; + + buf = bmake_malloc(len = strlen(line) + strlen(argv0) + 2); + (void)snprintf(buf, len, "%s %s", argv0, line); + if (p1) + free(p1); + + argv = brk_string(buf, &argc, TRUE, &args); + if (argv == NULL) { + Error("Unterminated quoted string [%s]", buf); + free(buf); + return; + } + free(buf); + MainParseArgs(argc, argv); + + free(args); + free(argv); +} + +Boolean +Main_SetObjdir(const char *path) +{ + struct stat sb; + char *p = NULL; + char buf[MAXPATHLEN + 1]; + Boolean rc = FALSE; + + /* expand variable substitutions */ + if (strchr(path, '$') != 0) { + snprintf(buf, MAXPATHLEN, "%s", path); + path = p = Var_Subst(NULL, buf, VAR_GLOBAL, 0); + } + + if (path[0] != '/') { + snprintf(buf, MAXPATHLEN, "%s/%s", curdir, path); + path = buf; + } + + /* look for the directory and try to chdir there */ + if (stat(path, &sb) == 0 && S_ISDIR(sb.st_mode)) { + if (chdir(path)) { + (void)fprintf(stderr, "make warning: %s: %s.\n", + path, strerror(errno)); + } else { + strncpy(objdir, path, MAXPATHLEN); + Var_Set(".OBJDIR", objdir, VAR_GLOBAL, 0); + setenv("PWD", objdir, 1); + Dir_InitDot(); + rc = TRUE; + } + } + + if (p) + free(p); + return rc; +} + +/*- + * ReadAllMakefiles -- + * wrapper around ReadMakefile() to read all. + * + * Results: + * TRUE if ok, FALSE on error + */ +static int +ReadAllMakefiles(const void *p, const void *q) +{ + return (ReadMakefile(p, q) == 0); +} + +#ifdef SIGINFO +/*ARGSUSED*/ +static void +siginfo(int signo) +{ + char dir[MAXPATHLEN]; + char str[2 * MAXPATHLEN]; + int len; + if (getcwd(dir, sizeof(dir)) == NULL) + return; + len = snprintf(str, sizeof(str), "%s: Working in: %s\n", progname, dir); + if (len > 0) + (void)write(STDERR_FILENO, str, (size_t)len); +} +#endif + +/*- + * main -- + * The main function, for obvious reasons. Initializes variables + * and a few modules, then parses the arguments give it in the + * environment and on the command line. Reads the system makefile + * followed by either Makefile, makefile or the file given by the + * -f argument. Sets the .MAKEFLAGS PMake variable based on all the + * flags it has received by then uses either the Make or the Compat + * module to create the initial list of targets. + * + * Results: + * If -q was given, exits -1 if anything was out-of-date. Else it exits + * 0. + * + * Side Effects: + * The program exits when done. Targets are created. etc. etc. etc. + */ +int +main(int argc, char **argv) +{ + Lst targs; /* target nodes to create -- passed to Make_Init */ + Boolean outOfDate = FALSE; /* FALSE if all targets up to date */ + struct stat sb, sa; + char *p1, *path, *pwd; + char mdpath[MAXPATHLEN]; + char *machine = getenv("MACHINE"); + const char *machine_arch = getenv("MACHINE_ARCH"); + char *syspath = getenv("MAKESYSPATH"); + Lst sysMkPath; /* Path of sys.mk */ + char *cp = NULL, *start; + /* avoid faults on read-only strings */ + static char defsyspath[] = _PATH_DEFSYSPATH; + char found_path[MAXPATHLEN + 1]; /* for searching for sys.mk */ + struct timeval rightnow; /* to initialize random seed */ +#ifdef MAKE_NATIVE + struct utsname utsname; +#endif + + /* default to writing debug to stderr */ + debug_file = stderr; + +#ifdef SIGINFO + (void)signal(SIGINFO, siginfo); +#endif + /* + * Set the seed to produce a different random sequence + * on each program execution. + */ + gettimeofday(&rightnow, NULL); + srandom(rightnow.tv_sec + rightnow.tv_usec); + + if ((progname = strrchr(argv[0], '/')) != NULL) + progname++; + else + progname = argv[0]; +#if defined(RLIMIT_NOFILE) && !defined(__minix) + /* + * get rid of resource limit on file descriptors + */ + { + struct rlimit rl; + if (getrlimit(RLIMIT_NOFILE, &rl) != -1 && + rl.rlim_cur != rl.rlim_max) { + rl.rlim_cur = rl.rlim_max; + (void)setrlimit(RLIMIT_NOFILE, &rl); + } + } +#endif + + /* + * Get the name of this type of MACHINE from utsname + * so we can share an executable for similar machines. + * (i.e. m68k: amiga hp300, mac68k, sun3, ...) + * + * Note that both MACHINE and MACHINE_ARCH are decided at + * run-time. + */ + if (!machine) { +#ifdef MAKE_NATIVE + if (uname(&utsname) == -1) { + (void)fprintf(stderr, "%s: uname failed (%s).\n", progname, + strerror(errno)); + exit(2); + } + machine = utsname.machine; +#else +#ifdef MAKE_MACHINE + machine = MAKE_MACHINE; +#else + machine = "unknown"; +#endif +#endif + } + + if (!machine_arch) { +#ifndef MACHINE_ARCH +#ifdef MAKE_MACHINE_ARCH + machine_arch = MAKE_MACHINE_ARCH; +#else + machine_arch = "unknown"; +#endif +#else + machine_arch = MACHINE_ARCH; +#endif + } + + /* + * Just in case MAKEOBJDIR wants us to do something tricky. + */ + Var_Init(); /* Initialize the lists of variables for + * parsing arguments */ + Var_Set("MACHINE", machine, VAR_GLOBAL, 0); + Var_Set("MACHINE_ARCH", machine_arch, VAR_GLOBAL, 0); +#ifdef MAKE_VERSION + Var_Set("MAKE_VERSION", MAKE_VERSION, VAR_GLOBAL, 0); +#endif + Var_Set(".newline", "\n", VAR_GLOBAL, 0); /* handy for :@ loops */ + + create = Lst_Init(FALSE); + makefiles = Lst_Init(FALSE); + printVars = FALSE; + variables = Lst_Init(FALSE); + beSilent = FALSE; /* Print commands as executed */ + ignoreErrors = FALSE; /* Pay attention to non-zero returns */ + noExecute = FALSE; /* Execute all commands */ + noRecursiveExecute = FALSE; /* Execute all .MAKE targets */ + keepgoing = FALSE; /* Stop on error */ + allPrecious = FALSE; /* Remove targets when interrupted */ + queryFlag = FALSE; /* This is not just a check-run */ + noBuiltins = FALSE; /* Read the built-in rules */ + touchFlag = FALSE; /* Actually update targets */ + debug = 0; /* No debug verbosity, please. */ + jobsRunning = FALSE; + + maxJobs = DEFMAXLOCAL; /* Set default local max concurrency */ + maxJobTokens = maxJobs; + compatMake = FALSE; /* No compat mode */ + ignorePWD = FALSE; + + /* + * Initialize the parsing, directory and variable modules to prepare + * for the reading of inclusion paths and variable settings on the + * command line + */ + + /* + * Initialize various variables. + * MAKE also gets this name, for compatibility + * .MAKEFLAGS gets set to the empty string just in case. + * MFLAGS also gets initialized empty, for compatibility. + */ + Parse_Init(); + Var_Set("MAKE", argv[0], VAR_GLOBAL, 0); + Var_Set(".MAKE", argv[0], VAR_GLOBAL, 0); + Var_Set(MAKEFLAGS, "", VAR_GLOBAL, 0); + Var_Set(MAKEOVERRIDES, "", VAR_GLOBAL, 0); + Var_Set("MFLAGS", "", VAR_GLOBAL, 0); + Var_Set(".ALLTARGETS", "", VAR_GLOBAL, 0); + + /* + * Set some other useful macros + */ + { + char tmp[64]; + const char *ep; + + if (!(ep = getenv(MAKE_LEVEL))) { + ep = "0"; + } + Var_Set(MAKE_LEVEL, ep, VAR_GLOBAL, 0); + snprintf(tmp, sizeof(tmp), "%u", getpid()); + Var_Set(".MAKE.PID", tmp, VAR_GLOBAL, 0); + snprintf(tmp, sizeof(tmp), "%u", getppid()); + Var_Set(".MAKE.PPID", tmp, VAR_GLOBAL, 0); + } + Job_SetPrefix(); + + /* + * First snag any flags out of the MAKE environment variable. + * (Note this is *not* MAKEFLAGS since /bin/make uses that and it's + * in a different format). + */ +#ifdef POSIX + Main_ParseArgLine(getenv("MAKEFLAGS")); +#else + Main_ParseArgLine(getenv("MAKE")); +#endif + + MainParseArgs(argc, argv); + + /* + * Find where we are (now) and take care of PWD for the automounter... + * All this code is so that we know where we are when we start up + * on a different machine with pmake. + */ + if (getcwd(curdir, MAXPATHLEN) == NULL) { + (void)fprintf(stderr, "%s: %s.\n", progname, strerror(errno)); + exit(2); + } + + if (stat(curdir, &sa) == -1) { + (void)fprintf(stderr, "%s: %s: %s.\n", + progname, curdir, strerror(errno)); + exit(2); + } + + /* + * Overriding getcwd() with $PWD totally breaks MAKEOBJDIRPREFIX + * since the value of curdir can vary depending on how we got + * here. Ie sitting at a shell prompt (shell that provides $PWD) + * or via subdir.mk in which case its likely a shell which does + * not provide it. + * So, to stop it breaking this case only, we ignore PWD if + * MAKEOBJDIRPREFIX is set or MAKEOBJDIR contains a transform. + */ + if (!ignorePWD && + (pwd = getenv("PWD")) != NULL && + getenv("MAKEOBJDIRPREFIX") == NULL) { + const char *makeobjdir = getenv("MAKEOBJDIR"); + + if (makeobjdir == NULL || !strchr(makeobjdir, '$')) { + if (stat(pwd, &sb) == 0 && sa.st_ino == sb.st_ino && + sa.st_dev == sb.st_dev) + (void)strncpy(curdir, pwd, MAXPATHLEN); + } + } + Var_Set(".CURDIR", curdir, VAR_GLOBAL, 0); + + /* + * Find the .OBJDIR. If MAKEOBJDIRPREFIX, or failing that, + * MAKEOBJDIR is set in the environment, try only that value + * and fall back to .CURDIR if it does not exist. + * + * Otherwise, try _PATH_OBJDIR.MACHINE, _PATH_OBJDIR, and + * finally _PATH_OBJDIRPREFIX`pwd`, in that order. If none + * of these paths exist, just use .CURDIR. + */ + Dir_Init(curdir); + (void)Main_SetObjdir(curdir); + + if ((path = getenv("MAKEOBJDIRPREFIX")) != NULL) { + (void)snprintf(mdpath, MAXPATHLEN, "%s%s", path, curdir); + (void)Main_SetObjdir(mdpath); + } else if ((path = getenv("MAKEOBJDIR")) != NULL) { + (void)Main_SetObjdir(path); + } else { + (void)snprintf(mdpath, MAXPATHLEN, "%s.%s", _PATH_OBJDIR, machine); + if (!Main_SetObjdir(mdpath) && !Main_SetObjdir(_PATH_OBJDIR)) { + (void)snprintf(mdpath, MAXPATHLEN, "%s%s", + _PATH_OBJDIRPREFIX, curdir); + (void)Main_SetObjdir(mdpath); + } + } + + /* + * Be compatible if user did not specify -j and did not explicitly + * turned compatibility on + */ + if (!compatMake && !forceJobs) { + compatMake = TRUE; + } + + /* + * Initialize archive, target and suffix modules in preparation for + * parsing the makefile(s) + */ + Arch_Init(); + Targ_Init(); + Suff_Init(); + Trace_Init(tracefile); + + DEFAULT = NULL; + (void)time(&now); + + Trace_Log(MAKESTART, NULL); + + /* + * Set up the .TARGETS variable to contain the list of targets to be + * created. If none specified, make the variable empty -- the parser + * will fill the thing in with the default or .MAIN target. + */ + if (!Lst_IsEmpty(create)) { + LstNode ln; + + for (ln = Lst_First(create); ln != NULL; + ln = Lst_Succ(ln)) { + char *name = (char *)Lst_Datum(ln); + + Var_Append(".TARGETS", name, VAR_GLOBAL); + } + } else + Var_Set(".TARGETS", "", VAR_GLOBAL, 0); + + + /* + * If no user-supplied system path was given (through the -m option) + * add the directories from the DEFSYSPATH (more than one may be given + * as dir1:...:dirn) to the system include path. + */ + if (syspath == NULL || *syspath == '\0') + syspath = defsyspath; + else + syspath = bmake_strdup(syspath); + + for (start = syspath; *start != '\0'; start = cp) { + for (cp = start; *cp != '\0' && *cp != ':'; cp++) + continue; + if (*cp == ':') { + *cp++ = '\0'; + } + /* look for magic parent directory search string */ + if (strncmp(".../", start, 4) != 0) { + (void)Dir_AddDir(defIncPath, start); + } else { + if (Dir_FindHereOrAbove(curdir, start+4, + found_path, sizeof(found_path))) { + (void)Dir_AddDir(defIncPath, found_path); } } - end_of_args:; - } else - *nargv++ = *targv++; - } + } + if (syspath != defsyspath) + free(syspath); - /* evaluate and update environment MAKEFLAGS */ - if((p =getenv("MAKEFLAGS")) != (char *)0) - while(*p) setoption(*p++); - for( p = ptrmakeflags; !isspace((int)*p); p++) ; - *p = '\0'; - putenv(makeflags); + /* + * Read in the built-in rules first, followed by the specified + * makefile, if it was (makefile != NULL), or the default + * makefile and Makefile, in that order, if it wasn't. + */ + if (!noBuiltins) { + LstNode ln; + sysMkPath = Lst_Init(FALSE); + Dir_Expand(_PATH_DEFSYSMK, + Lst_IsEmpty(sysIncPath) ? defIncPath : sysIncPath, + sysMkPath); + if (Lst_IsEmpty(sysMkPath)) + Fatal("%s: no system rules (%s).", progname, + _PATH_DEFSYSMK); + ln = Lst_Find(sysMkPath, NULL, ReadMakefile); + if (ln == NULL) + Fatal("%s: cannot open %s.", progname, + (char *)Lst_Datum(ln)); + } -#ifdef eon - if (initalloc(memspace) == 0xffff) /* Must get memory for alloc */ - fatal("Cannot initalloc memory",(char *)0,0); + if (!Lst_IsEmpty(makefiles)) { + LstNode ln; + + ln = Lst_Find(makefiles, NULL, ReadAllMakefiles); + if (ln != NULL) + Fatal("%s: cannot open %s.", progname, + (char *)Lst_Datum(ln)); + } else if (ReadMakefile("makefile", NULL) != 0) + (void)ReadMakefile("Makefile", NULL); + + /* In particular suppress .depend for '-r -V .OBJDIR -f /dev/null' */ + if (!noBuiltins || !printVars) { + doing_depend = TRUE; + (void)ReadMakefile(".depend", NULL); + doing_depend = FALSE; + } + + Var_Append("MFLAGS", Var_Value(MAKEFLAGS, VAR_GLOBAL, &p1), VAR_GLOBAL); + if (p1) + free(p1); + + if (!compatMake) + Job_ServerStart(maxJobTokens, jp_0, jp_1); + if (DEBUG(JOB)) + fprintf(debug_file, "job_pipe %d %d, maxjobs %d, tokens %d, compat %d\n", + jp_0, jp_1, maxJobs, maxJobTokens, compatMake); + + Main_ExportMAKEFLAGS(TRUE); /* initial export */ + + Check_Cwd_av(0, NULL, 0); /* initialize it */ + + + /* + * For compatibility, look at the directories in the VPATH variable + * and add them to the search path, if the variable is defined. The + * variable's value is in the same format as the PATH envariable, i.e. + * ::... + */ + if (Var_Exists("VPATH", VAR_CMD)) { + char *vpath, savec; + /* + * GCC stores string constants in read-only memory, but + * Var_Subst will want to write this thing, so store it + * in an array + */ + static char VPATH[] = "${VPATH}"; + + vpath = Var_Subst(NULL, VPATH, VAR_CMD, FALSE); + path = vpath; + do { + /* skip to end of directory */ + for (cp = path; *cp != ':' && *cp != '\0'; cp++) + continue; + /* Save terminator character so know when to stop */ + savec = *cp; + *cp = '\0'; + /* Add directory to search path */ + (void)Dir_AddDir(dirSearchPath, path); + *cp = savec; + path = cp + 1; + } while (savec == ':'); + free(vpath); + } + + /* + * Now that all search paths have been read for suffixes et al, it's + * time to add the default search path to their lists... + */ + Suff_DoPaths(); + + /* + * Propagate attributes through :: dependency lists. + */ + Targ_Propagate(); + + /* print the initial graph, if the user requested it */ + if (DEBUG(GRAPH1)) + Targ_PrintGraph(1); + + /* print the values of any variables requested by the user */ + if (printVars) { + LstNode ln; + + for (ln = Lst_First(variables); ln != NULL; + ln = Lst_Succ(ln)) { + char *var = (char *)Lst_Datum(ln); + char *value; + + if (strchr(var, '$')) { + value = p1 = Var_Subst(NULL, var, VAR_GLOBAL, 0); + } else { + value = Var_Value(var, VAR_GLOBAL, &p1); + } + printf("%s\n", value ? value : ""); + if (p1) + free(p1); + } + } else { + /* + * Have now read the entire graph and need to make a list of + * targets to create. If none was given on the command line, + * we consult the parsing module to find the main target(s) + * to create. + */ + if (Lst_IsEmpty(create)) + targs = Parse_MainName(); + else + targs = Targ_FindList(create, TARG_CREATE); + + if (!compatMake) { + /* + * Initialize job module before traversing the graph + * now that any .BEGIN and .END targets have been read. + * This is done only if the -q flag wasn't given + * (to prevent the .BEGIN from being executed should + * it exist). + */ + if (!queryFlag) { + Job_Init(); + jobsRunning = TRUE; + } + + /* Traverse the graph, checking on all the targets */ + outOfDate = Make_Run(targs); + } else { + /* + * Compat_Init will take care of creating all the + * targets as well as initializing the module. + */ + Compat_Run(targs); + } + } + +#ifdef CLEANUP + Lst_Destroy(targs, NULL); + Lst_Destroy(variables, NULL); + Lst_Destroy(makefiles, NULL); + Lst_Destroy(create, (FreeProc *)free); #endif - if (makefile && strcmp(makefile, "-") == 0) /* use stdin as makefile */ - ifd = stdin; - else if (!makefile) { /* If no file, then use default */ - if ((ifd = fopen(makefile = DEFN1, "r")) == (FILE *)0) { - if (errno != MNOENT || !DEFN2) - fatal("Can't open %s: %s", DEFN1, errno); - else if ((ifd = fopen(makefile = DEFN2, "r")) == (FILE *)0) - fatal("Can't open %s: %s", DEFN2, errno); - } - } - else if ((ifd = fopen(makefile, "r")) == (FILE *)0) - fatal("Can't open %s: %s", makefile, errno); + /* print the graph now it's been processed if the user requested it */ + if (DEBUG(GRAPH2)) + Targ_PrintGraph(2); - init(); + Trace_Log(MAKEEND, 0); - makerules(); + Suff_End(); + Targ_End(); + Arch_End(); + Var_End(); + Parse_End(); + Dir_End(); + Job_End(); + Trace_End(); - mp = setmacro("MAKE", myname); - mp->m_flag |= M_MAKE; - setmacro("$", "$"); - - /* set environment macros */ - envp = environ; /* get actual environment ptr. */ - while (*envp) { - if((p = strchr(*envp, '=')) != (char *)NULL) { - *p = '\0'; - mp = setmacro(*envp, p + 1); - *p = '='; - if (useenv) mp->m_flag |= M_OVERRIDE; - } else - fatal("invalid environment: %s",*envp,0); - - ++envp; - } - - input(ifd); /* Input all the gunga */ - fclose(ifd); /* Finished with makefile */ - lineno = 0; /* Any calls to error now print no line number */ - - if (print) - prt(); /* Print out structures */ - - np = newname(".SILENT"); - if (np->n_flag & N_TARG) silent = TRUE; - - np = newname(".IGNORE"); - if (np->n_flag & N_TARG) ignore = TRUE; - - precious(); - - if (!firstname) - fatal("No targets defined",(char *)0,0); - - circh(); /* Check circles in target definitions */ - - if (!argc) - estat = make(firstname, 0); - else - while (argc--) { - estat |= make(newname(*argv++), 0); - } - - if (quest) - exit(estat); - else - exit(0); + return outOfDate ? 1 : 0; } -#ifdef __STDC__ -void setoption(char option) +/*- + * ReadMakefile -- + * Open and parse the given makefile. + * + * Results: + * 0 if ok. -1 if couldn't open file. + * + * Side Effects: + * lots + */ +static int +ReadMakefile(const void *p, const void *q __unused) +{ + const char *fname = p; /* makefile to read */ + int fd; + size_t len = MAXPATHLEN; + char *name, *path = bmake_malloc(len); + int setMAKEFILE; + + if (!strcmp(fname, "-")) { + Parse_File("(stdin)", dup(fileno(stdin))); + Var_Set("MAKEFILE", "", VAR_GLOBAL, 0); + } else { + setMAKEFILE = strcmp(fname, ".depend"); + + /* if we've chdir'd, rebuild the path name */ + if (strcmp(curdir, objdir) && *fname != '/') { + size_t plen = strlen(curdir) + strlen(fname) + 2; + if (len < plen) + path = bmake_realloc(path, len = 2 * plen); + + (void)snprintf(path, len, "%s/%s", curdir, fname); + fd = open(path, O_RDONLY); + if (fd != -1) { + fname = path; + goto found; + } + + /* If curdir failed, try objdir (ala .depend) */ + plen = strlen(objdir) + strlen(fname) + 2; + if (len < plen) + path = bmake_realloc(path, len = 2 * plen); + (void)snprintf(path, len, "%s/%s", objdir, fname); + fd = open(path, O_RDONLY); + if (fd != -1) { + fname = path; + goto found; + } + } else { + fd = open(fname, O_RDONLY); + if (fd != -1) + goto found; + } + /* look in -I and system include directories. */ + name = Dir_FindFile(fname, parseIncPath); + if (!name) + name = Dir_FindFile(fname, + Lst_IsEmpty(sysIncPath) ? defIncPath : sysIncPath); + if (!name || (fd = open(name, O_RDONLY)) == -1) { + if (name) + free(name); + free(path); + return(-1); + } + fname = name; + /* + * set the MAKEFILE variable desired by System V fans -- the + * placement of the setting here means it gets set to the last + * makefile specified, as it is set by SysV make. + */ +found: + if (setMAKEFILE) + Var_Set("MAKEFILE", fname, VAR_GLOBAL, 0); + Parse_File(fname, fd); + } + free(path); + return(0); +} + + +/* + * If MAKEOBJDIRPREFIX is in use, make ends up not in .CURDIR + * in situations that would not arrise with ./obj (links or not). + * This tends to break things like: + * + * build: + * ${MAKE} includes + * + * This function spots when ${.MAKE:T} or ${.MAKE} is a command (as + * opposed to an argument) in a command line and if so returns + * ${.CURDIR} so caller can chdir() so that the assumptions made by + * the Makefile hold true. + * + * If ${.MAKE} does not contain any '/', then ${.MAKE:T} is skipped. + * + * The chdir() only happens in the child process, and does nothing if + * MAKEOBJDIRPREFIX and MAKEOBJDIR are not in the environment so it + * should not break anything. Also if NOCHECKMAKECHDIR is set we + * do nothing - to ensure historic semantics can be retained. + */ +static int Check_Cwd_Off = 0; + +static char * +Check_Cwd_av(int ac, char **av, int copy) +{ + static char *make[4]; + static char *cur_dir = NULL; + char **mp; + char *cp; + int is_cmd, next_cmd; + int i; + int n; + + if (Check_Cwd_Off) { + if (DEBUG(CWD)) + fprintf(debug_file, "check_cwd: check is off.\n"); + return NULL; + } + + if (make[0] == NULL) { + if (Var_Exists("NOCHECKMAKECHDIR", VAR_GLOBAL)) { + Check_Cwd_Off = 1; + if (DEBUG(CWD)) + fprintf(debug_file, "check_cwd: turning check off.\n"); + return NULL; + } + + make[1] = Var_Value(".MAKE", VAR_GLOBAL, &cp); + if ((make[0] = strrchr(make[1], '/')) == NULL) { + make[0] = make[1]; + make[1] = NULL; + } else + ++make[0]; + make[2] = NULL; + cur_dir = Var_Value(".CURDIR", VAR_GLOBAL, &cp); + } + if (ac == 0 || av == NULL) { + if (DEBUG(CWD)) + fprintf(debug_file, "check_cwd: empty command.\n"); + return NULL; /* initialization only */ + } + + if (getenv("MAKEOBJDIR") == NULL && + getenv("MAKEOBJDIRPREFIX") == NULL) { + if (DEBUG(CWD)) + fprintf(debug_file, "check_cwd: no obj dirs.\n"); + return NULL; + } + + + next_cmd = 1; + for (i = 0; i < ac; ++i) { + is_cmd = next_cmd; + + n = strlen(av[i]); + cp = &(av[i])[n - 1]; + if (strspn(av[i], "|&;") == (size_t)n) { + next_cmd = 1; + continue; + } else if (*cp == ';' || *cp == '&' || *cp == '|' || *cp == ')') { + next_cmd = 1; + if (copy) { + do { + *cp-- = '\0'; + } while (*cp == ';' || *cp == '&' || *cp == '|' || + *cp == ')' || *cp == '}') ; + } else { + /* + * XXX this should not happen. + */ + fprintf(stderr, "%s: WARNING: raw arg ends in shell meta '%s'\n", + progname, av[i]); + } + } else + next_cmd = 0; + + cp = av[i]; + if (*cp == ';' || *cp == '&' || *cp == '|') + is_cmd = 1; + + if (DEBUG(CWD)) + fprintf(debug_file, "av[%d] == %s '%s'", + i, (is_cmd) ? "cmd" : "arg", av[i]); + if (is_cmd != 0) { + if (*cp == '(' || *cp == '{' || + *cp == ';' || *cp == '&' || *cp == '|') { + do { + ++cp; + } while (*cp == '(' || *cp == '{' || + *cp == ';' || *cp == '&' || *cp == '|'); + if (*cp == '\0') { + next_cmd = 1; + continue; + } + } + if (strcmp(cp, "cd") == 0 || strcmp(cp, "chdir") == 0) { + if (DEBUG(CWD)) + fprintf(debug_file, " == cd, done.\n"); + return NULL; + } + for (mp = make; *mp != NULL; ++mp) { + n = strlen(*mp); + if (strcmp(cp, *mp) == 0) { + if (DEBUG(CWD)) + fprintf(debug_file, " %s == '%s', chdir(%s)\n", + cp, *mp, cur_dir); + return cur_dir; + } + } + } + if (DEBUG(CWD)) + fprintf(debug_file, "\n"); + } + return NULL; +} + +char * +Check_Cwd_Cmd(const char *cmd) +{ + char *cp, *bp; + char **av; + int ac; + + if (Check_Cwd_Off) + return NULL; + + if (cmd) { + av = brk_string(cmd, &ac, TRUE, &bp); + if (DEBUG(CWD)) + fprintf(debug_file, "splitting: '%s' -> %d words\n", + cmd, ac); + } else { + ac = 0; + av = NULL; + bp = NULL; + } + cp = Check_Cwd_av(ac, av, 1); + if (bp) + free(bp); + if (av) + free(av); + return cp; +} + +void +Check_Cwd(const char **argv) +{ + char *cp; + int ac; + + if (Check_Cwd_Off) + return; + + for (ac = 0; argv[ac] != NULL; ++ac) + /* NOTHING */; + if (ac == 3 && *argv[1] == '-') { + cp = Check_Cwd_Cmd(argv[2]); + } else { + cp = Check_Cwd_av(ac, UNCONST(argv), 0); + } + if (cp) { + chdir(cp); + } +} + +/*- + * Cmd_Exec -- + * Execute the command in cmd, and return the output of that command + * in a string. + * + * Results: + * A string containing the output of the command, or the empty string + * If errnum is not NULL, it contains the reason for the command failure + * + * Side Effects: + * The string must be freed by the caller. + */ +char * +Cmd_Exec(const char *cmd, const char **errnum) +{ + const char *args[4]; /* Args for invoking the shell */ + int fds[2]; /* Pipe streams */ + int cpid; /* Child PID */ + int pid; /* PID from wait() */ + char *res; /* result */ + int status; /* command exit status */ + Buffer buf; /* buffer to store the result */ + char *cp; + int cc; + + + *errnum = NULL; + + if (!shellName) + Shell_Init(); + /* + * Set up arguments for shell + */ + args[0] = shellName; + args[1] = "-c"; + args[2] = cmd; + args[3] = NULL; + + /* + * Open a pipe for fetching its output + */ + if (pipe(fds) == -1) { + *errnum = "Couldn't create pipe for \"%s\""; + goto bad; + } + + /* + * Fork + */ +#if defined(__minix) + switch (cpid = fork()) { #else -void setoption(option) -char option; + switch (cpid = vfork()) { #endif -{ - register char *c; + case 0: + /* + * Close input side of pipe + */ + (void)close(fds[0]); - option = mylower(option); - switch(option) { - case 'n': /* Pretend mode */ - domake = FALSE; - break; - case 'i': /* Ignore fault mode */ - ignore = TRUE; - break; - case 'k': /* Continue on errror */ - conterr = TRUE; - break; - case 's': /* Silent about commands */ - silent = TRUE; - break; - case 'p': - print = TRUE; - break; - case 'r': - rules = FALSE; - break; - case 't': - dotouch = TRUE; - break; - case 'q': - quest = TRUE; - break; - case 'e': - useenv = TRUE; - break; - case 'd': - dbginfo = TRUE; - break; - case 'a': - ambigmac = TRUE; - break; - default: /* Wrong option */ - usage(); - } - for( c = ptrmakeflags; !isspace((int)*c); c++) - if ( *c == option) return; - *c = option; + /* + * Duplicate the output stream to the shell's output, then + * shut the extra thing down. Note we don't fetch the error + * stream...why not? Why? + */ + (void)dup2(fds[1], 1); + (void)close(fds[1]); + + Var_ExportVars(); + + (void)execv(shellPath, UNCONST(args)); + _exit(1); + /*NOTREACHED*/ + + case -1: + *errnum = "Couldn't exec \"%s\""; + goto bad; + + default: + /* + * No need for the writing half + */ + (void)close(fds[1]); + + Buf_Init(&buf, 0); + + do { + char result[BUFSIZ]; + cc = read(fds[0], result, sizeof(result)); + if (cc > 0) + Buf_AddBytes(&buf, cc, result); + } + while (cc > 0 || (cc == -1 && errno == EINTR)); + + /* + * Close the input side of the pipe. + */ + (void)close(fds[0]); + + /* + * Wait for the process to exit. + */ + while(((pid = waitpid(cpid, &status, 0)) != cpid) && (pid >= 0)) + continue; + + cc = Buf_Size(&buf); + res = Buf_Destroy(&buf, FALSE); + + if (cc == 0) + *errnum = "Couldn't read shell's output for \"%s\""; + + if (WIFSIGNALED(status)) + *errnum = "\"%s\" exited on a signal"; + else if (WEXITSTATUS(status) != 0) + *errnum = "\"%s\" returned non-zero status"; + + /* + * Null-terminate the result, convert newlines to spaces and + * install it in the variable. + */ + res[cc] = '\0'; + cp = &res[cc]; + + if (cc > 0 && *--cp == '\n') { + /* + * A final newline is just stripped + */ + *cp-- = '\0'; + } + while (cp >= res) { + if (*cp == '\n') { + *cp = ' '; + } + cp--; + } + break; + } + return res; +bad: + res = bmake_malloc(1); + *res = '\0'; + return res; } -void usage() +/*- + * Error -- + * Print an error message given its format. + * + * Results: + * None. + * + * Side Effects: + * The message is printed. + */ +/* VARARGS */ +void +Error(const char *fmt, ...) { - fprintf(stderr, "Syntax: %s [{options | macro=val | target}]\n", myname); - fprintf(stderr, "Function: maintaining computer programs V%s\n",version); - fprintf(stderr, "Options : -a : try to guess undefined ambiguous macros (*,<)\n"); - fprintf(stderr, " -d : print debugging information\n"); - fprintf(stderr, " -e : environment macro def. overwrite makefile def.\n"); - fprintf(stderr, " -f filename : makefile name (default: makefile, Makefile)\n"); - fprintf(stderr, " -i : ignore exit status of executed commands\n"); - fprintf(stderr, " -k : continue with unrelated branches on errors\n"); - fprintf(stderr, " -n : pretend to make\n"); - fprintf(stderr, " -p : print all macros & targets\n"); - fprintf(stderr, " -q : question up-to-dateness of target\n"); - fprintf(stderr, " -r : don't use inbuilt rules\n"); - fprintf(stderr, " -s : make silently\n"); - fprintf(stderr, " -t : touch files instead of making them\n"); - fprintf(stderr, "Environment: MAKEFLAGS\n"); - exit(1); + va_list ap; + FILE *err_file; + + err_file = debug_file; + if (err_file == stdout) + err_file = stderr; + for (;;) { + va_start(ap, fmt); + fprintf(err_file, "%s: ", progname); + (void)vfprintf(err_file, fmt, ap); + va_end(ap); + (void)fprintf(err_file, "\n"); + (void)fflush(err_file); + if (err_file == stderr) + break; + err_file = stderr; + } +} + +/*- + * Fatal -- + * Produce a Fatal error message. If jobs are running, waits for them + * to finish. + * + * Results: + * None + * + * Side Effects: + * The program exits + */ +/* VARARGS */ +void +Fatal(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + if (jobsRunning) + Job_Wait(); + + (void)vfprintf(stderr, fmt, ap); + va_end(ap); + (void)fprintf(stderr, "\n"); + (void)fflush(stderr); + + PrintOnError(NULL); + + if (DEBUG(GRAPH2) || DEBUG(GRAPH3)) + Targ_PrintGraph(2); + Trace_Log(MAKEERROR, 0); + exit(2); /* Not 1 so -q can distinguish error */ +} + +/* + * Punt -- + * Major exception once jobs are being created. Kills all jobs, prints + * a message and exits. + * + * Results: + * None + * + * Side Effects: + * All children are killed indiscriminately and the program Lib_Exits + */ +/* VARARGS */ +void +Punt(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + (void)fprintf(stderr, "%s: ", progname); + (void)vfprintf(stderr, fmt, ap); + va_end(ap); + (void)fprintf(stderr, "\n"); + (void)fflush(stderr); + + PrintOnError(NULL); + + DieHorribly(); +} + +/*- + * DieHorribly -- + * Exit without giving a message. + * + * Results: + * None + * + * Side Effects: + * A big one... + */ +void +DieHorribly(void) +{ + if (jobsRunning) + Job_AbortAll(); + if (DEBUG(GRAPH2)) + Targ_PrintGraph(2); + Trace_Log(MAKEERROR, 0); + exit(2); /* Not 1, so -q can distinguish error */ +} + +/* + * Finish -- + * Called when aborting due to errors in child shell to signal + * abnormal exit. + * + * Results: + * None + * + * Side Effects: + * The program exits + */ +void +Finish(int errors) + /* number of errors encountered in Make_Make */ +{ + Fatal("%d error%s", errors, errors == 1 ? "" : "s"); +} + +/* + * enunlink -- + * Remove a file carefully, avoiding directories. + */ +int +eunlink(const char *file) +{ + struct stat st; + + if (lstat(file, &st) == -1) + return -1; + + if (S_ISDIR(st.st_mode)) { + errno = EISDIR; + return -1; + } + return unlink(file); +} + +/* + * execError -- + * Print why exec failed, avoiding stdio. + */ +void +execError(const char *af, const char *av) +{ +#ifdef USE_IOVEC + int i = 0; + struct iovec iov[8]; +#define IOADD(s) \ + (void)(iov[i].iov_base = UNCONST(s), \ + iov[i].iov_len = strlen(iov[i].iov_base), \ + i++) +#else +#define IOADD(void)write(2, s, strlen(s)) +#endif + + IOADD(progname); + IOADD(": "); + IOADD(af); + IOADD("("); + IOADD(av); + IOADD(") failed ("); + IOADD(strerror(errno)); + IOADD(")\n"); + +#ifdef USE_IOVEC + (void)writev(2, iov, 8); +#endif +} + +/* + * usage -- + * exit with usage message + */ +static void +usage(void) +{ + (void)fprintf(stderr, +"usage: %s [-BeikNnqrstWX] \n\ + [-C directory] [-D variable] [-d flags] [-f makefile]\n\ + [-I directory] [-J private] [-j max_jobs] [-m directory] [-T file]\n\ + [-V variable] [variable=value] [target ...]\n", progname); + exit(2); } -void fatal(msg, a1, a2) -char *msg; -char *a1; -int a2; +int +PrintAddr(void *a, void *b) { - fprintf(stderr, "%s: ", myname); - fprintf(stderr, msg, a1, strerror(a2)); - fputc('\n', stderr); - exit(1); + printf("%lx ", (unsigned long) a); + return b ? 0 : 0; +} + + + +void +PrintOnError(const char *s) +{ + char tmp[64]; + char *cp; + + if (s) + printf("%s", s); + + printf("\n%s: stopped in %s\n", progname, curdir); + strncpy(tmp, "${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'\n@}", + sizeof(tmp) - 1); + cp = Var_Subst(NULL, tmp, VAR_GLOBAL, 0); + if (cp) { + if (*cp) + printf("%s", cp); + free(cp); + } +} + +void +Main_ExportMAKEFLAGS(Boolean first) +{ + static int once = 1; + char tmp[64]; + char *s; + + if (once != first) + return; + once = 0; + + strncpy(tmp, "${.MAKEFLAGS} ${.MAKEOVERRIDES:O:u:@v@$v=${$v:Q}@}", + sizeof(tmp)); + s = Var_Subst(NULL, tmp, VAR_CMD, 0); + if (s && *s) { +#ifdef POSIX + setenv("MAKEFLAGS", s, 1); +#else + setenv("MAKE", s, 1); +#endif + } } diff --git a/commands/bmake/make.1 b/commands/make/make.1 similarity index 100% rename from commands/bmake/make.1 rename to commands/make/make.1 diff --git a/commands/make/make.c b/commands/make/make.c index dde76300f..aa8f8bcd7 100644 --- a/commands/make/make.c +++ b/commands/make/make.c @@ -1,782 +1,1550 @@ -/************************************************************************* - * - * m a k e : m a k e . c - * - * Do the actual making for make plus system dependent stuff - *======================================================================== - * Edition history - * - * # Date Comments By - * --- -------- ---------------------------------------------------- --- - * 1 ?? ?? - * 2 01.07.89 $<,$* bugs fixed RAL - * 3 23.08.89 (time_t)time((time_t*)0) bug fixed, N_EXISTS added RAL - * 4 30.08.89 leading sp. in cmd. output eliminated, indention ch. PSH,RAL - * 5 03.09.89 :: time fixed, error output -> stderr, N_ERROR intr. - * fixed LZ elimintaed RAL - * 6 07.09.89 implmacro, DF macros,debug stuff added RAL - * 7 09.09.89 tos support added PHH,RAL - * 8 17.09.89 make1 arg. fixed, N_EXEC introduced RAL - * ------------ Version 2.0 released ------------------------------- RAL - * 18.05.90 fixed -n bug with silent rules. (Now echos them.) PAN - * - *************************************************************************/ - -#include "h.h" -#include -#include - -_PROTOTYPE(static void tellstatus, (FILE *out, char *name, int status)); - -static bool execflag; +/* $NetBSD: make.c,v 1.78 2009/01/23 21:26:30 dsl Exp $ */ /* - * Exec a shell that returns exit status correctly (/bin/esh). - * The standard EON shell returns the process number of the last - * async command, used by the debugger (ugg). - * [exec on eon is like a fork+exec on unix] + * Copyright (c) 1988, 1989, 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Adam de Boor. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. */ -int dosh(string, shell) -char *string; -char *shell; -{ - int number; - -#ifdef unix - return system(string); -#endif -#ifdef tos - return Tosexec(string); -#endif -#ifdef eon - return ((number = execl(shell, shell,"-c", string, 0)) == -1) ? - -1: /* couldn't start the shell */ - wait(number); /* return its exit status */ -#endif -#ifdef os9 - int status, pid; - - strcat(string, "\n"); - if ((number = os9fork(shell, strlen(string), string, 0, 0, 0)) == -1) - return -1; /* Couldn't start a shell */ - do { - if ((pid = wait(&status)) == -1) - return -1; /* child already died!?!? */ - } while (pid != number); - - return status; -#endif -} - - -#ifdef unix -/* - * Make a file look very outdated after an error trying to make it. - * Don't remove, this keeps hard links intact. (kjb) - */ -int makeold(name) char *name; -{ - struct utimbuf a; - - a.actime = a.modtime = 0; /* The epoch */ - - return utime(name, &a); -} -#endif - - -static void tellstatus(out, name, status) -FILE *out; -char *name; -int status; -{ - char cwd[PATH_MAX]; - - fprintf(out, "%s in %s: ", - name, getcwd(cwd, sizeof(cwd)) == NULL ? "?" : cwd); - - if (WIFEXITED(status)) { - fprintf(out, "Exit code %d", WEXITSTATUS(status)); - } else { - fprintf(out, "Signal %d%s", - WTERMSIG(status), status & 0x80 ? " - core dumped" : ""); - } -} - /* - * Do commands to make a target + * Copyright (c) 1989 by Berkeley Softworks + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Adam de Boor. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. */ -void docmds1(np, lp) -struct name *np; -struct line *lp; -{ - register char *q; - register char *p; - register struct cmd *cp; - bool ssilent; - bool signore; - int estat; - char *shell; - - if (*(shell = getmacro("SHELL")) == '\0') -#ifdef eon - shell = ":bin/esh"; -#endif -#ifdef unix - shell = "/bin/sh"; -#endif -#ifdef os9 - shell = "shell"; -#endif -#ifdef tos - shell = "DESKTOP"; /* TOS has no shell */ -#endif - - for (cp = lp->l_cmd; cp; cp = cp->c_next) { - execflag = TRUE; - strcpy(str1, cp->c_cmd); - expmake = FALSE; - expand(&str1s); - q = str1; - ssilent = silent; - signore = ignore; - while ((*q == '@') || (*q == '-')) { - if (*q == '@') /* Specific silent */ - ssilent = TRUE; - else /* Specific ignore */ - signore = TRUE; - if (!domake) putchar(*q); /* Show all characters. */ - q++; /* Not part of the command */ - } - - for (p=q; *p; p++) { - if (*p == '\n' && p[1] != '\0') { - *p = ' '; - if (!ssilent || !domake) - fputs("\\\n", stdout); - } - else if (!ssilent || !domake) - putchar(*p); - } - if (!ssilent || !domake) - putchar('\n'); - - if (domake || expmake) { /* Get the shell to execute it */ - fflush(stdout); - if ((estat = dosh(q, shell)) != 0) { - if (estat == -1) - fatal("Couldn't execute %s", shell,0); - else if (signore) { - tellstatus(stdout, myname, estat); - printf(" (Ignored)\n"); - } else { - tellstatus(stderr, myname, estat); - fprintf(stderr, "\n"); - if (!(np->n_flag & N_PREC)) -#ifdef unix - if (makeold(np->n_name) == 0) - fprintf(stderr,"%s: made '%s' look old.\n", myname, np->n_name); +#ifndef MAKE_NATIVE +static char rcsid[] = "$NetBSD: make.c,v 1.78 2009/01/23 21:26:30 dsl Exp $"; #else - if (unlink(np->n_name) == 0) - fprintf(stderr,"%s: '%s' removed.\n", myname, np->n_name); +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)make.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: make.c,v 1.78 2009/01/23 21:26:30 dsl Exp $"); #endif - if (!conterr) exit(estat != 0); - np->n_flag |= N_ERROR; - return; - } - } +#endif /* not lint */ +#endif + +/*- + * make.c -- + * The functions which perform the examination of targets and + * their suitability for creation + * + * Interface: + * Make_Run Initialize things for the module and recreate + * whatever needs recreating. Returns TRUE if + * work was (or would have been) done and FALSE + * otherwise. + * + * Make_Update Update all parents of a given child. Performs + * various bookkeeping chores like the updating + * of the cmtime field of the parent, filling + * of the IMPSRC context variable, etc. It will + * place the parent on the toBeMade queue if it + * should be. + * + * Make_TimeStamp Function to set the parent's cmtime field + * based on a child's modification time. + * + * Make_DoAllVar Set up the various local variables for a + * target, including the .ALLSRC variable, making + * sure that any variable that needs to exist + * at the very least has the empty value. + * + * Make_OODate Determine if a target is out-of-date. + * + * Make_HandleUse See if a child is a .USE node for a parent + * and perform the .USE actions if so. + * + * Make_ExpandUse Expand .USE nodes + */ + +#include "make.h" +#include "hash.h" +#include "dir.h" +#include "job.h" + +static unsigned int checked = 1;/* Sequence # to detect recursion */ +static Lst toBeMade; /* The current fringe of the graph. These + * are nodes which await examination by + * MakeOODate. It is added to by + * Make_Update and subtracted from by + * MakeStartJobs */ + +static int MakeAddChild(void *, void *); +static int MakeFindChild(void *, void *); +static int MakeUnmark(void *, void *); +static int MakeAddAllSrc(void *, void *); +static int MakeTimeStamp(void *, void *); +static int MakeHandleUse(void *, void *); +static Boolean MakeStartJobs(void); +static int MakePrintStatus(void *, void *); +static int MakeCheckOrder(void *, void *); +static int MakeBuildChild(void *, void *); +static int MakeBuildParent(void *, void *); + +static void +make_abort(GNode *gn, int line) +{ + static int two = 2; + + fprintf(debug_file, "make_abort from line %d\n", line); + Targ_PrintNode(gn, &two); + Lst_ForEach(toBeMade, Targ_PrintNode, &two); + Targ_PrintGraph(3); + abort(); +} + +/*- + *----------------------------------------------------------------------- + * Make_TimeStamp -- + * Set the cmtime field of a parent node based on the mtime stamp in its + * child. Called from MakeOODate via Lst_ForEach. + * + * Input: + * pgn the current parent + * cgn the child we've just examined + * + * Results: + * Always returns 0. + * + * Side Effects: + * The cmtime of the parent node will be changed if the mtime + * field of the child is greater than it. + *----------------------------------------------------------------------- + */ +int +Make_TimeStamp(GNode *pgn, GNode *cgn) +{ + if (cgn->mtime > pgn->cmtime) { + pgn->cmtime = cgn->mtime; + } + return (0); +} + +/* + * Input: + * pgn the current parent + * cgn the child we've just examined + * + */ +static int +MakeTimeStamp(void *pgn, void *cgn) +{ + return Make_TimeStamp((GNode *)pgn, (GNode *)cgn); +} + +/*- + *----------------------------------------------------------------------- + * Make_OODate -- + * See if a given node is out of date with respect to its sources. + * Used by Make_Run when deciding which nodes to place on the + * toBeMade queue initially and by Make_Update to screen out USE and + * EXEC nodes. In the latter case, however, any other sort of node + * must be considered out-of-date since at least one of its children + * will have been recreated. + * + * Input: + * gn the node to check + * + * Results: + * TRUE if the node is out of date. FALSE otherwise. + * + * Side Effects: + * The mtime field of the node and the cmtime field of its parents + * will/may be changed. + *----------------------------------------------------------------------- + */ +Boolean +Make_OODate(GNode *gn) +{ + Boolean oodate; + + /* + * Certain types of targets needn't even be sought as their datedness + * doesn't depend on their modification time... + */ + if ((gn->type & (OP_JOIN|OP_USE|OP_USEBEFORE|OP_EXEC)) == 0) { + (void)Dir_MTime(gn); + if (DEBUG(MAKE)) { + if (gn->mtime != 0) { + fprintf(debug_file, "modified %s...", Targ_FmtTime(gn->mtime)); + } else { + fprintf(debug_file, "non-existent..."); + } } - } -} + } - -void docmds(np) -struct name *np; -{ - register struct line *lp; - - for (lp = np->n_line; lp; lp = lp->l_next) - docmds1(np, lp); -} - -#ifdef tos -/* - * execute the command submitted by make, - * needed because TOS has no internal shell, - * so we use Pexec to do the job - * v 1.1 of 10/sep/89 by yeti - */ - -#define DELM1 ';' -#define DELM2 ' ' -#define DELM3 ',' - -int Tosexec(string) -char *string; -{ - register char *help, *help2, c; - register unsigned char l=1; - char progname[80], command[255], plain[15]; - static char **envp,*env; - register int error,i; - - /* generate strange TOS environment (RAL) */ - for ( i = 0, envp = environ; *envp; envp++) i += strlen(*envp) +1; - if ((env = malloc(i+1)) == (char *)0) - fatal("No memory for TOS environment",(char *)0,0); - for ( envp = environ, help = env; *envp; envp++) { - strcpy ( help, *envp); - while ( *(help++)) ; - } - *help = '\0'; - - help = progname; - while((*help++=*string++) != ' '); /* progname is command name */ - *--help = '\0'; - - l = strlen(string); /* build option list */ - command[0] = l; /* TOS likes it complicated */ - strcpy(&command[1],string); - if ((error = (int) Pexec(0,progname,command,env)) != -33) { - free(env); - return(error); - } - - /* could'nt find program, try to search the PATH */ - if((help=strrchr(progname,'\\')) != (char *) 0) /* just the */ - strcpy(plain,++help); /* name */ - else if((help=strrchr(progname,'/')) != (char *) 0) - strcpy(plain,++help); - else if((help=strrchr(progname,':')) != (char *) 0) - strcpy(plain,++help); - else - strcpy(plain,progname); - - if(*(help=getmacro("PATH")) == '\0') { - free(env); - return(-33); - } - c = 1; - while(c) - { help2 = &progname[-1]; - i = 0; - while((c=*help++) != '\0' && i<80 && c != DELM1 - && c != DELM2 && c != DELM3) - *++help2 = c, i++; - *++help2 = '\\'; - strcpy(++help2,plain); - if((error=(int) Pexec(0,progname,command,env))!=-33) { - free(env); - return(error); - } - } - free(env); - return(-33); -} - - -/* (stolen from ZOO -- thanks to Rahul Dehsi) -Function mstonix() accepts an MSDOS format date and time and returns -a **IX format time. No adjustment is done for timezone. -*/ - -time_t mstonix (date, time) -unsigned int date, time; -{ - int year, month, day, hour, min, sec, daycount; - time_t longtime; - /* no. of days to beginning of month for each month */ - static int dsboy[12] = { 0, 31, 59, 90, 120, 151, 181, 212, - 243, 273, 304, 334}; - - if (date == 0 && time == 0) /* special case! */ - return (0L); - - /* part of following code is common to zoolist.c */ - year = (((unsigned int) date >> 9) & 0x7f) + 1980; - month = ((unsigned int) date >> 5) & 0x0f; - day = date & 0x1f; - - hour = ((unsigned int) time >> 11)& 0x1f; - min = ((unsigned int) time >> 5) & 0x3f; - sec = ((unsigned int) time & 0x1f) * 2; - -/* DEBUG and leap year fixes thanks to Mark Alexander */ -#ifdef DEBUG - printf ("mstonix: year=%d month=%d day=%d hour=%d min=%d sec=%d\n", - year, month, day, hour, min, sec); -#endif - /* Calculate days since 1970/01/01 */ - daycount = 365 * (year - 1970) + /* days due to whole years */ - (year - 1969) / 4 + /* days due to leap years */ - dsboy[month-1] + /* days since beginning of this year */ - day-1; /* days since beginning of month */ - - if (year % 4 == 0 && - year % 400 != 0 && month >= 3) /* if this is a leap year and month */ - daycount++; /* is March or later, add a day */ - - /* Knowing the days, we can find seconds */ - longtime = daycount * 24L * 60L * 60L + - hour * 60L * 60L + min * 60 + sec; - return (longtime); -} -#endif /* tos */ - -#ifdef os9 -/* - * Some stuffing around to get the modified time of a file - * in an os9 file system - */ -void getmdate(fd, tbp) -int fd; -struct sgtbuf *tbp; -{ - struct registers regs; - static struct fildes fdbuf; - - - regs.rg_a = fd; - regs.rg_b = SS_FD; - regs.rg_x = &fdbuf; - regs.rg_y = sizeof (fdbuf); - - if (_os9(I_GETSTT, ®s) == -1) { - errno = regs.rg_b & 0xff; - return -1; - } - if (tbp) - { - _strass(tbp, fdbuf.fd_date, sizeof (fdbuf.fd_date)); - tbp->t_second = 0; /* Files are only acurate to mins */ - } - return 0; -} - - -/* - * Kludge routine to return an aproximation of how many - * seconds since 1980. Dates will be in order, but will not - * be lineer - */ -time_t cnvtime(tbp) -struct sgtbuf *tbp; -{ - long acc; - - acc = tbp->t_year - 80; /* Baseyear is 1980 */ - acc = acc * 12 + tbp->t_month; - acc = acc * 31 + tbp->t_day; - acc = acc * 24 + tbp->t_hour; - acc = acc * 60 + tbp->t_minute; - acc = acc * 60 + tbp->t_second; - - return acc; -} - - -/* - * Get the current time in the internal format - */ -void time(tp) -time_t *tp; -{ - struct sgtbuf tbuf; - - - if (getime(&tbuf) < 0) - return -1; - - if (tp) - *tp = cnvtime(&tbuf); - - return 0; -} -#endif - - -/* - * Get the modification time of a file. If the first - * doesn't exist, it's modtime is set to 0. - */ -void modtime(np) -struct name *np; -{ -#ifdef unix - struct stat info; - int r; - - if (is_archive_ref(np->n_name)) { - r = archive_stat(np->n_name, &info); - } else { - r = stat(np->n_name, &info); - } - if (r < 0) { - if (errno != ENOENT) - fatal("Can't open %s: %s", np->n_name, errno); - - np->n_time = 0L; - np->n_flag &= ~N_EXISTS; - } else { - np->n_time = info.st_mtime; - np->n_flag |= N_EXISTS; - } -#endif -#ifdef tos - struct DOSTIME fm; - int fd; - - if((fd=Fopen(np->n_name,0)) < 0) { - np->n_time = 0L; - np->n_flag &= ~N_EXISTS; - } - else { - Fdatime(&fm,fd,0); - Fclose(fd); - np->n_time = mstonix((unsigned int)fm.date,(unsigned int)fm.time); - np->n_flag |= N_EXISTS; - } -#endif -#ifdef eon - struct stat info; - int fd; - - if ((fd = open(np->n_name, 0)) < 0) { - if (errno != ER_NOTF) - fatal("Can't open %s: %s", np->n_name, errno); - - np->n_time = 0L; - np->n_flag &= ~N_EXISTS; - } - else if (getstat(fd, &info) < 0) - fatal("Can't getstat %s: %s", np->n_name, errno); - else { - np->n_time = info.st_mod; - np->n_flag |= N_EXISTS; - } - - close(fd); -#endif -#ifdef os9 - struct sgtbuf info; - int fd; - - if ((fd = open(np->n_name, 0)) < 0) { - if (errno != E_PNNF) - fatal("Can't open %s: %s", np->n_name, errno); - - np->n_time = 0L; - np->n_flag &= ~N_EXISTS; - } - else if (getmdate(fd, &info) < 0) - fatal("Can't getstat %s: %s", np->n_name, errno); - else { - np->n_time = cnvtime(&info); - np->n_flag |= N_EXISTS; - } - - close(fd); -#endif -} - - -/* - * Update the mod time of a file to now. - */ -void touch(np) -struct name *np; -{ - char c; - int fd; - - if (!domake || !silent) printf("touch(%s)\n", np->n_name); - - if (domake) { -#ifdef unix - struct utimbuf a; - - a.actime = a.modtime = time((time_t *)NULL); - if (utime(np->n_name, &a) < 0) - printf("%s: '%s' not touched - non-existant\n", - myname, np->n_name); -#endif -#ifdef tos - struct DOSTIME fm; - int fd; - - if((fd=Fopen(np->n_name,0)) < 0) { - printf("%s: '%s' not touched - non-existant\n", - myname, np->n_name); - } - else { - fm.date = Tgetdate(); - fm.time = Tgettime(); - Fdatime(&fm,fd,1); - Fclose(fd); - } -#endif -#ifdef eon - if ((fd = open(np->n_name, 0)) < 0) - printf("%s: '%s' not touched - non-existant\n", - myname, np->n_name); - else - { - uread(fd, &c, 1, 0); - uwrite(fd, &c, 1); - } - close(fd); -#endif -#ifdef os9 + /* + * A target is remade in one of the following circumstances: + * its modification time is smaller than that of its youngest child + * and it would actually be run (has commands or type OP_NOP) + * it's the object of a force operator + * it has no children, was on the lhs of an operator and doesn't exist + * already. + * + * Libraries are only considered out-of-date if the archive module says + * they are. + * + * These weird rules are brought to you by Backward-Compatibility and + * the strange people who wrote 'Make'. + */ + if (gn->type & (OP_USE|OP_USEBEFORE)) { /* - * Strange that something almost as totally useless - * as this is easy to do in os9! + * If the node is a USE node it is *never* out of date + * no matter *what*. */ - if ((fd = open(np->n_name, S_IWRITE)) < 0) - printf("%s: '%s' not touched - non-existant\n", - myname, np->n_name); - close(fd); + if (DEBUG(MAKE)) { + fprintf(debug_file, ".USE node..."); + } + oodate = FALSE; + } else if ((gn->type & OP_LIB) && + ((gn->mtime==0) || Arch_IsLib(gn))) { + if (DEBUG(MAKE)) { + fprintf(debug_file, "library..."); + } + + /* + * always out of date if no children and :: target + * or non-existent. + */ + oodate = (gn->mtime == 0 || Arch_LibOODate(gn) || + (gn->cmtime == 0 && (gn->type & OP_DOUBLEDEP))); + } else if (gn->type & OP_JOIN) { + /* + * A target with the .JOIN attribute is only considered + * out-of-date if any of its children was out-of-date. + */ + if (DEBUG(MAKE)) { + fprintf(debug_file, ".JOIN node..."); + } + if (DEBUG(MAKE)) { + fprintf(debug_file, "source %smade...", gn->flags & CHILDMADE ? "" : "not "); + } + oodate = (gn->flags & CHILDMADE) ? TRUE : FALSE; + } else if (gn->type & (OP_FORCE|OP_EXEC|OP_PHONY)) { + /* + * A node which is the object of the force (!) operator or which has + * the .EXEC attribute is always considered out-of-date. + */ + if (DEBUG(MAKE)) { + if (gn->type & OP_FORCE) { + fprintf(debug_file, "! operator..."); + } else if (gn->type & OP_PHONY) { + fprintf(debug_file, ".PHONY node..."); + } else { + fprintf(debug_file, ".EXEC node..."); + } + } + oodate = TRUE; + } else if (gn->mtime < gn->cmtime || + (gn->cmtime == 0 && + ((gn->mtime == 0 && !(gn->type & OP_OPTIONAL)) + || gn->type & OP_DOUBLEDEP))) + { + /* + * A node whose modification time is less than that of its + * youngest child or that has no children (cmtime == 0) and + * either doesn't exist (mtime == 0) and it isn't optional + * or was the object of a * :: operator is out-of-date. + * Why? Because that's the way Make does it. + */ + if (DEBUG(MAKE)) { + if (gn->mtime < gn->cmtime) { + fprintf(debug_file, "modified before source..."); + } else if (gn->mtime == 0) { + fprintf(debug_file, "non-existent and no sources..."); + } else { + fprintf(debug_file, ":: operator and no sources..."); + } + } + oodate = TRUE; + } else { + /* + * When a non-existing child with no sources + * (such as a typically used FORCE source) has been made and + * the target of the child (usually a directory) has the same + * timestamp as the timestamp just given to the non-existing child + * after it was considered made. + */ + if (DEBUG(MAKE)) { + if (gn->flags & FORCE) + fprintf(debug_file, "non existing child..."); + } + oodate = (gn->flags & FORCE) ? TRUE : FALSE; + } + + /* + * If the target isn't out-of-date, the parents need to know its + * modification time. Note that targets that appear to be out-of-date + * but aren't, because they have no commands and aren't of type OP_NOP, + * have their mtime stay below their children's mtime to keep parents from + * thinking they're out-of-date. + */ + if (!oodate) { + Lst_ForEach(gn->parents, MakeTimeStamp, gn); + } + + return (oodate); +} + +/*- + *----------------------------------------------------------------------- + * MakeAddChild -- + * Function used by Make_Run to add a child to the list l. + * It will only add the child if its make field is FALSE. + * + * Input: + * gnp the node to add + * lp the list to which to add it + * + * Results: + * Always returns 0 + * + * Side Effects: + * The given list is extended + *----------------------------------------------------------------------- + */ +static int +MakeAddChild(void *gnp, void *lp) +{ + GNode *gn = (GNode *)gnp; + Lst l = (Lst) lp; + + if ((gn->flags & REMAKE) == 0 && !(gn->type & (OP_USE|OP_USEBEFORE))) { + if (DEBUG(MAKE)) + fprintf(debug_file, "MakeAddChild: need to examine %s%s\n", + gn->name, gn->cohort_num); + (void)Lst_EnQueue(l, gn); + } + return (0); +} + +/*- + *----------------------------------------------------------------------- + * MakeFindChild -- + * Function used by Make_Run to find the pathname of a child + * that was already made. + * + * Input: + * gnp the node to find + * + * Results: + * Always returns 0 + * + * Side Effects: + * The path and mtime of the node and the cmtime of the parent are + * updated; the unmade children count of the parent is decremented. + *----------------------------------------------------------------------- + */ +static int +MakeFindChild(void *gnp, void *pgnp) +{ + GNode *gn = (GNode *)gnp; + GNode *pgn = (GNode *)pgnp; + + (void)Dir_MTime(gn); + Make_TimeStamp(pgn, gn); + pgn->unmade--; + + return (0); +} + +/*- + *----------------------------------------------------------------------- + * Make_HandleUse -- + * Function called by Make_Run and SuffApplyTransform on the downward + * pass to handle .USE and transformation nodes. It implements the + * .USE and transformation functionality by copying the node's commands, + * type flags and children to the parent node. + * + * A .USE node is much like an explicit transformation rule, except + * its commands are always added to the target node, even if the + * target already has commands. + * + * Input: + * cgn The .USE node + * pgn The target of the .USE node + * + * Results: + * none + * + * Side Effects: + * Children and commands may be added to the parent and the parent's + * type may be changed. + * + *----------------------------------------------------------------------- + */ +void +Make_HandleUse(GNode *cgn, GNode *pgn) +{ + LstNode ln; /* An element in the children list */ + +#ifdef DEBUG_SRC + if ((cgn->type & (OP_USE|OP_USEBEFORE|OP_TRANSFORM)) == 0) { + fprintf(debug_file, "Make_HandleUse: called for plain node %s\n", cgn->name); + return; + } #endif - } + + if ((cgn->type & (OP_USE|OP_USEBEFORE)) || Lst_IsEmpty(pgn->commands)) { + if (cgn->type & OP_USEBEFORE) { + /* + * .USEBEFORE -- + * prepend the child's commands to the parent. + */ + Lst cmds = pgn->commands; + pgn->commands = Lst_Duplicate(cgn->commands, NULL); + (void)Lst_Concat(pgn->commands, cmds, LST_CONCNEW); + Lst_Destroy(cmds, NULL); + } else { + /* + * .USE or target has no commands -- + * append the child's commands to the parent. + */ + (void)Lst_Concat(pgn->commands, cgn->commands, LST_CONCNEW); + } + } + + if (Lst_Open(cgn->children) == SUCCESS) { + while ((ln = Lst_Next(cgn->children)) != NULL) { + GNode *tgn, *gn = (GNode *)Lst_Datum(ln); + + /* + * Expand variables in the .USE node's name + * and save the unexpanded form. + * We don't need to do this for commands. + * They get expanded properly when we execute. + */ + if (gn->uname == NULL) { + gn->uname = gn->name; + } else { + if (gn->name) + free(gn->name); + } + gn->name = Var_Subst(NULL, gn->uname, pgn, FALSE); + if (gn->name && gn->uname && strcmp(gn->name, gn->uname) != 0) { + /* See if we have a target for this node. */ + tgn = Targ_FindNode(gn->name, TARG_NOCREATE); + if (tgn != NULL) + gn = tgn; + } + + (void)Lst_AtEnd(pgn->children, gn); + (void)Lst_AtEnd(gn->parents, pgn); + pgn->unmade += 1; + } + Lst_Close(cgn->children); + } + + pgn->type |= cgn->type & ~(OP_OPMASK|OP_USE|OP_USEBEFORE|OP_TRANSFORM); } +/*- + *----------------------------------------------------------------------- + * MakeHandleUse -- + * Callback function for Lst_ForEach, used by Make_Run on the downward + * pass to handle .USE nodes. Should be called before the children + * are enqueued to be looked at by MakeAddChild. + * This function calls Make_HandleUse to copy the .USE node's commands, + * type flags and children to the parent node. + * + * Input: + * cgnp the child we've just examined + * pgnp the current parent + * + * Results: + * returns 0. + * + * Side Effects: + * After expansion, .USE child nodes are removed from the parent + * + *----------------------------------------------------------------------- + */ +static int +MakeHandleUse(void *cgnp, void *pgnp) +{ + GNode *cgn = (GNode *)cgnp; + GNode *pgn = (GNode *)pgnp; + LstNode ln; /* An element in the children list */ + int unmarked; + + unmarked = ((cgn->type & OP_MARK) == 0); + cgn->type |= OP_MARK; + + if ((cgn->type & (OP_USE|OP_USEBEFORE)) == 0) + return (0); + + if (unmarked) + Make_HandleUse(cgn, pgn); + + /* + * This child node is now "made", so we decrement the count of + * unmade children in the parent... We also remove the child + * from the parent's list to accurately reflect the number of decent + * children the parent has. This is used by Make_Run to decide + * whether to queue the parent or examine its children... + */ + if ((ln = Lst_Member(pgn->children, cgn)) != NULL) { + Lst_Remove(pgn->children, ln); + pgn->unmade--; + } + return (0); +} + + +/*- + *----------------------------------------------------------------------- + * Make_Recheck -- + * Check the modification time of a gnode, and update it as described + * in the comments below. + * + * Results: + * returns 0 if the gnode does not exist, or it's filesystem + * time if it does. + * + * Side Effects: + * the gnode's modification time and path name are affected. + * + *----------------------------------------------------------------------- + */ +time_t +Make_Recheck(GNode *gn) +{ + time_t mtime = Dir_MTime(gn); + +#ifndef RECHECK + /* + * We can't re-stat the thing, but we can at least take care of rules + * where a target depends on a source that actually creates the + * target, but only if it has changed, e.g. + * + * parse.h : parse.o + * + * parse.o : parse.y + * yacc -d parse.y + * cc -c y.tab.c + * mv y.tab.o parse.o + * cmp -s y.tab.h parse.h || mv y.tab.h parse.h + * + * In this case, if the definitions produced by yacc haven't changed + * from before, parse.h won't have been updated and gn->mtime will + * reflect the current modification time for parse.h. This is + * something of a kludge, I admit, but it's a useful one.. + * XXX: People like to use a rule like + * + * FRC: + * + * To force things that depend on FRC to be made, so we have to + * check for gn->children being empty as well... + */ + if (!Lst_IsEmpty(gn->commands) || Lst_IsEmpty(gn->children)) { + gn->mtime = now; + } +#else + /* + * This is what Make does and it's actually a good thing, as it + * allows rules like + * + * cmp -s y.tab.h parse.h || cp y.tab.h parse.h + * + * to function as intended. Unfortunately, thanks to the stateless + * nature of NFS (by which I mean the loose coupling of two clients + * using the same file from a common server), there are times + * when the modification time of a file created on a remote + * machine will not be modified before the local stat() implied by + * the Dir_MTime occurs, thus leading us to believe that the file + * is unchanged, wreaking havoc with files that depend on this one. + * + * I have decided it is better to make too much than to make too + * little, so this stuff is commented out unless you're sure it's ok. + * -- ardeb 1/12/88 + */ + /* + * Christos, 4/9/92: If we are saving commands pretend that + * the target is made now. Otherwise archives with ... rules + * don't work! + */ + if (NoExecute(gn) || (gn->type & OP_SAVE_CMDS) || + (mtime == 0 && !(gn->type & OP_WAIT))) { + if (DEBUG(MAKE)) { + fprintf(debug_file, " recheck(%s): update time from %s to now\n", + gn->name, Targ_FmtTime(gn->mtime)); + } + gn->mtime = now; + } + else { + if (DEBUG(MAKE)) { + fprintf(debug_file, " recheck(%s): current update time: %s\n", + gn->name, Targ_FmtTime(gn->mtime)); + } + } +#endif + return mtime; +} + +/*- + *----------------------------------------------------------------------- + * Make_Update -- + * Perform update on the parents of a node. Used by JobFinish once + * a node has been dealt with and by MakeStartJobs if it finds an + * up-to-date node. + * + * Input: + * cgn the child node + * + * Results: + * Always returns 0 + * + * Side Effects: + * The unmade field of pgn is decremented and pgn may be placed on + * the toBeMade queue if this field becomes 0. + * + * If the child was made, the parent's flag CHILDMADE field will be + * set true and its cmtime set to now. + * + * If the child is not up-to-date and still does not exist, + * set the FORCE flag on the parents. + * + * If the child wasn't made, the cmtime field of the parent will be + * altered if the child's mtime is big enough. + * + * Finally, if the child is the implied source for the parent, the + * parent's IMPSRC variable is set appropriately. + * + *----------------------------------------------------------------------- + */ +void +Make_Update(GNode *cgn) +{ + GNode *pgn; /* the parent node */ + char *cname; /* the child's name */ + LstNode ln; /* Element in parents and iParents lists */ + time_t mtime = -1; + char *p1; + Lst parents; + GNode *centurion; + + /* It is save to re-examine any nodes again */ + checked++; + + cname = Var_Value(TARGET, cgn, &p1); + if (p1) + free(p1); + + if (DEBUG(MAKE)) + fprintf(debug_file, "Make_Update: %s%s\n", cgn->name, cgn->cohort_num); + + /* + * If the child was actually made, see what its modification time is + * now -- some rules won't actually update the file. If the file still + * doesn't exist, make its mtime now. + */ + if (cgn->made != UPTODATE) { + mtime = Make_Recheck(cgn); + } + + /* + * If this is a `::' node, we must consult its first instance + * which is where all parents are linked. + */ + if ((centurion = cgn->centurion) != NULL) { + if (!Lst_IsEmpty(cgn->parents)) + Punt("%s%s: cohort has parents", cgn->name, cgn->cohort_num); + centurion->unmade_cohorts -= 1; + if (centurion->unmade_cohorts < 0) + Error("Graph cycles through centurion %s", centurion->name); + } else { + centurion = cgn; + } + parents = centurion->parents; + + /* If this was a .ORDER node, schedule the RHS */ + Lst_ForEach(centurion->order_succ, MakeBuildParent, Lst_First(toBeMade)); + + /* Now mark all the parents as having one less unmade child */ + if (Lst_Open(parents) == SUCCESS) { + while ((ln = Lst_Next(parents)) != NULL) { + pgn = (GNode *)Lst_Datum(ln); + if (DEBUG(MAKE)) + fprintf(debug_file, "inspect parent %s%s: flags %x, " + "type %x, made %d, unmade %d ", + pgn->name, pgn->cohort_num, pgn->flags, + pgn->type, pgn->made, pgn->unmade-1); + + if (!(pgn->flags & REMAKE)) { + /* This parent isn't needed */ + if (DEBUG(MAKE)) + fprintf(debug_file, "- not needed\n"); + continue; + } + if (mtime == 0 && !(cgn->type & OP_WAIT)) + pgn->flags |= FORCE; + + /* + * If the parent has the .MADE attribute, its timestamp got + * updated to that of its newest child, and its unmake + * child count got set to zero in Make_ExpandUse(). + * However other things might cause us to build one of its + * children - and so we mustn't do any processing here when + * the child build finishes. + */ + if (pgn->type & OP_MADE) { + if (DEBUG(MAKE)) + fprintf(debug_file, "- .MADE\n"); + continue; + } + + if ( ! (cgn->type & (OP_EXEC|OP_USE|OP_USEBEFORE))) { + if (cgn->made == MADE) + pgn->flags |= CHILDMADE; + (void)Make_TimeStamp(pgn, cgn); + } + + /* + * A parent must wait for the completion of all instances + * of a `::' dependency. + */ + if (centurion->unmade_cohorts != 0 || centurion->made < MADE) { + if (DEBUG(MAKE)) + fprintf(debug_file, + "- centurion made %d, %d unmade cohorts\n", + centurion->made, centurion->unmade_cohorts); + continue; + } + + /* One more child of this parent is now made */ + pgn->unmade -= 1; + if (pgn->unmade < 0) { + if (DEBUG(MAKE)) { + fprintf(debug_file, "Graph cycles through %s%s\n", + pgn->name, pgn->cohort_num); + Targ_PrintGraph(2); + } + Error("Graph cycles through %s%s", pgn->name, pgn->cohort_num); + } + + /* We must always rescan the parents of .WAIT and .ORDER nodes. */ + if (pgn->unmade != 0 && !(centurion->type & OP_WAIT) + && !(centurion->flags & DONE_ORDER)) { + if (DEBUG(MAKE)) + fprintf(debug_file, "- unmade children\n"); + continue; + } + if (pgn->made != DEFERRED) { + /* + * Either this parent is on a different branch of the tree, + * or it on the RHS of a .WAIT directive + * or it is already on the toBeMade list. + */ + if (DEBUG(MAKE)) + fprintf(debug_file, "- not deferred\n"); + continue; + } + if (pgn->order_pred + && Lst_ForEach(pgn->order_pred, MakeCheckOrder, 0)) { + /* A .ORDER rule stops us building this */ + continue; + } + if (DEBUG(MAKE)) { + static int two = 2; + fprintf(debug_file, "- %s%s made, schedule %s%s (made %d)\n", + cgn->name, cgn->cohort_num, + pgn->name, pgn->cohort_num, pgn->made); + Targ_PrintNode(pgn, &two); + } + /* Ok, we can schedule the parent again */ + pgn->made = REQUESTED; + (void)Lst_EnQueue(toBeMade, pgn); + } + Lst_Close(parents); + } + + /* + * Set the .PREFIX and .IMPSRC variables for all the implied parents + * of this node. + */ + if (Lst_Open(cgn->iParents) == SUCCESS) { + char *cpref = Var_Value(PREFIX, cgn, &p1); + + while ((ln = Lst_Next(cgn->iParents)) != NULL) { + pgn = (GNode *)Lst_Datum(ln); + if (pgn->flags & REMAKE) { + Var_Set(IMPSRC, cname, pgn, 0); + if (cpref != NULL) + Var_Set(PREFIX, cpref, pgn, 0); + } + } + if (p1) + free(p1); + Lst_Close(cgn->iParents); + } +} + +/*- + *----------------------------------------------------------------------- + * MakeAddAllSrc -- + * Add a child's name to the ALLSRC and OODATE variables of the given + * node. Called from Make_DoAllVar via Lst_ForEach. A child is added only + * if it has not been given the .EXEC, .USE or .INVISIBLE attributes. + * .EXEC and .USE children are very rarely going to be files, so... + * If the child is a .JOIN node, its ALLSRC is propagated to the parent. + * + * A child is added to the OODATE variable if its modification time is + * later than that of its parent, as defined by Make, except if the + * parent is a .JOIN node. In that case, it is only added to the OODATE + * variable if it was actually made (since .JOIN nodes don't have + * modification times, the comparison is rather unfair...).. + * + * Results: + * Always returns 0 + * + * Side Effects: + * The ALLSRC variable for the given node is extended. + *----------------------------------------------------------------------- + */ +static int +MakeUnmark(void *cgnp, void *pgnp __unused) +{ + GNode *cgn = (GNode *)cgnp; + + cgn->type &= ~OP_MARK; + return (0); +} /* - * Recursive routine to make a target. + * Input: + * cgnp The child to add + * pgnp The parent to whose ALLSRC variable it should + * be added + * */ -int make(np, level) -struct name *np; -int level; +static int +MakeAddAllSrc(void *cgnp, void *pgnp) { - register struct depend *dp; - register struct line *lp; - register struct depend *qdp; - time_t now, t, dtime = 0; - bool dbgfirst = TRUE; - char *basename = (char *) 0; - char *inputname = (char *) 0; + GNode *cgn = (GNode *)cgnp; + GNode *pgn = (GNode *)pgnp; - if (np->n_flag & N_DONE) { - if(dbginfo) dbgprint(level,np,"already done"); - return 0; - } + if (cgn->type & OP_MARK) + return (0); + cgn->type |= OP_MARK; - modtime(np); /* Gets modtime of this file */ + if ((cgn->type & (OP_EXEC|OP_USE|OP_USEBEFORE|OP_INVISIBLE)) == 0) { + char *child, *allsrc; + char *p1 = NULL, *p2 = NULL; - while (time(&now) == np->n_time) { - /* Time of target is equal to the current time. This bothers us, because - * we can't tell if it needs to be updated if we update a file it depends - * on within a second. So wait until the second is over. - */ - usleep(10000); - } + if (cgn->type & OP_ARCHV) + child = Var_Value(MEMBER, cgn, &p1); + else + child = cgn->path ? cgn->path : cgn->name; + if (cgn->type & OP_JOIN) { + allsrc = Var_Value(ALLSRC, cgn, &p2); + } else { + allsrc = child; + } + if (allsrc != NULL) + Var_Append(ALLSRC, allsrc, pgn); + if (p2) + free(p2); + if (pgn->type & OP_JOIN) { + if (cgn->made == MADE) { + Var_Append(OODATE, child, pgn); + } + } else if ((pgn->mtime < cgn->mtime) || + (cgn->mtime >= now && cgn->made == MADE)) + { + /* + * It goes in the OODATE variable if the parent is younger than the + * child or if the child has been modified more recently than + * the start of the make. This is to keep pmake from getting + * confused if something else updates the parent after the + * make starts (shouldn't happen, I know, but sometimes it + * does). In such a case, if we've updated the kid, the parent + * is likely to have a modification time later than that of + * the kid and anything that relies on the OODATE variable will + * be hosed. + * + * XXX: This will cause all made children to go in the OODATE + * variable, even if they're not touched, if RECHECK isn't defined, + * since cgn->mtime is set to now in Make_Update. According to + * some people, this is good... + */ + Var_Append(OODATE, child, pgn); + } + if (p1) + free(p1); + } + return (0); +} + +/*- + *----------------------------------------------------------------------- + * Make_DoAllVar -- + * Set up the ALLSRC and OODATE variables. Sad to say, it must be + * done separately, rather than while traversing the graph. This is + * because Make defined OODATE to contain all sources whose modification + * times were later than that of the target, *not* those sources that + * were out-of-date. Since in both compatibility and native modes, + * the modification time of the parent isn't found until the child + * has been dealt with, we have to wait until now to fill in the + * variable. As for ALLSRC, the ordering is important and not + * guaranteed when in native mode, so it must be set here, too. + * + * Results: + * None + * + * Side Effects: + * The ALLSRC and OODATE variables of the given node is filled in. + * If the node is a .JOIN node, its TARGET variable will be set to + * match its ALLSRC variable. + *----------------------------------------------------------------------- + */ +void +Make_DoAllVar(GNode *gn) +{ + Lst_ForEach(gn->children, MakeUnmark, gn); + Lst_ForEach(gn->children, MakeAddAllSrc, gn); - if (rules) { - for (lp = np->n_line; lp; lp = lp->l_next) - if (lp->l_cmd) - break; - if (!lp) - dyndep(np,&basename,&inputname); - } + if (!Var_Exists (OODATE, gn)) { + Var_Set(OODATE, "", gn, 0); + } + if (!Var_Exists (ALLSRC, gn)) { + Var_Set(ALLSRC, "", gn, 0); + } - if (!(np->n_flag & (N_TARG | N_EXISTS))) { - fprintf(stderr,"%s: Don't know how to make %s\n", myname, np->n_name); - if (conterr) { - np->n_flag |= N_ERROR; - if (dbginfo) dbgprint(level,np,"don't know how to make"); - return 0; - } - else exit(1); - } + if (gn->type & OP_JOIN) { + char *p1; + Var_Set(TARGET, Var_Value(ALLSRC, gn, &p1), gn, 0); + if (p1) + free(p1); + } +} + +/*- + *----------------------------------------------------------------------- + * MakeStartJobs -- + * Start as many jobs as possible. + * + * Results: + * If the query flag was given to pmake, no job will be started, + * but as soon as an out-of-date target is found, this function + * returns TRUE. At all other times, this function returns FALSE. + * + * Side Effects: + * Nodes are removed from the toBeMade queue and job table slots + * are filled. + * + *----------------------------------------------------------------------- + */ - for (qdp = (struct depend *)0, lp = np->n_line; lp; lp = lp->l_next) { - for (dp = lp->l_dep; dp; dp = dp->d_next) { - if(dbginfo && dbgfirst) { - dbgprint(level,np," {"); - dbgfirst = FALSE; - } - make(dp->d_name, level+1); - if (np->n_time < dp->d_name->n_time) - qdp = newdep(dp->d_name, qdp); - dtime = max(dtime, dp->d_name->n_time); - if (dp->d_name->n_flag & N_ERROR) np->n_flag |= N_ERROR; - if (dp->d_name->n_flag & N_EXEC ) np->n_flag |= N_EXEC; - } - if (!quest && (np->n_flag & N_DOUBLE) && - (np->n_time < dtime || !( np->n_flag & N_EXISTS))) { - execflag = FALSE; - make1(np, lp, qdp, basename, inputname); /* free()'s qdp */ - dtime = 0; - qdp = (struct depend *)0; - if(execflag) np->n_flag |= N_EXEC; - } - } +static int +MakeCheckOrder(void *v_bn, void *ignore __unused) +{ + GNode *bn = v_bn; - np->n_flag |= N_DONE; - - if (quest) { - t = np->n_time; - np->n_time = now; - return (t < dtime); - } - else if ((np->n_time < dtime || !( np->n_flag & N_EXISTS)) - && !(np->n_flag & N_DOUBLE)) { - execflag = FALSE; - make1(np, (struct line *)0, qdp, basename, inputname); /* free()'s qdp */ - np->n_time = now; - if ( execflag) np->n_flag |= N_EXEC; - } - else if ( np->n_flag & N_EXEC ) { - np->n_time = now; - } - - if (dbginfo) { - if(dbgfirst) { - if(np->n_flag & N_ERROR) - dbgprint(level,np,"skipped because of error"); - else if(np->n_flag & N_EXEC) - dbgprint(level,np,"successfully made"); - else dbgprint(level,np,"is up to date"); - } - else { - if(np->n_flag & N_ERROR) - dbgprint(level,(struct name *)0,"} skipped because of error"); - else if(np->n_flag & N_EXEC) - dbgprint(level,(struct name *)0,"} successfully made"); - else dbgprint(level,(struct name *)0,"} is up to date"); - } - } - if (level == 0 && !(np->n_flag & N_EXEC)) - printf("%s: '%s' is up to date\n", myname, np->n_name); - - if(basename) - free(basename); - return 0; + if (bn->made >= MADE || !(bn->flags & REMAKE)) + return 0; + if (DEBUG(MAKE)) + fprintf(debug_file, "MakeCheckOrder: Waiting for .ORDER node %s%s\n", + bn->name, bn->cohort_num); + return 1; } - -void make1(np, lp, qdp, basename, inputname) -struct name *np; -struct line *lp; -register struct depend *qdp; -char *basename; -char *inputname; +static int +MakeBuildChild(void *v_cn, void *toBeMade_next) { - register struct depend *dp; - size_t l1, l2; + GNode *cn = v_cn; - if (dotouch) - touch(np); - else if (!(np->n_flag & N_ERROR)) { - strcpy(str1, ""); + if (DEBUG(MAKE)) + fprintf(debug_file, "MakeBuildChild: inspect %s%s, made %d, type %x\n", + cn->name, cn->cohort_num, cn->made, cn->type); + if (cn->made > DEFERRED) + return 0; - if(!inputname) { - inputname = str1; /* default */ - if (ambigmac) implmacros(np,lp,&basename,&inputname); + /* If this node is on the RHS of a .ORDER, check LHSs. */ + if (cn->order_pred && Lst_ForEach(cn->order_pred, MakeCheckOrder, 0)) { + /* Can't build this (or anything else in this child list) yet */ + cn->made = DEFERRED; + return 1; } - setDFmacro("<",inputname); - if(!basename) - basename = str1; - setDFmacro("*",basename); + if (DEBUG(MAKE)) + fprintf(debug_file, "MakeBuildChild: schedule %s%s\n", + cn->name, cn->cohort_num); - for (dp = qdp; dp; dp = qdp) { - l1= strlen(str1); - l2= strlen(dp->d_name->n_name); - while (l1 + 1 + l2 +1 > str1s.len) - strrealloc(&str1s); - if (strlen(str1)) - strcat(str1, " "); - strcat(str1, dp->d_name->n_name); - qdp = dp->d_next; - free(dp); - } - setmacro("?", str1); - setDFmacro("@", np->n_name); - - if (lp) /* lp set if doing a :: rule */ - docmds1(np, lp); + cn->made = REQUESTED; + if (toBeMade_next == NULL) + Lst_AtEnd(toBeMade, cn); else - docmds(np); - } + Lst_InsertBefore(toBeMade, toBeMade_next, cn); + + if (cn->unmade_cohorts != 0) + Lst_ForEach(cn->cohorts, MakeBuildChild, toBeMade_next); + + /* + * If this node is a .WAIT node with unmade chlidren + * then don't add the next sibling. + */ + return cn->type & OP_WAIT && cn->unmade > 0; } -void implmacros(np,lp, pbasename,pinputname) -struct name *np; -struct line *lp; -char **pbasename; /* Name without suffix */ -char **pinputname; +/* When a .ORDER RHS node completes we do this on each LHS */ +static int +MakeBuildParent(void *v_pn, void *toBeMade_next) { - struct line *llp; - register char *p; - register char *q; - register char *suff; /* Old suffix */ - int baselen; - struct depend *dp; - bool dpflag = FALSE; + GNode *pn = v_pn; - /* get basename out of target name */ - p = str2; - q = np->n_name; - suff = suffix(q); - while ( *q && (q < suff || !suff)) *p++ = *q++; - *p = '\0'; - if ((*pbasename = (char *) malloc(strlen(str2)+1)) == (char *)0 ) - fatal("No memory for basename",(char *)0,0); - strcpy(*pbasename,str2); - baselen = strlen(str2); + if (pn->made != DEFERRED) + return 0; - if ( lp) - llp = lp; - else - llp = np->n_line; + if (MakeBuildChild(pn, toBeMade_next) == 0) { + /* Mark so that when this node is built we reschedule its parents */ + pn->flags |= DONE_ORDER; + } - while (llp) { - for (dp = llp->l_dep; dp; dp = dp->d_next) { - if( strncmp(*pbasename,dp->d_name->n_name,baselen) == 0) { - *pinputname = dp->d_name->n_name; - return; - } - if( !dpflag) { - *pinputname = dp->d_name->n_name; - dpflag = TRUE; - } - } - if (lp) break; - llp = llp->l_next; - } - -#if NO_WE_DO_WANT_THIS_BASENAME - free(*pbasename); /* basename ambiguous or no dependency file */ - *pbasename = (char *)0; -#endif - return; + return 0; } -void dbgprint(level,np,comment) -int level; -struct name *np; -char *comment; +static Boolean +MakeStartJobs(void) { - char *timep; + GNode *gn; + int have_token = 0; - if(np) { - timep = ctime(&np->n_time); - timep[24] = '\0'; - fputs(&timep[4],stdout); - } - else fputs(" ",stdout); - fputs(" ",stdout); - while(level--) fputs(" ",stdout); - if (np) { - fputs(np->n_name,stdout); - if (np->n_flag & N_DOUBLE) fputs(" :: ",stdout); - else fputs(" : ",stdout); - } - fputs(comment,stdout); - putchar((int)'\n'); - fflush(stdout); - return; + while (!Lst_IsEmpty (toBeMade)) { + /* Get token now to avoid cycling job-list when we only have 1 token */ + if (!have_token && !Job_TokenWithdraw()) + break; + have_token = 1; + + gn = (GNode *)Lst_DeQueue(toBeMade); + if (DEBUG(MAKE)) + fprintf(debug_file, "Examining %s%s...\n", + gn->name, gn->cohort_num); + + if (gn->made != REQUESTED) { + if (DEBUG(MAKE)) + fprintf(debug_file, "state %d\n", gn->made); + + make_abort(gn, __LINE__); + } + + if (gn->checked == checked) { + /* We've already looked at this node since a job finished... */ + if (DEBUG(MAKE)) + fprintf(debug_file, "already checked %s%s\n", + gn->name, gn->cohort_num); + gn->made = DEFERRED; + continue; + } + gn->checked = checked; + + if (gn->unmade != 0) { + /* + * We can't build this yet, add all unmade children to toBeMade, + * just before the current first element. + */ + gn->made = DEFERRED; + Lst_ForEach(gn->children, MakeBuildChild, Lst_First(toBeMade)); + /* and drop this node on the floor */ + if (DEBUG(MAKE)) + fprintf(debug_file, "dropped %s%s\n", gn->name, gn->cohort_num); + continue; + } + + gn->made = BEINGMADE; + if (Make_OODate(gn)) { + if (DEBUG(MAKE)) { + fprintf(debug_file, "out-of-date\n"); + } + if (queryFlag) { + return (TRUE); + } + Make_DoAllVar(gn); + Job_Make(gn); + have_token = 0; + } else { + if (DEBUG(MAKE)) { + fprintf(debug_file, "up-to-date\n"); + } + gn->made = UPTODATE; + if (gn->type & OP_JOIN) { + /* + * Even for an up-to-date .JOIN node, we need it to have its + * context variables so references to it get the correct + * value for .TARGET when building up the context variables + * of its parent(s)... + */ + Make_DoAllVar(gn); + } + Make_Update(gn); + } + } + + if (have_token) + Job_TokenReturn(); + + return (FALSE); +} + +/*- + *----------------------------------------------------------------------- + * MakePrintStatus -- + * Print the status of a top-level node, viz. it being up-to-date + * already or not created due to an error in a lower level. + * Callback function for Make_Run via Lst_ForEach. + * + * Input: + * gnp Node to examine + * cyclep True if gn->unmade being non-zero implies a + * cycle in the graph, not an error in an + * inferior. + * + * Results: + * Always returns 0. + * + * Side Effects: + * A message may be printed. + * + *----------------------------------------------------------------------- + */ +static int +MakePrintStatusOrder(void *ognp, void *gnp) +{ + GNode *ogn = ognp; + GNode *gn = gnp; + + if (!(ogn->flags & REMAKE) || ogn->made > REQUESTED) + /* not waiting for this one */ + return 0; + + printf(" `%s%s' has .ORDER dependency against %s%s " + "(made %d, flags %x, type %x)\n", + gn->name, gn->cohort_num, + ogn->name, ogn->cohort_num, ogn->made, ogn->flags, ogn->type); + if (DEBUG(MAKE) && debug_file != stdout) + fprintf(debug_file, " `%s%s' has .ORDER dependency against %s%s " + "(made %d, flags %x, type %x)\n", + gn->name, gn->cohort_num, + ogn->name, ogn->cohort_num, ogn->made, ogn->flags, ogn->type); + return 0; } +static int +MakePrintStatus(void *gnp, void *v_errors) +{ + GNode *gn = (GNode *)gnp; + int *errors = v_errors; + + if (gn->flags & DONECYCLE) + /* We've completely processed this node before, don't do it again. */ + return 0; + + if (gn->unmade == 0) { + gn->flags |= DONECYCLE; + switch (gn->made) { + case UPTODATE: + printf("`%s%s' is up to date.\n", gn->name, gn->cohort_num); + break; + case MADE: + break; + case UNMADE: + case DEFERRED: + case REQUESTED: + case BEINGMADE: + (*errors)++; + printf("`%s%s' was not built (made %d, flags %x, type %x)!\n", + gn->name, gn->cohort_num, gn->made, gn->flags, gn->type); + if (DEBUG(MAKE) && debug_file != stdout) + fprintf(debug_file, + "`%s%s' was not built (made %d, flags %x, type %x)!\n", + gn->name, gn->cohort_num, gn->made, gn->flags, gn->type); + /* Most likely problem is actually caused by .ORDER */ + Lst_ForEach(gn->order_pred, MakePrintStatusOrder, gn); + break; + default: + /* Errors - already counted */ + printf("`%s%s' not remade because of errors.\n", + gn->name, gn->cohort_num); + if (DEBUG(MAKE) && debug_file != stdout) + fprintf(debug_file, "`%s%s' not remade because of errors.\n", + gn->name, gn->cohort_num); + break; + } + return 0; + } + + if (DEBUG(MAKE)) + fprintf(debug_file, "MakePrintStatus: %s%s has %d unmade children\n", + gn->name, gn->cohort_num, gn->unmade); + /* + * If printing cycles and came to one that has unmade children, + * print out the cycle by recursing on its children. + */ + if (!(gn->flags & CYCLE)) { + /* Fist time we've seen this node, check all children */ + gn->flags |= CYCLE; + Lst_ForEach(gn->children, MakePrintStatus, errors); + /* Mark that this node needn't be processed again */ + gn->flags |= DONECYCLE; + return 0; + } + + /* Only output the error once per node */ + gn->flags |= DONECYCLE; + Error("Graph cycles through `%s%s'", gn->name, gn->cohort_num); + if ((*errors)++ > 100) + /* Abandon the whole error report */ + return 1; + + /* Reporting for our children will give the rest of the loop */ + Lst_ForEach(gn->children, MakePrintStatus, errors); + return 0; +} + + +/*- + *----------------------------------------------------------------------- + * Make_ExpandUse -- + * Expand .USE nodes and create a new targets list + * + * Input: + * targs the initial list of targets + * + * Side Effects: + *----------------------------------------------------------------------- + */ +void +Make_ExpandUse(Lst targs) +{ + GNode *gn; /* a temporary pointer */ + Lst examine; /* List of targets to examine */ + + examine = Lst_Duplicate(targs, NULL); + + /* + * Make an initial downward pass over the graph, marking nodes to be made + * as we go down. We call Suff_FindDeps to find where a node is and + * to get some children for it if it has none and also has no commands. + * If the node is a leaf, we stick it on the toBeMade queue to + * be looked at in a minute, otherwise we add its children to our queue + * and go on about our business. + */ + while (!Lst_IsEmpty (examine)) { + gn = (GNode *)Lst_DeQueue(examine); + + if (gn->flags & REMAKE) + /* We've looked at this one already */ + continue; + gn->flags |= REMAKE; + if (DEBUG(MAKE)) + fprintf(debug_file, "Make_ExpandUse: examine %s%s\n", + gn->name, gn->cohort_num); + + if ((gn->type & OP_DOUBLEDEP) && !Lst_IsEmpty (gn->cohorts)) { + /* Append all the 'cohorts' to the list of things to examine */ + Lst new; + new = Lst_Duplicate(gn->cohorts, NULL); + Lst_Concat(new, examine, LST_CONCLINK); + examine = new; + } + + /* + * Apply any .USE rules before looking for implicit dependencies + * to make sure everything has commands that should... + * Make sure that the TARGET is set, so that we can make + * expansions. + */ + if (gn->type & OP_ARCHV) { + char *eoa, *eon; + eoa = strchr(gn->name, '('); + eon = strchr(gn->name, ')'); + if (eoa == NULL || eon == NULL) + continue; + *eoa = '\0'; + *eon = '\0'; + Var_Set(MEMBER, eoa + 1, gn, 0); + Var_Set(ARCHIVE, gn->name, gn, 0); + *eoa = '('; + *eon = ')'; + } + + (void)Dir_MTime(gn); + Var_Set(TARGET, gn->path ? gn->path : gn->name, gn, 0); + Lst_ForEach(gn->children, MakeUnmark, gn); + Lst_ForEach(gn->children, MakeHandleUse, gn); + + if ((gn->type & OP_MADE) == 0) + Suff_FindDeps(gn); + else { + /* Pretend we made all this node's children */ + Lst_ForEach(gn->children, MakeFindChild, gn); + if (gn->unmade != 0) + printf("Warning: %s%s still has %d unmade children\n", + gn->name, gn->cohort_num, gn->unmade); + } + + if (gn->unmade != 0) + Lst_ForEach(gn->children, MakeAddChild, examine); + } + + Lst_Destroy(examine, NULL); +} + +/*- + *----------------------------------------------------------------------- + * Make_ProcessWait -- + * Convert .WAIT nodes into dependencies + * + * Input: + * targs the initial list of targets + * + *----------------------------------------------------------------------- + */ + +static int +link_parent(void *cnp, void *pnp) +{ + GNode *cn = cnp; + GNode *pn = pnp; + + Lst_AtEnd(pn->children, cn); + Lst_AtEnd(cn->parents, pn); + pn->unmade++; + return 0; +} + +static int +add_wait_dep(void *v_cn, void *v_wn) +{ + GNode *cn = v_cn; + GNode *wn = v_wn; + + if (cn == wn) + return 1; + + if (cn == NULL || wn == NULL) { + printf("bad wait dep %p %p\n", cn, wn); + exit(4); + } + if (DEBUG(MAKE)) + fprintf(debug_file, ".WAIT: add dependency %s%s -> %s\n", + cn->name, cn->cohort_num, wn->name); + + Lst_AtEnd(wn->children, cn); + wn->unmade++; + Lst_AtEnd(cn->parents, wn); + return 0; +} + +static void +Make_ProcessWait(Lst targs) +{ + GNode *pgn; /* 'parent' node we are examining */ + GNode *cgn; /* Each child in turn */ + LstNode owln; /* Previous .WAIT node */ + Lst examine; /* List of targets to examine */ + LstNode ln; + + /* + * We need all the nodes to have a common parent in order for the + * .WAIT and .ORDER scheduling to work. + * Perhaps this should be done earlier... + */ + + pgn = Targ_NewGN(".MAIN"); + pgn->flags = REMAKE; + pgn->type = OP_PHONY | OP_DEPENDS; + /* Get it displayed in the diag dumps */ + Lst_AtFront(Targ_List(), pgn); + + Lst_ForEach(targs, link_parent, pgn); + + /* Start building with the 'dummy' .MAIN' node */ + MakeBuildChild(pgn, NULL); + + examine = Lst_Init(FALSE); + Lst_AtEnd(examine, pgn); + + while (!Lst_IsEmpty (examine)) { + pgn = Lst_DeQueue(examine); + + /* We only want to process each child-list once */ + if (pgn->flags & DONE_WAIT) + continue; + pgn->flags |= DONE_WAIT; + if (DEBUG(MAKE)) + fprintf(debug_file, "Make_ProcessWait: examine %s\n", pgn->name); + + if ((pgn->type & OP_DOUBLEDEP) && !Lst_IsEmpty (pgn->cohorts)) { + /* Append all the 'cohorts' to the list of things to examine */ + Lst new; + new = Lst_Duplicate(pgn->cohorts, NULL); + Lst_Concat(new, examine, LST_CONCLINK); + examine = new; + } + + owln = Lst_First(pgn->children); + Lst_Open(pgn->children); + for (; (ln = Lst_Next(pgn->children)) != NULL; ) { + cgn = Lst_Datum(ln); + if (cgn->type & OP_WAIT) { + /* Make the .WAIT node depend on the previous children */ + Lst_ForEachFrom(pgn->children, owln, add_wait_dep, cgn); + owln = ln; + } else { + Lst_AtEnd(examine, cgn); + } + } + Lst_Close(pgn->children); + } + + Lst_Destroy(examine, NULL); +} + +/*- + *----------------------------------------------------------------------- + * Make_Run -- + * Initialize the nodes to remake and the list of nodes which are + * ready to be made by doing a breadth-first traversal of the graph + * starting from the nodes in the given list. Once this traversal + * is finished, all the 'leaves' of the graph are in the toBeMade + * queue. + * Using this queue and the Job module, work back up the graph, + * calling on MakeStartJobs to keep the job table as full as + * possible. + * + * Input: + * targs the initial list of targets + * + * Results: + * TRUE if work was done. FALSE otherwise. + * + * Side Effects: + * The make field of all nodes involved in the creation of the given + * targets is set to 1. The toBeMade list is set to contain all the + * 'leaves' of these subgraphs. + *----------------------------------------------------------------------- + */ +Boolean +Make_Run(Lst targs) +{ + int errors; /* Number of errors the Job module reports */ + + /* Start trying to make the current targets... */ + toBeMade = Lst_Init(FALSE); + + Make_ExpandUse(targs); + Make_ProcessWait(targs); + + if (DEBUG(MAKE)) { + fprintf(debug_file, "#***# full graph\n"); + Targ_PrintGraph(1); + } + + if (queryFlag) { + /* + * We wouldn't do any work unless we could start some jobs in the + * next loop... (we won't actually start any, of course, this is just + * to see if any of the targets was out of date) + */ + return (MakeStartJobs()); + } + /* + * Initialization. At the moment, no jobs are running and until some + * get started, nothing will happen since the remaining upward + * traversal of the graph is performed by the routines in job.c upon + * the finishing of a job. So we fill the Job table as much as we can + * before going into our loop. + */ + (void)MakeStartJobs(); + + /* + * Main Loop: The idea here is that the ending of jobs will take + * care of the maintenance of data structures and the waiting for output + * will cause us to be idle most of the time while our children run as + * much as possible. Because the job table is kept as full as possible, + * the only time when it will be empty is when all the jobs which need + * running have been run, so that is the end condition of this loop. + * Note that the Job module will exit if there were any errors unless the + * keepgoing flag was given. + */ + while (!Lst_IsEmpty(toBeMade) || jobTokensRunning > 0) { + Job_CatchOutput(); + (void)MakeStartJobs(); + } + + errors = Job_Finish(); + + /* + * Print the final status of each target. E.g. if it wasn't made + * because some inferior reported an error. + */ + if (DEBUG(MAKE)) + fprintf(debug_file, "done: errors %d\n", errors); + if (errors == 0) { + Lst_ForEach(targs, MakePrintStatus, &errors); + if (DEBUG(MAKE)) { + fprintf(debug_file, "done: errors %d\n", errors); + if (errors) + Targ_PrintGraph(4); + } + } + return errors != 0; +} diff --git a/commands/bmake/make.h b/commands/make/make.h similarity index 100% rename from commands/bmake/make.h rename to commands/make/make.h diff --git a/commands/bmake/make_malloc.c b/commands/make/make_malloc.c similarity index 100% rename from commands/bmake/make_malloc.c rename to commands/make/make_malloc.c diff --git a/commands/bmake/make_malloc.h b/commands/make/make_malloc.h similarity index 100% rename from commands/bmake/make_malloc.h rename to commands/make/make_malloc.h diff --git a/commands/bmake/nonints.h b/commands/make/nonints.h similarity index 100% rename from commands/bmake/nonints.h rename to commands/make/nonints.h diff --git a/commands/bmake/parse.c b/commands/make/parse.c similarity index 100% rename from commands/bmake/parse.c rename to commands/make/parse.c diff --git a/commands/bmake/pathnames.h b/commands/make/pathnames.h similarity index 100% rename from commands/bmake/pathnames.h rename to commands/make/pathnames.h diff --git a/commands/make/reader.c b/commands/make/reader.c deleted file mode 100644 index 4d0fed500..000000000 --- a/commands/make/reader.c +++ /dev/null @@ -1,134 +0,0 @@ -/************************************************************************* - * - * m a k e : r e a d e r . c - * - * Read in makefile - *======================================================================== - * Edition history - * - * # Date Comments By - * --- -------- ---------------------------------------------------- --- - * 1 ?? ?? - * 2 23.08.89 cast to NULL added RAL - * 3 30.08.89 indention changed PSH,RAL - * 4 03.09.89 fixed LZ eliminated RAL - * ------------ Version 2.0 released ------------------------------- RAL - * - *************************************************************************/ - -#include "h.h" - - -/* - * Syntax error handler. Print message, with line number, and exits. - */ -void error(msg, a1) -char *msg; -char *a1; -{ - fprintf(stderr, "%s: ", myname); - fprintf(stderr, msg, a1); - if (lineno) fprintf(stderr, " in %s near line %d", makefile, lineno); - fputc('\n', stderr); - exit(1); -} - - -/* - * Read a line into the supplied string. Remove - * comments, ignore blank lines. Deal with quoted (\) #, and - * quoted newlines. If EOF return TRUE. - * - * The comment handling code has been changed to leave comments and - * backslashes alone in shell commands (lines starting with a tab). - * This is not what POSIX wants, but what all makes do. (KJB) - */ -bool getline(strs, fd) -struct str *strs; -FILE *fd; -{ - register char *p; - char *q; - int c; - - for (;;) { - strs->pos = 0; - for (;;) { - do { - if (strs->pos >= strs->len) - strrealloc(strs); - if ((c = getc(fd)) == EOF) - return TRUE; /* EOF */ - (*strs->ptr)[strs->pos++] = c; - } while (c != '\n'); - - lineno++; - - if (strs->pos >= 2 && (*strs->ptr)[strs->pos - 2] == '\\') { - (*strs->ptr)[strs->pos - 2] = '\n'; - strs->pos--; - } else { - break; - } - } - - if (strs->pos >= strs->len) - strrealloc(strs); - (*strs->ptr)[strs->pos] = '\0'; - - p = q = *strs->ptr; - while (isspace(*q)) q++; - if (*p != '\t' || *q == '#') { - while (((q = strchr(p, '#')) != (char *)0) && - (p != q) && (q[-1] == '\\')) - { - char *a; - - a = q - 1; /* Del \ chr; move rest back */ - p = q; - while (*a++ = *q++) - ; - } - if (q != (char *)0) - { - q[0] = '\n'; - q[1] = '\0'; - } - } - - p = *strs->ptr; - while (isspace(*p)) /* Checking for blank */ - p++; - - if (*p != '\0') - return FALSE; - } -} - - -/* - * Get a word from the current line, surounded by white space. - * return a pointer to it. String returned has no white spaces - * in it. - */ -char *gettok(ptr) -register char **ptr; -{ - register char *p; - - - while (isspace(**ptr)) /* Skip spaces */ - (*ptr)++; - - if (**ptr == '\0') /* Nothing after spaces */ - return ((char *)NULL); - - p = *ptr; /* word starts here */ - - while ((**ptr != '\0') && (!isspace(**ptr))) - (*ptr)++; /* Find end of word */ - - *(*ptr)++ = '\0'; /* Terminate it */ - - return(p); -} diff --git a/commands/make/rules.c b/commands/make/rules.c deleted file mode 100644 index a0335ba90..000000000 --- a/commands/make/rules.c +++ /dev/null @@ -1,314 +0,0 @@ -/************************************************************************* - * - * m a k e : r u l e s . c - * - * Control of the implicit suffix rules - *======================================================================== - * Edition history - * - * # Date Comments By - * --- -------- ---------------------------------------------------- --- - * 1 ?? ?? - * 2 01.07.89 $<,$* bugs fixed, impl. r. ending in expl. r. added RAL - * 3 23.08.89 suffix as macro, testname intr., algorithem to find - * source dep. made more intelligent (see Readme3) RAL - * 4 30.08.89 indention changed PSH,RAL - * 5 03.09.89 fixed LZ eliminated RAL - * 6 07.09.89 rules of type '.c', .DEFAULT added, dep. search impr.RAL - * ------------ Version 2.0 released ------------------------------- RAL - * - *************************************************************************/ - -#include "h.h" - - -/* - * Dynamic dependency. This routine applies the suffis rules - * to try and find a source and a set of rules for a missing - * target. If found, np is made into a target with the implicit - * source name, and rules. Returns TRUE if np was made into - * a target. - */ -bool dyndep(np,pbasename,pinputname) -struct name *np; -char **pbasename; /* Name without suffix */ -char **pinputname; -{ - register char *p; - register char *q; - register char *suff; /* Old suffix */ - struct name *op = (struct name *)0,*optmp; /* New dependent */ - struct name *sp; /* Suffix */ - struct line *lp,*nlp; - struct depend *dp,*ndp; - struct cmd *cmdp; - char *newsuff; - bool depexists = FALSE; - - - p = str1; - q = np->n_name; - suff = suffix(q); - while (*q && (q < suff || !suff)) *p++ = *q++; - *p = '\0'; - if ((*pbasename = (char *) malloc(strlen(str1)+1)) == (char *)0 ) - fatal("No memory for basename",(char *)0,0); - strcpy(*pbasename,str1); - if ( !suff) suff = p - str1 + *pbasename; /* set suffix to nullstring */ - - if (!((sp = newname(".SUFFIXES"))->n_flag & N_TARG)) return FALSE; - - /* search all .SUFFIXES lines */ - for (lp = sp->n_line; lp; lp = lp->l_next) - /* try all suffixes */ - for (dp = lp->l_dep; dp; dp = dp->d_next) { - /* compose implicit rule name (.c.o)...*/ - newsuff = dp->d_name->n_name; - while (strlen(suff)+strlen(newsuff)+1 >= str1s.len) strrealloc(&str1s); - p = str1; - q = newsuff; - while (*p++ = *q++) ; - p--; - q = suff; - while (*p++ = *q++) ; - /* look if the rule exists */ - sp = newname(str1); - if (sp->n_flag & N_TARG) { - /* compose resulting dependency name */ - while (strlen(*pbasename) + strlen(newsuff)+1 >= str1s.len) - strrealloc(&str1s); - q = *pbasename; - p = str1; - while (*p++ = *q++) ; - p--; - q = newsuff; - while (*p++ = *q++) ; - /* test if dependency file or an explicit rule exists */ - if ((optmp= testname(str1)) != (struct name *)0) { - /* store first possible dependency as default */ - if ( op == (struct name *)0) { - op = optmp; - cmdp = sp->n_line->l_cmd; - } - /* check if testname is an explicit dependency */ - for ( nlp=np->n_line; nlp; nlp=nlp->l_next) { - for( ndp=nlp->l_dep; ndp; ndp=ndp->d_next) { - if ( strcmp( ndp->d_name->n_name, str1) == 0) { - op = optmp; - cmdp = sp->n_line->l_cmd; - ndp = (struct depend *) 0; - goto found2; - } - depexists = TRUE; - } - } - /* if no explicit dependencies : accept testname */ - if (!depexists) goto found; - } - } - } - - if ( op == (struct name *)0) { - if( np->n_flag & N_TARG) { /* DEFAULT handling */ - if (!((sp = newname(".DEFAULT"))->n_flag & N_TARG)) return FALSE; - if (!(sp->n_line)) return FALSE; - cmdp = sp->n_line->l_cmd; - for ( nlp=np->n_line; nlp; nlp=nlp->l_next) { - if ( ndp=nlp->l_dep) { - op = ndp->d_name; - ndp = (struct depend *)0; - goto found2; - } - } - newline(np, (struct depend *)0, cmdp, 0); - *pinputname = (char *)0; - *pbasename = (char *)0; - return TRUE; - } - else return FALSE; - } - -found: - ndp = newdep(op, (struct depend *)0); -found2: - newline(np, ndp, cmdp, 0); - *pinputname = op->n_name; - return TRUE; -} - - -/* - * Make the default rules - */ -void makerules() -{ - struct cmd *cp; - struct name *np; - struct depend *dp; - - -#ifdef eon - setmacro("BDSCC", "asm"); - /* setmacro("BDSCFLAGS", ""); */ - cp = newcmd("$(BDSCC) $(BDSCFLAGS) -n $<", (struct cmd *)0); - np = newname(".c.o"); - newline(np, (struct depend *)0, cp, 0); - - setmacro("CC", "c"); - setmacro("CFLAGS", "-O"); - cp = newcmd("$(CC) $(CFLAGS) -c $<", (struct cmd *)0); - np = newname(".c.obj"); - newline(np, (struct depend *)0, cp, 0); - - setmacro("M80", "asm -n"); - /* setmacro("M80FLAGS", ""); */ - cp = newcmd("$(M80) $(M80FLAGS) $<", (struct cmd *)0); - np = newname(".mac.o"); - newline(np, (struct depend *)0, cp, 0); - - setmacro("AS", "zas"); - /* setmacro("ASFLAGS", ""); */ - cp = newcmd("$(ZAS) $(ASFLAGS) -o $@ $<", (struct cmd *)0); - np = newname(".as.obj"); - newline(np, (struct depend *)0, cp, 0); - - np = newname(".as"); - dp = newdep(np, (struct depend *)0); - np = newname(".obj"); - dp = newdep(np, dp); - np = newname(".c"); - dp = newdep(np, dp); - np = newname(".o"); - dp = newdep(np, dp); - np = newname(".mac"); - dp = newdep(np, dp); - np = newname(".SUFFIXES"); - newline(np, dp, (struct cmd *)0, 0); -#endif - -#ifdef tos -#define unix -#endif - -/* - * Some of the UNIX implicit rules - */ - -#ifdef unix - - setmacro("CC", "cc"); - setmacro("CFLAGS", ""); - - cp = newcmd("$(CC) -S $(CFLAGS) $<", (struct cmd *)0); - np = newname(".c.s"); - newline(np, (struct depend *)0, cp, 0); - - cp = newcmd("$(CC) -c $(CFLAGS) $<", (struct cmd *)0); - np = newname(".c.o"); - newline(np, (struct depend *)0, cp, 0); - -#if this_rule_is_a_bit_too_much_of_a_good_thing -#ifdef MINIXPC - cp = newcmd("$(CC) $(CFLAGS) -i -o $@ $<", (struct cmd *)0); -#else - cp = newcmd("$(CC) $(CFLAGS) -o $@ $<", (struct cmd *)0); -#endif /* MINIXPC */ - np = newname(".c"); - newline(np, (struct depend *)0, cp, 0); -#endif - - cp = newcmd("$(CC) -c $(CFLAGS) $<", (struct cmd *)0); - np = newname(".s.o"); - newline(np, (struct depend *)0, cp, 0); - - setmacro("YACC", "yacc"); - /*setmacro("YFLAGS", ""); */ - cp = newcmd("$(YACC) $(YFLAGS) $<", (struct cmd *)0); - cp = newcmd("mv y.tab.c $@", cp); - np = newname(".y.c"); - newline(np, (struct depend *)0, cp, 0); - - cp = newcmd("$(YACC) $(YFLAGS) $<", (struct cmd *)0); - cp = newcmd("$(CC) $(CFLAGS) -c y.tab.c", cp); - cp = newcmd("mv y.tab.o $@", cp); - np = newname(".y.o"); - cp = newcmd("rm y.tab.c", cp); - newline(np, (struct depend *)0, cp, 0); - - setmacro("FLEX", "flex"); - cp = newcmd("$(FLEX) $(FLEX_FLAGS) $<", (struct cmd *)0); - cp = newcmd("mv lex.yy.c $@", cp); - np = newname(".l.c"); - newline(np, (struct depend *)0, cp, 0); - - cp = newcmd("$(FLEX) $(FLEX_FLAGS) $<", (struct cmd *)0); - cp = newcmd("$(CC) $(CFLAGS) -c lex.yy.c", cp); - cp = newcmd("mv lex.yy.o $@", cp); - np = newname(".l.o"); - cp = newcmd("rm lex.yy.c", cp); - newline(np, (struct depend *)0, cp, 0); - - np = newname(".o"); - dp = newdep(np, (struct depend *)0); - np = newname(".s"); - dp = newdep(np, dp); - np = newname(".c"); - dp = newdep(np, dp); - np = newname(".y"); - dp = newdep(np, dp); - np = newname(".l"); - dp = newdep(np, dp); - np = newname(".SUFFIXES"); - newline(np, dp, (struct cmd *)0, 0); - -#endif /* unix */ - - -#ifdef os9 -/* - * Fairlight use an enhanced version of the C sub-system. - * They have a specialised macro pre-processor. - */ - setmacro("CC", "cc"); - setmacro("CFLAGS", "-z"); - cp = newcmd("$(CC) $(CFLAGS) -r $<", (struct cmd *)0); - - np = newname(".c.r"); - newline(np, (struct depend *)0, cp, 0); - np = newname(".ca.r"); - newline(np, (struct depend *)0, cp, 0); - np = newname(".a.r"); - newline(np, (struct depend *)0, cp, 0); - np = newname(".o.r"); - newline(np, (struct depend *)0, cp, 0); - np = newname(".mc.r"); - newline(np, (struct depend *)0, cp, 0); - np = newname(".mca.r"); - newline(np, (struct depend *)0, cp, 0); - np = newname(".ma.r"); - newline(np, (struct depend *)0, cp, 0); - np = newname(".mo.r"); - newline(np, (struct depend *)0, cp, 0); - - np = newname(".r"); - dp = newdep(np, (struct depend *)0); - np = newname(".mc"); - dp = newdep(np, dp); - np = newname(".mca"); - dp = newdep(np, dp); - np = newname(".c"); - dp = newdep(np, dp); - np = newname(".ca"); - dp = newdep(np, dp); - np = newname(".ma"); - dp = newdep(np, dp); - np = newname(".mo"); - dp = newdep(np, dp); - np = newname(".o"); - dp = newdep(np, dp); - np = newname(".a"); - dp = newdep(np, dp); - np = newname(".SUFFIXES"); - newline(np, dp, (struct cmd *)0, 0); -#endif -} diff --git a/commands/bmake/sprite.h b/commands/make/sprite.h similarity index 100% rename from commands/bmake/sprite.h rename to commands/make/sprite.h diff --git a/commands/bmake/str.c b/commands/make/str.c similarity index 100% rename from commands/bmake/str.c rename to commands/make/str.c diff --git a/commands/bmake/strlist.c b/commands/make/strlist.c similarity index 100% rename from commands/bmake/strlist.c rename to commands/make/strlist.c diff --git a/commands/bmake/strlist.h b/commands/make/strlist.h similarity index 100% rename from commands/bmake/strlist.h rename to commands/make/strlist.h diff --git a/commands/bmake/suff.c b/commands/make/suff.c similarity index 100% rename from commands/bmake/suff.c rename to commands/make/suff.c diff --git a/commands/bmake/targ.c b/commands/make/targ.c similarity index 100% rename from commands/bmake/targ.c rename to commands/make/targ.c diff --git a/commands/bmake/trace.c b/commands/make/trace.c similarity index 100% rename from commands/bmake/trace.c rename to commands/make/trace.c diff --git a/commands/bmake/trace.h b/commands/make/trace.h similarity index 100% rename from commands/bmake/trace.h rename to commands/make/trace.h diff --git a/commands/bmake/unit-tests/Makefile b/commands/make/unit-tests/Makefile similarity index 100% rename from commands/bmake/unit-tests/Makefile rename to commands/make/unit-tests/Makefile diff --git a/commands/bmake/unit-tests/comment b/commands/make/unit-tests/comment similarity index 100% rename from commands/bmake/unit-tests/comment rename to commands/make/unit-tests/comment diff --git a/commands/bmake/unit-tests/cond1 b/commands/make/unit-tests/cond1 similarity index 100% rename from commands/bmake/unit-tests/cond1 rename to commands/make/unit-tests/cond1 diff --git a/commands/bmake/unit-tests/dotwait b/commands/make/unit-tests/dotwait similarity index 100% rename from commands/bmake/unit-tests/dotwait rename to commands/make/unit-tests/dotwait diff --git a/commands/bmake/unit-tests/export b/commands/make/unit-tests/export similarity index 100% rename from commands/bmake/unit-tests/export rename to commands/make/unit-tests/export diff --git a/commands/bmake/unit-tests/export-all b/commands/make/unit-tests/export-all similarity index 100% rename from commands/bmake/unit-tests/export-all rename to commands/make/unit-tests/export-all diff --git a/commands/bmake/unit-tests/forsubst b/commands/make/unit-tests/forsubst similarity index 100% rename from commands/bmake/unit-tests/forsubst rename to commands/make/unit-tests/forsubst diff --git a/commands/bmake/unit-tests/moderrs b/commands/make/unit-tests/moderrs similarity index 100% rename from commands/bmake/unit-tests/moderrs rename to commands/make/unit-tests/moderrs diff --git a/commands/bmake/unit-tests/modmatch b/commands/make/unit-tests/modmatch similarity index 100% rename from commands/bmake/unit-tests/modmatch rename to commands/make/unit-tests/modmatch diff --git a/commands/bmake/unit-tests/modmisc b/commands/make/unit-tests/modmisc similarity index 100% rename from commands/bmake/unit-tests/modmisc rename to commands/make/unit-tests/modmisc diff --git a/commands/bmake/unit-tests/modorder b/commands/make/unit-tests/modorder similarity index 100% rename from commands/bmake/unit-tests/modorder rename to commands/make/unit-tests/modorder diff --git a/commands/bmake/unit-tests/modts b/commands/make/unit-tests/modts similarity index 100% rename from commands/bmake/unit-tests/modts rename to commands/make/unit-tests/modts diff --git a/commands/bmake/unit-tests/modword b/commands/make/unit-tests/modword similarity index 100% rename from commands/bmake/unit-tests/modword rename to commands/make/unit-tests/modword diff --git a/commands/bmake/unit-tests/posix b/commands/make/unit-tests/posix similarity index 100% rename from commands/bmake/unit-tests/posix rename to commands/make/unit-tests/posix diff --git a/commands/bmake/unit-tests/qequals b/commands/make/unit-tests/qequals similarity index 100% rename from commands/bmake/unit-tests/qequals rename to commands/make/unit-tests/qequals diff --git a/commands/bmake/unit-tests/ternary b/commands/make/unit-tests/ternary similarity index 100% rename from commands/bmake/unit-tests/ternary rename to commands/make/unit-tests/ternary diff --git a/commands/bmake/unit-tests/test.exp b/commands/make/unit-tests/test.exp similarity index 100% rename from commands/bmake/unit-tests/test.exp rename to commands/make/unit-tests/test.exp diff --git a/commands/bmake/unit-tests/unexport b/commands/make/unit-tests/unexport similarity index 100% rename from commands/bmake/unit-tests/unexport rename to commands/make/unit-tests/unexport diff --git a/commands/bmake/unit-tests/unexport-env b/commands/make/unit-tests/unexport-env similarity index 100% rename from commands/bmake/unit-tests/unexport-env rename to commands/make/unit-tests/unexport-env diff --git a/commands/bmake/unit-tests/varcmd b/commands/make/unit-tests/varcmd similarity index 100% rename from commands/bmake/unit-tests/varcmd rename to commands/make/unit-tests/varcmd diff --git a/commands/bmake/util.c b/commands/make/util.c similarity index 100% rename from commands/bmake/util.c rename to commands/make/util.c diff --git a/commands/bmake/var.c b/commands/make/var.c similarity index 100% rename from commands/bmake/var.c rename to commands/make/var.c diff --git a/commands/scripts/mkdep.sh b/commands/scripts/mkdep.sh index 5c5a40d87..ad2f1ee07 100644 --- a/commands/scripts/mkdep.sh +++ b/commands/scripts/mkdep.sh @@ -8,6 +8,8 @@ # Added option to generate .depend files in subdirectories of given dir. # Jorrit N. Herder +set -e + case $# in # Display help ... @@ -36,6 +38,7 @@ case $# in : < "$f" || exit o=`expr "$f" : '\(.*\)\..*'`.o + o=`basename $o` echo @@ -43,6 +46,8 @@ case $# in sed -e '/^#/!d s/.*"\(.*\)".*/\1/ s:^\./::' \ + -e '/^$/d' \ + -e '/^$/d' \ -e "s:^:$o\: :" | \ sort -u done diff --git a/commands/simple/Makefile b/commands/simple/Makefile index e12b78d16..f1d7327c3 100644 --- a/commands/simple/Makefile +++ b/commands/simple/Makefile @@ -465,7 +465,7 @@ in.rshd: in.rshd.c @install -S 8kw $@ installx: install.c # Note: avoided confict with 'install' rule. - $(CCLD) -o $@ $< + $(CCLD) -o $@ install.c intr: intr.c $(CCLD) -o $@ intr.c @@ -1123,617 +1123,618 @@ install: \ # /usr/bin/add_route: add_route - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/del_route: /usr/bin/add_route - install -l $< $@ + install -l $> $@ /usr/bin/arp: arp - install -cs -o root -m 4755 $< $@ + install -cs -o root -m 4755 $> $@ /usr/bin/at: at - install -cs -o root -m 4755 $< $@ + install -cs -o root -m 4755 $> $@ /usr/bin/backup: backup - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/restore: /usr/bin/backup - install -l $< $@ + install -l $> $@ /usr/bin/badblocks: badblocks - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/banner: banner - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/basename: basename - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/cal: cal - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/calendar: calendar - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/cat: cat - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/cdiff: cdiff - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/cdprobe: cdprobe - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/cgrep: cgrep - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/chmem: chmem - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/chmod: chmod - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/chown: chown - install -cs -o bin $< $@ + install -cs -o bin $> $@ /bin/chroot: chroot - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/chgrp: /usr/bin/chown - install -l $< $@ + install -l $> $@ /usr/bin/ci: ci - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/cksum: cksum - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/cleantmp: cleantmp - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/cmp: cmp - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/co: co - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/comm: comm - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/compress: compress - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/uncompress /usr/bin/zcat: /usr/bin/compress - install -l $< $@ + install -l $> $@ /bin/cp: cp - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/cp: cp - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/clone /usr/bin/cpdir \ /usr/bin/ln /usr/bin/mv /usr/bin/rm: /usr/bin/cp - install -l $< $@ + install -l $> $@ /bin/ln /bin/mv /bin/rm: /bin/cp - install -l $< $@ + install -l $> $@ /usr/bin/crc: crc - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/cut: cut - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/dd: dd - install -cs -o bin $< $@ + install -cs -o bin $> $@ /bin/dev2name: dev2name - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/devsize: devsize - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/decomp16: decomp16 - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/df: df - install -cs -o root -m 4755 $< $@ + install -cs -o root -m 4755 $> $@ /usr/bin/dhrystone: dhrystone - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/diff: diff - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/dirname: dirname - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/du: du - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/dumpcore: dumpcore - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/ed: ed - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/eject: eject - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/env: env - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/expand: expand - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/factor: factor - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/fgrep: fgrep - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/file: file - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/find: find - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/finger: finger - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/fix: fix - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/fold: fold - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/fortune: fortune - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/fsck: fsck - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/fsck1: fsck1 - install -cs -o bin $< $@ + install -cs -o bin $> $@ /bin/getty: getty - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/getty: getty - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/gomoku: gomoku - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/grep: grep - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/egrep: /usr/bin/grep - install -l $< $@ + install -l $> $@ /usr/bin/head: head - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/host: host - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/hostaddr: hostaddr - install -cs -o root -m 4755 $< $@ + install -cs -o root -m 4755 $> $@ /usr/bin/id: id - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/ifconfig: ifconfig - install -cs -o root -m 4755 $< $@ + install -cs -o root -m 4755 $> $@ /usr/bin/ifdef: ifdef - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/in.fingerd: in.fingerd - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/in.rshd: in.rshd - install -cs -o bin $< $@ + install -cs -o bin $> $@ /bin/install: installx - install -cs -o root -m 4755 $< $@ + install -cs -o root -m 4755 $> $@ /usr/bin/install: installx - install -cs -o root -m 4755 $< $@ + install -cs -o root -m 4755 $> $@ /usr/bin/intr: intr - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/ipcs: ipcs - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/ipcrm: ipcrm - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/irdpd: irdpd - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/isoread: isoread - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/isodir /usr/bin/isoinfo: /usr/bin/isoread - install -l $< $@ + install -l $> $@ /usr/bin/join: join - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/kill: kill - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/last: last - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/uptime: /usr/bin/last - install -l $< $@ + install -l $> $@ /usr/bin/leave: leave - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/life: life - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/loadramdisk: loadramdisk - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/login: login - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/look: look - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/lp: lp - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/lpd: lpd - install -cs -o daemon -m 4755 $< $@ + install -cs -o daemon -m 4755 $> $@ /usr/bin/ls: ls - install -cs -o bin $< $@ + install -cs -o bin $> $@ /bin/ls: ls - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/lspci: lspci - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/mail: mail - install -cs -o root -m 4755 $< $@ + install -cs -o root -m 4755 $> $@ /usr/bin/man: man - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/mesg: mesg - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/mkdir: mkdir - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/mkfifo: mkfifo - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/mkfs: mkfs - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/mknod: mknod - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/mkproto: mkproto - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/modem: modem - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/mount: mount - install -cs -o root -m 4755 $< $@ + install -cs -o root -m 4755 $> $@ /usr/bin/mt: mt - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/newroot: newroot - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/nm: nm - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/nice: nice - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/nohup: nohup - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/nonamed: nonamed - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/od: od - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/passwd: passwd - install -cs -o root -m 4755 $< $@ + install -cs -o root -m 4755 $> $@ /usr/bin/chfn /usr/bin/chsh: /usr/bin/passwd - install -l $< $@ + install -l $> $@ /usr/bin/paste: paste - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/ping: ping - install -cs -o root -m 4755 $< $@ + install -cs -o root -m 4755 $> $@ /usr/bin/pr: pr - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/pr_routes: pr_routes - install -cs -o root -m 4755 $< $@ + install -cs -o root -m 4755 $> $@ /usr/bin/progressbar: progressbar - install -cs -o root -m 755 $< $@ + install -cs -o root -m 755 $> $@ /usr/bin/prep: prep - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/printf: printf - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/printenv: /usr/bin/env install -ls -o bin /usr/bin/env /usr/bin/printenv /usr/bin/printroot: printroot - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/proto: proto - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/pwd: pwd - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/lib/pwdauth: pwdauth - install -cs -o root -m 4755 $< $@ + install -cs -o root -m 4755 $> $@ /usr/bin/ramdisk: ramdisk - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/rarpd: rarpd - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/rcp: rcp - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/rawspeed: rawspeed - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/rdate: rdate - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/readall: readall - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/readlink: /usr/bin/stat - install -l $< $@ + install -l $> $@ /usr/bin/readfs: readfs - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/remsync: remsync - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/rev: rev - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/rget: rget - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/rput: /usr/bin/rget - install -l $< $@ + install -l $> $@ /usr/bin/rlogin: rlogin - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/rmdir: rmdir - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/rsh: rsh - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/sed: sed - install -cs -o bin $< $@ + install -cs -o bin $> $@ /bin/sed: sed - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/shar: shar - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/size: size - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/sleep: sleep - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/slip: slip - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/sort: sort - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/split: split - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/stat: stat - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/fstat: /usr/bin/stat - install -l $< $@ + install -l $> $@ /usr/bin/strings: strings - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/strip: strip - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/stty: stty - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/su: su - install -cs -o root -m 4755 $< $@ + install -cs -o root -m 4755 $> $@ /usr/bin/sum: sum - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/swapfs: swapfs - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/sync: sync - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/synctree: synctree - install -cs -o bin $< $@ + install -cs -o bin $> $@ /bin/sysenv: sysenv - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/sysenv: sysenv - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/tail: tail - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/tar: tar - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/tcpd: tcpd - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/tcpdp: tcpdp - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/tcpstat: tcpstat - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/tee: tee - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/term: term - install -cs -o bin -g uucp -m 2755 $< $@ + install -cs -o bin -g uucp -m 2755 $> $@ /usr/bin/termcap: termcap - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/tget: tget - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/time: time - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/top: top - install -cs -o root -m 4755 $< $@ + install -cs -o root -m 4755 $> $@ /usr/bin/touch: touch - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/tr: tr - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/truncate: truncate - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/tsort: tsort - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/ttt: ttt - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/tty: tty - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/udpstat: udpstat - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/umount: umount - install -cs -o root -m 4755 $< $@ + install -cs -o root -m 4755 $> $@ /usr/bin/uname: uname - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/arch: /usr/bin/uname - install -l $< $@ + install -l $> $@ /usr/bin/unexpand: unexpand - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/uniq: uniq - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/update: update - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/uud: uud - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/uudecode: /usr/bin/uud - install -l $< $@ + install -l $> $@ /usr/bin/uue: uue - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/uuencode: /usr/bin/uue - install -l $< $@ + install -l $> $@ /usr/bin/vol: vol - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/wc: wc - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/which: which - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/who: who - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/whoami: whoami - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/write: write - install -cs -o bin -g tty -m 2755 $< $@ + install -cs -o bin -g tty -m 2755 $> $@ /usr/bin/writeisofs: writeisofs - install -cs -S 2M -o bin $< $@ + install -cs -S 2M -o bin $> $@ /usr/bin/xargs: xargs - install -cs -o bin $< $@ + install -cs -o bin $> $@ /usr/bin/yes: yes - install -cs -o bin $< $@ + install -cs -o bin $> $@ /bin/cat: /usr/bin/cat - install -lcs $< $@ + install -lcs $> $@ /bin/fsck: /usr/bin/fsck - install -lcs $< $@ + install -lcs $> $@ /bin/intr: /usr/bin/intr - install -lcs $< $@ + install -lcs $> $@ /bin/mount: /usr/bin/mount - install -lcs $< $@ + install -lcs $> $@ /bin/printroot: /usr/bin/printroot - install -lcs $< $@ + install -lcs $> $@ /bin/pwd: /usr/bin/pwd - install -lcs $< $@ + install -lcs $> $@ /bin/sync: /usr/bin/sync - install -lcs $< $@ + install -lcs $> $@ /bin/umount: /usr/bin/umount - install -lcs $< $@ + install -lcs $> $@ clean: rm -rf $(ALL) a.out core + diff --git a/docs/UPDATING b/docs/UPDATING index e980e1985..a5e84ed31 100644 --- a/docs/UPDATING +++ b/docs/UPDATING @@ -1,3 +1,13 @@ +20100215: + Make(1) has been replaced: Run 'make install' in commands/make + Mkdep updates: Copy commands/scripts/mkdep.sh to /usr/bin/mkdep + Make(1) needs mkfiles: Copy files in etc/mk to /etc/mk + ACK update: Copy commands/i386/acd.descr to /usr/lib/descr + End.a renamed: + -Copy /usr/lib/i86/end.a to /usr/lib/i86/libend.a + -Copy /usr/lib/i386/end.a to /usr/lib/i386/libend.a + -Copy /usr/gnu/lib/end.a to /usr/gnu/lib/libend.a + Asmconv updates: Run 'make install' in commands/i386/asmconv 20091212: /etc/drivers.conf has been renamed to /etc/system.conf. user "service" has been added to password file /etc/passwd. diff --git a/drivers/amddev/Makefile b/drivers/amddev/Makefile index c231b2b55..7a10e6156 100644 --- a/drivers/amddev/Makefile +++ b/drivers/amddev/Makefile @@ -27,6 +27,4 @@ clean: depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend -# Include generated dependencies. -include .depend diff --git a/drivers/at_wini/Makefile b/drivers/at_wini/Makefile index 333a9459e..b8494e1dc 100644 --- a/drivers/at_wini/Makefile +++ b/drivers/at_wini/Makefile @@ -38,6 +38,4 @@ clean: depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c ../libdriver/*.c > .depend -# Include generated dependencies. -include .depend diff --git a/drivers/atl2/Makefile b/drivers/atl2/Makefile index e97dfd40e..f3f392874 100644 --- a/drivers/atl2/Makefile +++ b/drivers/atl2/Makefile @@ -34,7 +34,3 @@ clean: depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend - -# Include generated dependencies. -include .depend - diff --git a/drivers/audio/es1370/Makefile b/drivers/audio/es1370/Makefile index 828a415ca..c6f2d6a34 100644 --- a/drivers/audio/es1370/Makefile +++ b/drivers/audio/es1370/Makefile @@ -34,6 +34,4 @@ clean: depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend -# Include generated dependencies. -include .depend diff --git a/drivers/audio/es1371/Makefile b/drivers/audio/es1371/Makefile index db5df78a3..8b6f2fdce 100644 --- a/drivers/audio/es1371/Makefile +++ b/drivers/audio/es1371/Makefile @@ -51,6 +51,4 @@ depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend -# Include generated dependencies. -include .depend diff --git a/drivers/audio/sb16/Makefile b/drivers/audio/sb16/Makefile index ae892173d..f95bbb7e6 100644 --- a/drivers/audio/sb16/Makefile +++ b/drivers/audio/sb16/Makefile @@ -36,6 +36,4 @@ clean: depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend -# Include generated dependencies. -include .depend diff --git a/drivers/bios_wini/Makefile b/drivers/bios_wini/Makefile index f0ff487e8..52ae04735 100644 --- a/drivers/bios_wini/Makefile +++ b/drivers/bios_wini/Makefile @@ -36,6 +36,4 @@ clean: depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c ../libdriver/*.c > .depend -# Include generated dependencies. -include .depend diff --git a/drivers/dec21140A/Makefile b/drivers/dec21140A/Makefile index 94abfd6a4..873b05516 100644 --- a/drivers/dec21140A/Makefile +++ b/drivers/dec21140A/Makefile @@ -37,7 +37,3 @@ depend: ## Clean directory clean: @rm -f $(DRIVER) *.o *.BAK *~ - -include .depend - -## end diff --git a/drivers/dp8390/Makefile b/drivers/dp8390/Makefile index 08a02c1b1..79c33642f 100644 --- a/drivers/dp8390/Makefile +++ b/drivers/dp8390/Makefile @@ -35,6 +35,4 @@ clean: depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend -# Include generated dependencies. -include .depend diff --git a/drivers/dpeth/Makefile b/drivers/dpeth/Makefile index 81f9db26a..60475181c 100644 --- a/drivers/dpeth/Makefile +++ b/drivers/dpeth/Makefile @@ -38,6 +38,5 @@ depend: clean: @rm -f $(DRIVER) *.o *.BAK -include .depend ## end diff --git a/drivers/e1000/Makefile b/drivers/e1000/Makefile index 2d5506a3d..127dfd88a 100644 --- a/drivers/e1000/Makefile +++ b/drivers/e1000/Makefile @@ -40,5 +40,3 @@ clean: depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend -# Include generated dependencies. -include .depend diff --git a/drivers/filter/Makefile b/drivers/filter/Makefile index ab231958c..6ae37a588 100644 --- a/drivers/filter/Makefile +++ b/drivers/filter/Makefile @@ -26,6 +26,4 @@ clean: depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend -# Include generated dependencies. -include .depend diff --git a/drivers/floppy/Makefile b/drivers/floppy/Makefile index e690291fd..5747b4633 100644 --- a/drivers/floppy/Makefile +++ b/drivers/floppy/Makefile @@ -36,6 +36,4 @@ clean: depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c ../libdriver/*.c > .depend -# Include generated dependencies. -include .depend diff --git a/drivers/fxp/Makefile b/drivers/fxp/Makefile index 3850d3502..af4a37e26 100644 --- a/drivers/fxp/Makefile +++ b/drivers/fxp/Makefile @@ -35,6 +35,4 @@ clean: depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend -# Include generated dependencies. -include .depend diff --git a/drivers/lance/Makefile b/drivers/lance/Makefile index 6995bb47d..ec7dd19b2 100644 --- a/drivers/lance/Makefile +++ b/drivers/lance/Makefile @@ -36,5 +36,3 @@ clean: depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend -# Include generated dependencies. -include .depend diff --git a/drivers/libdriver/Makefile b/drivers/libdriver/Makefile index c88984a15..c9b944d9e 100644 --- a/drivers/libdriver/Makefile +++ b/drivers/libdriver/Makefile @@ -29,6 +29,4 @@ clean: depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend -# Include generated dependencies. -include .depend diff --git a/drivers/log/Makefile b/drivers/log/Makefile index eecdc5e69..672e18ad9 100644 --- a/drivers/log/Makefile +++ b/drivers/log/Makefile @@ -26,7 +26,7 @@ $(DRIVER): $(OBJ) $(LIB_DEP) # install with other drivers install: $(DRIVER) - install -o root -cs $< /sbin/$(DRIVER) + install -o root -cs $(DRIVER) /sbin/$(DRIVER) # clean up local files clean: @@ -36,6 +36,4 @@ clean: depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c ../libdriver/*.c > .depend -# Include generated dependencies. -include .depend diff --git a/drivers/memory/Makefile b/drivers/memory/Makefile index d27a36472..b124a4db9 100644 --- a/drivers/memory/Makefile +++ b/drivers/memory/Makefile @@ -53,6 +53,4 @@ depend: mkdep "$(CC) -E $(CPPFLAGS)" memory.c ../libdriver/*.c > .depend cd ramdisk && make depend -# Include generated dependencies. -include .depend diff --git a/drivers/memory/ramdisk/Makefile b/drivers/memory/ramdisk/Makefile index 5f1b0bd0f..ea7a043f5 100644 --- a/drivers/memory/ramdisk/Makefile +++ b/drivers/memory/ramdisk/Makefile @@ -109,6 +109,4 @@ depend: proto.gen: $(MAKEDEV) proto.sh proto sh -e proto.sh >proto.gen -# Include generated dependencies. -include .depend diff --git a/drivers/orinoco/Makefile b/drivers/orinoco/Makefile index 9a1d8900b..337dcc89d 100644 --- a/drivers/orinoco/Makefile +++ b/drivers/orinoco/Makefile @@ -35,8 +35,6 @@ clean: depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend -# Include generated dependencies. -include .depend diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile index 60d1fd6f8..e655e56dc 100644 --- a/drivers/pci/Makefile +++ b/drivers/pci/Makefile @@ -35,6 +35,4 @@ clean: depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend -# Include generated dependencies. -include .depend diff --git a/drivers/printer/Makefile b/drivers/printer/Makefile index b3a9d8c7f..5150b8073 100644 --- a/drivers/printer/Makefile +++ b/drivers/printer/Makefile @@ -36,6 +36,4 @@ clean: depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend -# Include generated dependencies. -include .depend diff --git a/drivers/random/Makefile b/drivers/random/Makefile index 3d4056b79..81b52ec82 100644 --- a/drivers/random/Makefile +++ b/drivers/random/Makefile @@ -44,6 +44,4 @@ clean: depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c ../libdriver/*.c aes/*.c > .depend -# Include generated dependencies. -include .depend diff --git a/drivers/readclock/Makefile b/drivers/readclock/Makefile index 73867d175..193631198 100644 --- a/drivers/readclock/Makefile +++ b/drivers/readclock/Makefile @@ -28,6 +28,4 @@ clean: depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend -# Include generated dependencies. -include .depend diff --git a/drivers/rtl8139/Makefile b/drivers/rtl8139/Makefile index 49d2df802..f9b2469ba 100644 --- a/drivers/rtl8139/Makefile +++ b/drivers/rtl8139/Makefile @@ -36,6 +36,4 @@ clean: depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend -# Include generated dependencies. -include .depend diff --git a/drivers/rtl8169/Makefile b/drivers/rtl8169/Makefile index 0d9403a60..a08159b27 100644 --- a/drivers/rtl8169/Makefile +++ b/drivers/rtl8169/Makefile @@ -36,6 +36,4 @@ clean: depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend -# Include generated dependencies. -include .depend diff --git a/drivers/sb16/Makefile b/drivers/sb16/Makefile index 73c76a07a..59e749b33 100644 --- a/drivers/sb16/Makefile +++ b/drivers/sb16/Makefile @@ -36,6 +36,4 @@ clean: depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend -# Include generated dependencies. -include .depend diff --git a/drivers/ti1225/Makefile b/drivers/ti1225/Makefile index b197db5dd..43e21e174 100644 --- a/drivers/ti1225/Makefile +++ b/drivers/ti1225/Makefile @@ -35,6 +35,4 @@ clean: depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend -# Include generated dependencies. -include .depend diff --git a/drivers/tty/Makefile b/drivers/tty/Makefile index 4d42d0ce5..9e819ca28 100644 --- a/drivers/tty/Makefile +++ b/drivers/tty/Makefile @@ -42,7 +42,5 @@ clean: depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend -# Include generated dependencies. -include .depend diff --git a/etc/Makefile b/etc/Makefile index 6d39701df..5cdd2d0ec 100644 --- a/etc/Makefile +++ b/etc/Makefile @@ -7,6 +7,7 @@ FILES1=fstab group hostname.file inet.conf motd.install mtab passwd profile \ rs.inet rs.single make.conf system.conf FILES2=shadow FILES3=daily dhcptags.conf rc +DIR1=mk all:: @@ -17,6 +18,7 @@ install:: mkdir -p $(ETC) @for f in $(FILES1); do if [ -f $(ETC)/$$f ]; then :; else cp $$f $(ETC)/$$f; chmod 755 $(ETC)/$$f; fi; done @for f in $(FILES2); do if [ -f $(ETC)/$$f ]; then :; else cp $$f $(ETC)/$$f; chmod 600 $(ETC)/$$f; fi; done + @for d in $(DIR1); do if [ -d $(ETC)/$$d ]; then :; else cp -r $$d $(ETC)/; chmod -r 755 $(ETC)/$$d; fi; done @echo "Making hierarchy.." sh mtree.sh mtree/minix.tree @for f in $(FILES3); do if [ -f $(USRETC)/$$f ]; then :; else cp usr/$$f $(USRETC); chmod 755 $(USRETC)/$$f; fi; done diff --git a/etc/mk/minix.ack.mk b/etc/mk/minix.ack.mk new file mode 100644 index 000000000..d2fef931f --- /dev/null +++ b/etc/mk/minix.ack.mk @@ -0,0 +1,10 @@ +.SUFFIXES: .o .e + +# Treated like a C file +.e.o: + ${_MKTARGET_COMPILE} + ${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET} +# .if !defined(CFLAGS) || empty(CFLAGS:M*-g*) +# ${OBJCOPY} -x ${.TARGET} +# .endif + diff --git a/etc/mk/minix.dep.mk b/etc/mk/minix.dep.mk new file mode 100644 index 000000000..95be53edb --- /dev/null +++ b/etc/mk/minix.dep.mk @@ -0,0 +1,88 @@ +# $NetBSD: bsd.dep.mk,v 1.68 2008/10/25 22:27:36 apb Exp $ + +##### Basic targets +cleandir: cleandepend +realdepend: beforedepend .depend afterdepend +.ORDER: beforedepend .depend afterdepend + +beforedepend .depend afterdepend: # ensure existence + +##### Default values +MKDEP?= mkdep +MKDEP_SUFFIXES?= .o + +##### Build rules +# some of the rules involve .h sources, so remove them from mkdep line + +.if defined(SRCS) # { +_TRADITIONAL_CPP?=-traditional-cpp +__acpp_flags= ${_TRADITIONAL_CPP} + +__DPSRCS.all= ${SRCS:C/\.(c|m|s|S|C|cc|cpp|cxx)$/.d/} \ + ${DPSRCS:C/\.(c|m|s|S|C|cc|cpp|cxx)$/.d/} +__DPSRCS.d= ${__DPSRCS.all:O:u:M*.d} +__DPSRCS.notd= ${__DPSRCS.all:O:u:N*.d} + +.NOPATH: .depend ${__DPSRCS.d} + +.if !empty(__DPSRCS.d) # { +${__DPSRCS.d}: ${__DPSRCS.notd} ${DPSRCS} +.endif # } + +.depend: ${__DPSRCS.d} + ${_MKTARGET_CREATE} + rm -f .depend +# ${MKDEP} -d -f ${.TARGET} -s ${MKDEP_SUFFIXES:Q} ${__DPSRCS.d} + cat ${__DPSRCS.d} > ${.TARGET} + +.SUFFIXES: .d .s .S .c .C .cc .cpp .cxx .m + +.c.d: + ${_MKTARGET_CREATE} +# ${MKDEP} -f ${.TARGET} -- ${MKDEPFLAGS} \ +# ${CFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ +# ${CPPFLAGS} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} +# mkdep -- ${MKDEPFLAGS} \ +# ${CFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ +# ${CPPFLAGS} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} > ${.TARGET} + mkdep "$(CC) ${CFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ + ${CPPFLAGS} ${CPPFLAGS.${.IMPSRC:T}} -E" ${.IMPSRC} > ${.TARGET} + +# .m.d: +# ${_MKTARGET_CREATE} +# ${MKDEP} -f ${.TARGET} -- ${MKDEPFLAGS} \ +# ${OBJCFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ +# ${CPPFLAGS} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} + +.s.d .S.d: + ${_MKTARGET_CREATE} +# ${MKDEP} -f ${.TARGET} -- ${MKDEPFLAGS} \ +# ${AFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ +# ${CPPFLAGS} ${CPPFLAGS.${.IMPSRC:T}} ${__acpp_flags} ${.IMPSRC} + mkdep "$(CC) ${AFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ + ${CPPFLAGS} ${CPPFLAGS.${.IMPSRC:T}} -E" ${.IMPSRC} > ${.TARGET} + +# .C.d .cc.d .cpp.d .cxx.d: +# ${_MKTARGET_CREATE} +# ${MKDEP} -f ${.TARGET} -- ${MKDEPFLAGS} \ +# ${CXXFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ +# ${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEMXX} \ +# ${DESTDIR}/usr/include/g++} \ +# ${CPPFLAGS} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} + +.endif # defined(SRCS) # } + +##### Clean rules +cleandepend: .PHONY +.if defined(SRCS) + rm -f .depend ${__DPSRCS.d} ${.CURDIR}/tags ${CLEANDEPEND} +.endif + +##### Custom rules +# .if !target(tags) +# tags: ${SRCS} +# .if defined(SRCS) +# -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC:N*.h} | \ +# ${TOOL_SED} "s;\${.CURDIR}/;;" > tags +# .endif +# .endif diff --git a/etc/mk/minix.files.mk b/etc/mk/minix.files.mk new file mode 100644 index 000000000..f853b610d --- /dev/null +++ b/etc/mk/minix.files.mk @@ -0,0 +1,161 @@ +# $NetBSD: bsd.files.mk,v 1.40 2008/12/05 18:51:16 cube Exp $ + +.if !defined(_MINIX_FILES_MK_) +_MINIX_FILES_MK_=1 + +.include + +.if !target(__fileinstall) +##### Basic targets +realinstall: filesinstall +realall: filesbuild + +##### Default values +FILESDIR?= ${BINDIR} +FILESOWN?= ${BINOWN} +FILESGRP?= ${BINGRP} +FILESMODE?= ${NONBINMODE} + +##### Build rules +filesbuild: +.PHONY: filesbuild + +##### Install rules +filesinstall:: # ensure existence +.PHONY: filesinstall + +configfilesinstall:: .PHONY + +__fileinstall: .USE + ${_MKTARGET_INSTALL} + ${INSTALL_FILE} \ + -o ${FILESOWN_${.ALLSRC:T}:U${FILESOWN}} \ + -g ${FILESGRP_${.ALLSRC:T}:U${FILESGRP}} \ + -m ${FILESMODE_${.ALLSRC:T}:U${FILESMODE}} \ + ${SYSPKGTAG} ${.ALLSRC} ${.TARGET} + +.endif # !target(__fileinstall) + + +.for F in ${FILES:O:u} +_FDIR:= ${FILESDIR_${F}:U${FILESDIR}} # dir override +_FNAME:= ${FILESNAME_${F}:U${FILESNAME:U${F:T}}} # name override +_F:= ${DESTDIR}${_FDIR}/${_FNAME} # installed path +_FDOBUILD:= ${FILESBUILD_${F}:Uno} + +.if ${MKUPDATE} == "no" +${_F}! ${F} __fileinstall # install rule +.if !defined(BUILD) && !make(all) && !make(${F}) && (${_FDOBUILD} == "no") +${_F}! .MADE # no build at install +.endif +.else +${_F}: ${F} __fileinstall # install rule +.if !defined(BUILD) && !make(all) && !make(${F}) && (${_FDOBUILD} == "no") +${_F}: .MADE # no build at install +.endif +.endif + +.if ${_FDOBUILD} != "no" +filesbuild: ${F} +CLEANFILES+= ${F} +.endif + +filesinstall:: ${_F} +.PRECIOUS: ${_F} # keep if install fails +.endfor + + +# +# CONFIGFILES +# +configinstall: configfilesinstall + +.for F in ${CONFIGFILES:O:u} +_FDIR:= ${FILESDIR_${F}:U${FILESDIR}} # dir override +_FNAME:= ${FILESNAME_${F}:U${FILESNAME:U${F:T}}} # name override +_F:= ${DESTDIR}${_FDIR}/${_FNAME} # installed path +_FDOBUILD:= ${FILESBUILD_${F}:Uno} + +.if ${MKUPDATE} == "no" +${_F}! ${F} __fileinstall # install rule +.if !defined(BUILD) && !make(all) && !make(${F}) && (${_FDOBUILD} == "no") +${_F}! .MADE # no build at install +.endif +.else +${_F}: ${F} __fileinstall # install rule +.if !defined(BUILD) && !make(all) && !make(${F}) && (${_FDOBUILD} == "no") +${_F}: .MADE # no build at install +.endif +.endif + +.if ${_FDOBUILD} != "no" +filesbuild: ${F} +CLEANFILES+= ${F} +.endif + +configfilesinstall:: ${_F} +.PRECIOUS: ${_F} # keep if install fails +.endfor + +.undef _FDIR +.undef _FNAME +.undef _F + + +# +# BUILDSYMLINKS +# +.if defined(BUILDSYMLINKS) # { + +.for _SL _TL in ${BUILDSYMLINKS} +BUILDSYMLINKS.s+= ${_SL} +BUILDSYMLINKS.t+= ${_TL} +${_TL}: ${_SL} + ${_MKMSG} "symlink " ${.CURDIR:T}/${.TARGET} + rm -f ${.TARGET} + ln -s ${.ALLSRC} ${.TARGET} +.endfor + +realall: ${BUILDSYMLINKS.t} + +cleandir: cleanbuildsymlinks +cleanbuildsymlinks: .PHONY + rm -f ${BUILDSYMLINKS.t} + +.endif # } + +# +# .uue -> "" handling (i.e. decode a given binary/object) +# +# UUDECODE_FILES - List of files which are stored in the source tree +# as .uue and should be uudecoded. +# +# UUDECODE_FILES_RENAME_fn - For this file, rename its output to the provided +# name (handled via -p and redirecting stdout) + +.if defined(UUDECODE_FILES) # { +.SUFFIXES: .uue + +.uue: + ${_MKTARGET_CREATE} + rm -f ${.TARGET} ${.TARGET}.tmp + ${TOOL_UUDECODE} -p ${.IMPSRC} > ${.TARGET}.tmp \ + && mv ${.TARGET}.tmp ${UUDECODE_FILES_RENAME_${.TARGET}:U${.TARGET}} + +realall: ${UUDECODE_FILES} + +CLEANUUDECODE_FILES=${UUDECODE_FILES} ${UUDECODE_FILES:=.tmp} +.for i in ${UUDECODE_FILES} +CLEANUUDECODE_FILES+=${UUDECODE_FILES_RENAME_${i}} +.endfor + +clean: cleanuudecodefiles +cleanuudecodefiles: .PHONY + rm -f ${CLEANUUDECODE_FILES} +.endif # } + +##### Pull in related .mk logic +.include +#.include + +.endif # !defined(_MINIX_FILES_MK_) diff --git a/etc/mk/minix.gcc.mk b/etc/mk/minix.gcc.mk new file mode 100644 index 000000000..02ce960c4 --- /dev/null +++ b/etc/mk/minix.gcc.mk @@ -0,0 +1,19 @@ +.SUFFIXES: .o .s .gs + +ASMCONV=asmconv +CPP.s=${CC} ${AFLAGS} -E -x assembler-with-cpp +ASMCONVFLAGS+=-mi386 ack gnu +ASSEMBLE=gas ${AFLAGS} + +# Need to convert ACK assembly files to GNU assembly before building +.s.o: + ${_MKTARGET_COMPILE} + ${CPP.s} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.PREFIX}.ack.s + ${ASMCONV} ${ASMCONVFLAGS} ${.PREFIX}.ack.s ${.PREFIX}.gnu.s + ${COMPILE.s} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.PREFIX}.gnu.s -o ${.TARGET} + rm -rf ${.PREFIX}.ack.s ${.PREFIX}.gnu.s + +# GNU Assembly file +.gs.o: + ${_MKTARGET_COMPILE} + ${ASSEMBLE} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET} diff --git a/etc/mk/minix.init.mk b/etc/mk/minix.init.mk new file mode 100644 index 000000000..258388b60 --- /dev/null +++ b/etc/mk/minix.init.mk @@ -0,0 +1,13 @@ +# $NetBSD: bsd.init.mk,v 1.2 2003/07/28 02:38:33 lukem Exp $ + +# includes Makefile.inc and ; this is used at the +# top of all files which actually "build something". + +.if !defined(_MINIX_INIT_MK_) +_MINIX_INIT_MK_=1 + +.-include "${.CURDIR}/../Makefile.inc" +.include +.MAIN: all + +.endif # !defined(_MINIX_INIT_MK_) diff --git a/etc/mk/minix.lib.mk b/etc/mk/minix.lib.mk new file mode 100644 index 000000000..5e80832c7 --- /dev/null +++ b/etc/mk/minix.lib.mk @@ -0,0 +1,142 @@ +# $NetBSD: bsd.lib.mk,v 1.299 2009/11/27 11:44:36 tsutsui Exp $ +# @(#)bsd.lib.mk 8.3 (Berkeley) 4/22/94 + +.include + +# Pull in here so we can override its .c.o rule +.include + +##### Basic targets +.PHONY: libinstall +realinstall: libinstall +clean: cleanlib + + +##### LIB specific flags. +COPTS+= ${COPTS.lib${LIB}} +CPPFLAGS+= ${CPPFLAGS.lib${LIB}} +CXXFLAGS+= ${CXXFLAGS.lib${LIB}} +OBJCOPTS+= ${OBJCOPTS.lib${LIB}} +LDADD+= ${LDADD.lib${LIB}} +LDFLAGS+= ${LDFLAGS.lib${LIB}} +LDSTATIC+= ${LDSTATIC.lib${LIB}} + +##### Libraries that this may depend upon. +.if defined(LIBDPLIBS) && ${MKPIC} != "no" # { +.for _lib _dir in ${LIBDPLIBS} +.if !defined(LIBDO.${_lib}) +LIBDO.${_lib}!= cd ${_dir} && ${PRINTOBJDIR} +.MAKEOVERRIDES+=LIBDO.${_lib} +.endif +LDADD+= -L${LIBDO.${_lib}} -l${_lib} +DPADD+= ${LIBDO.${_lib}}/lib${_lib}.so +.endfor +.endif # } + +##### Build and install rules +MKDEP_SUFFIXES?= .o .po .so .go .ln + +# add additional suffixes not exported. +# .po is used for profiling object files. +# .so is used for PIC object files. +.SUFFIXES: .out .a .ln .so .po .go .o .s .S .c .cc .cpp .cxx .C .m .F .f .r .y .l .cl .p .h + +CFLAGS+= ${COPTS} +OBJCFLAGS+= ${OBJCOPTS} +AFLAGS+= ${COPTS} +FFLAGS+= ${FOPTS} + +.c.o: + ${_MKTARGET_COMPILE} + ${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET} +# .if !defined(CFLAGS) || empty(CFLAGS:M*-g*) +# ${OBJCOPY} -x ${.TARGET} +# .endif + +.cc.o .cpp.o .cxx.o .C.o: + ${_MKTARGET_COMPILE} + ${COMPILE.cc} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET} +# .if !defined(CFLAGS) || empty(CFLAGS:M*-g*) +# ${OBJCOPY} -x ${.TARGET} +# .endif + +.s.o: + ${_MKTARGET_COMPILE} + ${COMPILE.s} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET} +# ${OBJCOPY} -x ${.TARGET} + +.S.o: + ${_MKTARGET_COMPILE} + ${COMPILE.S} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} -o ${.TARGET} +# ${OBJCOPY} -x ${.TARGET} + + +.if defined(LIB) # { +_LIBS=lib${LIB}.a +.endif + +OBJS+=${SRCS:N*.h:N*.sh:R:S/$/.o/g} + +STOBJS+=${OBJS} + +LOBJS+=${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln} + +ALLOBJS= + +ALLOBJS+=${STOBJS} + +_YLSRCS= ${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}} + +.NOPATH: ${ALLOBJS} ${_LIBS} ${_YLSRCS} + +realall: ${SRCS} ${ALLOBJS:O} ${_LIBS} + +MKARZERO?=no + +#_ARFL=crs +_ARFL=cr + + +__archivebuild: .USE + ${_MKTARGET_BUILD} + rm -f ${.TARGET} +# ${AR} ${_ARFL} ${.TARGET} `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}` + ${AR} ${_ARFL} ${.TARGET} ${.ALLSRC:M*o} + +__archiveinstall: .USE + ${_MKTARGET_INSTALL} + ${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + ${_INSTRANLIB} ${.ALLSRC} ${.TARGET} + +DPSRCS+= ${_YLSRCS} +CLEANFILES+= ${_YLSRCS} + +${STOBJS} ${POBJS} ${GOBJS} ${SOBJS} ${LOBJS}: ${DPSRCS} + +lib${LIB}.a:: ${STOBJS} __archivebuild + +cleanlib: .PHONY + rm -f a.out [Ee]rrs mklog core *.core ${CLEANFILES} + rm -f lib${LIB}.a ${STOBJS} + + +libinstall:: ${DESTDIR}${LIBDIR}/lib${LIB}.a +.PRECIOUS: ${DESTDIR}${LIBDIR}/lib${LIB}.a + ${_MKTARGET_INSTALL} + ${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + ${.ALLSRC} ${.TARGET} + +.if !defined(BUILD) && !make(all) && !make(lib${LIB}.a) +${DESTDIR}${LIBDIR}/lib${LIB}.a: .MADE +.endif +${DESTDIR}${LIBDIR}/lib${LIB}.a: lib${LIB}.a __archiveinstall + + +.include +.include + +.if (${COMPILER_TYPE} == ack) +.include +.elif (${COMPILER_TYPE} == gnu) +.include +.endif diff --git a/etc/mk/minix.obj.mk b/etc/mk/minix.obj.mk new file mode 100644 index 000000000..396906d57 --- /dev/null +++ b/etc/mk/minix.obj.mk @@ -0,0 +1,109 @@ +# $NetBSD: bsd.obj.mk,v 1.48 2007/12/11 14:06:04 lukem Exp $ + +.if !defined(_MINIX_OBJ_MK_) +_MINIX_OBJ_MK_=1 + +.include + +__curdir:= ${.CURDIR} + +.if ${MKOBJ} == "no" +obj: +.else +.if defined(MAKEOBJDIRPREFIX) || defined(MAKEOBJDIR) +.if defined(MAKEOBJDIRPREFIX) +__objdir:= ${MAKEOBJDIRPREFIX}${__curdir} +.else +__objdir:= ${MAKEOBJDIR} +.endif +# MAKEOBJDIR and MAKEOBJDIRPREFIX are env variables supported +# by make(1). We simply mkdir -p the specified path. +# If that fails - we do a mkdir to get the appropriate error message +# before bailing out. +obj: +.if defined(MAKEOBJDIRPREFIX) + @if [ ! -d ${MAKEOBJDIRPREFIX} ]; then \ + echo "MAKEOBJDIRPREFIX ${MAKEOBJDIRPREFIX} does not exist, bailing..."; \ + exit 1; \ + fi; +.endif + @if [ ! -d ${__objdir} ]; then \ + mkdir -p ${__objdir}; \ + if [ ! -d ${__objdir} ]; then \ + mkdir ${__objdir}; exit 1; \ + fi; \ + ${_MKSHMSG} " objdir ${__objdir}"; \ + fi +.else +PAWD?= /bin/pwd + +__objdir= obj${OBJMACHINE:D.${MACHINE}} + +__usrobjdir= ${BSDOBJDIR}${USR_OBJMACHINE:D.${MACHINE}} +__usrobjdirpf= ${USR_OBJMACHINE:D:U${OBJMACHINE:D.${MACHINE}}} + +.if defined(BUILDID) +__objdir:= ${__objdir}.${BUILDID} +__usrobjdirpf:= ${__usrobjdirpf}.${BUILDID} +__need_objdir_target=yes +.endif + +.if defined(OBJHOSTMACHINE) && (${MKHOSTOBJ:Uno} != "no") +# In case .CURDIR has been twiddled by a .mk file and is now relative, +# make it absolute again. +.if ${__curdir:M/*} == "" +__curdir!= cd ${__curdir} && ${PAWD} +.endif + +__objdir:= ${__objdir}.${HOST_OSTYPE} +__usrobjdirpf:= ${__usrobjdirpf}.${HOST_OSTYPE} +__need_objdir_target=yes +.endif + +.if defined(__need_objdir_target) +# Get make to change its internal definition of .OBJDIR +.OBJDIR: ${__objdir} +.endif + +obj: + @cd ${__curdir}; \ + here=`${PAWD}`/; subdir=$${here#${BSDSRCDIR}/}; \ + if [ "$$here" != "$$subdir" ]; then \ + if [ ! -d ${__usrobjdir} ]; then \ + echo "BSDOBJDIR ${__usrobjdir} does not exist, bailing..."; \ + exit 1; \ + fi; \ + subdir=$${subdir%/}; \ + dest=${__usrobjdir}/$$subdir${__usrobjdirpf}; \ + if [ -x ${TOOL_STAT} ] && \ + ttarg=`${TOOL_STAT} -qf '%Y' $${here}${__objdir}` && \ + [ "$$dest" = "$$ttarg" ]; then \ + : ; \ + else \ + ${_MKSHMSG} " objdir $$dest"; \ + rm -rf ${__objdir}; \ + ln -s $$dest ${__objdir}; \ + fi; \ + if [ ! -d $$dest ]; then \ + mkdir -p $$dest; \ + else \ + true; \ + fi; \ + else \ + true ; \ + dest=$${here}${__objdir} ; \ + if [ ! -d ${__objdir} ] || [ -h ${__objdir} ]; then \ + ${_MKSHMSG} " objdir $$dest"; \ + rm -f ${__objdir}; \ + mkdir $$dest; \ + fi ; \ + fi; +.endif +.endif + +print-objdir: + @echo ${.OBJDIR} + +.include + +.endif # !defined(_MINIX_OBJ_MK_) diff --git a/etc/mk/minix.own.mk b/etc/mk/minix.own.mk new file mode 100644 index 000000000..1e67be05e --- /dev/null +++ b/etc/mk/minix.own.mk @@ -0,0 +1,917 @@ +# $NetBSD: bsd.own.mk,v 1.603 2009/12/06 16:15:15 uebayasi Exp $ + +.if !defined(_MINIX_OWN_MK_) +_MINIX_OWN_MK_=1 + +MAKECONF?= /etc/mk.conf +.-include "${MAKECONF}" + +# +# CPU model, derived from MACHINE_ARCH +# +MACHINE_CPU= ${MACHINE_ARCH:C/mipse[bl]/mips/:C/mips64e[bl]/mips/:C/sh3e[bl]/sh3/:S/m68000/m68k/:S/armeb/arm/} + +# +# Subdirectory used below ${RELEASEDIR} when building a release +# +RELEASEMACHINEDIR?= ${MACHINE} + +# +# Subdirectory or path component used for the following paths: +# distrib/${RELEASEMACHINE} +# distrib/notes/${RELEASEMACHINE} +# etc/etc.${RELEASEMACHINE} +# Used when building a release. +# +RELEASEMACHINE?= ${MACHINE} + +# +# NEED_OWN_INSTALL_TARGET is set to "no" by pkgsrc/mk/bsd.pkg.mk to +# ensure that things defined by (default targets, +# INSTALL_FILE, etc.) are not conflicting with bsd.pkg.mk. +# +NEED_OWN_INSTALL_TARGET?= yes + +# +# This lists the platforms which do not have working in-tree toolchains. +# For the in-tree gcc 3.3.2 toolchain, this list is empty. +# If some future port is not supported by the in-tree toolchain, this +# should be set to "yes" for that port only. +# +TOOLCHAIN_MISSING?= no + +# default to GCC4 +.if !defined(HAVE_GCC) && !defined(HAVE_PCC) +HAVE_GCC= 4 +.endif + +# default to GDB6 +HAVE_GDB?= 6 + +# default to binutils 2.19 +HAVE_BINUTILS?= 219 + +CPPFLAG_ISYSTEM= -isystem +.if defined(HAVE_GCC) +.if ${HAVE_GCC} == 3 +CPPFLAG_ISYSTEMXX= -isystem-cxx +.else # GCC 4 +CPPFLAG_ISYSTEMXX= -cxx-isystem +.endif +.endif + +.if empty(.MAKEFLAGS:M-V*) +.if defined(MAKEOBJDIRPREFIX) || defined(MAKEOBJDIR) +PRINTOBJDIR= ${MAKE} -r -V .OBJDIR -f /dev/null xxx +.else +PRINTOBJDIR= ${MAKE} -V .OBJDIR +.endif +.else +PRINTOBJDIR= echo # prevent infinite recursion +.endif + +# +# Determine if running in the NetBSD source tree by checking for the +# existence of build.sh and tools/ in the current or a parent directory, +# and setting _SRC_TOP_ to the result. +# +.if !defined(_SRC_TOP_) # { +_SRC_TOP_!= cd ${.CURDIR}; while :; do \ + here=`pwd`; \ + [ -f build.sh ] && [ -d tools ] && { echo $$here; break; }; \ + case $$here in /) echo ""; break;; esac; \ + cd ..; done + +.MAKEOVERRIDES+= _SRC_TOP_ + +.endif # } + +# +# If _SRC_TOP_ != "", we're within the NetBSD source tree, so set +# defaults for NETBSDSRCDIR and _SRC_TOP_OBJ_. +# +.if (${_SRC_TOP_} != "") # { + +NETBSDSRCDIR?= ${_SRC_TOP_} + +.if !defined(_SRC_TOP_OBJ_) +_SRC_TOP_OBJ_!= cd ${_SRC_TOP_} && ${PRINTOBJDIR} +.MAKEOVERRIDES+= _SRC_TOP_OBJ_ +.endif + +.endif # _SRC_TOP_ != "" # } + + +.if (${_SRC_TOP_} != "") && \ + (${TOOLCHAIN_MISSING} == "no" || defined(EXTERNAL_TOOLCHAIN)) +USETOOLS?= yes +.endif +USETOOLS?= no + + +.if ${MACHINE_ARCH} == "mips" || ${MACHINE_ARCH} == "mips64" || \ + ${MACHINE_ARCH} == "sh3" +.BEGIN: + @echo "Must set MACHINE_ARCH to one of ${MACHINE_ARCH}eb or ${MACHINE_ARCH}el" + @false +.elif defined(REQUIRETOOLS) && \ + (${TOOLCHAIN_MISSING} == "no" || defined(EXTERNAL_TOOLCHAIN)) && \ + ${USETOOLS} == "no" +.BEGIN: + @echo "USETOOLS=no, but this component requires a version-specific host toolchain" + @false +.endif + +# +# Host platform information; may be overridden +# +.if !defined(HOST_OSTYPE) +_HOST_OSNAME!= uname -s +_HOST_OSREL!= uname -r +# For _HOST_ARCH, if uname -p fails, or prints "unknown", or prints +# something that does not look like an identifier, then use uname -m. +_HOST_ARCH!= uname -p 2>/dev/null +_HOST_ARCH:= ${HOST_ARCH:tW:C/.*[^-_A-Za-z0-9].*//:S/unknown//} +.if empty(_HOST_ARCH) +_HOST_ARCH!= uname -m +.endif +HOST_OSTYPE:= ${_HOST_OSNAME}-${_HOST_OSREL:C/\([^\)]*\)//g:[*]:C/ /_/g}-${_HOST_ARCH:C/\([^\)]*\)//g:[*]:C/ /_/g} +.MAKEOVERRIDES+= HOST_OSTYPE +.endif # !defined(HOST_OSTYPE) + +.if ${USETOOLS} == "yes" # { + +# +# Provide a default for TOOLDIR. +# +.if !defined(TOOLDIR) +TOOLDIR:= ${_SRC_TOP_OBJ_}/tooldir.${HOST_OSTYPE} +.MAKEOVERRIDES+= TOOLDIR +.endif + +# +# This is the prefix used for the NetBSD-sourced tools. +# +_TOOL_PREFIX?= nb + +# +# If an external toolchain base is specified, use it. +# +.if defined(EXTERNAL_TOOLCHAIN) # { +AR= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-ar +AS= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-as +LD= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-ld +NM= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-nm +OBJCOPY= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-objcopy +OBJDUMP= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-objdump +RANLIB= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-ranlib +SIZE= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-size +STRIP= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-strip + +CC= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-gcc +CPP= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-cpp +CXX= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-c++ +FC= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-g77 +OBJC= ${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-gcc +.else # } { +# Define default locations for common tools. +.if ${USETOOLS_BINUTILS:Uyes} == "yes" # { +AR= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-ar +AS= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-as +LD= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-ld +NM= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-nm +OBJCOPY= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-objcopy +OBJDUMP= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-objdump +RANLIB= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-ranlib +SIZE= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-size +STRIP= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-strip +.endif # } + +.if defined(HAVE_GCC) && ${USETOOLS_GCC:Uyes} == "yes" # { +CC= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-gcc +CPP= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-cpp +CXX= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-c++ +FC= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-g77 +OBJC= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-gcc +.endif # } + +.if defined(HAVE_PCC) && ${USETOOLS_PCC:Uyes} == "yes" +CC= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-pcc +CPP= ${TOOLDIR}/libexec/${MACHINE_GNU_PLATFORM}-cpp +CXX= false +FC= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-f77 +OBJC= false +.endif + +.endif # EXTERNAL_TOOLCHAIN # } + +HOST_MKDEP= ${TOOLDIR}/bin/${_TOOL_PREFIX}host-mkdep + +DBSYM= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-dbsym +ELF2ECOFF= ${TOOLDIR}/bin/${_TOOL_PREFIX}mips-elf2ecoff +INSTALL= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-install +LEX= ${TOOLDIR}/bin/${_TOOL_PREFIX}lex +LINT= CC=${CC:Q} ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-lint +LORDER= NM=${NM:Q} MKTEMP=${TOOL_MKTEMP:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}lorder +MKDEP= CC=${CC:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}mkdep +PAXCTL= ${TOOLDIR}/bin/${_TOOL_PREFIX}paxctl +TSORT= ${TOOLDIR}/bin/${_TOOL_PREFIX}tsort -q +YACC= ${TOOLDIR}/bin/${_TOOL_PREFIX}yacc + +TOOL_AMIGAAOUT2BB= ${TOOLDIR}/bin/${_TOOL_PREFIX}amiga-aout2bb +TOOL_AMIGAELF2BB= ${TOOLDIR}/bin/${_TOOL_PREFIX}amiga-elf2bb +TOOL_AMIGATXLT= ${TOOLDIR}/bin/${_TOOL_PREFIX}amiga-txlt +TOOL_ASN1_COMPILE= ${TOOLDIR}/bin/${_TOOL_PREFIX}asn1_compile +TOOL_ATF_COMPILE= ${TOOLDIR}/bin/${_TOOL_PREFIX}atf-compile +TOOL_AWK= ${TOOLDIR}/bin/${_TOOL_PREFIX}awk +TOOL_CAP_MKDB= ${TOOLDIR}/bin/${_TOOL_PREFIX}cap_mkdb +TOOL_CAT= ${TOOLDIR}/bin/${_TOOL_PREFIX}cat +TOOL_CKSUM= ${TOOLDIR}/bin/${_TOOL_PREFIX}cksum +TOOL_COMPILE_ET= ${TOOLDIR}/bin/${_TOOL_PREFIX}compile_et +TOOL_CONFIG= ${TOOLDIR}/bin/${_TOOL_PREFIX}config +TOOL_CRUNCHGEN= MAKE=${.MAKE:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}crunchgen +TOOL_CTAGS= ${TOOLDIR}/bin/${_TOOL_PREFIX}ctags +TOOL_DB= ${TOOLDIR}/bin/${_TOOL_PREFIX}db +TOOL_DISKLABEL= ${TOOLDIR}/bin/nbdisklabel-${MAKEWRAPPERMACHINE} +TOOL_EQN= ${TOOLDIR}/bin/${_TOOL_PREFIX}eqn +TOOL_FDISK= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-fdisk +TOOL_FGEN= ${TOOLDIR}/bin/${_TOOL_PREFIX}fgen +TOOL_GENASSYM= ${TOOLDIR}/bin/${_TOOL_PREFIX}genassym +TOOL_GENCAT= ${TOOLDIR}/bin/${_TOOL_PREFIX}gencat +TOOL_GMAKE= ${TOOLDIR}/bin/${_TOOL_PREFIX}gmake +TOOL_GREP= ${TOOLDIR}/bin/${_TOOL_PREFIX}grep +TOOL_GROFF= PATH=${TOOLDIR}/lib/groff:$${PATH} ${TOOLDIR}/bin/${_TOOL_PREFIX}groff +TOOL_HEXDUMP= ${TOOLDIR}/bin/${_TOOL_PREFIX}hexdump +TOOL_HP300MKBOOT= ${TOOLDIR}/bin/${_TOOL_PREFIX}hp300-mkboot +TOOL_HP700MKBOOT= ${TOOLDIR}/bin/${_TOOL_PREFIX}hp700-mkboot +TOOL_INDXBIB= ${TOOLDIR}/bin/${_TOOL_PREFIX}indxbib +TOOL_INSTALLBOOT= ${TOOLDIR}/bin/${_TOOL_PREFIX}installboot +TOOL_INSTALL_INFO= ${TOOLDIR}/bin/${_TOOL_PREFIX}install-info +TOOL_JOIN= ${TOOLDIR}/bin/${_TOOL_PREFIX}join +TOOL_M4= ${TOOLDIR}/bin/${_TOOL_PREFIX}m4 +TOOL_MACPPCFIXCOFF= ${TOOLDIR}/bin/${_TOOL_PREFIX}macppc-fixcoff +TOOL_MAKEFS= ${TOOLDIR}/bin/${_TOOL_PREFIX}makefs +TOOL_MAKEINFO= ${TOOLDIR}/bin/${_TOOL_PREFIX}makeinfo +TOOL_MAKEWHATIS= ${TOOLDIR}/bin/${_TOOL_PREFIX}makewhatis +TOOL_MANDOC_ASCII= ${TOOLDIR}/bin/${_TOOL_PREFIX}mandoc -Tascii +TOOL_MANDOC_HTML= ${TOOLDIR}/bin/${_TOOL_PREFIX}mandoc -Thtml +TOOL_MANDOC_LINT= ${TOOLDIR}/bin/${_TOOL_PREFIX}mandoc -Tlint +TOOL_MDSETIMAGE= ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-mdsetimage +TOOL_MENUC= MENUDEF=${TOOLDIR}/share/misc ${TOOLDIR}/bin/${_TOOL_PREFIX}menuc +TOOL_MIPSELF2ECOFF= ${TOOLDIR}/bin/${_TOOL_PREFIX}mips-elf2ecoff +TOOL_MKCSMAPPER= ${TOOLDIR}/bin/${_TOOL_PREFIX}mkcsmapper +TOOL_MKESDB= ${TOOLDIR}/bin/${_TOOL_PREFIX}mkesdb +TOOL_MKLOCALE= ${TOOLDIR}/bin/${_TOOL_PREFIX}mklocale +TOOL_MKMAGIC= ${TOOLDIR}/bin/${_TOOL_PREFIX}file +TOOL_MKTEMP= ${TOOLDIR}/bin/${_TOOL_PREFIX}mktemp +TOOL_MSGC= MSGDEF=${TOOLDIR}/share/misc ${TOOLDIR}/bin/${_TOOL_PREFIX}msgc +TOOL_MTREE= ${TOOLDIR}/bin/${_TOOL_PREFIX}mtree +TOOL_PAX= ${TOOLDIR}/bin/${_TOOL_PREFIX}pax +TOOL_PIC= ${TOOLDIR}/bin/${_TOOL_PREFIX}pic +TOOL_PKG_CREATE= ${TOOLDIR}/bin/${_TOOL_PREFIX}pkg_create +TOOL_POWERPCMKBOOTIMAGE=${TOOLDIR}/bin/${_TOOL_PREFIX}powerpc-mkbootimage +TOOL_PWD_MKDB= ${TOOLDIR}/bin/${_TOOL_PREFIX}pwd_mkdb +TOOL_REFER= ${TOOLDIR}/bin/${_TOOL_PREFIX}refer +TOOL_ROFF_ASCII= PATH=${TOOLDIR}/lib/groff:$${PATH} ${TOOLDIR}/bin/${_TOOL_PREFIX}nroff +TOOL_ROFF_DVI= ${TOOL_GROFF} -Tdvi +TOOL_ROFF_HTML= ${TOOL_GROFF} -Tlatin1 -mdoc2html +TOOL_ROFF_PS= ${TOOL_GROFF} -Tps +TOOL_ROFF_RAW= ${TOOL_GROFF} -Z +TOOL_RPCGEN= RPCGEN_CPP=${CPP:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}rpcgen +TOOL_SED= ${TOOLDIR}/bin/${_TOOL_PREFIX}sed +TOOL_SOELIM= ${TOOLDIR}/bin/${_TOOL_PREFIX}soelim +TOOL_SPARKCRC= ${TOOLDIR}/bin/${_TOOL_PREFIX}sparkcrc +TOOL_STAT= ${TOOLDIR}/bin/${_TOOL_PREFIX}stat +TOOL_STRFILE= ${TOOLDIR}/bin/${_TOOL_PREFIX}strfile +TOOL_SUNLABEL= ${TOOLDIR}/bin/${_TOOL_PREFIX}sunlabel +TOOL_TBL= ${TOOLDIR}/bin/${_TOOL_PREFIX}tbl +TOOL_UUDECODE= ${TOOLDIR}/bin/${_TOOL_PREFIX}uudecode +TOOL_VGRIND= ${TOOLDIR}/bin/${_TOOL_PREFIX}vgrind -f +TOOL_ZIC= ${TOOLDIR}/bin/${_TOOL_PREFIX}zic + +.else # USETOOLS != yes # } { + +TOOL_AMIGAAOUT2BB= amiga-aout2bb +TOOL_AMIGAELF2BB= amiga-elf2bb +TOOL_AMIGATXLT= amiga-txlt +TOOL_ASN1_COMPILE= asn1_compile +TOOL_ATF_COMPILE= atf-compile +TOOL_AWK= awk +TOOL_CAP_MKDB= cap_mkdb +TOOL_CAT= cat +TOOL_CKSUM= cksum +TOOL_COMPILE_ET= compile_et +TOOL_CONFIG= config +TOOL_CRUNCHGEN= crunchgen +TOOL_CTAGS= ctags +TOOL_DB= db +TOOL_DISKLABEL= disklabel +TOOL_EQN= eqn +TOOL_FDISK= fdisk +TOOL_FGEN= fgen +TOOL_GENASSYM= genassym +TOOL_GENCAT= gencat +TOOL_GMAKE= gmake +TOOL_GREP= grep +TOOL_GROFF= groff +TOOL_HEXDUMP= hexdump +TOOL_HP300MKBOOT= hp300-mkboot +TOOL_HP700MKBOOT= hp700-mkboot +TOOL_INDXBIB= indxbib +TOOL_INSTALLBOOT= installboot +TOOL_INSTALL_INFO= install-info +TOOL_JOIN= join +TOOL_M4= m4 +TOOL_MACPPCFIXCOFF= macppc-fixcoff +TOOL_MAKEFS= makefs +TOOL_MAKEINFO= makeinfo +TOOL_MAKEWHATIS= /usr/libexec/makewhatis +TOOL_MDSETIMAGE= mdsetimage +TOOL_MENUC= menuc +TOOL_MIPSELF2ECOFF= mips-elf2ecoff +TOOL_MKCSMAPPER= mkcsmapper +TOOL_MKESDB= mkesdb +TOOL_MKLOCALE= mklocale +TOOL_MKMAGIC= file +TOOL_MKTEMP= mktemp +TOOL_MSGC= msgc +TOOL_MTREE= mtree +TOOL_PAX= pax +TOOL_PIC= pic +TOOL_PKG_CREATE= pkg_create +TOOL_POWERPCMKBOOTIMAGE= powerpc-mkbootimage +TOOL_PWD_MKDB= pwd_mkdb +TOOL_REFER= refer +TOOL_ROFF_ASCII= nroff +TOOL_ROFF_DVI= ${TOOL_GROFF} -Tdvi +TOOL_ROFF_HTML= ${TOOL_GROFF} -Tlatin1 -mdoc2html +TOOL_ROFF_PS= ${TOOL_GROFF} -Tps +TOOL_ROFF_RAW= ${TOOL_GROFF} -Z +TOOL_RPCGEN= rpcgen +TOOL_SED= sed +TOOL_SOELIM= soelim +TOOL_SPARKCRC= sparkcrc +TOOL_STAT= stat +TOOL_STRFILE= strfile +TOOL_SUNLABEL= sunlabel +TOOL_TBL= tbl +TOOL_UUDECODE= uudecode +TOOL_VGRIND= vgrind -f +TOOL_ZIC= zic + +.endif # USETOOLS != yes # } + +# +# Targets to check if DESTDIR or RELEASEDIR is provided +# +.if !target(check_DESTDIR) +check_DESTDIR: .PHONY .NOTMAIN +.if !defined(DESTDIR) + @echo "setenv DESTDIR before doing that!" + @false +.else + @true +.endif +.endif + +.if !target(check_RELEASEDIR) +check_RELEASEDIR: .PHONY .NOTMAIN +.if !defined(RELEASEDIR) + @echo "setenv RELEASEDIR before doing that!" + @false +.else + @true +.endif +.endif + + +.if ${USETOOLS} == "yes" # { +# +# Make sure DESTDIR is set, so that builds with these tools always +# get appropriate -nostdinc, -nostdlib, etc. handling. The default is +# , meaning start from /, the root directory. +# +DESTDIR?= +.endif # } + +# +# Build a dynamically linked /bin and /sbin, with the necessary shared +# libraries moved from /usr/lib to /lib and the shared linker moved +# from /usr/libexec to /lib +# +# Note that if the BINDIR is not /bin or /sbin, then we always use the +# non-DYNAMICROOT behavior (i.e. it is only enabled for programs in /bin +# and /sbin). See . +# +MKDYNAMICROOT?= yes + +# +# Where the system object and source trees are kept; can be configurable +# by the user in case they want them in ~/foosrc and ~/fooobj (for example). +# +BSDSRCDIR?= /usr/src +BSDOBJDIR?= /usr/obj +NETBSDSRCDIR?= ${BSDSRCDIR} + +#BINGRP?= wheel +BINGRP?= operator +BINOWN?= root +BINMODE?= 555 +NONBINMODE?= 444 + +MANDIR?= /usr/share/man +MANGRP?= wheel +MANOWN?= root +MANMODE?= ${NONBINMODE} +MANINSTALL?= catinstall htmlinstall maninstall + +INFODIR?= /usr/share/info +INFOGRP?= wheel +INFOOWN?= root +INFOMODE?= ${NONBINMODE} + +#LIBDIR?= /usr/lib +.if (${COMPILER_TYPE} == ack) +LIBDIR?= /usr/lib/i386 +.elif (${COMPILER_TYPE} == gnu) +LIBDIR?= /usr/gnu/lib +.endif + +LINTLIBDIR?= /usr/libdata/lint +LIBGRP?= ${BINGRP} +LIBOWN?= ${BINOWN} +LIBMODE?= ${NONBINMODE} + +DOCDIR?= /usr/share/doc +HTMLDOCDIR?= /usr/share/doc/html +DOCGRP?= wheel +DOCOWN?= root +DOCMODE?= ${NONBINMODE} + +NLSDIR?= /usr/share/nls +NLSGRP?= wheel +NLSOWN?= root +NLSMODE?= ${NONBINMODE} + +KMODULEGRP?= wheel +KMODULEOWN?= root +KMODULEMODE?= ${NONBINMODE} + +LOCALEDIR?= /usr/share/locale +LOCALEGRP?= wheel +LOCALEOWN?= root +LOCALEMODE?= ${NONBINMODE} + +FIRMWAREDIR?= /libdata/firmware +FIRMWAREGRP?= wheel +FIRMWAREOWN?= root +FIRMWAREMODE?= ${NONBINMODE} + +DEBUGDIR?= /usr/libdata/debug +DEBUGGRP?= wheel +DEBUGOWN?= root +DEBUGMODE?= ${NONBINMODE} + +# +# Data-driven table using make variables to control how +# toolchain-dependent targets and shared libraries are built +# for different platforms and object formats. +# +# OBJECT_FMT: currently either "ELF" or "a.out". +# +# All platforms are ELF. +# +OBJECT_FMT= ELF + +# +# If this platform's toolchain is missing, we obviously cannot build it. +# +.if ${TOOLCHAIN_MISSING} != "no" +MKBINUTILS:= no +MKGDB:= no +MKGCC:= no +.endif + +# +# If we are using an external toolchain, we can still build the target's +# binutils, but we cannot build GCC's support libraries, since those are +# tightly-coupled to the version of GCC being used. +# +.if defined(EXTERNAL_TOOLCHAIN) +MKGCC:= no +.endif + +# +# The m68000 port is incomplete. +# +.if ${MACHINE_ARCH} == "m68000" +NOPIC= # defined +MKISCSI= no +# XXX GCC 4 outputs mcount() calling sequences that try to load values +# from over 64KB away and this fails to assemble. +.if defined(HAVE_GCC) && (${HAVE_GCC} == 4) +NOPROFILE= # defined +.endif +.endif + +# +# The ia64 port is incomplete. +# +.if ${MACHINE_ARCH} == "ia64" +MKLINT= no +MKGDB= no +.endif + +# +# On the MIPS, all libs are compiled with ABIcalls (and are thus PIC), +# not just shared libraries, so don't build the _pic version. +# +.if ${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb" || \ + ${MACHINE_ARCH} == "mips64el" || ${MACHINE_ARCH} == "mips64eb" +MKPICLIB:= no +.endif + +# +# On VAX using ELF, all objects are PIC, not just shared libraries, +# so don't build the _pic version. Unless we are using GCC3 which +# doesn't support PIC yet. +# +.if ${MACHINE_ARCH} == "vax" +MKPICLIB= no +.endif + +# +# Location of the file that contains the major and minor numbers of the +# version of a shared library. If this file exists a shared library +# will be built by . +# +SHLIB_VERSION_FILE?= ${.CURDIR}/shlib_version + +# +# GNU sources and packages sometimes see architecture names differently. +# +GNU_ARCH.coldfire=m68k +GNU_ARCH.i386=i486 +GCC_CONFIG_ARCH.i386=i486 +GCC_CONFIG_TUNE.i386=nocona +GCC_CONFIG_TUNE.x86_64=nocona +GNU_ARCH.m68000=m68010 +GNU_ARCH.sh3eb=sh +GNU_ARCH.sh3el=shle +GNU_ARCH.mips64eb=mips64 +MACHINE_GNU_ARCH=${GNU_ARCH.${MACHINE_ARCH}:U${MACHINE_ARCH}} + +# +# In order to identify NetBSD to GNU packages, we sometimes need +# an "elf" tag for historically a.out platforms. +# +.if ${OBJECT_FMT} == "ELF" && \ + (${MACHINE_GNU_ARCH} == "arm" || \ + ${MACHINE_GNU_ARCH} == "armeb" || \ + ${MACHINE_ARCH} == "i386" || \ + ${MACHINE_CPU} == "m68k" || \ + ${MACHINE_GNU_ARCH} == "sh" || \ + ${MACHINE_GNU_ARCH} == "shle" || \ + ${MACHINE_ARCH} == "sparc" || \ + ${MACHINE_ARCH} == "vax") +MACHINE_GNU_PLATFORM?=${MACHINE_GNU_ARCH}--netbsdelf +.else +MACHINE_GNU_PLATFORM?=${MACHINE_GNU_ARCH}--netbsd +.endif + +# +# Determine if arch uses native kernel modules with rump +# +.if ${MACHINE_ARCH} == "i386" || \ + ${MACHINE_ARCH} == "x86_64" +RUMPKMOD= # defined +.endif + +TARGETS+= all clean cleandir depend dependall includes \ + install lint obj regress tags html +PHONY_NOTMAIN = all clean cleandir depend dependall distclean includes \ + install lint obj regress tags beforedepend afterdepend \ + beforeinstall afterinstall realinstall realdepend realall \ + html subdir-all subdir-install subdir-depend +.PHONY: ${PHONY_NOTMAIN} +.NOTMAIN: ${PHONY_NOTMAIN} + +.if ${NEED_OWN_INSTALL_TARGET} != "no" +.if !target(install) +install: beforeinstall .WAIT subdir-install realinstall .WAIT afterinstall +beforeinstall: +subdir-install: +realinstall: +afterinstall: +.endif +all: realall subdir-all +subdir-all: +realall: +depend: realdepend subdir-depend +subdir-depend: +realdepend: +distclean: cleandir +cleandir: clean + +dependall: .NOTMAIN realdepend .MAKE + @cd ${.CURDIR}; ${MAKE} realall +.endif + +# +# Define MKxxx variables (which are either yes or no) for users +# to set in /etc/mk.conf and override in the make environment. +# These should be tested with `== "no"' or `!= "no"'. +# The NOxxx variables should only be set by Makefiles. +# +# Please keep etc/Makefile and share/man/man5/mk.conf.5 in sync +# with changes to the MK* variables here. +# + +# +# Supported NO* options (if defined, MK* will be forced to "no", +# regardless of user's mk.conf setting). +# +# Source makefiles should set NO*, and not MK*, and must do so before +# including bsd.own.mk. +# +.for var in \ + NOCRYPTO NODOC NOHTML NOINFO NOLINKLIB NOLINT NOMAN NONLS NOOBJ NOPIC \ + NOPICINSTALL NOPROFILE NOSHARE NOSTATICLIB +.if defined(${var}) +MK${var:S/^NO//}:= no +.endif +.endfor + +# +# Older-style variables that enabled behaviour when set. +# +.for var in MANZ UNPRIVED UPDATE +.if defined(${var}) +MK${var}:= yes +.endif +.endfor + +# +# MK* options which have variable defaults. +# +.if ${MACHINE} == "amd64" || ${MACHINE} == "sparc64" +MKCOMPAT?= yes +.else +# Don't let this build where it really isn't supported. +MKCOMPAT:= no +.endif + +# +# MK* backward compatibility. +# +.if defined(MKBFD) +MKBINUTILS?= ${MKBFD} +.endif + +# +# We want to build zfs only for i386 and amd64 by default for now. +# +.if ${MACHINE} == "amd64" || ${MACHINE} == "i386" +MKZFS?= yes +.endif + +# +# MK* options which default to "yes". +# +_MKVARS.yes= \ + MKATF \ + MKBINUTILS \ + MKCATPAGES MKCRYPTO MKCOMPLEX MKCVS \ + MKDOC \ + MKGCC MKGCCCMDS MKGDB \ + MKHESIOD MKHTML \ + MKIEEEFP MKINET6 MKINFO MKIPFILTER MKISCSI \ + MKKERBEROS \ + MKKMOD \ + MKLDAP MKLINKLIB MKLINT MKLVM \ + MKMAN \ + MKMDNS \ + MKNLS \ + MKOBJ \ + MKPAM \ + MKPF MKPIC MKPICINSTALL MKPICLIB MKPOSTFIX MKPROFILE \ + MKSHARE MKSKEY MKSTATICLIB \ + MKX11FONTS \ + MKYP +.for var in ${_MKVARS.yes} +${var}?= yes +.endfor + +# +# MK* options which default to "no". +# +_MKVARS.no= \ + MKCRYPTO_IDEA MKCRYPTO_MDC2 MKCRYPTO_RC5 MKDEBUG MKDEBUGLIB \ + MKEXTSRC \ + MKMANDOC MKMANZ MKOBJDIRS \ + MKPCC MKPCCCMDS \ + MKSOFTFLOAT MKSTRIPIDENT \ + MKUNPRIVED MKUPDATE MKX11 MKZFS +.for var in ${_MKVARS.no} +${var}?=no +.endfor + +# +# Force some options off if their dependencies are off. +# + +.if ${MKCRYPTO} == "no" +MKKERBEROS:= no +.endif + +.if ${MKMAN} == "no" +MKCATPAGES:= no +MKHTML:= no +.endif + +.if ${MKLINKLIB} == "no" +MKLINT:= no +MKPICINSTALL:= no +MKPROFILE:= no +.endif + +.if ${MKPIC} == "no" +MKPICLIB:= no +.endif + +.if ${MKOBJ} == "no" +MKOBJDIRS:= no +.endif + +.if ${MKSHARE} == "no" +MKCATPAGES:= no +MKDOC:= no +MKINFO:= no +MKHTML:= no +MKMAN:= no +MKNLS:= no +.endif + +# +# install(1) parameters. +# +COPY?= -c +.if ${MKUPDATE} == "no" +PRESERVE?= +.else +PRESERVE?= -p +.endif +#XXX: Not supported by MINIX install +#RENAME?= -r +HRDLINK?= -l h +SYMLINK?= -l s + +METALOG?= ${DESTDIR}/METALOG +METALOG.add?= ${TOOL_CAT} -l >> ${METALOG} +.if (${_SRC_TOP_} != "") # only set INSTPRIV if inside ${NETBSDSRCDIR} +.if ${MKUNPRIVED} != "no" +INSTPRIV.unpriv=-U -M ${METALOG} -D ${DESTDIR} -h sha256 +.else +INSTPRIV.unpriv= +.endif +INSTPRIV?= ${INSTPRIV.unpriv} -N ${NETBSDSRCDIR}/etc +.endif +STRIPFLAG?= + +.if ${NEED_OWN_INSTALL_TARGET} != "no" +INSTALL_DIR?= ${INSTALL} ${INSTPRIV} -d +INSTALL_FILE?= ${INSTALL} ${INSTPRIV} ${COPY} ${PRESERVE} ${RENAME} +INSTALL_LINK?= ${INSTALL} ${INSTPRIV} ${HRDLINK} ${RENAME} +INSTALL_SYMLINK?= ${INSTALL} ${INSTPRIV} ${SYMLINK} ${RENAME} +HOST_INSTALL_FILE?= ${INSTALL} ${COPY} ${PRESERVE} ${RENAME} +HOST_INSTALL_DIR?= ${INSTALL} -d +HOST_INSTALL_SYMLINK?= ${INSTALL} ${SYMLINK} ${RENAME} +.endif + +# +# Set defaults for the USE_xxx variables. +# + +# +# USE_* options which default to "no" and will be forced to "no" if their +# corresponding MK* variable is set to "no". +# +.for var in USE_SKEY +.if (${${var:S/USE_/MK/}} == "no") +${var}:= no +.else +${var}?= no +.endif +.endfor + +# +# USE_* options which default to "yes" unless their corresponding MK* +# variable is set to "no". +# +.for var in USE_HESIOD USE_INET6 USE_KERBEROS USE_LDAP USE_PAM USE_YP +.if (${${var:S/USE_/MK/}} == "no") +${var}:= no +.else +${var}?= yes +.endif +.endfor + +# +# USE_* options which default to "yes". +# +.for var in USE_JEMALLOC +${var}?= yes +.endfor + +# +# USE_* options which default to "no". +# +#.for var in +#${var}?= no +#.endfor + + +# +# MAKEDIRTARGET dir target [extra make(1) params] +# run "cd $${dir} && ${MAKE} [params] $${target}", with a pretty message +# +MAKEDIRTARGET=\ + @_makedirtarget() { \ + dir="$$1"; shift; \ + target="$$1"; shift; \ + case "$${dir}" in \ + /*) this="$${dir}/"; \ + real="$${dir}" ;; \ + .) this="${_THISDIR_}"; \ + real="${.CURDIR}" ;; \ + *) this="${_THISDIR_}$${dir}/"; \ + real="${.CURDIR}/$${dir}" ;; \ + esac; \ + show=$${this:-.}; \ + echo "$${target} ===> $${show%/}$${1:+ (with: $$@)}"; \ + cd "$${real}" \ + && ${MAKE} _THISDIR_="$${this}" "$$@" $${target}; \ + }; \ + _makedirtarget + +# +# MAKEVERBOSE support. Levels are: +# 0 Minimal output ("quiet") +# 1 Describe what is occurring +# 2 Describe what is occurring and echo the actual command +# 3 Ignore the effect of the "@" prefix in make commands +# 4 Trace shell commands using the shell's -x flag +# +MAKEVERBOSE?= 2 + +.if ${MAKEVERBOSE} == 0 +_MKMSG?= @\# +_MKSHMSG?= : echo +_MKSHECHO?= : echo +.SILENT: +.elif ${MAKEVERBOSE} == 1 +_MKMSG?= @echo ' ' +_MKSHMSG?= echo ' ' +_MKSHECHO?= : echo +.SILENT: +.else # MAKEVERBOSE >= 2 +_MKMSG?= @echo '\# ' +_MKSHMSG?= echo '\# ' +_MKSHECHO?= echo +.SILENT: __makeverbose_dummy_target__ +.endif # MAKEVERBOSE >= 2 +.if ${MAKEVERBOSE} >= 3 +.MAKEFLAGS: -dl +.endif # ${MAKEVERBOSE} >= 3 +.if ${MAKEVERBOSE} >= 4 +.MAKEFLAGS: -dx +.endif # ${MAKEVERBOSE} >= 4 + +_MKMSG_BUILD?= ${_MKMSG} " build " +_MKMSG_CREATE?= ${_MKMSG} " create " +_MKMSG_COMPILE?= ${_MKMSG} "compile " +_MKMSG_FORMAT?= ${_MKMSG} " format " +_MKMSG_INSTALL?= ${_MKMSG} "install " +_MKMSG_LINK?= ${_MKMSG} " link " +_MKMSG_LEX?= ${_MKMSG} " lex " +_MKMSG_REMOVE?= ${_MKMSG} " remove " +_MKMSG_YACC?= ${_MKMSG} " yacc " + +_MKSHMSG_CREATE?= ${_MKSHMSG} " create " +_MKSHMSG_INSTALL?= ${_MKSHMSG} "install " + +_MKTARGET_BUILD?= ${_MKMSG_BUILD} ${.CURDIR:T}/${.TARGET} +_MKTARGET_CREATE?= ${_MKMSG_CREATE} ${.CURDIR:T}/${.TARGET} +_MKTARGET_COMPILE?= ${_MKMSG_COMPILE} ${.CURDIR:T}/${.TARGET} +_MKTARGET_FORMAT?= ${_MKMSG_FORMAT} ${.CURDIR:T}/${.TARGET} +_MKTARGET_INSTALL?= ${_MKMSG_INSTALL} ${.TARGET} +_MKTARGET_LINK?= ${_MKMSG_LINK} ${.CURDIR:T}/${.TARGET} +_MKTARGET_LEX?= ${_MKMSG_LEX} ${.CURDIR:T}/${.TARGET} +_MKTARGET_REMOVE?= ${_MKMSG_REMOVE} ${.TARGET} +_MKTARGET_YACC?= ${_MKMSG_YACC} ${.CURDIR:T}/${.TARGET} + +.if ${MKMANDOC} == "yes" +TARGETS+= lintmanpages +.endif + +.endif # !defined(_MINIX_OWN_MK_) diff --git a/etc/mk/minix.prog.mk b/etc/mk/minix.prog.mk new file mode 100644 index 000000000..c10f8a8e7 --- /dev/null +++ b/etc/mk/minix.prog.mk @@ -0,0 +1,375 @@ +# $NetBSD: bsd.prog.mk,v 1.243 2009/11/27 11:44:36 tsutsui Exp $ +# @(#)bsd.prog.mk 8.2 (Berkeley) 4/2/94 + +.ifndef HOSTPROG + +.include + +# +# Definitions and targets shared among all programs built by a single +# Makefile. +# + +##### Basic targets +realinstall: proginstall scriptsinstall +clean: cleanprog + +cleanobjs: .PHONY + +cleanprog: .PHONY cleanobjs cleanextra + rm -f a.out [Ee]rrs mklog core *.core + +##### Default values +.if empty(CPPFLAGS:M-nostdinc) +CPPFLAGS+= ${DESTDIR:D-nostdinc ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include} +.endif +.if empty(CXXFLAGS:M-nostdinc++) +CXXFLAGS+= ${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEMXX} ${DESTDIR}/usr/include/g++} +.endif +CFLAGS+= ${COPTS} +OBJCFLAGS+= ${OBJCOPTS} +MKDEP_SUFFIXES?= .o .ln + +##### Installed system library definitions +# +# E.g. +# LIBC?=${DESTDIR}/usr/lib/libc.a +# LIBX11?=${DESTDIR}/usr/X11R7/lib/libX11.a +# etc.. + +.for _lib in \ + archive asn1 bluetooth bsdmalloc bz2 c c_pic cdk com_err compat \ + crypt crypto crypto_idea crypto_mdc2 crypto_rc5 \ + curses dbm des edit event \ + fetch form fl g2c gcc gnumalloc gssapi hdb heimntlm hx509 intl ipsec \ + kadm5clnt kadm5srv kafs krb5 kvm l lber ldap ldap_r \ + m magic menu objc ossaudio pam pcap pci pmc posix pthread pthread_dbg \ + puffs radius resolv rmt roken rpcsvc rt rump rumpuser skey sl ss \ + ssh ssl termcap usbhid util wrap y z bind9 dns lwres isccfg isccc isc \ + \ + rumpfs_cd9660fs rumpfs_efs rumpfs_ext2fs rumpfs_ffs rumpfs_hfs \ + rumpfs_lfs rumpfs_msdosfs rumpfs_nfs rumpfs_ntfs rumpfs_syspuffs \ + rumpfs_tmpfs rumpfs_udf rumpfs_ufs +.ifndef LIB${_lib:tu} +LIB${_lib:tu}= ${DESTDIR}/usr/lib/lib${_lib}.a +.MADE: ${LIB${_lib:tu}} # Note: ${DESTDIR} will be expanded +.endif +.endfor + +# These need + -> X transformations +.ifndef LIBSTDCXX +LIBSTDCXX= ${DESTDIR}/usr/lib/libstdc++.a +.MADE: ${LIBSTDCXX} +.endif + +.ifndef LIBSUPCXX +LIBSUPCXX= ${DESTDIR}/usr/lib/libsupc++.a +.MADE: ${LIBSUPCXX} +.endif + +.for _lib in \ + dps expat fntstubs fontcache fontconfig fontenc freetype FS \ + GL GLU ICE lbxutil SM X11 Xau Xaw Xdmcp Xext Xfont Xft \ + Xi Xinerama xkbfile Xmu Xmuu Xpm Xrandr Xrender Xss Xt \ + XTrap Xtst Xv Xxf86dga Xxf86misc Xxf86vm +.ifndef LIB${_lib:tu} +LIB${_lib:tu}= ${DESTDIR}${X11USRLIBDIR}/lib${_lib}.a +.MADE: ${LIB${_lib:tu}} # Note: ${DESTDIR} will be expanded +.endif +.endfor + +.if defined(RESCUEDIR) +CPPFLAGS+= -DRESCUEDIR=\"${RESCUEDIR}\" +.endif + +__proginstall: .USE + ${_MKTARGET_INSTALL} + ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ + ${STRIPFLAG} ${.ALLSRC} ${.TARGET} + +__progdebuginstall: .USE + ${_MKTARGET_INSTALL} + ${INSTALL_FILE} -o ${DEBUGOWN} -g ${DEBUGGRP} -m ${DEBUGMODE} \ + ${.ALLSRC} ${.TARGET} + + + +# +# Backwards compatibility with Makefiles that assume that bsd.prog.mk +# can only build a single binary. +# + +_APPEND_MANS=yes +_APPEND_SRCS=yes + +_CCLINKFLAGS= +.if defined(DESTDIR) +_CCLINKFLAGS+= -B${_GCC_CRTDIR}/ -B${DESTDIR}/usr/lib/ +.endif + +.if defined(PROG_CXX) +PROG= ${PROG_CXX} +_CCLINK= ${CXX} ${_CCLINKFLAGS} +.endif + +.if defined(PROG) +_CCLINK?= ${CC} ${_CCLINKFLAGS} +. if defined(MAN) +MAN.${PROG}= ${MAN} +_APPEND_MANS= no +. endif +. if !defined(OBJS) +OBJS= ${OBJS.${PROG}} +. endif +. if defined(PROGNAME) +PROGNAME.${PROG}= ${PROGNAME} +. endif +. if defined(SRCS) +SRCS.${PROG}= ${SRCS} +_APPEND_SRCS= no +. endif +.endif + +# Turn the single-program PROG and PROG_CXX variables into their multi-word +# counterparts, PROGS and PROGS_CXX. +.if defined(PROG_CXX) && !defined(PROGS_CXX) +PROGS_CXX= ${PROG_CXX} +.elif defined(PROG) && !defined(PROGS) +PROGS= ${PROG} +.endif + + + +# +# Per-program definitions and targets. +# + +# Definitions specific to C programs. +.for _P in ${PROGS} +SRCS.${_P}?= ${_P}.c +_CCLINK.${_P}= ${CC} ${_CCLINKFLAGS} +.endfor + +# Definitions specific to C++ programs. +.for _P in ${PROGS_CXX} +SRCS.${_P}?= ${_P}.cc +_CCLINK.${_P}= ${CXX} ${_CCLINKFLAGS} +.endfor + +# Language-independent definitions. +.for _P in ${PROGS} ${PROGS_CXX} # { + +BINDIR.${_P}?= ${BINDIR} +PROGNAME.${_P}?= ${_P} + +.if ${MKDEBUG} != "no" && ${OBJECT_FMT} == "ELF" && !commands(${_P}) +_PROGDEBUG.${_P}:= ${PROGNAME.${_P}}.debug +.endif + +##### PROG specific flags. +COPTS+= ${COPTS.${_P}} +CPPFLAGS+= ${CPPFLAGS.${_P}} +CXXFLAGS+= ${CXXFLAGS.${_P}} +OBJCOPTS+= ${OBJCOPTS.${_P}} +LDADD+= ${LDADD.${_P}} +LDFLAGS+= ${LDFLAGS.${_P}} +LDSTATIC+= ${LDSTATIC.${_P}} + +_COPTS.${_P}= ${COPTS} ${COPTS.${_P}} +_CPPFLAGS.${_P}= ${CPPFLAGS} ${CPPFLAGS.${_P}} +_CXXFLAGS.${_P}= ${CXXFLAGS} ${CXXFLAGS.${_P}} +_OBJCOPTS.${_P}= ${OBJCOPTS} ${OBJCOPTS.${_P}} +_LDADD.${_P}= ${LDADD} ${LDADD.${_P}} +_LDFLAGS.${_P}= ${LDFLAGS} ${LDFLAGS.${_P}} +_LDSTATIC.${_P}= ${LDSTATIC} ${LDSTATIC.${_P}} + +##### Build and install rules +.if !empty(_APPEND_SRCS:M[Yy][Ee][Ss]) +SRCS+= ${SRCS.${_P}} # For bsd.dep.mk +.endif + +_YPSRCS.${_P}= ${SRCS.${_P}:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS.${_P}:M*.y:.y=.h}} + +DPSRCS+= ${_YPSRCS.${_P}} +CLEANFILES+= ${_YPSRCS.${_P}} + +.if !empty(SRCS.${_P}:N*.h:N*.sh:N*.fth) +OBJS.${_P}+= ${SRCS.${_P}:N*.h:N*.sh:N*.fth:R:S/$/.o/g} +LOBJS.${_P}+= ${LSRCS:.c=.ln} ${SRCS.${_P}:M*.c:.c=.ln} +.endif + +.if defined(OBJS.${_P}) && !empty(OBJS.${_P}) # { +.NOPATH: ${OBJS.${_P}} ${_P} ${_YPSRCS.${_P}} + +${OBJS.${_P}} ${LOBJS.${_P}}: ${DPSRCS} + +${_P}: .gdbinit ${LIBCRT0} ${OBJS.${_P}} ${LIBC} ${LIBCRTBEGIN} ${LIBCRTEND} ${DPADD} +.if !commands(${_P}) + ${_MKTARGET_LINK} + ${_CCLINK.${_P}} \ + ${DESTDIR:D-Wl,-nostdlib} \ + ${_LDFLAGS.${_P}} ${_LDSTATIC.${_P}} -o ${.TARGET} \ + ${OBJS.${_P}} ${_LDADD.${_P}} \ + ${DESTDIR:D-L${_GCC_LIBGCCDIR}} \ + ${_PROGLDOPTS} +.if defined(PAXCTL_FLAGS.${_P}) + ${PAXCTL} ${PAXCTL_FLAGS.${_P}} ${.TARGET} +.endif +.if ${MKSTRIPIDENT} != "no" + ${OBJCOPY} -R .ident ${.TARGET} +.endif +.endif # !commands(${_P}) + +${_P}.ro: ${OBJS.${_P}} ${DPADD} + ${_MKTARGET_LINK} + ${LD} -r -dc -o ${.TARGET} ${OBJS.${_P}} + +.if defined(_PROGDEBUG.${_P}) +${_PROGDEBUG.${_P}}: ${_P} + ${_MKTARGET_CREATE} + ${OBJCOPY} --only-keep-debug ${_P} ${_PROGDEBUG.${_P}} + ${OBJCOPY} -R .gnu_debuglink --add-gnu-debuglink=${_PROGDEBUG.${_P}} ${_P} \ + || rm -f ${_PROGDEBUG.${_P}} +.endif + +.endif # defined(OBJS.${_P}) && !empty(OBJS.${_P}) # } + +.if !defined(MAN.${_P}) +MAN.${_P}= ${_P}.1 +.endif # !defined(MAN.${_P}) +.if !empty(_APPEND_MANS:M[Yy][Ee][Ss]) +MAN+= ${MAN.${_P}} +.endif + +realall: ${_P} ${_PROGDEBUG.${_P}} + +cleanprog: cleanprog-${_P} +cleanprog-${_P}: + rm -f ${_P} ${_PROGDEBUG.${_P}} + +.if defined(OBJS.${_P}) && !empty(OBJS.${_P}) +cleanobjs: cleanobjs-${_P} +cleanobjs-${_P}: + rm -f ${OBJS.${_P}} ${LOBJS.${_P}} +.endif + +_PROG_INSTALL+= proginstall-${_P} + +.if !target(proginstall-${_P}) # { +proginstall-${_P}:: ${DESTDIR}${BINDIR.${_P}}/${PROGNAME.${_P}} \ + ${_PROGDEBUG.${_P}:D${DESTDIR}${DEBUGDIR}${BINDIR.${_P}}/${_PROGDEBUG.${_P}}} +.PRECIOUS: ${DESTDIR}${BINDIR.${_P}}/${PROGNAME.${_P}} \ + ${_PROGDEBUG.${_P}:D${DESTDIR}${DEBUGDIR}${BINDIR.${_P}}/${_PROGDEBUG.${_P}}} + +.if ${MKUPDATE} == "no" +${DESTDIR}${BINDIR.${_P}}/${PROGNAME.${_P}}! ${_P} __proginstall +.if !defined(BUILD) && !make(all) && !make(${_P}) +${DESTDIR}${BINDIR.${_P}}/${PROGNAME.${_P}}! .MADE +.endif +.if defined(_PROGDEBUG.${_P}) +${DESTDIR}${DEBUGDIR}${BINDIR.${_P}}/${_PROGDEBUG.${_P}}! ${_PROGDEBUG.${_P}} __progdebuginstall +.if !defined(BUILD) && !make(all) && !make(${_P}) +${DESTDIR}${DEBUGDIR}${BINDIR.${_P}}/${_PROGDEBUG.${_P}}! .MADE +.endif +.endif # define(_PROGDEBUG.${_P}) +.else # MKUPDATE != no +${DESTDIR}${BINDIR.${_P}}/${PROGNAME.${_P}}: ${_P} __proginstall +.if !defined(BUILD) && !make(all) && !make(${_P}) +${DESTDIR}${BINDIR.${_P}}/${PROGNAME.${_P}}: .MADE +.endif +.if defined(_PROGDEBUG.${_P}) +${DESTDIR}${DEBUGDIR}${BINDIR.${_P}}/${_PROGDEBUG.${_P}}: ${_PROGDEBUG.${_P}} __progdebuginstall +.if !defined(BUILD) && !make(all) && !make(${_P}) +${DESTDIR}${DEBUGDIR}${BINDIR.${_P}}/${_PROGDEBUG.${_P}}: .MADE +.endif +.endif # defined(_PROGDEBUG.${_P}) +.endif # MKUPDATE != no + +.endif # !target(proginstall-${_P}) # } + +lint: lint-${_P} +lint-${_P}: ${LOBJS.${_P}} +.if defined(LOBJS.${_P}) && !empty(LOBJS.${_P}) + ${LINT} ${LINTFLAGS} ${_LDFLAGS.${_P}:C/-L[ ]*/-L/Wg:M-L*} ${LOBJS.${_P}} ${_LDADD.${_P}} +.endif + +.endfor # _P in ${PROGS} ${PROGS_CXX} # } + +.if defined(OBJS) && !empty(OBJS) && \ + (empty(PROGS) && empty(PROGS_CXX)) +cleanobjs: cleanobjs-plain +cleanobjs-plain: + rm -f ${OBJS} ${LOBJS} +.endif + +.if !target(proginstall) +proginstall:: ${_PROG_INSTALL} +.endif +.PHONY: proginstall + + + +realall: ${SCRIPTS} +.if defined(SCRIPTS) && !target(scriptsinstall) # { +SCRIPTSDIR?=${BINDIR} +SCRIPTSOWN?=${BINOWN} +SCRIPTSGRP?=${BINGRP} +SCRIPTSMODE?=${BINMODE} + +scriptsinstall:: ${SCRIPTS:@S@${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}@} +.PRECIOUS: ${SCRIPTS:@S@${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}@} + +__scriptinstall: .USE + ${_MKTARGET_INSTALL} + ${INSTALL_FILE} \ + -o ${SCRIPTSOWN_${.ALLSRC:T}:U${SCRIPTSOWN}} \ + -g ${SCRIPTSGRP_${.ALLSRC:T}:U${SCRIPTSGRP}} \ + -m ${SCRIPTSMODE_${.ALLSRC:T}:U${SCRIPTSMODE}} \ + ${.ALLSRC} ${.TARGET} + +.for S in ${SCRIPTS:O:u} +.if ${MKUPDATE} == "no" +${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}! ${S} __scriptinstall +.if !defined(BUILD) && !make(all) && !make(${S}) +${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}! .MADE +.endif +.else +${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}: ${S} __scriptinstall +.if !defined(BUILD) && !make(all) && !make(${S}) +${DESTDIR}${SCRIPTSDIR_${S}:U${SCRIPTSDIR}}/${SCRIPTSNAME_${S}:U${SCRIPTSNAME:U${S:T:R}}}: .MADE +.endif +.endif +.endfor +.endif # } + +.if !target(scriptsinstall) +scriptsinstall:: +.endif +.PHONY: scriptsinstall + +##### Pull in related .mk logic +LINKSOWN?= ${BINOWN} +LINKSGRP?= ${BINGRP} +LINKSMODE?= ${BINMODE} +# .include +.include +# .include +# .include +.include +.include + +.if (${COMPILER_TYPE} == ack) +.include +.elif (${COMPILER_TYPE} == gnu) +.include +.endif + + +cleanextra: .PHONY +.if defined(CLEANFILES) && !empty(CLEANFILES) + rm -f ${CLEANFILES} +.endif + +${TARGETS}: # ensure existence + +.endif # HOSTPROG diff --git a/etc/mk/minix.subdir.mk b/etc/mk/minix.subdir.mk new file mode 100644 index 000000000..31cec4bbd --- /dev/null +++ b/etc/mk/minix.subdir.mk @@ -0,0 +1,44 @@ +# $NetBSD: bsd.subdir.mk,v 1.50 2009/11/29 16:00:00 uebayasi Exp $ +# @(#)bsd.subdir.mk 8.1 (Berkeley) 6/8/93 + +.include + +.if !defined(NOSUBDIR) # { + +.for dir in ${SUBDIR} +.if exists(${dir}.${MACHINE}) +__REALSUBDIR+=${dir}.${MACHINE} +.else +__REALSUBDIR+=${dir} +.endif +.endfor + +__recurse: .USE + @${MAKEDIRTARGET} ${.TARGET:C/^[^-]*-//} ${.TARGET:C/-.*$//} + +.if make(cleandir) +__RECURSETARG= ${TARGETS:Nclean} +clean: +.else +__RECURSETARG= ${TARGETS} +.endif + +# for obscure reasons, we can't do a simple .if ${dir} == ".WAIT" +# but have to assign to __TARGDIR first. +.for targ in ${__RECURSETARG} +.for dir in ${__REALSUBDIR} +__TARGDIR := ${dir} +.if ${__TARGDIR} == ".WAIT" +SUBDIR_${targ} += .WAIT +.elif !commands(${targ}-${dir}) +${targ}-${dir}: .PHONY .MAKE __recurse +SUBDIR_${targ} += ${targ}-${dir} +.endif +.endfor +subdir-${targ}: .PHONY ${SUBDIR_${targ}} +${targ}: subdir-${targ} +.endfor + +.endif # ! NOSUBDIR # } + +${TARGETS}: # ensure existence diff --git a/etc/mk/minix.sys.mk b/etc/mk/minix.sys.mk new file mode 100644 index 000000000..0bc0fb102 --- /dev/null +++ b/etc/mk/minix.sys.mk @@ -0,0 +1,207 @@ +# $NetBSD: bsd.sys.mk,v 1.186 2009/11/30 16:13:23 uebayasi Exp $ +# +# Build definitions used for NetBSD source tree builds. + +.if !defined(_MINIX_SYS_MK_) +_MINIX_SYS_MK_=1 + +.if defined(WARNS) +.if ${WARNS} > 0 +CFLAGS+= -Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith +#CFLAGS+= -Wmissing-declarations -Wredundant-decls -Wnested-externs +# Add -Wno-sign-compare. -Wsign-compare is included in -Wall as of GCC 3.3, +# but our sources aren't up for it yet. Also, add -Wno-traditional because +# gcc includes #elif in the warnings, which is 'this code will not compile +# in a traditional environment' warning, as opposed to 'this code behaves +# differently in traditional and ansi environments' which is the warning +# we wanted, and now we don't get anymore. +CFLAGS+= -Wno-sign-compare -Wno-traditional +.if !defined(NOGCCERROR) +# Set assembler warnings to be fatal +CFLAGS+= -Wa,--fatal-warnings +.endif +# Set linker warnings to be fatal +# XXX no proper way to avoid "FOO is a patented algorithm" warnings +# XXX on linking static libs +.if (!defined(MKPIC) || ${MKPIC} != "no") && \ + (!defined(LDSTATIC) || ${LDSTATIC} != "-static") +LDFLAGS+= -Wl,--fatal-warnings +.endif +.endif +.if ${WARNS} > 1 +CFLAGS+= -Wreturn-type -Wswitch -Wshadow +.endif +.if ${WARNS} > 2 +CFLAGS+= -Wcast-qual -Wwrite-strings +CFLAGS+= -Wextra -Wno-unused-parameter +CXXFLAGS+= -Wabi +CXXFLAGS+= -Wold-style-cast +CXXFLAGS+= -Wctor-dtor-privacy -Wnon-virtual-dtor -Wreorder \ + -Wno-deprecated -Wno-non-template-friend \ + -Woverloaded-virtual -Wno-pmf-conversions -Wsign-promo -Wsynth +.endif +.if ${WARNS} > 3 && defined(HAVE_GCC) && ${HAVE_GCC} >= 3 +CFLAGS+= -Wsign-compare +CFLAGS+= -std=gnu99 +.endif +.endif + +# XXX: Temporarily disabled for MINIX +# CPPFLAGS+= ${AUDIT:D-D__AUDIT__} +# CFLAGS+= ${CWARNFLAGS} ${NOGCCERROR:D:U-Werror} +# LINTFLAGS+= ${DESTDIR:D-d ${DESTDIR}/usr/include} + +.if (${MACHINE_ARCH} == "alpha") || \ + (${MACHINE_ARCH} == "hppa") || \ + (${MACHINE_ARCH} == "ia64") || \ + (${MACHINE_ARCH} == "mipsel") || (${MACHINE_ARCH} == "mipseb") || \ + (${MACHINE_ARCH} == "mips64el") || (${MACHINE_ARCH} == "mips64eb") +HAS_SSP= no +.else +HAS_SSP= yes +.endif + +.if defined(USE_FORT) && (${USE_FORT} != "no") +USE_SSP?= yes +.if !defined(KERNSRCDIR) && !defined(KERN) # not for kernels nor kern modules +CPPFLAGS+= -D_FORTIFY_SOURCE=2 +.endif +.endif + +.if defined(USE_SSP) && (${USE_SSP} != "no") && (${BINDIR:Ux} != "/usr/mdec") +.if ${HAS_SSP} == "yes" +COPTS+= -fstack-protector -Wstack-protector --param ssp-buffer-size=1 +.endif +.endif + +.if defined(MKSOFTFLOAT) && (${MKSOFTFLOAT} != "no") +COPTS+= -msoft-float +FOPTS+= -msoft-float +.endif + +.if defined(MKIEEEFP) && (${MKIEEEFP} != "no") +.if ${MACHINE_ARCH} == "alpha" +CFLAGS+= -mieee +FFLAGS+= -mieee +.endif +.endif + +.if ${MACHINE} == "sparc64" && ${MACHINE_ARCH} == "sparc" +CFLAGS+= -Wa,-Av8plus +.endif + +CFLAGS+= ${CPUFLAGS} +AFLAGS+= ${CPUFLAGS} + +# Position Independent Executable flags +PIE_CFLAGS?= -fPIC -DPIC +PIE_LDFLAGS?= -Wl,-pie -shared-libgcc +PIE_AFLAGS?= -fPIC -DPIC + +# Helpers for cross-compiling +HOST_CC?= cc +HOST_CFLAGS?= -O +HOST_COMPILE.c?=${HOST_CC} ${HOST_CFLAGS} ${HOST_CPPFLAGS} -c +HOST_COMPILE.cc?= ${HOST_CXX} ${HOST_CXXFLAGS} ${HOST_CPPFLAGS} -c +.if defined(HOSTPROG_CXX) +HOST_LINK.c?= ${HOST_CXX} ${HOST_CXXFLAGS} ${HOST_CPPFLAGS} ${HOST_LDFLAGS} +.else +HOST_LINK.c?= ${HOST_CC} ${HOST_CFLAGS} ${HOST_CPPFLAGS} ${HOST_LDFLAGS} +.endif + +HOST_CXX?= c++ +HOST_CXXFLAGS?= -O + +HOST_CPP?= cpp +HOST_CPPFLAGS?= + +HOST_LD?= ld +HOST_LDFLAGS?= + +HOST_AR?= ar +HOST_RANLIB?= ranlib + +HOST_LN?= ln + +# HOST_SH must be an absolute path +HOST_SH?= /bin/sh + +ELF2ECOFF?= elf2ecoff +MKDEP?= mkdep +OBJCOPY?= objcopy +OBJDUMP?= objdump +PAXCTL?= paxctl +STRIP?= strip + +# TOOL_* variables are defined in bsd.own.mk + +.SUFFIXES: .o .ln .lo .c .cc .cpp .cxx .C .m ${YHEADER:D.h} + +# C +.c.o: + ${_MKTARGET_COMPILE} + ${COMPILE.c} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} + +.c.ln: + ${_MKTARGET_COMPILE} + ${LINT} ${LINTFLAGS} \ + ${CPPFLAGS:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ + ${CPPFLAGS.${.IMPSRC:T}:C/-([IDU])[ ]*/-\1/Wg:M-[IDU]*} \ + -i ${.IMPSRC} + +# C++ +.cc.o .cpp.o .cxx.o .C.o: + ${_MKTARGET_COMPILE} + ${COMPILE.cc} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} + +# Objective C +# (Defined here rather than in because `.m' is not just +# used for Objective C source) +.m.o: + ${_MKTARGET_COMPILE} + ${COMPILE.m} ${OBJCOPTS} ${OBJCOPTS.${.IMPSRC:T}} ${.IMPSRC} + +# Host-compiled C objects +# The intermediate step is necessary for Sun CC, which objects to calling +# object files anything but *.o +.c.lo: + ${_MKTARGET_COMPILE} + ${HOST_COMPILE.c} -o ${.TARGET}.o ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} + mv ${.TARGET}.o ${.TARGET} + +# C++ +.cc.lo .cpp.lo .cxx.lo .C.lo: + ${_MKTARGET_COMPILE} + ${HOST_COMPILE.cc} -o ${.TARGET}.o ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} + mv ${.TARGET}.o ${.TARGET} + +# Assembly +.s.o: + ${_MKTARGET_COMPILE} + ${COMPILE.s} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} + +.S.o: + ${_MKTARGET_COMPILE} + ${COMPILE.S} ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} ${.IMPSRC} + +# Lex +LFLAGS+= ${LPREFIX.${.IMPSRC:T}:D-P${LPREFIX.${.IMPSRC:T}}} +LFLAGS+= ${LPREFIX:D-P${LPREFIX}} + +.l.c: + ${_MKTARGET_LEX} + ${LEX.l} -o${.TARGET} ${.IMPSRC} + +# Yacc +YFLAGS+= ${YPREFIX.${.IMPSRC:T}:D-p${YPREFIX.${.IMPSRC:T}}} ${YHEADER.${.IMPSRC:T}:D-d} +YFLAGS+= ${YPREFIX:D-p${YPREFIX}} ${YHEADER:D-d} + +.y.c: + ${_MKTARGET_YACC} + ${YACC.y} -o ${.TARGET} ${.IMPSRC} + +.ifdef YHEADER +.y.h: ${.TARGET:.h=.c} +.endif + +.endif # !defined(_MINIX_SYS_MK_) diff --git a/kernel/Makefile b/kernel/Makefile index 3fc3bc070..55f4094d4 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -50,5 +50,3 @@ depend: .c.o: $(CC) $(CFLAGS) -c -o $@ $< -# Include generated dependencies. -include .depend diff --git a/kernel/arch/i386/Makefile b/kernel/arch/i386/Makefile index 481f9c51c..770fe661f 100644 --- a/kernel/arch/i386/Makefile +++ b/kernel/arch/i386/Makefile @@ -26,12 +26,13 @@ OBJS= arch_do_vmctl.o \ watchdog.o CPPFLAGS=-Iinclude -CFLAGS=$(CPPFLAGS) -Wall $(CPROFILE) +CFLAGS=-Iinclude -Wall $(CPROFILE) build: $(HEAD) $(ARCHAR) -$(ARCHAR): $(OBJS) +$(ARCHAR): $(ARCHAR)($(OBJS)) aal cr $@ $(OBJS) +# ar cru $(.TARGET) $(.OODATE) depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c *.S > .depend @@ -40,39 +41,6 @@ clean: rm -f *.a *.o *~ *.tmp *.s # How to build it -$(ARCHAR)(exception.o): exception.c - $(CC) $(CFLAGS) -c $< - -$(ARCHAR)(i8259.o): i8259.c - $(CC) $(CFLAGS) -c $< - -$(ARCHAR)(memory.o): memory.c - $(CC) $(CFLAGS) -c $< - -$(ARCHAR)(protect.o): protect.c - $(CC) $(CFLAGS) -c $< - -$(ARCHAR)(system.o): system.c - $(CC) $(CFLAGS) -c $< - -$(ARCHAR)(do_int86.o): do_int86.c - $(CC) $(CFLAGS) -c $< - -$(ARCHAR)(do_iopenable.o): do_iopenable.c - $(CC) $(CFLAGS) -c $< - -$(ARCHAR)(arch_do_vmctl.o): arch_do_vmctl.c - $(CC) $(CFLAGS) -c $< - -$(ARCHAR)(do_readbios.o): do_readbios.c - $(CC) $(CFLAGS) -c $< - -$(ARCHAR)(do_sdevio.o): do_sdevio.c - $(CC) $(CFLAGS) -c $< - -$(ARCHAR)(clock.o): clock.c - $(CC) $(CFLAGS) -c $< - klib386.o: klib386.S $(CC) $(CFLAGS) -E -D__ASSEMBLY__ -o $@.tmp $< gas2ack $@.tmp $@.s @@ -88,11 +56,6 @@ apic_asm.o: apic_asm.S gas2ack $@.tmp $@.s $(CC) $(CFLAGS) -c -o $@ $@.s -.c.o: - $(CC) $(CFLAGS) -c -o $@ $< - $(HEAD): mpx386.o cp $< $@ -# Include generated dependencies. -include .depend diff --git a/kernel/system/Makefile b/kernel/system/Makefile index 595164b27..f2d0081b2 100644 --- a/kernel/system/Makefile +++ b/kernel/system/Makefile @@ -8,12 +8,13 @@ i = $u/include a = ../arch # Programs, flags, etc. -CC = exec cc $(CFLAGS) -c -CCNOPROF = exec cc $(CFLAGSNOPROF) -c # no call profiling for these +#CC = exec cc $(CFLAGS) -c +CC = exec cc +#CCNOPROF = exec cc $(CFLAGSNOPROF) -c # no call profiling for these CPP = $l/cpp LD = $(CC) -.o CFLAGS = -I$i $(CPROFILE) -I$a/$(ARCH)/include -CFLAGSNOPROF = -I$i +#CFLAGSNOPROF = -I$i LDFLAGS = -i SYSTEM = ../system.a @@ -22,160 +23,49 @@ SYSTEM = ../system.a all build install: $(SYSTEM) OBJECTS = \ - $(SYSTEM)(do_unused.o) \ - $(SYSTEM)(do_fork.o) \ - $(SYSTEM)(do_exec.o) \ - $(SYSTEM)(do_newmap.o) \ - $(SYSTEM)(do_exit.o) \ - $(SYSTEM)(do_trace.o) \ - $(SYSTEM)(do_nice.o) \ - $(SYSTEM)(do_runctl.o) \ - $(SYSTEM)(do_times.o) \ - $(SYSTEM)(do_setalarm.o) \ - $(SYSTEM)(do_stime.o) \ - $(SYSTEM)(do_vtimer.o) \ - $(SYSTEM)(do_irqctl.o) \ - $(SYSTEM)(do_devio.o) \ - $(SYSTEM)(do_vdevio.o) \ - $(SYSTEM)(do_copy.o) \ - $(SYSTEM)(do_umap.o) \ - $(SYSTEM)(do_memset.o) \ - $(SYSTEM)(do_setgrant.o) \ - $(SYSTEM)(do_privctl.o) \ - $(SYSTEM)(do_segctl.o) \ - $(SYSTEM)(do_safecopy.o) \ - $(SYSTEM)(do_safemap.o) \ - $(SYSTEM)(do_sysctl.o) \ - $(SYSTEM)(do_getksig.o) \ - $(SYSTEM)(do_endksig.o) \ - $(SYSTEM)(do_kill.o) \ - $(SYSTEM)(do_sigsend.o) \ - $(SYSTEM)(do_sigreturn.o) \ - $(SYSTEM)(do_abort.o) \ - $(SYSTEM)(do_getinfo.o) \ - $(SYSTEM)(do_sprofile.o) \ - $(SYSTEM)(do_cprofile.o) \ - $(SYSTEM)(do_profbuf.o) \ - $(SYSTEM)(do_vmctl.o) + do_unused.o \ + do_fork.o \ + do_exec.o \ + do_newmap.o \ + do_exit.o \ + do_trace.o \ + do_nice.o \ + do_runctl.o \ + do_times.o \ + do_setalarm.o \ + do_stime.o \ + do_vtimer.o \ + do_irqctl.o \ + do_devio.o \ + do_vdevio.o \ + do_copy.o \ + do_umap.o \ + do_memset.o \ + do_setgrant.o \ + do_privctl.o \ + do_segctl.o \ + do_safecopy.o \ + do_safemap.o \ + do_sysctl.o \ + do_getksig.o \ + do_endksig.o \ + do_kill.o \ + do_sigsend.o \ + do_sigreturn.o \ + do_abort.o \ + do_getinfo.o \ + do_sprofile.o \ + do_cprofile.o \ + do_profbuf.o \ + do_vmctl.o -build $(SYSTEM): $(OBJECTS) +build $(SYSTEM): $(SYSTEM)($(OBJECTS)) aal cr $@ *.o +# aal cr $@ $(OBJECTS) +# ar cru $(.TARGET) $(.OODATE) clean: rm -f $(SYSTEM) *.o *~ *.bak depend: - mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend - -# Include generated dependencies. -include .depend - - -$(SYSTEM)(do_unused.o): do_unused.c - $(CC) do_unused.c - -$(SYSTEM)(do_fork.o): do_fork.c - $(CC) do_fork.c - -$(SYSTEM)(do_exec.o): do_exec.c - $(CC) do_exec.c - -$(SYSTEM)(do_newmap.o): do_newmap.c - $(CC) do_newmap.c - -$(SYSTEM)(do_exit.o): do_exit.c - $(CC) do_exit.c - -$(SYSTEM)(do_trace.o): do_trace.c - $(CC) do_trace.c - -$(SYSTEM)(do_nice.o): do_nice.c - $(CC) do_nice.c - -$(SYSTEM)(do_runctl.o): do_runctl.c - $(CC) do_runctl.c - -$(SYSTEM)(do_times.o): do_times.c - $(CC) do_times.c - -$(SYSTEM)(do_setalarm.o): do_setalarm.c - $(CC) do_setalarm.c - -$(SYSTEM)(do_stime.o): do_stime.c - $(CC) do_stime.c - -$(SYSTEM)(do_vtimer.o): do_vtimer.c - $(CC) do_vtimer.c - -$(SYSTEM)(do_irqctl.o): do_irqctl.c - $(CC) do_irqctl.c - -$(SYSTEM)(do_devio.o): do_devio.c - $(CC) do_devio.c - -$(SYSTEM)(do_vdevio.o): do_vdevio.c - $(CC) do_vdevio.c - -$(SYSTEM)(do_copy.o): do_copy.c - $(CC) do_copy.c - -$(SYSTEM)(do_umap.o): do_umap.c - $(CC) do_umap.c - -$(SYSTEM)(do_memset.o): do_memset.c - $(CC) do_memset.c - -$(SYSTEM)(do_getksig.o): do_getksig.c - $(CC) do_getksig.c - -$(SYSTEM)(do_endksig.o): do_endksig.c - $(CC) do_endksig.c - -$(SYSTEM)(do_kill.o): do_kill.c - $(CC) do_kill.c - -$(SYSTEM)(do_sigsend.o): do_sigsend.c - $(CC) do_sigsend.c - -$(SYSTEM)(do_sigreturn.o): do_sigreturn.c - $(CC) do_sigreturn.c - -$(SYSTEM)(do_getinfo.o): do_getinfo.c - $(CC) do_getinfo.c - -$(SYSTEM)(do_abort.o): do_abort.c - $(CC) do_abort.c - -$(SYSTEM)(do_setgrant.o): do_setgrant.c - $(CC) do_setgrant.c - -$(SYSTEM)(do_privctl.o): do_privctl.c - $(CC) do_privctl.c - -$(SYSTEM)(do_safecopy.o): do_safecopy.c - $(CC) do_safecopy.c - -$(SYSTEM)(do_safemap.o): do_safemap.c - $(CC) do_safemap.c - -$(SYSTEM)(do_sysctl.o): do_sysctl.c - $(CC) do_sysctl.c - -$(SYSTEM)(do_segctl.o): do_segctl.c - $(CC) do_segctl.c - -$(SYSTEM)(do_vm.o): do_vm.o -do_vm.o: do_vm.c - $(CC) do_vm.c - -$(SYSTEM)(do_sprofile.o): do_sprofile.c - $(CC) do_sprofile.c - -$(SYSTEM)(do_cprofile.o): do_cprofile.c - $(CC) do_cprofile.c - -$(SYSTEM)(do_profbuf.o): do_profbuf.c - $(CC) do_profbuf.c - -$(SYSTEM)(do_vmctl.o): do_vmctl.c - $(CC) do_vmctl.c + mkdep "$(CC) $(CFLAGS) -E" *.c > .depend diff --git a/kernel/utility.c b/kernel/utility.c index 07989df5e..8dd4f5201 100644 --- a/kernel/utility.c +++ b/kernel/utility.c @@ -1,6 +1,6 @@ /* This file contains a collection of miscellaneous procedures: * minix_panic: abort MINIX due to a fatal error - * kprintf: (from lib/sysutil/kprintf.c) + * kprintf: (from libsys/kprintf.c) * kputc: buffered putc used by kernel kprintf */ @@ -52,7 +52,7 @@ if (minix_panicing++) { /* Include system printf() implementation named kprintf() */ #define printf kprintf -#include "../lib/sysutil/kprintf.c" +#include "../lib/libsys/kprintf.c" /*===========================================================================* * kputc * diff --git a/lib/.depend-ack b/lib/.depend-ack deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/.depend-gnu b/lib/.depend-gnu deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/Makedepend-ack b/lib/Makedepend-ack deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/Makedepend-gnu b/lib/Makedepend-gnu deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/Makefile b/lib/Makefile index 9d36f2b77..63de6aa0c 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -1,211 +1,9 @@ -#Generated from ./Makefile.in -all: all-ack +.include -all-ack: -all-gnu: +SUBDIR= csu libc libcurses libend libedit libm libsys libtimers libutil -makefiles: Makefile -Makedepend-ack Makedepend-gnu: - sh ./generate.sh . obj-ack obj-gnu +.if (${COMPILER_TYPE} == ack) +SUBDIR+= ack/libd ack/libe ack/libfp ack/liby +.endif -Makefile: Makefile.in Makedepend-ack Makedepend-gnu - sh ./generate.sh . obj-ack obj-gnu - @echo - @echo *Attention* - @echo Makefile is regenerated... rerun command to see changes - @echo *Attention* - @echo - -all-ack: makefiles - mkdir -p obj-ack/./ansi - cd ansi && $(MAKE) $@ - mkdir -p obj-ack/./curses - cd curses && $(MAKE) $@ - mkdir -p obj-ack/./dummy - cd dummy && $(MAKE) $@ - mkdir -p obj-ack/./editline - cd editline && $(MAKE) $@ - mkdir -p obj-ack/./end - cd end && $(MAKE) $@ - mkdir -p obj-ack/./ip - cd ip && $(MAKE) $@ - mkdir -p obj-ack/./math - cd math && $(MAKE) $@ - mkdir -p obj-ack/./other - cd other && $(MAKE) $@ - mkdir -p obj-ack/./posix - cd posix && $(MAKE) $@ - mkdir -p obj-ack/./regex - cd regex && $(MAKE) $@ - mkdir -p obj-ack/./stdio - cd stdio && $(MAKE) $@ - mkdir -p obj-ack/./stdtime - cd stdtime && $(MAKE) $@ - mkdir -p obj-ack/./syscall - cd syscall && $(MAKE) $@ - mkdir -p obj-ack/./syslib - cd syslib && $(MAKE) $@ - mkdir -p obj-ack/./util - cd util && $(MAKE) $@ - mkdir -p obj-ack/./sysutil - cd sysutil && $(MAKE) $@ - mkdir -p obj-ack/./sysvipc - cd sysvipc && $(MAKE) $@ - mkdir -p obj-ack/./timers - cd timers && $(MAKE) $@ - mkdir -p obj-ack/./i386 - cd i386 && $(MAKE) $@ - mkdir -p obj-ack/./ack - cd ack && $(MAKE) $@ - mkdir -p obj-ack/./gnu - cd gnu && $(MAKE) $@ - -all-gnu: makefiles - mkdir -p obj-gnu/./ansi - cd ansi && $(MAKE) $@ - mkdir -p obj-gnu/./curses - cd curses && $(MAKE) $@ - mkdir -p obj-gnu/./dummy - cd dummy && $(MAKE) $@ - mkdir -p obj-gnu/./editline - cd editline && $(MAKE) $@ - mkdir -p obj-gnu/./end - cd end && $(MAKE) $@ - mkdir -p obj-gnu/./ip - cd ip && $(MAKE) $@ - mkdir -p obj-gnu/./math - cd math && $(MAKE) $@ - mkdir -p obj-gnu/./other - cd other && $(MAKE) $@ - mkdir -p obj-gnu/./posix - cd posix && $(MAKE) $@ - mkdir -p obj-gnu/./regex - cd regex && $(MAKE) $@ - mkdir -p obj-gnu/./stdio - cd stdio && $(MAKE) $@ - mkdir -p obj-gnu/./stdtime - cd stdtime && $(MAKE) $@ - mkdir -p obj-gnu/./syscall - cd syscall && $(MAKE) $@ - mkdir -p obj-gnu/./syslib - cd syslib && $(MAKE) $@ - mkdir -p obj-gnu/./util - cd util && $(MAKE) $@ - mkdir -p obj-gnu/./sysutil - cd sysutil && $(MAKE) $@ - mkdir -p obj-gnu/./sysvipc - cd sysvipc && $(MAKE) $@ - mkdir -p obj-gnu/./timers - cd timers && $(MAKE) $@ - mkdir -p obj-gnu/./i386 - cd i386 && $(MAKE) $@ - mkdir -p obj-gnu/./ack - cd ack && $(MAKE) $@ - mkdir -p obj-gnu/./gnu - cd gnu && $(MAKE) $@ - -clean depend depend-ack depend-gnu:: makefiles - cd ansi && $(MAKE) $@ - cd curses && $(MAKE) $@ - cd dummy && $(MAKE) $@ - cd editline && $(MAKE) $@ - cd end && $(MAKE) $@ - cd ip && $(MAKE) $@ - cd math && $(MAKE) $@ - cd other && $(MAKE) $@ - cd posix && $(MAKE) $@ - cd regex && $(MAKE) $@ - cd stdio && $(MAKE) $@ - cd stdtime && $(MAKE) $@ - cd syscall && $(MAKE) $@ - cd syslib && $(MAKE) $@ - cd util && $(MAKE) $@ - cd sysutil && $(MAKE) $@ - cd sysvipc && $(MAKE) $@ - cd timers && $(MAKE) $@ - cd i386 && $(MAKE) $@ - cd ack && $(MAKE) $@ - cd gnu && $(MAKE) $@ - -makefiles: ansi/Makefile -makefiles: curses/Makefile -makefiles: dummy/Makefile -makefiles: editline/Makefile -makefiles: end/Makefile -makefiles: ip/Makefile -makefiles: math/Makefile -makefiles: other/Makefile -makefiles: posix/Makefile -makefiles: regex/Makefile -makefiles: stdio/Makefile -makefiles: stdtime/Makefile -makefiles: syscall/Makefile -makefiles: syslib/Makefile -makefiles: util/Makefile -makefiles: sysutil/Makefile -makefiles: sysvipc/Makefile -makefiles: timers/Makefile -makefiles: i386/Makefile -makefiles: ack/Makefile -makefiles: gnu/Makefile - -ansi/Makefile: ansi/Makefile.in - cd ansi && sh .././generate.sh ./ansi ../obj-ack ../obj-gnu && $(MAKE) makefiles -curses/Makefile: curses/Makefile.in - cd curses && sh .././generate.sh ./curses ../obj-ack ../obj-gnu && $(MAKE) makefiles -dummy/Makefile: dummy/Makefile.in - cd dummy && sh .././generate.sh ./dummy ../obj-ack ../obj-gnu && $(MAKE) makefiles -editline/Makefile: editline/Makefile.in - cd editline && sh .././generate.sh ./editline ../obj-ack ../obj-gnu && $(MAKE) makefiles -end/Makefile: end/Makefile.in - cd end && sh .././generate.sh ./end ../obj-ack ../obj-gnu && $(MAKE) makefiles -ip/Makefile: ip/Makefile.in - cd ip && sh .././generate.sh ./ip ../obj-ack ../obj-gnu && $(MAKE) makefiles -math/Makefile: math/Makefile.in - cd math && sh .././generate.sh ./math ../obj-ack ../obj-gnu && $(MAKE) makefiles -other/Makefile: other/Makefile.in - cd other && sh .././generate.sh ./other ../obj-ack ../obj-gnu && $(MAKE) makefiles -posix/Makefile: posix/Makefile.in - cd posix && sh .././generate.sh ./posix ../obj-ack ../obj-gnu && $(MAKE) makefiles -regex/Makefile: regex/Makefile.in - cd regex && sh .././generate.sh ./regex ../obj-ack ../obj-gnu && $(MAKE) makefiles -stdio/Makefile: stdio/Makefile.in - cd stdio && sh .././generate.sh ./stdio ../obj-ack ../obj-gnu && $(MAKE) makefiles -stdtime/Makefile: stdtime/Makefile.in - cd stdtime && sh .././generate.sh ./stdtime ../obj-ack ../obj-gnu && $(MAKE) makefiles -syscall/Makefile: syscall/Makefile.in - cd syscall && sh .././generate.sh ./syscall ../obj-ack ../obj-gnu && $(MAKE) makefiles -syslib/Makefile: syslib/Makefile.in - cd syslib && sh .././generate.sh ./syslib ../obj-ack ../obj-gnu && $(MAKE) makefiles -util/Makefile: util/Makefile.in - cd util && sh .././generate.sh ./util ../obj-ack ../obj-gnu && $(MAKE) makefiles -sysutil/Makefile: sysutil/Makefile.in - cd sysutil && sh .././generate.sh ./sysutil ../obj-ack ../obj-gnu && $(MAKE) makefiles -sysvipc/Makefile: sysvipc/Makefile.in - cd sysvipc && sh .././generate.sh ./sysvipc ../obj-ack ../obj-gnu && $(MAKE) makefiles -timers/Makefile: timers/Makefile.in - cd timers && sh .././generate.sh ./timers ../obj-ack ../obj-gnu && $(MAKE) makefiles -i386/Makefile: i386/Makefile.in - cd i386 && sh .././generate.sh ./i386 ../obj-ack ../obj-gnu && $(MAKE) makefiles -ack/Makefile: ack/Makefile.in - cd ack && sh .././generate.sh ./ack ../obj-ack ../obj-gnu && $(MAKE) makefiles -gnu/Makefile: gnu/Makefile.in - cd gnu && sh .././generate.sh ./gnu ../obj-ack ../obj-gnu && $(MAKE) makefiles - -clean:: - rm -f obj-ack/./* - rm -f obj-gnu/./* - -install: install-ack - -install-ack: all-ack - cp obj-ack/*.[ao] /usr/lib/i386 - -install-gnu: all-gnu - cp obj-gnu/*.[ao] /usr/gnu/lib - -include Makedepend-ack -include .depend-ack - -include Makedepend-gnu -include .depend-gnu +.include diff --git a/lib/Makefile.in b/lib/Makefile.in deleted file mode 100644 index 64c4cd8a5..000000000 --- a/lib/Makefile.in +++ /dev/null @@ -1,31 +0,0 @@ - -#ACKBASE=$(CURDIR)/obj-ack -#GNUBASE=$(CURDIR)/obj-gnu - -#OBJDIR=. - -. /etc/make.conf - -SUBDIRS="ansi \ - curses \ - dummy \ - editline \ - end \ - ip \ - math \ - other \ - posix \ - regex \ - stdio \ - stdtime \ - syscall \ - syslib \ - util \ - sysutil \ - sysvipc \ - timers \ - $ARCH \ - ack - gnu" - -TYPE=both diff --git a/lib/README b/lib/README index 466ca8c07..cc3d9c3a4 100644 --- a/lib/README +++ b/lib/README @@ -1,7 +1,14 @@ -make depend - find dependencies of ack libraries -make all - compile ack libraries -make install - compile and install ack libraries +ack_build.sh - for ACK library building +gnu_build.sh - for GNU library building -make depend-gnu - find dependencies of gnu libraries -make all-gnu - compile gnu libraries -make install-gnu - compile and install gnu libraries +ack_build.sh obj - create objdirs for gnu libraries +ack_build.sh depend - find dependencies of ack libraries +ack_build.sh all - compile ack libraries +ack_build.sh install - compile and install ack libraries +ack_build.sh clean - clean for ack libraries + +gnu_build.sh obj - create objdirs for gnu libraries +gnu_build.sh depend - find dependencies of gnu libraries +gnu_build.sh all - compile gnu libraries +gnu_build.sh install - compile and install gnu libraries +gnu_build.sh clean - clean for gnu libraries diff --git a/lib/ack/Makefile.in b/lib/ack/Makefile.in deleted file mode 100644 index 7987b479b..000000000 --- a/lib/ack/Makefile.in +++ /dev/null @@ -1,12 +0,0 @@ - -SUBDIRS=" \ - float \ - fphook \ - i386 \ - libm2 \ - libp \ - liby \ - math \ - rts" - -TYPE=ack diff --git a/lib/ack/float/FP.compile b/lib/ack/float/FP.compile deleted file mode 100755 index f0868f073..000000000 --- a/lib/ack/float/FP.compile +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh -# Author: Kees J. Bot -# Compile one soft FP source file. -# (These files shouldn't be optimized normally, but the 16-bit C compiler -# only optimizes scratch register allocation a bit with -O. To the 32-bit -# compiler -O is a no-op.) - -case $#:$2 in -2:*.fc) ;; -*) echo "$0: $1: not a FC file" >&2; exit 1 -esac - -dst=$1 -src=$2 -base="`basename "$src" .fc`" -trap 'rm -f tmp.c tmp.s"; exit 1' 2 - -cp "$src" tmp.c && -cc -O -I. -D_MINIX -D_POSIX_SOURCE -S tmp.c && -sed -f FP.script tmp.s > "$base.s" && -cc -c -o $dst "$base.s" && -rm tmp.c tmp.s diff --git a/lib/ack/float/Makefile.in b/lib/ack/float/Makefile.in deleted file mode 100644 index 589e03f95..000000000 --- a/lib/ack/float/Makefile.in +++ /dev/null @@ -1,61 +0,0 @@ -# Makefile for lib/float. - -#CC1 = /bin/sh ./FP.compile - -LIBRARIES=libfp - -libfp_FILES=" \ - add_ext.fc \ - adder.fc \ - adf4.fc \ - adf8.fc \ - cff4.fc \ - cff8.fc \ - cfi.fc \ - cfu.fc \ - cif4.fc \ - cif8.fc \ - cmf4.fc \ - cmf8.fc \ - compact.fc \ - cuf4.fc \ - cuf8.fc \ - div_ext.fc \ - dvf4.fc \ - dvf8.fc \ - extend.fc \ - fef4.fc \ - fef8.fc \ - fif4.fc \ - fif8.fc \ - fptrp.s \ - mlf4.fc \ - mlf8.fc \ - mul_ext.fc \ - ngf4.fc \ - ngf8.fc \ - nrm_ext.fc \ - sbf4.fc \ - sbf8.fc \ - sft_ext.fc \ - shifter.fc \ - sub_ext.fc \ - zrf4.fc \ - zrf8.fc \ - zrf_ext.fc" - -TYPE=ack - -#extra commands to convert the c files to the correct assembler files - -#%.s: %.fc -# /bin/sh ./FP.compile $< - -#1. make a assembler file of the c file -#%.fs: %.fc -# -cp $< $(<:.fc=.c) && cc -O -I. -D_MINIX -D_POSIX_SOURCE -S $(<:.fc=.c) && cp $(<:.fc=.s) $(<:.fc=.fs) -# @rm $(<:.fc=.c) $(<:.fc=.s) - -#2. modify the assembler file -#%.s: %.fs -# sed -f FP.script $< > $@ diff --git a/lib/ack/fphook/FP.compile b/lib/ack/fphook/FP.compile deleted file mode 100755 index 3ca814d8a..000000000 --- a/lib/ack/fphook/FP.compile +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh -# Author: Kees J. Bot -# Compile one soft FP source file. -# (These files shouldn't be optimized normally, but the 16-bit C compiler -# only optimizes scratch register allocation a bit with -O. To the 32-bit -# compiler -O is a no-op.) - -case $#:$1 in -1:*.fc) ;; -*) echo "$0: $1: not a FC file" >&2; exit 1 -esac - -base="`basename "$1" .fc`" -trap 'rm -f tmp.c tmp.s"; exit 1' 2 - -cp "$1" tmp.c && -cc -O -I. -D_MINIX -D_POSIX_SOURCE -S tmp.c && -sed -f FP.script tmp.s > "$base.s" && -rm tmp.c tmp.s diff --git a/lib/ack/fphook/FP.script b/lib/ack/fphook/FP.script deleted file mode 100755 index 56a3fd608..000000000 --- a/lib/ack/fphook/FP.script +++ /dev/null @@ -1,39 +0,0 @@ -s/_adf4/.adf4/ -s/_adf8/.adf8/ -s/_cff4/.cff4/ -s/_cff8/.cff8/ -s/_cfi/.cfi/ -s/_cfu/.cfu/ -s/_cif4/.cif4/ -s/_cif8/.cif8/ -s/_cmf4/.cmf4/ -s/_cmf8/.cmf8/ -s/_cuf4/.cuf4/ -s/_cuf8/.cuf8/ -s/_dvf4/.dvf4/ -s/_dvf8/.dvf8/ -s/_fef4/.fef4/ -s/_fef8/.fef8/ -s/_fif4/.fif4/ -s/_fif8/.fif8/ -s/_mlf4/.mlf4/ -s/_mlf8/.mlf8/ -s/_ngf4/.ngf4/ -s/_ngf8/.ngf8/ -s/_sbf4/.sbf4/ -s/_sbf8/.sbf8/ -s/_zrf4/.zrf4/ -s/_zrf8/.zrf8/ -s/_add_ext/.add_ext/ -s/_div_ext/.div_ext/ -s/_mul_ext/.mul_ext/ -s/_nrm_ext/.nrm_ext/ -s/_sft_ext/.sft_ext/ -s/_sub_ext/.sub_ext/ -s/_zrf_ext/.zrf_ext/ -s/_compact/.compact/ -s/_extend/.extend/ -s/_b64_add/.b64_add/ -s/_b64_sft/.b64_sft/ -s/_b64_rsft/.b64_rsft/ -s/_b64_lsft/.b64_lsft/ diff --git a/lib/ack/fphook/FP_bias.h b/lib/ack/fphook/FP_bias.h deleted file mode 100644 index db17a4132..000000000 --- a/lib/ack/fphook/FP_bias.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - include file for floating point package -*/ - - /* FLOAT FORMAT EXPONENT BIAS */ - -#define SGL_BIAS 127 /* excess 128 notation used */ -#define DBL_BIAS 1023 /* excess 1024 notation used */ -#define EXT_BIAS 0 /* 2s-complement notation used */ - /* this is possible because the */ - /* sign is in a seperate word */ - - /* VARIOUS MAX AND MIN VALUES */ - /* 1) FOR THE DIFFERENT FORMATS */ - -#define SGL_MAX 254 /* standard definition */ -#define SGL_MIN 1 /* standard definition */ -#define DBL_MAX 2046 /* standard definition */ -#define DBL_MIN 1 /* standard definition */ -#define EXT_MAX 16383 /* standard minimum */ -#define EXT_MIN -16382 /* standard minimum */ diff --git a/lib/ack/fphook/FP_shift.h b/lib/ack/fphook/FP_shift.h deleted file mode 100644 index 5b685636f..000000000 --- a/lib/ack/fphook/FP_shift.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - include file for floating point package -*/ - -# define CARRYBIT 0x80000000L -# define NORMBIT 0x80000000L -# define EXP_STORE 16 - - - /* parameters for Single Precision */ -#define SGL_EXPSHIFT 7 -#define SGL_M1LEFT 8 -#define SGL_ZERO 0xffffff80L -#define SGL_EXACT 0xff -#define SGL_RUNPACK SGL_M1LEFT - -#define SGL_ROUNDUP 0x80 -#define SGL_CARRYOUT 0x01000000L -#define SGL_MASK 0x007fffffL - - /* parameters for Double Precision */ - /* used in extend.c */ - -#define DBL_EXPSHIFT 4 - -#define DBL_M1LEFT 11 - -#define DBL_RPACK (32-DBL_M1LEFT) -#define DBL_LPACK DBL_M1LEFT - - /* used in compact.c */ - -#define DBL_ZERO 0xfffffd00L - -#define DBL_EXACT 0x7ff - -#define DBL_RUNPACK DBL_M1LEFT -#define DBL_LUNPACK (32-DBL_RUNPACK) - -#define DBL_ROUNDUP 0x400 -#define DBL_CARRYOUT 0x00200000L -#define DBL_MASK 0x000fffffL diff --git a/lib/ack/fphook/FP_trap.h b/lib/ack/fphook/FP_trap.h deleted file mode 100644 index 045897bc3..000000000 --- a/lib/ack/fphook/FP_trap.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - include file for floating point package -*/ - - /* EM TRAPS */ - -#define EIOVFL 3 /* Integer Overflow */ -#define EFOVFL 4 /* Floating Overflow */ -#define EFUNFL 5 /* Floating Underflow */ -#define EIDIVZ 6 /* Integer Divide by 0 */ -#define EFDIVZ 7 /* Floating Divide by 0.0 */ -#define EIUND 8 /* Integer Undefined Number */ -#define EFUND 9 /* Floating Undefined Number */ -#define ECONV 10 /* Conversion Error */ -# define trap(x) _fptrp(x) diff --git a/lib/ack/fphook/FP_types.h b/lib/ack/fphook/FP_types.h deleted file mode 100644 index a23f32b89..000000000 --- a/lib/ack/fphook/FP_types.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/********************************************************/ -/* - Type definitions for C Floating Point Package - include file for floating point package -*/ -/********************************************************/ -/* - THESE STRUCTURES ARE USED TO ADDRESS THE INDIVIDUAL - PARTS OF THE FLOATING POINT NUMBER REPRESENTATIONS. - - THREE STRUCTURES ARE DEFINED: - SINGLE: single precision floating format - DOUBLE: double precision floating format - EXTEND: double precision extended format -*/ -/********************************************************/ - -#ifndef __FPTYPES -#define __FPTYPES - -typedef struct { - unsigned long h_32; /* higher 32 bits of 64 */ - unsigned long l_32; /* lower 32 bits of 64 */ -} B64; - -typedef unsigned long SINGLE; - -typedef struct { - unsigned long d[2]; -} DOUBLE; - -typedef struct { /* expanded float format */ - short sign; - short exp; - B64 mantissa; -#define m1 mantissa.h_32 -#define m2 mantissa.l_32 -} EXTEND; - -struct fef4_returns { - int e; - SINGLE f; -}; - -struct fef8_returns { - int e; - DOUBLE f; -}; - -struct fif4_returns { - SINGLE ipart; - SINGLE fpart; -}; - -struct fif8_returns { - DOUBLE ipart; - DOUBLE fpart; -}; - -#if __STDC__ -#define _PROTOTYPE(function, params) function params -#else -#define _PROTOTYPE(function, params) function() -#endif -_PROTOTYPE( void add_ext, (EXTEND *e1, EXTEND *e2)); -_PROTOTYPE( void mul_ext, (EXTEND *e1, EXTEND *e2)); -_PROTOTYPE( void div_ext, (EXTEND *e1, EXTEND *e2)); -_PROTOTYPE( void sub_ext, (EXTEND *e1, EXTEND *e2)); -_PROTOTYPE( void sft_ext, (EXTEND *e1, EXTEND *e2)); -_PROTOTYPE( void nrm_ext, (EXTEND *e1)); -_PROTOTYPE( void zrf_ext, (EXTEND *e1)); -_PROTOTYPE( void extend, (unsigned long *from, EXTEND *to, int size)); -_PROTOTYPE( void compact, (EXTEND *from, unsigned long *to, int size)); -_PROTOTYPE( void _fptrp, (int)); -_PROTOTYPE( void adf4, (SINGLE s2, SINGLE s1)); -_PROTOTYPE( void adf8, (DOUBLE s2, DOUBLE s1)); -_PROTOTYPE( void sbf4, (SINGLE s2, SINGLE s1)); -_PROTOTYPE( void sbf8, (DOUBLE s2, DOUBLE s1)); -_PROTOTYPE( void dvf4, (SINGLE s2, SINGLE s1)); -_PROTOTYPE( void dvf8, (DOUBLE s2, DOUBLE s1)); -_PROTOTYPE( void mlf4, (SINGLE s2, SINGLE s1)); -_PROTOTYPE( void mlf8, (DOUBLE s2, DOUBLE s1)); -_PROTOTYPE( void ngf4, (SINGLE f)); -_PROTOTYPE( void ngf8, (DOUBLE f)); -_PROTOTYPE( void zrf4, (SINGLE *l)); -_PROTOTYPE( void zrf8, (DOUBLE *z)); -_PROTOTYPE( void cff4, (DOUBLE src)); -_PROTOTYPE( void cff8, (SINGLE src)); -_PROTOTYPE( void cif4, (int ss, long src)); -_PROTOTYPE( void cif8, (int ss, long src)); -_PROTOTYPE( void cuf4, (int ss, long src)); -_PROTOTYPE( void cuf8, (int ss, long src)); -_PROTOTYPE( long cfu, (int ds, int ss, DOUBLE src)); -_PROTOTYPE( long cfi, (int ds, int ss, DOUBLE src)); -_PROTOTYPE( int cmf4, (SINGLE s2, SINGLE s1)); -_PROTOTYPE( int cmf8, (DOUBLE d1, DOUBLE d2)); -_PROTOTYPE( void fef4, (struct fef4_returns *r, SINGLE s1)); -_PROTOTYPE( void fef8, (struct fef8_returns *r, DOUBLE s1)); -_PROTOTYPE( void fif4, (struct fif4_returns *p, SINGLE x, SINGLE y)); -_PROTOTYPE( void fif8, (struct fif8_returns *p, DOUBLE x, DOUBLE y)); - -_PROTOTYPE( void b64_sft, (B64 *, int)); -_PROTOTYPE( void b64_lsft, (B64 *)); -_PROTOTYPE( void b64_rsft, (B64 *)); -_PROTOTYPE( int b64_add, (B64 *, B64 *)); -#endif diff --git a/lib/ack/fphook/add_ext.fc b/lib/ack/fphook/add_ext.fc deleted file mode 100644 index a077663ab..000000000 --- a/lib/ack/fphook/add_ext.fc +++ /dev/null @@ -1,56 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - ADD TWO EXTENDED FORMAT NUMBERS -*/ - -#include "FP_types.h" - -void -add_ext(e1,e2) -register EXTEND *e1,*e2; -{ - if ((e2->m1 | e2->m2) == 0L) { - return; - } - if ((e1->m1 | e1->m2) == 0L) { - *e1 = *e2; - return; - } - sft_ext(e1, e2); /* adjust mantissas to equal powers */ - if (e1->sign != e2->sign) { - /* e1 + e2 = e1 - (-e2) */ - if (e2->m1 > e1->m1 || - (e2->m1 == e1->m1 && e2->m2 > e1->m2)) { - /* abs(e2) > abs(e1) */ - EXTEND x; - - x = *e1; - *e1 = *e2; - if (x.m2 > e1->m2) { - e1->m1 -= 1; /* carry in */ - } - e1->m1 -= x.m1; - e1->m2 -= x.m2; - } - else { - if (e2->m2 > e1->m2) - e1->m1 -= 1; /* carry in */ - e1->m1 -= e2->m1; - e1->m2 -= e2->m2; - } - } - else { - if (b64_add(&e1->mantissa,&e2->mantissa)) { /* addition carry */ - b64_rsft(&e1->mantissa); /* shift mantissa one bit RIGHT */ - e1->m1 |= 0x80000000L; /* set max bit */ - e1->exp++; /* increase the exponent */ - } - } - nrm_ext(e1); -} diff --git a/lib/ack/fphook/adder.fc b/lib/ack/fphook/adder.fc deleted file mode 100644 index a0af3ce75..000000000 --- a/lib/ack/fphook/adder.fc +++ /dev/null @@ -1,50 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - * these are the routines the routines to do 32 and 64-bit addition - */ - -# ifdef EXT_DEBUG -# include -# endif - -# include "FP_types.h" -# define UNKNOWN -1 -# define TRUE 1 -# define FALSE 0 -# define MAXBIT 0x80000000L - - /* - * add 64 bits - */ -int -b64_add(e1,e2) - /* - * pointers to 64 bit 'registers' - */ -register B64 *e1,*e2; -{ - register int overflow; - int carry; - - /* add higher pair of 32 bits */ - overflow = ((unsigned long) 0xFFFFFFFF - e1->h_32 < e2->h_32); - e1->h_32 += e2->h_32; - - /* add lower pair of 32 bits */ - carry = ((unsigned long) 0xFFFFFFFF - e1->l_32 < e2->l_32); - e1->l_32 += e2->l_32; -# ifdef EXT_DEBUG - printf("\t\t\t\t\tb64_add: overflow (%d); internal carry(%d)\n", - overflow,carry); - fflush(stdout); -# endif - if ((carry) && (++e1->h_32 == 0)) - return(TRUE); /* had a 64 bit overflow */ - return(overflow); /* return status from higher add */ -} diff --git a/lib/ack/fphook/adder.h b/lib/ack/fphook/adder.h deleted file mode 100644 index 2fed41451..000000000 --- a/lib/ack/fphook/adder.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - * include file for 32 & 64 bit addition - */ - -typedef struct B64 { - unsigned long h_32; /* higher 32 bits of 64 */ - unsigned long l_32; /* lower 32 bits of 64 */ -} B64; diff --git a/lib/ack/fphook/adf4.fc b/lib/ack/fphook/adf4.fc deleted file mode 100644 index 572f3daa3..000000000 --- a/lib/ack/fphook/adf4.fc +++ /dev/null @@ -1,32 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - ADD TWO FLOATS - SINGLE (ADF 4) -*/ - -#include "FP_types.h" - -void -adf4(s2,s1) -SINGLE s1,s2; -{ - EXTEND e1,e2; - int swap = 0; - - if (s1 == (SINGLE) 0) { - s1 = s2; - return; - } - if (s2 == (SINGLE) 0) { - return; - } - extend(&s1,&e1,sizeof(SINGLE)); - extend(&s2,&e2,sizeof(SINGLE)); - add_ext(&e1,&e2); - compact(&e1,&s1,sizeof(SINGLE)); -} diff --git a/lib/ack/fphook/adf8.fc b/lib/ack/fphook/adf8.fc deleted file mode 100644 index 387c975c0..000000000 --- a/lib/ack/fphook/adf8.fc +++ /dev/null @@ -1,32 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - ADD TWO FLOATS - DOUBLE (ADF 8) -*/ - -#include "FP_types.h" - -void -adf8(s2,s1) -DOUBLE s1,s2; -{ - EXTEND e1,e2; - - if (s1.d[0] == 0 && s1.d[1] == 0) { - s1 = s2; - return; - } - if (s2.d[0] == 0 && s2.d[1] == 0) { - return; - } - - extend(&s1.d[0],&e1,sizeof(DOUBLE)); - extend(&s2.d[0],&e2,sizeof(DOUBLE)); - add_ext(&e1,&e2); - compact(&e1,&s1.d[0],sizeof(DOUBLE)); -} diff --git a/lib/ack/fphook/cff4.fc b/lib/ack/fphook/cff4.fc deleted file mode 100644 index ae3b740c5..000000000 --- a/lib/ack/fphook/cff4.fc +++ /dev/null @@ -1,28 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - CONVERT DOUBLE TO SINGLE (CFF 8 4) - - This routine works quite simply. A floating point - of size 08 is converted to extended format. - This extended variable is converted back to - a floating point of size 04. - -*/ - -#include "FP_types.h" - -void -cff4(src) -DOUBLE src; /* the source itself - THIS TIME it's DOUBLE */ -{ - EXTEND buf; - - extend(&src.d[0],&buf,sizeof(DOUBLE)); /* no matter what */ - compact(&buf,&(src.d[1]),sizeof(SINGLE)); -} diff --git a/lib/ack/fphook/cff8.fc b/lib/ack/fphook/cff8.fc deleted file mode 100644 index a851803ad..000000000 --- a/lib/ack/fphook/cff8.fc +++ /dev/null @@ -1,28 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - CONVERT SINGLE TO DOUBLE (CFF 4 8) - - This routine works quite simply. A floating point - of size 04 is converted to extended format. - This extended variable is converted back to - a floating point of size 08. - -*/ - -#include "FP_types.h" - -void -cff8(src) -SINGLE src; -{ - EXTEND buf; - - extend(&src,&buf,sizeof(SINGLE)); /* no matter what */ - compact(&buf, &src,sizeof(DOUBLE)); -} diff --git a/lib/ack/fphook/cfi.fc b/lib/ack/fphook/cfi.fc deleted file mode 100644 index cfd28230e..000000000 --- a/lib/ack/fphook/cfi.fc +++ /dev/null @@ -1,52 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - CONVERT FLOAT TO SIGNED (CFI m n) - - N.B. The caller must know what it is getting. - A LONG is always returned. If it is an - integer the high byte is cleared first. -*/ - -#include "FP_trap.h" -#include "FP_types.h" -#include "FP_shift.h" - -long -cfi(ds,ss,src) -int ds; /* destination size (2 or 4) */ -int ss; /* source size (4 or 8) */ -DOUBLE src; /* assume worst case */ -{ - EXTEND buf; - long new; - short max_exp; - - extend(&src.d[0],&buf,ss); /* get extended format */ - if (buf.exp < 0) { /* no conversion needed */ - src.d[ss == 8] = 0L; - return(0L); - } - max_exp = (ds << 3) - 2; /* signed numbers */ - /* have more limited max_exp */ - if (buf.exp > max_exp) { - if (buf.exp == max_exp+1 && buf.sign && buf.m1 == NORMBIT && - buf.m2 == 0L) { - } - else { - trap(EIOVFL); /* integer overflow */ - buf.exp %= max_exp; /* truncate */ - } - } - new = buf.m1 >> (31-buf.exp); - if (buf.sign) - new = -new; -done: - src.d[ss == 8] = new; - return(new); -} diff --git a/lib/ack/fphook/cfu.fc b/lib/ack/fphook/cfu.fc deleted file mode 100644 index e9a551ac7..000000000 --- a/lib/ack/fphook/cfu.fc +++ /dev/null @@ -1,43 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - CONVERT FLOAT TO UNSIGNED (CFU m n) - - N.B. The caller must know what it is getting. - A LONG is always returned. If it is an - integer the high byte is cleared first. -*/ - -#include "FP_trap.h" -#include "FP_types.h" - -long -cfu(ds,ss,src) -int ds; /* destination size (2 or 4) */ -int ss; /* source size (4 or 8) */ -DOUBLE src; /* assume worst case */ -{ - EXTEND buf; - long new; - short newint, max_exp; - - extend(&src.d[0],&buf,ss); /* get extended format */ - if (buf.exp < 0) { /* no conversion needed */ - src.d[ss == 8] = 0L; - return(0L); - } - max_exp = (ds << 3) - 1; - if (buf.exp > max_exp) { - trap(EIOVFL); /* integer overflow */ - buf.exp %= max_exp; - } - new = buf.m1 >> (31-buf.exp); -done: - src.d[ss == 8] = new; - return(new); -} diff --git a/lib/ack/fphook/cif4.fc b/lib/ack/fphook/cif4.fc deleted file mode 100644 index 160d5f6d2..000000000 --- a/lib/ack/fphook/cif4.fc +++ /dev/null @@ -1,56 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - CONVERT INTEGER TO SINGLE (CIF n 4) - - THIS ROUTINE WORKS BY FILLING AN EXTENDED - WITH THE INTEGER VALUE IN EXTENDED FORMAT - AND USES COMPACT() TO PUT IT INTO THE PROPER - FLOATING POINT PRECISION. -*/ - -#include "FP_types.h" - -void -cif4(ss,src) -int ss; /* source size */ -long src; /* largest possible integer to convert */ -{ - EXTEND buf; - short *ipt; - long i_src; - SINGLE *result; - - zrf_ext(&buf); - if (ss == sizeof(long)) { - buf.exp = 31; - i_src = src; - result = (SINGLE *) &src; - } - else { - ipt = (short *) &src; - i_src = (long) *ipt; - buf.exp = 15; - result = (SINGLE *) &ss; - } - if (i_src == 0) { - *result = (SINGLE) 0L; - return; - } - /* ESTABLISHED THAT src != 0 */ - /* adjust exponent field */ - buf.sign = (i_src < 0) ? 0x8000 : 0; - /* clear sign bit of integer */ - /* move to mantissa field */ - buf.m1 = (i_src < 0) ? -i_src : i_src; - /* adjust mantissa field */ - if (ss != sizeof(long)) - buf.m1 <<= 16; - nrm_ext(&buf); /* adjust mantissa field */ - compact(&buf, result,sizeof(SINGLE)); /* put on stack */ -} diff --git a/lib/ack/fphook/cif8.fc b/lib/ack/fphook/cif8.fc deleted file mode 100644 index 1ab979813..000000000 --- a/lib/ack/fphook/cif8.fc +++ /dev/null @@ -1,55 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - CONVERT INTEGER TO FLOAT (CIF n 8) - - THIS ROUTINE WORKS BY FILLING AN EXTENDED - WITH THE INTEGER VALUE IN EXTENDED FORMAT - AND USES COMPACT() TO PUT IT INTO THE PROPER - FLOATING POINT PRECISION. -*/ - -#include "FP_types.h" - -void -cif8(ss,src) -int ss; /* source size */ -long src; /* largest possible integer to convert */ -{ - EXTEND buf; - DOUBLE *result; /* for return value */ - short *ipt; - long i_src; - - result = (DOUBLE *) ((void *) &ss); /* always */ - zrf_ext(&buf); - if (ss == sizeof(long)) { - buf.exp = 31; - i_src = src; - } - else { - ipt = (short *) &src; - i_src = (long) *ipt; - buf.exp = 15; - } - if (i_src == 0) { - zrf8(result); - return; - } - /* ESTABLISHED THAT src != 0 */ - /* adjust exponent field */ - buf.sign = (i_src < 0) ? 0x8000 : 0; - /* clear sign bit of integer */ - /* move to mantissa field */ - buf.m1 = (i_src < 0) ? -i_src : i_src; - /* adjust mantissa field */ - if (ss != sizeof(long)) - buf.m1 <<= 16; - nrm_ext(&buf); - compact(&buf,&result->d[0],8); -} diff --git a/lib/ack/fphook/cmf4.fc b/lib/ack/fphook/cmf4.fc deleted file mode 100644 index ee186ff4c..000000000 --- a/lib/ack/fphook/cmf4.fc +++ /dev/null @@ -1,40 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - COMPARE SINGLES (CMF 4) -*/ - -#include "FP_types.h" -#include "get_put.h" - -int -cmf4(f1,f2) -SINGLE f1,f2; -{ - /* - * return ((f1 < f2) ? 1 : (f1 - f2)) - */ -#define SIGN(x) (((x) < 0) ? -1 : 1) - int sign1,sign2; - long l1,l2; - - l1 = get4((char *) &f1); - l2 = get4((char *) &f2); - - if (l1 == l2) return 0; - - sign1 = SIGN(l1); - sign2 = SIGN(l2); - if (sign1 != sign2) { - if ((l1 & 0x7fffffff) == 0 && - (l2 & 0x7fffffff) == 0) return 0; - return ((sign1 > 0) ? -1 : 1); - } - - return (sign1 * ((l1 < l2) ? 1 : -1)); -} diff --git a/lib/ack/fphook/cmf8.fc b/lib/ack/fphook/cmf8.fc deleted file mode 100644 index 5badab0c4..000000000 --- a/lib/ack/fphook/cmf8.fc +++ /dev/null @@ -1,61 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - COMPARE DOUBLES (CMF 8) -*/ - -#include "FP_types.h" -#include "get_put.h" - -int -cmf8(d1,d2) -DOUBLE d1,d2; -{ -#define SIGN(x) (((x) < 0) ? -1 : 1) - /* - * return ((d1 < d2) ? 1 : (d1 > d2) ? -1 : 0)) - */ - long l1,l2; - int sign1,sign2; - int rv; - -#if FL_MSL_AT_LOW_ADDRESS - l1 = get4((char *)&d1); - l2 = get4((char *)&d2); -#else - l1 = get4(((char *)&d1+4)); - l2 = get4(((char *)&d2+4)); -#endif - sign1 = SIGN(l1); - sign2 = SIGN(l2); - if (sign1 != sign2) { - l1 &= 0x7fffffff; - l2 &= 0x7fffffff; - if (l1 != 0 || l2 != 0) { - return ((sign1 > 0) ? -1 : 1); - } - } - if (l1 != l2) { /* we can decide here */ - rv = l1 < l2 ? 1 : -1; - } - else { /* decide in 2nd half */ - unsigned long u1, u2; -#if FL_MSL_AT_LOW_ADDRESS - u1 = get4(((char *)&d1 + 4)); - u2 = get4(((char *)&d2 + 4)); -#else - u1 = get4((char *)&d1); - u2 = get4((char *)&d2); -#endif - if (u1 == u2) - return(0); - if (u1 < u2) rv = 1; - else rv = -1; - } - return sign1 * rv; -} diff --git a/lib/ack/fphook/compact.fc b/lib/ack/fphook/compact.fc deleted file mode 100644 index a5a1074d1..000000000 --- a/lib/ack/fphook/compact.fc +++ /dev/null @@ -1,202 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - COMPACT EXTEND FORMAT INTO FLOAT OF PROPER SIZE -*/ - -# include "FP_bias.h" -# include "FP_shift.h" -# include "FP_trap.h" -# include "FP_types.h" -# include "get_put.h" - -void -compact(f,to,size) -EXTEND *f; -unsigned long *to; -int size; -{ - int error = 0; - - if (size == sizeof(DOUBLE)) { - /* - * COMPACT EXTENDED INTO DOUBLE - */ - DOUBLE *DBL = (DOUBLE *) (void *) to; - - if ((f->m1|(f->m2 & DBL_ZERO)) == 0L) { - zrf8(DBL); - return; - } - f->exp += DBL_BIAS; /* restore proper bias */ - if (f->exp > DBL_MAX) { -dbl_over: trap(EFOVFL); - f->exp = DBL_MAX+1; - f->m1 = 0; - f->m2 = 0; - if (error++) - return; - } - else if (f->exp < DBL_MIN) { - b64_rsft(&(f->mantissa)); - if (f->exp < 0) { - b64_sft(&(f->mantissa), -f->exp); - f->exp = 0; - } - /* underflow ??? */ - } - - /* local CAST conversion */ - - /* because of special format shift only 10 bits */ - /* bit shift mantissa 10 bits */ - - /* first align within words, then do store operation */ - - DBL->d[0] = f->m1 >> DBL_RUNPACK; /* plus 22 == 32 */ - DBL->d[1] = f->m2 >> DBL_RUNPACK; /* plus 22 == 32 */ - DBL->d[1] |= (f->m1 << DBL_LUNPACK); /* plus 10 == 32 */ - - /* if not exact then round to nearest */ - /* on a tie, round to even */ - -#ifdef EXCEPTION_INEXACT - if ((f->m2 & DBL_EXACT) != 0) { - INEXACT(); -#endif - if (((f->m2 & DBL_EXACT) > DBL_ROUNDUP) - || ((f->m2 & DBL_EXACT) == DBL_ROUNDUP - && (f->m2 & (DBL_ROUNDUP << 1)))) { - DBL->d[1]++; /* rounding up */ - if (DBL->d[1] == 0L) { /* carry out */ - DBL->d[0]++; - - if (f->exp == 0 && (DBL->d[0] & ~DBL_MASK)) { - f->exp++; - } - if (DBL->d[0] & DBL_CARRYOUT) { /* carry out */ - if (DBL->d[0] & 01) - DBL->d[1] = CARRYBIT; - DBL->d[0] >>= 1; - f->exp++; - } - } - /* check for overflow */ - if (f->exp > DBL_MAX) - goto dbl_over; - } -#ifdef EXCEPTION_INEXACT - } -#endif - - /* - * STORE EXPONENT AND SIGN: - * - * 1) clear leading bits (B4-B15) - * 2) shift and store exponent - */ - - DBL->d[0] &= DBL_MASK; - DBL->d[0] |= - ((long) (f->exp << DBL_EXPSHIFT) << EXP_STORE); - if (f->sign) - DBL->d[0] |= CARRYBIT; - - /* - * STORE MANTISSA - */ - -#if FL_MSL_AT_LOW_ADDRESS - put4(DBL->d[0], (char *) &DBL->d[0]); - put4(DBL->d[1], (char *) &DBL->d[1]); -#else - { unsigned long l; - put4(DBL->d[1], (char *) &l); - put4(DBL->d[0], (char *) &DBL->d[1]); - DBL->d[0] = l; - } -#endif - } - else { - /* - * COMPACT EXTENDED INTO FLOAT - */ - SINGLE *SGL; - - /* local CAST conversion */ - SGL = (SINGLE *) (void *) to; - if ((f->m1 & SGL_ZERO) == 0L) { - *SGL = 0L; - return; - } - f->exp += SGL_BIAS; /* restore bias */ - if (f->exp > SGL_MAX) { -sgl_over: trap(EFOVFL); - f->exp = SGL_MAX+1; - f->m1 = 0L; - f->m2 = 0L; - if (error++) - return; - } - else if (f->exp < SGL_MIN) { - b64_rsft(&(f->mantissa)); - if (f->exp < 0) { - b64_sft(&(f->mantissa), -f->exp); - f->exp = 0; - } - /* underflow ??? */ - } - - /* shift mantissa and store */ - *SGL = (f->m1 >> SGL_RUNPACK); - - /* check for rounding to nearest */ - /* on a tie, round to even */ -#ifdef EXCEPTION_INEXACT - if (f->m2 != 0 || - (f->m1 & SGL_EXACT) != 0L) { - INEXACT(); -#endif - if (((f->m1 & SGL_EXACT) > SGL_ROUNDUP) - || ((f->m1 & SGL_EXACT) == SGL_ROUNDUP - && (f->m1 & (SGL_ROUNDUP << 1)))) { - (*SGL)++; - if (f->exp == 0 && (*SGL & ~SGL_MASK)) { - f->exp++; - } - /* check normal */ - if (*SGL & SGL_CARRYOUT) { - *SGL >>= 1; - f->exp++; - } - if (f->exp > SGL_MAX) - goto sgl_over; - } -#ifdef EXCEPTION_INEXACT - } -#endif - - /* - * STORE EXPONENT AND SIGN: - * - * 1) clear leading bit of fraction - * 2) shift and store exponent - */ - - *SGL &= SGL_MASK; /* B23-B31 are 0 */ - *SGL |= ((long) (f->exp << SGL_EXPSHIFT) << EXP_STORE); - if (f->sign) - *SGL |= CARRYBIT; - - /* - * STORE MANTISSA - */ - - put4(*SGL, (char *) &SGL); - } -} diff --git a/lib/ack/fphook/cuf4.fc b/lib/ack/fphook/cuf4.fc deleted file mode 100644 index c022f0e90..000000000 --- a/lib/ack/fphook/cuf4.fc +++ /dev/null @@ -1,57 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - CONVERT INTEGER TO SINGLE (CUF n 4) - - THIS ROUTINE WORKS BY FILLING AN EXTENDED - WITH THE INTEGER VALUE IN EXTENDED FORMAT - AND USES COMPACT() TO PUT IT INTO THE PROPER - FLOATING POINT PRECISION. -*/ - -#include "FP_types.h" - -void -cuf4(ss,src) -int ss; /* source size */ -long src; /* largest possible integer to convert */ -{ - EXTEND buf; - short *ipt; - SINGLE *result; - long i_src; - - zrf_ext(&buf); - if (ss == sizeof(long)) { - buf.exp = 31; - i_src = src; - result = (SINGLE *) &src; - } - else { - ipt = (short *) &src; - i_src = (long) *ipt; - buf.exp = 15; - result = (SINGLE *) ((void *) &ss); - } - if (i_src == 0) { - *result = (SINGLE) 0L; - return; - } - /* ESTABLISHED THAT src != 0 */ - - /* adjust exponent field */ - if (ss != sizeof(long)) - i_src <<= 16; - - /* move to mantissa field */ - buf.m1 = i_src; - - /* adjust mantissa field */ - nrm_ext(&buf); - compact(&buf,result,4); -} diff --git a/lib/ack/fphook/cuf8.fc b/lib/ack/fphook/cuf8.fc deleted file mode 100644 index d18ec6c7a..000000000 --- a/lib/ack/fphook/cuf8.fc +++ /dev/null @@ -1,54 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - CONVERT INTEGER TO FLOAT (CUF n 8) - - THIS ROUTINE WORKS BY FILLING AN EXTENDED - WITH THE INTEGER VALUE IN EXTENDED FORMAT - AND USES COMPACT() TO PUT IT INTO THE PROPER - FLOATING POINT PRECISION. -*/ - -#include "FP_types.h" - -void -cuf8(ss,src) -int ss; /* source size */ -long src; /* largest possible integer to convert */ -{ - EXTEND buf; - short *ipt; - long i_src; - - zrf_ext(&buf); - if (ss == sizeof(long)) { - buf.exp = 31; - i_src = src; - } - else { - ipt = (short *) &src; - i_src = (long) *ipt; - buf.exp = 15; - } - if (i_src == 0) { - zrf8((DOUBLE *)((void *)&ss)); - return; - } - /* ESTABLISHED THAT src != 0 */ - - /* adjust exponent field */ - if (ss != sizeof(long)) - i_src <<= 16; - - /* move to mantissa field */ - buf.m1 = i_src; - - /* adjust mantissa field */ - nrm_ext(&buf); - compact(&buf,(unsigned long *) (void *)&ss,8); -} diff --git a/lib/ack/fphook/div_ext.fc b/lib/ack/fphook/div_ext.fc deleted file mode 100644 index bb9531178..000000000 --- a/lib/ack/fphook/div_ext.fc +++ /dev/null @@ -1,266 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - DIVIDE EXTENDED FORMAT -*/ - -#include "FP_bias.h" -#include "FP_trap.h" -#include "FP_types.h" - -/* - November 15, 1984 - - This is a routine to do the work. - There are two versions: - One is based on the partial products method - and makes no use possible machine instructions - to divide (hardware dividers). - The other is used when USE_DIVIDE is defined. It is much faster on - machines with fast 4 byte operations. -*/ -/********************************************************/ - -void -div_ext(e1,e2) -EXTEND *e1,*e2; -{ - short error = 0; - B64 result; - register unsigned long *lp; -#ifndef USE_DIVIDE - short count; -#else - unsigned short u[9], v[5]; - register int j; - register unsigned short *u_p = u; - int maxv = 4; -#endif - - if ((e2->m1 | e2->m2) == 0) { - /* - * Exception 8.2 - Divide by zero - */ - trap(EFDIVZ); - e1->m1 = e1->m2 = 0L; - e1->exp = EXT_MAX; - return; - } - if ((e1->m1 | e1->m2) == 0) { /* 0 / anything == 0 */ - e1->exp = 0; /* make sure */ - return; - } -#ifndef USE_DIVIDE - /* - * numbers are right shifted one bit to make sure - * that m1 is quaranteed to be larger if its - * maximum bit is set - */ - b64_rsft(&e1->mantissa); /* 64 bit shift right */ - b64_rsft(&e2->mantissa); /* 64 bit shift right */ - e1->exp++; - e2->exp++; -#endif - /* check for underflow, divide by zero, etc */ - e1->sign ^= e2->sign; - e1->exp -= e2->exp; - -#ifndef USE_DIVIDE - /* do division of mantissas */ - /* uses partial product method */ - /* init control variables */ - - count = 64; - result.h_32 = 0L; - result.l_32 = 0L; - - /* partial product division loop */ - - while (count--) { - /* first left shift result 1 bit */ - /* this is ALWAYS done */ - - b64_lsft(&result); - - /* compare dividend and divisor */ - /* if dividend >= divisor add a bit */ - /* and subtract divisior from dividend */ - - if ( (e1->m1 < e2->m1) || - ((e1->m1 == e2->m1) && (e1->m2 < e2->m2) )) - ; /* null statement */ - /* i.e., don't add or subtract */ - else { - result.l_32++; /* ADD */ - if (e2->m2 > e1->m2) - e1->m1 -= 1; /* carry in */ - e1->m1 -= e2->m1; /* do SUBTRACTION */ - e1->m2 -= e2->m2; /* SUBTRACTION */ - } - - /* shift dividend left one bit OR */ - /* IF it equals ZERO we can break out */ - /* of the loop, but still must shift */ - /* the quotient the remaining count bits */ - /* NB save the results of this test in error */ - /* if not zero, then the result is inexact. */ - /* this would be reported in IEEE standard */ - - /* lp points to dividend */ - lp = &e1->m1; - - error = ((*lp | *(lp+1)) != 0L) ? 1 : 0; - if (error) { /* more work */ - /* assume max bit == 0 (see above) */ - b64_lsft(&e1->mantissa); - continue; - } - else - break; /* leave loop */ - } /* end of divide by subtraction loop */ - - if (count > 0) { - lp = &result.h_32; - if (count > 31) { /* move to higher word */ - *lp = *(lp+1); - count -= 32; - *(lp+1) = 0L; /* clear low word */ - } - if (*lp) - *lp <<= count; /* shift rest of way */ - lp++; /* == &result.l_32 */ - if (*lp) { - result.h_32 |= (*lp >> 32-count); - *lp <<= count; - } - } -#else /* USE_DIVIDE */ - - u[4] = (e1->m2 & 1) << 15; - b64_rsft(&(e1->mantissa)); - u[0] = e1->m1 >> 16; - u[1] = e1->m1; - u[2] = e1->m2 >> 16; - u[3] = e1->m2; - u[5] = 0; u[6] = 0; u[7] = 0; - v[1] = e2->m1 >> 16; - v[2] = e2->m1; - v[3] = e2->m2 >> 16; - v[4] = e2->m2; - while (! v[maxv]) maxv--; - result.h_32 = 0; - result.l_32 = 0; - lp = &result.h_32; - - /* - * Use an algorithm of Knuth (The art of programming, Seminumerical - * algorithms), to divide u by v. u and v are both seen as numbers - * with base 65536. - */ - for (j = 0; j <= 3; j++, u_p++) { - unsigned long q_est, temp; - - if (j == 2) lp++; - if (u_p[0] == 0 && u_p[1] < v[1]) continue; - temp = ((unsigned long)u_p[0] << 16) + u_p[1]; - if (u_p[0] >= v[1]) { - q_est = 0x0000FFFFL; - } - else { - q_est = temp / v[1]; - } - temp -= q_est * v[1]; - while (temp < 0x10000 && v[2]*q_est > ((temp<<16)+u_p[2])) { - q_est--; - temp += v[1]; - } - /* Now, according to Knuth, we have an estimate of the - quotient, that is either correct or one too big, but - almost always correct. - */ - if (q_est != 0) { - int i; - unsigned long k = 0; - int borrow = 0; - - for (i = maxv; i > 0; i--) { - unsigned long tmp = q_est * v[i] + k + borrow; - unsigned short md = tmp; - - borrow = (md > u_p[i]); - u_p[i] -= md; - k = tmp >> 16; - } - k += borrow; - borrow = u_p[0] < k; - u_p[0] -= k; - - if (borrow) { - /* So, this does not happen often; the estimate - was one too big; correct this - */ - *lp |= (j & 1) ? (q_est - 1) : ((q_est-1)<<16); - borrow = 0; - for (i = maxv; i > 0; i--) { - unsigned long tmp - = v[i]+(unsigned long)u_p[i]+borrow; - - u_p[i] = tmp; - borrow = tmp >> 16; - } - u_p[0] += borrow; - } - else *lp |= (j & 1) ? q_est : (q_est<<16); - } - } -#ifdef EXCEPTION_INEXACT - u_p = &u[0]; - for (j = 7; j >= 0; j--) { - if (*u_p++) { - error = 1; - break; - } - } -#endif -#endif - -#ifdef EXCEPTION_INEXACT - if (error) { - /* - * report here exception 8.5 - Inexact - * from Draft 8.0 of IEEE P754: - * In the absence of an invalid operation exception, - * if the rounded result of an operation is not exact or if - * it overflows without a trap, then the inexact exception - * shall be assigned. The rounded or overflowed result - * shall be delivered to the destination. - */ - INEXACT(); -#endif - e1->mantissa = result; - - nrm_ext(e1); - if (e1->exp < EXT_MIN) { - /* - * Exception 8.4 - Underflow - */ - trap(EFUNFL); /* underflow */ - e1->exp = EXT_MIN; - e1->m1 = e1->m2 = 0L; - return; - } - if (e1->exp >= EXT_MAX) { - /* - * Exception 8.3 - Overflow - */ - trap(EFOVFL); /* overflow */ - e1->exp = EXT_MAX; - e1->m1 = e1->m2 = 0L; - return; - } -} diff --git a/lib/ack/fphook/dvf4.fc b/lib/ack/fphook/dvf4.fc deleted file mode 100644 index 7d82cd8b8..000000000 --- a/lib/ack/fphook/dvf4.fc +++ /dev/null @@ -1,26 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - DIVIDE TWO SINGLES - SINGLE Precision (dvf 4) -*/ - -#include "FP_types.h" - -void -dvf4(s2,s1) -SINGLE s1,s2; -{ - EXTEND e1,e2; - - extend(&s1,&e1,sizeof(SINGLE)); - extend(&s2,&e2,sizeof(SINGLE)); - - /* do a divide */ - div_ext(&e1,&e2); - compact(&e1,&s1,sizeof(SINGLE)); -} diff --git a/lib/ack/fphook/dvf8.fc b/lib/ack/fphook/dvf8.fc deleted file mode 100644 index fafe50f53..000000000 --- a/lib/ack/fphook/dvf8.fc +++ /dev/null @@ -1,26 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - DIVIDE TWO FLOATS - DOUBLE Precision (DVF 8) -*/ - -#include "FP_types.h" - -void -dvf8(s2,s1) -DOUBLE s1,s2; -{ - EXTEND e1,e2; - - extend(&s1.d[0],&e1,sizeof(DOUBLE)); - extend(&s2.d[0],&e2,sizeof(DOUBLE)); - - /* do a divide */ - div_ext(&e1,&e2); - compact(&e1,&s1.d[0],sizeof(DOUBLE)); -} diff --git a/lib/ack/fphook/extend.fc b/lib/ack/fphook/extend.fc deleted file mode 100644 index 70febb1e3..000000000 --- a/lib/ack/fphook/extend.fc +++ /dev/null @@ -1,111 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - CONVERTS FLOATING POINT TO EXTENDED FORMAT - - Two sizes of FLOATING Point are known: - SINGLE and DOUBLE -*/ -/********************************************************/ -/* - It is not required to normalize in extended - format, but it has been chosen to do so. - Extended Format is as follows (at exit): - -->sign S000 0000 | 0000 0000 -->exp 0EEE EEEE | EEEE EEEE -->m1 LFFF FFFF | FFFF FFFF - FFFF FFFF | FFFF FFFF -->m2 FFFF FFFF | FFFF FFFF - FFFF F000 | 0000 0000 -*/ -/********************************************************/ - -#include "FP_bias.h" -#include "FP_shift.h" -#include "FP_types.h" -#include "get_put.h" -/********************************************************/ - -void -extend(from,to,size) -unsigned long *from; -EXTEND *to; -int size; -{ - register char *cpt1; - unsigned long tmp; - int leadbit = 0; - - cpt1 = (char *) from; - -#if FL_MSL_AT_LOW_ADDRESS -#if FL_MSW_AT_LOW_ADDRESS - to->exp = uget2(cpt1); -#else - to->exp = uget2(cpt1+2); -#endif -#else -#if FL_MSW_AT_LOW_ADDRESS - to->exp = uget2(cpt1+(size == sizeof(DOUBLE) ? 4 : 0)); -#else - to->exp = uget2(cpt1+(size == sizeof(DOUBLE) ? 6 : 2)); -#endif -#endif - to->sign = (to->exp & 0x8000); /* set sign bit */ - to->exp ^= to->sign; - if (size == sizeof(DOUBLE)) - to->exp >>= DBL_EXPSHIFT; - else - to->exp >>= SGL_EXPSHIFT; - if (to->exp > 0) - leadbit++; /* will set Lead bit later */ - else to->exp++; - - if (size == sizeof(DOUBLE)) { -#if FL_MSL_AT_LOW_ADDRESS - to->m1 = get4(cpt1); - cpt1 += 4; - tmp = get4(cpt1); -#else - tmp = get4(cpt1); - cpt1 += 4; - to->m1 = get4(cpt1); -#endif - if (to->exp == 1 && to->m1 == 0 && tmp == 0) { - to->exp = 0; - to->sign = 0; - to->m1 = 0; - to->m2 = 0; - return; - } - to->m1 <<= DBL_M1LEFT; /* shift */ - to->exp -= DBL_BIAS; /* remove bias */ - to->m1 |= (tmp>>DBL_RPACK); /* plus 10 == 32 */ - to->m2 = (tmp<m1 = get4(cpt1); - to->m1 <<= SGL_M1LEFT; /* shift */ - if (to->exp == 1 && to->m1 == 0) { - to->exp = 0; - to->sign = 0; - to->m1 = 0; - to->m2 = 0; - return; - } - to->exp -= SGL_BIAS; /* remove bias */ - to->m2 = 0L; - } - - to->m1 |= NORMBIT; /* set bit L */ - if (leadbit == 0) { /* set or clear Leading Bit */ - to->m1 &= ~NORMBIT; /* clear bit L */ - nrm_ext(to); /* and normalize */ - } -} diff --git a/lib/ack/fphook/fef4.fc b/lib/ack/fphook/fef4.fc deleted file mode 100644 index ff426f57b..000000000 --- a/lib/ack/fphook/fef4.fc +++ /dev/null @@ -1,33 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - SEPERATE INTO EXPONENT AND FRACTION (FEF 4) -*/ - -#include "FP_types.h" - -void -fef4(r,s1) -SINGLE s1; -struct fef4_returns *r; -{ - EXTEND buf; - register struct fef4_returns *p = r; /* make copy; r might refer - to itself (see table) - */ - - extend(&s1,&buf,sizeof(SINGLE)); - if (buf.exp == 0 && buf.m1 == 0 && buf.m2 == 0) { - p->e = 0; - } - else { - p->e = buf.exp+1; - buf.exp = -1; - } - compact(&buf,&p->f,sizeof(SINGLE)); -} diff --git a/lib/ack/fphook/fef8.fc b/lib/ack/fphook/fef8.fc deleted file mode 100644 index 1c3b3b0b5..000000000 --- a/lib/ack/fphook/fef8.fc +++ /dev/null @@ -1,33 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - SEPERATE DOUBLE INTO EXPONENT AND FRACTION (FEF 8) -*/ - -#include "FP_types.h" - -void -fef8(r, s1) -DOUBLE s1; -struct fef8_returns *r; -{ - EXTEND buf; - register struct fef8_returns *p = r; /* make copy, r might refer - to itself (see table) - */ - - extend(&s1.d[0],&buf,sizeof(DOUBLE)); - if (buf.exp == 0 && buf.m1 == 0 && buf.m2 == 0) { - p->e = 0; - } - else { - p->e = buf.exp + 1; - buf.exp = -1; - } - compact(&buf,&p->f.d[0],sizeof(DOUBLE)); -} diff --git a/lib/ack/fphook/fif4.fc b/lib/ack/fphook/fif4.fc deleted file mode 100644 index 059372469..000000000 --- a/lib/ack/fphook/fif4.fc +++ /dev/null @@ -1,46 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - MULTIPLY AND DISMEMBER PARTS (FIF 4) -*/ - -#include "FP_types.h" -#include "FP_shift.h" - -void -fif4(p,x,y) -SINGLE x,y; -struct fif4_returns *p; -{ - - EXTEND e1,e2; - - extend(&y,&e1,sizeof(SINGLE)); - extend(&x,&e2,sizeof(SINGLE)); - /* do a multiply */ - mul_ext(&e1,&e2); - e2 = e1; - compact(&e2,&y,sizeof(SINGLE)); - if (e1.exp < 0) { - p->ipart = 0; - p->fpart = y; - return; - } - if (e1.exp > 30 - SGL_M1LEFT) { - p->ipart = y; - p->fpart = 0; - return; - } - b64_sft(&e1.mantissa, 63 - e1.exp); - b64_sft(&e1.mantissa, e1.exp - 63); /* "loose" low order bits */ - compact(&e1,&(p->ipart),sizeof(SINGLE)); - extend(&(p->ipart), &e2, sizeof(SINGLE)); - extend(&y, &e1, sizeof(SINGLE)); - sub_ext(&e1, &e2); - compact(&e1, &(p->fpart), sizeof(SINGLE)); -} diff --git a/lib/ack/fphook/fif8.fc b/lib/ack/fphook/fif8.fc deleted file mode 100644 index 9f1b9b15e..000000000 --- a/lib/ack/fphook/fif8.fc +++ /dev/null @@ -1,48 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - MULTIPLY AND DISMEMBER PARTS (FIF 8) -*/ - -#include "FP_types.h" -#include "FP_shift.h" - -void -fif8(p,x,y) -DOUBLE x,y; -struct fif8_returns *p; -{ - - EXTEND e1,e2; - - extend(&y.d[0],&e1,sizeof(DOUBLE)); - extend(&x.d[0],&e2,sizeof(DOUBLE)); - /* do a multiply */ - mul_ext(&e1,&e2); - e2 = e1; - compact(&e2, &y.d[0], sizeof(DOUBLE)); - if (e1.exp < 0) { - p->ipart.d[0] = 0; - p->ipart.d[1] = 0; - p->fpart = y; - return; - } - if (e1.exp > 62 - DBL_M1LEFT) { - p->ipart = y; - p->fpart.d[0] = 0; - p->fpart.d[1] = 0; - return; - } - b64_sft(&e1.mantissa, 63 - e1.exp); - b64_sft(&e1.mantissa, e1.exp - 63); /* "loose" low order bits */ - compact(&e1, &(p->ipart.d[0]), sizeof(DOUBLE)); - extend(&(p->ipart.d[0]), &e2, sizeof(DOUBLE)); - extend(&y.d[0], &e1, sizeof(DOUBLE)); - sub_ext(&e1, &e2); - compact(&e1, &(p->fpart.d[0]), sizeof(DOUBLE)); -} diff --git a/lib/ack/fphook/fptrp.s b/lib/ack/fphook/fptrp.s deleted file mode 100644 index d2823f4d7..000000000 --- a/lib/ack/fphook/fptrp.s +++ /dev/null @@ -1,19 +0,0 @@ -# -.sect .text; .sect .rom; .sect .data; .sect .bss -.define __fptrp -.sect .text -__fptrp: -#if __i386 - push ebp - mov ebp, esp - mov eax, 8(bp) - call .Xtrp - leave - ret -#else /* i86 */ - push bp - mov bp, sp - mov ax, 4(bp) - call .Xtrp - jmp .cret -#endif diff --git a/lib/ack/fphook/get_put.h b/lib/ack/fphook/get_put.h deleted file mode 100644 index 9fd7f606f..000000000 --- a/lib/ack/fphook/get_put.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -#include - -#if CHAR_UNSIGNED -#define Xchar(ch) (ch) -#else -#define Xchar(ch) ((ch) & 0377) -#endif - -#define BYTES_REVERSED (MSB_AT_LOW_ADDRESS != FL_MSB_AT_LOW_ADDRESS) -#define WORDS_REVERSED (MSW_AT_LOW_ADDRESS != FL_MSW_AT_LOW_ADDRESS) -#define LONGS_REVERSED (FL_MSL_AT_LOW_ADDRESS) - -#if BYTES_REVERSED -#define uget2(c) (Xchar((c)[1]) | ((unsigned) Xchar((c)[0]) << 8)) -#define Xput2(i, c) (((c)[1] = (i)), ((c)[0] = (i) >> 8)) -#define put2(i, c) { register int j = (i); Xput2(j, c); } -#else -#define uget2(c) (* ((unsigned short *) (c))) -#define Xput2(i, c) (* ((short *) (c)) = (i)) -#define put2(i, c) Xput2(i, c) -#endif - -#define get2(c) ((short) uget2(c)) - -#if WORDS_REVERSED || BYTES_REVERSED -#define get4(c) (uget2((c)+2) | ((long) uget2(c) << 16)) -#define put4(l, c) { register long x=(l); \ - Xput2((int)x,(c)+2); \ - Xput2((int)(x>>16),(c)); \ - } -#else -#define get4(c) (* ((long *) (c))) -#define put4(l, c) (* ((long *) (c)) = (l)) -#endif diff --git a/lib/ack/fphook/mlf4.fc b/lib/ack/fphook/mlf4.fc deleted file mode 100644 index d5f515d19..000000000 --- a/lib/ack/fphook/mlf4.fc +++ /dev/null @@ -1,25 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - * Multiply Single Precesion Float (MLF 4) - */ - -#include "FP_types.h" - -void -mlf4(s2,s1) -SINGLE s1,s2; -{ - EXTEND e1,e2; - - extend(&s1,&e1,sizeof(SINGLE)); - extend(&s2,&e2,sizeof(SINGLE)); - /* do a multiply */ - mul_ext(&e1,&e2); - compact(&e1,&s1,sizeof(SINGLE)); -} diff --git a/lib/ack/fphook/mlf8.fc b/lib/ack/fphook/mlf8.fc deleted file mode 100644 index b43cdf3c1..000000000 --- a/lib/ack/fphook/mlf8.fc +++ /dev/null @@ -1,25 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - * Multiply Double Precision Float (MLF 8) - */ - -#include "FP_types.h" - -void -mlf8(s2,s1) -DOUBLE s1,s2; -{ - EXTEND e1,e2; - - extend(&s1.d[0],&e1,sizeof(DOUBLE)); - extend(&s2.d[0],&e2,sizeof(DOUBLE)); - /* do a multiply */ - mul_ext(&e1,&e2); - compact(&e1,&s1.d[0],sizeof(DOUBLE)); -} diff --git a/lib/ack/fphook/mul_ext.fc b/lib/ack/fphook/mul_ext.fc deleted file mode 100644 index 78a614014..000000000 --- a/lib/ack/fphook/mul_ext.fc +++ /dev/null @@ -1,98 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - ROUTINE TO MULTIPLY TWO EXTENDED FORMAT NUMBERS -*/ - -# include "FP_bias.h" -# include "FP_trap.h" -# include "FP_types.h" -# include "FP_shift.h" - -void -mul_ext(e1,e2) -EXTEND *e1,*e2; -{ - register int i,j; /* loop control */ - unsigned short mp[4]; /* multiplier */ - unsigned short mc[4]; /* multipcand */ - unsigned short result[8]; /* result */ - register unsigned short *pres; - - /* first save the sign (XOR) */ - e1->sign ^= e2->sign; - - /* compute new exponent */ - e1->exp += e2->exp + 1; - /* 128 bit multiply of mantissas */ - - /* assign unknown long formats */ - /* to known unsigned word formats */ - mp[0] = e1->m1 >> 16; - mp[1] = (unsigned short) e1->m1; - mp[2] = e1->m2 >> 16; - mp[3] = (unsigned short) e1->m2; - mc[0] = e2->m1 >> 16; - mc[1] = (unsigned short) e2->m1; - mc[2] = e2->m2 >> 16; - mc[3] = (unsigned short) e2->m2; - for (i = 8; i--;) { - result[i] = 0; - } - /* - * fill registers with their components - */ - for(i=4, pres = &result[4];i--;pres--) if (mp[i]) { - unsigned short k = 0; - unsigned long mpi = mp[i]; - for(j=4;j--;) { - unsigned long tmp = (unsigned long)pres[j] + k; - if (mc[j]) tmp += mpi * mc[j]; - pres[j] = tmp; - k = tmp >> 16; - } - pres[-1] = k; - } - if (! (result[0] & 0x8000)) { - e1->exp--; - for (i = 0; i <= 3; i++) { - result[i] <<= 1; - if (result[i+1]&0x8000) result[i] |= 1; - } - result[4] <<= 1; - } - - /* - * combine the registers to a total - */ - e1->m1 = ((unsigned long)(result[0]) << 16) + result[1]; - e1->m2 = ((unsigned long)(result[2]) << 16) + result[3]; - if (result[4] & 0x8000) { - if (++e1->m2 == 0) - if (++e1->m1 == 0) { - e1->m1 = NORMBIT; - e1->exp++; - } - } - - /* check for overflow */ - if (e1->exp >= EXT_MAX) { - trap(EFOVFL); - /* if caught */ - /* return signed infinity */ - e1->exp = EXT_MAX; -infinity: e1->m1 = e1->m2 =0L; - return; - } - /* check for underflow */ - if (e1->exp < EXT_MIN) { - trap(EFUNFL); - e1->exp = EXT_MIN; - goto infinity; - } -} diff --git a/lib/ack/fphook/ngf4.fc b/lib/ack/fphook/ngf4.fc deleted file mode 100644 index 9f1f812ea..000000000 --- a/lib/ack/fphook/ngf4.fc +++ /dev/null @@ -1,27 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - NEGATE A FLOATING POINT (NGF 4) -*/ -/********************************************************/ - -#include "FP_types.h" -#include "get_put.h" - -#define OFF ((FL_MSW_AT_LOW_ADDRESS ? 0 : 2) + (FL_MSB_AT_LOW_ADDRESS ? 0 : 1)) -void -ngf4(f) -SINGLE f; -{ - unsigned char *p; - - if (f != (SINGLE) 0) { - p = (unsigned char *) &f + OFF; - *p ^= 0x80; - } -} diff --git a/lib/ack/fphook/ngf8.fc b/lib/ack/fphook/ngf8.fc deleted file mode 100644 index 473ffa510..000000000 --- a/lib/ack/fphook/ngf8.fc +++ /dev/null @@ -1,28 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - NEGATE A FLOATING POINT (NGF 8) -*/ -/********************************************************/ - -#include "FP_types.h" -#include "get_put.h" - -#define OFF ((FL_MSL_AT_LOW_ADDRESS ? 0 : 4) + (FL_MSW_AT_LOW_ADDRESS ? 0 : 2) + (FL_MSB_AT_LOW_ADDRESS ? 0 : 1)) - -void -ngf8(f) -DOUBLE f; -{ - unsigned char *p; - - if (f.d[0] != 0 || f.d[1] != 0) { - p = (unsigned char *) &f + OFF; - *p ^= 0x80; - } -} diff --git a/lib/ack/fphook/nrm_ext.fc b/lib/ack/fphook/nrm_ext.fc deleted file mode 100644 index dc83554b1..000000000 --- a/lib/ack/fphook/nrm_ext.fc +++ /dev/null @@ -1,50 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/********************************************************/ -/* - NORMALIZE an EXTENDED FORMAT NUMBER -*/ -/********************************************************/ - -#include "FP_shift.h" -#include "FP_types.h" - -void -nrm_ext(e1) -EXTEND *e1; -{ - /* we assume that the mantissa != 0 */ - /* if it is then just return */ - /* to let it be a problem elsewhere */ - /* THAT IS, The exponent is not set to */ - /* zero. If we don't test here an */ - /* infinite loop is generated when */ - /* mantissa is zero */ - - if ((e1->m1 | e1->m2) == 0L) - return; - - /* if top word is zero mov low word */ - /* to top word, adjust exponent value */ - if (e1->m1 == 0L) { - e1->m1 = e1->m2; - e1->m2 = 0L; - e1->exp -= 32; - } - if ((e1->m1 & NORMBIT) == 0) { - unsigned long l = ((unsigned long)NORMBIT >> 1); - int cnt = -1; - - while (! (l & e1->m1)) { - l >>= 1; - cnt--; - } - e1->exp += cnt; - b64_sft(&(e1->mantissa), cnt); - } -} diff --git a/lib/ack/fphook/sbf4.fc b/lib/ack/fphook/sbf4.fc deleted file mode 100644 index 368c11102..000000000 --- a/lib/ack/fphook/sbf4.fc +++ /dev/null @@ -1,27 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - SUBTRACT TWO FLOATS - SINGLE Precision (SBF 4) -*/ - -#include "FP_types.h" - -void -sbf4(s2,s1) -SINGLE s1,s2; -{ - EXTEND e1,e2; - - if (s2 == (SINGLE) 0) { - return; - } - extend(&s1,&e1,sizeof(SINGLE)); - extend(&s2,&e2,sizeof(SINGLE)); - sub_ext(&e1,&e2); - compact(&e1,&s1,sizeof(SINGLE)); -} diff --git a/lib/ack/fphook/sbf8.fc b/lib/ack/fphook/sbf8.fc deleted file mode 100644 index 9d4c1067c..000000000 --- a/lib/ack/fphook/sbf8.fc +++ /dev/null @@ -1,27 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - SUBTRACT TWO FLOATS - DOUBLE Precision (SBF 8) -*/ - -#include "FP_types.h" - -void -sbf8(s2,s1) -DOUBLE s1,s2; -{ - EXTEND e1, e2; - - if (s2.d[0] == 0 && s2.d[1] == 0) { - return; - } - extend(&s1.d[0],&e1,sizeof(DOUBLE)); - extend(&s2.d[0],&e2,sizeof(DOUBLE)); - sub_ext(&e1,&e2); - compact(&e1,&s1.d[0],sizeof(DOUBLE)); -} diff --git a/lib/ack/fphook/sft_ext.fc b/lib/ack/fphook/sft_ext.fc deleted file mode 100644 index a933f9dc9..000000000 --- a/lib/ack/fphook/sft_ext.fc +++ /dev/null @@ -1,39 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - SHIFT TWO EXTENDED NUMBERS INTO PROPER - ALIGNMENT FOR ADDITION (exponents are equal) - Numbers should not be zero on entry. -*/ - -#include "FP_types.h" - -void -sft_ext(e1,e2) -EXTEND *e1,*e2; -{ - register EXTEND *s; - register int diff; - - diff = e1->exp - e2->exp; - - if (!diff) - return; /* exponents are equal */ - - if (diff < 0) { /* e2 is larger */ - /* shift e1 */ - diff = -diff; - s = e1; - } - else /* e1 is larger */ - /* shift e2 */ - s = e2; - - s->exp += diff; - b64_sft(&(s->mantissa), diff); -} diff --git a/lib/ack/fphook/shifter.fc b/lib/ack/fphook/shifter.fc deleted file mode 100644 index 089da20c2..000000000 --- a/lib/ack/fphook/shifter.fc +++ /dev/null @@ -1,75 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -# include "FP_types.h" - -void -b64_sft(e1,n) -B64 *e1; -int n; -{ - if (n > 0) { - if (n > 63) { - e1->l_32 = 0; - e1->h_32 = 0; - return; - } - if (n >= 32) { - e1->l_32 = e1->h_32; - e1->h_32 = 0; - n -= 32; - } - if (n > 0) { - e1->l_32 >>= n; - if (e1->h_32 != 0) { - e1->l_32 |= (e1->h_32 << (32 - n)); - e1->h_32 >>= n; - } - } - return; - } - n = -n; - if (n > 0) { - if (n > 63) { - e1->l_32 = 0; - e1->h_32 = 0; - return; - } - if (n >= 32) { - e1->h_32 = e1->l_32; - e1->l_32 = 0; - n -= 32; - } - if (n > 0) { - e1->h_32 <<= n; - if (e1->l_32 != 0) { - e1->h_32 |= (e1->l_32 >> (32 - n)); - e1->l_32 <<= n; - } - } - } -} - -void -b64_lsft(e1) -B64 *e1; -{ - /* shift left 1 bit */ - e1->h_32 <<= 1; - if (e1->l_32 & 0x80000000L) e1->h_32 |= 1; - e1->l_32 <<= 1; -} - -void -b64_rsft(e1) -B64 *e1; -{ - /* shift right 1 bit */ - e1->l_32 >>= 1; - if (e1->h_32 & 1) e1->l_32 |= 0x80000000L; - e1->h_32 >>= 1; -} diff --git a/lib/ack/fphook/sub_ext.fc b/lib/ack/fphook/sub_ext.fc deleted file mode 100644 index 64180aa6f..000000000 --- a/lib/ack/fphook/sub_ext.fc +++ /dev/null @@ -1,53 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - SUBTRACT 2 EXTENDED FORMAT NUMBERS -*/ - -#include "FP_types.h" - -void -sub_ext(e1,e2) -EXTEND *e1,*e2; -{ - if ((e2->m1 | e2->m2) == 0L) { - return; - } - if ((e1->m1 | e1->m2) == 0L) { - *e1 = *e2; - e1->sign = e2->sign ? 0 : 1; - return; - } - sft_ext(e1, e2); - if (e1->sign != e2->sign) { - /* e1 - e2 = e1 + (-e2) */ - if (b64_add(&e1->mantissa,&e2->mantissa)) { /* addition carry */ - b64_rsft(&e1->mantissa); /* shift mantissa one bit RIGHT */ - e1->m1 |= 0x80000000L; /* set max bit */ - e1->exp++; /* increase the exponent */ - } - } - else if (e2->m1 > e1->m1 || - (e2->m1 == e1->m1 && e2->m2 > e1->m2)) { - /* abs(e2) > abs(e1) */ - if (e1->m2 > e2->m2) { - e2->m1 -= 1; /* carry in */ - } - e2->m1 -= e1->m1; - e2->m2 -= e1->m2; - *e1 = *e2; - e1->sign = e2->sign ? 0 : 1; - } - else { - if (e2->m2 > e1->m2) - e1->m1 -= 1; /* carry in */ - e1->m1 -= e2->m1; - e1->m2 -= e2->m2; - } - nrm_ext(e1); -} diff --git a/lib/ack/fphook/zrf4.fc b/lib/ack/fphook/zrf4.fc deleted file mode 100644 index a913e813d..000000000 --- a/lib/ack/fphook/zrf4.fc +++ /dev/null @@ -1,19 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - return a zero float (ZRF 4) -*/ - -#include "FP_types.h" - -void -zrf4(l) -SINGLE *l; -{ - *l = 0L; -} diff --git a/lib/ack/fphook/zrf8.fc b/lib/ack/fphook/zrf8.fc deleted file mode 100644 index 4fcdbb85b..000000000 --- a/lib/ack/fphook/zrf8.fc +++ /dev/null @@ -1,21 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - return a zero double (ZRF 8) -*/ - -#include "FP_types.h" - -void -zrf8(z) -DOUBLE *z; -{ - - z->d[0] = 0L; - z->d[1] = 0L; -} diff --git a/lib/ack/fphook/zrf_ext.fc b/lib/ack/fphook/zrf_ext.fc deleted file mode 100644 index 8f5878989..000000000 --- a/lib/ack/fphook/zrf_ext.fc +++ /dev/null @@ -1,22 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - ZERO and return EXTEND FORMAT FLOAT -*/ - -#include "FP_types.h" - -void -zrf_ext(e) -EXTEND *e; -{ - e->m1 = 0; - e->m2 = 0; - e->exp = 0; - e->sign = 0; -} diff --git a/lib/ack/h/m2_traps.h b/lib/ack/h/m2_traps.h deleted file mode 100644 index 9ea6330f0..000000000 --- a/lib/ack/h/m2_traps.h +++ /dev/null @@ -1,16 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1990 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ - -/* Modula-2 runtime errors */ - -#define M2_TOOLARGE 64 /* stack of process too large */ -#define M2_TOOMANY 65 /* too many nested traps & handlers */ -#define M2_NORESULT 66 /* no RETURN from procedure function */ -#define M2_UOVFL 67 /* cardinal overflow */ -#define M2_FORCH 68 /* FOR-loop control variable changed */ -#define M2_UUVFL 69 /* cardinal underflow */ -#define M2_INTERNAL 70 /* internal error, should not happen */ -#define M2_UNIXSIG 71 /* unix signal */ diff --git a/lib/ack/h/pc_err.h b/lib/ack/h/pc_err.h deleted file mode 100644 index bf72386c7..000000000 --- a/lib/ack/h/pc_err.h +++ /dev/null @@ -1,29 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -#define EARGC 64 -#define EEXP 65 -#define ELOG 66 -#define ESQT 67 -#define EASS 68 -#define EPACK 69 -#define EUNPACK 70 -#define EMOD 71 -#define EBADF 72 -#define EFREE 73 -#define EFUNASS 74 -#define EWIDTH 75 - -#define EWRITEF 96 -#define EREADF 97 -#define EEOF 98 -#define EFTRUNC 99 -#define ERESET 100 -#define EREWR 101 -#define ECLOSE 102 -#define EREAD 103 -#define EWRITE 104 -#define EDIGIT 105 -#define EASCII 106 diff --git a/lib/ack/h/pc_file.h b/lib/ack/h/pc_file.h deleted file mode 100644 index 3cd9f9dcd..000000000 --- a/lib/ack/h/pc_file.h +++ /dev/null @@ -1,24 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -#define WRBIT 0100000 -#define TXTBIT 040000 -#define EOFBIT 020000 -#define ELNBIT 010000 -#define WINDOW 04000 -#define MAGIC 0252 - -#define PC_BUFLEN 1024 - -struct file { - char *ptr; - unsigned flags; - char *fname; - int ufd; - int size; - int count; - int buflen; - char bufadr[PC_BUFLEN]; -}; diff --git a/lib/ack/h/pc_math.h b/lib/ack/h/pc_math.h deleted file mode 100644 index 0b2aaea83..000000000 --- a/lib/ack/h/pc_math.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * localmath.h - This header is used by the mathematical library. - */ -/* $Header$ */ - -/* some constants (Hart & Cheney) */ -#define M_PI 3.14159265358979323846264338327950288 -#define M_2PI 6.28318530717958647692528676655900576 -#define M_3PI_4 2.35619449019234492884698253745962716 -#define M_PI_2 1.57079632679489661923132169163975144 -#define M_3PI_8 1.17809724509617246442349126872981358 -#define M_PI_4 0.78539816339744830961566084581987572 -#define M_PI_8 0.39269908169872415480783042290993786 -#define M_1_PI 0.31830988618379067153776752674502872 -#define M_2_PI 0.63661977236758134307553505349005744 -#define M_4_PI 1.27323954473516268615107010698011488 -#define M_E 2.71828182845904523536028747135266250 -#define M_LOG2E 1.44269504088896340735992468100189213 -#define M_LOG10E 0.43429448190325182765112891891660508 -#define M_LN2 0.69314718055994530941723212145817657 -#define M_LN10 2.30258509299404568401799145468436421 -#define M_SQRT2 1.41421356237309504880168872420969808 -#define M_1_SQRT2 0.70710678118654752440084436210484904 -#define M_EULER 0.57721566490153286060651209008240243 - -/* macros for constructing polynomials */ -#define POLYNOM1(x, a) ((a)[1]*(x)+(a)[0]) -#define POLYNOM2(x, a) (POLYNOM1((x),(a)+1)*(x)+(a)[0]) -#define POLYNOM3(x, a) (POLYNOM2((x),(a)+1)*(x)+(a)[0]) -#define POLYNOM4(x, a) (POLYNOM3((x),(a)+1)*(x)+(a)[0]) -#define POLYNOM5(x, a) (POLYNOM4((x),(a)+1)*(x)+(a)[0]) -#define POLYNOM6(x, a) (POLYNOM5((x),(a)+1)*(x)+(a)[0]) -#define POLYNOM7(x, a) (POLYNOM6((x),(a)+1)*(x)+(a)[0]) -#define POLYNOM8(x, a) (POLYNOM7((x),(a)+1)*(x)+(a)[0]) -#define POLYNOM9(x, a) (POLYNOM8((x),(a)+1)*(x)+(a)[0]) -#define POLYNOM10(x, a) (POLYNOM9((x),(a)+1)*(x)+(a)[0]) -#define POLYNOM11(x, a) (POLYNOM10((x),(a)+1)*(x)+(a)[0]) -#define POLYNOM12(x, a) (POLYNOM11((x),(a)+1)*(x)+(a)[0]) -#define POLYNOM13(x, a) (POLYNOM12((x),(a)+1)*(x)+(a)[0]) - -#define M_LN_MAX_D (M_LN2 * DBL_MAX_EXP) -#define M_LN_MIN_D (M_LN2 * (DBL_MIN_EXP - 1)) diff --git a/lib/ack/i386/Makefile.in b/lib/ack/i386/Makefile.in deleted file mode 100644 index 92350c337..000000000 --- a/lib/ack/i386/Makefile.in +++ /dev/null @@ -1,4 +0,0 @@ - -SUBDIRS="em head" - -TYPE=ack diff --git a/lib/ack/i386/em/byte_order.h b/lib/ack/i386/em/byte_order.h deleted file mode 100644 index d08b45a5d..000000000 --- a/lib/ack/i386/em/byte_order.h +++ /dev/null @@ -1,6 +0,0 @@ -#define CHAR_UNSIGNED 0 -#define MSB_AT_LOW_ADDRESS 0 -#define MSW_AT_LOW_ADDRESS 0 -#define FL_MSB_AT_LOW_ADDRESS 0 -#define FL_MSW_AT_LOW_ADDRESS 0 -#define FL_MSL_AT_LOW_ADDRESS 0 diff --git a/lib/ack/i386/head/Makefile.in b/lib/ack/i386/head/Makefile.in deleted file mode 100644 index ca0f3992d..000000000 --- a/lib/ack/i386/head/Makefile.in +++ /dev/null @@ -1,9 +0,0 @@ -# Makefile for lib/ack/i386/head. - -#ASFLAGS = -I. - -LIBRARIES=libe - -libe_FILES=em_head.s - -TYPE=ack diff --git a/lib/ack/i386/head/em_abs.h b/lib/ack/i386/head/em_abs.h deleted file mode 100644 index 9855cff5a..000000000 --- a/lib/ack/i386/head/em_abs.h +++ /dev/null @@ -1,35 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ -#define LINO_AD 0 -#define FILN_AD 4 - -#define LINO (*(int *)(_hol0()+LINO_AD)) -#define FILN (*(char **)(_hol0()+FILN_AD)) - -#define EARRAY 0 -#define ERANGE 1 -#define ESET 2 -#define EIOVFL 3 -#define EFOVFL 4 -#define EFUNFL 5 -#define EIDIVZ 6 -#define EFDIVZ 7 -#define EIUND 8 -#define EFUND 9 -#define ECONV 10 - -#define ESTACK 16 -#define EHEAP 17 -#define EILLINS 18 -#define EODDZ 19 -#define ECASE 20 -#define EMEMFLT 21 -#define EBADPTR 22 -#define EBADPC 23 -#define EBADLAE 24 -#define EBADMON 25 -#define EBADLIN 26 -#define EBADGTO 27 diff --git a/lib/ack/fphook/Makefile.in b/lib/ack/libd/Makefile similarity index 76% rename from lib/ack/fphook/Makefile.in rename to lib/ack/libd/Makefile index 61eb65417..25e3bf676 100644 --- a/lib/ack/fphook/Makefile.in +++ b/lib/ack/libd/Makefile @@ -1,4 +1,4 @@ -# Makefile for lib/ack/fphook. +# Makefile for libd # The ACK ANSI C compiler has an nice trick to reduce the size of programs # that do not use floating point. If a program uses floating point then the @@ -8,12 +8,10 @@ # routines are found in libc.a. (The printf and scanf need floating point # for the %f formats, whether you use them or not.) -CFLAGS="-O -D_MINIX -D_POSIX_SOURCE -I.." +CPPFLAGS+=-O -D_MINIX -D_POSIX_SOURCE -I${.CURDIR}/../../libc/stdio -LIBRARIES="libd libc" +LIB= d -libd_FILES=fphook.c +SRCS= fphook.c -libc_FILES="fltpr.c strtod.c" - -TYPE=ack +.include diff --git a/lib/ack/fphook/fphook.c b/lib/ack/libd/fphook.c similarity index 99% rename from lib/ack/fphook/fphook.c rename to lib/ack/libd/fphook.c index 61730d609..9f8c084ff 100644 --- a/lib/ack/fphook/fphook.c +++ b/lib/ack/libd/fphook.c @@ -6,7 +6,7 @@ #ifndef NOFLOAT #include #include -#include "../stdio/loc_incl.h" +#include "loc_incl.h" int _fp_hook = 1; static char * diff --git a/lib/ack/libe/Makefile b/lib/ack/libe/Makefile new file mode 100644 index 000000000..83fa0ff41 --- /dev/null +++ b/lib/ack/libe/Makefile @@ -0,0 +1,10 @@ +# Makefile for libe + +LIB= e + +AFLAGS+=-O -D_MINIX -D_POSIX_SOURCE -Was-ack + +.include "${.CURDIR}/arch/${ARCH}/em/Makefile.inc" +.include "${.CURDIR}/arch/${ARCH}/head/Makefile.inc" + +.include diff --git a/lib/ack/i386/em/Makefile.in b/lib/ack/libe/arch/i386/em/Makefile.inc similarity index 80% rename from lib/ack/i386/em/Makefile.in rename to lib/ack/libe/arch/i386/em/Makefile.inc index 6d3a67dc9..b944a0cc6 100644 --- a/lib/ack/i386/em/Makefile.in +++ b/lib/ack/libe/arch/i386/em/Makefile.inc @@ -1,10 +1,7 @@ -# Makefile for lib/ack/i386/em. +# em sources +.PATH: ${.CURDIR}/arch/${ARCH}/em -CFLAGS="-O -D_MINIX -D_POSIX_SOURCE -Was-ack" - -LIBRARIES=libe - -libe_FILES=" \ +SRCS+= \ em_adi.s \ em_and.s \ em_blm.s \ @@ -49,6 +46,4 @@ libe_FILES=" \ em_stop.s \ em_trp.s \ em_unknown.s \ - em_xor.s" - -TYPE=ack + em_xor.s diff --git a/lib/ack/float/byte_order.h b/lib/ack/libe/arch/i386/em/byte_order.h similarity index 100% rename from lib/ack/float/byte_order.h rename to lib/ack/libe/arch/i386/em/byte_order.h diff --git a/lib/ack/i386/em/disconnected/em_adf4.s b/lib/ack/libe/arch/i386/em/disconnected/em_adf4.s similarity index 100% rename from lib/ack/i386/em/disconnected/em_adf4.s rename to lib/ack/libe/arch/i386/em/disconnected/em_adf4.s diff --git a/lib/ack/i386/em/disconnected/em_adf8.s b/lib/ack/libe/arch/i386/em/disconnected/em_adf8.s similarity index 100% rename from lib/ack/i386/em/disconnected/em_adf8.s rename to lib/ack/libe/arch/i386/em/disconnected/em_adf8.s diff --git a/lib/ack/i386/em/disconnected/em_cff4.s b/lib/ack/libe/arch/i386/em/disconnected/em_cff4.s similarity index 100% rename from lib/ack/i386/em/disconnected/em_cff4.s rename to lib/ack/libe/arch/i386/em/disconnected/em_cff4.s diff --git a/lib/ack/i386/em/disconnected/em_cff8.s b/lib/ack/libe/arch/i386/em/disconnected/em_cff8.s similarity index 100% rename from lib/ack/i386/em/disconnected/em_cff8.s rename to lib/ack/libe/arch/i386/em/disconnected/em_cff8.s diff --git a/lib/ack/i386/em/disconnected/em_cfi.s b/lib/ack/libe/arch/i386/em/disconnected/em_cfi.s similarity index 100% rename from lib/ack/i386/em/disconnected/em_cfi.s rename to lib/ack/libe/arch/i386/em/disconnected/em_cfi.s diff --git a/lib/ack/i386/em/disconnected/em_cfu.s b/lib/ack/libe/arch/i386/em/disconnected/em_cfu.s similarity index 100% rename from lib/ack/i386/em/disconnected/em_cfu.s rename to lib/ack/libe/arch/i386/em/disconnected/em_cfu.s diff --git a/lib/ack/i386/em/disconnected/em_cif4.s b/lib/ack/libe/arch/i386/em/disconnected/em_cif4.s similarity index 100% rename from lib/ack/i386/em/disconnected/em_cif4.s rename to lib/ack/libe/arch/i386/em/disconnected/em_cif4.s diff --git a/lib/ack/i386/em/disconnected/em_cif8.s b/lib/ack/libe/arch/i386/em/disconnected/em_cif8.s similarity index 100% rename from lib/ack/i386/em/disconnected/em_cif8.s rename to lib/ack/libe/arch/i386/em/disconnected/em_cif8.s diff --git a/lib/ack/i386/em/disconnected/em_cmf4.s b/lib/ack/libe/arch/i386/em/disconnected/em_cmf4.s similarity index 100% rename from lib/ack/i386/em/disconnected/em_cmf4.s rename to lib/ack/libe/arch/i386/em/disconnected/em_cmf4.s diff --git a/lib/ack/i386/em/disconnected/em_cmf8.s b/lib/ack/libe/arch/i386/em/disconnected/em_cmf8.s similarity index 100% rename from lib/ack/i386/em/disconnected/em_cmf8.s rename to lib/ack/libe/arch/i386/em/disconnected/em_cmf8.s diff --git a/lib/ack/i386/em/disconnected/em_cuf4.s b/lib/ack/libe/arch/i386/em/disconnected/em_cuf4.s similarity index 100% rename from lib/ack/i386/em/disconnected/em_cuf4.s rename to lib/ack/libe/arch/i386/em/disconnected/em_cuf4.s diff --git a/lib/ack/i386/em/disconnected/em_cuf8.s b/lib/ack/libe/arch/i386/em/disconnected/em_cuf8.s similarity index 100% rename from lib/ack/i386/em/disconnected/em_cuf8.s rename to lib/ack/libe/arch/i386/em/disconnected/em_cuf8.s diff --git a/lib/ack/i386/em/disconnected/em_dvf4.s b/lib/ack/libe/arch/i386/em/disconnected/em_dvf4.s similarity index 100% rename from lib/ack/i386/em/disconnected/em_dvf4.s rename to lib/ack/libe/arch/i386/em/disconnected/em_dvf4.s diff --git a/lib/ack/i386/em/disconnected/em_dvf8.s b/lib/ack/libe/arch/i386/em/disconnected/em_dvf8.s similarity index 100% rename from lib/ack/i386/em/disconnected/em_dvf8.s rename to lib/ack/libe/arch/i386/em/disconnected/em_dvf8.s diff --git a/lib/ack/i386/em/disconnected/em_fef4.s b/lib/ack/libe/arch/i386/em/disconnected/em_fef4.s similarity index 100% rename from lib/ack/i386/em/disconnected/em_fef4.s rename to lib/ack/libe/arch/i386/em/disconnected/em_fef4.s diff --git a/lib/ack/i386/em/disconnected/em_fef8.s b/lib/ack/libe/arch/i386/em/disconnected/em_fef8.s similarity index 100% rename from lib/ack/i386/em/disconnected/em_fef8.s rename to lib/ack/libe/arch/i386/em/disconnected/em_fef8.s diff --git a/lib/ack/i386/em/disconnected/em_fif4.s b/lib/ack/libe/arch/i386/em/disconnected/em_fif4.s similarity index 100% rename from lib/ack/i386/em/disconnected/em_fif4.s rename to lib/ack/libe/arch/i386/em/disconnected/em_fif4.s diff --git a/lib/ack/i386/em/disconnected/em_fif8.s b/lib/ack/libe/arch/i386/em/disconnected/em_fif8.s similarity index 100% rename from lib/ack/i386/em/disconnected/em_fif8.s rename to lib/ack/libe/arch/i386/em/disconnected/em_fif8.s diff --git a/lib/ack/i386/em/disconnected/em_mlf4.s b/lib/ack/libe/arch/i386/em/disconnected/em_mlf4.s similarity index 100% rename from lib/ack/i386/em/disconnected/em_mlf4.s rename to lib/ack/libe/arch/i386/em/disconnected/em_mlf4.s diff --git a/lib/ack/i386/em/disconnected/em_mlf8.s b/lib/ack/libe/arch/i386/em/disconnected/em_mlf8.s similarity index 100% rename from lib/ack/i386/em/disconnected/em_mlf8.s rename to lib/ack/libe/arch/i386/em/disconnected/em_mlf8.s diff --git a/lib/ack/i386/em/disconnected/em_ngf4.s b/lib/ack/libe/arch/i386/em/disconnected/em_ngf4.s similarity index 100% rename from lib/ack/i386/em/disconnected/em_ngf4.s rename to lib/ack/libe/arch/i386/em/disconnected/em_ngf4.s diff --git a/lib/ack/i386/em/disconnected/em_ngf8.s b/lib/ack/libe/arch/i386/em/disconnected/em_ngf8.s similarity index 100% rename from lib/ack/i386/em/disconnected/em_ngf8.s rename to lib/ack/libe/arch/i386/em/disconnected/em_ngf8.s diff --git a/lib/ack/i386/em/disconnected/em_sbf4.s b/lib/ack/libe/arch/i386/em/disconnected/em_sbf4.s similarity index 100% rename from lib/ack/i386/em/disconnected/em_sbf4.s rename to lib/ack/libe/arch/i386/em/disconnected/em_sbf4.s diff --git a/lib/ack/i386/em/disconnected/em_sbf8.s b/lib/ack/libe/arch/i386/em/disconnected/em_sbf8.s similarity index 100% rename from lib/ack/i386/em/disconnected/em_sbf8.s rename to lib/ack/libe/arch/i386/em/disconnected/em_sbf8.s diff --git a/lib/ack/i386/em/em_adi.s b/lib/ack/libe/arch/i386/em/em_adi.s similarity index 100% rename from lib/ack/i386/em/em_adi.s rename to lib/ack/libe/arch/i386/em/em_adi.s diff --git a/lib/ack/i386/em/em_and.s b/lib/ack/libe/arch/i386/em/em_and.s similarity index 100% rename from lib/ack/i386/em/em_and.s rename to lib/ack/libe/arch/i386/em/em_and.s diff --git a/lib/ack/i386/em/em_blm.s b/lib/ack/libe/arch/i386/em/em_blm.s similarity index 100% rename from lib/ack/i386/em/em_blm.s rename to lib/ack/libe/arch/i386/em/em_blm.s diff --git a/lib/ack/i386/em/em_cii.s b/lib/ack/libe/arch/i386/em/em_cii.s similarity index 100% rename from lib/ack/i386/em/em_cii.s rename to lib/ack/libe/arch/i386/em/em_cii.s diff --git a/lib/ack/i386/em/em_cms.s b/lib/ack/libe/arch/i386/em/em_cms.s similarity index 100% rename from lib/ack/i386/em/em_cms.s rename to lib/ack/libe/arch/i386/em/em_cms.s diff --git a/lib/ack/i386/em/em_com.s b/lib/ack/libe/arch/i386/em/em_com.s similarity index 100% rename from lib/ack/i386/em/em_com.s rename to lib/ack/libe/arch/i386/em/em_com.s diff --git a/lib/ack/i386/em/em_csa4.s b/lib/ack/libe/arch/i386/em/em_csa4.s similarity index 100% rename from lib/ack/i386/em/em_csa4.s rename to lib/ack/libe/arch/i386/em/em_csa4.s diff --git a/lib/ack/i386/em/em_csb4.s b/lib/ack/libe/arch/i386/em/em_csb4.s similarity index 100% rename from lib/ack/i386/em/em_csb4.s rename to lib/ack/libe/arch/i386/em/em_csb4.s diff --git a/lib/ack/i386/em/em_cuu.s b/lib/ack/libe/arch/i386/em/em_cuu.s similarity index 100% rename from lib/ack/i386/em/em_cuu.s rename to lib/ack/libe/arch/i386/em/em_cuu.s diff --git a/lib/ack/i386/em/em_dup.s b/lib/ack/libe/arch/i386/em/em_dup.s similarity index 100% rename from lib/ack/i386/em/em_dup.s rename to lib/ack/libe/arch/i386/em/em_dup.s diff --git a/lib/ack/i386/em/em_dvi.s b/lib/ack/libe/arch/i386/em/em_dvi.s similarity index 100% rename from lib/ack/i386/em/em_dvi.s rename to lib/ack/libe/arch/i386/em/em_dvi.s diff --git a/lib/ack/i386/em/em_dvu.s b/lib/ack/libe/arch/i386/em/em_dvu.s similarity index 100% rename from lib/ack/i386/em/em_dvu.s rename to lib/ack/libe/arch/i386/em/em_dvu.s diff --git a/lib/ack/i386/em/em_error.s b/lib/ack/libe/arch/i386/em/em_error.s similarity index 100% rename from lib/ack/i386/em/em_error.s rename to lib/ack/libe/arch/i386/em/em_error.s diff --git a/lib/ack/i386/em/em_exg.s b/lib/ack/libe/arch/i386/em/em_exg.s similarity index 100% rename from lib/ack/i386/em/em_exg.s rename to lib/ack/libe/arch/i386/em/em_exg.s diff --git a/lib/ack/i386/em/em_fat.s b/lib/ack/libe/arch/i386/em/em_fat.s similarity index 100% rename from lib/ack/i386/em/em_fat.s rename to lib/ack/libe/arch/i386/em/em_fat.s diff --git a/lib/ack/i386/em/em_fp8087.s b/lib/ack/libe/arch/i386/em/em_fp8087.s similarity index 100% rename from lib/ack/i386/em/em_fp8087.s rename to lib/ack/libe/arch/i386/em/em_fp8087.s diff --git a/lib/ack/i386/em/em_gto.s b/lib/ack/libe/arch/i386/em/em_gto.s similarity index 100% rename from lib/ack/i386/em/em_gto.s rename to lib/ack/libe/arch/i386/em/em_gto.s diff --git a/lib/ack/i386/em/em_hol0.s b/lib/ack/libe/arch/i386/em/em_hol0.s similarity index 100% rename from lib/ack/i386/em/em_hol0.s rename to lib/ack/libe/arch/i386/em/em_hol0.s diff --git a/lib/ack/i386/em/em_iaar.s b/lib/ack/libe/arch/i386/em/em_iaar.s similarity index 100% rename from lib/ack/i386/em/em_iaar.s rename to lib/ack/libe/arch/i386/em/em_iaar.s diff --git a/lib/ack/i386/em/em_ilar.s b/lib/ack/libe/arch/i386/em/em_ilar.s similarity index 100% rename from lib/ack/i386/em/em_ilar.s rename to lib/ack/libe/arch/i386/em/em_ilar.s diff --git a/lib/ack/i386/em/em_inn.s b/lib/ack/libe/arch/i386/em/em_inn.s similarity index 100% rename from lib/ack/i386/em/em_inn.s rename to lib/ack/libe/arch/i386/em/em_inn.s diff --git a/lib/ack/i386/em/em_ior.s b/lib/ack/libe/arch/i386/em/em_ior.s similarity index 100% rename from lib/ack/i386/em/em_ior.s rename to lib/ack/libe/arch/i386/em/em_ior.s diff --git a/lib/ack/i386/em/em_isar.s b/lib/ack/libe/arch/i386/em/em_isar.s similarity index 100% rename from lib/ack/i386/em/em_isar.s rename to lib/ack/libe/arch/i386/em/em_isar.s diff --git a/lib/ack/i386/em/em_lar4.s b/lib/ack/libe/arch/i386/em/em_lar4.s similarity index 100% rename from lib/ack/i386/em/em_lar4.s rename to lib/ack/libe/arch/i386/em/em_lar4.s diff --git a/lib/ack/i386/em/em_loi.s b/lib/ack/libe/arch/i386/em/em_loi.s similarity index 100% rename from lib/ack/i386/em/em_loi.s rename to lib/ack/libe/arch/i386/em/em_loi.s diff --git a/lib/ack/i386/em/em_mli.s b/lib/ack/libe/arch/i386/em/em_mli.s similarity index 100% rename from lib/ack/i386/em/em_mli.s rename to lib/ack/libe/arch/i386/em/em_mli.s diff --git a/lib/ack/i386/em/em_mon.s b/lib/ack/libe/arch/i386/em/em_mon.s similarity index 100% rename from lib/ack/i386/em/em_mon.s rename to lib/ack/libe/arch/i386/em/em_mon.s diff --git a/lib/ack/i386/em/em_ngi.s b/lib/ack/libe/arch/i386/em/em_ngi.s similarity index 100% rename from lib/ack/i386/em/em_ngi.s rename to lib/ack/libe/arch/i386/em/em_ngi.s diff --git a/lib/ack/i386/em/em_nop.s b/lib/ack/libe/arch/i386/em/em_nop.s similarity index 100% rename from lib/ack/i386/em/em_nop.s rename to lib/ack/libe/arch/i386/em/em_nop.s diff --git a/lib/ack/i386/em/em_print.s b/lib/ack/libe/arch/i386/em/em_print.s similarity index 100% rename from lib/ack/i386/em/em_print.s rename to lib/ack/libe/arch/i386/em/em_print.s diff --git a/lib/ack/i386/em/em_rck.s b/lib/ack/libe/arch/i386/em/em_rck.s similarity index 100% rename from lib/ack/i386/em/em_rck.s rename to lib/ack/libe/arch/i386/em/em_rck.s diff --git a/lib/ack/i386/em/em_rmi.s b/lib/ack/libe/arch/i386/em/em_rmi.s similarity index 100% rename from lib/ack/i386/em/em_rmi.s rename to lib/ack/libe/arch/i386/em/em_rmi.s diff --git a/lib/ack/i386/em/em_rmu.s b/lib/ack/libe/arch/i386/em/em_rmu.s similarity index 100% rename from lib/ack/i386/em/em_rmu.s rename to lib/ack/libe/arch/i386/em/em_rmu.s diff --git a/lib/ack/i386/em/em_rol.s b/lib/ack/libe/arch/i386/em/em_rol.s similarity index 100% rename from lib/ack/i386/em/em_rol.s rename to lib/ack/libe/arch/i386/em/em_rol.s diff --git a/lib/ack/i386/em/em_ror.s b/lib/ack/libe/arch/i386/em/em_ror.s similarity index 100% rename from lib/ack/i386/em/em_ror.s rename to lib/ack/libe/arch/i386/em/em_ror.s diff --git a/lib/ack/i386/em/em_sar4.s b/lib/ack/libe/arch/i386/em/em_sar4.s similarity index 100% rename from lib/ack/i386/em/em_sar4.s rename to lib/ack/libe/arch/i386/em/em_sar4.s diff --git a/lib/ack/i386/em/em_sbi.s b/lib/ack/libe/arch/i386/em/em_sbi.s similarity index 100% rename from lib/ack/i386/em/em_sbi.s rename to lib/ack/libe/arch/i386/em/em_sbi.s diff --git a/lib/ack/i386/em/em_set.s b/lib/ack/libe/arch/i386/em/em_set.s similarity index 100% rename from lib/ack/i386/em/em_set.s rename to lib/ack/libe/arch/i386/em/em_set.s diff --git a/lib/ack/i386/em/em_sli.s b/lib/ack/libe/arch/i386/em/em_sli.s similarity index 100% rename from lib/ack/i386/em/em_sli.s rename to lib/ack/libe/arch/i386/em/em_sli.s diff --git a/lib/ack/i386/em/em_sri.s b/lib/ack/libe/arch/i386/em/em_sri.s similarity index 100% rename from lib/ack/i386/em/em_sri.s rename to lib/ack/libe/arch/i386/em/em_sri.s diff --git a/lib/ack/i386/em/em_sti.s b/lib/ack/libe/arch/i386/em/em_sti.s similarity index 100% rename from lib/ack/i386/em/em_sti.s rename to lib/ack/libe/arch/i386/em/em_sti.s diff --git a/lib/ack/i386/em/em_stop.s b/lib/ack/libe/arch/i386/em/em_stop.s similarity index 100% rename from lib/ack/i386/em/em_stop.s rename to lib/ack/libe/arch/i386/em/em_stop.s diff --git a/lib/ack/i386/em/em_trp.s b/lib/ack/libe/arch/i386/em/em_trp.s similarity index 100% rename from lib/ack/i386/em/em_trp.s rename to lib/ack/libe/arch/i386/em/em_trp.s diff --git a/lib/ack/i386/em/em_unknown.s b/lib/ack/libe/arch/i386/em/em_unknown.s similarity index 100% rename from lib/ack/i386/em/em_unknown.s rename to lib/ack/libe/arch/i386/em/em_unknown.s diff --git a/lib/ack/i386/em/em_xor.s b/lib/ack/libe/arch/i386/em/em_xor.s similarity index 100% rename from lib/ack/i386/em/em_xor.s rename to lib/ack/libe/arch/i386/em/em_xor.s diff --git a/lib/ack/libe/arch/i386/head/Makefile.inc b/lib/ack/libe/arch/i386/head/Makefile.inc new file mode 100644 index 000000000..210ff2880 --- /dev/null +++ b/lib/ack/libe/arch/i386/head/Makefile.inc @@ -0,0 +1,4 @@ +# head sources +.PATH: ${.CURDIR}/arch/${ARCH}/head + +SRCS+= em_head.s diff --git a/lib/ack/h/em_abs.h b/lib/ack/libe/arch/i386/head/em_abs.h similarity index 100% rename from lib/ack/h/em_abs.h rename to lib/ack/libe/arch/i386/head/em_abs.h diff --git a/lib/ack/i386/head/em_head.s b/lib/ack/libe/arch/i386/head/em_head.s similarity index 100% rename from lib/ack/i386/head/em_head.s rename to lib/ack/libe/arch/i386/head/em_head.s diff --git a/lib/ack/float/FP.script b/lib/ack/libfp/FP.script similarity index 100% rename from lib/ack/float/FP.script rename to lib/ack/libfp/FP.script diff --git a/lib/ack/float/FP_bias.h b/lib/ack/libfp/FP_bias.h similarity index 100% rename from lib/ack/float/FP_bias.h rename to lib/ack/libfp/FP_bias.h diff --git a/lib/ack/float/FP_shift.h b/lib/ack/libfp/FP_shift.h similarity index 100% rename from lib/ack/float/FP_shift.h rename to lib/ack/libfp/FP_shift.h diff --git a/lib/ack/float/FP_trap.h b/lib/ack/libfp/FP_trap.h similarity index 100% rename from lib/ack/float/FP_trap.h rename to lib/ack/libfp/FP_trap.h diff --git a/lib/ack/float/FP_types.h b/lib/ack/libfp/FP_types.h similarity index 100% rename from lib/ack/float/FP_types.h rename to lib/ack/libfp/FP_types.h diff --git a/lib/ack/libfp/Makefile b/lib/ack/libfp/Makefile new file mode 100644 index 000000000..2425876b7 --- /dev/null +++ b/lib/ack/libfp/Makefile @@ -0,0 +1,56 @@ +# Makefile for libfp + +# .fc build rule +.SUFFIXES: .o .fc + +.fc.o: + ${_MKTARGET_COMPILE} + cp ${.IMPSRC} tmp.c + cc -O -I${.CURDIR} -D_MINIX -D_POSIX_SOURCE -S tmp.c + sed -f ${.CURDIR}/FP.script tmp.s > ${.PREFIX}.s + cc -I${.CURDIR} -c -o ${.TARGET} ${.PREFIX}.s + rm -f tmp.c tmp.s ${PREFIX}.s + +LIB= fp + +SRCS= \ + add_ext.fc \ + adder.fc \ + adf4.fc \ + adf8.fc \ + cff4.fc \ + cff8.fc \ + cfi.fc \ + cfu.fc \ + cif4.fc \ + cif8.fc \ + cmf4.fc \ + cmf8.fc \ + compact.fc \ + cuf4.fc \ + cuf8.fc \ + div_ext.fc \ + dvf4.fc \ + dvf8.fc \ + extend.fc \ + fef4.fc \ + fef8.fc \ + fif4.fc \ + fif8.fc \ + fptrp.s \ + mlf4.fc \ + mlf8.fc \ + mul_ext.fc \ + ngf4.fc \ + ngf8.fc \ + nrm_ext.fc \ + sbf4.fc \ + sbf8.fc \ + sft_ext.fc \ + shifter.fc \ + sub_ext.fc \ + zrf4.fc \ + zrf8.fc \ + zrf_ext.fc + +.include diff --git a/lib/ack/float/add_ext.fc b/lib/ack/libfp/add_ext.fc similarity index 100% rename from lib/ack/float/add_ext.fc rename to lib/ack/libfp/add_ext.fc diff --git a/lib/ack/float/adder.fc b/lib/ack/libfp/adder.fc similarity index 100% rename from lib/ack/float/adder.fc rename to lib/ack/libfp/adder.fc diff --git a/lib/ack/float/adder.h b/lib/ack/libfp/adder.h similarity index 100% rename from lib/ack/float/adder.h rename to lib/ack/libfp/adder.h diff --git a/lib/ack/float/adf4.fc b/lib/ack/libfp/adf4.fc similarity index 100% rename from lib/ack/float/adf4.fc rename to lib/ack/libfp/adf4.fc diff --git a/lib/ack/float/adf8.fc b/lib/ack/libfp/adf8.fc similarity index 100% rename from lib/ack/float/adf8.fc rename to lib/ack/libfp/adf8.fc diff --git a/lib/ack/fphook/byte_order.h b/lib/ack/libfp/byte_order.h similarity index 100% rename from lib/ack/fphook/byte_order.h rename to lib/ack/libfp/byte_order.h diff --git a/lib/ack/float/cff4.fc b/lib/ack/libfp/cff4.fc similarity index 100% rename from lib/ack/float/cff4.fc rename to lib/ack/libfp/cff4.fc diff --git a/lib/ack/float/cff8.fc b/lib/ack/libfp/cff8.fc similarity index 100% rename from lib/ack/float/cff8.fc rename to lib/ack/libfp/cff8.fc diff --git a/lib/ack/float/cfi.fc b/lib/ack/libfp/cfi.fc similarity index 100% rename from lib/ack/float/cfi.fc rename to lib/ack/libfp/cfi.fc diff --git a/lib/ack/float/cfu.fc b/lib/ack/libfp/cfu.fc similarity index 100% rename from lib/ack/float/cfu.fc rename to lib/ack/libfp/cfu.fc diff --git a/lib/ack/float/cif4.fc b/lib/ack/libfp/cif4.fc similarity index 100% rename from lib/ack/float/cif4.fc rename to lib/ack/libfp/cif4.fc diff --git a/lib/ack/float/cif8.fc b/lib/ack/libfp/cif8.fc similarity index 100% rename from lib/ack/float/cif8.fc rename to lib/ack/libfp/cif8.fc diff --git a/lib/ack/float/cmf4.fc b/lib/ack/libfp/cmf4.fc similarity index 100% rename from lib/ack/float/cmf4.fc rename to lib/ack/libfp/cmf4.fc diff --git a/lib/ack/float/cmf8.fc b/lib/ack/libfp/cmf8.fc similarity index 100% rename from lib/ack/float/cmf8.fc rename to lib/ack/libfp/cmf8.fc diff --git a/lib/ack/float/compact.fc b/lib/ack/libfp/compact.fc similarity index 100% rename from lib/ack/float/compact.fc rename to lib/ack/libfp/compact.fc diff --git a/lib/ack/float/cuf4.fc b/lib/ack/libfp/cuf4.fc similarity index 100% rename from lib/ack/float/cuf4.fc rename to lib/ack/libfp/cuf4.fc diff --git a/lib/ack/float/cuf8.fc b/lib/ack/libfp/cuf8.fc similarity index 100% rename from lib/ack/float/cuf8.fc rename to lib/ack/libfp/cuf8.fc diff --git a/lib/ack/float/div_ext.fc b/lib/ack/libfp/div_ext.fc similarity index 100% rename from lib/ack/float/div_ext.fc rename to lib/ack/libfp/div_ext.fc diff --git a/lib/ack/float/dvf4.fc b/lib/ack/libfp/dvf4.fc similarity index 100% rename from lib/ack/float/dvf4.fc rename to lib/ack/libfp/dvf4.fc diff --git a/lib/ack/float/dvf8.fc b/lib/ack/libfp/dvf8.fc similarity index 100% rename from lib/ack/float/dvf8.fc rename to lib/ack/libfp/dvf8.fc diff --git a/lib/ack/float/extend.fc b/lib/ack/libfp/extend.fc similarity index 100% rename from lib/ack/float/extend.fc rename to lib/ack/libfp/extend.fc diff --git a/lib/ack/float/fef4.fc b/lib/ack/libfp/fef4.fc similarity index 100% rename from lib/ack/float/fef4.fc rename to lib/ack/libfp/fef4.fc diff --git a/lib/ack/float/fef8.fc b/lib/ack/libfp/fef8.fc similarity index 100% rename from lib/ack/float/fef8.fc rename to lib/ack/libfp/fef8.fc diff --git a/lib/ack/float/fif4.fc b/lib/ack/libfp/fif4.fc similarity index 100% rename from lib/ack/float/fif4.fc rename to lib/ack/libfp/fif4.fc diff --git a/lib/ack/float/fif8.fc b/lib/ack/libfp/fif8.fc similarity index 100% rename from lib/ack/float/fif8.fc rename to lib/ack/libfp/fif8.fc diff --git a/lib/ack/float/fptrp.s b/lib/ack/libfp/fptrp.s similarity index 100% rename from lib/ack/float/fptrp.s rename to lib/ack/libfp/fptrp.s diff --git a/lib/ack/float/get_put.h b/lib/ack/libfp/get_put.h similarity index 100% rename from lib/ack/float/get_put.h rename to lib/ack/libfp/get_put.h diff --git a/lib/ack/float/mlf4.fc b/lib/ack/libfp/mlf4.fc similarity index 100% rename from lib/ack/float/mlf4.fc rename to lib/ack/libfp/mlf4.fc diff --git a/lib/ack/float/mlf8.fc b/lib/ack/libfp/mlf8.fc similarity index 100% rename from lib/ack/float/mlf8.fc rename to lib/ack/libfp/mlf8.fc diff --git a/lib/ack/float/mul_ext.fc b/lib/ack/libfp/mul_ext.fc similarity index 100% rename from lib/ack/float/mul_ext.fc rename to lib/ack/libfp/mul_ext.fc diff --git a/lib/ack/float/ngf4.fc b/lib/ack/libfp/ngf4.fc similarity index 100% rename from lib/ack/float/ngf4.fc rename to lib/ack/libfp/ngf4.fc diff --git a/lib/ack/float/ngf8.fc b/lib/ack/libfp/ngf8.fc similarity index 100% rename from lib/ack/float/ngf8.fc rename to lib/ack/libfp/ngf8.fc diff --git a/lib/ack/float/nrm_ext.fc b/lib/ack/libfp/nrm_ext.fc similarity index 100% rename from lib/ack/float/nrm_ext.fc rename to lib/ack/libfp/nrm_ext.fc diff --git a/lib/ack/float/sbf4.fc b/lib/ack/libfp/sbf4.fc similarity index 100% rename from lib/ack/float/sbf4.fc rename to lib/ack/libfp/sbf4.fc diff --git a/lib/ack/float/sbf8.fc b/lib/ack/libfp/sbf8.fc similarity index 100% rename from lib/ack/float/sbf8.fc rename to lib/ack/libfp/sbf8.fc diff --git a/lib/ack/float/sft_ext.fc b/lib/ack/libfp/sft_ext.fc similarity index 100% rename from lib/ack/float/sft_ext.fc rename to lib/ack/libfp/sft_ext.fc diff --git a/lib/ack/float/shifter.fc b/lib/ack/libfp/shifter.fc similarity index 100% rename from lib/ack/float/shifter.fc rename to lib/ack/libfp/shifter.fc diff --git a/lib/ack/float/sub_ext.fc b/lib/ack/libfp/sub_ext.fc similarity index 100% rename from lib/ack/float/sub_ext.fc rename to lib/ack/libfp/sub_ext.fc diff --git a/lib/ack/float/zrf4.fc b/lib/ack/libfp/zrf4.fc similarity index 100% rename from lib/ack/float/zrf4.fc rename to lib/ack/libfp/zrf4.fc diff --git a/lib/ack/float/zrf8.fc b/lib/ack/libfp/zrf8.fc similarity index 100% rename from lib/ack/float/zrf8.fc rename to lib/ack/libfp/zrf8.fc diff --git a/lib/ack/float/zrf_ext.fc b/lib/ack/libfp/zrf_ext.fc similarity index 100% rename from lib/ack/float/zrf_ext.fc rename to lib/ack/libfp/zrf_ext.fc diff --git a/lib/ack/libm2/Arguments.c b/lib/ack/libm2/Arguments.c deleted file mode 100644 index eaf696236..000000000 --- a/lib/ack/libm2/Arguments.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* - Module: Access to program arguments and environment - Author: Ceriel J.H. Jacobs - Version: $Header$ -*/ - -extern char **argv, ***_penviron; -extern int argc; -unsigned int _Arguments__Argc; - -static char * -findname(s1, s2) -register char *s1, *s2; -{ - - while (*s1 == *s2++) s1++; - if (*s1 == '\0' && *(s2-1) == '=') return s2; - return 0; -} - -static unsigned int -scopy(src, dst, max) - register char *src, *dst; - unsigned int max; -{ - register unsigned int i = 0; - - while (*src && i <= max) { - i++; - *dst++ = *src++; - } - if (i <= max) { - *dst = '\0'; - return i+1; - } - while (*src++) i++; - return i + 1; -} - -_Arguments_() -{ - _Arguments__Argc = argc; -} - -unsigned -_Arguments__Argv(n, argument, l, u, s) - unsigned int u; - char *argument; -{ - - if (n >= argc) return 0; - return scopy(argv[n], argument, u); -} - -unsigned -_Arguments__GetEnv(name, nn, nu, ns, value, l, u, s) - char *name, *value; - unsigned int nu, u; -{ - register char **p = *_penviron; - register char *v = 0; - - while (*p && !(v = findname(name, *p++))) { - /* nothing */ - } - if (!v) return 0; - return scopy(v, value, u); -} diff --git a/lib/ack/libm2/ArraySort.mod b/lib/ack/libm2/ArraySort.mod deleted file mode 100755 index 147ca9e60..000000000 --- a/lib/ack/libm2/ArraySort.mod +++ /dev/null @@ -1,155 +0,0 @@ -(* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*) - -(*$R-*) -IMPLEMENTATION MODULE ArraySort; -(* - Module: Array sorting module. - Author: Ceriel J.H. Jacobs - Version: $Header$ -*) - FROM SYSTEM IMPORT ADDRESS, BYTE; (* no generics in Modula-2, sorry *) - - TYPE BytePtr = POINTER TO BYTE; - - VAR compareproc: CompareProc; - - PROCEDURE Sort(base: ADDRESS; (* address of array *) - nel: CARDINAL; (* number of elements in array *) - size: CARDINAL; (* size of each element *) - compar: CompareProc); (* the comparison procedure *) - BEGIN - compareproc := compar; - qsort(base, base+(nel-1)*size, size); - END Sort; - - PROCEDURE qsort(a1, a2: ADDRESS; size: CARDINAL); - (* Implemented with quick-sort, with some extra's *) - VAR left, right, lefteq, righteq: ADDRESS; - cmp: CompareResult; - mainloop: BOOLEAN; - BEGIN - WHILE a2 > a1 DO - left := a1; - right := a2; - lefteq := a1 + size * (((a2 - a1) + size) DIV (2 * size)); - righteq := lefteq; - (* - Pick an element in the middle of the array. - We will collect the equals around it. - "lefteq" and "righteq" indicate the left and right - bounds of the equals respectively. - Smaller elements end up left of it, larger elements end - up right of it. - *) - LOOP - LOOP - IF left >= lefteq THEN EXIT END; - cmp := compareproc(left, lefteq); - IF cmp = greater THEN EXIT END; - IF cmp = less THEN - left := left + size; - ELSE - (* equal, so exchange with the element - to the left of the "equal"-interval. - *) - lefteq := lefteq - size; - exchange(left, lefteq, size); - END; - END; - mainloop := FALSE; - LOOP - IF right <= righteq THEN EXIT END; - cmp := compareproc(right, righteq); - IF cmp = less THEN - IF left < lefteq THEN - (* larger one at the left, - so exchange - *) - exchange(left,right,size); - left := left + size; - right := right - size; - mainloop := TRUE; - EXIT; - END; - (* - no more room at the left part, so we - move the "equal-interval" one place to the - right, and the smaller element to the - left of it. - This is best expressed as a three-way - exchange. - *) - righteq := righteq + size; - threewayexchange(left, righteq, right, - size); - lefteq := lefteq + size; - left := lefteq; - ELSIF cmp = equal THEN - (* equal, zo exchange with the element - to the right of the "equal" - interval - *) - righteq := righteq + size; - exchange(right, righteq, size); - ELSE - (* leave it where it is *) - right := right - size; - END; - END; - IF (NOT mainloop) THEN - IF left >= lefteq THEN - (* sort "smaller" part *) - qsort(a1, lefteq - size, size); - (* and now the "larger" part, saving a - procedure call, because of this big - WHILE loop - *) - a1 := righteq + size; - EXIT; (* from the LOOP *) - END; - (* larger element to the left, but no more room, - so move the "equal-interval" one place to the - left, and the larger element to the right - of it. - *) - lefteq := lefteq - size; - threewayexchange(right, lefteq, left, size); - righteq := righteq - size; - right := righteq; - END; - END; - END; - END qsort; - - PROCEDURE exchange(a,b: BytePtr; size : CARDINAL); - VAR c: BYTE; - BEGIN - WHILE size > 0 DO - DEC(size); - c := a^; - a^ := b^; - a := ADDRESS(a) + 1; - b^ := c; - b := ADDRESS(b) + 1; - END; - END exchange; - - PROCEDURE threewayexchange(p,q,r: BytePtr; size: CARDINAL); - VAR c: BYTE; - BEGIN - WHILE size > 0 DO - DEC(size); - c := p^; - p^ := r^; - p := ADDRESS(p) + 1; - r^ := q^; - r := ADDRESS(r) + 1; - q^ := c; - q := ADDRESS(q) + 1; - END; - END threewayexchange; - -END ArraySort. diff --git a/lib/ack/libm2/CSP.mod b/lib/ack/libm2/CSP.mod deleted file mode 100755 index 7a50df425..000000000 --- a/lib/ack/libm2/CSP.mod +++ /dev/null @@ -1,347 +0,0 @@ -(*$R-*) -IMPLEMENTATION MODULE CSP; -(* - Module: Communicating Sequential Processes - From: "A Modula-2 Implementation of CSP", - M. Collado, R. Morales, J.J. Moreno, - SIGPlan Notices, Volume 22, Number 6, June 1987. - Some modifications by Ceriel J.H. Jacobs - Version: $Header$ - - See this article for an explanation of the use of this module. -*) - - FROM random IMPORT Uniform; - FROM SYSTEM IMPORT BYTE, ADDRESS, NEWPROCESS, TRANSFER; - FROM Storage IMPORT Allocate, Deallocate; - FROM Traps IMPORT Message; - - CONST WorkSpaceSize = 2000; - - TYPE ByteAddress = POINTER TO BYTE; - Channel = POINTER TO ChannelDescriptor; - ProcessType = POINTER TO ProcessDescriptor; - ProcessDescriptor = RECORD - next: ProcessType; - father: ProcessType; - cor: ADDRESS; - wsp: ADDRESS; - guardindex: INTEGER; - guardno: CARDINAL; - guardcount: CARDINAL; - opened: Channel; - sons: CARDINAL; - msgadr: ADDRESS; - msglen: CARDINAL; - END; - - Queue = RECORD - head, tail: ProcessType; - END; - - ChannelDescriptor = RECORD - senders: Queue; - owner: ProcessType; - guardindex: INTEGER; - next: Channel; - END; - - VAR cp: ProcessType; - free, ready: Queue; - -(* ------------ Private modules and procedures ------------- *) - - MODULE ProcessQueue; - - IMPORT ProcessType, Queue; - EXPORT Push, Pop, InitQueue, IsEmpty; - - PROCEDURE InitQueue(VAR q: Queue); - BEGIN - WITH q DO - head := NIL; - tail := NIL - END - END InitQueue; - - PROCEDURE Push(p: ProcessType; VAR q: Queue); - BEGIN - p^.next := NIL; - WITH q DO - IF head = NIL THEN - tail := p - ELSE - head^.next := p - END; - head := p - END - END Push; - - PROCEDURE Pop(VAR q: Queue; VAR p: ProcessType); - BEGIN - WITH q DO - p := tail; - IF p # NIL THEN - tail := tail^.next; - IF head = p THEN - head := NIL - END - END - END - END Pop; - - PROCEDURE IsEmpty(q: Queue): BOOLEAN; - BEGIN - RETURN q.head = NIL - END IsEmpty; - - END ProcessQueue; - - - PROCEDURE DoTransfer; - VAR aux: ProcessType; - BEGIN - aux := cp; - Pop(ready, cp); - IF cp = NIL THEN - HALT - ELSE - TRANSFER(aux^.cor, cp^.cor) - END - END DoTransfer; - - PROCEDURE OpenChannel(ch: Channel; n: INTEGER); - BEGIN - WITH ch^ DO - IF guardindex = 0 THEN - guardindex := n; - next := cp^.opened; - cp^.opened := ch - END - END - END OpenChannel; - - PROCEDURE CloseChannels(p: ProcessType); - BEGIN - WITH p^ DO - WHILE opened # NIL DO - opened^.guardindex := 0; - opened := opened^.next - END - END - END CloseChannels; - - PROCEDURE ThereAreOpenChannels(): BOOLEAN; - BEGIN - RETURN cp^.opened # NIL; - END ThereAreOpenChannels; - - PROCEDURE Sending(ch: Channel): BOOLEAN; - BEGIN - RETURN NOT IsEmpty(ch^.senders) - END Sending; - -(* -------------- Public Procedures ----------------- *) - - PROCEDURE COBEGIN; - (* Beginning of a COBEGIN .. COEND structure *) - BEGIN - END COBEGIN; - - PROCEDURE COEND; - (* End of a COBEGIN .. COEND structure *) - (* VAR aux: ProcessType; *) - BEGIN - IF cp^.sons > 0 THEN - DoTransfer - END - END COEND; - - PROCEDURE StartProcess(P: PROC); - (* Start an anonimous process that executes the procedure P *) - VAR newprocess: ProcessType; - BEGIN - Pop(free, newprocess); - IF newprocess = NIL THEN - Allocate(newprocess,SIZE(ProcessDescriptor)); - Allocate(newprocess^.wsp, WorkSpaceSize) - END; - WITH newprocess^ DO - father := cp; - sons := 0; - msglen := 0; - NEWPROCESS(P, wsp, WorkSpaceSize, cor) - END; - cp^.sons := cp^.sons + 1; - Push(newprocess, ready) - END StartProcess; - - PROCEDURE StopProcess; - (* Terminate a Process (itself) *) - VAR aux: ProcessType; - BEGIN - aux := cp^.father; - aux^.sons := aux^.sons - 1; - IF aux^.sons = 0 THEN - Push(aux, ready) - END; - aux := cp; - Push(aux, free); - Pop(ready, cp); - IF cp = NIL THEN - HALT - ELSE - TRANSFER(aux^.cor, cp^.cor) - END - END StopProcess; - - PROCEDURE InitChannel(VAR ch: Channel); - (* Initialize the channel ch *) - BEGIN - Allocate(ch, SIZE(ChannelDescriptor)); - WITH ch^ DO - InitQueue(senders); - owner := NIL; - next := NIL; - guardindex := 0 - END - END InitChannel; - - PROCEDURE GetChannel(ch: Channel); - (* Assign the channel ch to the process that gets it *) - BEGIN - WITH ch^ DO - IF owner # NIL THEN - Message("Channel already has an owner"); - HALT - END; - owner := cp - END - END GetChannel; - - PROCEDURE Send(data: ARRAY OF BYTE; VAR ch: Channel); - (* Send a message with the data to the cvhannel ch *) - VAR m: ByteAddress; - (* aux: ProcessType; *) - i: CARDINAL; - BEGIN - WITH ch^ DO - Push(cp, senders); - Allocate(cp^.msgadr, SIZE(data)); - m := cp^.msgadr; - cp^.msglen := HIGH(data); - FOR i := 0 TO HIGH(data) DO - m^ := data[i]; - m := ADDRESS(m) + 1 - END; - IF guardindex # 0 THEN - owner^.guardindex := guardindex; - CloseChannels(owner); - Push(owner, ready) - END - END; - DoTransfer - END Send; - - PROCEDURE Receive(VAR ch: Channel; VAR dest: ARRAY OF BYTE); - (* Receive a message from the channel ch into the dest variable *) - VAR aux: ProcessType; - m: ByteAddress; - i: CARDINAL; - BEGIN - WITH ch^ DO - IF cp # owner THEN - Message("Only owner of channel can receive from it"); - HALT - END; - IF Sending(ch) THEN - Pop(senders, aux); - m := aux^.msgadr; - FOR i := 0 TO aux^.msglen DO - dest[i] := m^; - m := ADDRESS(m) + 1 - END; - Push(aux, ready); - Push(cp, ready); - CloseChannels(cp) - ELSE - OpenChannel(ch, -1); - DoTransfer; - Pop(senders, aux); - m := aux^.msgadr; - FOR i := 0 TO aux^.msglen DO - dest[i] := m^; - m := ADDRESS(m) + 1 - END; - Push(cp, ready); - Push(aux, ready) - END; - Deallocate(aux^.msgadr, aux^.msglen+1); - DoTransfer - END - END Receive; - - PROCEDURE SELECT(n: CARDINAL); - (* Beginning of a SELECT structure with n guards *) - BEGIN - cp^.guardindex := Uniform(1,n); - cp^.guardno := n; - cp^.guardcount := n - END SELECT; - - PROCEDURE NEXTGUARD(): CARDINAL; - (* Returns an index to the next guard to be evaluated in a SELECT *) - BEGIN - RETURN cp^.guardindex - END NEXTGUARD; - - PROCEDURE GUARD(cond: BOOLEAN; ch: Channel; - VAR dest: ARRAY OF BYTE): BOOLEAN; - (* Evaluates a guard, including reception management *) - (* VAR aux: ProcessType; *) - BEGIN - IF NOT cond THEN - RETURN FALSE - ELSIF ch = NIL THEN - CloseChannels(cp); - cp^.guardindex := 0; - RETURN TRUE - ELSIF Sending(ch) THEN - Receive(ch, dest); - cp^.guardindex := 0; - RETURN TRUE - ELSE - OpenChannel(ch, cp^.guardindex); - RETURN FALSE - END - END GUARD; - - PROCEDURE ENDSELECT(): BOOLEAN; - (* End of a SELECT structure *) - BEGIN - WITH cp^ DO - IF guardindex <= 0 THEN - RETURN TRUE - END; - guardcount := guardcount - 1; - IF guardcount # 0 THEN - guardindex := (guardindex MOD INTEGER(guardno)) + 1 - ELSIF ThereAreOpenChannels() THEN - DoTransfer - ELSE - guardindex := 0 - END - END; - RETURN FALSE - END ENDSELECT; - -BEGIN - InitQueue(free); - InitQueue(ready); - Allocate(cp,SIZE(ProcessDescriptor)); - WITH cp^ DO - sons := 0; - father := NIL - END -END CSP. - diff --git a/lib/ack/libm2/Conversion.mod b/lib/ack/libm2/Conversion.mod deleted file mode 100755 index b64ebc42c..000000000 --- a/lib/ack/libm2/Conversion.mod +++ /dev/null @@ -1,73 +0,0 @@ -(* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*) - -(*$R-*) -IMPLEMENTATION MODULE Conversions; -(* - Module: numeric-to-string conversions - Author: Ceriel J.H. Jacobs - Version: $Header$ -*) - - PROCEDURE ConvertNum(num, len, base: CARDINAL; - neg: BOOLEAN; - VAR str: ARRAY OF CHAR); - VAR i: CARDINAL; - r: CARDINAL; - tmp: ARRAY [0..20] OF CHAR; - BEGIN - i := 0; - REPEAT - r := num MOD base; - num := num DIV base; - IF r <= 9 THEN - tmp[i] := CHR(r + ORD('0')); - ELSE - tmp[i] := CHR(r - 10 + ORD('A')); - END; - INC(i); - UNTIL num = 0; - IF neg THEN - tmp[i] := '-'; - INC(i) - END; - IF len > HIGH(str) + 1 THEN len := HIGH(str) + 1; END; - IF i > HIGH(str) + 1 THEN i := HIGH(str) + 1; END; - r := 0; - WHILE len > i DO str[r] := ' '; INC(r); DEC(len); END; - WHILE i > 0 DO str[r] := tmp[i-1]; DEC(i); INC(r); END; - WHILE r <= HIGH(str) DO - str[r] := 0C; - INC(r); - END; - END ConvertNum; - - PROCEDURE ConvertOctal(num, len: CARDINAL; VAR str: ARRAY OF CHAR); - BEGIN - ConvertNum(num, len, 8, FALSE, str); - END ConvertOctal; - - PROCEDURE ConvertHex(num, len: CARDINAL; VAR str: ARRAY OF CHAR); - BEGIN - ConvertNum(num, len, 16, FALSE, str); - END ConvertHex; - - PROCEDURE ConvertCardinal(num, len: CARDINAL; VAR str: ARRAY OF CHAR); - BEGIN - ConvertNum(num, len, 10, FALSE, str); - END ConvertCardinal; - - PROCEDURE ConvertInteger(num: INTEGER; - len: CARDINAL; - VAR str: ARRAY OF CHAR); - BEGIN - IF (num < 0) AND (num >= -MAX(INTEGER)) THEN - ConvertNum(-num, len, 10, TRUE, str); - ELSE - ConvertNum(CARDINAL(num), len, 10, num < 0, str); - END; - END ConvertInteger; - -END Conversions. diff --git a/lib/ack/libm2/EM.e b/lib/ack/libm2/EM.e deleted file mode 100644 index ae6f42e62..000000000 --- a/lib/ack/libm2/EM.e +++ /dev/null @@ -1,100 +0,0 @@ -# -; -; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. -; See the copyright notice in the ACK home directory, in the file "Copyright". -; -; -; Module: Interface to some EM instructions and data -; Author: Ceriel J.H. Jacobs -; Version: $Header$ -; - mes 2,_EM_WSIZE,_EM_PSIZE - -#define ARG1 0 -#define ARG2 _EM_DSIZE -#define IRES 2*_EM_DSIZE - -; FIF is called with three parameters: -; - address of integer part result (IRES) -; - float two (ARG2) -; - float one (ARG1) -; and returns an _EM_DSIZE-byte floating point number -; Definition: -; PROCEDURE FIF(ARG1, ARG2: LONGREAL; VAR IRES: LONGREAL) : LONGREAL; - - exp $FIF - pro $FIF,0 - lal 0 - loi 2*_EM_DSIZE - fif _EM_DSIZE - lal IRES - loi _EM_PSIZE - sti _EM_DSIZE - ret _EM_DSIZE - end ? - -#define FARG 0 -#define ERES _EM_DSIZE - -; FEF is called with two parameters: -; - address of base 2 exponent result (ERES) -; - floating point number to be split (FARG) -; and returns an _EM_DSIZE-byte floating point number (the mantissa) -; Definition: -; PROCEDURE FEF(FARG: LONGREAL; VAR ERES: integer): LONGREAL; - - exp $FEF - pro $FEF,0 - lal FARG - loi _EM_DSIZE - fef _EM_DSIZE - lal ERES - loi _EM_PSIZE - sti _EM_WSIZE - ret _EM_DSIZE - end ? - -#define TRAP 0 - -; TRP is called with one parameter: -; - trap number (TRAP) -; Definition: -; PROCEDURE TRP(trapno: INTEGER); - - exp $TRP - pro $TRP, 0 - lol TRAP - trp - ret 0 - end ? - -#define PROC 0 - -; SIG is called with one parameter: -; - procedure instance identifier (PROC) -; and returns the old traphandler. - - exa handler - exp $SIG - pro $SIG, 0 - lae handler - loi _EM_PSIZE - lal PROC - loi _EM_PSIZE - lae handler - sti _EM_PSIZE - ret _EM_PSIZE - end ? - - exp $LINO - pro $LINO,0 - loe 0 - ret _EM_WSIZE - end ? - - exp $FILN - pro $FILN,0 - lae 4 - loi _EM_PSIZE - ret _EM_PSIZE - end ? diff --git a/lib/ack/libm2/InOut.mod b/lib/ack/libm2/InOut.mod deleted file mode 100755 index 74e56af52..000000000 --- a/lib/ack/libm2/InOut.mod +++ /dev/null @@ -1,371 +0,0 @@ -(* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*) - -(*$R-*) -IMPLEMENTATION MODULE InOut ; -(* - Module: Wirth's Input/Output module - Author: Ceriel J.H. Jacobs - Version: $Header$ -*) - - IMPORT Streams; - FROM Conversions IMPORT - ConvertCardinal, ConvertInteger, - ConvertOctal, ConvertHex; - FROM Traps IMPORT Message; - - CONST TAB = 11C; - - TYPE numbuf = ARRAY[0..255] OF CHAR; - - VAR unread: BOOLEAN; - unreadch: CHAR; - CurrIn, CurrOut: Streams.Stream; - result: Streams.StreamResult; - - PROCEDURE Read(VAR c : CHAR); - - BEGIN - IF unread THEN - unread := FALSE; - c := unreadch; - Done := TRUE; - ELSE - Streams.Read(CurrIn, c, result); - Done := result = Streams.succeeded; - END; - END Read; - - PROCEDURE UnRead(ch: CHAR); - BEGIN - unread := TRUE; - unreadch := ch; - END UnRead; - - PROCEDURE Write(c: CHAR); - BEGIN - Streams.Write(CurrOut, c, result); - END Write; - - PROCEDURE OpenInput(defext: ARRAY OF CHAR); - VAR namebuf : ARRAY [1..128] OF CHAR; - BEGIN - IF CurrIn # Streams.InputStream THEN - Streams.CloseStream(CurrIn, result); - END; - MakeFileName("Name of input file: ", defext, namebuf); - IF NOT Done THEN RETURN; END; - openinput(namebuf); - END OpenInput; - - PROCEDURE OpenInputFile(filename: ARRAY OF CHAR); - BEGIN - IF CurrIn # Streams.InputStream THEN - Streams.CloseStream(CurrIn, result); - END; - openinput(filename); - END OpenInputFile; - - PROCEDURE openinput(namebuf: ARRAY OF CHAR); - BEGIN - IF (namebuf[0] = '-') AND (namebuf[1] = 0C) THEN - CurrIn := Streams.InputStream; - Done := TRUE; - ELSE - Streams.OpenStream(CurrIn, namebuf, Streams.text, - Streams.reading, result); - Done := result = Streams.succeeded; - END; - END openinput; - - PROCEDURE CloseInput; - BEGIN - IF CurrIn # Streams.InputStream THEN - Streams.CloseStream(CurrIn, result); - END; - CurrIn := Streams.InputStream; - END CloseInput; - - PROCEDURE OpenOutput(defext: ARRAY OF CHAR); - VAR namebuf : ARRAY [1..128] OF CHAR; - BEGIN - IF CurrOut # Streams.OutputStream THEN - Streams.CloseStream(CurrOut, result); - END; - MakeFileName("Name of output file: ", defext, namebuf); - IF NOT Done THEN RETURN; END; - openoutput(namebuf); - END OpenOutput; - - PROCEDURE OpenOutputFile(filename: ARRAY OF CHAR); - BEGIN - IF CurrOut # Streams.OutputStream THEN - Streams.CloseStream(CurrOut, result); - END; - openoutput(filename); - END OpenOutputFile; - - PROCEDURE openoutput(namebuf: ARRAY OF CHAR); - BEGIN - IF (namebuf[1] = '-') AND (namebuf[2] = 0C) THEN - CurrOut := Streams.OutputStream; - Done := TRUE; - ELSE - Streams.OpenStream(CurrOut, namebuf, Streams.text, - Streams.writing, result); - Done := result = Streams.succeeded; - END; - END openoutput; - - PROCEDURE CloseOutput; - BEGIN - IF CurrOut # Streams.OutputStream THEN - Streams.CloseStream(CurrOut, result); - END; - CurrOut := Streams.OutputStream; - END CloseOutput; - - PROCEDURE MakeFileName(prompt, defext : ARRAY OF CHAR; - VAR buf : ARRAY OF CHAR); - VAR i : INTEGER; - j : CARDINAL; - BEGIN - Done := TRUE; - IF Streams.isatty(Streams.InputStream, result) THEN - XWriteString(prompt); - END; - XReadString(buf); - i := 0; - WHILE buf[i] # 0C DO i := i + 1 END; - IF i # 0 THEN - i := i - 1; - IF buf[i] = '.' THEN - FOR j := 0 TO HIGH(defext) DO - i := i + 1; - buf[i] := defext[j]; - END; - buf[i+1] := 0C; - END; - RETURN; - END; - Done := FALSE; - END MakeFileName; - - PROCEDURE ReadInt(VAR integ : INTEGER); - CONST - SAFELIMITDIV10 = MAX(INTEGER) DIV 10; - SAFELIMITREM10 = MAX(INTEGER) MOD 10; - TYPE - itype = [0..31]; - ibuf = ARRAY itype OF CHAR; - VAR - int : INTEGER; - neg : BOOLEAN; - safedigit: [0 .. 9]; - chvalue: CARDINAL; - buf : ibuf; - index : itype; - BEGIN - ReadString(buf); - IF NOT Done THEN - RETURN - END; - index := 0; - IF buf[index] = '-' THEN - neg := TRUE; - INC(index); - ELSIF buf[index] = '+' THEN - neg := FALSE; - INC(index); - ELSE - neg := FALSE - END; - - safedigit := SAFELIMITREM10; - IF neg THEN safedigit := safedigit + 1 END; - int := 0; - WHILE (buf[index] >= '0') & (buf[index] <= '9') DO - chvalue := ORD(buf[index]) - ORD('0'); - IF (int > SAFELIMITDIV10) OR - ( (int = SAFELIMITDIV10) AND - (chvalue > safedigit)) THEN - Message("integer too large"); - HALT; - ELSE - int := 10*int + VAL(INTEGER, chvalue); - INC(index) - END; - END; - IF neg THEN - integ := -int - ELSE - integ := int - END; - IF buf[index] > " " THEN - Message("illegal integer"); - HALT; - END; - Done := TRUE; - END ReadInt; - - PROCEDURE ReadCard(VAR card : CARDINAL); - CONST - SAFELIMITDIV10 = MAX(CARDINAL) DIV 10; - SAFELIMITREM10 = MAX(CARDINAL) MOD 10; - - TYPE - itype = [0..31]; - ibuf = ARRAY itype OF CHAR; - - VAR - int : CARDINAL; - index : itype; - buf : ibuf; - safedigit: [0 .. 9]; - chvalue: CARDINAL; - BEGIN - ReadString(buf); - IF NOT Done THEN RETURN; END; - index := 0; - safedigit := SAFELIMITREM10; - int := 0; - WHILE (buf[index] >= '0') & (buf[index] <= '9') DO - chvalue := ORD(buf[index]) - ORD('0'); - IF (int > SAFELIMITDIV10) OR - ( (int = SAFELIMITDIV10) AND - (chvalue > safedigit)) THEN - Message("cardinal too large"); - HALT; - ELSE - int := 10*int + chvalue; - INC(index); - END; - END; - IF buf[index] > " " THEN - Message("illegal cardinal"); - HALT; - END; - card := int; - Done := TRUE; - END ReadCard; - - PROCEDURE ReadString(VAR s : ARRAY OF CHAR); - TYPE charset = SET OF CHAR; - VAR i : CARDINAL; - ch : CHAR; - - BEGIN - i := 0; - REPEAT - Read(ch); - UNTIL NOT (ch IN charset{' ', TAB, 12C, 15C}); - IF NOT Done THEN - RETURN; - END; - UnRead(ch); - REPEAT - Read(ch); - termCH := ch; - IF i <= HIGH(s) THEN - s[i] := ch; - IF (NOT Done) OR (ch <= " ") THEN - s[i] := 0C; - END; - END; - INC(i); - UNTIL (NOT Done) OR (ch <= " "); - IF Done THEN UnRead(ch); END; - END ReadString; - - PROCEDURE XReadString(VAR s : ARRAY OF CHAR); - VAR j : CARDINAL; - ch : CHAR; - - BEGIN - j := 0; - LOOP - Streams.Read(Streams.InputStream, ch, result); - IF result # Streams.succeeded THEN - EXIT; - END; - IF ch <= " " THEN - s[j] := 0C; - EXIT; - END; - IF j < HIGH(s) THEN - s[j] := ch; - INC(j); - END; - END; - END XReadString; - - PROCEDURE XWriteString(s: ARRAY OF CHAR); - VAR i: CARDINAL; - BEGIN - i := 0; - LOOP - IF (i <= HIGH(s)) AND (s[i] # 0C) THEN - Streams.Write(Streams.OutputStream, s[i], result); - INC(i); - ELSE - EXIT; - END; - END; - END XWriteString; - - PROCEDURE WriteCard(card, width : CARDINAL); - VAR - buf : numbuf; - BEGIN - ConvertCardinal(card, width, buf); - WriteString(buf); - END WriteCard; - - PROCEDURE WriteInt(int : INTEGER; width : CARDINAL); - VAR - buf : numbuf; - BEGIN - ConvertInteger(int, width, buf); - WriteString(buf); - END WriteInt; - - PROCEDURE WriteHex(card, width : CARDINAL); - VAR - buf : numbuf; - BEGIN - ConvertHex(card, width, buf); - WriteString(buf); - END WriteHex; - - PROCEDURE WriteLn; - BEGIN - Write(EOL) - END WriteLn; - - PROCEDURE WriteOct(card, width : CARDINAL); - VAR - buf : numbuf; - BEGIN - ConvertOctal(card, width, buf); - WriteString(buf); - END WriteOct; - - PROCEDURE WriteString(str : ARRAY OF CHAR); - VAR - nbytes : CARDINAL; - BEGIN - nbytes := 0; - WHILE (nbytes <= HIGH(str)) AND (str[nbytes] # 0C) DO - Write(str[nbytes]); - INC(nbytes) - END; - END WriteString; - -BEGIN (* InOut initialization *) - CurrIn := Streams.InputStream; - CurrOut := Streams.OutputStream; - unread := FALSE; -END InOut. diff --git a/lib/ack/libm2/LtoUset.e b/lib/ack/libm2/LtoUset.e deleted file mode 100644 index a724aff44..000000000 --- a/lib/ack/libm2/LtoUset.e +++ /dev/null @@ -1,61 +0,0 @@ -# -; -; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. -; See the copyright notice in the ACK home directory, in the file "Copyright". -; -; -; Module: Compute non-constant set displays -; Author: Ceriel J.H. Jacobs -; Version: $Header$ -; - mes 2,_EM_WSIZE,_EM_PSIZE - - ; LtoUset is called for set displays containing { expr1 .. expr2 }. - ; It has six parameters, of which the caller must pop five: - ; - The set in which bits must be set. - ; - the lower bound of the set type. - ; - The set size in bytes. - ; - The upper bound of set elements, specified by the set-type. - ; - "expr2", the upper bound - ; - "expr1", the lower bound - -#define SETBASE 5*_EM_WSIZE -#define SETLOW 4*_EM_WSIZE -#define SETSIZE 3*_EM_WSIZE -#define USETSIZ 2*_EM_WSIZE -#define LWB _EM_WSIZE -#define UPB 0 - exp $LtoUset - pro $LtoUset,0 - lal SETBASE ; address of initial set - lol SETSIZE - los _EM_WSIZE ; load initial set - lol LWB ; low bound - lol SETLOW - sbu _EM_WSIZE - stl LWB - lol UPB ; high bound - lol SETLOW - sbu _EM_WSIZE - stl UPB -1 - lol LWB - lol UPB - cmu _EM_WSIZE - zgt *2 ; while low <= high - lol LWB - lol SETSIZE - set ? ; create [low] - lol SETSIZE - ior ? ; merge with initial set - lol LWB - loc 1 - adu _EM_WSIZE - stl LWB - bra *1 ; loop back -2 - lal SETBASE - lol SETSIZE - sts _EM_WSIZE ; store result over initial set - ret 0 - end 0 diff --git a/lib/ack/libm2/Makefile.in b/lib/ack/libm2/Makefile.in deleted file mode 100644 index 270c8704f..000000000 --- a/lib/ack/libm2/Makefile.in +++ /dev/null @@ -1,57 +0,0 @@ -# Makefile for lib/ack/libm2. - -CFLAGS="-O -I../h -wo" -M2FLAGS="-O -ws -n" - -LIBRARIES=libm2 - -libm2_FILES=" \ - Arguments.c \ - ArraySort.mod \ - CSP.mod \ - Conversion.mod \ - EM.e \ - InOut.mod \ - LtoUset.e \ - MathLib0.mod \ - Mathlib.mod \ - PascalIO.mod \ - Processes.mod \ - RealConver.mod \ - RealInOut.mod \ - SYSTEM.c \ - Semaphores.mod \ - Storage.mod \ - StrAss.c \ - Streams.mod \ - Strings.mod \ - Termcap.mod \ - Terminal.mod \ - Traps.mod \ - XXTermcap.c \ - absd.c \ - absf.e \ - absi.c \ - absl.c \ - blockmove.c \ - cap.c \ - catch.c \ - confarray.c \ - dvi.c \ - halt.c \ - head_m2.e \ - init.c \ - load.c \ - par_misc.e \ - random.mod \ - rcka.c \ - rcki.c \ - rckil.c \ - rcku.c \ - rckul.c \ - sigtrp.c \ - stackprio.c \ - store.c \ - ucheck.c" - -TYPE=ack diff --git a/lib/ack/libm2/MathLib0.mod b/lib/ack/libm2/MathLib0.mod deleted file mode 100755 index ba40da625..000000000 --- a/lib/ack/libm2/MathLib0.mod +++ /dev/null @@ -1,69 +0,0 @@ -(* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*) - -(*$R-*) -IMPLEMENTATION MODULE MathLib0; -(* - Module: Some mathematical functions - Author: Ceriel J.H. Jacobs - Version: $Header$ -*) - - IMPORT Mathlib; - - PROCEDURE cos(arg: REAL): REAL; - BEGIN - RETURN Mathlib.cos(arg); - END cos; - - PROCEDURE sin(arg: REAL): REAL; - BEGIN - RETURN Mathlib.sin(arg); - END sin; - - PROCEDURE arctan(arg: REAL): REAL; - BEGIN - RETURN Mathlib.arctan(arg); - END arctan; - - PROCEDURE sqrt(arg: REAL): REAL; - BEGIN - RETURN Mathlib.sqrt(arg); - END sqrt; - - PROCEDURE ln(arg: REAL): REAL; - BEGIN - RETURN Mathlib.ln(arg); - END ln; - - PROCEDURE exp(arg: REAL): REAL; - BEGIN - RETURN Mathlib.exp(arg); - END exp; - - PROCEDURE entier(x: REAL): INTEGER; - VAR i: INTEGER; - BEGIN - IF x < 0.0 THEN - i := TRUNC(-x); - IF FLOAT(i) = -x THEN - RETURN -i; - ELSE - RETURN -i -1; - END; - END; - RETURN TRUNC(x); - END entier; - - PROCEDURE real(x: INTEGER): REAL; - BEGIN - IF x < 0 THEN - RETURN - FLOAT(-x); - END; - RETURN FLOAT(x); - END real; - -BEGIN -END MathLib0. diff --git a/lib/ack/libm2/Mathlib.mod b/lib/ack/libm2/Mathlib.mod deleted file mode 100755 index 31899e8d3..000000000 --- a/lib/ack/libm2/Mathlib.mod +++ /dev/null @@ -1,576 +0,0 @@ -(* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*) - -(*$R-*) -IMPLEMENTATION MODULE Mathlib; -(* - Module: Mathematical functions - Author: Ceriel J.H. Jacobs - Version: $Header$ -*) - - FROM EM IMPORT FIF, FEF; - FROM Traps IMPORT Message; - - CONST - OneRadianInDegrees = 57.295779513082320876798155D; - OneDegreeInRadians = 0.017453292519943295769237D; - OneOverSqrt2 = 0.70710678118654752440084436210484904D; - - (* basic functions *) - - PROCEDURE pow(x: REAL; i: INTEGER): REAL; - BEGIN - RETURN SHORT(longpow(LONG(x), i)); - END pow; - - PROCEDURE longpow(x: LONGREAL; i: INTEGER): LONGREAL; - VAR val: LONGREAL; - ri: LONGREAL; - BEGIN - ri := FLOATD(i); - IF x < 0.0D THEN - val := longexp(longln(-x) * ri); - IF ODD(i) THEN RETURN -val; - ELSE RETURN val; - END; - ELSIF x = 0.0D THEN - RETURN 0.0D; - ELSE - RETURN longexp(longln(x) * ri); - END; - END longpow; - - PROCEDURE sqrt(x: REAL): REAL; - BEGIN - RETURN SHORT(longsqrt(LONG(x))); - END sqrt; - - PROCEDURE longsqrt(x: LONGREAL): LONGREAL; - VAR - temp: LONGREAL; - exp, i: INTEGER; - BEGIN - IF x <= 0.0D THEN - IF x < 0.0D THEN - Message("sqrt: negative argument"); - HALT - END; - RETURN 0.0D; - END; - temp := FEF(x,exp); - (* - * NOTE - * this wont work on 1's comp - *) - IF ODD(exp) THEN - temp := 2.0D * temp; - DEC(exp); - END; - temp := 0.5D*(1.0D + temp); - - WHILE exp > 28 DO - temp := temp * 16384.0D; - exp := exp - 28; - END; - WHILE exp < -28 DO - temp := temp / 16384.0D; - exp := exp + 28; - END; - WHILE exp >= 2 DO - temp := temp * 2.0D; - exp := exp - 2; - END; - WHILE exp <= -2 DO - temp := temp / 2.0D; - exp := exp + 2; - END; - FOR i := 0 TO 5 DO - temp := 0.5D*(temp + x/temp); - END; - RETURN temp; - END longsqrt; - - PROCEDURE ldexp(x:LONGREAL; n: INTEGER): LONGREAL; - BEGIN - WHILE n >= 16 DO - x := x * 65536.0D; - n := n - 16; - END; - WHILE n > 0 DO - x := x * 2.0D; - DEC(n); - END; - WHILE n <= -16 DO - x := x / 65536.0D; - n := n + 16; - END; - WHILE n < 0 DO - x := x / 2.0D; - INC(n); - END; - RETURN x; - END ldexp; - - PROCEDURE exp(x: REAL): REAL; - BEGIN - RETURN SHORT(longexp(LONG(x))); - END exp; - - PROCEDURE longexp(x: LONGREAL): LONGREAL; - (* Algorithm and coefficients from: - "Software manual for the elementary functions" - by W.J. Cody and W. Waite, Prentice-Hall, 1980 - *) - CONST - p0 = 0.25000000000000000000D+00; - p1 = 0.75753180159422776666D-02; - p2 = 0.31555192765684646356D-04; - q0 = 0.50000000000000000000D+00; - q1 = 0.56817302698551221787D-01; - q2 = 0.63121894374398503557D-03; - q3 = 0.75104028399870046114D-06; - - VAR - neg: BOOLEAN; - n: INTEGER; - xn, g, x1, x2: LONGREAL; - BEGIN - neg := x < 0.0D; - IF neg THEN - x := -x; - END; - n := TRUNC(x/longln2 + 0.5D); - xn := FLOATD(n); - x1 := FLOATD(TRUNCD(x)); - x2 := x - x1; - g := ((x1 - xn * 0.693359375D)+x2) - xn * (-2.1219444005469058277D-4); - IF neg THEN - g := -g; - n := -n; - END; - xn := g*g; - x := g*((p2*xn+p1)*xn+p0); - INC(n); - RETURN ldexp(0.5D + x/((((q3*xn+q2)*xn+q1)*xn+q0) - x), n); - END longexp; - - PROCEDURE ln(x: REAL): REAL; (* natural log *) - BEGIN - RETURN SHORT(longln(LONG(x))); - END ln; - - PROCEDURE longln(x: LONGREAL): LONGREAL; (* natural log *) - (* Algorithm and coefficients from: - "Software manual for the elementary functions" - by W.J. Cody and W. Waite, Prentice-Hall, 1980 - *) - CONST - p0 = -0.64124943423745581147D+02; - p1 = 0.16383943563021534222D+02; - p2 = -0.78956112887491257267D+00; - q0 = -0.76949932108494879777D+03; - q1 = 0.31203222091924532844D+03; - q2 = -0.35667977739034646171D+02; - q3 = 1.0D; - VAR - exp: INTEGER; - z, znum, zden, w: LONGREAL; - - BEGIN - IF x <= 0.0D THEN - Message("ln: argument <= 0"); - HALT - END; - x := FEF(x, exp); - IF x > OneOverSqrt2 THEN - znum := (x - 0.5D) - 0.5D; - zden := x * 0.5D + 0.5D; - ELSE - znum := x - 0.5D; - zden := znum * 0.5D + 0.5D; - DEC(exp); - END; - z := znum / zden; - w := z * z; - x := z + z * w * (((p2*w+p1)*w+p0)/(((q3*w+q2)*w+q1)*w+q0)); - z := FLOATD(exp); - x := x + z * (-2.121944400546905827679D-4); - RETURN x + z * 0.693359375D; - END longln; - - PROCEDURE log(x: REAL): REAL; (* log with base 10 *) - BEGIN - RETURN SHORT(longlog(LONG(x))); - END log; - - PROCEDURE longlog(x: LONGREAL): LONGREAL; (* log with base 10 *) - BEGIN - RETURN longln(x)/longln10; - END longlog; - - (* trigonometric functions; arguments in radians *) - - PROCEDURE sin(x: REAL): REAL; - BEGIN - RETURN SHORT(longsin(LONG(x))); - END sin; - - PROCEDURE sinus(x: LONGREAL; cosflag: BOOLEAN) : LONGREAL; - (* Algorithm and coefficients from: - "Software manual for the elementary functions" - by W.J. Cody and W. Waite, Prentice-Hall, 1980 - *) - CONST - r0 = -0.16666666666666665052D+00; - r1 = 0.83333333333331650314D-02; - r2 = -0.19841269841201840457D-03; - r3 = 0.27557319210152756119D-05; - r4 = -0.25052106798274584544D-07; - r5 = 0.16058936490371589114D-09; - r6 = -0.76429178068910467734D-12; - r7 = 0.27204790957888846175D-14; - A1 = 3.1416015625D; - A2 = -8.908910206761537356617D-6; - VAR - x1, x2, y : LONGREAL; - neg : BOOLEAN; - BEGIN - IF x < 0.0D THEN - neg := TRUE; - x := -x - ELSE neg := FALSE - END; - IF cosflag THEN - neg := FALSE; - y := longhalfpi + x - ELSE - y := x - END; - y := y / longpi + 0.5D; - - IF FIF(y, 1.0D, y) < 0.0D THEN ; END; - IF FIF(y, 0.5D, x1) # 0.0D THEN neg := NOT neg END; - IF cosflag THEN y := y - 0.5D END; - x2 := FIF(x, 1.0, x1); - x := x1 - y * A1; - x := x + x2; - x := x - y * A2; - - IF x < 0.0D THEN - neg := NOT neg; - x := -x - END; - y := x * x; - x := x + x * y * (((((((r7*y+r6)*y+r5)*y+r4)*y+r3)*y+r2)*y+r1)*y+r0); - IF neg THEN RETURN -x END; - RETURN x; - END sinus; - - PROCEDURE longsin(x: LONGREAL): LONGREAL; - BEGIN - RETURN sinus(x, FALSE); - END longsin; - - PROCEDURE cos(x: REAL): REAL; - BEGIN - RETURN SHORT(longcos(LONG(x))); - END cos; - - PROCEDURE longcos(x: LONGREAL): LONGREAL; - BEGIN - IF x < 0.0D THEN x := -x; END; - RETURN sinus(x, TRUE); - END longcos; - - PROCEDURE tan(x: REAL): REAL; - BEGIN - RETURN SHORT(longtan(LONG(x))); - END tan; - - PROCEDURE longtan(x: LONGREAL): LONGREAL; - (* Algorithm and coefficients from: - "Software manual for the elementary functions" - by W.J. Cody and W. Waite, Prentice-Hall, 1980 - *) - - CONST - p1 = -0.13338350006421960681D+00; - p2 = 0.34248878235890589960D-02; - p3 = -0.17861707342254426711D-04; - - q0 = 1.0D; - q1 = -0.46671683339755294240D+00; - q2 = 0.25663832289440112864D-01; - q3 = -0.31181531907010027307D-03; - q4 = 0.49819433993786512270D-06; - - A1 = 1.57080078125D; - A2 = -4.454455103380768678308D-06; - - VAR y, x1, x2: LONGREAL; - negative: BOOLEAN; - invert: BOOLEAN; - BEGIN - negative := x < 0.0D; - y := x / longhalfpi + 0.5D; - - (* Use extended precision to calculate reduced argument. - Here we used 12 bits of the mantissa for a1. - Also split x in integer part x1 and fraction part x2. - *) - IF FIF(y, 1.0D, y) < 0.0D THEN ; END; - invert := FIF(y, 0.5D, x1) # 0.0D; - x2 := FIF(x, 1.0D, x1); - x := x1 - y * A1; - x := x + x2; - x := x - y * A2; - - y := x * x; - x := x + x * y * ((p3*y+p2)*y+p1); - y := (((q4*y+q3)*y+q2)*y+q1)*y+q0; - IF negative THEN x := -x END; - IF invert THEN RETURN -y/x END; - RETURN x/y; - END longtan; - - PROCEDURE arcsin(x: REAL): REAL; - BEGIN - RETURN SHORT(longarcsin(LONG(x))); - END arcsin; - - PROCEDURE arcsincos(x: LONGREAL; cosfl: BOOLEAN): LONGREAL; - CONST - p0 = -0.27368494524164255994D+02; - p1 = 0.57208227877891731407D+02; - p2 = -0.39688862997540877339D+02; - p3 = 0.10152522233806463645D+02; - p4 = -0.69674573447350646411D+00; - - q0 = -0.16421096714498560795D+03; - q1 = 0.41714430248260412556D+03; - q2 = -0.38186303361750149284D+03; - q3 = 0.15095270841030604719D+03; - q4 = -0.23823859153670238830D+02; - q5 = 1.0D; - VAR - negative : BOOLEAN; - big: BOOLEAN; - g: LONGREAL; - BEGIN - negative := x < 0.0D; - IF negative THEN x := -x; END; - IF x > 0.5D THEN - big := TRUE; - IF x > 1.0D THEN - Message("arcsin or arccos: argument > 1"); - HALT - END; - g := 0.5D - 0.5D * x; - x := -longsqrt(g); - x := x + x; - ELSE - big := FALSE; - g := x * x; - END; - x := x + x * g * - ((((p4*g+p3)*g+p2)*g+p1)*g+p0)/(((((q5*g+q4)*g+q3)*g+q2)*g+q1)*g+q0); - IF cosfl AND NOT negative THEN x := -x END; - IF cosfl = NOT big THEN - x := (x + longquartpi) + longquartpi; - ELSIF cosfl AND negative AND big THEN - x := (x + longhalfpi) + longhalfpi; - END; - IF negative AND NOT cosfl THEN x := -x END; - RETURN x; - END arcsincos; - - PROCEDURE longarcsin(x: LONGREAL): LONGREAL; - BEGIN - RETURN arcsincos(x, FALSE); - END longarcsin; - - PROCEDURE arccos(x: REAL): REAL; - BEGIN - RETURN SHORT(longarccos(LONG(x))); - END arccos; - - PROCEDURE longarccos(x: LONGREAL): LONGREAL; - BEGIN - RETURN arcsincos(x, TRUE); - END longarccos; - - PROCEDURE arctan(x: REAL): REAL; - BEGIN - RETURN SHORT(longarctan(LONG(x))); - END arctan; - - VAR A: ARRAY[0..3] OF LONGREAL; - arctaninit: BOOLEAN; - - PROCEDURE longarctan(x: LONGREAL): LONGREAL; - (* Algorithm and coefficients from: - "Software manual for the elementary functions" - by W.J. Cody and W. Waite, Prentice-Hall, 1980 - *) - CONST - p0 = -0.13688768894191926929D+02; - p1 = -0.20505855195861651981D+02; - p2 = -0.84946240351320683534D+01; - p3 = -0.83758299368150059274D+00; - q0 = 0.41066306682575781263D+02; - q1 = 0.86157349597130242515D+02; - q2 = 0.59578436142597344465D+02; - q3 = 0.15024001160028576121D+02; - q4 = 1.0D; - VAR - g: LONGREAL; - neg: BOOLEAN; - n: INTEGER; - BEGIN - IF NOT arctaninit THEN - arctaninit := TRUE; - A[0] := 0.0D; - A[1] := 0.52359877559829887307710723554658381D; (* p1/6 *) - A[2] := longhalfpi; - A[3] := 1.04719755119659774615421446109316763D; (* pi/3 *) - END; - neg := FALSE; - IF x < 0.0D THEN - neg := TRUE; - x := -x; - END; - IF x > 1.0D THEN - x := 1.0D/x; - n := 2 - ELSE - n := 0 - END; - IF x > 0.26794919243112270647D (* 2-sqrt(3) *) THEN - INC(n); - x := (((0.73205080756887729353D*x-0.5D)-0.5D)+x)/ - (1.73205080756887729353D + x); - END; - g := x*x; - x := x + x * g * (((p3*g+p2)*g+p1)*g+p0) / ((((q4*g+q3)*g+q2)*g+q1)*g+q0); - IF n > 1 THEN x := -x END; - x := x + A[n]; - IF neg THEN RETURN -x; END; - RETURN x; - END longarctan; - - (* hyperbolic functions *) - (* The C math library has better implementations for some of these, but - they depend on some properties of the floating point implementation, - and, for now, we don't want that in the Modula-2 system. - *) - - PROCEDURE sinh(x: REAL): REAL; - BEGIN - RETURN SHORT(longsinh(LONG(x))); - END sinh; - - PROCEDURE longsinh(x: LONGREAL): LONGREAL; - VAR expx: LONGREAL; - BEGIN - expx := longexp(x); - RETURN (expx - 1.0D/expx)/2.0D; - END longsinh; - - PROCEDURE cosh(x: REAL): REAL; - BEGIN - RETURN SHORT(longcosh(LONG(x))); - END cosh; - - PROCEDURE longcosh(x: LONGREAL): LONGREAL; - VAR expx: LONGREAL; - BEGIN - expx := longexp(x); - RETURN (expx + 1.0D/expx)/2.0D; - END longcosh; - - PROCEDURE tanh(x: REAL): REAL; - BEGIN - RETURN SHORT(longtanh(LONG(x))); - END tanh; - - PROCEDURE longtanh(x: LONGREAL): LONGREAL; - VAR expx: LONGREAL; - BEGIN - expx := longexp(x); - RETURN (expx - 1.0D/expx) / (expx + 1.0D/expx); - END longtanh; - - PROCEDURE arcsinh(x: REAL): REAL; - BEGIN - RETURN SHORT(longarcsinh(LONG(x))); - END arcsinh; - - PROCEDURE longarcsinh(x: LONGREAL): LONGREAL; - VAR neg: BOOLEAN; - BEGIN - neg := FALSE; - IF x < 0.0D THEN - neg := TRUE; - x := -x; - END; - x := longln(x + longsqrt(x*x+1.0D)); - IF neg THEN RETURN -x; END; - RETURN x; - END longarcsinh; - - PROCEDURE arccosh(x: REAL): REAL; - BEGIN - RETURN SHORT(longarccosh(LONG(x))); - END arccosh; - - PROCEDURE longarccosh(x: LONGREAL): LONGREAL; - BEGIN - IF x < 1.0D THEN - Message("arccosh: argument < 1"); - HALT - END; - RETURN longln(x + longsqrt(x*x - 1.0D)); - END longarccosh; - - PROCEDURE arctanh(x: REAL): REAL; - BEGIN - RETURN SHORT(longarctanh(LONG(x))); - END arctanh; - - PROCEDURE longarctanh(x: LONGREAL): LONGREAL; - BEGIN - IF (x <= -1.0D) OR (x >= 1.0D) THEN - Message("arctanh: ABS(argument) >= 1"); - HALT - END; - RETURN longln((1.0D + x)/(1.0D - x)) / 2.0D; - END longarctanh; - - (* conversions *) - - PROCEDURE RadianToDegree(x: REAL): REAL; - BEGIN - RETURN SHORT(longRadianToDegree(LONG(x))); - END RadianToDegree; - - PROCEDURE longRadianToDegree(x: LONGREAL): LONGREAL; - BEGIN - RETURN x * OneRadianInDegrees; - END longRadianToDegree; - - PROCEDURE DegreeToRadian(x: REAL): REAL; - BEGIN - RETURN SHORT(longDegreeToRadian(LONG(x))); - END DegreeToRadian; - - PROCEDURE longDegreeToRadian(x: LONGREAL): LONGREAL; - BEGIN - RETURN x * OneDegreeInRadians; - END longDegreeToRadian; - -BEGIN - arctaninit := FALSE; -END Mathlib. diff --git a/lib/ack/libm2/PascalIO.mod b/lib/ack/libm2/PascalIO.mod deleted file mode 100755 index b29049bd3..000000000 --- a/lib/ack/libm2/PascalIO.mod +++ /dev/null @@ -1,437 +0,0 @@ -(* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*) - -(*$R-*) -IMPLEMENTATION MODULE PascalIO; -(* - Module: Pascal-like Input/Output - Author: Ceriel J.H. Jacobs - Version: $Header$ -*) - - FROM Conversions IMPORT - ConvertInteger, ConvertCardinal; - FROM RealConversions IMPORT - LongRealToString, StringToLongReal; - FROM Traps IMPORT Message; - FROM Streams IMPORT Stream, StreamKind, StreamMode, StreamResult, - InputStream, OutputStream, OpenStream, CloseStream, - EndOfStream, Read, Write, StreamBuffering; - FROM Storage IMPORT Allocate; - FROM SYSTEM IMPORT ADR; - - TYPE charset = SET OF CHAR; - btype = (Preading, Pwriting, free); - - CONST spaces = charset{11C, 12C, 13C, 14C, 15C, ' '}; - - TYPE IOstream = RECORD - type: btype; - done, eof : BOOLEAN; - ch: CHAR; - next: Text; - stream: Stream; - END; - Text = POINTER TO IOstream; - numbuf = ARRAY[0..255] OF CHAR; - - VAR ibuf, obuf: IOstream; - head: Text; - result: StreamResult; - - PROCEDURE Reset(VAR InputText: Text; Filename: ARRAY OF CHAR); - BEGIN - doclose(InputText); - getstruct(InputText); - WITH InputText^ DO - OpenStream(stream, Filename, text, reading, result); - IF result # succeeded THEN - Message("could not open input file"); - HALT; - END; - type := Preading; - done := FALSE; - eof := FALSE; - END; - END Reset; - - PROCEDURE Rewrite(VAR OutputText: Text; Filename: ARRAY OF CHAR); - BEGIN - doclose(OutputText); - getstruct(OutputText); - WITH OutputText^ DO - OpenStream(stream, Filename, text, writing, result); - IF result # succeeded THEN - Message("could not open output file"); - HALT; - END; - type := Pwriting; - END; - END Rewrite; - - PROCEDURE CloseOutput(); - VAR p: Text; - BEGIN - p := head; - WHILE p # NIL DO - doclose(p); - p := p^.next; - END; - END CloseOutput; - - PROCEDURE doclose(Xtext: Text); - BEGIN - IF Xtext # Notext THEN - WITH Xtext^ DO - IF type # free THEN - CloseStream(stream, result); - type := free; - END; - END; - END; - END doclose; - - PROCEDURE getstruct(VAR Xtext: Text); - BEGIN - Xtext := head; - WHILE (Xtext # NIL) AND (Xtext^.type # free) DO - Xtext := Xtext^.next; - END; - IF Xtext = NIL THEN - Allocate(Xtext,SIZE(IOstream)); - Xtext^.next := head; - head := Xtext; - END; - END getstruct; - - PROCEDURE Error(tp: btype); - BEGIN - IF tp = Preading THEN - Message("input text expected"); - ELSE - Message("output text expected"); - END; - HALT; - END Error; - - PROCEDURE ReadChar(InputText: Text; VAR ch : CHAR); - BEGIN - ch := NextChar(InputText); - IF InputText^.eof THEN - Message("unexpected EOF"); - HALT; - END; - InputText^.done := FALSE; - END ReadChar; - - PROCEDURE NextChar(InputText: Text): CHAR; - BEGIN - WITH InputText^ DO - IF type # Preading THEN Error(Preading); END; - IF NOT done THEN - IF EndOfStream(stream, result) THEN - eof := TRUE; - ch := 0C; - ELSE - Read(stream, ch, result); - done := TRUE; - END; - END; - RETURN ch; - END; - END NextChar; - - PROCEDURE Get(InputText: Text); - VAR dummy: CHAR; - BEGIN - ReadChar(InputText, dummy); - END Get; - - PROCEDURE Eoln(InputText: Text): BOOLEAN; - BEGIN - RETURN NextChar(InputText) = 12C; - END Eoln; - - PROCEDURE Eof(InputText: Text): BOOLEAN; - BEGIN - RETURN (NextChar(InputText) = 0C) AND InputText^.eof; - END Eof; - - PROCEDURE ReadLn(InputText: Text); - VAR ch: CHAR; - BEGIN - REPEAT - ReadChar(InputText, ch) - UNTIL ch = 12C; - END ReadLn; - - PROCEDURE WriteChar(OutputText: Text; char: CHAR); - BEGIN - WITH OutputText^ DO - IF type # Pwriting THEN Error(Pwriting); END; - Write(stream, char, result); - END; - END WriteChar; - - PROCEDURE WriteLn(OutputText: Text); - BEGIN - WriteChar(OutputText, 12C); - END WriteLn; - - PROCEDURE Page(OutputText: Text); - BEGIN - WriteChar(OutputText, 14C); - END Page; - - PROCEDURE ReadInteger(InputText: Text; VAR int : INTEGER); - CONST - SAFELIMITDIV10 = MAX(INTEGER) DIV 10; - SAFELIMITREM10 = MAX(INTEGER) MOD 10; - VAR - neg : BOOLEAN; - safedigit: CARDINAL; - ch: CHAR; - chvalue: CARDINAL; - BEGIN - WHILE NextChar(InputText) IN spaces DO - Get(InputText); - END; - ch := NextChar(InputText); - IF ch = '-' THEN - Get(InputText); - ch := NextChar(InputText); - neg := TRUE; - ELSIF ch = '+' THEN - Get(InputText); - ch := NextChar(InputText); - neg := FALSE; - ELSE - neg := FALSE - END; - - safedigit := SAFELIMITREM10; - IF neg THEN safedigit := safedigit + 1 END; - int := 0; - IF (ch >= '0') AND (ch <= '9') THEN - WHILE (ch >= '0') & (ch <= '9') DO - chvalue := ORD(ch) - ORD('0'); - IF (int < -SAFELIMITDIV10) OR - ( (int = -SAFELIMITDIV10) AND - (chvalue > safedigit)) THEN - Message("integer too large"); - HALT; - ELSE - int := 10*int - VAL(INTEGER, chvalue); - Get(InputText); - ch := NextChar(InputText); - END; - END; - IF NOT neg THEN - int := -int - END; - ELSE - Message("integer expected"); - HALT; - END; - END ReadInteger; - - PROCEDURE ReadCardinal(InputText: Text; VAR card : CARDINAL); - CONST - SAFELIMITDIV10 = MAX(CARDINAL) DIV 10; - SAFELIMITREM10 = MAX(CARDINAL) MOD 10; - - VAR - ch : CHAR; - safedigit: CARDINAL; - chvalue: CARDINAL; - BEGIN - WHILE NextChar(InputText) IN spaces DO - Get(InputText); - END; - ch := NextChar(InputText); - safedigit := SAFELIMITREM10; - card := 0; - IF (ch >= '0') AND (ch <= '9') THEN - WHILE (ch >= '0') & (ch <= '9') DO - chvalue := ORD(ch) - ORD('0'); - IF (card > SAFELIMITDIV10) OR - ( (card = SAFELIMITDIV10) AND - (chvalue > safedigit)) THEN - Message("cardinal too large"); - HALT; - ELSE - card := 10*card + chvalue; - Get(InputText); - ch := NextChar(InputText); - END; - END; - ELSE - Message("cardinal expected"); - HALT; - END; - END ReadCardinal; - - PROCEDURE ReadReal(InputText: Text; VAR real: REAL); - VAR x1: LONGREAL; - BEGIN - ReadLongReal(InputText, x1); - real := x1 - END ReadReal; - - PROCEDURE ReadLongReal(InputText: Text; VAR real: LONGREAL); - VAR - buf: numbuf; - ch: CHAR; - ok: BOOLEAN; - index: INTEGER; - - PROCEDURE inch(): CHAR; - BEGIN - buf[index] := ch; - INC(index); - Get(InputText); - RETURN NextChar(InputText); - END inch; - - BEGIN - index := 0; - ok := TRUE; - WHILE NextChar(InputText) IN spaces DO - Get(InputText); - END; - ch := NextChar(InputText); - IF (ch ='+') OR (ch = '-') THEN - ch := inch(); - END; - IF (ch >= '0') AND (ch <= '9') THEN - WHILE (ch >= '0') AND (ch <= '9') DO - ch := inch(); - END; - IF (ch = '.') THEN - ch := inch(); - IF (ch >= '0') AND (ch <= '9') THEN - WHILE (ch >= '0') AND (ch <= '9') DO - ch := inch(); - END; - ELSE - ok := FALSE; - END; - END; - IF ok AND (ch = 'E') THEN - ch := inch(); - IF (ch ='+') OR (ch = '-') THEN - ch := inch(); - END; - IF (ch >= '0') AND (ch <= '9') THEN - WHILE (ch >= '0') AND (ch <= '9') DO - ch := inch(); - END; - ELSE - ok := FALSE; - END; - END; - ELSE - ok := FALSE; - END; - IF ok THEN - buf[index] := 0C; - StringToLongReal(buf, real, ok); - END; - IF NOT ok THEN - Message("Illegal real"); - HALT; - END; - END ReadLongReal; - - PROCEDURE WriteCardinal(OutputText: Text; card: CARDINAL; width: CARDINAL); - VAR - buf : numbuf; - BEGIN - ConvertCardinal(card, 1, buf); - WriteString(OutputText, buf, width); - END WriteCardinal; - - PROCEDURE WriteInteger(OutputText: Text; int: INTEGER; width: CARDINAL); - VAR - buf : numbuf; - BEGIN - ConvertInteger(int, 1, buf); - WriteString(OutputText, buf, width); - END WriteInteger; - - PROCEDURE WriteBoolean(OutputText: Text; bool: BOOLEAN; width: CARDINAL); - BEGIN - IF bool THEN - WriteString(OutputText, " TRUE", width); - ELSE - WriteString(OutputText, "FALSE", width); - END; - END WriteBoolean; - - PROCEDURE WriteReal(OutputText: Text; real: REAL; width, nfrac: CARDINAL); - BEGIN - WriteLongReal(OutputText, LONG(real), width, nfrac) - END WriteReal; - - PROCEDURE WriteLongReal(OutputText: Text; real: LONGREAL; width, nfrac: CARDINAL); - VAR - buf: numbuf; - ok: BOOLEAN; - digits: INTEGER; - BEGIN - IF width > SIZE(buf) THEN - width := SIZE(buf); - END; - IF nfrac > 0 THEN - LongRealToString(real, width, nfrac, buf, ok); - ELSE - IF width < 9 THEN width := 9; END; - IF real < 0.0D THEN - digits := 7 - INTEGER(width); - ELSE - digits := 6 - INTEGER(width); - END; - LongRealToString(real, width, digits, buf, ok); - END; - WriteString(OutputText, buf, 0); - END WriteLongReal; - - PROCEDURE WriteString(OutputText: Text; str: ARRAY OF CHAR; width: CARDINAL); - VAR index: CARDINAL; - BEGIN - index := 0; - WHILE (index <= HIGH(str)) AND (str[index] # Eos) DO - INC(index); - END; - WHILE index < width DO - WriteChar(OutputText, " "); - INC(index); - END; - index := 0; - WHILE (index <= HIGH(str)) AND (str[index] # Eos) DO - WriteChar(OutputText, str[index]); - INC(index); - END; - END WriteString; - -BEGIN (* PascalIO initialization *) - WITH ibuf DO - stream := InputStream; - eof := FALSE; - type := Preading; - done := FALSE; - END; - WITH obuf DO - stream := OutputStream; - eof := FALSE; - type := Pwriting; - END; - Notext := NIL; - Input := ADR(ibuf); - Output := ADR(obuf); - Input^.next := Output; - Output^.next := NIL; - head := Input; -END PascalIO. diff --git a/lib/ack/libm2/Processes.mod b/lib/ack/libm2/Processes.mod deleted file mode 100755 index 152c7e640..000000000 --- a/lib/ack/libm2/Processes.mod +++ /dev/null @@ -1,101 +0,0 @@ -(*$R-*) -IMPLEMENTATION MODULE Processes [1]; -(* - Module: Processes - From: "Programming in Modula-2", 3rd, corrected edition, by N. Wirth - Version: $Header$ -*) - - FROM SYSTEM IMPORT ADDRESS, TSIZE, NEWPROCESS, TRANSFER; - FROM Storage IMPORT Allocate; - FROM Traps IMPORT Message; - - TYPE SIGNAL = POINTER TO ProcessDescriptor; - - ProcessDescriptor = - RECORD next: SIGNAL; (* ring *) - queue: SIGNAL; (* queue of waiting processes *) - cor: ADDRESS; - ready: BOOLEAN; - END; - - VAR cp: SIGNAL; (* current process *) - - PROCEDURE StartProcess(P: PROC; n: CARDINAL); - VAR s0: SIGNAL; - wsp: ADDRESS; - BEGIN - s0 := cp; - Allocate(wsp, n); - Allocate(cp, TSIZE(ProcessDescriptor)); - WITH cp^ DO - next := s0^.next; - s0^.next := cp; - ready := TRUE; - queue := NIL - END; - NEWPROCESS(P, wsp, n, cp^.cor); - TRANSFER(s0^.cor, cp^.cor); - END StartProcess; - - PROCEDURE SEND(VAR s: SIGNAL); - VAR s0: SIGNAL; - BEGIN - IF s # NIL THEN - s0 := cp; - cp := s; - WITH cp^ DO - s := queue; - ready := TRUE; - queue := NIL - END; - TRANSFER(s0^.cor, cp^.cor); - END - END SEND; - - PROCEDURE WAIT(VAR s: SIGNAL); - VAR s0, s1: SIGNAL; - BEGIN - (* insert cp in queue s *) - IF s = NIL THEN - s := cp - ELSE - s0 := s; - s1 := s0^.queue; - WHILE s1 # NIL DO - s0 := s1; - s1 := s0^.queue - END; - s0^.queue := cp - END; - s0 := cp; - REPEAT - cp := cp^.next - UNTIL cp^.ready; - IF cp = s0 THEN - (* deadlock *) - Message("deadlock"); - HALT - END; - s0^.ready := FALSE; - TRANSFER(s0^.cor, cp^.cor) - END WAIT; - - PROCEDURE Awaited(s: SIGNAL): BOOLEAN; - BEGIN - RETURN s # NIL - END Awaited; - - PROCEDURE Init(VAR s: SIGNAL); - BEGIN - s := NIL - END Init; - -BEGIN - Allocate(cp, TSIZE(ProcessDescriptor)); - WITH cp^ DO - next := cp; - ready := TRUE; - queue := NIL - END -END Processes. diff --git a/lib/ack/libm2/RealConver.mod b/lib/ack/libm2/RealConver.mod deleted file mode 100755 index c663f5ed0..000000000 --- a/lib/ack/libm2/RealConver.mod +++ /dev/null @@ -1,337 +0,0 @@ -(* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*) - -(*$R-*) -IMPLEMENTATION MODULE RealConversions; -(* - Module: string-to-real and real-to-string conversions - Author: Ceriel J.H. Jacobs - Version: $Header$ -*) - - - PROCEDURE RealToString(arg: REAL; - width, digits: INTEGER; - VAR str: ARRAY OF CHAR; - VAR ok: BOOLEAN); - BEGIN - LongRealToString(LONG(arg), width, digits, str, ok); - END RealToString; - - TYPE - Powers = RECORD - pval: LONGREAL; - rpval: LONGREAL; - exp: INTEGER - END; - - VAR Powers10: ARRAY[1..6] OF Powers; - - PROCEDURE LongRealToString(arg: LONGREAL; - width, digits: INTEGER; - VAR str: ARRAY OF CHAR; - VAR ok: BOOLEAN); - VAR pointpos: INTEGER; - i: CARDINAL; - ecvtflag: BOOLEAN; - r: LONGREAL; - ind1, ind2 : CARDINAL; - sign: BOOLEAN; - ndigits: CARDINAL; - - BEGIN - r := arg; - IF digits < 0 THEN - ecvtflag := TRUE; - ndigits := -digits; - ELSE - ecvtflag := FALSE; - ndigits := digits; - END; - IF (HIGH(str) < ndigits + 3) THEN - str[0] := 0C; ok := FALSE; RETURN - END; - pointpos := 0; - sign := r < 0.0D; - IF sign THEN r := -r END; - ok := TRUE; - IF NOT (r / 10.0D < r) THEN - (* assume Nan or Infinity *) - r := 0.0D; - ok := FALSE; - END; - IF r # 0.0D THEN - IF r >= 10.0D THEN - FOR i := 1 TO 6 DO - WITH Powers10[i] DO - WHILE r >= pval DO - r := r * rpval; - INC(pointpos, exp) - END; - END; - END; - END; - IF r < 1.0D THEN - FOR i := 1 TO 6 DO - WITH Powers10[i] DO - WHILE r*pval < 10.0D DO - r := r * pval; - DEC(pointpos, exp) - END; - END; - END; - END; - (* Now, we have r in [1.0, 10.0) *) - INC(pointpos); - END; - ind1 := 0; - ind2 := ndigits+1; - - IF NOT ecvtflag THEN - IF INTEGER(ind2) + pointpos <= 0 THEN - ind2 := 1; - ELSE - ind2 := INTEGER(ind2) + pointpos - END; - END; - IF ind2 > HIGH(str) THEN - ok := FALSE; - str[0] := 0C; - RETURN; - END; - WHILE ind1 < ind2 DO - str[ind1] := CHR(TRUNC(r)+ORD('0')); - r := 10.0D * (r - FLOATD(TRUNC(r))); - INC(ind1); - END; - IF ind2 > 0 THEN - DEC(ind2); - ind1 := ind2; - str[ind2] := CHR(ORD(str[ind2])+5); - WHILE str[ind2] > '9' DO - str[ind2] := '0'; - IF ind2 > 0 THEN - DEC(ind2); - str[ind2] := CHR(ORD(str[ind2])+1); - ELSE - str[ind2] := '1'; - INC(pointpos); - IF NOT ecvtflag THEN - IF ind1 > 0 THEN str[ind1] := '0'; END; - INC(ind1); - END; - END; - END; - IF (NOT ecvtflag) AND (ind1 = 0) THEN - str[0] := CHR(ORD(str[0])-5); - INC(ind1); - END; - END; - IF ecvtflag THEN - FOR i := ind1 TO 2 BY -1 DO - str[i] := str[i-1]; - END; - str[1] := '.'; - INC(ind1); - IF sign THEN - FOR i := ind1 TO 1 BY -1 DO - str[i] := str[i-1]; - END; - INC(ind1); - str[0] := '-'; - END; - IF (ind1 + 4) > HIGH(str) THEN - str[0] := 0C; - ok := FALSE; - RETURN; - END; - str[ind1] := 'E'; INC(ind1); - IF arg # 0.0D THEN DEC(pointpos); END; - IF pointpos < 0 THEN - pointpos := -pointpos; - str[ind1] := '-'; - ELSE - str[ind1] := '+'; - END; - INC(ind1); - str[ind1] := CHR(ORD('0') + CARDINAL(pointpos DIV 100)); - pointpos := pointpos MOD 100; - INC(ind1); - str[ind1] := CHR(ORD('0') + CARDINAL(pointpos DIV 10)); - INC(ind1); - str[ind1] := CHR(ORD('0') + CARDINAL(pointpos MOD 10)); - ELSE - IF pointpos <= 0 THEN - FOR i := ind1 TO 1 BY -1 DO - str[i+CARDINAL(-pointpos)] := str[i-1]; - END; - FOR i := 0 TO CARDINAL(-pointpos) DO - str[i] := '0'; - END; - ind1 := ind1 + CARDINAL(1 - pointpos); - pointpos := 1; - END; - FOR i := ind1 TO CARDINAL(pointpos+1) BY -1 DO - str[i] := str[i-1]; - END; - IF ndigits = 0 THEN - str[pointpos] := 0C; - ind1 := pointpos - 1; - ELSE - str[pointpos] := '.'; - IF INTEGER(ind1) > pointpos+INTEGER(ndigits) THEN - ind1 := pointpos+INTEGER(ndigits); - END; - str[pointpos+INTEGER(ndigits)+1] := 0C; - END; - IF sign THEN - FOR i := ind1 TO 0 BY -1 DO - str[i+1] := str[i]; - END; - str[0] := '-'; - INC(ind1); - END; - END; - IF (ind1+1) <= HIGH(str) THEN str[ind1+1] := 0C; END; - IF ind1 >= CARDINAL(width) THEN - ok := FALSE; - RETURN; - END; - IF width > 0 THEN - DEC(width); - END; - IF (width > 0) AND (ind1 < CARDINAL(width)) THEN - FOR i := ind1 TO 0 BY -1 DO - str[i + CARDINAL(width) - ind1] := str[i]; - END; - FOR i := 0 TO CARDINAL(width)-(ind1+1) DO - str[i] := ' '; - END; - ind1 := CARDINAL(width); - IF (ind1+1) <= HIGH(str) THEN - FOR ind1 := ind1+1 TO HIGH(str) DO - str[ind1] := 0C; - END; - END; - END; - - END LongRealToString; - - - PROCEDURE StringToReal(str: ARRAY OF CHAR; - VAR r: REAL; VAR ok: BOOLEAN); - VAR x: LONGREAL; - BEGIN - StringToLongReal(str, x, ok); - IF ok THEN - r := x; - END; - END StringToReal; - - PROCEDURE StringToLongReal(str: ARRAY OF CHAR; - VAR r: LONGREAL; VAR ok: BOOLEAN); - CONST BIG = 1.0D17; - TYPE SETOFCHAR = SET OF CHAR; - VAR pow10 : INTEGER; - i : INTEGER; - e : LONGREAL; - ch : CHAR; - signed: BOOLEAN; - signedexp: BOOLEAN; - iB: CARDINAL; - - BEGIN - r := 0.0D; - pow10 := 0; - iB := 0; - ok := TRUE; - signed := FALSE; - WHILE (str[iB] = ' ') OR (str[iB] = CHR(9)) DO - INC(iB); - IF iB > HIGH(str) THEN - ok := FALSE; - RETURN; - END; - END; - IF str[iB] = '-' THEN signed := TRUE; INC(iB) - ELSIF str[iB] = '+' THEN INC(iB) - END; - ch := str[iB]; INC(iB); - IF NOT (ch IN SETOFCHAR{'0'..'9'}) THEN ok := FALSE; RETURN END; - REPEAT - IF r>BIG THEN INC(pow10) ELSE r:= 10.0D*r+FLOATD(ORD(ch)-ORD('0')) END; - IF iB <= HIGH(str) THEN - ch := str[iB]; INC(iB); - END; - UNTIL (iB > HIGH(str)) OR NOT (ch IN SETOFCHAR{'0'..'9'}); - IF (ch = '.') AND (iB <= HIGH(str)) THEN - ch := str[iB]; INC(iB); - IF NOT (ch IN SETOFCHAR{'0'..'9'}) THEN ok := FALSE; RETURN END; - REPEAT - IF r < BIG THEN - r := 10.0D * r + FLOATD(ORD(ch)-ORD('0')); - DEC(pow10); - END; - IF iB <= HIGH(str) THEN - ch := str[iB]; INC(iB); - END; - UNTIL (iB > HIGH(str)) OR NOT (ch IN SETOFCHAR{'0'..'9'}); - END; - IF (ch = 'E') THEN - IF iB > HIGH(str) THEN - ok := FALSE; - RETURN; - ELSE - ch := str[iB]; INC(iB); - END; - i := 0; - signedexp := FALSE; - IF (ch = '-') OR (ch = '+') THEN - signedexp := ch = '-'; - IF iB > HIGH(str) THEN - ok := FALSE; - RETURN; - ELSE - ch := str[iB]; INC(iB); - END; - END; - IF NOT (ch IN SETOFCHAR{'0'..'9'}) THEN ok := FALSE; RETURN END; - REPEAT - i := i*10 + INTEGER(ORD(ch) - ORD('0')); - IF iB <= HIGH(str) THEN - ch := str[iB]; INC(iB); - END; - UNTIL (iB > HIGH(str)) OR NOT (ch IN SETOFCHAR{'0'..'9'}); - IF signedexp THEN i := -i END; - pow10 := pow10 + i; - END; - IF pow10 < 0 THEN i := -pow10; ELSE i := pow10; END; - e := 1.0D; - DEC(i); - WHILE i >= 10 DO - e := e * 10000000000.0D; - DEC(i,10); - END; - WHILE i >= 0 DO - e := e * 10.0D; - DEC(i) - END; - IF pow10<0 THEN - r := r / e; - ELSE - r := r * e; - END; - IF signed THEN r := -r; END; - IF (iB <= HIGH(str)) AND (ORD(ch) > ORD(' ')) THEN ok := FALSE; END - END StringToLongReal; - -BEGIN - WITH Powers10[1] DO pval := 1.0D32; rpval := 1.0D-32; exp := 32 END; - WITH Powers10[2] DO pval := 1.0D16; rpval := 1.0D-16; exp := 16 END; - WITH Powers10[3] DO pval := 1.0D8; rpval := 1.0D-8; exp := 8 END; - WITH Powers10[4] DO pval := 1.0D4; rpval := 1.0D-4; exp := 4 END; - WITH Powers10[5] DO pval := 1.0D2; rpval := 1.0D-2; exp := 2 END; - WITH Powers10[6] DO pval := 1.0D1; rpval := 1.0D-1; exp := 1 END; -END RealConversions. diff --git a/lib/ack/libm2/RealInOut.mod b/lib/ack/libm2/RealInOut.mod deleted file mode 100755 index e2565cc2f..000000000 --- a/lib/ack/libm2/RealInOut.mod +++ /dev/null @@ -1,97 +0,0 @@ -(* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*) - -(*$R-*) -IMPLEMENTATION MODULE RealInOut; -(* - Module: InOut for REAL numbers - Author: Ceriel J.H. Jacobs - Version: $Header$ -*) - - FROM InOut IMPORT ReadString, WriteString, WriteOct; - FROM Traps IMPORT Message; - FROM SYSTEM IMPORT WORD; - FROM RealConversions IMPORT - LongRealToString, StringToLongReal; - - CONST MAXNDIG = 32; - MAXWIDTH = MAXNDIG+7; - TYPE RBUF = ARRAY [0..MAXWIDTH+1] OF CHAR; - - PROCEDURE WriteReal(arg: REAL; ndigits: CARDINAL); - BEGIN - WriteLongReal(LONG(arg), ndigits) - END WriteReal; - - PROCEDURE WriteLongReal(arg: LONGREAL; ndigits: CARDINAL); - VAR buf : RBUF; - ok : BOOLEAN; - - BEGIN - IF ndigits > MAXWIDTH THEN ndigits := MAXWIDTH; END; - IF ndigits < 10 THEN ndigits := 10; END; - LongRealToString(arg, ndigits, -INTEGER(ndigits - 7), buf, ok); - WriteString(buf); - END WriteLongReal; - - PROCEDURE WriteFixPt(arg: REAL; n, k: CARDINAL); - BEGIN - WriteLongFixPt(LONG(arg), n, k) - END WriteFixPt; - - PROCEDURE WriteLongFixPt(arg: LONGREAL; n, k: CARDINAL); - VAR buf: RBUF; - ok : BOOLEAN; - - BEGIN - IF n > MAXWIDTH THEN n := MAXWIDTH END; - LongRealToString(arg, n, k, buf, ok); - WriteString(buf); - END WriteLongFixPt; - - PROCEDURE ReadReal(VAR x: REAL); - VAR x1: LONGREAL; - BEGIN - ReadLongReal(x1); - x := x1 - END ReadReal; - - PROCEDURE ReadLongReal(VAR x: LONGREAL); - VAR Buf: ARRAY[0..512] OF CHAR; - ok: BOOLEAN; - - BEGIN - ReadString(Buf); - StringToLongReal(Buf, x, ok); - IF NOT ok THEN - Message("real expected"); - HALT; - END; - Done := TRUE; - END ReadLongReal; - - PROCEDURE wroct(x: ARRAY OF WORD); - VAR i: CARDINAL; - BEGIN - FOR i := 0 TO HIGH(x) DO - WriteOct(CARDINAL(x[i]), 0); - WriteString(" "); - END; - END wroct; - - PROCEDURE WriteRealOct(x: REAL); - BEGIN - wroct(x); - END WriteRealOct; - - PROCEDURE WriteLongRealOct(x: LONGREAL); - BEGIN - wroct(x); - END WriteLongRealOct; - -BEGIN - Done := FALSE; -END RealInOut. diff --git a/lib/ack/libm2/SYSTEM.c b/lib/ack/libm2/SYSTEM.c deleted file mode 100644 index 51def5596..000000000 --- a/lib/ack/libm2/SYSTEM.c +++ /dev/null @@ -1,115 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* - Module: SYSTEM - Author: Ceriel J.H. Jacobs - Version: $Header$ -*/ - -/* - An implementation of the Modula-2 NEWPROCESS and TRANSFER facilities - using the topsize, topsave, and topload facilities. - For each coroutine, a proc structure is built. For the main routine, - a static space is declared to save its stack. For the other coroutines, - the user specifies this space. -*/ - -#include - -#define MAXMAIN 2048 - -struct proc { - unsigned size; /* size of saved stackframe(s) */ - int (*proc)(); /* address of coroutine procedure */ - char *brk; /* stack break of this coroutine */ -}; - -extern unsigned topsize(); - -static struct proc mainproc[MAXMAIN/sizeof(struct proc) + 1]; - -static struct proc *curproc = 0;/* current coroutine */ -extern char *MainLB; /* stack break of main routine */ - -_SYSTEM__NEWPROCESS(p, a, n, p1) - int (*p)(); /* coroutine procedure */ - struct proc *a; /* pointer to area for saved stack-frame */ - unsigned n; /* size of this area */ - struct proc **p1; /* where to leave coroutine descriptor, - in this implementation the address of - the area for saved stack-frame(s) */ -{ - /* This procedure creates a new coroutine, but does not - transfer control to it. The routine "topsize" will compute the - stack break, which will be the local base of this routine. - Notice that we can do this because we do not need the stack - above this point for this coroutine. In Modula-2, coroutines - must be level 0 procedures without parameters. - */ - char *brk = 0; - unsigned sz = topsize(&brk); - - if (sz + sizeof(struct proc) > n) { - /* not enough space */ - TRP(M2_TOOLARGE); - } - a->size = n; - a->proc = p; - a->brk = brk; - *p1 = a; - if (topsave(brk, a+1)) - /* stack frame saved; now just return */ - ; - else { - /* We get here through the first transfer to the coroutine - created above. - This also means that curproc is now set to this coroutine. - We cannot trust the parameters anymore. - Just call the coroutine procedure. - */ - (*(curproc->proc))(); - _cleanup(); - _exit(0); - } -} - -_SYSTEM__TRANSFER(a, b) - struct proc **a, **b; -{ - /* transfer from one coroutine to another, saving the current - descriptor in the space indicated by "a", and transfering to - the coroutine in descriptor "b". - */ - unsigned size; - - if (! curproc) { - /* the current coroutine is the main process; - initialize a coroutine descriptor for it ... - */ - mainproc[0].brk = MainLB; - mainproc[0].size = sizeof(mainproc); - curproc = &mainproc[0]; - } - *a = curproc; /* save current descriptor in "a" */ - if (*b == curproc) { - /* transfer to itself is a no-op */ - return; - } - size = topsize(&(curproc->brk)); - if (size + sizeof(struct proc) > curproc->size) { - TRP(M2_TOOLARGE); - } - if (topsave(curproc->brk, curproc+1)) { - /* stack top saved. Now restore context of target - coroutine - */ - curproc = *b; - topload(curproc+1); - /* we never get here ... */ - } - /* but we do get here, when a transfer is done to the coroutine in "a". - */ -} diff --git a/lib/ack/libm2/Semaphores.mod b/lib/ack/libm2/Semaphores.mod deleted file mode 100755 index d6c056649..000000000 --- a/lib/ack/libm2/Semaphores.mod +++ /dev/null @@ -1,118 +0,0 @@ -(* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*) - -(*$R-*) -IMPLEMENTATION MODULE Semaphores [1]; -(* - Module: Processes with semaphores - Author: Ceriel J.H. Jacobs - Version: $Header$ - - Quasi-concurrency implementation -*) - - FROM SYSTEM IMPORT ADDRESS, NEWPROCESS, TRANSFER; - FROM Storage IMPORT Allocate; - FROM random IMPORT Uniform; - FROM Traps IMPORT Message; - - TYPE Sema = POINTER TO Semaphore; - Processes = POINTER TO Process; - Semaphore = - RECORD - level: CARDINAL; - END; - Process = - RECORD next: Processes; - proc: ADDRESS; - waiting: Sema; - END; - - VAR cp: Processes; (* current process *) - - PROCEDURE StartProcess(P: PROC; n: CARDINAL); - VAR s0: Processes; - wsp: ADDRESS; - BEGIN - s0 := cp; - Allocate(wsp, n); - Allocate(cp, SIZE(Process)); - WITH cp^ DO - next := s0^.next; - s0^.next := cp; - waiting := NIL; - END; - NEWPROCESS(P, wsp, n, cp^.proc); - TRANSFER(s0^.proc, cp^.proc); - END StartProcess; - - PROCEDURE Up(VAR s: Sema); - BEGIN - s^.level := s^.level + 1; - ReSchedule; - END Up; - - PROCEDURE Down(VAR s: Sema); - BEGIN - IF s^.level = 0 THEN - cp^.waiting := s; - ELSE - s^.level := s^.level - 1; - END; - ReSchedule; - END Down; - - PROCEDURE NewSema(n: CARDINAL): Sema; - VAR s: Sema; - BEGIN - Allocate(s, SIZE(Semaphore)); - s^.level := n; - RETURN s; - END NewSema; - - PROCEDURE Level(s: Sema): CARDINAL; - BEGIN - RETURN s^.level; - END Level; - - PROCEDURE ReSchedule; - VAR s0: Processes; - i, j: CARDINAL; - BEGIN - s0 := cp; - i := Uniform(1, 5); - j := i; - LOOP - cp := cp^.next; - IF Runnable(cp) THEN - DEC(i); - IF i = 0 THEN EXIT END; - END; - IF (cp = s0) AND (j = i) THEN - (* deadlock *) - Message("deadlock"); - HALT - END; - END; - IF cp # s0 THEN TRANSFER(s0^.proc, cp^.proc); END; - END ReSchedule; - - PROCEDURE Runnable(p: Processes): BOOLEAN; - BEGIN - IF p^.waiting = NIL THEN RETURN TRUE; END; - IF p^.waiting^.level > 0 THEN - p^.waiting^.level := p^.waiting^.level - 1; - p^.waiting := NIL; - RETURN TRUE; - END; - RETURN FALSE; - END Runnable; -BEGIN - Allocate(cp, SIZE(Process)); - WITH cp^ DO - next := cp; - waiting := NIL; - END -END Semaphores. diff --git a/lib/ack/libm2/Storage.mod b/lib/ack/libm2/Storage.mod deleted file mode 100755 index a416f4901..000000000 --- a/lib/ack/libm2/Storage.mod +++ /dev/null @@ -1,353 +0,0 @@ -(* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*) - -(*$R-*) -IMPLEMENTATION MODULE Storage; -(* - Module: Dynamic Storage Allocation - Author: Ceriel J.H. Jacobs - Adapted from a version in C by Hans Tebra - Version: $Header$ -*) -(* This storage manager maintains an array of lists of objects with the - same size. Commonly used sizes have their own bucket. The larger ones - are put in a single list. -*) - FROM Unix IMPORT sbrk, ILLBREAK; - FROM SYSTEM IMPORT ADDRESS, ADR; - FROM Traps IMPORT Message; - - CONST - NLISTS = 20; - MAGICW = 0A5A5H; - MAGICC = 175C; - - TYPE - ALIGNTYPE = - RECORD - CASE : INTEGER OF - 1: l: LONGINT | - 2: p: ADDRESS | - 3: d: LONGREAL - END - END; (* A type with high alignment requirements *) - BucketPtr = POINTER TO Bucket; - Bucket = - RECORD - CASE : BOOLEAN OF - FALSE: - BNEXT: BucketPtr; (* next free Bucket *) - BSIZE: CARDINAL; | (* size of user part in UNITs *) - TRUE: BXX: ALIGNTYPE - END; - BSTORE: ALIGNTYPE; - END; - - CONST - UNIT = SIZE(ALIGNTYPE); - - VAR - FreeLists: ARRAY[0..NLISTS] OF BucketPtr; (* small blocks *) - Llist: BucketPtr; (* others *) - Compacted: BOOLEAN; (* avoid recursive reorganization *) - FirstBlock: BucketPtr; - USED: ADDRESS; - - PROCEDURE MyAllocate(size: CARDINAL) : ADDRESS; - VAR nu : CARDINAL; - b : CARDINAL; - p, q: BucketPtr; - pc: POINTER TO CHAR; - brk : ADDRESS; - BEGIN - IF size > CARDINAL(MAX(INTEGER)-2*UNIT + 1) THEN - RETURN NIL; - END; - nu := (size + (UNIT-1)) DIV UNIT; - IF nu = 0 THEN - nu := 1; - END; - IF nu <= NLISTS THEN - b := nu; - IF FreeLists[b] # NIL THEN - (* Exact fit *) - p := FreeLists[b]; - FreeLists[b] := p^.BNEXT; - p^.BNEXT := USED; - IF p^.BSIZE * UNIT # size THEN - pc := ADR(p^.BSTORE) + size; - pc^ := MAGICC; - END; - p^.BSIZE := size; - RETURN ADR(p^.BSTORE); - END; - - (* Search for a block with >= 2 units more than requested. - We pay for an additional header when the block is split. - *) - FOR b := b+2 TO NLISTS DO - IF FreeLists[b] # NIL THEN - q := FreeLists[b]; - FreeLists[b] := q^.BNEXT; - p := ADDRESS(q) + (nu+1)*UNIT; - (* p indicates the block that must be given - back - *) - p^.BSIZE := q^.BSIZE - nu - 1; - p^.BNEXT := FreeLists[p^.BSIZE]; - FreeLists[p^.BSIZE] := p; - q^.BSIZE := nu; - q^.BNEXT := USED; - IF q^.BSIZE * UNIT # size THEN - pc := ADR(q^.BSTORE) + size; - pc^ := MAGICC; - END; - q^.BSIZE := size; - RETURN ADR(q^.BSTORE); - END; - END; - END; - - p := Llist; - IF p # NIL THEN - q := NIL; - WHILE (p # NIL) AND (p^.BSIZE < nu) DO - q := p; - p := p^.BNEXT; - END; - - IF p # NIL THEN - (* p^.BSIZE >= nu *) - IF p^.BSIZE <= nu + NLISTS + 1 THEN - (* Remove p from this list *) - IF q # NIL THEN q^.BNEXT := p^.BNEXT - ELSE Llist := p^.BNEXT; - END; - p^.BNEXT := USED; - IF p^.BSIZE > nu + 1 THEN - (* split block, - tail goes to FreeLists area - *) - q := ADDRESS(p) + (nu+1)*UNIT; - q^.BSIZE := p^.BSIZE -nu -1; - q^.BNEXT := FreeLists[q^.BSIZE]; - FreeLists[q^.BSIZE] := q; - p^.BSIZE := nu; - END; - IF p^.BSIZE * UNIT # size THEN - pc := ADR(p^.BSTORE) + size; - pc^ := MAGICC; - END; - p^.BSIZE := size; - RETURN ADR(p^.BSTORE); - END; - (* Give part of tail of original block. - Block stays in this list. - *) - q := ADDRESS(p) + (p^.BSIZE-nu)*UNIT; - q^.BSIZE := nu; - p^.BSIZE := p^.BSIZE - nu - 1; - q^.BNEXT := USED; - IF q^.BSIZE * UNIT # size THEN - pc := ADR(q^.BSTORE) + size; - pc^ := MAGICC; - END; - q^.BSIZE := size; - RETURN ADR(q^.BSTORE); - END; - END; - - IF Compacted THEN - (* reorganization did not yield sufficient memory *) - RETURN NIL; - END; - - brk := sbrk(UNIT * (nu + 1)); - IF brk = ILLBREAK THEN - ReOrganize(); - Compacted := TRUE; - brk := MyAllocate(size); - Compacted := FALSE; - RETURN brk; - END; - - p := brk; - p^.BSIZE := nu; - p^.BNEXT := USED; - IF p^.BSIZE * UNIT # size THEN - pc := ADR(p^.BSTORE) + size; - pc^ := MAGICC; - END; - p^.BSIZE := size; - RETURN ADR(p^.BSTORE); - END MyAllocate; - - PROCEDURE ALLOCATE(VAR a: ADDRESS; size: CARDINAL); - BEGIN - Allocate(a, size); - END ALLOCATE; - - PROCEDURE Allocate(VAR a: ADDRESS; size: CARDINAL); - BEGIN - a := MyAllocate(size); - IF a = NIL THEN - Message("out of core"); - HALT; - END; - END Allocate; - - PROCEDURE Available(size: CARDINAL): BOOLEAN; - VAR a: ADDRESS; - BEGIN - a:= MyAllocate(size); - IF a # NIL THEN - Deallocate(a, size); - RETURN TRUE; - END; - RETURN FALSE; - END Available; - - PROCEDURE DEALLOCATE(VAR a: ADDRESS; size: CARDINAL); - BEGIN - Deallocate(a, size); - END DEALLOCATE; - - PROCEDURE Deallocate(VAR a: ADDRESS; size: CARDINAL); - VAR p: BucketPtr; - pc: POINTER TO CHAR; - BEGIN - IF (a = NIL) THEN - Message("(Warning) Deallocate: NIL pointer deallocated"); - RETURN; - END; - p := a - UNIT; - IF (p^.BNEXT # BucketPtr(USED)) THEN - Message("(Warning) Deallocate: area already deallocated or heap corrupted"); - a := NIL; - RETURN; - END; - WITH p^ DO - IF BSIZE # size THEN - Message("(Warning) Deallocate: wrong size or heap corrupted"); - END; - BSIZE := (size + (UNIT - 1)) DIV UNIT; - IF (BSIZE*UNIT # size) THEN - pc := a + size; - IF pc^ # MAGICC THEN - Message("(Warning) Deallocate: heap corrupted"); - END; - END; - IF BSIZE <= NLISTS THEN - BNEXT := FreeLists[BSIZE]; - FreeLists[BSIZE] := p; - ELSE - BNEXT := Llist; - Llist := p; - END; - END; - a := NIL - END Deallocate; - - PROCEDURE ReOrganize(); - VAR lastblock: BucketPtr; - b, be: BucketPtr; - i: CARDINAL; - BEGIN - lastblock := NIL; - FOR i := 1 TO NLISTS DO - b := FreeLists[i]; - WHILE b # NIL DO - IF ADDRESS(b) > ADDRESS(lastblock) THEN - lastblock := b; - END; - be := b^.BNEXT; - b^.BNEXT := NIL; (* temporary free mark *) - b := be; - END; - END; - - b := Llist; - WHILE b # NIL DO - IF ADDRESS(b) > ADDRESS(lastblock) THEN - lastblock := b; - END; - be := b^.BNEXT; - b^.BNEXT := NIL; - b := be; - END; - - (* Now, all free blocks have b^.BNEXT = NIL *) - - b := FirstBlock; - WHILE ADDRESS(b) < ADDRESS(lastblock) DO - LOOP - be := ADDRESS(b)+(b^.BSIZE+1)*UNIT; - IF b^.BNEXT # NIL THEN - (* this block is not free *) - EXIT; - END; - IF ADDRESS(be) > ADDRESS(lastblock) THEN - (* no next block *) - EXIT; - END; - IF be^.BNEXT # NIL THEN - (* next block is not free *) - EXIT; - END; - (* this block and the next one are free, - so merge them, but only if it is not too big - *) - IF MAX(CARDINAL) - b^.BSIZE > be^.BSIZE THEN - b^.BSIZE := b^.BSIZE + be^.BSIZE + 1; - ELSE - EXIT; - END; - END; - b := be; - END; - - (* clear all free lists *) - FOR i := 1 TO NLISTS DO FreeLists[i] := NIL; END; - Llist := NIL; - - (* collect free blocks in them again *) - b := FirstBlock; - WHILE ADDRESS(b) <= ADDRESS(lastblock) DO - WITH b^ DO - IF BNEXT = NIL THEN - IF BSIZE <= NLISTS THEN - BNEXT := FreeLists[BSIZE]; - FreeLists[BSIZE] := b; - ELSE - BNEXT := Llist; - Llist := b; - END; - b := ADDRESS(b) + (BSIZE+1) * UNIT; - ELSE - b := ADDRESS(b) + - ((BSIZE + (UNIT - 1)) DIV UNIT + 1) * UNIT; - END; - END; - END; - END ReOrganize; - - PROCEDURE InitStorage(); - VAR i: CARDINAL; - brk: ADDRESS; - BEGIN - FOR i := 1 TO NLISTS DO - FreeLists[i] := NIL; - END; - Llist := NIL; - brk := sbrk(0); - brk := sbrk(UNIT - brk MOD UNIT); - FirstBlock := sbrk(0); - Compacted := FALSE; - USED := MAGICW; - END InitStorage; - -BEGIN - InitStorage(); -END Storage. diff --git a/lib/ack/libm2/StrAss.c b/lib/ack/libm2/StrAss.c deleted file mode 100644 index c8c49f713..000000000 --- a/lib/ack/libm2/StrAss.c +++ /dev/null @@ -1,23 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* - Module: assign string to character array, with possible 0-byte - extension - Author: Ceriel J.H. Jacobs - Version: $Header$ -*/ -StringAssign(dstsiz, srcsiz, dstaddr, srcaddr) - register char *dstaddr, *srcaddr; -{ - while (srcsiz > 0) { - *dstaddr++ = *srcaddr++; - srcsiz--; - dstsiz--; - } - if (dstsiz > 0) { - *dstaddr = 0; - } -} diff --git a/lib/ack/libm2/Streams.mod b/lib/ack/libm2/Streams.mod deleted file mode 100755 index 451470149..000000000 --- a/lib/ack/libm2/Streams.mod +++ /dev/null @@ -1,443 +0,0 @@ -# -(* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*) - -(*$R-*) -IMPLEMENTATION MODULE Streams; -(* - Module: Stream Input/Output - Author: Ceriel J.H. Jacobs - Version: $Header$ - - Implementation for Unix -*) - - FROM SYSTEM IMPORT BYTE, ADR; - FROM Epilogue IMPORT CallAtEnd; - FROM Storage IMPORT Allocate, Available; - FROM StripUnix IMPORT - open, close, lseek, read, write, creat; - IMPORT StripUnix; - - CONST BUFSIZ = 1024; (* tunable *) - TYPE IOB = RECORD - kind: StreamKind; - mode: StreamMode; - eof: BOOLEAN; - buffering: StreamBuffering; - next : Stream; - fildes: INTEGER; - cnt, maxcnt: INTEGER; - bufferedcnt: INTEGER; - buf: ARRAY[1..BUFSIZ] OF BYTE; - END; - Stream = POINTER TO IOB; - VAR - ibuf, obuf, ebuf: IOB; - head: Stream; - - PROCEDURE getstruct(VAR stream: Stream); - BEGIN - stream := head; - WHILE (stream # NIL) AND (stream^.kind # none) DO - stream := stream^.next; - END; - IF stream = NIL THEN - IF NOT Available(SIZE(IOB)) THEN - RETURN; - END; - Allocate(stream,SIZE(IOB)); - stream^.next := head; - head := stream; - END; - END getstruct; - - PROCEDURE freestruct(stream: Stream); - BEGIN - stream^.kind := none; - END freestruct; - - PROCEDURE OpenStream(VAR stream: Stream; - filename: ARRAY OF CHAR; - kind: StreamKind; - mode: StreamMode; - VAR result: StreamResult); - VAR fd: INTEGER; - i: CARDINAL; - BEGIN - IF kind = none THEN - result := illegaloperation; - RETURN; - END; - getstruct(stream); - IF stream = NIL THEN - result := nomemory; - RETURN; - END; - WITH stream^ DO - FOR i := 0 TO HIGH(filename) DO - buf[i+1] := BYTE(filename[i]); - END; - buf[HIGH(filename)+2] := BYTE(0C); - END; - IF (mode = reading) THEN - fd := open(ADR(stream^.buf), 0); - ELSE - fd := -1; - IF (mode = appending) THEN - fd := open(ADR(stream^.buf), 1); - IF fd >= 0 THEN - IF (lseek(fd, 0D , 2) < 0D) THEN ; END; - END; - END; - IF fd < 0 THEN - fd := creat(ADR(stream^.buf), 666B); - END; - END; - IF fd < 0 THEN - result := openfailed; - freestruct(stream); - stream := NIL; - RETURN; - END; - result := succeeded; - stream^.fildes := fd; - stream^.kind := kind; - stream^.mode := mode; - stream^.buffering := blockbuffered; - stream^.bufferedcnt := BUFSIZ; - stream^.maxcnt := 0; - stream^.eof := FALSE; - IF mode = reading THEN - stream^.cnt := 1; - ELSE - stream^.cnt := 0; - END; - END OpenStream; - - PROCEDURE SetStreamBuffering( stream: Stream; - b: StreamBuffering; - VAR result: StreamResult); - BEGIN - result := succeeded; - IF (stream = NIL) OR (stream^.kind = none) THEN - result := nostream; - RETURN; - END; - IF (stream^.mode = reading) OR - ((b = linebuffered) AND (stream^.kind = binary)) THEN - result := illegaloperation; - RETURN; - END; - FlushStream(stream, result); - IF b = unbuffered THEN - stream^.bufferedcnt := 1; - END; - stream^.buffering := b; - END SetStreamBuffering; - - PROCEDURE FlushStream(stream: Stream; VAR result: StreamResult); - VAR cnt1: INTEGER; - BEGIN - result := succeeded; - IF (stream = NIL) OR (stream^.kind = none) THEN - result := nostream; - RETURN; - END; - WITH stream^ DO - IF mode = reading THEN - result := illegaloperation; - RETURN; - END; - IF (cnt > 0) THEN - cnt1 := cnt; - cnt := 0; - IF write(fildes, ADR(buf), cnt1) < 0 THEN END; - END; - END; - END FlushStream; - - PROCEDURE CloseStream(VAR stream: Stream; VAR result: StreamResult); - BEGIN - IF (stream # NIL) AND (stream^.kind # none) THEN - result := succeeded; - IF stream^.mode # reading THEN - FlushStream(stream, result); - END; - IF close(stream^.fildes) < 0 THEN ; END; - freestruct(stream); - ELSE - result := nostream; - END; - stream := NIL; - END CloseStream; - - PROCEDURE EndOfStream(stream: Stream; VAR result: StreamResult): BOOLEAN; - BEGIN - result := succeeded; - IF (stream = NIL) OR (stream^.kind = none) THEN - result := nostream; - RETURN FALSE; - END; - IF stream^.mode # reading THEN - result := illegaloperation; - RETURN FALSE; - END; - IF stream^.eof THEN RETURN TRUE; END; - RETURN (CHAR(NextByte(stream)) = 0C) AND stream^.eof; - END EndOfStream; - - PROCEDURE FlushLineBuffers(); - VAR s: Stream; - result: StreamResult; - BEGIN - s := head; - WHILE s # NIL DO - IF (s^.kind # none) AND (s^.buffering = linebuffered) THEN - FlushStream(s, result); - END; - s := s^.next; - END; - END FlushLineBuffers; - - PROCEDURE NextByte(stream: Stream): BYTE; - VAR c: BYTE; - BEGIN - WITH stream^ DO - IF cnt <= maxcnt THEN - c := buf[cnt]; - ELSE - IF eof THEN RETURN BYTE(0C); END; - IF stream = InputStream THEN - FlushLineBuffers(); - END; - maxcnt := read(fildes, ADR(buf), bufferedcnt); - cnt := 1; - IF maxcnt <= 0 THEN - eof := TRUE; - c := BYTE(0C); - ELSE - c := buf[1]; - END; - END; - END; - RETURN c; - END NextByte; - - PROCEDURE Read(stream: Stream; VAR ch: CHAR; VAR result: StreamResult); - VAR EoF: BOOLEAN; - BEGIN - ch := 0C; - EoF := EndOfStream(stream, result); - IF result # succeeded THEN RETURN; END; - IF EoF THEN - result := endoffile; - RETURN; - END; - WITH stream^ DO - ch := CHAR(buf[cnt]); - INC(cnt); - END; - END Read; - - PROCEDURE ReadByte(stream: Stream; VAR byte: BYTE; VAR result: StreamResult); - VAR EoF: BOOLEAN; - BEGIN - byte := BYTE(0C); - EoF := EndOfStream(stream, result); - IF result # succeeded THEN RETURN; END; - IF EoF THEN - result := endoffile; - RETURN; - END; - WITH stream^ DO - byte := buf[cnt]; - INC(cnt); - END; - END ReadByte; - - PROCEDURE ReadBytes(stream: Stream; - VAR bytes: ARRAY OF BYTE; - VAR result: StreamResult); - VAR i: CARDINAL; - BEGIN - FOR i := 0 TO HIGH(bytes) DO - ReadByte(stream, bytes[i], result); - END; - END ReadBytes; - - PROCEDURE Write(stream: Stream; ch: CHAR; VAR result: StreamResult); - BEGIN - IF (stream = NIL) OR (stream^.kind = none) THEN - result := nostream; - RETURN; - END; - IF (stream^.kind # text) OR (stream^.mode = reading) THEN - result := illegaloperation; - RETURN; - END; - WITH stream^ DO - INC(cnt); - buf[cnt] := BYTE(ch); - IF (cnt >= bufferedcnt) OR - ((ch = 12C) AND (buffering = linebuffered)) - THEN - FlushStream(stream, result); - END; - END; - END Write; - - PROCEDURE WriteByte(stream: Stream; byte: BYTE; VAR result: StreamResult); - BEGIN - IF (stream = NIL) OR (stream^.kind = none) THEN - result := nostream; - RETURN; - END; - IF (stream^.kind # binary) OR (stream^.mode = reading) THEN - result := illegaloperation; - RETURN; - END; - WITH stream^ DO - INC(cnt); - buf[cnt] := byte; - IF cnt >= bufferedcnt THEN - FlushStream(stream, result); - END; - END; - END WriteByte; - - PROCEDURE WriteBytes(stream: Stream; bytes: ARRAY OF BYTE; VAR result: StreamResult); - VAR i: CARDINAL; - BEGIN - FOR i := 0 TO HIGH(bytes) DO - WriteByte(stream, bytes[i], result); - END; - END WriteBytes; - - PROCEDURE EndIt; - VAR h, h1 : Stream; - result: StreamResult; - BEGIN - h := head; - WHILE h # NIL DO - h1 := h; - CloseStream(h1, result); - h := h^.next; - END; - END EndIt; - - PROCEDURE GetPosition(s: Stream; VAR position: LONGINT; - VAR result: StreamResult); - BEGIN - IF (s = NIL) OR (s^.kind = none) THEN - result := illegaloperation; - RETURN; - END; - IF (s^.mode # reading) THEN FlushStream(s, result); END; - position := lseek(s^.fildes, 0D, 1); - IF position < 0D THEN - result := illegaloperation; - RETURN; - END; - IF s^.mode = reading THEN - position := position + LONG(s^.maxcnt - s^.cnt + 1); - END; - END GetPosition; - - PROCEDURE SetPosition(s: Stream; position: LONGINT; VAR result: StreamResult); - VAR currpos: LONGINT; - BEGIN - currpos := 0D; - IF (s = NIL) OR (s^.kind = none) THEN - result := nostream; - RETURN; - END; - IF (s^.mode # reading) THEN - FlushStream(s, result); - ELSE - s^.maxcnt := 0; - s^.eof := FALSE; - END; - IF s^.mode = appending THEN - currpos := lseek(s^.fildes, 0D, 1); - IF currpos < 0D THEN - result := illegaloperation; - RETURN; - END; - END; - IF position < currpos THEN - result := illegaloperation; - RETURN; - END; - currpos := lseek(s^.fildes, position, 0); - IF currpos < 0D THEN - result := illegaloperation; - RETURN; - END; - result := succeeded; - END SetPosition; - - PROCEDURE isatty(stream: Stream; VAR result: StreamResult): BOOLEAN; - BEGIN - IF (stream = NIL) OR (stream^.kind = none) THEN - result := nostream; - RETURN FALSE; - END; - RETURN StripUnix.isatty(stream^.fildes); - END isatty; - - PROCEDURE InitStreams; - VAR result: StreamResult; - BEGIN - InputStream := ADR(ibuf); - OutputStream := ADR(obuf); - ErrorStream := ADR(ebuf); - WITH ibuf DO - kind := text; - mode := reading; - eof := FALSE; - next := ADR(obuf); - fildes := 0; - maxcnt := 0; - cnt := 1; - bufferedcnt := BUFSIZ; - END; - WITH obuf DO - kind := text; - mode := writing; - eof := TRUE; - next := ADR(ebuf); - fildes := 1; - maxcnt := 0; - cnt := 0; - bufferedcnt := BUFSIZ; - IF isatty(OutputStream, result) THEN - buffering := linebuffered; - ELSE - buffering := blockbuffered; - END; - END; - WITH ebuf DO - kind := text; - mode := writing; - eof := TRUE; - next := NIL; - fildes := 2; - maxcnt := 0; - cnt := 0; - bufferedcnt := BUFSIZ; - IF isatty(ErrorStream, result) THEN - buffering := linebuffered; - ELSE - buffering := blockbuffered; - END; - END; - head := InputStream; - IF CallAtEnd(EndIt) THEN ; END; - END InitStreams; - -BEGIN - InitStreams -END Streams. diff --git a/lib/ack/libm2/Strings.mod b/lib/ack/libm2/Strings.mod deleted file mode 100755 index 8ae31eea5..000000000 --- a/lib/ack/libm2/Strings.mod +++ /dev/null @@ -1,171 +0,0 @@ -(* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*) - -(*$R-*) -IMPLEMENTATION MODULE Strings; -(* - Module: String manipulations - Author: Ceriel J.H. Jacobs - Version: $Header$ -*) - - PROCEDURE Assign(source: ARRAY OF CHAR; VAR dest: ARRAY OF CHAR); - (* Assign string source to dest - *) - VAR i: CARDINAL; - max: CARDINAL; - BEGIN - max := HIGH(source); - IF HIGH(dest) < max THEN max := HIGH(dest); END; - i := 0; - WHILE (i <= max) AND (source[i] # 0C) DO - dest[i] := source[i]; - INC(i); - END; - IF i < HIGH(dest) THEN dest[i] := 0C; END; - END Assign; - - PROCEDURE Insert(substr: ARRAY OF CHAR; VAR str: ARRAY OF CHAR; inx: CARDINAL); - (* Insert the string substr into str, starting at str[inx]. - If inx is equal to or greater than Length(str) then substr is appended - to the end of str. - *) - VAR sublen, length, i: CARDINAL; - BEGIN - sublen := Length(substr); - IF sublen = 0 THEN RETURN; END; - length := Length(str); - IF inx > length THEN inx := length; END; - i := length; - IF i + sublen - 1 > HIGH(str) THEN i := HIGH(str); END; - WHILE i > inx DO - str[i+sublen-1] := str[i-1]; - DEC(i); - END; - FOR i := 0 TO sublen - 1 DO - IF i + inx <= HIGH(str) THEN - str[i + inx] := substr[i]; - ELSE - RETURN; - END; - END; - IF length + sublen <= HIGH(str) THEN - str[length + sublen] := 0C; - END; - END Insert; - - PROCEDURE Delete(VAR str: ARRAY OF CHAR; inx, len: CARDINAL); - (* Delete len characters from str, starting at str[inx]. - If inx >= Length(str) then nothing happens. - If there are not len characters to delete, characters to the end of the - string are deleted. - *) - VAR length: CARDINAL; - BEGIN - IF len = 0 THEN RETURN; END; - length := Length(str); - IF inx >= length THEN RETURN; END; - WHILE inx + len < length DO - str[inx] := str[inx + len]; - INC(inx); - END; - str[inx] := 0C; - END Delete; - - PROCEDURE Pos(substr, str: ARRAY OF CHAR): CARDINAL; - (* Return the index into str of the first occurrence of substr. - Pos returns a value greater than HIGH(str) of no occurrence is found. - *) - VAR i, j, max, subl: CARDINAL; - BEGIN - max := Length(str); - subl := Length(substr); - IF subl > max THEN RETURN HIGH(str) + 1; END; - IF subl = 0 THEN RETURN 0; END; - max := max - subl; - FOR i := 0 TO max DO - j := 0; - WHILE (j <= subl-1) AND (str[i+j] = substr[j]) DO - INC(j); - END; - IF j = subl THEN RETURN i; END; - END; - RETURN HIGH(str) + 1; - END Pos; - - PROCEDURE Copy(str: ARRAY OF CHAR; - inx, len: CARDINAL; - VAR result: ARRAY OF CHAR); - (* Copy at most len characters from str into result, starting at str[inx]. - *) - VAR i: CARDINAL; - BEGIN - IF Length(str) <= inx THEN RETURN END; - i := 0; - LOOP - IF i > HIGH(result) THEN RETURN; END; - IF len = 0 THEN EXIT; END; - IF inx > HIGH(str) THEN EXIT; END; - result[i] := str[inx]; - INC(i); INC(inx); DEC(len); - END; - IF i <= HIGH(result) THEN result[i] := 0C; END; - END Copy; - - PROCEDURE Concat(s1, s2: ARRAY OF CHAR; VAR result: ARRAY OF CHAR); - (* Concatenate two strings. - *) - VAR i, j: CARDINAL; - BEGIN - i := 0; - WHILE (i <= HIGH(s1)) AND (s1[i] # 0C) DO - IF i > HIGH(result) THEN RETURN END; - result[i] := s1[i]; - INC(i); - END; - j := 0; - WHILE (j <= HIGH(s2)) AND (s2[j] # 0C) DO - IF i > HIGH(result) THEN RETURN END; - result[i] := s2[j]; - INC(i); - INC(j); - END; - IF i <= HIGH(result) THEN result[i] := 0C; END; - END Concat; - - PROCEDURE Length(str: ARRAY OF CHAR): CARDINAL; - (* Return number of characters in str. - *) - VAR i: CARDINAL; - BEGIN - i := 0; - WHILE (i <= HIGH(str)) DO - IF str[i] = 0C THEN RETURN i; END; - INC(i); - END; - RETURN i; - END Length; - - PROCEDURE CompareStr(s1, s2: ARRAY OF CHAR): INTEGER; - (* Compare two strings, return -1 if s1 < s2, 0 if s1 = s2, and 1 if s1 > s2. - *) - VAR i: CARDINAL; - max: CARDINAL; - BEGIN - max := HIGH(s1); - IF HIGH(s2) < max THEN max := HIGH(s2); END; - i := 0; - WHILE (i <= max) DO - IF s1[i] < s2[i] THEN RETURN -1; END; - IF s1[i] > s2[i] THEN RETURN 1; END; - IF s1[i] = 0C THEN RETURN 0; END; - INC(i); - END; - IF (i <= HIGH(s1)) AND (s1[i] # 0C) THEN RETURN 1; END; - IF (i <= HIGH(s2)) AND (s2[i] # 0C) THEN RETURN -1; END; - RETURN 0; - END CompareStr; - -END Strings. diff --git a/lib/ack/libm2/Termcap.mod b/lib/ack/libm2/Termcap.mod deleted file mode 100755 index 1098f7884..000000000 --- a/lib/ack/libm2/Termcap.mod +++ /dev/null @@ -1,99 +0,0 @@ -(* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*) - -(* - Module: Interface to termcap database - From: Unix manual chapter 3 - Version: $Header$ -*) - -(*$R-*) -IMPLEMENTATION MODULE Termcap; - - IMPORT XXTermcap; - FROM SYSTEM IMPORT ADR, ADDRESS; - FROM Unix IMPORT isatty; - FROM Arguments IMPORT - GetEnv; - - TYPE STR = ARRAY[1..32] OF CHAR; - STRCAP = POINTER TO STR; - - VAR Buf, Buf1 : ARRAY [1..1024] OF CHAR; - BufCnt : INTEGER; - - PROCEDURE Tgetent(name: ARRAY OF CHAR) : INTEGER; - VAR i: INTEGER; - x: STRCAP; - BEGIN - i := XXTermcap.tgetent(ADR(Buf), ADR(name)); - BufCnt := 1; - IF isatty(1) THEN - ELSE - (* This used to be something returned by gtty(). To increase - * portability we forget about old terminals needing delays. - * (kjb) - *) - XXTermcap.ospeed := 0; - END; - IF i > 0 THEN - IF Tgetstr("pc", x) THEN - XXTermcap.PC := x^[1]; - ELSE XXTermcap.PC := 0C; - END; - IF Tgetstr("up", x) THEN ; END; XXTermcap.UP := x; - IF Tgetstr("bc", x) THEN ; END; XXTermcap.BC := x; - END; - RETURN i; - END Tgetent; - - PROCEDURE Tgetnum(id: ARRAY OF CHAR): INTEGER; - BEGIN - RETURN XXTermcap.tgetnum(ADR(id)); - END Tgetnum; - - PROCEDURE Tgetflag(id: ARRAY OF CHAR): BOOLEAN; - BEGIN - RETURN XXTermcap.tgetflag(ADR(id)) = 1; - END Tgetflag; - - PROCEDURE Tgoto(cm: STRCAP; col, line: INTEGER): STRCAP; - BEGIN - RETURN XXTermcap.tgoto(cm, col, line); - END Tgoto; - - PROCEDURE Tgetstr(id: ARRAY OF CHAR; VAR res: STRCAP) : BOOLEAN; - VAR a, a2: ADDRESS; - b: CARDINAL; - BEGIN - a := ADR(Buf1[BufCnt]); - a2 := XXTermcap.tgetstr(ADR(id), ADR(a)); - res := a2; - IF a2 = NIL THEN - RETURN FALSE; - END; - b := a - a2; - INC(BufCnt, b); - RETURN TRUE; - END Tgetstr; - - PROCEDURE Tputs(cp: STRCAP; affcnt: INTEGER; p: PUTPROC); - BEGIN - XXTermcap.tputs(cp, affcnt, XXTermcap.PUTPROC(p)); - END Tputs; - - PROCEDURE InitTermcap; - VAR Bf: STR; - BEGIN - IF GetEnv("TERM", Bf) = 0 THEN - Bf := "dumb"; - END; - IF Tgetent(Bf) <= 0 THEN - END; - END InitTermcap; - -BEGIN - InitTermcap; -END Termcap. diff --git a/lib/ack/libm2/Terminal.mod b/lib/ack/libm2/Terminal.mod deleted file mode 100755 index 7a6c0a66f..000000000 --- a/lib/ack/libm2/Terminal.mod +++ /dev/null @@ -1,114 +0,0 @@ -# -(* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*) - -(*$R-*) -IMPLEMENTATION MODULE Terminal; -(* - Module: Input/Output to/from terminals - Author: Ceriel J.H. Jacobs - Version: $Header$ - - Implementation for Unix. -*) - FROM SYSTEM IMPORT ADR; -#ifdef __USG - FROM Unix IMPORT read, write, open, fcntl; -#else - FROM Unix IMPORT read, write, open, ioctl; -#endif - VAR fildes: INTEGER; - unreadch: CHAR; - unread: BOOLEAN; - tty: ARRAY[0..8] OF CHAR; - - PROCEDURE Read(VAR ch: CHAR); - BEGIN - IF unread THEN - ch := unreadch; - unread := FALSE - ELSE - IF read(fildes, ADR(ch), 1) < 0 THEN - ; - END; - END; - unreadch := ch; - END Read; - - PROCEDURE BusyRead(VAR ch: CHAR); - VAR l: INTEGER; - BEGIN - IF unread THEN - ch := unreadch; - unread := FALSE - ELSE -#ifdef __USG - l := fcntl(fildes, (*FGETFL*) 3, 0); - IF fcntl(fildes, - (* FSETFL *) 4, - l + (*ONDELAY*) 2) < 0 THEN - ; - END; - IF read(fildes, ADR(ch), 1) = 0 THEN - ch := 0C; - ELSE - unreadch := ch; - END; - IF fcntl(fildes, (*FSETFL*)4, l) < 0 THEN - ; - END; -#else -#ifdef __BSD4_2 - IF ioctl(fildes, INTEGER(ORD('f')*256+127+4*65536+40000000H), ADR(l)) < 0 THEN -#else - IF ioctl(fildes, INTEGER(ORD('f')*256+127), ADR(l)) < 0 THEN -#endif - ; - END; - - IF l = 0 THEN - ch := 0C; - ELSE - IF read(fildes, ADR(ch), 1) < 0 THEN - ; - END; - unreadch := ch; - END; -#endif - END; - END BusyRead; - - PROCEDURE ReadAgain; - BEGIN - unread := TRUE; - END ReadAgain; - - PROCEDURE Write(ch: CHAR); - BEGIN - IF write(fildes, ADR(ch), 1) < 0 THEN - ; - END; - END Write; - - PROCEDURE WriteLn; - BEGIN - Write(12C); - END WriteLn; - - PROCEDURE WriteString(s: ARRAY OF CHAR); - VAR i: CARDINAL; - BEGIN - i := 0; - WHILE (i <= HIGH(s)) & (s[i] # 0C) DO - Write(s[i]); - INC(i) - END - END WriteString; - -BEGIN - tty := "/dev/tty"; - fildes := open(ADR(tty), 2); - unread := FALSE; -END Terminal. diff --git a/lib/ack/libm2/Traps.mod b/lib/ack/libm2/Traps.mod deleted file mode 100755 index 913ee4a8d..000000000 --- a/lib/ack/libm2/Traps.mod +++ /dev/null @@ -1,96 +0,0 @@ -(* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*) - -(*$R-*) -IMPLEMENTATION MODULE Traps; -(* - Module: Facility for handling traps - Author: Ceriel J.H. Jacobs - Version: $Header$ -*) - - FROM EM IMPORT SIG, LINO, FILN, TRP; - FROM Unix IMPORT write; - FROM SYSTEM IMPORT ADDRESS, ADR; - FROM Arguments IMPORT - Argv; - - PROCEDURE InstallTrapHandler(t: TrapHandler): TrapHandler; - (* Install a new trap handler, and return the previous one. - Parameter of trap handler is the trap number. - *) - BEGIN - RETURN SIG(t); - END InstallTrapHandler; - - PROCEDURE Message(str: ARRAY OF CHAR); - (* Write message "str" on standard error, preceeded by filename and - linenumber if possible - *) - VAR p: POINTER TO CHAR; - l: CARDINAL; - lino: INTEGER; - buf, buf2: ARRAY [0..255] OF CHAR; - i, j: CARDINAL; - BEGIN - p := FILN(); - IF p # NIL THEN - i := 1; - buf[0] := '"'; - WHILE p^ # 0C DO - buf[i] := p^; - INC(i); - p := ADDRESS(p) + 1; - END; - buf[i] := '"'; - INC(i); - IF write(2, ADR(buf), i) < 0 THEN END; - ELSE - l := Argv(0, buf); - IF write(2, ADR(buf), l-1) < 0 THEN END; - END; - lino := LINO(); - i := 0; - IF lino # 0 THEN - i := 7; - buf[0] := ','; buf[1] := ' '; - buf[2] := 'l'; buf[3] := 'i'; buf[4] := 'n'; buf[5] := 'e'; - buf[6] := ' '; - IF lino < 0 THEN - buf[7] := '-'; - i := 8; - lino := - lino; - END; - j := 0; - REPEAT - buf2[j] := CHR(CARDINAL(lino) MOD 10 + ORD('0')); - lino := lino DIV 10; - INC(j); - UNTIL lino = 0; - WHILE j > 0 DO - DEC(j); - buf[i] := buf2[j]; - INC(i); - END; - END; - buf[i] := ':'; - buf[i+1] := ' '; - IF write(2, ADR(buf), i+2) < 0 THEN END; - i := 0; - WHILE (i <= HIGH(str)) AND (str[i] # 0C) DO - INC(i); - END; - IF write(2, ADR(str), i) < 0 THEN END; - buf[0] := 12C; - IF write(2, ADR(buf), 1) < 0 THEN END; - END Message; - - PROCEDURE Trap(n: INTEGER); - (* cause trap number "n" to occur *) - BEGIN - TRP(n); - END Trap; - -END Traps. diff --git a/lib/ack/libm2/XXTermcap.c b/lib/ack/libm2/XXTermcap.c deleted file mode 100644 index 56a4f9c77..000000000 --- a/lib/ack/libm2/XXTermcap.c +++ /dev/null @@ -1,573 +0,0 @@ -/* - * termcap.c 1.1 20/7/87 agc Joypace Ltd - * - * Copyright Joypace Ltd, London, UK, 1987. All rights reserved. - * This file may be freely distributed provided that this notice - * remains attached. - * - * A public domain implementation of the termcap(3) routines. - * - * Made fully functional by Ceriel J.H. Jacobs. - * - * BUGS: - * - does not check termcap entry sizes - * - not fully tested - */ - -#define CAPABLEN 2 - -#define ISSPACE(c) ((c) == ' ' || (c) == '\t' || (c) == '\r' || (c) == '\n') -#define ISDIGIT(x) ((x) >= '0' && (x) <= '9') - -short ospeed = 0; /* output speed */ -char PC = 0; /* padding character */ -char *BC = 0; /* back cursor movement */ -char *UP = 0; /* up cursor movement */ - -static char *capab = 0; /* the capability itself */ -static int check_for_tc(); -static int match_name(); - -#define NULL 0 - -/* Some things from C-library, needed here because the C-library is not - loaded with Modula-2 programs -*/ - -static char * -strcat(s1, s2) -register char *s1, *s2; -{ - /* Append s2 to the end of s1. */ - - char *original = s1; - - /* Find the end of s1. */ - while (*s1 != 0) s1++; - - /* Now copy s2 to the end of s1. */ - while (*s1++ = *s2++) /* nothing */ ; - return(original); -} - -static char * -strcpy(s1, s2) -register char *s1, *s2; -{ -/* Copy s2 to s1. */ - char *original = s1; - - while (*s1++ = *s2++) /* nothing */; - return(original); -} - -static int -strlen(s) -char *s; -{ -/* Return length of s. */ - - char *original = s; - - while (*s != 0) s++; - return(s - original); -} - -static int -strcmp(s1, s2) -register char *s1, *s2; -{ -/* Compare 2 strings. */ - - for(;;) { - if (*s1 != *s2) { - if (!*s1) return -1; - if (!*s2) return 1; - return(*s1 - *s2); - } - if (*s1++ == 0) return(0); - s2++; - } -} - -static int -strncmp(s1, s2, n) - register char *s1, *s2; - int n; -{ -/* Compare two strings, but at most n characters. */ - - while (n-- > 0) { - if (*s1 != *s2) { - if (!*s1) return -1; - if (!*s2) return 1; - return(*s1 - *s2); - } - if (*s1++ == 0) break; - s2++; - } - return 0; -} - -static char * -getenv(name) -register char *name; -{ - extern char ***_penviron; - register char **v = *_penviron, *p, *q; - - if (v == 0 || name == 0) return 0; - while ((p = *v++) != 0) { - q = name; - while (*q && *q++ == *p++) /* nothing */ ; - if (*q || *p != '=') continue; - return(p+1); - } - return(0); -} - -static char * -fgets(buf, count, fd) - char *buf; -{ - static char bf[1024]; - static int cnt = 0; - static char *pbf = &bf[0]; - register char *c = buf; - - - while (--count) { - if (pbf >= &bf[cnt]) { - if ((cnt = read(fd, bf, 1024)) <= 0) { - if (c == buf) return (char *) NULL; - *c = 0; - return buf; - } - pbf = &bf[0]; - } - *c = *pbf++; - if (*c++ == '\n') { - *c = 0; - return buf; - } - } - *c = 0; - return buf; -} - -/* - * tgetent - get the termcap entry for terminal name, and put it - * in bp (which must be an array of 1024 chars). Returns 1 if - * termcap entry found, 0 if not found, and -1 if file not found. - */ -int -tgetent(bp, name) -char *bp; -char *name; -{ - int fp; - char *file; - char *cp; - short len = strlen(name); - char buf[1024]; - - capab = bp; - if ((file = getenv("TERMCAP")) != (char *) NULL) { - if (*file != '/' && - (cp = getenv("TERM")) != NULL && strcmp(name, cp) == 0) { - (void) strcpy(bp, file); - return(1); - } - else file = "/etc/termcap"; - } else - file = "/etc/termcap"; - if ((fp = open(file, 0)) < 0) { - capab = 0; - return(-1); - } - while (fgets(buf, 1024, fp) != NULL) { - if (buf[0] == '#') continue; - while (*(cp = &buf[strlen(buf) - 2]) == '\\') - if (fgets(cp, 1024, fp) == NULL) - return (0); - if (match_name(buf, name)) { - strcpy(bp, buf); - close(fp); - if(check_for_tc() == 0) { - capab = 0; - return 0; - } - return 1; - } - } - capab = 0; - close(fp); - return(0); -} - -/* - * Compare the terminal name with each termcap entry name; Return 1 if a - * match is found. - */ -static int -match_name(buf, name) - char *buf; - char *name; -{ - register char *tp = buf; - register char *np; - - for (;;) { - for (np = name; *np && *tp == *np; np++, tp++) { } - if (*np == 0 && (*tp == '|' || *tp == ':' || *tp == 0)) - return(1); - while (*tp != 0 && *tp != '|' && *tp != ':') tp++; - if (*tp++ != '|') return (0); - } -} - -/* - * Handle tc= definitions recursively. - */ -static int -check_for_tc() -{ - static int count = 0; - char *savcapab = capab; - char buf[1024]; - char terminalname[128]; - register char *p = capab + strlen(capab) - 2, *q; - - while (*p != ':') - if (--p < capab) - return(0); /* no : in termcap entry */ - if (p[1] != 't' || p[2] != 'c') - return(1); - if (count > 16) { - return(0); /* recursion in tc= definitions */ - } - count++; - strcpy(terminalname, &p[4]); - q = terminalname; - while (*q && *q != ':') q++; - *q = 0; - if (tgetent(buf, terminalname) != 1) { - --count; - return(0); - } - --count; - for (q = buf; *q && *q != ':'; q++) { } - strcpy(p, q); - capab = savcapab; - return(1); -} - -/* - * tgetnum - get the numeric terminal capability corresponding - * to id. Returns the value, -1 if invalid. - */ -int -tgetnum(id) -char *id; -{ - char *cp; - int ret; - - if ((cp = capab) == NULL || id == NULL || *cp == 0) - return(-1); - while (*++cp && *cp != ':') - ; - while (*cp) { - cp++; - while (ISSPACE(*cp)) - cp++; - if (strncmp(cp, id, CAPABLEN) == 0) { - while (*cp && *cp != ':' && *cp != '#') - cp++; - if (*cp != '#') - return(-1); - for (ret = 0, cp++ ; *cp && ISDIGIT(*cp) ; cp++) - ret = ret * 10 + *cp - '0'; - return(ret); - } - while (*cp && *cp != ':') - cp++; - } - return(-1); -} - -/* - * tgetflag - get the boolean flag corresponding to id. Returns -1 - * if invalid, 0 if the flag is not in termcap entry, or 1 if it is - * present. - */ -int -tgetflag(id) -char *id; -{ - char *cp; - - if ((cp = capab) == NULL || id == NULL || *cp == 0) - return(-1); - while (*++cp && *cp != ':') - ; - while (*cp) { - cp++; - while (ISSPACE(*cp)) - cp++; - if (strncmp(cp, id, CAPABLEN) == 0) - return(1); - while (*cp && *cp != ':') - cp++; - } - return(0); -} - -/* - * tgetstr - get the string capability corresponding to id and place - * it in area (advancing area at same time). Expand escape sequences - * etc. Returns the string, or NULL if it can't do it. - */ -char * -tgetstr(id, area) -char *id; -char **area; -{ - char *cp; - char *ret; - int i; - - if ((cp = capab) == NULL || id == NULL || *cp == 0) - return(NULL); - while (*++cp != ':') - ; - while (*cp) { - cp++; - while (ISSPACE(*cp)) - cp++; - if (strncmp(cp, id, CAPABLEN) == 0) { - while (*cp && *cp != ':' && *cp != '=') - cp++; - if (*cp != '=') - return(NULL); - for (ret = *area, cp++; *cp && *cp != ':' ; (*area)++, cp++) - switch(*cp) { - case '^' : - **area = *++cp - 'A' + 1; - break; - case '\\' : - switch(*++cp) { - case 'E' : - **area = '\033'; - break; - case 'n' : - **area = '\n'; - break; - case 'r' : - **area = '\r'; - break; - case 't' : - **area = '\t'; - break; - case 'b' : - **area = '\b'; - break; - case 'f' : - **area = '\f'; - break; - case '0' : - case '1' : - case '2' : - case '3' : - for (i=0 ; *cp && ISDIGIT(*cp) ; cp++) - i = i * 8 + *cp - '0'; - **area = i; - cp--; - break; - case '^' : - case '\\' : - **area = *cp; - break; - } - break; - default : - **area = *cp; - } - *(*area)++ = '\0'; - return(ret); - } - while (*cp && *cp != ':') - cp++; - } - return(NULL); -} - -/* - * tgoto - given the cursor motion string cm, make up the string - * for the cursor to go to (destcol, destline), and return the string. - * Returns "OOPS" if something's gone wrong, or the string otherwise. - */ -char * -tgoto(cm, destcol, destline) -char *cm; -int destcol; -int destline; -{ - register char *rp; - static char ret[32]; - char added[16]; - int *dp = &destline; - int numval; - int swapped = 0; - - added[0] = 0; - for (rp = ret ; *cm ; cm++) { - if (*cm == '%') { - switch(*++cm) { - case '>' : - if (dp == NULL) - return("OOPS"); - cm++; - if (*dp > *cm++) { - *dp += *cm; - } - break; - case '+' : - case '.' : - if (dp == NULL) - return("OOPS"); - if (*cm == '+') *dp = *dp + *++cm; - for (;;) { - switch(*dp) { - case 0: - case 04: - case '\t': - case '\n': - /* filter these out */ - if (dp == &destcol || swapped || UP) { - strcat(added, dp == &destcol || swapped ? - (BC ? BC : "\b") : - UP); - (*dp)++; - continue; - } - } - break; - } - *rp++ = *dp; - dp = (dp == &destline) ? &destcol : NULL; - break; - - case 'r' : { - int tmp = destline; - - destline = destcol; - destcol = tmp; - swapped = 1 - swapped; - break; - } - case 'n' : - destcol ^= 0140; - destline ^= 0140; - break; - - case '%' : - *rp++ = '%'; - break; - - case 'i' : - destcol++; - destline++; - break; - - case 'B' : - if (dp == NULL) - return("OOPS"); - *dp = 16 * (*dp / 10) + *dp % 10; - break; - - case 'D' : - if (dp == NULL) - return("OOPS"); - *dp = *dp - 2 * (*dp % 16); - break; - - case 'd' : - case '2' : - case '3' : - if (dp == NULL) - return("OOPS"); - numval = *dp; - dp = (dp == &destline) ? &destcol : NULL; - if (numval >= 100) { - *rp++ = '0' + numval / 100; - } - else if (*cm == '3') { - *rp++ = ' '; - } - if (numval >= 10) { - *rp++ = '0' + ((numval%100)/10); - } - else if (*cm == '3' || *cm == '2') { - *rp++ = ' '; - } - *rp++ = '0' + (numval%10); - break; - default : - return("OOPS"); - } - } - else *rp++ = *cm; - } - *rp = '\0'; - strcpy(rp, added); - return(ret); -} - -static int tens_of_ms_p_char[] = { /* index as returned by gtty */ - /* assume 10 bits per char */ - 0, 2000, 1333, 909, 743, 666, 500, 333, 166, 83, 55, 41, 20, 10, 5, 2 -}; -/* - * tputs - put the string cp out onto the terminal, using the function - * outc. Also handle padding. - */ -int -tputs(cp, affcnt, outc) -register char *cp; -int affcnt; -int (*outc)(); -{ - int delay = 0; - if (cp == NULL) - return(1); - while (ISDIGIT(*cp)) { - delay = delay * 10 + (*cp++ - '0'); - } - delay *= 10; - if (*cp == '.') { - cp++; - if (ISDIGIT(*cp)) { - delay += *cp++ - '0'; - } - while (ISDIGIT(*cp)) cp++; - } - if (*cp == '*') { - delay *= affcnt; - cp++; - } - while (*cp) - (*outc)(*cp++); - if (delay != 0 && - ospeed > 0 && - ospeed < (sizeof tens_of_ms_p_char / sizeof tens_of_ms_p_char[0])) { - delay = (delay + tens_of_ms_p_char[ospeed] - 1) / - tens_of_ms_p_char[ospeed]; - while (delay--) (*outc)(PC); - } - return(1); -} - -/* - * That's all, folks... - */ diff --git a/lib/ack/libm2/absd.c b/lib/ack/libm2/absd.c deleted file mode 100644 index 07aa4d242..000000000 --- a/lib/ack/libm2/absd.c +++ /dev/null @@ -1,18 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* - Module: double abs function - Author: Ceriel J.H. Jacobs - Version: $Header$ -*/ -#ifndef NOFLOAT -double -absd(i) - double i; -{ - return i >= 0 ? i : -i; -} -#endif diff --git a/lib/ack/libm2/absf.e b/lib/ack/libm2/absf.e deleted file mode 100644 index c8a9b880a..000000000 --- a/lib/ack/libm2/absf.e +++ /dev/null @@ -1,30 +0,0 @@ -# -; -; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. -; See the copyright notice in the ACK home directory, in the file "Copyright". -; -; -; Module: REAL abs function -; Author: Ceriel J.H. Jacobs -; Version: $Header$ -; - mes 2,_EM_WSIZE,_EM_PSIZE - exp $absf - pro $absf,0 - mes 5 - mes 9,8 - lal 0 - loi _EM_FSIZE - zrf _EM_FSIZE - cmf _EM_FSIZE - zlt *3 - lal 0 - loi _EM_FSIZE - bra *4 -3 - lal 0 - loi _EM_FSIZE - ngf _EM_FSIZE -4 - ret _EM_FSIZE - end 0 diff --git a/lib/ack/libm2/absi.c b/lib/ack/libm2/absi.c deleted file mode 100644 index 6306dbfb9..000000000 --- a/lib/ack/libm2/absi.c +++ /dev/null @@ -1,15 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* - Module: integer abs function - Author: Ceriel J.H. Jacobs - Version: $Header$ -*/ - -absi(i) -{ - return i >= 0 ? i : -i; -} diff --git a/lib/ack/libm2/absl.c b/lib/ack/libm2/absl.c deleted file mode 100644 index 27f5ddb0d..000000000 --- a/lib/ack/libm2/absl.c +++ /dev/null @@ -1,16 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* - Module: longint abs function - Author: Ceriel J.H. Jacobs - Version: $Header$ -*/ -long -absl(i) - long i; -{ - return i >= 0 ? i : -i; -} diff --git a/lib/ack/libm2/blockmove.c b/lib/ack/libm2/blockmove.c deleted file mode 100644 index 18f2d3b5c..000000000 --- a/lib/ack/libm2/blockmove.c +++ /dev/null @@ -1,23 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* - Module: block moves - Author: Ceriel J.H. Jacobs - Version: $Header$ -*/ - -#if _EM_WSIZE==_EM_PSIZE -typedef unsigned pcnt; -#else -typedef unsigned long pcnt; -#endif - -blockmove(siz, dst, src) - pcnt siz; - register char *dst, *src; -{ - while (siz--) *dst++ = *src++; -} diff --git a/lib/ack/libm2/cap.c b/lib/ack/libm2/cap.c deleted file mode 100644 index 28f03b5e3..000000000 --- a/lib/ack/libm2/cap.c +++ /dev/null @@ -1,18 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* - Module: cap; implementation of CAP - Author: Ceriel J.H. Jacobs - Version: $Header$ -*/ - -cap(u) - unsigned u; -{ - register unsigned *p = &u; - - if (*p >= 'a' && *p <= 'z') *p += 'A'-'a'; -} diff --git a/lib/ack/libm2/catch.c b/lib/ack/libm2/catch.c deleted file mode 100644 index 378bac1cc..000000000 --- a/lib/ack/libm2/catch.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* - Module: default modula-2 trap handler - Author: Ceriel J.H. Jacobs - Version: $Header$ -*/ -#include -#include -#include - -static struct errm { - int errno; - char *errmes; -} errors[] = { - { EARRAY, "array bound error"}, - { ERANGE, "range bound error"}, - { ESET, "set bound error"}, - { EIOVFL, "integer overflow"}, - { EFOVFL, "real overflow"}, - { EFUNFL, "real underflow"}, - { EIDIVZ, "divide by 0"}, - { EFDIVZ, "divide by 0.0"}, - { EIUND, "undefined integer"}, - { EFUND, "undefined real"}, - { ECONV, "conversion error"}, - - { ESTACK, "stack overflow"}, - { EHEAP, "heap overflow"}, - { EILLINS, "illegal instruction"}, - { EODDZ, "illegal size argument"}, - { ECASE, "case error"}, - { EMEMFLT, "addressing non existent memory"}, - { EBADPTR, "bad pointer used"}, - { EBADPC, "program counter out of range"}, - { EBADLAE, "bad argument of lae"}, - { EBADMON, "bad monitor call"}, - { EBADLIN, "argument if LIN too high"}, - { EBADGTO, "GTO descriptor error"}, - - { M2_TOOLARGE, "stack size of process too large"}, - { M2_TOOMANY, "too many nested traps + handlers"}, - { M2_NORESULT, "no RETURN from function procedure"}, - { M2_UOVFL, "cardinal overflow"}, - { M2_FORCH, "(warning) FOR-loop control variable was changed in the body"}, - { M2_UUVFL, "cardinal underflow"}, - { M2_INTERNAL, "internal error; ask an expert for help"}, - { M2_UNIXSIG, "got a unix signal"}, - { -1, 0} -}; - -catch(trapno) - int trapno; -{ - register struct errm *ep = &errors[0]; - char *errmessage; - char buf[20]; - register char *p, *s; - - while (ep->errno != trapno && ep->errmes != 0) ep++; - if (p = ep->errmes) { - while (*p) p++; - _Traps__Message(ep->errmes, 0, (int) (p - ep->errmes), 1); - } - else { - int i = trapno; - static char q[] = "error number xxxxxxxxxxxxx"; - - p = &q[13]; - s = buf; - if (i < 0) { - i = -i; - *p++ = '-'; - } - do - *s++ = i % 10 + '0'; - while (i /= 10); - while (s > buf) *p++ = *--s; - *p = 0; - _Traps__Message(q, 0, (int) (p - q), 1); - } -#if !defined(__em24) && !defined(__em44) && !defined(__em22) - if (trapno == M2_UNIXSIG) { - extern int __signo; - signal(__signo, SIG_DFL); - _cleanup(); - kill(getpid(), __signo); - _exit(trapno); - } -#endif - if (trapno != M2_FORCH) { - _cleanup(); - _exit(trapno); - } - SIG(catch); -} diff --git a/lib/ack/libm2/confarray.c b/lib/ack/libm2/confarray.c deleted file mode 100644 index d282a270c..000000000 --- a/lib/ack/libm2/confarray.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* - Module: runtime support for conformant arrays - Author: Ceriel J.H. Jacobs - Version: $Header$ -*/ -#include - -#ifndef EM_WSIZE -#define EM_WSIZE _EM_WSIZE -#define EM_PSIZE _EM_PSIZE -#endif - -#if EM_WSIZE==EM_PSIZE -typedef unsigned pcnt; -#else -typedef unsigned long pcnt; -#endif - -struct descr { - char *addr; - int low; - unsigned int highminlow; - unsigned int size; -}; - -static struct descr *descrs[10]; -static struct descr **ppdescr = descrs; - -pcnt -new_stackptr(pdscr, a) - struct descr *pdscr; -{ - register struct descr *pdescr = pdscr; - pcnt size = (((pdescr->highminlow + 1) * pdescr->size + - (EM_WSIZE - 1)) & ~(EM_WSIZE - 1)); - - if (ppdescr >= &descrs[10]) { - /* to many nested traps + handlers ! */ - TRP(M2_TOOMANY); - } - *ppdescr++ = pdescr; - if ((char *) &a - (char *) &pdscr > 0) { - /* stack grows downwards */ - return - size; - } - return size; -} - -copy_array(pp, a) - char *pp; -{ - register char *p = pp; - register char *q; - register pcnt sz; - char dummy; - - ppdescr--; - sz = ((*ppdescr)->highminlow + 1) * (*ppdescr)->size; - - if ((char *) &a - (char *) &pp > 0) { - (*ppdescr)->addr = q = (char *) &a; - } - else (*ppdescr)->addr = q = (char *) &a - - ((sz + (EM_WSIZE - 1)) & ~ (EM_WSIZE - 1)); - - while (sz--) *q++ = *p++; -} diff --git a/lib/ack/libm2/dvi.c b/lib/ack/libm2/dvi.c deleted file mode 100644 index d72076def..000000000 --- a/lib/ack/libm2/dvi.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* - Module: implementation of DIV and MOD - Author: Ceriel J.H. Jacobs - Version: $Header$ - Reason: We cannot use DVI and RMI, because DVI rounds towards 0 - and Modula-2 requires truncation -*/ - -#include - -int -dvi(j,i) - int j,i; -{ - if (j == 0) TRP(EIDIVZ); - if ((i < 0) != (j < 0)) { - if (i < 0) i = -i; - else j = -j; - return -((i+j-1)/j); - } - else return i/j; -} - -long -dvil(j,i) - long j,i; -{ - if (j == 0) TRP(EIDIVZ); - if ((i < 0) != (j < 0)) { - if (i < 0) i = -i; - else j = -j; - return -((i+j-1)/j); - } - else return i/j; -} - -int -rmi(j,i) - int j,i; -{ - if (j == 0) TRP(EIDIVZ); - if (i == 0) return 0; - if ((i < 0) != (j < 0)) { - if (i < 0) i = -i; - else j = -j; - return j*((i+j-1)/j)-i; - } - else return i%j; -} - -long -rmil(j,i) - long j,i; -{ - if (j == 0) TRP(EIDIVZ); - if (i == 0) return 0L; - if ((i < 0) != (j < 0)) { - if (i < 0) i = -i; - else j = -j; - return j*((i+j-1)/j)-i; - } - else return i%j; -} diff --git a/lib/ack/libm2/halt.c b/lib/ack/libm2/halt.c deleted file mode 100644 index 0c257d0db..000000000 --- a/lib/ack/libm2/halt.c +++ /dev/null @@ -1,37 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* - Module: program termination routines - Author: Ceriel J.H. Jacobs - Version: $Header$ -*/ -#define MAXPROCS 32 - -static int callindex = 0; -static int (*proclist[MAXPROCS])(); - -_cleanup() -{ - while (--callindex >= 0) - (*proclist[callindex])(); - callindex = 0; -} - -CallAtEnd(p) - int (*p)(); -{ - if (callindex >= MAXPROCS) { - return 0; - } - proclist[callindex++] = p; - return 1; -} - -halt() -{ - _cleanup(); - _exit(0); -} diff --git a/lib/ack/libm2/head_m2.e b/lib/ack/libm2/head_m2.e deleted file mode 100644 index 6de740921..000000000 --- a/lib/ack/libm2/head_m2.e +++ /dev/null @@ -1,63 +0,0 @@ -# -; -; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. -; See the copyright notice in the ACK home directory, in the file "Copyright". -; -; -; Module: Modula-2 runtime startoff -; Author: Ceriel J.H. Jacobs -; Version: $Header$ -; - - mes 2,_EM_WSIZE,_EM_PSIZE - - exa handler - exa argv - exa argc - exa MainLB - exa bkillbss - exp $catch - exp $init - inp $trap_handler - -bkillbss - bss _EM_PSIZE,0,0 - - exp $_m_a_i_n - pro $_m_a_i_n, 0 - - lor 0 - lae MainLB - sti _EM_PSIZE - - lal _EM_WSIZE - loi _EM_PSIZE - lae argv ; save argument pointer - sti _EM_PSIZE - - lol 0 - ste argc ; save argument count - - lpi $trap_handler - sig - asp _EM_PSIZE - cal $init - cal $__M2M_ - cal $halt - loc 0 ; should not get here - ret _EM_WSIZE - end - - pro $trap_handler,0 - lpi $trap_handler - sig - lol 0 ; trap number - lae handler - loi _EM_PSIZE - lpi $catch - lae handler - sti _EM_PSIZE - cai - asp _EM_PSIZE+_EM_WSIZE - rtt - end 0 diff --git a/lib/ack/libm2/init.c b/lib/ack/libm2/init.c deleted file mode 100644 index 60e54cf34..000000000 --- a/lib/ack/libm2/init.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* - Module: initialization and some global vars - Author: Ceriel J.H. Jacobs - Version: $Header$ -*/ - -#include -#include -#include - -/* map unix signals onto EM traps */ -init() -{ - sigtrp(M2_UNIXSIG, SIGHUP); - sigtrp(M2_UNIXSIG, SIGINT); - sigtrp(M2_UNIXSIG, SIGQUIT); - sigtrp(EILLINS, SIGILL); - sigtrp(M2_UNIXSIG, SIGTRAP); -#ifdef SIGIOT - sigtrp(M2_UNIXSIG, SIGIOT); -#endif -#if SIGEMT - sigtrp(M2_UNIXSIG, SIGEMT); -#endif - sigtrp(M2_UNIXSIG, SIGFPE); - sigtrp(M2_UNIXSIG, SIGBUS); - sigtrp(M2_UNIXSIG, SIGSEGV); -#ifdef SIGSYS - sigtrp(EBADMON, SIGSYS); -#endif - sigtrp(M2_UNIXSIG, SIGPIPE); - sigtrp(M2_UNIXSIG, SIGALRM); - sigtrp(M2_UNIXSIG, SIGTERM); -} - -killbss() -{ - /* Fill bss with junk? Make lots of VM pages dirty? No way! */ -} - -extern int catch(); - -int (*handler)() = catch; -char **argv; -int argc; -char *MainLB; diff --git a/lib/ack/libm2/load.c b/lib/ack/libm2/load.c deleted file mode 100644 index 3ec6321b2..000000000 --- a/lib/ack/libm2/load.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* - Module: get value on stack, byte by byte - Author: Ceriel J.H. Jacobs - Version: $Header$ -*/ - -#include - -#ifndef EM_WSIZE -#define EM_WSIZE _EM_WSIZE -#define EM_PSIZE _EM_PSIZE -#endif - -#if EM_WSIZE==EM_PSIZE -typedef unsigned pcnt; -#else -typedef long pcnt; -#endif - -load(siz, addr, p) - register char *addr; - register pcnt siz; -{ - /* Make sure, that a value with a size that could have been - handled by the LOI instruction ends up at the same place, - where it would, were the LOI instruction used. - */ - register char *q = (char *) &p; - char t[4]; - - if (siz < EM_WSIZE && EM_WSIZE % siz == 0) { - /* as long as EM_WSIZE <= 4 ... */ - if (siz != 2) TRP(M2_INTERNAL); /* internal error */ - q = &t[0]; - } - while (siz--) *q++ = *addr++; - if (q - t == 2) { - *((unsigned *)(&p)) = *((unsigned short *) (&t[0])); - } -} diff --git a/lib/ack/libm2/par_misc.e b/lib/ack/libm2/par_misc.e deleted file mode 100644 index b0e86969e..000000000 --- a/lib/ack/libm2/par_misc.e +++ /dev/null @@ -1,175 +0,0 @@ -# -; -; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. -; See the copyright notice in the ACK home directory, in the file "Copyright". -; - -; -; Module: coroutine primitives -; Author: Kees Bot, Edwin Scheffer, Ceriel Jacobs -; Version: $Header$ -; - - mes 2,_EM_WSIZE,_EM_PSIZE - - ; topsize takes care of two things: - ; - given a stack-break, - ; it computes the size of the chunk of memory needed to save the stack; - ; - also, if this stack-break = 0, it creates one, assuming that caller is - ; the stack-break. - ; - ; This implementation assumes a continuous stack growing downwards - - exp $topsize -#ifdef __sparc - inp $topsize2 - pro $topsize, 0 - mes 11 - zer _EM_PSIZE - lal 0 - loi _EM_PSIZE - cal $topsize2 - asp 2*_EM_PSIZE - lfr _EM_WSIZE - ret _EM_WSIZE - end 0 - pro $topsize2, (3*_EM_WSIZE+3*_EM_PSIZE) -#else - pro $topsize, (3*_EM_WSIZE+3*_EM_PSIZE) -#endif - ; local space for line-number, ignoremask, filename, stack-break, size, - ; and stack-pointer (see the topsave routine) - mes 11 - lal 0 - loi _EM_PSIZE - loi _EM_PSIZE ; stack-break or 0 - zer _EM_PSIZE - cmp - zne *1 - lxl 0 - dch ; local base of caller -#ifdef __sparc - dch ; because of the extra layer -#endif - lal 0 - loi _EM_PSIZE - sti _EM_PSIZE -1 - lal 0 - loi _EM_PSIZE - loi _EM_PSIZE - lpb ; convert this local base to an argument base. - ; An implementation of a sort of "topsize" EM - ; instruction should take a local base, and save - ; the whole frame. - - lor 1 ; stack-break SP - sbs _EM_WSIZE ; stack-break-SP - ret _EM_WSIZE ; return size of block to be saved - end 3*_EM_WSIZE+3*_EM_PSIZE - - exp $topsave -#ifdef __sparc - inp $topsave2 - pro $topsave,0 - mes 11 - lal 0 - loi 2*_EM_PSIZE - cal $topsave2 - asp 2*_EM_PSIZE - lfr _EM_WSIZE - ret _EM_WSIZE - end 0 - pro $topsave2,0 -#else - pro $topsave, 0 -#endif - mes 11 - loe 0 - lae 4 ; load line number and file name - loi _EM_PSIZE - lim ; ignore mask - lor 0 ; LB - lal 0 - loi _EM_PSIZE ; stack-break - lpb - lor 1 - sbs _EM_WSIZE - loc _EM_WSIZE - adu _EM_WSIZE ; gives size - dup _EM_WSIZE - stl 0 ; save size - lor 1 ; SP (the SP BEFORE pushing) - lor 1 ; SP (address of stack top to save) - lal _EM_PSIZE ; area - loi _EM_PSIZE - lol 0 ; size - bls _EM_WSIZE ; move whole block - asp 3*_EM_PSIZE+3*_EM_WSIZE ; remove the lot from the stack - loc 1 - ret _EM_WSIZE ; return 1 - end 0 - -sv - bss _EM_PSIZE,0,0 - - exp $topload -#ifdef __sparc - inp $topload1 - pro $topload,0 - lal 0 - loi _EM_PSIZE - cal $topload1 - asp _EM_PSIZE - lfr _EM_WSIZE - ret _EM_WSIZE - end 0 - pro $topload1, 0 -#else - pro $topload, 0 -#endif - mes 11 - - lal 0 - loi _EM_PSIZE - lae sv - sti _EM_PSIZE ; saved parameter - - lxl 0 -2 - dup _EM_PSIZE - adp -3*_EM_PSIZE - lal 0 - loi _EM_PSIZE ; compare target SP with current LB to see if we must - loi _EM_PSIZE - cmp ; find another LB first - zgt *1 - dch ; just follow dynamic chain to make sure we find - ; a legal one - bra *2 -1 - str 0 - - lae sv - loi _EM_PSIZE - loi _EM_PSIZE ; load indirect to - str 1 ; restore SP - asp 0-_EM_PSIZE ; to stop int from complaining about non-existent memory - lae sv - loi _EM_PSIZE ; source address - lor 1 - adp _EM_PSIZE ; destination address - lae sv - loi _EM_PSIZE - adp _EM_PSIZE - loi _EM_WSIZE ; size of block - bls _EM_WSIZE - asp _EM_PSIZE+_EM_WSIZE ; drop size + SP - str 0 ; restore local base - sim ; ignore mask - lae 4 - sti _EM_PSIZE - ste 0 ; line and file - loc 0 - ret _EM_WSIZE - end 0 diff --git a/lib/ack/libm2/random.mod b/lib/ack/libm2/random.mod deleted file mode 100755 index 826e99f69..000000000 --- a/lib/ack/libm2/random.mod +++ /dev/null @@ -1,58 +0,0 @@ -(* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*) - -(*$R-*) -IMPLEMENTATION MODULE random; -(* - Module: random numbers - Author: Ceriel J.H. Jacobs - Version: $Header$ -*) - - FROM Unix IMPORT getpid, time; - TYPE index = [1..55]; - - VAR X: ARRAY index OF CARDINAL; - j, k: index; - tm: LONGINT; - - PROCEDURE Random(): CARDINAL; - BEGIN - IF k-1 <= 0 THEN k := 55; ELSE DEC(k) END; - IF j-1 <= 0 THEN j := 55; ELSE DEC(j) END; - X[k] := X[k] + X[j]; - RETURN X[k] - END Random; - - PROCEDURE Uniform (lwb, upb: CARDINAL): CARDINAL; - BEGIN - IF upb <= lwb THEN RETURN lwb; END; - RETURN lwb + (Random() MOD (upb - lwb + 1)); - END Uniform; - - PROCEDURE StartSeed(seed: CARDINAL); - VAR v: CARDINAL; - BEGIN - FOR k := 1 TO 55 DO - seed := 1297 * seed + 123; - X[k] := seed; - END; - FOR k := 1 TO 15 DO - j := tm MOD 55D + 1D; - v := X[j]; - tm := tm DIV 7D; - j := tm MOD 55D + 1D; - X[j] := v; - tm := tm * 3D; - END; - k := 1; - j := 25; - END StartSeed; - -BEGIN - tm := time(NIL); - X[1] := tm; - StartSeed(CARDINAL(getpid()) * X[1]); -END random. diff --git a/lib/ack/libm2/rcka.c b/lib/ack/libm2/rcka.c deleted file mode 100644 index 6178bd6fb..000000000 --- a/lib/ack/libm2/rcka.c +++ /dev/null @@ -1,25 +0,0 @@ -/* - * (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - * - * - * Module: range checks for INTEGER, now for array indexing - * Author: Ceriel J.H. Jacobs - * Version: $Header$ -*/ - -#include - -extern TRP(); - -struct array_descr { - int lbound; - int n_elts_min_one; - unsigned size; -}; - -rcka(descr, indx) - struct array_descr *descr; -{ - if (indx < 0 || indx > descr->n_elts_min_one) TRP(EARRAY); -} diff --git a/lib/ack/libm2/rcki.c b/lib/ack/libm2/rcki.c deleted file mode 100644 index 289646170..000000000 --- a/lib/ack/libm2/rcki.c +++ /dev/null @@ -1,23 +0,0 @@ -/* - * (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - * - * - * Module: range checks for INTEGER - * Author: Ceriel J.H. Jacobs - * Version: $Header$ -*/ - -#include - -extern TRP(); - -struct range_descr { - int low, high; -}; - -rcki(descr, val) - struct range_descr *descr; -{ - if (val < descr->low || val > descr->high) TRP(ERANGE); -} diff --git a/lib/ack/libm2/rckil.c b/lib/ack/libm2/rckil.c deleted file mode 100644 index 2c4328d4c..000000000 --- a/lib/ack/libm2/rckil.c +++ /dev/null @@ -1,24 +0,0 @@ -/* - * (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - * - * - * Module: range checks for LONGINT - * Author: Ceriel J.H. Jacobs - * Version: $Header$ -*/ - -#include - -extern TRP(); - -struct range_descr { - long low, high; -}; - -rckil(descr, val) - struct range_descr *descr; - long val; -{ - if (val < descr->low || val > descr->high) TRP(ERANGE); -} diff --git a/lib/ack/libm2/rcku.c b/lib/ack/libm2/rcku.c deleted file mode 100644 index 8dfb3204f..000000000 --- a/lib/ack/libm2/rcku.c +++ /dev/null @@ -1,24 +0,0 @@ -/* - * (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - * - * - * Module: range checks for CARDINAL - * Author: Ceriel J.H. Jacobs - * Version: $Header$ -*/ - -#include - -extern TRP(); - -struct range_descr { - unsigned low, high; -}; - -rcku(descr, val) - struct range_descr *descr; - unsigned val; -{ - if (val < descr->low || val > descr->high) TRP(ERANGE); -} diff --git a/lib/ack/libm2/rckul.c b/lib/ack/libm2/rckul.c deleted file mode 100644 index 86647502c..000000000 --- a/lib/ack/libm2/rckul.c +++ /dev/null @@ -1,24 +0,0 @@ -/* - * (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - * - * - * Module: range checks for LONGCARD - * Author: Ceriel J.H. Jacobs - * Version: $Header$ -*/ - -#include - -extern TRP(); - -struct range_descr { - unsigned long low, high; -}; - -rckul(descr, val) - struct range_descr *descr; - unsigned long val; -{ - if (val < descr->low || val > descr->high) TRP(ERANGE); -} diff --git a/lib/ack/libm2/sigtrp.c b/lib/ack/libm2/sigtrp.c deleted file mode 100644 index 6dc777d69..000000000 --- a/lib/ack/libm2/sigtrp.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* - Module: Mapping of Unix signals to EM traps - (only when not using the MON instruction) - Author: Ceriel J.H. Jacobs - Version: $Header$ -*/ - -#if !defined(__em22) && !defined(__em24) && !defined(__em44) - -#define EM_trap(n) TRP(n) /* define to whatever is needed to cause the trap */ - -#include -#include - -int __signo; - -static int __traps[] = { - -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, - -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, - -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -}; - -static void -__ctchsig(signo) -{ - signal(signo,__ctchsig); -#ifdef __BSD4_2 - sigsetmask(sigblock(0) & ~(1<<(signo - 1))); -#endif - __signo = signo; - EM_trap(__traps[signo]); -} - -int -sigtrp(trapno, signo) -{ - /* Let Unix signal signo cause EM trap trapno to occur. - If trapno = -2, restore default, - If trapno = -3, ignore. - Return old trapnumber. - Careful, this could be -2 or -3; But return value of -1 - indicates failure, with error number in errno. - */ - extern int errno; - void (*ctch)() = __ctchsig; - void (*oldctch)(); - int oldtrap; - - if (signo <= 0 || signo >= sizeof(__traps)/sizeof(__traps[0])) { - errno = EINVAL; - return -1; - } - - if (trapno == -3) - ctch = SIG_IGN; - else if (trapno == -2) - ctch = SIG_DFL; - else if (trapno >= 0 && trapno <= 252) - ; - else { - errno = EINVAL; - return -1; - } - - oldtrap = __traps[signo]; - - if ((oldctch = signal(signo, ctch)) == (void (*)())-1) /* errno set by signal */ - return -1; - - else if (oldctch == SIG_IGN) { - signal(signo, SIG_IGN); - } - else __traps[signo] = trapno; - - return oldtrap; -} -#endif diff --git a/lib/ack/libm2/stackprio.c b/lib/ack/libm2/stackprio.c deleted file mode 100644 index ecd3fee2a..000000000 --- a/lib/ack/libm2/stackprio.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* - Module: Dummy priority routines - Author: Ceriel J.H. Jacobs - Version: $Header$ -*/ - -static unsigned prio = 0; - -stackprio(n) - unsigned n; -{ - unsigned old = prio; - - if (n > prio) prio = n; - return old; -} - -unstackprio(n) - unsigned n; -{ - prio = n; -} diff --git a/lib/ack/libm2/store.c b/lib/ack/libm2/store.c deleted file mode 100644 index d69aa4023..000000000 --- a/lib/ack/libm2/store.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* - Module: store values from stack, byte by byte - Author: Ceriel J.H. Jacobs - Version: $Header$ -*/ - -#include - -#ifndef EM_WSIZE -#define EM_WSIZE _EM_WSIZE -#define EM_PSIZE _EM_PSIZE -#endif - -#if EM_WSIZE==EM_PSIZE -typedef unsigned pcnt; -#else -typedef long pcnt; -#endif - -store(siz, addr, p) - register char *addr; - register pcnt siz; -{ - /* Make sure, that a value with a size that could have been - handled by the LOI instruction is handled as if it was - loaded with the LOI instruction. - */ - register char *q = (char *) &p; - char t[4]; - - if (siz < EM_WSIZE && EM_WSIZE % siz == 0) { - /* as long as EM_WSIZE <= 4 ... */ - if (siz != 2) TRP(M2_INTERNAL); /* internal error */ - *((unsigned short *) (&t[0])) = *((unsigned *) q); - q = &t[0]; - } - while (siz--) *addr++ = *q++; -} diff --git a/lib/ack/libm2/ucheck.c b/lib/ack/libm2/ucheck.c deleted file mode 100644 index 411a7ce33..000000000 --- a/lib/ack/libm2/ucheck.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - * - * - * Module: CARDINAL operations with overflow checking - * Author: Ceriel J.H. Jacobs - * Version: $Header$ -*/ - -#ifndef EM_WSIZE -#define EM_WSIZE _EM_WSIZE -#endif -#ifndef EM_LSIZE -#define EM_LSIZE _EM_LSIZE -#endif - -#include - -#define MAXCARD ((unsigned)-1) -#if EM_WSIZE < EM_LSIZE -#define MAXLONGCARD ((unsigned long) -1L) -#endif - -adduchk(a,b) - unsigned a,b; -{ - if (MAXCARD - a < b) TRP(M2_UOVFL); -} - -#if EM_WSIZE < EM_LSIZE -addulchk(a,b) - unsigned long a,b; -{ - if (MAXLONGCARD - a < b) TRP(M2_UOVFL); -} -#endif - -muluchk(a,b) - unsigned a,b; -{ - if (a != 0 && MAXCARD/a < b) TRP(M2_UOVFL); -} - -#if EM_WSIZE < EM_LSIZE -mululchk(a,b) - unsigned long a,b; -{ - if (a != 0 && MAXLONGCARD/a < b) TRP(M2_UOVFL); -} -#endif - -subuchk(a,b) - unsigned a,b; -{ - if (b < a) TRP(M2_UUVFL); -} - -#if EM_WSIZE < EM_LSIZE -subulchk(a,b) - unsigned long a,b; -{ - if (b < a) TRP(M2_UUVFL); -} -#endif diff --git a/lib/ack/libp/Makefile.in b/lib/ack/libp/Makefile.in deleted file mode 100644 index 3ca2fbd50..000000000 --- a/lib/ack/libp/Makefile.in +++ /dev/null @@ -1,83 +0,0 @@ -# Makefile for lib/ack/libp. - -CFLAGS="-O -I../h -wo" -#CC1 = $(CC) $(CFLAGS) -c - -LIBRARIES=libp - -libp_FILES=" \ - abi.c \ - abl.c \ - abr.c \ - arg.c \ - ass.c \ - asz.c \ - atn.c \ - bcp.c \ - bts.e \ - buff.c \ - catch.c \ - clock.c \ - cls.c \ - cvt.c \ - diag.c \ - dis.c \ - efl.c \ - eln.c \ - encaps.e \ - exp.c \ - fef.e \ - fif.e \ - get.c \ - gto.e \ - head_pc.e \ - hlt.c \ - hol0.e \ - incpt.c \ - ini.c \ - log.c \ - mdi.c \ - mdl.c \ - new.c \ - nfa.c \ - nobuff.c \ - notext.c \ - opn.c \ - outcpt.c \ - pac.c \ - pclose.c \ - pcreat.c \ - pentry.c \ - perrno.c \ - pexit.c \ - popen.c \ - put.c \ - rcka.c \ - rdc.c \ - rdi.c \ - rdl.c \ - rdr.c \ - rf.c \ - rln.c \ - rnd.c \ - sav.e \ - sig.e \ - sin.c \ - sqt.c \ - string.c \ - trap.e \ - trp.e \ - unp.c \ - uread.c \ - uwrite.c \ - wdw.c \ - wf.c \ - wrc.c \ - wrf.c \ - wri.c \ - wrl.c \ - wrr.c \ - wrs.c \ - wrz.c" - -TYPE=ack diff --git a/lib/ack/libp/abi.c b/lib/ack/libp/abi.c deleted file mode 100644 index abfe4e9be..000000000 --- a/lib/ack/libp/abi.c +++ /dev/null @@ -1,23 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* Author: J.W. Stevenson */ - -int _abi(i) int i; { - return(i>=0 ? i : -i); -} diff --git a/lib/ack/libp/abl.c b/lib/ack/libp/abl.c deleted file mode 100644 index 9ffbfbe96..000000000 --- a/lib/ack/libp/abl.c +++ /dev/null @@ -1,23 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* Author: J.W. Stevenson */ - -long _abl(i) long i; { - return(i>=0 ? i : -i); -} diff --git a/lib/ack/libp/abr.c b/lib/ack/libp/abr.c deleted file mode 100644 index 9a8c0bdfd..000000000 --- a/lib/ack/libp/abr.c +++ /dev/null @@ -1,23 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* Author: J.W. Stevenson */ - -double _abr(r) double r; { - return(r>=0 ? r : -r); -} diff --git a/lib/ack/libp/arg.c b/lib/ack/libp/arg.c deleted file mode 100644 index fdbf14c3f..000000000 --- a/lib/ack/libp/arg.c +++ /dev/null @@ -1,56 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* Author: J.W. Stevenson */ - -/* function argc:integer; extern; */ -/* function argv(i:integer):string; extern; */ -/* procedure argshift; extern; */ -/* function environ(i:integer):string; extern; */ - -extern int _pargc; -extern char **_pargv; -extern char ***_penviron; - -int argc() { - return(_pargc); -} - -char *argv(i) { - if (i >= _pargc) - return(0); - return(_pargv[i]); -} - -argshift() { - - if (_pargc > 1) { - --_pargc; - _pargv++; - } -} - -char *environ(i) { - char **p; char *q; - - if (p = *_penviron) - while (q = *p++) - if (i-- < 0) - return(q); - return(0); -} diff --git a/lib/ack/libp/ass.c b/lib/ack/libp/ass.c deleted file mode 100644 index 8522d9426..000000000 --- a/lib/ack/libp/ass.c +++ /dev/null @@ -1,33 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* Author: J.W. Stevenson */ - -#include -#include - -extern char *_hol0(); -extern _trp(); - -_ass(line,bool) int line,bool; { - - if (bool==0) { - LINO = line; - _trp(EASS); - } -} diff --git a/lib/ack/libp/asz.c b/lib/ack/libp/asz.c deleted file mode 100644 index 271b882da..000000000 --- a/lib/ack/libp/asz.c +++ /dev/null @@ -1,29 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* Author: J.W. Stevenson */ - -struct descr { - int low; - int diff; - int size; -}; - -int _asz(dp) struct descr *dp; { - return(dp->size * (dp->diff + 1)); -} diff --git a/lib/ack/libp/atn.c b/lib/ack/libp/atn.c deleted file mode 100644 index 320c18923..000000000 --- a/lib/ack/libp/atn.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - * - * Author: Ceriel J.H. Jacobs - */ - -/* $Header$ */ - -#define __NO_DEFS -#include - -#if __STDC__ -#include -#endif - -double -_atn(x) - double x; -{ - /* Algorithm and coefficients from: - "Software manual for the elementary functions" - by W.J. Cody and W. Waite, Prentice-Hall, 1980 - */ - - static double p[] = { - -0.13688768894191926929e+2, - -0.20505855195861651981e+2, - -0.84946240351320683534e+1, - -0.83758299368150059274e+0 - }; - static double q[] = { - 0.41066306682575781263e+2, - 0.86157349597130242515e+2, - 0.59578436142597344465e+2, - 0.15024001160028576121e+2, - 1.0 - }; - static double a[] = { - 0.0, - 0.52359877559829887307710723554658381, /* pi/6 */ - M_PI_2, - 1.04719755119659774615421446109316763 /* pi/3 */ - }; - - int neg = x < 0; - int n; - double g; - - if (neg) { - x = -x; - } - if (x > 1.0) { - x = 1.0/x; - n = 2; - } - else n = 0; - - if (x > 0.26794919243112270647) { /* 2-sqtr(3) */ - n = n + 1; - x = (((0.73205080756887729353*x-0.5)-0.5)+x)/ - (1.73205080756887729353+x); - } - - /* ??? avoid underflow ??? */ - - g = x * x; - x += x * g * POLYNOM3(g, p) / POLYNOM4(g, q); - if (n > 1) x = -x; - x += a[n]; - return neg ? -x : x; -} diff --git a/lib/ack/libp/bcp.c b/lib/ack/libp/bcp.c deleted file mode 100644 index ef8edf605..000000000 --- a/lib/ack/libp/bcp.c +++ /dev/null @@ -1,30 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* Author: J.W. Stevenson */ - -int _bcp(sz,y,x) int sz; unsigned char *y,*x; { - - while (--sz >= 0) { - if (*x < *y) - return(-1); - if (*x++ > *y++) - return(1); - } - return(0); -} diff --git a/lib/ack/libp/bts.e b/lib/ack/libp/bts.e deleted file mode 100644 index adb57f360..000000000 --- a/lib/ack/libp/bts.e +++ /dev/null @@ -1,56 +0,0 @@ -# -; $Header$ -; -; (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. -; -; This product is part of the Amsterdam Compiler Kit. -; -; Permission to use, sell, duplicate or disclose this software must be -; obtained in writing. Requests for such permissions may be sent to -; -; Dr. Andrew S. Tanenbaum -; Wiskundig Seminarium -; Vrije Universiteit -; Postbox 7161 -; 1007 MC Amsterdam -; The Netherlands -; -; - -; Author: J.W. Stevenson */ - - mes 2,_EM_WSIZE,_EM_PSIZE - -#define SIZE 0 -#define HIGH _EM_WSIZE -#define LOWB 2*_EM_WSIZE -#define BASE 3*_EM_WSIZE - -; _bts is called with four parameters: -; - the initial set (BASE) -; - low bound of range of bits (LOWB) -; - high bound of range of bits (HIGH) -; - set size in bytes (SIZE) - - exp $_bts - pro $_bts,0 - lal BASE ; address of initial set - lol SIZE - los _EM_WSIZE ; load initial set -1 - lol LOWB ; low bound - lol HIGH ; high bound - bgt *2 ; while low <= high - lol LOWB - lol SIZE - set ? ; create [low] - lol SIZE - ior ? ; merge with initial set - inl LOWB ; increment low bound - bra *1 ; loop back -2 - lal BASE - lol SIZE - sts _EM_WSIZE ; store result over initial set - ret 0 - end ? diff --git a/lib/ack/libp/buff.c b/lib/ack/libp/buff.c deleted file mode 100644 index 471025c48..000000000 --- a/lib/ack/libp/buff.c +++ /dev/null @@ -1,35 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* Author: J.W. Stevenson */ - -#include - -extern _flush(); - -/* procedure buff(var f:file of ?); */ - -buff(f) struct file *f; { - int sz; - - if ((f->flags & (0377|WRBIT)) != (MAGIC|WRBIT)) - return; - _flush(f); - sz = f->size; - f->count = f->buflen = (sz>PC_BUFLEN ? sz : PC_BUFLEN-PC_BUFLEN%sz); -} diff --git a/lib/ack/libp/catch.c b/lib/ack/libp/catch.c deleted file mode 100644 index 204a8a1cf..000000000 --- a/lib/ack/libp/catch.c +++ /dev/null @@ -1,154 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -#include -#include -#include - -/* to make it easier to patch ... */ -extern struct file *_curfil; - -static struct errm { - int errno; - char *errmes; -} errors[] = { - { EARRAY, "array bound error"}, - { ERANGE, "range bound error"}, - { ESET, "set bound error"}, - { EIOVFL, "integer overflow"}, - { EFOVFL, "real overflow"}, - { EFUNFL, "real underflow"}, - { EIDIVZ, "divide by 0"}, - { EFDIVZ, "divide by 0.0"}, - { EIUND, "undefined integer"}, - { EFUND, "undefined real"}, - { ECONV, "conversion error"}, - - { ESTACK, "stack overflow"}, - { EHEAP, "heap overflow"}, - { EILLINS, "illegal instruction"}, - { EODDZ, "illegal size argument"}, - { ECASE, "case error"}, - { EMEMFLT, "addressing non existent memory"}, - { EBADPTR, "bad pointer used"}, - { EBADPC, "program counter out of range"}, - { EBADLAE, "bad argument of lae"}, - { EBADMON, "bad monitor call"}, - { EBADLIN, "argument if LIN too high"}, - { EBADGTO, "GTO descriptor error"}, - - { EARGC, "more args expected" }, - { EEXP, "error in exp" }, - { ELOG, "error in ln" }, - { ESQT, "error in sqrt" }, - { EASS, "assertion failed" }, - { EPACK, "array bound error in pack" }, - { EUNPACK, "array bound error in unpack" }, - { EMOD, "only positive j in 'i mod j'" }, - { EBADF, "file not yet open" }, - { EFREE, "dispose error" }, - { EFUNASS, "function not assigned" }, - { EWIDTH, "illegal field width" }, - - { EWRITEF, "not writable" }, - { EREADF, "not readable" }, - { EEOF, "end of file" }, - { EFTRUNC, "truncated" }, - { ERESET, "reset error" }, - { EREWR, "rewrite error" }, - { ECLOSE, "close error" }, - { EREAD, "read error" }, - { EWRITE, "write error" }, - { EDIGIT, "digit expected" }, - { EASCII, "non-ASCII char read" }, - { -1, 0} -}; - -extern int _pargc; -extern char **_pargv; -extern char ***_penviron; - -extern char *_hol0(); -extern _trp(); -extern _exit(); -extern int _write(); - -_catch(erno) unsigned erno; { - register struct errm *ep = &errors[0]; - char *p,*q,*s,**qq; - char buf[20]; - unsigned i; - int j = erno; - char *pp[11]; - char xbuf[100]; - - qq = pp; - if (p = FILN) - *qq++ = p; - else - *qq++ = _pargv[0]; - - while (ep->errno != erno && ep->errmes != 0) ep++; - p = buf; - s = xbuf; - if (i = LINO) { - *qq++ = ", "; - do - *p++ = i % 10 + '0'; - while (i /= 10); - while (p > buf) *s++ = *--p; - } - *s++ = ':'; - *s++ = ' '; - *s++ = '\0'; - *qq++ = xbuf; - if ((erno & ~037) == 0140 && (_curfil->flags&0377)==MAGIC) { - /* file error */ - *qq++ = "file "; - *qq++ = _curfil->fname; - *qq++ = ": "; - } - if (ep->errmes) *qq++ = ep->errmes; - else { - *qq++ = "error number "; - *qq++ = s; - p = buf; - if (j < 0) { - j = -j; - *s++ = '-'; - } - do - *p++ = j % 10 + '0'; - while (j /= 10); - while (p > buf) *s++ = *--p; - *s = 0; - } - *qq++ = "\n"; - *qq = 0; - qq = pp; - while (q = *qq++) { - p = q; - while (*p) - p++; - if (_write(2,q,(int)(p-q)) < 0) - ; - } - _exit(erno); -error: - _trp(erno); -} diff --git a/lib/ack/libp/clock.c b/lib/ack/libp/clock.c deleted file mode 100644 index f5847696a..000000000 --- a/lib/ack/libp/clock.c +++ /dev/null @@ -1,47 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* Author: J.W. Stevenson */ - -/* function clock:integer; extern; */ - -extern int _times(); - -struct tbuf { - long utime; - long stime; - long cutime; - long cstime; -}; - -#ifndef EM_WSIZE -#define EM_WSIZE _EM_WSIZE -#endif - -int clock() { - struct tbuf t; - - _times(&t); - return( (int)(t.utime + t.stime) & -#if EM_WSIZE <= 2 - 077777 -#else - 0x7fffffffL -#endif - ); -} diff --git a/lib/ack/libp/cls.c b/lib/ack/libp/cls.c deleted file mode 100644 index f891a3658..000000000 --- a/lib/ack/libp/cls.c +++ /dev/null @@ -1,67 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* Author: J.W. Stevenson */ - -#include -#include - -extern struct file *_curfil; -extern _trp(); -extern _flush(); -extern _outcpt(); -extern int _close(); - -_xcls(f) struct file *f; { - - if ((f->flags & WRBIT) == 0) - return; - if ((f->flags & (TXTBIT|ELNBIT)) == TXTBIT) { -#ifdef CPM - *f->ptr = '\r'; - _outcpt(f); -#endif - *f->ptr = '\n'; - _outcpt(f); - } - _flush(f); -} - -_cls(f) struct file *f; { -#ifdef MAYBE - char *p; -#endif - - _curfil = f; - if ((f->flags&0377) != MAGIC) - return; -#ifdef MAYBE - p = f->bufadr; - if (f->ptr < p) - return; - if (f->buflen <= 0) - return; - p += f->buflen; - if (f->ptr >= p) - return; -#endif - _xcls(f); - if (_close(f->ufd) != 0) - _trp(ECLOSE); - f->flags = 0; -} diff --git a/lib/ack/libp/cvt.c b/lib/ack/libp/cvt.c deleted file mode 100644 index d3c2116dc..000000000 --- a/lib/ack/libp/cvt.c +++ /dev/null @@ -1,119 +0,0 @@ -/* $Header$ */ -#ifndef NOFLOAT - -#if __STDC__ -#include -#else -#include -#define DBL_MAX M_MAX_D -#endif - -static char *cvt(); -#define NDIGITS 128 - -char * -_ecvt(value, ndigit, decpt, sign) - double value; - int ndigit, *decpt, *sign; -{ - return cvt(value, ndigit, decpt, sign, 1); -} - -char * -_fcvt(value, ndigit, decpt, sign) - double value; - int ndigit, *decpt, *sign; -{ - return cvt(value, ndigit, decpt, sign, 0); -} - -static struct powers_of_10 { - double pval; - double rpval; - int exp; -} p10[] = { - 1.0e32, 1.0e-32, 32, - 1.0e16, 1.0e-16, 16, - 1.0e8, 1.0e-8, 8, - 1.0e4, 1.0e-4, 4, - 1.0e2, 1.0e-2, 2, - 1.0e1, 1.0e-1, 1, - 1.0e0, 1.0e0, 0 -}; - -static char * -cvt(value, ndigit, decpt, sign, ecvtflag) - double value; - int ndigit, *decpt, *sign; -{ - static char buf[NDIGITS+1]; - register char *p = buf; - register char *pe; - - if (ndigit < 0) ndigit = 0; - if (ndigit > NDIGITS) ndigit = NDIGITS; - pe = &buf[ndigit]; - buf[0] = '\0'; - - *sign = 0; - if (value < 0) { - *sign = 1; - value = -value; - } - - *decpt = 0; - if (value >= DBL_MAX) { - value = DBL_MAX; - } - if (value != 0.0) { - register struct powers_of_10 *pp = &p10[0]; - - if (value >= 10.0) do { - while (value >= pp->pval) { - value *= pp->rpval; - *decpt += pp->exp; - } - } while ((++pp)->exp > 0); - - pp = &p10[0]; - if (value < 1.0) do { - while (value * pp->pval < 10.0) { - value *= pp->pval; - *decpt -= pp->exp; - } - } while ((++pp)->exp > 0); - - (*decpt)++; /* because now value in [1.0, 10.0) */ - } - if (! ecvtflag) { - /* for fcvt() we need ndigit digits behind the dot */ - pe += *decpt; - if (pe > &buf[NDIGITS]) pe = &buf[NDIGITS]; - } - while (p <= pe) { - *p++ = (int)value + '0'; - value = 10.0 * (value - (int)value); - } - if (pe >= buf) { - p = pe; - *p += 5; /* round of at the end */ - while (*p > '9') { - *p = '0'; - if (p > buf) ++*--p; - else { - *p = '1'; - ++*decpt; - if (! ecvtflag) { - /* maybe add another digit at the end, - because the point was shifted right - */ - if (pe > buf) *pe = '0'; - pe++; - } - } - } - *pe = '\0'; - } - return buf; -} -#endif diff --git a/lib/ack/libp/diag.c b/lib/ack/libp/diag.c deleted file mode 100644 index ea16c0b7d..000000000 --- a/lib/ack/libp/diag.c +++ /dev/null @@ -1,34 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* Author: J.W. Stevenson */ - -#include - -/* procedure diag(var f:text); */ - -diag(f) struct file *f; { - - f->ptr = f->bufadr; - f->flags = WRBIT|EOFBIT|ELNBIT|TXTBIT|MAGIC; - f->fname = "DIAG"; - f->ufd = 2; - f->size = 1; - f->count = 1; - f->buflen = 1; -} diff --git a/lib/ack/libp/dis.c b/lib/ack/libp/dis.c deleted file mode 100644 index 7d8c738e2..000000000 --- a/lib/ack/libp/dis.c +++ /dev/null @@ -1,87 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* Author: J.W. Stevenson */ - -#include - -#define assert() /* nothing */ - -/* - * use circular list of free blocks from low to high addresses - * _highp points to free block with highest address - */ -struct adm { - struct adm *next; - int size; -}; - -extern struct adm *_lastp; -extern struct adm *_highp; -extern _trp(); - -static int merge(p1,p2) struct adm *p1,*p2; { - struct adm *p; - - p = (struct adm *)((char *)p1 + p1->size); - if (p > p2) - _trp(EFREE); - if (p != p2) - return(0); - p1->size += p2->size; - p1->next = p2->next; - return(1); -} - -_dis(n,pp) int n; struct adm **pp; { - struct adm *p1,*p2; - - /* - * NOTE: dispose only objects whose size is a multiple of sizeof(*pp). - * this is always true for objects allocated by _new() - */ - n = ((n+sizeof(*p1)-1) / sizeof(*p1)) * sizeof(*p1); - if (n == 0) - return; - if ((p1= *pp) == (struct adm *) 0) - _trp(EFREE); - p1->size = n; - if ((p2 = _highp) == 0) /*p1 is the only free block*/ - p1->next = p1; - else { - if (p2 > p1) { - /*search for the preceding free block*/ - if (_lastp < p1) /*reduce search*/ - p2 = _lastp; - while (p2->next < p1) - p2 = p2->next; - } - /* if p2 preceeds p1 in the circular list, - * try to merge them */ - p1->next = p2->next; p2->next = p1; - if (p2 <= p1 && merge(p2,p1)) - p1 = p2; - p2 = p1->next; - /* p1 preceeds p2 in the circular list */ - if (p2 > p1) merge(p1,p2); - } - if (p1 >= p1->next) - _highp = p1; - _lastp = p1; - *pp = (struct adm *) 0; -} diff --git a/lib/ack/libp/efl.c b/lib/ack/libp/efl.c deleted file mode 100644 index 888de603a..000000000 --- a/lib/ack/libp/efl.c +++ /dev/null @@ -1,36 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* Author: J.W. Stevenson */ - -#include -#include - -extern struct file *_curfil; -extern _trp(); -extern _incpt(); - -int _efl(f) struct file *f; { - - _curfil = f; - if ((f->flags & 0377) != MAGIC) - _trp(EBADF); - if ((f->flags & (WINDOW|WRBIT|EOFBIT)) == 0) - _incpt(f); - return((f->flags & EOFBIT) != 0); -} diff --git a/lib/ack/libp/eln.c b/lib/ack/libp/eln.c deleted file mode 100644 index 08be0a547..000000000 --- a/lib/ack/libp/eln.c +++ /dev/null @@ -1,33 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* Author: J.W. Stevenson */ - -#include -#include - -extern _trp(); -extern _rf(); - -int _eln(f) struct file *f; { - - _rf(f); - if (f->flags & EOFBIT) - _trp(EEOF); - return((f->flags & ELNBIT) != 0); -} diff --git a/lib/ack/libp/encaps.e b/lib/ack/libp/encaps.e deleted file mode 100644 index 43557e904..000000000 --- a/lib/ack/libp/encaps.e +++ /dev/null @@ -1,144 +0,0 @@ -# - - -; $Header$ -; (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. -; -; This product is part of the Amsterdam Compiler Kit. -; -; Permission to use, sell, duplicate or disclose this software must be -; obtained in writing. Requests for such permissions may be sent to -; -; Dr. Andrew S. Tanenbaum -; Wiskundig Seminarium -; Vrije Universiteit -; Postbox 7161 -; 1007 MC Amsterdam -; The Netherlands -; - - mes 2,_EM_WSIZE,_EM_PSIZE - -; procedure encaps(procedure p; procedure(q(n:integer)); -; {call q if a trap occurs during the execution of p} -; {if q returns, continue execution of p} - - - inp $handler - -#define PIISZ 2*_EM_PSIZE - -#define PARG 0 -#define QARG PIISZ -#define E_ELB 0-_EM_PSIZE -#define E_EHA -2*_EM_PSIZE - -; encaps is called with two parameters: -; - procedure instance identifier of q (QARG) -; - procedure instance identifier of p (PARG) -; and two local variables: -; - the lb of the previous encaps (E_ELB) -; - the procedure identifier of the previous handler (E_EHA) -; -; One static variable: -; - the lb of the currently active encaps (enc_lb) - -enc_lb - bss _EM_PSIZE,0,0 - - exp $encaps - pro $encaps,PIISZ - ; save lb of previous encaps - lae enc_lb - loi _EM_PSIZE - lal E_ELB - sti _EM_PSIZE - ; set new lb - lxl 0 - lae enc_lb - sti _EM_PSIZE - ; save old handler id while setting up the new handler - lpi $handler - sig - lal E_EHA - sti _EM_PSIZE - ; handler is ready, p can be called - ; p doesn't expect parameters except possibly the static link - ; always passing the link won't hurt - lal PARG - loi PIISZ - cai - asp _EM_PSIZE - ; reinstate old handler - lal E_ELB - loi _EM_PSIZE - lae enc_lb - sti _EM_PSIZE - lal E_EHA - loi _EM_PSIZE - sig - asp _EM_PSIZE - ret 0 - end ? - -#define TRAP 0 -#define H_ELB 0-_EM_PSIZE - -; handler is called with one parameter: -; - trap number (TRAP) -; one local variable -; - the current LB of the enclosing encaps (H_ELB) - - - pro $handler,_EM_PSIZE - ; save LB of nearest encaps - lae enc_lb - loi _EM_PSIZE - lal H_ELB - sti _EM_PSIZE - ; fetch setting for previous encaps via LB of nearest - lal H_ELB - loi _EM_PSIZE - adp E_ELB - loi _EM_PSIZE ; LB of previous encaps - lae enc_lb - sti _EM_PSIZE - lal H_ELB - loi _EM_PSIZE - adp E_EHA - loi _EM_PSIZE ; previous handler - sig - asp _EM_PSIZE - ; previous handler is re-instated, time to call Q - lol TRAP ; the one and only real parameter - lal H_ELB - loi _EM_PSIZE - lpb ; argument base of enclosing encaps - adp QARG - loi PIISZ - exg _EM_PSIZE - dup _EM_PSIZE ; The static link is now on top - zer _EM_PSIZE - cmp - zeq *1 - ; non-zero LB - exg _EM_PSIZE - cai - asp _EM_WSIZE+_EM_PSIZE - bra *2 -1 - ; zero LB - asp _EM_PSIZE - cai - asp _EM_WSIZE -2 - ; now reinstate handler for continued execution of p - lal H_ELB - loi _EM_PSIZE - lae enc_lb - sti _EM_PSIZE - lpi $handler - sig - asp _EM_PSIZE - rtt - end ? diff --git a/lib/ack/libp/exp.c b/lib/ack/libp/exp.c deleted file mode 100644 index 647ea5203..000000000 --- a/lib/ack/libp/exp.c +++ /dev/null @@ -1,118 +0,0 @@ -/* - * (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - * - * Author: Ceriel J.H. Jacobs - */ - -/* $Header$ */ -#define __NO_DEFS -#include -#include -extern _trp(); - -#if __STDC__ -#include -#include -#define M_MIN_D DBL_MIN -#define M_MAX_D DBL_MAX -#define M_DMINEXP DBL_MIN_EXP -#endif -#undef HUGE -#define HUGE HUGE_VAL - -static double -Ldexp(fl,exp) - double fl; - int exp; -{ - extern double _fef(); - int sign = 1; - int currexp; - - if (fl<0) { - fl = -fl; - sign = -1; - } - fl = _fef(fl,&currexp); - exp += currexp; - if (exp > 0) { - while (exp>30) { - fl *= (double) (1L << 30); - exp -= 30; - } - fl *= (double) (1L << exp); - } - else { - while (exp<-30) { - fl /= (double) (1L << 30); - exp += 30; - } - fl /= (double) (1L << -exp); - } - return sign * fl; -} - -double -_exp(x) - double x; -{ - /* Algorithm and coefficients from: - "Software manual for the elementary functions" - by W.J. Cody and W. Waite, Prentice-Hall, 1980 - */ - - static double p[] = { - 0.25000000000000000000e+0, - 0.75753180159422776666e-2, - 0.31555192765684646356e-4 - }; - - static double q[] = { - 0.50000000000000000000e+0, - 0.56817302698551221787e-1, - 0.63121894374398503557e-3, - 0.75104028399870046114e-6 - }; - double xn, g; - int n; - int negative = x < 0; - - if (x <= M_LN_MIN_D) { - g = M_MIN_D/4.0; - - if (g != 0.0) { - /* unnormalized numbers apparently exist */ - if (x < (M_LN2 * (M_DMINEXP - 53))) return 0.0; - } - else { - if (x < M_LN_MIN_D) return 0.0; - return M_MIN_D; - } - } - if (x >= M_LN_MAX_D) { - if (x > M_LN_MAX_D) { - _trp(EEXP); - return HUGE; - } - return M_MAX_D; - } - if (negative) x = -x; - - n = x * M_LOG2E + 0.5; /* 1/ln(2) = log2(e), 0.5 added for rounding */ - xn = n; - { - double x1 = (long) x; - double x2 = x - x1; - - g = ((x1-xn*0.693359375)+x2) - xn*(-2.1219444005469058277e-4); - } - if (negative) { - g = -g; - n = -n; - } - xn = g * g; - x = g * POLYNOM2(xn, p); - n += 1; - return (Ldexp(0.5 + x/(POLYNOM3(xn, q) - x), n)); -} diff --git a/lib/ack/libp/fef.e b/lib/ack/libp/fef.e deleted file mode 100644 index 0caaedcd6..000000000 --- a/lib/ack/libp/fef.e +++ /dev/null @@ -1,39 +0,0 @@ -# -; $Header$ -; -; (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. -; -; This product is part of the Amsterdam Compiler Kit. -; -; Permission to use, sell, duplicate or disclose this software must be -; obtained in writing. Requests for such permissions may be sent to -; -; Dr. Andrew S. Tanenbaum -; Wiskundig Seminarium -; Vrije Universiteit -; Postbox 7161 -; 1007 MC Amsterdam -; The Netherlands -; -; - - mes 2,_EM_WSIZE,_EM_PSIZE - -#define FARG 0 -#define ERES _EM_DSIZE - -; _fef is called with two parameters: -; - address of exponent result (ERES) -; - floating point number to be split (FARG) -; and returns an _EM_DSIZE-byte floating point number - - exp $_fef - pro $_fef,0 - lal FARG - loi _EM_DSIZE - fef _EM_DSIZE - lal ERES - loi _EM_PSIZE - sti _EM_WSIZE - ret _EM_DSIZE - end ? diff --git a/lib/ack/libp/fif.e b/lib/ack/libp/fif.e deleted file mode 100644 index 2e11cf3b3..000000000 --- a/lib/ack/libp/fif.e +++ /dev/null @@ -1,41 +0,0 @@ -# -; $Header$ -; -; (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. -; -; This product is part of the Amsterdam Compiler Kit. -; -; Permission to use, sell, duplicate or disclose this software must be -; obtained in writing. Requests for such permissions may be sent to -; -; Dr. Andrew S. Tanenbaum -; Wiskundig Seminarium -; Vrije Universiteit -; Postbox 7161 -; 1007 MC Amsterdam -; The Netherlands -; -; - - mes 2,_EM_WSIZE,_EM_PSIZE - -#define ARG1 0 -#define ARG2 _EM_DSIZE -#define IRES 2*_EM_DSIZE - -; _fif is called with three parameters: -; - address of integer part result (IRES) -; - float two (ARG2) -; - float one (ARG1) -; and returns an _EM_DSIZE-byte floating point number - - exp $_fif - pro $_fif,0 - lal 0 - loi 2*_EM_DSIZE - fif _EM_DSIZE - lal IRES - loi _EM_PSIZE - sti _EM_DSIZE - ret _EM_DSIZE - end ? diff --git a/lib/ack/libp/get.c b/lib/ack/libp/get.c deleted file mode 100644 index ec8420772..000000000 --- a/lib/ack/libp/get.c +++ /dev/null @@ -1,31 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -#include -#include - -extern _rf(); -extern _trp(); - -_get(f) struct file *f; { - - _rf(f); - if (f->flags&EOFBIT) - _trp(EEOF); - f->flags &= ~WINDOW; -} diff --git a/lib/ack/libp/gto.e b/lib/ack/libp/gto.e deleted file mode 100644 index be9efa0ff..000000000 --- a/lib/ack/libp/gto.e +++ /dev/null @@ -1,85 +0,0 @@ -# -; $Header$ -; (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. -; -; This product is part of the Amsterdam Compiler Kit. -; -; Permission to use, sell, duplicate or disclose this software must be -; obtained in writing. Requests for such permissions may be sent to -; -; Dr. Andrew S. Tanenbaum -; Wiskundig Seminarium -; Vrije Universiteit -; Postbox 7161 -; 1007 MC Amsterdam -; The Netherlands -; - -/* Author: J.W. Stevenson */ - - - mes 2,_EM_WSIZE,_EM_PSIZE - -#define TARLB 0 -#define DESCR _EM_PSIZE - -#define NEWPC 0 -#define SAVSP _EM_PSIZE - -#define D_PC 0 -#define D_SP _EM_PSIZE -#define D_LB _EM_PSIZE+_EM_PSIZE - -#define LOCLB 0-_EM_PSIZE - -; _gto is called with two arguments: -; - pointer to the label descriptor (DESCR) -; - local base (LB) of target procedure (TARLB) -; the label descriptor contains two items: -; - label address i.e. new PC (NEWPC) -; - offset in target procedure frame (SAVSP) -; using this offset and the LB of the target procedure, the address of -; of local variable of the target procedure is constructed. -; the target procedure must have stored the correct target SP there. - -descr - bss 3*_EM_PSIZE,0,0 - - exp $_gto - pro $_gto,_EM_PSIZE - lal DESCR - loi _EM_PSIZE - adp NEWPC - loi _EM_PSIZE - lae descr+D_PC - sti _EM_PSIZE - lal TARLB - loi _EM_PSIZE - zer _EM_PSIZE - cmp - zeq *1 - lal TARLB - loi _EM_PSIZE - bra *2 -1 - lae _m_lb - loi _EM_PSIZE -2 - lal LOCLB - sti _EM_PSIZE - lal LOCLB - loi _EM_PSIZE - lal DESCR - loi _EM_PSIZE - adp SAVSP - loi _EM_WSIZE ; or _EM_PSIZE ? - ads _EM_WSIZE ; or _EM_PSIZE ? - loi _EM_PSIZE - lae descr+D_SP - sti _EM_PSIZE - lal LOCLB - loi _EM_PSIZE - lae descr+D_LB - sti _EM_PSIZE - gto descr - end ? diff --git a/lib/ack/libp/head_pc.e b/lib/ack/libp/head_pc.e deleted file mode 100644 index 63ad6ae5d..000000000 --- a/lib/ack/libp/head_pc.e +++ /dev/null @@ -1,3 +0,0 @@ -# -; $Header$ - mes 2,_EM_WSIZE,_EM_PSIZE diff --git a/lib/ack/libp/hlt.c b/lib/ack/libp/hlt.c deleted file mode 100644 index 0c04c592e..000000000 --- a/lib/ack/libp/hlt.c +++ /dev/null @@ -1,35 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* Author: J.W. Stevenson */ - -#include - -extern struct file **_extfl; -extern int _extflc; -extern _cls(); -extern _exit(); - -_hlt(ecode) int ecode; { - int i; - - for (i = 0; i < _extflc; i++) - if (_extfl[i] != (struct file *) 0) - _cls(_extfl[i]); - _exit(ecode); -} diff --git a/lib/ack/libp/hol0.e b/lib/ack/libp/hol0.e deleted file mode 100644 index d84d7731f..000000000 --- a/lib/ack/libp/hol0.e +++ /dev/null @@ -1,29 +0,0 @@ -# - -; $Header$ -; -; (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. -; -; This product is part of the Amsterdam Compiler Kit. -; -; Permission to use, sell, duplicate or disclose this software must be -; obtained in writing. Requests for such permissions may be sent to -; -; Dr. Andrew S. Tanenbaum -; Wiskundig Seminarium -; Vrije Universiteit -; Postbox 7161 -; 1007 MC Amsterdam -; The Netherlands -; -; - - mes 2,_EM_WSIZE,_EM_PSIZE - -; _hol0 return the address of the ABS block (hol0) - - exp $_hol0 - pro $_hol0,0 - lae 0 - ret _EM_PSIZE - end ? diff --git a/lib/ack/libp/incpt.c b/lib/ack/libp/incpt.c deleted file mode 100644 index 5818a8604..000000000 --- a/lib/ack/libp/incpt.c +++ /dev/null @@ -1,75 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* Author: J.W. Stevenson */ - -#include -#include - -#define EINTR 4 - -extern int errno; -extern _trp(); -extern int _read(); - -_incpt(f) struct file *f; { - - if (f->flags & EOFBIT) - _trp(EEOF); - f->flags |= WINDOW; - f->flags &= ~ELNBIT; -#ifdef CPM - do { -#endif - f->ptr += f->size; - if (f->count == 0) { - f->ptr = f->bufadr; - for(;;) { - f->count=_read(f->ufd,f->bufadr,f->buflen); - if ( f->count<0 ) { - if (errno != EINTR) _trp(EREAD) ; - continue ; - } - break ; - } - if (f->count == 0) { - f->flags |= EOFBIT; - *f->ptr = '\0'; - return; - } - } - if ((f->count -= f->size) < 0) - _trp(EFTRUNC); -#ifdef CPM - } while ((f->flags&TXTBIT) && *f->ptr == '\r'); -#endif - if (f->flags & TXTBIT) { - if (*f->ptr & 0200) - _trp(EASCII); - if (*f->ptr == '\n') { - f->flags |= ELNBIT; - *f->ptr = ' '; - } -#ifdef CPM - if (*f->ptr == 26) { - f->flags |= EOFBIT; - *f->ptr = 0; - } -#endif - } -} diff --git a/lib/ack/libp/ini.c b/lib/ack/libp/ini.c deleted file mode 100644 index 7614eb1ce..000000000 --- a/lib/ack/libp/ini.c +++ /dev/null @@ -1,71 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* Author: J.W. Stevenson */ - -#include - -extern (*_sig())(); -extern _catch(); -#ifndef CPM -extern int _isatty(); -#endif - -struct file **_extfl; -int _extflc; /* number of external files */ -char *_m_lb; /* LB of _m_a_i_n */ -struct file *_curfil; /* points to file struct in case of errors */ -int _pargc; -char **_pargv; -char ***_penviron; -int _fp_hook = 1; /* This is for Minix, but does not harm others */ - -_ini(args,c,p,mainlb) char *args,*mainlb; int c; struct file **p; { - struct file *f; - char buf[128]; - - _pargc= *(int *)args; args += sizeof (int); - _pargv= *(char ***)args; - _sig(_catch); - _extfl = p; - _extflc = c; - if( !c ) return; - _m_lb = mainlb; - if ( (f = _extfl[0]) != (struct file *) 0) { - f->ptr = f->bufadr; - f->flags = MAGIC|TXTBIT; - f->fname = "INPUT"; - f->ufd = 0; - f->size = 1; - f->count = 0; - f->buflen = PC_BUFLEN; - } - if ( (f = _extfl[1]) != (struct file *) 0) { - f->ptr = f->bufadr; - f->flags = MAGIC|TXTBIT|WRBIT|EOFBIT|ELNBIT; - f->fname = "OUTPUT"; - f->ufd = 1; - f->size = 1; -#ifdef CPM - f->count = 1; -#else - f->count = (_isatty(1) ? 1 : PC_BUFLEN); -#endif - f->buflen = f->count; - } -} diff --git a/lib/ack/libp/log.c b/lib/ack/libp/log.c deleted file mode 100644 index 0f164fcbd..000000000 --- a/lib/ack/libp/log.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - * - * Author: Ceriel J.H. Jacobs - */ - -/* $Header$ */ - -#define __NO_DEFS -#include -#include - -#if __STDC__ -#include -#include -#endif -#undef HUGE -#define HUGE HUGE_VAL - -double -_log(x) - double x; -{ - /* Algorithm and coefficients from: - "Software manual for the elementary functions" - by W.J. Cody and W. Waite, Prentice-Hall, 1980 - */ - static double a[] = { - -0.64124943423745581147e2, - 0.16383943563021534222e2, - -0.78956112887491257267e0 - }; - static double b[] = { - -0.76949932108494879777e3, - 0.31203222091924532844e3, - -0.35667977739034646171e2, - 1.0 - }; - - extern double _fef(); - double znum, zden, z, w; - int exponent; - - if (x <= 0) { - _trp(ELOG); - return -HUGE; - } - - x = _fef(x, &exponent); - if (x > M_1_SQRT2) { - znum = (x - 0.5) - 0.5; - zden = x * 0.5 + 0.5; - } - else { - znum = x - 0.5; - zden = znum * 0.5 + 0.5; - exponent--; - } - z = znum/zden; w = z * z; - x = z + z * w * (POLYNOM2(w,a)/POLYNOM3(w,b)); - z = exponent; - x += z * (-2.121944400546905827679e-4); - return x + z * 0.693359375; -} diff --git a/lib/ack/libp/mdi.c b/lib/ack/libp/mdi.c deleted file mode 100644 index af9438d74..000000000 --- a/lib/ack/libp/mdi.c +++ /dev/null @@ -1,71 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* Author: J.W. Stevenson */ - -#include - -extern _trp(); - -int _mdi(j,i) int j,i; { - - if (j <= 0) - _trp(EMOD); - i = i % j; - if (i < 0) - i += j; - return(i); -} - -long _mdil(j,i) long j,i; { - - if (j <= 0) - _trp(EMOD); - i = i % j; - if (i < 0) - i += j; - return(i); -} - -int _dvi(j, i) unsigned int j,i; { - int neg = 0; - - if ((int)j < 0) { - j = -(int)j; neg = 1; - } - if ((int)i < 0) { - i = -(int)i; neg = !neg; - } - i = i / j; - if (neg) return -(int)i; - return i; -} - -long _dvil(j, i) unsigned long j,i; { - int neg = 0; - - if ((long)j < 0) { - j = -(long)j; neg = 1; - } - if ((long)i < 0) { - i = -(long)i; neg = !neg; - } - i = i / j; - if (neg) return -(long)i; - return i; -} diff --git a/lib/ack/libp/mdl.c b/lib/ack/libp/mdl.c deleted file mode 100644 index 8c8272f44..000000000 --- a/lib/ack/libp/mdl.c +++ /dev/null @@ -1,33 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* Author: J.W. Stevenson */ - -#include - -extern _trp(); - -long _mdl(j,i) long j,i; { - - if (j <= 0) - _trp(EMOD); - i = i % j; - if (i < 0) - i += j; - return(i); -} diff --git a/lib/ack/libp/new.c b/lib/ack/libp/new.c deleted file mode 100644 index 6ea6a304a..000000000 --- a/lib/ack/libp/new.c +++ /dev/null @@ -1,69 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* Author: J.W. Stevenson */ - -extern _sav(); -extern _rst(); - -#define assert(x) /* nothing */ -#define UNDEF 0x8000 - -struct adm { - struct adm *next; - int size; -}; - -struct adm *_lastp = 0; -struct adm *_highp = 0; - -_new(n,pp) int n; struct adm **pp; { - struct adm *p,*q; - int *ptmp; - - n = ((n+sizeof(*p)-1) / sizeof(*p)) * sizeof(*p); - if ((p = _lastp) != 0) - do { - q = p->next; - if (q->size >= n) { - assert(q->size%sizeof(adm) == 0); - if ((q->size -= n) == 0) { - if (p == q) - p = 0; - else - p->next = q->next; - if (q == _highp) - _highp = p; - } - _lastp = p; - p = (struct adm *)((char *)q + q->size); - q = (struct adm *)((char *)p + n); - goto initialize; - } - p = q; - } while (p != _lastp); - /*no free block big enough*/ - _sav(&p); - q = (struct adm *)((char *)p + n); - _rst(&q); -initialize: - *pp = p; - ptmp = (int *)p; - while (ptmp < (int *)q) - *ptmp++ = UNDEF; -} diff --git a/lib/ack/libp/nfa.c b/lib/ack/libp/nfa.c deleted file mode 100644 index cfdb9af4d..000000000 --- a/lib/ack/libp/nfa.c +++ /dev/null @@ -1,16 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1990 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ - -/* Author: Hans van Eck */ - -#include - -extern _trp(); - -_nfa(bool) -{ - if (! bool) _trp(EFUNASS); -} diff --git a/lib/ack/libp/nobuff.c b/lib/ack/libp/nobuff.c deleted file mode 100644 index 10f80cb48..000000000 --- a/lib/ack/libp/nobuff.c +++ /dev/null @@ -1,33 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* Author: J.W. Stevenson */ - -#include - -extern _flush(); - -/* procedure nobuff(var f:file of ?); */ - -nobuff(f) struct file *f; { - - if ((f->flags & (0377|WRBIT)) != (MAGIC|WRBIT)) - return; - _flush(f); - f->count = f->buflen = f->size; -} diff --git a/lib/ack/libp/notext.c b/lib/ack/libp/notext.c deleted file mode 100644 index 8a46e5f35..000000000 --- a/lib/ack/libp/notext.c +++ /dev/null @@ -1,23 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -#include - -notext(f) struct file *f; { - f->flags &= ~TXTBIT; -} diff --git a/lib/ack/libp/opn.c b/lib/ack/libp/opn.c deleted file mode 100644 index 2df6d3834..000000000 --- a/lib/ack/libp/opn.c +++ /dev/null @@ -1,118 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* Author: J.W. Stevenson */ - -#include -#include - -extern struct file **_extfl; -extern int _extflc; -extern struct file *_curfil; -extern int _pargc; -extern char **_pargv; -extern char ***_penviron; - -extern _cls(); -extern _xcls(); -extern _trp(); -extern int _getpid(); -extern int _creat(); -extern int _open(); -extern int _close(); -extern int _unlink(); -extern long _lseek(); - -static int tmpfil() { - static char namebuf[] = "/usr/tmp/plf.xxxxx"; - int i; char *p,*q; - - i = _getpid(); - p = namebuf; - q = p + 13; - do - *q++ = (i & 07) + '0'; - while (i >>= 3); - *q = '\0'; - if ((i = _creat(p,0644)) < 0) - if ((i = _creat(p += 4,0644)) < 0) - if ((i = _creat(p += 5,0644)) < 0) - goto error; - if (_close(i) != 0) - goto error; - if ((i = _open(p,2)) < 0) - goto error; - if (_unlink(p) != 0) -error: _trp(EREWR); - return(i); -} - -static int initfl(descr,sz,f) int descr; int sz; struct file *f; { - int i; - - _curfil = f; - if (sz == 0) { - sz++; - descr |= TXTBIT; - } - for (i=0; i<_extflc; i++) - if (f == _extfl[i]) - break; - if (i >= _extflc) { /* local file */ - f->fname = "LOCAL"; - if ((descr & WRBIT) == 0 && (f->flags & 0377) == MAGIC) { - _xcls(f); - if (_lseek(f->ufd,(long)0,0) == -1) - _trp(ERESET); - } else { - _cls(f); - f->ufd = tmpfil(); - } - } else { /* external file */ - if (--i <= 0) - return(0); - if (i >= _pargc) - _trp(EARGC); - f->fname = _pargv[i]; - _cls(f); - if ((descr & WRBIT) == 0) { - if ((f->ufd = _open(f->fname,0)) < 0) - _trp(ERESET); - } else { - if ((f->ufd = _creat(f->fname,0644)) < 0) - _trp(EREWR); - } - } - f->buflen = (sz>PC_BUFLEN ? sz : PC_BUFLEN-PC_BUFLEN%sz); - f->size = sz; - f->ptr = f->bufadr; - f->flags = descr; - return(1); -} - -_opn(sz,f) int sz; struct file *f; { - - if (initfl(MAGIC,sz,f)) - f->count = 0; -} - -_cre(sz,f) int sz; struct file *f; { - - if (initfl(WRBIT|EOFBIT|ELNBIT|MAGIC,sz,f)) - f->count = f->buflen; -} diff --git a/lib/ack/libp/outcpt.c b/lib/ack/libp/outcpt.c deleted file mode 100644 index 98b02e5b3..000000000 --- a/lib/ack/libp/outcpt.c +++ /dev/null @@ -1,50 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* Author: J.W. Stevenson */ - -#include -#include - -#define EINTR 4 - -extern int errno; -extern _trp(); -extern int _write(); - -_flush(f) struct file *f; { - int i,n; - - f->ptr = f->bufadr; - n = f->buflen - f->count; - if (n <= 0) - return; - f->count = f->buflen; - if ((i = _write(f->ufd,f->bufadr,n)) < 0 && errno == EINTR) - return; - if (i != n) - _trp(EWRITE); -} - -_outcpt(f) struct file *f; { - - f->flags &= ~ELNBIT; - f->ptr += f->size; - if ((f->count -= f->size) <= 0) - _flush(f); -} diff --git a/lib/ack/libp/pac.c b/lib/ack/libp/pac.c deleted file mode 100644 index 6ce3751ff..000000000 --- a/lib/ack/libp/pac.c +++ /dev/null @@ -1,63 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* Author: J.W. Stevenson */ - -#include - -extern _trp(); - -#define assert(x) /* nothing */ - -#ifndef EM_WSIZE -#define EM_WSIZE _EM_WSIZE -#endif - -struct descr { - int low; - int diff; - int size; -}; - -_pac(ad,zd,zp,i,ap) int i; struct descr *ad,*zd; char *zp,*ap; { - - if (zd->diff > ad->diff || - (i -= ad->low) < 0 || - (i+zd->diff) > ad->diff) - _trp(EPACK); - ap += (i * ad->size); - i = (zd->diff + 1) * zd->size; - if (zd->size == 1) { - int *aptmp = (int *)ap; - assert(ad->size == EM_WSIZE); - while (--i >= 0) - *zp++ = *aptmp++; -#if EM_WSIZE > 2 - } else if (zd->size == 2) { - int *aptmp = (int *)ap; - short *zptmp = (short *) zp; - assert(ad->size == EM_WSIZE); - while (--i >= 0) - *zptmp++ = *aptmp++; -#endif - } else { - assert(ad->size == zd->size); - while (--i >= 0) - *zp++ = *ap++; - } -} diff --git a/lib/ack/libp/pclose.c b/lib/ack/libp/pclose.c deleted file mode 100644 index 88ba88aea..000000000 --- a/lib/ack/libp/pclose.c +++ /dev/null @@ -1,27 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -#include - -extern _cls(); - -/* procedure pclose(var f:file of ??); */ - -pclose(f) struct file *f; { - _cls(f); -} diff --git a/lib/ack/libp/pcreat.c b/lib/ack/libp/pcreat.c deleted file mode 100644 index f1190b922..000000000 --- a/lib/ack/libp/pcreat.c +++ /dev/null @@ -1,41 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* Author: J.W. Stevenson */ - -#include -#include - -extern _cls(); -extern _trp(); -extern int _creat(); - -/* procedure pcreat(var f:text; s:string); */ - -pcreat(f,s) struct file *f; char *s; { - - _cls(f); /* initializes _curfil */ - f->ptr = f->bufadr; - f->flags = WRBIT|EOFBIT|ELNBIT|TXTBIT|MAGIC; - f->fname = s; - f->size = 1; - f->count = PC_BUFLEN; - f->buflen = PC_BUFLEN; - if ((f->ufd = _creat(s,0644)) < 0) - _trp(EREWR); -} diff --git a/lib/ack/libp/pentry.c b/lib/ack/libp/pentry.c deleted file mode 100644 index bac8aad0c..000000000 --- a/lib/ack/libp/pentry.c +++ /dev/null @@ -1,35 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* Author: J.W. Stevenson */ - -#include - -extern struct file **_extfl; -extern _wrs(); -extern _wrz(); -extern _wln(); - -procentry(name) char *name; { - struct file *f; - - f = _extfl[1]; - _wrs(5,"call ",f); - _wrz(name,f); - _wln(f); -} diff --git a/lib/ack/libp/perrno.c b/lib/ack/libp/perrno.c deleted file mode 100644 index 3cc6a1b6d..000000000 --- a/lib/ack/libp/perrno.c +++ /dev/null @@ -1,25 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* function perrno:integer; extern; */ - -extern int errno; - -int perrno() { - return(errno); -} diff --git a/lib/ack/libp/pexit.c b/lib/ack/libp/pexit.c deleted file mode 100644 index 2b00a28ac..000000000 --- a/lib/ack/libp/pexit.c +++ /dev/null @@ -1,33 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -#include - -extern struct file **_extfl; -extern _wrs(); -extern _wrz(); -extern _wln(); - -procexit(name) char *name; { - struct file *f; - - f = _extfl[1]; - _wrs(5,"exit ",f); - _wrz(name,f); - _wln(f); -} diff --git a/lib/ack/libp/popen.c b/lib/ack/libp/popen.c deleted file mode 100644 index b542c7ee3..000000000 --- a/lib/ack/libp/popen.c +++ /dev/null @@ -1,41 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* Author: J.W. Stevenson */ - -#include -#include - -extern _cls(); -extern _trp(); -extern int _open(); - -/* procedure popen(var f:text; s:string); */ - -popen(f,s) struct file *f; char *s; { - - _cls(f); /* initializes _curfil */ - f->ptr = f->bufadr; - f->flags = TXTBIT|MAGIC; - f->fname = s; - f->size = 1; - f->count = 0; - f->buflen = PC_BUFLEN; - if ((f->ufd = _open(s,0)) < 0) - _trp(ERESET); -} diff --git a/lib/ack/libp/put.c b/lib/ack/libp/put.c deleted file mode 100644 index dcc86e196..000000000 --- a/lib/ack/libp/put.c +++ /dev/null @@ -1,27 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -#include - -extern _wf(); -extern _outcpt(); - -_put(f) struct file *f; { - _wf(f); - _outcpt(f); -} diff --git a/lib/ack/libp/rcka.c b/lib/ack/libp/rcka.c deleted file mode 100644 index b08b6b0be..000000000 --- a/lib/ack/libp/rcka.c +++ /dev/null @@ -1,25 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1990 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - */ - -/* Author: Hans van Eck */ - -#include - -extern _trp(); - -struct array_descr { - int lbound; - unsigned n_elts_min_one; - unsigned size; /* doesn't really matter */ - }; - -_rcka(descr, index) -struct array_descr *descr; -{ - if( index < descr->lbound || - index > (int) descr->n_elts_min_one + descr->lbound ) - _trp(EARRAY); -} diff --git a/lib/ack/libp/rdc.c b/lib/ack/libp/rdc.c deleted file mode 100644 index 17f0708a8..000000000 --- a/lib/ack/libp/rdc.c +++ /dev/null @@ -1,31 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -#include - -extern _rf(); -extern _incpt(); - -int _rdc(f) struct file *f; { - int c; - - _rf(f); - c = *f->ptr; - _incpt(f); - return(c); -} diff --git a/lib/ack/libp/rdi.c b/lib/ack/libp/rdi.c deleted file mode 100644 index fa1909b81..000000000 --- a/lib/ack/libp/rdi.c +++ /dev/null @@ -1,78 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* Author: J.W. Stevenson */ - -#include -#include - -extern _trp(); -extern _rf(); -extern _incpt(); - -_skipsp(f) struct file *f; { - while ((*f->ptr == ' ') || (*f->ptr == '\t')) - _incpt(f); -} - -int _getsig(f) struct file *f; { - int sign; - - if ((sign = (*f->ptr == '-')) || *f->ptr == '+') - _incpt(f); - return(sign); -} - -int _fstdig(f) struct file *f; { - int ch; - - ch = *f->ptr - '0'; - if ((unsigned) ch > 9) { - _trp(EDIGIT); - ch = 0; - } - return(ch); -} - -int _nxtdig(f) struct file *f; { - int ch; - - _incpt(f); - ch = *f->ptr - '0'; - if ((unsigned) ch > 9) - return(-1); - return(ch); -} - -int _getint(f) struct file *f; { - int is_signed,i,ch; - - is_signed = _getsig(f); - ch = _fstdig(f); - i = 0; - do - i = i*10 - ch; - while ((ch = _nxtdig(f)) >= 0); - return(is_signed ? i : -i); -} - -int _rdi(f) struct file *f; { - _rf(f); - _skipsp(f); - return(_getint(f)); -} diff --git a/lib/ack/libp/rdl.c b/lib/ack/libp/rdl.c deleted file mode 100644 index 76fa6a3f8..000000000 --- a/lib/ack/libp/rdl.c +++ /dev/null @@ -1,41 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* Author: J.W. Stevenson */ - -#include - -extern _rf(); -extern _skipsp(); -extern int _getsig(); -extern int _fstdig(); -extern int _nxtdig(); - -long _rdl(f) struct file *f; { - int is_signed,ch; long l; - - _rf(f); - _skipsp(f); - is_signed = _getsig(f); - ch = _fstdig(f); - l = 0; - do - l = l*10 - ch; - while ((ch = _nxtdig(f)) >= 0); - return(is_signed ? l : -l); -} diff --git a/lib/ack/libp/rdr.c b/lib/ack/libp/rdr.c deleted file mode 100644 index a9ea1c8f3..000000000 --- a/lib/ack/libp/rdr.c +++ /dev/null @@ -1,78 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* Author: J.W. Stevenson */ - -#include - -#define BIG 1e17 - -extern _rf(); -extern _incpt(); -extern _skipsp(); -extern int _getsig(); -extern int _getint(); -extern int _fstdig(); -extern int _nxtdig(); - -static double r; -static int pow10; - -static dig(ch) int ch; { - - if (r>BIG) - pow10++; - else - r = r*10.0 + ch; -} - -double _rdr(f) struct file *f; { - int i; double e; int is_signed,ch; - - r = 0; - pow10 = 0; - _rf(f); - _skipsp(f); - is_signed = _getsig(f); - ch = _fstdig(f); - do - dig(ch); - while ((ch = _nxtdig(f)) >= 0); - if (*f->ptr == '.') { - _incpt(f); - ch = _fstdig(f); - do { - dig(ch); - pow10--; - } while ((ch = _nxtdig(f)) >= 0); - } - if ((*f->ptr == 'e') || (*f->ptr == 'E')) { - _incpt(f); - pow10 += _getint(f); - } - if ((i = pow10) < 0) - i = -i; - e = 1.0; - while (--i >= 0) - e *= 10.0; - if (pow10<0) - r /= e; - else - r *= e; - return(is_signed? -r : r); -} diff --git a/lib/ack/libp/rf.c b/lib/ack/libp/rf.c deleted file mode 100644 index dee966838..000000000 --- a/lib/ack/libp/rf.c +++ /dev/null @@ -1,35 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -#include -#include - -extern struct file *_curfil; -extern _trp(); -extern _incpt(); - -_rf(f) struct file *f; { - - _curfil = f; - if ((f->flags&0377) != MAGIC) - _trp(EBADF); - if (f->flags & WRBIT) - _trp(EREADF); - if ((f->flags & WINDOW) == 0) - _incpt(f); -} diff --git a/lib/ack/libp/rln.c b/lib/ack/libp/rln.c deleted file mode 100644 index 16e93c0ce..000000000 --- a/lib/ack/libp/rln.c +++ /dev/null @@ -1,30 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -#include - -extern _rf(); -extern _incpt(); - -_rln(f) struct file *f; { - - _rf(f); - while ((f->flags & ELNBIT) == 0) - _incpt(f); - f->flags &= ~WINDOW; -} diff --git a/lib/ack/libp/rnd.c b/lib/ack/libp/rnd.c deleted file mode 100644 index 0345caa87..000000000 --- a/lib/ack/libp/rnd.c +++ /dev/null @@ -1,21 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -double _rnd(r) double r; { - return(r + (r<0 ? -0.5 : 0.5)); -} diff --git a/lib/ack/libp/sav.e b/lib/ack/libp/sav.e deleted file mode 100644 index 317567833..000000000 --- a/lib/ack/libp/sav.e +++ /dev/null @@ -1,49 +0,0 @@ -# -; $Header$ -; (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. -; -; This product is part of the Amsterdam Compiler Kit. -; -; Permission to use, sell, duplicate or disclose this software must be -; obtained in writing. Requests for such permissions may be sent to -; -; Dr. Andrew S. Tanenbaum -; Wiskundig Seminarium -; Vrije Universiteit -; Postbox 7161 -; 1007 MC Amsterdam -; The Netherlands -; - -/* Author: J.W. Stevenson */ - - - mes 2,_EM_WSIZE,_EM_PSIZE - -#define PTRAD 0 - -#define HP 2 - -; _sav called with one parameter: -; - address of pointer variable (PTRAD) - - exp $_sav - pro $_sav,0 - lor HP - lal PTRAD - loi _EM_PSIZE - sti _EM_PSIZE - ret 0 - end ? - -; _rst is called with one parameter: -; - address of pointer variable (PTRAD) - - exp $_rst - pro $_rst,0 - lal PTRAD - loi _EM_PSIZE - loi _EM_PSIZE - str HP - ret 0 - end ? diff --git a/lib/ack/libp/sig.e b/lib/ack/libp/sig.e deleted file mode 100644 index 8aec2651e..000000000 --- a/lib/ack/libp/sig.e +++ /dev/null @@ -1,35 +0,0 @@ -#define PROC 0 - -; $Header$ -; -; (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. -; -; This product is part of the Amsterdam Compiler Kit. -; -; Permission to use, sell, duplicate or disclose this software must be -; obtained in writing. Requests for such permissions may be sent to -; -; Dr. Andrew S. Tanenbaum -; Wiskundig Seminarium -; Vrije Universiteit -; Postbox 7161 -; 1007 MC Amsterdam -; The Netherlands -; -; - - mes 2,_EM_WSIZE,_EM_PSIZE - -; _sig is called with one parameter: -; - procedure instance identifier (PROC) -; and returns nothing. -; only the procedure identifier inside the PROC is used. - - exp $_sig - pro $_sig,0 - lal PROC - loi _EM_PSIZE - sig - asp _EM_PSIZE - ret 0 ; ignore the result of sig - end ? diff --git a/lib/ack/libp/sin.c b/lib/ack/libp/sin.c deleted file mode 100644 index 47132a45d..000000000 --- a/lib/ack/libp/sin.c +++ /dev/null @@ -1,101 +0,0 @@ -/* - * (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - * - * Author: Ceriel J.H. Jacobs - */ - -/* $Header$ */ - -#define __NO_DEFS -#include - -#if __STDC__ -#include -#endif - -static double -sinus(x, cos_flag) - double x; -{ - /* Algorithm and coefficients from: - "Software manual for the elementary functions" - by W.J. Cody and W. Waite, Prentice-Hall, 1980 - */ - - static double r[] = { - -0.16666666666666665052e+0, - 0.83333333333331650314e-2, - -0.19841269841201840457e-3, - 0.27557319210152756119e-5, - -0.25052106798274584544e-7, - 0.16058936490371589114e-9, - -0.76429178068910467734e-12, - 0.27204790957888846175e-14 - }; - - double xsqr; - double y; - int neg = 0; - - if (x < 0) { - x = -x; - neg = 1; - } - if (cos_flag) { - neg = 0; - y = M_PI_2 + x; - } - else y = x; - - /* ??? avoid loss of significance, if y is too large, error ??? */ - - y = y * M_1_PI + 0.5; - - /* Use extended precision to calculate reduced argument. - Here we used 12 bits of the mantissa for a1. - Also split x in integer part x1 and fraction part x2. - */ -#define A1 3.1416015625 -#define A2 -8.908910206761537356617e-6 - { - double x1, x2; - extern double _fif(); - - _fif(y, 1.0, &y); - if (_fif(y, 0.5, &x1)) neg = !neg; - if (cos_flag) y -= 0.5; - x2 = _fif(x, 1.0, &x1); - x = x1 - y * A1; - x += x2; - x -= y * A2; -#undef A1 -#undef A2 - } - - if (x < 0) { - neg = !neg; - x = -x; - } - - /* ??? avoid underflow ??? */ - - y = x * x; - x += x * y * POLYNOM7(y, r); - return neg ? -x : x; -} - -double -_sin(x) - double x; -{ - return sinus(x, 0); -} - -double -_cos(x) - double x; -{ - if (x < 0) x = -x; - return sinus(x, 1); -} diff --git a/lib/ack/libp/sqt.c b/lib/ack/libp/sqt.c deleted file mode 100644 index 12bdfa30e..000000000 --- a/lib/ack/libp/sqt.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - * See the copyright notice in the ACK home directory, in the file "Copyright". - * - * Author: Ceriel J.H. Jacobs - */ - -/* $Header$ */ -#define __NO_DEFS -#include -extern _trp(); - -#define NITER 5 - -static double -Ldexp(fl,exp) - double fl; - int exp; -{ - extern double _fef(); - int sign = 1; - int currexp; - - if (fl<0) { - fl = -fl; - sign = -1; - } - fl = _fef(fl,&currexp); - exp += currexp; - if (exp > 0) { - while (exp>30) { - fl *= (double) (1L << 30); - exp -= 30; - } - fl *= (double) (1L << exp); - } - else { - while (exp<-30) { - fl /= (double) (1L << 30); - exp += 30; - } - fl /= (double) (1L << -exp); - } - return sign * fl; -} - -double -_sqt(x) - double x; -{ - extern double _fef(); - int exponent; - double val; - - if (x <= 0) { - if (x < 0) _trp(ESQT); - return 0; - } - - val = _fef(x, &exponent); - if (exponent & 1) { - exponent--; - val *= 2; - } - val = Ldexp(val + 1.0, exponent/2 - 1); - /* was: val = (val + 1.0)/2.0; val = Ldexp(val, exponent/2); */ - for (exponent = NITER - 1; exponent >= 0; exponent--) { - val = (val + x / val) / 2.0; - } - return val; -} diff --git a/lib/ack/libp/string.c b/lib/ack/libp/string.c deleted file mode 100644 index a36f608a0..000000000 --- a/lib/ack/libp/string.c +++ /dev/null @@ -1,60 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* function strbuf(var b:charbuf):string; */ - -char *strbuf(s) char *s; { - return(s); -} - -/* function strtobuf(s:string; var b:charbuf; blen:integer):integer; */ - -int strtobuf(s,b,l) char *s,*b; { - int i; - - i = 0; - while (--l>=0) { - if ((*b++ = *s++) == 0) - break; - i++; - } - return(i); -} - -/* function strlen(s:string):integer; */ - -int strlen(s) char *s; { - int i; - - i = 0; - while (*s++) - i++; - return(i); -} - -/* function strfetch(s:string; i:integer):char; */ - -int strfetch(s,i) char *s; { - return(s[i-1]); -} - -/* procedure strstore(s:string; i:integer; c:char); */ - -strstore(s,i,c) char *s; { - s[i-1] = c; -} diff --git a/lib/ack/libp/trap.e b/lib/ack/libp/trap.e deleted file mode 100644 index cb4424ba9..000000000 --- a/lib/ack/libp/trap.e +++ /dev/null @@ -1,33 +0,0 @@ -# - -; $Header$ -; -; (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. -; -; This product is part of the Amsterdam Compiler Kit. -; -; Permission to use, sell, duplicate or disclose this software must be -; obtained in writing. Requests for such permissions may be sent to -; -; Dr. Andrew S. Tanenbaum -; Wiskundig Seminarium -; Vrije Universiteit -; Postbox 7161 -; 1007 MC Amsterdam -; The Netherlands -; -; - - mes 2,_EM_WSIZE,_EM_PSIZE - -#define TRAP 0 - -; trap is called with one parameter: -; - trap number (TRAP) - - exp $trap - pro $trap,0 - lol TRAP - trp - ret 0 - end ? diff --git a/lib/ack/libp/trp.e b/lib/ack/libp/trp.e deleted file mode 100644 index 430669aa7..000000000 --- a/lib/ack/libp/trp.e +++ /dev/null @@ -1,38 +0,0 @@ -# - -; $Header$ -; -; (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. -; -; This product is part of the Amsterdam Compiler Kit. -; -; Permission to use, sell, duplicate or disclose this software must be -; obtained in writing. Requests for such permissions may be sent to -; -; Dr. Andrew S. Tanenbaum -; Wiskundig Seminarium -; Vrije Universiteit -; Postbox 7161 -; 1007 MC Amsterdam -; The Netherlands -; -; - - mes 2,_EM_WSIZE,_EM_PSIZE - -#define TRAP 0 - -; _trp() and trap() perform the same function, -; but have to be separate. trap exists to facilitate the user. -; _trp is there for the system, trap cannot be used for that purpose -; because a user might define its own Pascal routine called trap. - -; _trp is called with one parameter: -; - trap number (TRAP) - - exp $_trp - pro $_trp,0 - lol TRAP - trp - ret 0 - end ? diff --git a/lib/ack/libp/unp.c b/lib/ack/libp/unp.c deleted file mode 100644 index d9d5a5fa8..000000000 --- a/lib/ack/libp/unp.c +++ /dev/null @@ -1,65 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* Author: J.W. Stevenson */ - -#include - -extern _trp(); - -#define assert(x) /* nothing */ - -#ifndef EM_WSIZE -#define EM_WSIZE _EM_WSIZE -#endif - -struct descr { - int low; - int diff; - int size; -}; - -_unp(ad,zd,i,ap,zp,noext) int i; struct descr *ad,*zd; char *ap,*zp; int noext; { - - if (zd->diff > ad->diff || - (i -= ad->low) < 0 || - (i+zd->diff) > ad->diff) - _trp(EUNPACK); - ap += (i * ad->size); - i = (zd->diff + 1) * zd->size; - if (zd->size == 1) { - int *aptmp = (int *) ap; - assert(ad->size == EM_WSIZE); - while (--i >= 0) - if (noext) *aptmp++ = *zp++ & 0377; - else *aptmp++ = *zp++; -#if EM_WSIZE > 2 - } else if (zd->size == 2) { - int *aptmp = (int *) ap; - short *zptmp = (short *) zp; - assert(ad->size == EM_WSIZE); - while (--i >= 0) - if (noext) *aptmp++ = *zptmp++ & 0177777; - else *aptmp++ = *zptmp++; -#endif - } else { - assert(ad->size == zd->size); - while (--i >= 0) - *ap++ = *zp++; - } -} diff --git a/lib/ack/libp/uread.c b/lib/ack/libp/uread.c deleted file mode 100644 index ce700470e..000000000 --- a/lib/ack/libp/uread.c +++ /dev/null @@ -1,25 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* function uread(fd:integer; var b:buf; n:integer):integer; */ - -extern int _read(); - -int uread(fd,b,n) char *b; int fd,n; { - return(_read(fd,b,n)); -} diff --git a/lib/ack/libp/uwrite.c b/lib/ack/libp/uwrite.c deleted file mode 100644 index 1a1a20c0a..000000000 --- a/lib/ack/libp/uwrite.c +++ /dev/null @@ -1,25 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* function uwrite(fd:integer; var b:buf; n:integer):integer; */ - -extern int _write(); - -int uwrite(fd,b,n) char *b; int fd,n; { - return(_write(fd,b,n)); -} diff --git a/lib/ack/libp/wdw.c b/lib/ack/libp/wdw.c deleted file mode 100644 index 33ac2f77a..000000000 --- a/lib/ack/libp/wdw.c +++ /dev/null @@ -1,30 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -#include - -extern struct file *_curfil; -extern _incpt(); - -char *_wdw(f) struct file *f; { - - _curfil = f; - if ((f->flags & (WINDOW|WRBIT|0377)) == MAGIC) - _incpt(f); - return(f->ptr); -} diff --git a/lib/ack/libp/wf.c b/lib/ack/libp/wf.c deleted file mode 100644 index cd0f2b9f0..000000000 --- a/lib/ack/libp/wf.c +++ /dev/null @@ -1,32 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -#include -#include - -extern struct file *_curfil; -extern _trp(); - -_wf(f) struct file *f; { - - _curfil = f; - if ((f->flags&0377) != MAGIC) - _trp(EBADF); - if ((f->flags & WRBIT) == 0) - _trp(EWRITEF); -} diff --git a/lib/ack/libp/wrc.c b/lib/ack/libp/wrc.c deleted file mode 100644 index 95b6ea25e..000000000 --- a/lib/ack/libp/wrc.c +++ /dev/null @@ -1,41 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -#include - -extern _wf(); -extern _outcpt(); - -_wrc(c,f) int c; struct file *f; { - *f->ptr = c; - _wf(f); - _outcpt(f); -} - -_wln(f) struct file *f; { -#ifdef CPM - _wrc('\r',f); -#endif - _wrc('\n',f); - f->flags |= ELNBIT; -} - -_pag(f) struct file *f; { - _wrc('\014',f); - f->flags |= ELNBIT; -} diff --git a/lib/ack/libp/wrf.c b/lib/ack/libp/wrf.c deleted file mode 100644 index 5ee6e629a..000000000 --- a/lib/ack/libp/wrf.c +++ /dev/null @@ -1,68 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* Author: J.W. Stevenson */ - -#include -#include - -extern _wstrin(); -extern char *_fcvt(); - -#define assert(x) /* nothing */ - -#if __STDC__ -#include -#define HUGE_DIG DBL_MAX_10_EXP /* log10(maxreal) */ -#else -#define HUGE_DIG 400 /* log10(maxreal) */ -#endif -#define PREC_DIG 80 /* the maximum digits returned by _fcvt() */ -#define FILL_CHAR '0' /* char printed if all of _fcvt() used */ -#define BUFSIZE HUGE_DIG + PREC_DIG + 3 - -_wrf(n,w,r,f) int n,w; double r; struct file *f; { - char *p,*b; int s,d; char buf[BUFSIZE]; - - if ( n < 0 || w < 0) _trp(EWIDTH); - p = buf; - if (n > PREC_DIG) - n = PREC_DIG; - b = _fcvt(r,n,&d,&s); - assert(abs(d) <= HUGE_DIG); - if (s) - *p++ = '-'; - if (d<=0) - *p++ = '0'; - else - do - *p++ = (*b ? *b++ : FILL_CHAR); - while (--d > 0); - if (n > 0) - *p++ = '.'; - while (++d <= 0) { - if (--n < 0) - break; - *p++ = '0'; - } - while (--n >= 0) { - *p++ = (*b ? *b++ : FILL_CHAR); - assert(p <= buf+BUFSIZE); - } - _wstrin(w,(int)(p-buf),buf,f); -} diff --git a/lib/ack/libp/wri.c b/lib/ack/libp/wri.c deleted file mode 100644 index 5c06e5290..000000000 --- a/lib/ack/libp/wri.c +++ /dev/null @@ -1,72 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -#include -#include - -extern _wstrin(); - -#ifndef EM_WSIZE -#ifdef _EM_WSIZE -#define EM_WSIZE _EM_WSIZE -#endif -#endif - -#if EM_WSIZE==4 -#define SZ 11 -#define MININT -2147483648 -#define STRMININT "-2147483648" -#endif -#if EM_WSIZE==2 -#define SZ 6 -#define MININT -32768 -#define STRMININT "-32768" -#endif -#if EM_WSIZE==1 -#define SZ 4 -#define MININT -128 -#define STRMININT "-128" -#endif - -#ifndef STRMININT -Something wrong here! -#endif - -_wsi(w,i,f) int w,i; struct file *f; { - char *p; int j; char buf[SZ]; - - if (w < 0) _trp(EWIDTH); - p = &buf[SZ]; - if ((j=i) < 0) { - if (i == MININT) { - _wstrin(w,SZ,STRMININT,f); - return; - } - j = -j; - } - do - *--p = '0' + j%10; - while (j /= 10); - if (i<0) - *--p = '-'; - _wstrin(w,(int)(&buf[SZ]-p),p,f); -} - -_wri(i,f) int i; struct file *f; { - _wsi(SZ,i,f); -} diff --git a/lib/ack/libp/wrl.c b/lib/ack/libp/wrl.c deleted file mode 100644 index f5a3d67ca..000000000 --- a/lib/ack/libp/wrl.c +++ /dev/null @@ -1,51 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* Author: J.W. Stevenson */ - -#include -#include - -extern _wstrin(); - -#define MAXNEGLONG -2147483648 - -_wsl(w,l,f) int w; long l; struct file *f; { - char *p,c; long j; char buf[11]; - - if (w < 0) _trp(EWIDTH); - p = &buf[11]; - if ((j=l) < 0) { - if (l == MAXNEGLONG) { - _wstrin(w,11,"-2147483648",f); - return; - } - j = -j; - } - do { - c = j%10; - *--p = c + '0'; - } while (j /= 10); - if (l<0) - *--p = '-'; - _wstrin(w,(int)(&buf[11]-p),p,f); -} - -_wrl(l,f) long l; struct file *f; { - _wsl(11,l,f); -} diff --git a/lib/ack/libp/wrr.c b/lib/ack/libp/wrr.c deleted file mode 100644 index 5c2df66e7..000000000 --- a/lib/ack/libp/wrr.c +++ /dev/null @@ -1,67 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* Author: J.W. Stevenson */ - -#include -#include - -extern _wstrin(); -extern char *_ecvt(); - -#define PREC_DIG 80 /* maximum digits produced by _ecvt() */ - -_wsr(w,r,f) int w; double r; struct file *f; { - char *p,*b; int s,d,i; char buf[PREC_DIG+7]; - - if (w < 0) _trp(EWIDTH); - p = buf; - if ((i = w-6) < 2) - i = 2; - b = _ecvt(r,i,&d,&s); - *p++ = s? '-' : ' '; - if (*b == '0') - d++; - *p++ = *b++; - *p++ = '.'; - while (--i > 0) - *p++ = *b++; - *p++ = 'e'; - d--; - if (d < 0) { - d = -d; - *p++ = '-'; - } else - *p++ = '+'; - - if (d >= 1000) { - *p++ = '*'; - *p++ = '*'; - *p++ = '*'; - } - else { - *p++ = '0' + d/100; - *p++ = '0' + (d/10) % 10; - *p++ = '0' + d%10; - } - _wstrin(w,(int)(p-buf),buf,f); -} - -_wrr(r,f) double r; struct file *f; { - _wsr(13,r,f); -} diff --git a/lib/ack/libp/wrs.c b/lib/ack/libp/wrs.c deleted file mode 100644 index a10951c61..000000000 --- a/lib/ack/libp/wrs.c +++ /dev/null @@ -1,68 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -/* Author: J.W. Stevenson */ - -#include -#include - -extern _wf(); -extern _outcpt(); - -_wstrin(width,len,buf,f) int width,len; char *buf; struct file *f; { - - _wf(f); - for (width -= len; width>0; width--) { - *f->ptr = ' '; - _outcpt(f); - } - while (--len >= 0) { - *f->ptr = *buf++; - _outcpt(f); - } -} - -_wsc(w,c,f) int w; char c; struct file *f; { - - if (w < 0) _trp(EWIDTH); - _wss(w,1,&c,f); -} - -_wss(w,len,s,f) int w,len; char *s; struct file *f; { - - if (w < 0 || len < 0) _trp(EWIDTH); - if (w < len) - len = w; - _wstrin(w,len,s,f); -} - -_wrs(len,s,f) int len; char *s; struct file *f; { - if (len < 0) _trp(EWIDTH); - _wss(len,len,s,f); -} - -_wsb(w,b,f) int w,b; struct file *f; { - if (b) - _wss(w,4,"true",f); - else - _wss(w,5,"false",f); -} - -_wrb(b,f) int b; struct file *f; { - _wsb(5,b,f); -} diff --git a/lib/ack/libp/wrz.c b/lib/ack/libp/wrz.c deleted file mode 100644 index 220c66a49..000000000 --- a/lib/ack/libp/wrz.c +++ /dev/null @@ -1,38 +0,0 @@ -/* $Header$ */ -/* - * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands. - * - * This product is part of the Amsterdam Compiler Kit. - * - * Permission to use, sell, duplicate or disclose this software must be - * obtained in writing. Requests for such permissions may be sent to - * - * Dr. Andrew S. Tanenbaum - * Wiskundig Seminarium - * Vrije Universiteit - * Postbox 7161 - * 1007 MC Amsterdam - * The Netherlands - * - */ - -#include -#include - -extern _wss(); -extern _wrs(); - -_wsz(w,s,f) int w; char *s; struct file *f; { - char *p; - - if (w < 0) _trp(EWIDTH); - for (p=s; *p; p++); - _wss(w,(int)(p-s),s,f); -} - -_wrz(s,f) char *s; struct file *f; { - char *p; - - for (p=s; *p; p++); - _wrs((int)(p-s),s,f); -} diff --git a/lib/ack/liby/Makefile b/lib/ack/liby/Makefile new file mode 100644 index 000000000..43c91991a --- /dev/null +++ b/lib/ack/liby/Makefile @@ -0,0 +1,11 @@ +# Makefile for liby + +CPPFLAGS+=-O -D_MINIX -D_POSIX_SOURCE -wo + +LIB= y + +SRCS= \ + main.c \ + yyerror.c + +.include diff --git a/lib/ack/liby/Makefile.in b/lib/ack/liby/Makefile.in deleted file mode 100644 index aab6f5b62..000000000 --- a/lib/ack/liby/Makefile.in +++ /dev/null @@ -1,11 +0,0 @@ -# Makefile for lib/liby. - -CFLAGS="-O -D_MINIX -D_POSIX_SOURCE -wo" - -LIBRARIES=liby - -liby_FILES=" \ - main.c \ - yyerror.c" - -TYPE=ack diff --git a/lib/ack/math/Makefile.in b/lib/ack/math/Makefile.in deleted file mode 100644 index a05920268..000000000 --- a/lib/ack/math/Makefile.in +++ /dev/null @@ -1,13 +0,0 @@ -# Makefile for lib/ack/math. - -CFLAGS="-O -D_MINIX -D_POSIX_SOURCE" - -LIBRARIES=libc - -libc_FILES=" \ - frexp.s \ - modf.s \ - isnan.c \ - ldexp.c" - -TYPE=ack diff --git a/lib/ack/rts/Makefile.in b/lib/ack/rts/Makefile.in deleted file mode 100644 index 4405bc5bc..000000000 --- a/lib/ack/rts/Makefile.in +++ /dev/null @@ -1,9 +0,0 @@ -# Makefile for lib/ack/rts. - -CFLAGS="-O -D_MINIX -D_POSIX_SOURCE" - -LIBRARIES=libc - -libc_FILES=setjmp.e - -TYPE=ack diff --git a/lib/ack_build.sh b/lib/ack_build.sh new file mode 100755 index 000000000..aceee3287 --- /dev/null +++ b/lib/ack_build.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +export COMPILER_TYPE=ack +export ARCH=i386 + +if [ "$COMPILER_TYPE" = 'ack' ]; then + export CC=cc + export MAKEOBJDIR=obj-ack +elif [ "$COMPILER_TYPE" = 'gnu' ]; then + export CC=gcc + export AR=gar + export MAKEOBJDIR=obj-gnu + export PATH=$PATH:/usr/gnu/bin +fi + +make $@ diff --git a/lib/ansi/Makefile.in b/lib/ansi/Makefile.in deleted file mode 100644 index 7c9c34898..000000000 --- a/lib/ansi/Makefile.in +++ /dev/null @@ -1,84 +0,0 @@ -# Makefile for lib/ansi. - -# This Makefile compiles part of the C library, the functions required by the -# ANSI C standard. This Makefile, and those in the other subdirectories use -# a little known feature of make, the ability to refer to a file within a -# library. The construct abs.o' names the file 'abs.o' contained -# in 'libc.a'. So the rule -# -# abs.o: abs.c -# cc -c abs.c -# aal cr libc.a abs.o -# rm abs.o -# -# compiles abs.c and installs the result abs.o in libc.a if abs.c is newer -# than the abs.o in the library. This Makefile does not work like this -# precisely, it first compiles all changed source files and than installs -# them all in one 'aal' command. - -# Many of the string functions in this directory are not used, because the -# have fast assembly implementations. - -CFLAGS="-O -D_MINIX -D_POSIX_SOURCE -D__USG" - -LIBRARIES=libc -libc_FILES=" \ - abort.c \ - abs.c \ - assert.c \ - atexit.c \ - atof.c \ - atoi.c \ - atol.c \ - bsearch.c \ - calloc.c \ - chartab.c \ - clock.c \ - difftime.c \ - div.c \ - errlist.c \ - exit.c \ - ext_comp.c \ - getenv.c \ - isalnum.c \ - isalpha.c \ - isascii.c \ - iscntrl.c \ - isdigit.c \ - isgraph.c \ - islower.c \ - isprint.c \ - ispunct.c \ - isspace.c \ - isupper.c \ - isxdigit.c \ - labs.c \ - ldiv.c \ - localeconv.c \ - malloc.c \ - mblen.c \ - mbstowcs.c \ - mbtowc.c \ - misc.c \ - qsort.c \ - raise.c \ - rand.c \ - setlocale.c \ - sigmisc.c \ - signal.c \ - strcoll.c \ - strcspn.c \ - strerror.c \ - strpbrk.c \ - strspn.c \ - strstr.c \ - strtok.c \ - strtol.c \ - strxfrm.c \ - system.c \ - tolower.c \ - toupper.c \ - wcstombs.c \ - wctomb.c" - -TYPE=both diff --git a/lib/csu/Makefile b/lib/csu/Makefile new file mode 100644 index 000000000..ee4a75b38 --- /dev/null +++ b/lib/csu/Makefile @@ -0,0 +1,16 @@ +.include + +.PATH: ${.CURDIR}/${ARCH} + +AFLAGS+= -O -D_MINIX -D_POSIX_SOURCE + +SRCS= crtso.s +OBJS= crtso.o + +realall: ${OBJS} + +FILES=${OBJS} +FILESDIR=${LIBDIR} +CLEANFILES=${OBJS} + +.include diff --git a/lib/i386/rts/crtso.s b/lib/csu/i386/crtso.s similarity index 100% rename from lib/i386/rts/crtso.s rename to lib/csu/i386/crtso.s diff --git a/lib/dummy/Makefile.in b/lib/dummy/Makefile.in deleted file mode 100644 index e8ad80c10..000000000 --- a/lib/dummy/Makefile.in +++ /dev/null @@ -1,13 +0,0 @@ -# Makefile for lib/dummy. - -# Make a dummy libm library so that -lm works. - - -LIBRARIES=libm - -libm_FILES=dummy.c - -TYPE=both - -#dummy.c: -# echo "int __dummy__;" > $@ diff --git a/lib/end/Makefile.in b/lib/end/Makefile.in deleted file mode 100644 index 369497d02..000000000 --- a/lib/end/Makefile.in +++ /dev/null @@ -1,11 +0,0 @@ -# Makefile for lib/end. - -LIBRARIES=end - -end_FILES=" \ - edata.s \ - em_end.s \ - end.s \ - etext.s" - -TYPE=both diff --git a/lib/float/FP.compile b/lib/float/FP.compile deleted file mode 100755 index 6e24ac3a3..000000000 --- a/lib/float/FP.compile +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh -# Author: Kees J. Bot -# Compile one soft FP source file. -# (These files shouldn't be optimized normally, but the 16-bit C compiler -# only optimizes scratch register allocation a bit with -O. To the 32-bit -# compiler -O is a no-op.) - -case $#:$1 in -1:*.c) ;; -*) echo "$0: $1: not a C file" >&2; exit 1 -esac - -base="`basename "$1" .c`" -trap 'rm -f tmp.s "$base.s"; exit 1' 2 - -cc -O -I. -D_MINIX -D_POSIX_SOURCE -S "$1" && -mv "$base.s" tmp.s && -sed -f FP.script tmp.s > "$base.s" && -cc -c "$base.s" && -rm tmp.s "$base.s" diff --git a/lib/float/FP.script b/lib/float/FP.script deleted file mode 100755 index 56a3fd608..000000000 --- a/lib/float/FP.script +++ /dev/null @@ -1,39 +0,0 @@ -s/_adf4/.adf4/ -s/_adf8/.adf8/ -s/_cff4/.cff4/ -s/_cff8/.cff8/ -s/_cfi/.cfi/ -s/_cfu/.cfu/ -s/_cif4/.cif4/ -s/_cif8/.cif8/ -s/_cmf4/.cmf4/ -s/_cmf8/.cmf8/ -s/_cuf4/.cuf4/ -s/_cuf8/.cuf8/ -s/_dvf4/.dvf4/ -s/_dvf8/.dvf8/ -s/_fef4/.fef4/ -s/_fef8/.fef8/ -s/_fif4/.fif4/ -s/_fif8/.fif8/ -s/_mlf4/.mlf4/ -s/_mlf8/.mlf8/ -s/_ngf4/.ngf4/ -s/_ngf8/.ngf8/ -s/_sbf4/.sbf4/ -s/_sbf8/.sbf8/ -s/_zrf4/.zrf4/ -s/_zrf8/.zrf8/ -s/_add_ext/.add_ext/ -s/_div_ext/.div_ext/ -s/_mul_ext/.mul_ext/ -s/_nrm_ext/.nrm_ext/ -s/_sft_ext/.sft_ext/ -s/_sub_ext/.sub_ext/ -s/_zrf_ext/.zrf_ext/ -s/_compact/.compact/ -s/_extend/.extend/ -s/_b64_add/.b64_add/ -s/_b64_sft/.b64_sft/ -s/_b64_rsft/.b64_rsft/ -s/_b64_lsft/.b64_lsft/ diff --git a/lib/float/FP_bias.h b/lib/float/FP_bias.h deleted file mode 100644 index db17a4132..000000000 --- a/lib/float/FP_bias.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - include file for floating point package -*/ - - /* FLOAT FORMAT EXPONENT BIAS */ - -#define SGL_BIAS 127 /* excess 128 notation used */ -#define DBL_BIAS 1023 /* excess 1024 notation used */ -#define EXT_BIAS 0 /* 2s-complement notation used */ - /* this is possible because the */ - /* sign is in a seperate word */ - - /* VARIOUS MAX AND MIN VALUES */ - /* 1) FOR THE DIFFERENT FORMATS */ - -#define SGL_MAX 254 /* standard definition */ -#define SGL_MIN 1 /* standard definition */ -#define DBL_MAX 2046 /* standard definition */ -#define DBL_MIN 1 /* standard definition */ -#define EXT_MAX 16383 /* standard minimum */ -#define EXT_MIN -16382 /* standard minimum */ diff --git a/lib/float/FP_shift.h b/lib/float/FP_shift.h deleted file mode 100644 index 5b685636f..000000000 --- a/lib/float/FP_shift.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - include file for floating point package -*/ - -# define CARRYBIT 0x80000000L -# define NORMBIT 0x80000000L -# define EXP_STORE 16 - - - /* parameters for Single Precision */ -#define SGL_EXPSHIFT 7 -#define SGL_M1LEFT 8 -#define SGL_ZERO 0xffffff80L -#define SGL_EXACT 0xff -#define SGL_RUNPACK SGL_M1LEFT - -#define SGL_ROUNDUP 0x80 -#define SGL_CARRYOUT 0x01000000L -#define SGL_MASK 0x007fffffL - - /* parameters for Double Precision */ - /* used in extend.c */ - -#define DBL_EXPSHIFT 4 - -#define DBL_M1LEFT 11 - -#define DBL_RPACK (32-DBL_M1LEFT) -#define DBL_LPACK DBL_M1LEFT - - /* used in compact.c */ - -#define DBL_ZERO 0xfffffd00L - -#define DBL_EXACT 0x7ff - -#define DBL_RUNPACK DBL_M1LEFT -#define DBL_LUNPACK (32-DBL_RUNPACK) - -#define DBL_ROUNDUP 0x400 -#define DBL_CARRYOUT 0x00200000L -#define DBL_MASK 0x000fffffL diff --git a/lib/float/FP_trap.h b/lib/float/FP_trap.h deleted file mode 100644 index 045897bc3..000000000 --- a/lib/float/FP_trap.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - include file for floating point package -*/ - - /* EM TRAPS */ - -#define EIOVFL 3 /* Integer Overflow */ -#define EFOVFL 4 /* Floating Overflow */ -#define EFUNFL 5 /* Floating Underflow */ -#define EIDIVZ 6 /* Integer Divide by 0 */ -#define EFDIVZ 7 /* Floating Divide by 0.0 */ -#define EIUND 8 /* Integer Undefined Number */ -#define EFUND 9 /* Floating Undefined Number */ -#define ECONV 10 /* Conversion Error */ -# define trap(x) _fptrp(x) diff --git a/lib/float/FP_types.h b/lib/float/FP_types.h deleted file mode 100644 index a23f32b89..000000000 --- a/lib/float/FP_types.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/********************************************************/ -/* - Type definitions for C Floating Point Package - include file for floating point package -*/ -/********************************************************/ -/* - THESE STRUCTURES ARE USED TO ADDRESS THE INDIVIDUAL - PARTS OF THE FLOATING POINT NUMBER REPRESENTATIONS. - - THREE STRUCTURES ARE DEFINED: - SINGLE: single precision floating format - DOUBLE: double precision floating format - EXTEND: double precision extended format -*/ -/********************************************************/ - -#ifndef __FPTYPES -#define __FPTYPES - -typedef struct { - unsigned long h_32; /* higher 32 bits of 64 */ - unsigned long l_32; /* lower 32 bits of 64 */ -} B64; - -typedef unsigned long SINGLE; - -typedef struct { - unsigned long d[2]; -} DOUBLE; - -typedef struct { /* expanded float format */ - short sign; - short exp; - B64 mantissa; -#define m1 mantissa.h_32 -#define m2 mantissa.l_32 -} EXTEND; - -struct fef4_returns { - int e; - SINGLE f; -}; - -struct fef8_returns { - int e; - DOUBLE f; -}; - -struct fif4_returns { - SINGLE ipart; - SINGLE fpart; -}; - -struct fif8_returns { - DOUBLE ipart; - DOUBLE fpart; -}; - -#if __STDC__ -#define _PROTOTYPE(function, params) function params -#else -#define _PROTOTYPE(function, params) function() -#endif -_PROTOTYPE( void add_ext, (EXTEND *e1, EXTEND *e2)); -_PROTOTYPE( void mul_ext, (EXTEND *e1, EXTEND *e2)); -_PROTOTYPE( void div_ext, (EXTEND *e1, EXTEND *e2)); -_PROTOTYPE( void sub_ext, (EXTEND *e1, EXTEND *e2)); -_PROTOTYPE( void sft_ext, (EXTEND *e1, EXTEND *e2)); -_PROTOTYPE( void nrm_ext, (EXTEND *e1)); -_PROTOTYPE( void zrf_ext, (EXTEND *e1)); -_PROTOTYPE( void extend, (unsigned long *from, EXTEND *to, int size)); -_PROTOTYPE( void compact, (EXTEND *from, unsigned long *to, int size)); -_PROTOTYPE( void _fptrp, (int)); -_PROTOTYPE( void adf4, (SINGLE s2, SINGLE s1)); -_PROTOTYPE( void adf8, (DOUBLE s2, DOUBLE s1)); -_PROTOTYPE( void sbf4, (SINGLE s2, SINGLE s1)); -_PROTOTYPE( void sbf8, (DOUBLE s2, DOUBLE s1)); -_PROTOTYPE( void dvf4, (SINGLE s2, SINGLE s1)); -_PROTOTYPE( void dvf8, (DOUBLE s2, DOUBLE s1)); -_PROTOTYPE( void mlf4, (SINGLE s2, SINGLE s1)); -_PROTOTYPE( void mlf8, (DOUBLE s2, DOUBLE s1)); -_PROTOTYPE( void ngf4, (SINGLE f)); -_PROTOTYPE( void ngf8, (DOUBLE f)); -_PROTOTYPE( void zrf4, (SINGLE *l)); -_PROTOTYPE( void zrf8, (DOUBLE *z)); -_PROTOTYPE( void cff4, (DOUBLE src)); -_PROTOTYPE( void cff8, (SINGLE src)); -_PROTOTYPE( void cif4, (int ss, long src)); -_PROTOTYPE( void cif8, (int ss, long src)); -_PROTOTYPE( void cuf4, (int ss, long src)); -_PROTOTYPE( void cuf8, (int ss, long src)); -_PROTOTYPE( long cfu, (int ds, int ss, DOUBLE src)); -_PROTOTYPE( long cfi, (int ds, int ss, DOUBLE src)); -_PROTOTYPE( int cmf4, (SINGLE s2, SINGLE s1)); -_PROTOTYPE( int cmf8, (DOUBLE d1, DOUBLE d2)); -_PROTOTYPE( void fef4, (struct fef4_returns *r, SINGLE s1)); -_PROTOTYPE( void fef8, (struct fef8_returns *r, DOUBLE s1)); -_PROTOTYPE( void fif4, (struct fif4_returns *p, SINGLE x, SINGLE y)); -_PROTOTYPE( void fif8, (struct fif8_returns *p, DOUBLE x, DOUBLE y)); - -_PROTOTYPE( void b64_sft, (B64 *, int)); -_PROTOTYPE( void b64_lsft, (B64 *)); -_PROTOTYPE( void b64_rsft, (B64 *)); -_PROTOTYPE( int b64_add, (B64 *, B64 *)); -#endif diff --git a/lib/float/add_ext.c b/lib/float/add_ext.c deleted file mode 100644 index a077663ab..000000000 --- a/lib/float/add_ext.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - ADD TWO EXTENDED FORMAT NUMBERS -*/ - -#include "FP_types.h" - -void -add_ext(e1,e2) -register EXTEND *e1,*e2; -{ - if ((e2->m1 | e2->m2) == 0L) { - return; - } - if ((e1->m1 | e1->m2) == 0L) { - *e1 = *e2; - return; - } - sft_ext(e1, e2); /* adjust mantissas to equal powers */ - if (e1->sign != e2->sign) { - /* e1 + e2 = e1 - (-e2) */ - if (e2->m1 > e1->m1 || - (e2->m1 == e1->m1 && e2->m2 > e1->m2)) { - /* abs(e2) > abs(e1) */ - EXTEND x; - - x = *e1; - *e1 = *e2; - if (x.m2 > e1->m2) { - e1->m1 -= 1; /* carry in */ - } - e1->m1 -= x.m1; - e1->m2 -= x.m2; - } - else { - if (e2->m2 > e1->m2) - e1->m1 -= 1; /* carry in */ - e1->m1 -= e2->m1; - e1->m2 -= e2->m2; - } - } - else { - if (b64_add(&e1->mantissa,&e2->mantissa)) { /* addition carry */ - b64_rsft(&e1->mantissa); /* shift mantissa one bit RIGHT */ - e1->m1 |= 0x80000000L; /* set max bit */ - e1->exp++; /* increase the exponent */ - } - } - nrm_ext(e1); -} diff --git a/lib/float/adder.c b/lib/float/adder.c deleted file mode 100644 index a0af3ce75..000000000 --- a/lib/float/adder.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - * these are the routines the routines to do 32 and 64-bit addition - */ - -# ifdef EXT_DEBUG -# include -# endif - -# include "FP_types.h" -# define UNKNOWN -1 -# define TRUE 1 -# define FALSE 0 -# define MAXBIT 0x80000000L - - /* - * add 64 bits - */ -int -b64_add(e1,e2) - /* - * pointers to 64 bit 'registers' - */ -register B64 *e1,*e2; -{ - register int overflow; - int carry; - - /* add higher pair of 32 bits */ - overflow = ((unsigned long) 0xFFFFFFFF - e1->h_32 < e2->h_32); - e1->h_32 += e2->h_32; - - /* add lower pair of 32 bits */ - carry = ((unsigned long) 0xFFFFFFFF - e1->l_32 < e2->l_32); - e1->l_32 += e2->l_32; -# ifdef EXT_DEBUG - printf("\t\t\t\t\tb64_add: overflow (%d); internal carry(%d)\n", - overflow,carry); - fflush(stdout); -# endif - if ((carry) && (++e1->h_32 == 0)) - return(TRUE); /* had a 64 bit overflow */ - return(overflow); /* return status from higher add */ -} diff --git a/lib/float/adder.h b/lib/float/adder.h deleted file mode 100644 index 2fed41451..000000000 --- a/lib/float/adder.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - * include file for 32 & 64 bit addition - */ - -typedef struct B64 { - unsigned long h_32; /* higher 32 bits of 64 */ - unsigned long l_32; /* lower 32 bits of 64 */ -} B64; diff --git a/lib/float/adf4.c b/lib/float/adf4.c deleted file mode 100644 index 572f3daa3..000000000 --- a/lib/float/adf4.c +++ /dev/null @@ -1,32 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - ADD TWO FLOATS - SINGLE (ADF 4) -*/ - -#include "FP_types.h" - -void -adf4(s2,s1) -SINGLE s1,s2; -{ - EXTEND e1,e2; - int swap = 0; - - if (s1 == (SINGLE) 0) { - s1 = s2; - return; - } - if (s2 == (SINGLE) 0) { - return; - } - extend(&s1,&e1,sizeof(SINGLE)); - extend(&s2,&e2,sizeof(SINGLE)); - add_ext(&e1,&e2); - compact(&e1,&s1,sizeof(SINGLE)); -} diff --git a/lib/float/adf8.c b/lib/float/adf8.c deleted file mode 100644 index 387c975c0..000000000 --- a/lib/float/adf8.c +++ /dev/null @@ -1,32 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - ADD TWO FLOATS - DOUBLE (ADF 8) -*/ - -#include "FP_types.h" - -void -adf8(s2,s1) -DOUBLE s1,s2; -{ - EXTEND e1,e2; - - if (s1.d[0] == 0 && s1.d[1] == 0) { - s1 = s2; - return; - } - if (s2.d[0] == 0 && s2.d[1] == 0) { - return; - } - - extend(&s1.d[0],&e1,sizeof(DOUBLE)); - extend(&s2.d[0],&e2,sizeof(DOUBLE)); - add_ext(&e1,&e2); - compact(&e1,&s1.d[0],sizeof(DOUBLE)); -} diff --git a/lib/float/byte_order.h b/lib/float/byte_order.h deleted file mode 100644 index d08b45a5d..000000000 --- a/lib/float/byte_order.h +++ /dev/null @@ -1,6 +0,0 @@ -#define CHAR_UNSIGNED 0 -#define MSB_AT_LOW_ADDRESS 0 -#define MSW_AT_LOW_ADDRESS 0 -#define FL_MSB_AT_LOW_ADDRESS 0 -#define FL_MSW_AT_LOW_ADDRESS 0 -#define FL_MSL_AT_LOW_ADDRESS 0 diff --git a/lib/float/cff4.c b/lib/float/cff4.c deleted file mode 100644 index ae3b740c5..000000000 --- a/lib/float/cff4.c +++ /dev/null @@ -1,28 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - CONVERT DOUBLE TO SINGLE (CFF 8 4) - - This routine works quite simply. A floating point - of size 08 is converted to extended format. - This extended variable is converted back to - a floating point of size 04. - -*/ - -#include "FP_types.h" - -void -cff4(src) -DOUBLE src; /* the source itself - THIS TIME it's DOUBLE */ -{ - EXTEND buf; - - extend(&src.d[0],&buf,sizeof(DOUBLE)); /* no matter what */ - compact(&buf,&(src.d[1]),sizeof(SINGLE)); -} diff --git a/lib/float/cff8.c b/lib/float/cff8.c deleted file mode 100644 index a851803ad..000000000 --- a/lib/float/cff8.c +++ /dev/null @@ -1,28 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - CONVERT SINGLE TO DOUBLE (CFF 4 8) - - This routine works quite simply. A floating point - of size 04 is converted to extended format. - This extended variable is converted back to - a floating point of size 08. - -*/ - -#include "FP_types.h" - -void -cff8(src) -SINGLE src; -{ - EXTEND buf; - - extend(&src,&buf,sizeof(SINGLE)); /* no matter what */ - compact(&buf, &src,sizeof(DOUBLE)); -} diff --git a/lib/float/cfi.c b/lib/float/cfi.c deleted file mode 100644 index cfd28230e..000000000 --- a/lib/float/cfi.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - CONVERT FLOAT TO SIGNED (CFI m n) - - N.B. The caller must know what it is getting. - A LONG is always returned. If it is an - integer the high byte is cleared first. -*/ - -#include "FP_trap.h" -#include "FP_types.h" -#include "FP_shift.h" - -long -cfi(ds,ss,src) -int ds; /* destination size (2 or 4) */ -int ss; /* source size (4 or 8) */ -DOUBLE src; /* assume worst case */ -{ - EXTEND buf; - long new; - short max_exp; - - extend(&src.d[0],&buf,ss); /* get extended format */ - if (buf.exp < 0) { /* no conversion needed */ - src.d[ss == 8] = 0L; - return(0L); - } - max_exp = (ds << 3) - 2; /* signed numbers */ - /* have more limited max_exp */ - if (buf.exp > max_exp) { - if (buf.exp == max_exp+1 && buf.sign && buf.m1 == NORMBIT && - buf.m2 == 0L) { - } - else { - trap(EIOVFL); /* integer overflow */ - buf.exp %= max_exp; /* truncate */ - } - } - new = buf.m1 >> (31-buf.exp); - if (buf.sign) - new = -new; -done: - src.d[ss == 8] = new; - return(new); -} diff --git a/lib/float/cfu.c b/lib/float/cfu.c deleted file mode 100644 index e9a551ac7..000000000 --- a/lib/float/cfu.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - CONVERT FLOAT TO UNSIGNED (CFU m n) - - N.B. The caller must know what it is getting. - A LONG is always returned. If it is an - integer the high byte is cleared first. -*/ - -#include "FP_trap.h" -#include "FP_types.h" - -long -cfu(ds,ss,src) -int ds; /* destination size (2 or 4) */ -int ss; /* source size (4 or 8) */ -DOUBLE src; /* assume worst case */ -{ - EXTEND buf; - long new; - short newint, max_exp; - - extend(&src.d[0],&buf,ss); /* get extended format */ - if (buf.exp < 0) { /* no conversion needed */ - src.d[ss == 8] = 0L; - return(0L); - } - max_exp = (ds << 3) - 1; - if (buf.exp > max_exp) { - trap(EIOVFL); /* integer overflow */ - buf.exp %= max_exp; - } - new = buf.m1 >> (31-buf.exp); -done: - src.d[ss == 8] = new; - return(new); -} diff --git a/lib/float/cif4.c b/lib/float/cif4.c deleted file mode 100644 index 160d5f6d2..000000000 --- a/lib/float/cif4.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - CONVERT INTEGER TO SINGLE (CIF n 4) - - THIS ROUTINE WORKS BY FILLING AN EXTENDED - WITH THE INTEGER VALUE IN EXTENDED FORMAT - AND USES COMPACT() TO PUT IT INTO THE PROPER - FLOATING POINT PRECISION. -*/ - -#include "FP_types.h" - -void -cif4(ss,src) -int ss; /* source size */ -long src; /* largest possible integer to convert */ -{ - EXTEND buf; - short *ipt; - long i_src; - SINGLE *result; - - zrf_ext(&buf); - if (ss == sizeof(long)) { - buf.exp = 31; - i_src = src; - result = (SINGLE *) &src; - } - else { - ipt = (short *) &src; - i_src = (long) *ipt; - buf.exp = 15; - result = (SINGLE *) &ss; - } - if (i_src == 0) { - *result = (SINGLE) 0L; - return; - } - /* ESTABLISHED THAT src != 0 */ - /* adjust exponent field */ - buf.sign = (i_src < 0) ? 0x8000 : 0; - /* clear sign bit of integer */ - /* move to mantissa field */ - buf.m1 = (i_src < 0) ? -i_src : i_src; - /* adjust mantissa field */ - if (ss != sizeof(long)) - buf.m1 <<= 16; - nrm_ext(&buf); /* adjust mantissa field */ - compact(&buf, result,sizeof(SINGLE)); /* put on stack */ -} diff --git a/lib/float/cif8.c b/lib/float/cif8.c deleted file mode 100644 index 1ab979813..000000000 --- a/lib/float/cif8.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - CONVERT INTEGER TO FLOAT (CIF n 8) - - THIS ROUTINE WORKS BY FILLING AN EXTENDED - WITH THE INTEGER VALUE IN EXTENDED FORMAT - AND USES COMPACT() TO PUT IT INTO THE PROPER - FLOATING POINT PRECISION. -*/ - -#include "FP_types.h" - -void -cif8(ss,src) -int ss; /* source size */ -long src; /* largest possible integer to convert */ -{ - EXTEND buf; - DOUBLE *result; /* for return value */ - short *ipt; - long i_src; - - result = (DOUBLE *) ((void *) &ss); /* always */ - zrf_ext(&buf); - if (ss == sizeof(long)) { - buf.exp = 31; - i_src = src; - } - else { - ipt = (short *) &src; - i_src = (long) *ipt; - buf.exp = 15; - } - if (i_src == 0) { - zrf8(result); - return; - } - /* ESTABLISHED THAT src != 0 */ - /* adjust exponent field */ - buf.sign = (i_src < 0) ? 0x8000 : 0; - /* clear sign bit of integer */ - /* move to mantissa field */ - buf.m1 = (i_src < 0) ? -i_src : i_src; - /* adjust mantissa field */ - if (ss != sizeof(long)) - buf.m1 <<= 16; - nrm_ext(&buf); - compact(&buf,&result->d[0],8); -} diff --git a/lib/float/cmf4.c b/lib/float/cmf4.c deleted file mode 100644 index ee186ff4c..000000000 --- a/lib/float/cmf4.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - COMPARE SINGLES (CMF 4) -*/ - -#include "FP_types.h" -#include "get_put.h" - -int -cmf4(f1,f2) -SINGLE f1,f2; -{ - /* - * return ((f1 < f2) ? 1 : (f1 - f2)) - */ -#define SIGN(x) (((x) < 0) ? -1 : 1) - int sign1,sign2; - long l1,l2; - - l1 = get4((char *) &f1); - l2 = get4((char *) &f2); - - if (l1 == l2) return 0; - - sign1 = SIGN(l1); - sign2 = SIGN(l2); - if (sign1 != sign2) { - if ((l1 & 0x7fffffff) == 0 && - (l2 & 0x7fffffff) == 0) return 0; - return ((sign1 > 0) ? -1 : 1); - } - - return (sign1 * ((l1 < l2) ? 1 : -1)); -} diff --git a/lib/float/cmf8.c b/lib/float/cmf8.c deleted file mode 100644 index 5badab0c4..000000000 --- a/lib/float/cmf8.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - COMPARE DOUBLES (CMF 8) -*/ - -#include "FP_types.h" -#include "get_put.h" - -int -cmf8(d1,d2) -DOUBLE d1,d2; -{ -#define SIGN(x) (((x) < 0) ? -1 : 1) - /* - * return ((d1 < d2) ? 1 : (d1 > d2) ? -1 : 0)) - */ - long l1,l2; - int sign1,sign2; - int rv; - -#if FL_MSL_AT_LOW_ADDRESS - l1 = get4((char *)&d1); - l2 = get4((char *)&d2); -#else - l1 = get4(((char *)&d1+4)); - l2 = get4(((char *)&d2+4)); -#endif - sign1 = SIGN(l1); - sign2 = SIGN(l2); - if (sign1 != sign2) { - l1 &= 0x7fffffff; - l2 &= 0x7fffffff; - if (l1 != 0 || l2 != 0) { - return ((sign1 > 0) ? -1 : 1); - } - } - if (l1 != l2) { /* we can decide here */ - rv = l1 < l2 ? 1 : -1; - } - else { /* decide in 2nd half */ - unsigned long u1, u2; -#if FL_MSL_AT_LOW_ADDRESS - u1 = get4(((char *)&d1 + 4)); - u2 = get4(((char *)&d2 + 4)); -#else - u1 = get4((char *)&d1); - u2 = get4((char *)&d2); -#endif - if (u1 == u2) - return(0); - if (u1 < u2) rv = 1; - else rv = -1; - } - return sign1 * rv; -} diff --git a/lib/float/compact.c b/lib/float/compact.c deleted file mode 100644 index a5a1074d1..000000000 --- a/lib/float/compact.c +++ /dev/null @@ -1,202 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - COMPACT EXTEND FORMAT INTO FLOAT OF PROPER SIZE -*/ - -# include "FP_bias.h" -# include "FP_shift.h" -# include "FP_trap.h" -# include "FP_types.h" -# include "get_put.h" - -void -compact(f,to,size) -EXTEND *f; -unsigned long *to; -int size; -{ - int error = 0; - - if (size == sizeof(DOUBLE)) { - /* - * COMPACT EXTENDED INTO DOUBLE - */ - DOUBLE *DBL = (DOUBLE *) (void *) to; - - if ((f->m1|(f->m2 & DBL_ZERO)) == 0L) { - zrf8(DBL); - return; - } - f->exp += DBL_BIAS; /* restore proper bias */ - if (f->exp > DBL_MAX) { -dbl_over: trap(EFOVFL); - f->exp = DBL_MAX+1; - f->m1 = 0; - f->m2 = 0; - if (error++) - return; - } - else if (f->exp < DBL_MIN) { - b64_rsft(&(f->mantissa)); - if (f->exp < 0) { - b64_sft(&(f->mantissa), -f->exp); - f->exp = 0; - } - /* underflow ??? */ - } - - /* local CAST conversion */ - - /* because of special format shift only 10 bits */ - /* bit shift mantissa 10 bits */ - - /* first align within words, then do store operation */ - - DBL->d[0] = f->m1 >> DBL_RUNPACK; /* plus 22 == 32 */ - DBL->d[1] = f->m2 >> DBL_RUNPACK; /* plus 22 == 32 */ - DBL->d[1] |= (f->m1 << DBL_LUNPACK); /* plus 10 == 32 */ - - /* if not exact then round to nearest */ - /* on a tie, round to even */ - -#ifdef EXCEPTION_INEXACT - if ((f->m2 & DBL_EXACT) != 0) { - INEXACT(); -#endif - if (((f->m2 & DBL_EXACT) > DBL_ROUNDUP) - || ((f->m2 & DBL_EXACT) == DBL_ROUNDUP - && (f->m2 & (DBL_ROUNDUP << 1)))) { - DBL->d[1]++; /* rounding up */ - if (DBL->d[1] == 0L) { /* carry out */ - DBL->d[0]++; - - if (f->exp == 0 && (DBL->d[0] & ~DBL_MASK)) { - f->exp++; - } - if (DBL->d[0] & DBL_CARRYOUT) { /* carry out */ - if (DBL->d[0] & 01) - DBL->d[1] = CARRYBIT; - DBL->d[0] >>= 1; - f->exp++; - } - } - /* check for overflow */ - if (f->exp > DBL_MAX) - goto dbl_over; - } -#ifdef EXCEPTION_INEXACT - } -#endif - - /* - * STORE EXPONENT AND SIGN: - * - * 1) clear leading bits (B4-B15) - * 2) shift and store exponent - */ - - DBL->d[0] &= DBL_MASK; - DBL->d[0] |= - ((long) (f->exp << DBL_EXPSHIFT) << EXP_STORE); - if (f->sign) - DBL->d[0] |= CARRYBIT; - - /* - * STORE MANTISSA - */ - -#if FL_MSL_AT_LOW_ADDRESS - put4(DBL->d[0], (char *) &DBL->d[0]); - put4(DBL->d[1], (char *) &DBL->d[1]); -#else - { unsigned long l; - put4(DBL->d[1], (char *) &l); - put4(DBL->d[0], (char *) &DBL->d[1]); - DBL->d[0] = l; - } -#endif - } - else { - /* - * COMPACT EXTENDED INTO FLOAT - */ - SINGLE *SGL; - - /* local CAST conversion */ - SGL = (SINGLE *) (void *) to; - if ((f->m1 & SGL_ZERO) == 0L) { - *SGL = 0L; - return; - } - f->exp += SGL_BIAS; /* restore bias */ - if (f->exp > SGL_MAX) { -sgl_over: trap(EFOVFL); - f->exp = SGL_MAX+1; - f->m1 = 0L; - f->m2 = 0L; - if (error++) - return; - } - else if (f->exp < SGL_MIN) { - b64_rsft(&(f->mantissa)); - if (f->exp < 0) { - b64_sft(&(f->mantissa), -f->exp); - f->exp = 0; - } - /* underflow ??? */ - } - - /* shift mantissa and store */ - *SGL = (f->m1 >> SGL_RUNPACK); - - /* check for rounding to nearest */ - /* on a tie, round to even */ -#ifdef EXCEPTION_INEXACT - if (f->m2 != 0 || - (f->m1 & SGL_EXACT) != 0L) { - INEXACT(); -#endif - if (((f->m1 & SGL_EXACT) > SGL_ROUNDUP) - || ((f->m1 & SGL_EXACT) == SGL_ROUNDUP - && (f->m1 & (SGL_ROUNDUP << 1)))) { - (*SGL)++; - if (f->exp == 0 && (*SGL & ~SGL_MASK)) { - f->exp++; - } - /* check normal */ - if (*SGL & SGL_CARRYOUT) { - *SGL >>= 1; - f->exp++; - } - if (f->exp > SGL_MAX) - goto sgl_over; - } -#ifdef EXCEPTION_INEXACT - } -#endif - - /* - * STORE EXPONENT AND SIGN: - * - * 1) clear leading bit of fraction - * 2) shift and store exponent - */ - - *SGL &= SGL_MASK; /* B23-B31 are 0 */ - *SGL |= ((long) (f->exp << SGL_EXPSHIFT) << EXP_STORE); - if (f->sign) - *SGL |= CARRYBIT; - - /* - * STORE MANTISSA - */ - - put4(*SGL, (char *) &SGL); - } -} diff --git a/lib/float/cuf4.c b/lib/float/cuf4.c deleted file mode 100644 index c022f0e90..000000000 --- a/lib/float/cuf4.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - CONVERT INTEGER TO SINGLE (CUF n 4) - - THIS ROUTINE WORKS BY FILLING AN EXTENDED - WITH THE INTEGER VALUE IN EXTENDED FORMAT - AND USES COMPACT() TO PUT IT INTO THE PROPER - FLOATING POINT PRECISION. -*/ - -#include "FP_types.h" - -void -cuf4(ss,src) -int ss; /* source size */ -long src; /* largest possible integer to convert */ -{ - EXTEND buf; - short *ipt; - SINGLE *result; - long i_src; - - zrf_ext(&buf); - if (ss == sizeof(long)) { - buf.exp = 31; - i_src = src; - result = (SINGLE *) &src; - } - else { - ipt = (short *) &src; - i_src = (long) *ipt; - buf.exp = 15; - result = (SINGLE *) ((void *) &ss); - } - if (i_src == 0) { - *result = (SINGLE) 0L; - return; - } - /* ESTABLISHED THAT src != 0 */ - - /* adjust exponent field */ - if (ss != sizeof(long)) - i_src <<= 16; - - /* move to mantissa field */ - buf.m1 = i_src; - - /* adjust mantissa field */ - nrm_ext(&buf); - compact(&buf,result,4); -} diff --git a/lib/float/cuf8.c b/lib/float/cuf8.c deleted file mode 100644 index d18ec6c7a..000000000 --- a/lib/float/cuf8.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - CONVERT INTEGER TO FLOAT (CUF n 8) - - THIS ROUTINE WORKS BY FILLING AN EXTENDED - WITH THE INTEGER VALUE IN EXTENDED FORMAT - AND USES COMPACT() TO PUT IT INTO THE PROPER - FLOATING POINT PRECISION. -*/ - -#include "FP_types.h" - -void -cuf8(ss,src) -int ss; /* source size */ -long src; /* largest possible integer to convert */ -{ - EXTEND buf; - short *ipt; - long i_src; - - zrf_ext(&buf); - if (ss == sizeof(long)) { - buf.exp = 31; - i_src = src; - } - else { - ipt = (short *) &src; - i_src = (long) *ipt; - buf.exp = 15; - } - if (i_src == 0) { - zrf8((DOUBLE *)((void *)&ss)); - return; - } - /* ESTABLISHED THAT src != 0 */ - - /* adjust exponent field */ - if (ss != sizeof(long)) - i_src <<= 16; - - /* move to mantissa field */ - buf.m1 = i_src; - - /* adjust mantissa field */ - nrm_ext(&buf); - compact(&buf,(unsigned long *) (void *)&ss,8); -} diff --git a/lib/float/div_ext.c b/lib/float/div_ext.c deleted file mode 100644 index bb9531178..000000000 --- a/lib/float/div_ext.c +++ /dev/null @@ -1,266 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - DIVIDE EXTENDED FORMAT -*/ - -#include "FP_bias.h" -#include "FP_trap.h" -#include "FP_types.h" - -/* - November 15, 1984 - - This is a routine to do the work. - There are two versions: - One is based on the partial products method - and makes no use possible machine instructions - to divide (hardware dividers). - The other is used when USE_DIVIDE is defined. It is much faster on - machines with fast 4 byte operations. -*/ -/********************************************************/ - -void -div_ext(e1,e2) -EXTEND *e1,*e2; -{ - short error = 0; - B64 result; - register unsigned long *lp; -#ifndef USE_DIVIDE - short count; -#else - unsigned short u[9], v[5]; - register int j; - register unsigned short *u_p = u; - int maxv = 4; -#endif - - if ((e2->m1 | e2->m2) == 0) { - /* - * Exception 8.2 - Divide by zero - */ - trap(EFDIVZ); - e1->m1 = e1->m2 = 0L; - e1->exp = EXT_MAX; - return; - } - if ((e1->m1 | e1->m2) == 0) { /* 0 / anything == 0 */ - e1->exp = 0; /* make sure */ - return; - } -#ifndef USE_DIVIDE - /* - * numbers are right shifted one bit to make sure - * that m1 is quaranteed to be larger if its - * maximum bit is set - */ - b64_rsft(&e1->mantissa); /* 64 bit shift right */ - b64_rsft(&e2->mantissa); /* 64 bit shift right */ - e1->exp++; - e2->exp++; -#endif - /* check for underflow, divide by zero, etc */ - e1->sign ^= e2->sign; - e1->exp -= e2->exp; - -#ifndef USE_DIVIDE - /* do division of mantissas */ - /* uses partial product method */ - /* init control variables */ - - count = 64; - result.h_32 = 0L; - result.l_32 = 0L; - - /* partial product division loop */ - - while (count--) { - /* first left shift result 1 bit */ - /* this is ALWAYS done */ - - b64_lsft(&result); - - /* compare dividend and divisor */ - /* if dividend >= divisor add a bit */ - /* and subtract divisior from dividend */ - - if ( (e1->m1 < e2->m1) || - ((e1->m1 == e2->m1) && (e1->m2 < e2->m2) )) - ; /* null statement */ - /* i.e., don't add or subtract */ - else { - result.l_32++; /* ADD */ - if (e2->m2 > e1->m2) - e1->m1 -= 1; /* carry in */ - e1->m1 -= e2->m1; /* do SUBTRACTION */ - e1->m2 -= e2->m2; /* SUBTRACTION */ - } - - /* shift dividend left one bit OR */ - /* IF it equals ZERO we can break out */ - /* of the loop, but still must shift */ - /* the quotient the remaining count bits */ - /* NB save the results of this test in error */ - /* if not zero, then the result is inexact. */ - /* this would be reported in IEEE standard */ - - /* lp points to dividend */ - lp = &e1->m1; - - error = ((*lp | *(lp+1)) != 0L) ? 1 : 0; - if (error) { /* more work */ - /* assume max bit == 0 (see above) */ - b64_lsft(&e1->mantissa); - continue; - } - else - break; /* leave loop */ - } /* end of divide by subtraction loop */ - - if (count > 0) { - lp = &result.h_32; - if (count > 31) { /* move to higher word */ - *lp = *(lp+1); - count -= 32; - *(lp+1) = 0L; /* clear low word */ - } - if (*lp) - *lp <<= count; /* shift rest of way */ - lp++; /* == &result.l_32 */ - if (*lp) { - result.h_32 |= (*lp >> 32-count); - *lp <<= count; - } - } -#else /* USE_DIVIDE */ - - u[4] = (e1->m2 & 1) << 15; - b64_rsft(&(e1->mantissa)); - u[0] = e1->m1 >> 16; - u[1] = e1->m1; - u[2] = e1->m2 >> 16; - u[3] = e1->m2; - u[5] = 0; u[6] = 0; u[7] = 0; - v[1] = e2->m1 >> 16; - v[2] = e2->m1; - v[3] = e2->m2 >> 16; - v[4] = e2->m2; - while (! v[maxv]) maxv--; - result.h_32 = 0; - result.l_32 = 0; - lp = &result.h_32; - - /* - * Use an algorithm of Knuth (The art of programming, Seminumerical - * algorithms), to divide u by v. u and v are both seen as numbers - * with base 65536. - */ - for (j = 0; j <= 3; j++, u_p++) { - unsigned long q_est, temp; - - if (j == 2) lp++; - if (u_p[0] == 0 && u_p[1] < v[1]) continue; - temp = ((unsigned long)u_p[0] << 16) + u_p[1]; - if (u_p[0] >= v[1]) { - q_est = 0x0000FFFFL; - } - else { - q_est = temp / v[1]; - } - temp -= q_est * v[1]; - while (temp < 0x10000 && v[2]*q_est > ((temp<<16)+u_p[2])) { - q_est--; - temp += v[1]; - } - /* Now, according to Knuth, we have an estimate of the - quotient, that is either correct or one too big, but - almost always correct. - */ - if (q_est != 0) { - int i; - unsigned long k = 0; - int borrow = 0; - - for (i = maxv; i > 0; i--) { - unsigned long tmp = q_est * v[i] + k + borrow; - unsigned short md = tmp; - - borrow = (md > u_p[i]); - u_p[i] -= md; - k = tmp >> 16; - } - k += borrow; - borrow = u_p[0] < k; - u_p[0] -= k; - - if (borrow) { - /* So, this does not happen often; the estimate - was one too big; correct this - */ - *lp |= (j & 1) ? (q_est - 1) : ((q_est-1)<<16); - borrow = 0; - for (i = maxv; i > 0; i--) { - unsigned long tmp - = v[i]+(unsigned long)u_p[i]+borrow; - - u_p[i] = tmp; - borrow = tmp >> 16; - } - u_p[0] += borrow; - } - else *lp |= (j & 1) ? q_est : (q_est<<16); - } - } -#ifdef EXCEPTION_INEXACT - u_p = &u[0]; - for (j = 7; j >= 0; j--) { - if (*u_p++) { - error = 1; - break; - } - } -#endif -#endif - -#ifdef EXCEPTION_INEXACT - if (error) { - /* - * report here exception 8.5 - Inexact - * from Draft 8.0 of IEEE P754: - * In the absence of an invalid operation exception, - * if the rounded result of an operation is not exact or if - * it overflows without a trap, then the inexact exception - * shall be assigned. The rounded or overflowed result - * shall be delivered to the destination. - */ - INEXACT(); -#endif - e1->mantissa = result; - - nrm_ext(e1); - if (e1->exp < EXT_MIN) { - /* - * Exception 8.4 - Underflow - */ - trap(EFUNFL); /* underflow */ - e1->exp = EXT_MIN; - e1->m1 = e1->m2 = 0L; - return; - } - if (e1->exp >= EXT_MAX) { - /* - * Exception 8.3 - Overflow - */ - trap(EFOVFL); /* overflow */ - e1->exp = EXT_MAX; - e1->m1 = e1->m2 = 0L; - return; - } -} diff --git a/lib/float/dvf4.c b/lib/float/dvf4.c deleted file mode 100644 index 7d82cd8b8..000000000 --- a/lib/float/dvf4.c +++ /dev/null @@ -1,26 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - DIVIDE TWO SINGLES - SINGLE Precision (dvf 4) -*/ - -#include "FP_types.h" - -void -dvf4(s2,s1) -SINGLE s1,s2; -{ - EXTEND e1,e2; - - extend(&s1,&e1,sizeof(SINGLE)); - extend(&s2,&e2,sizeof(SINGLE)); - - /* do a divide */ - div_ext(&e1,&e2); - compact(&e1,&s1,sizeof(SINGLE)); -} diff --git a/lib/float/dvf8.c b/lib/float/dvf8.c deleted file mode 100644 index fafe50f53..000000000 --- a/lib/float/dvf8.c +++ /dev/null @@ -1,26 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - DIVIDE TWO FLOATS - DOUBLE Precision (DVF 8) -*/ - -#include "FP_types.h" - -void -dvf8(s2,s1) -DOUBLE s1,s2; -{ - EXTEND e1,e2; - - extend(&s1.d[0],&e1,sizeof(DOUBLE)); - extend(&s2.d[0],&e2,sizeof(DOUBLE)); - - /* do a divide */ - div_ext(&e1,&e2); - compact(&e1,&s1.d[0],sizeof(DOUBLE)); -} diff --git a/lib/float/extend.c b/lib/float/extend.c deleted file mode 100644 index 70febb1e3..000000000 --- a/lib/float/extend.c +++ /dev/null @@ -1,111 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - CONVERTS FLOATING POINT TO EXTENDED FORMAT - - Two sizes of FLOATING Point are known: - SINGLE and DOUBLE -*/ -/********************************************************/ -/* - It is not required to normalize in extended - format, but it has been chosen to do so. - Extended Format is as follows (at exit): - -->sign S000 0000 | 0000 0000 -->exp 0EEE EEEE | EEEE EEEE -->m1 LFFF FFFF | FFFF FFFF - FFFF FFFF | FFFF FFFF -->m2 FFFF FFFF | FFFF FFFF - FFFF F000 | 0000 0000 -*/ -/********************************************************/ - -#include "FP_bias.h" -#include "FP_shift.h" -#include "FP_types.h" -#include "get_put.h" -/********************************************************/ - -void -extend(from,to,size) -unsigned long *from; -EXTEND *to; -int size; -{ - register char *cpt1; - unsigned long tmp; - int leadbit = 0; - - cpt1 = (char *) from; - -#if FL_MSL_AT_LOW_ADDRESS -#if FL_MSW_AT_LOW_ADDRESS - to->exp = uget2(cpt1); -#else - to->exp = uget2(cpt1+2); -#endif -#else -#if FL_MSW_AT_LOW_ADDRESS - to->exp = uget2(cpt1+(size == sizeof(DOUBLE) ? 4 : 0)); -#else - to->exp = uget2(cpt1+(size == sizeof(DOUBLE) ? 6 : 2)); -#endif -#endif - to->sign = (to->exp & 0x8000); /* set sign bit */ - to->exp ^= to->sign; - if (size == sizeof(DOUBLE)) - to->exp >>= DBL_EXPSHIFT; - else - to->exp >>= SGL_EXPSHIFT; - if (to->exp > 0) - leadbit++; /* will set Lead bit later */ - else to->exp++; - - if (size == sizeof(DOUBLE)) { -#if FL_MSL_AT_LOW_ADDRESS - to->m1 = get4(cpt1); - cpt1 += 4; - tmp = get4(cpt1); -#else - tmp = get4(cpt1); - cpt1 += 4; - to->m1 = get4(cpt1); -#endif - if (to->exp == 1 && to->m1 == 0 && tmp == 0) { - to->exp = 0; - to->sign = 0; - to->m1 = 0; - to->m2 = 0; - return; - } - to->m1 <<= DBL_M1LEFT; /* shift */ - to->exp -= DBL_BIAS; /* remove bias */ - to->m1 |= (tmp>>DBL_RPACK); /* plus 10 == 32 */ - to->m2 = (tmp<m1 = get4(cpt1); - to->m1 <<= SGL_M1LEFT; /* shift */ - if (to->exp == 1 && to->m1 == 0) { - to->exp = 0; - to->sign = 0; - to->m1 = 0; - to->m2 = 0; - return; - } - to->exp -= SGL_BIAS; /* remove bias */ - to->m2 = 0L; - } - - to->m1 |= NORMBIT; /* set bit L */ - if (leadbit == 0) { /* set or clear Leading Bit */ - to->m1 &= ~NORMBIT; /* clear bit L */ - nrm_ext(to); /* and normalize */ - } -} diff --git a/lib/float/fef4.c b/lib/float/fef4.c deleted file mode 100644 index ff426f57b..000000000 --- a/lib/float/fef4.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - SEPERATE INTO EXPONENT AND FRACTION (FEF 4) -*/ - -#include "FP_types.h" - -void -fef4(r,s1) -SINGLE s1; -struct fef4_returns *r; -{ - EXTEND buf; - register struct fef4_returns *p = r; /* make copy; r might refer - to itself (see table) - */ - - extend(&s1,&buf,sizeof(SINGLE)); - if (buf.exp == 0 && buf.m1 == 0 && buf.m2 == 0) { - p->e = 0; - } - else { - p->e = buf.exp+1; - buf.exp = -1; - } - compact(&buf,&p->f,sizeof(SINGLE)); -} diff --git a/lib/float/fef8.c b/lib/float/fef8.c deleted file mode 100644 index 1c3b3b0b5..000000000 --- a/lib/float/fef8.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - SEPERATE DOUBLE INTO EXPONENT AND FRACTION (FEF 8) -*/ - -#include "FP_types.h" - -void -fef8(r, s1) -DOUBLE s1; -struct fef8_returns *r; -{ - EXTEND buf; - register struct fef8_returns *p = r; /* make copy, r might refer - to itself (see table) - */ - - extend(&s1.d[0],&buf,sizeof(DOUBLE)); - if (buf.exp == 0 && buf.m1 == 0 && buf.m2 == 0) { - p->e = 0; - } - else { - p->e = buf.exp + 1; - buf.exp = -1; - } - compact(&buf,&p->f.d[0],sizeof(DOUBLE)); -} diff --git a/lib/float/fif4.c b/lib/float/fif4.c deleted file mode 100644 index 059372469..000000000 --- a/lib/float/fif4.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - MULTIPLY AND DISMEMBER PARTS (FIF 4) -*/ - -#include "FP_types.h" -#include "FP_shift.h" - -void -fif4(p,x,y) -SINGLE x,y; -struct fif4_returns *p; -{ - - EXTEND e1,e2; - - extend(&y,&e1,sizeof(SINGLE)); - extend(&x,&e2,sizeof(SINGLE)); - /* do a multiply */ - mul_ext(&e1,&e2); - e2 = e1; - compact(&e2,&y,sizeof(SINGLE)); - if (e1.exp < 0) { - p->ipart = 0; - p->fpart = y; - return; - } - if (e1.exp > 30 - SGL_M1LEFT) { - p->ipart = y; - p->fpart = 0; - return; - } - b64_sft(&e1.mantissa, 63 - e1.exp); - b64_sft(&e1.mantissa, e1.exp - 63); /* "loose" low order bits */ - compact(&e1,&(p->ipart),sizeof(SINGLE)); - extend(&(p->ipart), &e2, sizeof(SINGLE)); - extend(&y, &e1, sizeof(SINGLE)); - sub_ext(&e1, &e2); - compact(&e1, &(p->fpart), sizeof(SINGLE)); -} diff --git a/lib/float/fif8.c b/lib/float/fif8.c deleted file mode 100644 index 9f1b9b15e..000000000 --- a/lib/float/fif8.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - MULTIPLY AND DISMEMBER PARTS (FIF 8) -*/ - -#include "FP_types.h" -#include "FP_shift.h" - -void -fif8(p,x,y) -DOUBLE x,y; -struct fif8_returns *p; -{ - - EXTEND e1,e2; - - extend(&y.d[0],&e1,sizeof(DOUBLE)); - extend(&x.d[0],&e2,sizeof(DOUBLE)); - /* do a multiply */ - mul_ext(&e1,&e2); - e2 = e1; - compact(&e2, &y.d[0], sizeof(DOUBLE)); - if (e1.exp < 0) { - p->ipart.d[0] = 0; - p->ipart.d[1] = 0; - p->fpart = y; - return; - } - if (e1.exp > 62 - DBL_M1LEFT) { - p->ipart = y; - p->fpart.d[0] = 0; - p->fpart.d[1] = 0; - return; - } - b64_sft(&e1.mantissa, 63 - e1.exp); - b64_sft(&e1.mantissa, e1.exp - 63); /* "loose" low order bits */ - compact(&e1, &(p->ipart.d[0]), sizeof(DOUBLE)); - extend(&(p->ipart.d[0]), &e2, sizeof(DOUBLE)); - extend(&y.d[0], &e1, sizeof(DOUBLE)); - sub_ext(&e1, &e2); - compact(&e1, &(p->fpart.d[0]), sizeof(DOUBLE)); -} diff --git a/lib/float/fptrp.s b/lib/float/fptrp.s deleted file mode 100644 index d2823f4d7..000000000 --- a/lib/float/fptrp.s +++ /dev/null @@ -1,19 +0,0 @@ -# -.sect .text; .sect .rom; .sect .data; .sect .bss -.define __fptrp -.sect .text -__fptrp: -#if __i386 - push ebp - mov ebp, esp - mov eax, 8(bp) - call .Xtrp - leave - ret -#else /* i86 */ - push bp - mov bp, sp - mov ax, 4(bp) - call .Xtrp - jmp .cret -#endif diff --git a/lib/float/get_put.h b/lib/float/get_put.h deleted file mode 100644 index 9fd7f606f..000000000 --- a/lib/float/get_put.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -#include - -#if CHAR_UNSIGNED -#define Xchar(ch) (ch) -#else -#define Xchar(ch) ((ch) & 0377) -#endif - -#define BYTES_REVERSED (MSB_AT_LOW_ADDRESS != FL_MSB_AT_LOW_ADDRESS) -#define WORDS_REVERSED (MSW_AT_LOW_ADDRESS != FL_MSW_AT_LOW_ADDRESS) -#define LONGS_REVERSED (FL_MSL_AT_LOW_ADDRESS) - -#if BYTES_REVERSED -#define uget2(c) (Xchar((c)[1]) | ((unsigned) Xchar((c)[0]) << 8)) -#define Xput2(i, c) (((c)[1] = (i)), ((c)[0] = (i) >> 8)) -#define put2(i, c) { register int j = (i); Xput2(j, c); } -#else -#define uget2(c) (* ((unsigned short *) (c))) -#define Xput2(i, c) (* ((short *) (c)) = (i)) -#define put2(i, c) Xput2(i, c) -#endif - -#define get2(c) ((short) uget2(c)) - -#if WORDS_REVERSED || BYTES_REVERSED -#define get4(c) (uget2((c)+2) | ((long) uget2(c) << 16)) -#define put4(l, c) { register long x=(l); \ - Xput2((int)x,(c)+2); \ - Xput2((int)(x>>16),(c)); \ - } -#else -#define get4(c) (* ((long *) (c))) -#define put4(l, c) (* ((long *) (c)) = (l)) -#endif diff --git a/lib/float/mlf4.c b/lib/float/mlf4.c deleted file mode 100644 index d5f515d19..000000000 --- a/lib/float/mlf4.c +++ /dev/null @@ -1,25 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - * Multiply Single Precesion Float (MLF 4) - */ - -#include "FP_types.h" - -void -mlf4(s2,s1) -SINGLE s1,s2; -{ - EXTEND e1,e2; - - extend(&s1,&e1,sizeof(SINGLE)); - extend(&s2,&e2,sizeof(SINGLE)); - /* do a multiply */ - mul_ext(&e1,&e2); - compact(&e1,&s1,sizeof(SINGLE)); -} diff --git a/lib/float/mlf8.c b/lib/float/mlf8.c deleted file mode 100644 index b43cdf3c1..000000000 --- a/lib/float/mlf8.c +++ /dev/null @@ -1,25 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - * Multiply Double Precision Float (MLF 8) - */ - -#include "FP_types.h" - -void -mlf8(s2,s1) -DOUBLE s1,s2; -{ - EXTEND e1,e2; - - extend(&s1.d[0],&e1,sizeof(DOUBLE)); - extend(&s2.d[0],&e2,sizeof(DOUBLE)); - /* do a multiply */ - mul_ext(&e1,&e2); - compact(&e1,&s1.d[0],sizeof(DOUBLE)); -} diff --git a/lib/float/mul_ext.c b/lib/float/mul_ext.c deleted file mode 100644 index 78a614014..000000000 --- a/lib/float/mul_ext.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - ROUTINE TO MULTIPLY TWO EXTENDED FORMAT NUMBERS -*/ - -# include "FP_bias.h" -# include "FP_trap.h" -# include "FP_types.h" -# include "FP_shift.h" - -void -mul_ext(e1,e2) -EXTEND *e1,*e2; -{ - register int i,j; /* loop control */ - unsigned short mp[4]; /* multiplier */ - unsigned short mc[4]; /* multipcand */ - unsigned short result[8]; /* result */ - register unsigned short *pres; - - /* first save the sign (XOR) */ - e1->sign ^= e2->sign; - - /* compute new exponent */ - e1->exp += e2->exp + 1; - /* 128 bit multiply of mantissas */ - - /* assign unknown long formats */ - /* to known unsigned word formats */ - mp[0] = e1->m1 >> 16; - mp[1] = (unsigned short) e1->m1; - mp[2] = e1->m2 >> 16; - mp[3] = (unsigned short) e1->m2; - mc[0] = e2->m1 >> 16; - mc[1] = (unsigned short) e2->m1; - mc[2] = e2->m2 >> 16; - mc[3] = (unsigned short) e2->m2; - for (i = 8; i--;) { - result[i] = 0; - } - /* - * fill registers with their components - */ - for(i=4, pres = &result[4];i--;pres--) if (mp[i]) { - unsigned short k = 0; - unsigned long mpi = mp[i]; - for(j=4;j--;) { - unsigned long tmp = (unsigned long)pres[j] + k; - if (mc[j]) tmp += mpi * mc[j]; - pres[j] = tmp; - k = tmp >> 16; - } - pres[-1] = k; - } - if (! (result[0] & 0x8000)) { - e1->exp--; - for (i = 0; i <= 3; i++) { - result[i] <<= 1; - if (result[i+1]&0x8000) result[i] |= 1; - } - result[4] <<= 1; - } - - /* - * combine the registers to a total - */ - e1->m1 = ((unsigned long)(result[0]) << 16) + result[1]; - e1->m2 = ((unsigned long)(result[2]) << 16) + result[3]; - if (result[4] & 0x8000) { - if (++e1->m2 == 0) - if (++e1->m1 == 0) { - e1->m1 = NORMBIT; - e1->exp++; - } - } - - /* check for overflow */ - if (e1->exp >= EXT_MAX) { - trap(EFOVFL); - /* if caught */ - /* return signed infinity */ - e1->exp = EXT_MAX; -infinity: e1->m1 = e1->m2 =0L; - return; - } - /* check for underflow */ - if (e1->exp < EXT_MIN) { - trap(EFUNFL); - e1->exp = EXT_MIN; - goto infinity; - } -} diff --git a/lib/float/ngf4.c b/lib/float/ngf4.c deleted file mode 100644 index 9f1f812ea..000000000 --- a/lib/float/ngf4.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - NEGATE A FLOATING POINT (NGF 4) -*/ -/********************************************************/ - -#include "FP_types.h" -#include "get_put.h" - -#define OFF ((FL_MSW_AT_LOW_ADDRESS ? 0 : 2) + (FL_MSB_AT_LOW_ADDRESS ? 0 : 1)) -void -ngf4(f) -SINGLE f; -{ - unsigned char *p; - - if (f != (SINGLE) 0) { - p = (unsigned char *) &f + OFF; - *p ^= 0x80; - } -} diff --git a/lib/float/ngf8.c b/lib/float/ngf8.c deleted file mode 100644 index 473ffa510..000000000 --- a/lib/float/ngf8.c +++ /dev/null @@ -1,28 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - NEGATE A FLOATING POINT (NGF 8) -*/ -/********************************************************/ - -#include "FP_types.h" -#include "get_put.h" - -#define OFF ((FL_MSL_AT_LOW_ADDRESS ? 0 : 4) + (FL_MSW_AT_LOW_ADDRESS ? 0 : 2) + (FL_MSB_AT_LOW_ADDRESS ? 0 : 1)) - -void -ngf8(f) -DOUBLE f; -{ - unsigned char *p; - - if (f.d[0] != 0 || f.d[1] != 0) { - p = (unsigned char *) &f + OFF; - *p ^= 0x80; - } -} diff --git a/lib/float/nrm_ext.c b/lib/float/nrm_ext.c deleted file mode 100644 index dc83554b1..000000000 --- a/lib/float/nrm_ext.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/********************************************************/ -/* - NORMALIZE an EXTENDED FORMAT NUMBER -*/ -/********************************************************/ - -#include "FP_shift.h" -#include "FP_types.h" - -void -nrm_ext(e1) -EXTEND *e1; -{ - /* we assume that the mantissa != 0 */ - /* if it is then just return */ - /* to let it be a problem elsewhere */ - /* THAT IS, The exponent is not set to */ - /* zero. If we don't test here an */ - /* infinite loop is generated when */ - /* mantissa is zero */ - - if ((e1->m1 | e1->m2) == 0L) - return; - - /* if top word is zero mov low word */ - /* to top word, adjust exponent value */ - if (e1->m1 == 0L) { - e1->m1 = e1->m2; - e1->m2 = 0L; - e1->exp -= 32; - } - if ((e1->m1 & NORMBIT) == 0) { - unsigned long l = ((unsigned long)NORMBIT >> 1); - int cnt = -1; - - while (! (l & e1->m1)) { - l >>= 1; - cnt--; - } - e1->exp += cnt; - b64_sft(&(e1->mantissa), cnt); - } -} diff --git a/lib/float/sbf4.c b/lib/float/sbf4.c deleted file mode 100644 index 368c11102..000000000 --- a/lib/float/sbf4.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - SUBTRACT TWO FLOATS - SINGLE Precision (SBF 4) -*/ - -#include "FP_types.h" - -void -sbf4(s2,s1) -SINGLE s1,s2; -{ - EXTEND e1,e2; - - if (s2 == (SINGLE) 0) { - return; - } - extend(&s1,&e1,sizeof(SINGLE)); - extend(&s2,&e2,sizeof(SINGLE)); - sub_ext(&e1,&e2); - compact(&e1,&s1,sizeof(SINGLE)); -} diff --git a/lib/float/sbf8.c b/lib/float/sbf8.c deleted file mode 100644 index 9d4c1067c..000000000 --- a/lib/float/sbf8.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - SUBTRACT TWO FLOATS - DOUBLE Precision (SBF 8) -*/ - -#include "FP_types.h" - -void -sbf8(s2,s1) -DOUBLE s1,s2; -{ - EXTEND e1, e2; - - if (s2.d[0] == 0 && s2.d[1] == 0) { - return; - } - extend(&s1.d[0],&e1,sizeof(DOUBLE)); - extend(&s2.d[0],&e2,sizeof(DOUBLE)); - sub_ext(&e1,&e2); - compact(&e1,&s1.d[0],sizeof(DOUBLE)); -} diff --git a/lib/float/sft_ext.c b/lib/float/sft_ext.c deleted file mode 100644 index a933f9dc9..000000000 --- a/lib/float/sft_ext.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - SHIFT TWO EXTENDED NUMBERS INTO PROPER - ALIGNMENT FOR ADDITION (exponents are equal) - Numbers should not be zero on entry. -*/ - -#include "FP_types.h" - -void -sft_ext(e1,e2) -EXTEND *e1,*e2; -{ - register EXTEND *s; - register int diff; - - diff = e1->exp - e2->exp; - - if (!diff) - return; /* exponents are equal */ - - if (diff < 0) { /* e2 is larger */ - /* shift e1 */ - diff = -diff; - s = e1; - } - else /* e1 is larger */ - /* shift e2 */ - s = e2; - - s->exp += diff; - b64_sft(&(s->mantissa), diff); -} diff --git a/lib/float/shifter.c b/lib/float/shifter.c deleted file mode 100644 index 089da20c2..000000000 --- a/lib/float/shifter.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -# include "FP_types.h" - -void -b64_sft(e1,n) -B64 *e1; -int n; -{ - if (n > 0) { - if (n > 63) { - e1->l_32 = 0; - e1->h_32 = 0; - return; - } - if (n >= 32) { - e1->l_32 = e1->h_32; - e1->h_32 = 0; - n -= 32; - } - if (n > 0) { - e1->l_32 >>= n; - if (e1->h_32 != 0) { - e1->l_32 |= (e1->h_32 << (32 - n)); - e1->h_32 >>= n; - } - } - return; - } - n = -n; - if (n > 0) { - if (n > 63) { - e1->l_32 = 0; - e1->h_32 = 0; - return; - } - if (n >= 32) { - e1->h_32 = e1->l_32; - e1->l_32 = 0; - n -= 32; - } - if (n > 0) { - e1->h_32 <<= n; - if (e1->l_32 != 0) { - e1->h_32 |= (e1->l_32 >> (32 - n)); - e1->l_32 <<= n; - } - } - } -} - -void -b64_lsft(e1) -B64 *e1; -{ - /* shift left 1 bit */ - e1->h_32 <<= 1; - if (e1->l_32 & 0x80000000L) e1->h_32 |= 1; - e1->l_32 <<= 1; -} - -void -b64_rsft(e1) -B64 *e1; -{ - /* shift right 1 bit */ - e1->l_32 >>= 1; - if (e1->h_32 & 1) e1->l_32 |= 0x80000000L; - e1->h_32 >>= 1; -} diff --git a/lib/float/sub_ext.c b/lib/float/sub_ext.c deleted file mode 100644 index 64180aa6f..000000000 --- a/lib/float/sub_ext.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - SUBTRACT 2 EXTENDED FORMAT NUMBERS -*/ - -#include "FP_types.h" - -void -sub_ext(e1,e2) -EXTEND *e1,*e2; -{ - if ((e2->m1 | e2->m2) == 0L) { - return; - } - if ((e1->m1 | e1->m2) == 0L) { - *e1 = *e2; - e1->sign = e2->sign ? 0 : 1; - return; - } - sft_ext(e1, e2); - if (e1->sign != e2->sign) { - /* e1 - e2 = e1 + (-e2) */ - if (b64_add(&e1->mantissa,&e2->mantissa)) { /* addition carry */ - b64_rsft(&e1->mantissa); /* shift mantissa one bit RIGHT */ - e1->m1 |= 0x80000000L; /* set max bit */ - e1->exp++; /* increase the exponent */ - } - } - else if (e2->m1 > e1->m1 || - (e2->m1 == e1->m1 && e2->m2 > e1->m2)) { - /* abs(e2) > abs(e1) */ - if (e1->m2 > e2->m2) { - e2->m1 -= 1; /* carry in */ - } - e2->m1 -= e1->m1; - e2->m2 -= e1->m2; - *e1 = *e2; - e1->sign = e2->sign ? 0 : 1; - } - else { - if (e2->m2 > e1->m2) - e1->m1 -= 1; /* carry in */ - e1->m1 -= e2->m1; - e1->m2 -= e2->m2; - } - nrm_ext(e1); -} diff --git a/lib/float/zrf4.c b/lib/float/zrf4.c deleted file mode 100644 index a913e813d..000000000 --- a/lib/float/zrf4.c +++ /dev/null @@ -1,19 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - return a zero float (ZRF 4) -*/ - -#include "FP_types.h" - -void -zrf4(l) -SINGLE *l; -{ - *l = 0L; -} diff --git a/lib/float/zrf8.c b/lib/float/zrf8.c deleted file mode 100644 index 4fcdbb85b..000000000 --- a/lib/float/zrf8.c +++ /dev/null @@ -1,21 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - return a zero double (ZRF 8) -*/ - -#include "FP_types.h" - -void -zrf8(z) -DOUBLE *z; -{ - - z->d[0] = 0L; - z->d[1] = 0L; -} diff --git a/lib/float/zrf_ext.c b/lib/float/zrf_ext.c deleted file mode 100644 index 8f5878989..000000000 --- a/lib/float/zrf_ext.c +++ /dev/null @@ -1,22 +0,0 @@ -/* - (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands. - See the copyright notice in the ACK home directory, in the file "Copyright". -*/ - -/* $Header$ */ - -/* - ZERO and return EXTEND FORMAT FLOAT -*/ - -#include "FP_types.h" - -void -zrf_ext(e) -EXTEND *e; -{ - e->m1 = 0; - e->m2 = 0; - e->exp = 0; - e->sign = 0; -} diff --git a/lib/fphook/fltpr.c b/lib/fphook/fltpr.c deleted file mode 100644 index 7ba3fb018..000000000 --- a/lib/fphook/fltpr.c +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include -#include "../stdio/loc_incl.h" - -int _fp_hook = 1; - -char * -_f_print(va_list *ap, int flags, char *s, char c, int precision) -{ - fprintf(stderr,"cannot print floating point\n"); - exit(EXIT_FAILURE); -} diff --git a/lib/fphook/strtod.c b/lib/fphook/strtod.c deleted file mode 100644 index 8f58baa08..000000000 --- a/lib/fphook/strtod.c +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include - -double -strtod(const char *p, char **pp) -{ - fprintf(stderr,"cannot print floating point\n"); - exit(EXIT_FAILURE); -} diff --git a/lib/generate.sh b/lib/generate.sh deleted file mode 100644 index 887ec3c75..000000000 --- a/lib/generate.sh +++ /dev/null @@ -1,262 +0,0 @@ -#!/bin/sh -# called with parameters: 1:dir 2:ackbase 3:gnubase - -set -e - -. /etc/make.conf - -exec >Makefile -exec 3>Makedepend-ack -exec 4>Makedepend-gnu -touch .depend-ack -touch .depend-gnu - -echo "#Generated from $1/Makefile.in" - -ACKBASE=$2 -GNUBASE=$3 -OBJDIR=$1 - -RECURSIVE_TARGETS="clean depend depend-ack depend-gnu" - -if [ -z $ACKBASE ]; then echo ACKBASE is not set!; exit 1; fi -if [ -z $GNUBASE ]; then echo GNUBASE is not set!; exit 1; fi - -. Makefile.in - -#to enable library debugging, enable the next line -#CFLAGS=$CFLAGS" -g" - -echo "all: all-ack" -echo -echo "all-ack:" -echo "all-gnu:" -echo -echo "makefiles: Makefile" -echo "Makedepend-ack Makedepend-gnu: " -echo " sh $0 $OBJDIR $ACKBASE $GNUBASE" -echo -echo "Makefile: Makefile.in Makedepend-ack Makedepend-gnu" -echo " sh $0 $OBJDIR $ACKBASE $GNUBASE" -echo " @echo" -echo " @echo *Attention*" -echo " @echo Makefile is regenerated... rerun command to see changes" -echo " @echo *Attention*" -echo " @echo" -echo -if [ ! -z "$SUBDIRS" ]; then - echo "all-ack: makefiles" - for dir in $SUBDIRS - { - if [ $TYPE = "both" -o $TYPE = "ack" ]; then - echo " mkdir -p $ACKBASE/$OBJDIR/$dir" - fi - echo " cd $dir && \$(MAKE) \$@" - } - echo - echo "all-gnu: makefiles" - for dir in $SUBDIRS - { - if [ $TYPE = "both" -o $TYPE = "gnu" ]; then - echo " mkdir -p $GNUBASE/$OBJDIR/$dir" - fi - - echo " cd $dir && \$(MAKE) \$@" - } - echo - echo "$RECURSIVE_TARGETS:: makefiles" - for dir in $SUBDIRS - { - #if [ $TYPE = "both" -o $TYPE = "ack" ]; then - #echo " mkdir -p $ACKBASE/$OBJDIR/$dir" - #fi - #if [ $TYPE = "both" -o $TYPE = "gnu" ]; then - #echo " mkdir -p $GNUBASE/$OBJDIR/$dir" - #fi - - echo " cd $dir && \$(MAKE) \$@" - } - echo - for dir in $SUBDIRS - { - echo "makefiles: $dir/Makefile" - } - echo - for dir in $SUBDIRS - { - echo "$dir/Makefile: $dir/Makefile.in" - echo " cd $dir && sh ../$0 $OBJDIR/$dir ../$ACKBASE ../$GNUBASE && \$(MAKE) makefiles" - } -else - -echo "depend: depend-ack" - -echo "depend-ack:" >&3 -echo " rm .depend-ack" >&3 -echo " touch .depend-ack" >&3 - -echo "depend-gnu:" >&4 -echo " rm .depend-gnu" >&4 -echo " touch .depend-gnu" >&4 - -ackCommands() -{ - dstfile=$1 - srcfile=$2 - dstdir=`dirname $dstfile` - - case $srcfile in - *.s | *.c | *.e ) - echo " cc $CFLAGS -c -o $dstfile $srcfile" - - echo " mkdep 'cc $CFLAGS -E' $srcfile | sed -e 's:^\(.\):$dstdir/\1:' >> .depend-ack" >&3 - ;; - *.mod ) - echo " m2 $M2FLAGS -c -o $dstfile $srcfile" - - echo " mkdep 'm2 $M2FLAGS -E' $srcfile | sed -e 's:^\(.\):$dstdir/\1:' >> .depend-ack" >&3 - ;; - *.fc ) - echo " sh ./FP.compile $dstfile $srcfile" - - echo " mkdep 'cc -E' $srcfile | sed -e 's:^\(.\):$dstdir/\1:' >> .depend-ack" >&3 - ;; - esac -} - -gnuCommands() -{ - dstfile=$1 - srcfile=$2 - dstdir=`dirname $dstfile` - sedcmd="sed -e '//d' -e '//d' -e 's:^\(.\):$dstdir/\1:'" - - case $srcfile in - *.s ) - echo " gcc $CFLAGS -E -x assembler-with-cpp -I. $srcfile | asmconv -mi386 ack gnu > $GNUBASE/$OBJDIR/$srcfile.gnu" - echo " gas -o $dstfile $GNUBASE/$OBJDIR/$srcfile.gnu" - - echo " mkdep 'gcc $CFLAGS -E -x assembler-with-cpp -I.' $srcfile | $sedcmd >> .depend-gnu" >&4 - ;; - *.gs ) - echo " gas -o $dstfile $srcfile" - - echo " mkdep 'gcc $CFLAGS -E -x assembler-with-cpp -I.' $srcfile | $sedcmd >> .depend-gnu" >&4 - ;; - *.c ) - echo " gcc $CFLAGS -c -o $dstfile $srcfile" - - echo " mkdep 'gcc $CFLAGS -E' $srcfile | $sedcmd >> .depend-gnu" >&4 - ;; - #*.mod ) - # echo " \$(M2C) -o $dstfile $srcfile" - # ;; - #*.fc ) - # echo " sh ./FP.COMPILE $srcfile" - # ;; - esac - echo -} - -#libraries -for lib in $LIBRARIES -{ - if [ $TYPE = "both" -o $TYPE = "ack" ]; then - echo "all-ack: $ACKBASE/$lib.a" - eval "FILES=\$${lib}_FILES" - echo - for f in $FILES - { - o=`echo $f | sed -e 's/\\..*\$/\.o/'` - echo "$ACKBASE/$lib.a: $ACKBASE/$lib.a($o)" - } - echo - echo "$ACKBASE/$lib.a:" - echo " ar cr $ACKBASE/$lib.a $ACKBASE/$OBJDIR/*.o" - echo " rm $ACKBASE/$OBJDIR/*.o" - echo - for f in $FILES - { - o=`echo $f | sed -e 's/\\..*\$/\.o/'` - echo "$ACKBASE/$lib.a($o): $f" - - ackCommands $ACKBASE/$OBJDIR/$o $f - } - echo - fi - - if [ $TYPE = "both" -o $TYPE = "gnu" ]; then - echo "all-gnu: $GNUBASE/$lib.a" - eval "FILES=\$${lib}_FILES" - echo - for f in $FILES - { - o=`echo $f | sed -e 's/\\..*\$/\.o/'` - echo "$GNUBASE/$lib.a: $GNUBASE/$OBJDIR/$o" - } - echo - echo "$GNUBASE/$lib.a:" - echo " gar cr $GNUBASE/$lib.a \$?" - echo - for f in $FILES - { - o=`echo $f | sed -e 's/\\..*\$/\.o/'` - - echo "$GNUBASE/$OBJDIR/$o: $f" - - gnuCommands $GNUBASE/$OBJDIR/$o $f - } - echo - fi -} -echo - -#start files -for f in $STARTFILES -{ - o=`echo $f | sed -e 's/\\..*\$/\.o/'` - - if [ $TYPE = "both" -o $TYPE = "ack" ]; then - echo "all-ack: $ACKBASE/$o" - echo - echo "$ACKBASE/$o: $f" - ackCommands $ACKBASE/$o $f - echo - fi - if [ $TYPE = "both" -o $TYPE = "gnu" ]; then - echo "all-gnu: $GNUBASE/$o" - echo - echo "$GNUBASE/$o: $f" - gnuCommands $GNUBASE/$o $f - echo - fi -} - -fi # elif of if [ -n "$SUBDIRS" ] -echo -echo "clean::" -if [ $TYPE = "both" -o $TYPE = "ack" ]; then - echo " rm -f $ACKBASE/$OBJDIR/*" -fi -if [ $TYPE = "both" -o $TYPE = "gnu" ]; then - echo " rm -f $GNUBASE/$OBJDIR/*" -fi - -if [ $OBJDIR = "." ]; then - echo - echo "install: install-ack" - echo - echo "install-ack: all-ack" - # $ARCH is from /etc/make.conf - echo " cp $ACKBASE/*.[ao] /usr/lib/$ARCH" - echo - echo "install-gnu: all-gnu" - echo " cp $GNUBASE/*.[ao] /usr/gnu/lib" -fi - -echo -echo "include Makedepend-ack" -echo "include .depend-ack" -echo -echo "include Makedepend-gnu" -echo "include .depend-gnu" diff --git a/lib/gnu/Makefile.in b/lib/gnu/Makefile.in deleted file mode 100644 index cfc17794d..000000000 --- a/lib/gnu/Makefile.in +++ /dev/null @@ -1,7 +0,0 @@ - -SUBDIRS=" \ - end \ - ieee_float \ - rts" - -TYPE=gnu diff --git a/lib/gnu/end/Makefile.in b/lib/gnu/end/Makefile.in deleted file mode 100644 index bee2abf1c..000000000 --- a/lib/gnu/end/Makefile.in +++ /dev/null @@ -1,7 +0,0 @@ - -LIBRARIES=end - -end_FILES=gnu_end.gs - -TYPE=gnu - diff --git a/lib/gnu/ieee_float/Makefile.in b/lib/gnu/ieee_float/Makefile.in deleted file mode 100644 index 82343dcef..000000000 --- a/lib/gnu/ieee_float/Makefile.in +++ /dev/null @@ -1,14 +0,0 @@ - -CFLAGS="-O -I.." - -LIBRARIES=libc - -libc_FILES=" \ - frexp.c \ - isinf.c \ - isnan.c \ - ldexp.c \ - modf.c \ - fphook.c" - -TYPE=gnu diff --git a/lib/gnu/ieee_float/fphook.c b/lib/gnu/ieee_float/fphook.c deleted file mode 100644 index 61730d609..000000000 --- a/lib/gnu/ieee_float/fphook.c +++ /dev/null @@ -1,195 +0,0 @@ -/* - * fltpr.c - print floating point numbers - */ -/* $Header$ */ - -#ifndef NOFLOAT -#include -#include -#include "../stdio/loc_incl.h" -int _fp_hook = 1; - -static char * -_pfloat(long double r, register char *s, int n, int flags) -{ - register char *s1; - int sign, dp; - register int i; - - s1 = _fcvt(r, n, &dp, &sign); - if (sign) - *s++ = '-'; - else if (flags & FL_SIGN) - *s++ = '+'; - else if (flags & FL_SPACE) - *s++ = ' '; - - if (dp<=0) - *s++ = '0'; - for (i=dp; i>0; i--) - if (*s1) *s++ = *s1++; - else *s++ = '0'; - if (((i=n) > 0) || (flags & FL_ALT)) - *s++ = '.'; - while (++dp <= 0) { - if (--i<0) - break; - *s++ = '0'; - } - while (--i >= 0) - if (*s1) *s++ = *s1++; - else *s++ = '0'; - return s; -} - -static char * -_pscien(long double r, register char *s, int n, int flags) -{ - int sign, dp; - register char *s1; - - s1 = _ecvt(r, n + 1, &dp, &sign); - if (sign) - *s++ = '-'; - else if (flags & FL_SIGN) - *s++ = '+'; - else if (flags & FL_SPACE) - *s++ = ' '; - - *s++ = *s1++; - if ((n > 0) || (flags & FL_ALT)) - *s++ = '.'; - while (--n >= 0) - if (*s1) *s++ = *s1++; - else *s++ = '0'; - *s++ = 'e'; - if ( r != 0 ) --dp ; - if ( dp<0 ) { - *s++ = '-' ; dp= -dp ; - } else { - *s++ = '+' ; - } - if (dp >= 100) { - *s++ = '0' + (dp / 100); - dp %= 100; - } - *s++ = '0' + (dp/10); - *s++ = '0' + (dp%10); - return s; -} - -#define NDIGINEXP(exp) (((exp) >= 100 || (exp) <= -100) ? 3 : 2) -#define LOW_EXP -4 -#define USE_EXP(exp, ndigits) (((exp) < LOW_EXP + 1) || (exp >= ndigits + 1)) - -static char * -_gcvt(long double value, int ndigit, char *s, int flags) -{ - int sign, dp; - register char *s1, *s2; - register int i; - register int nndigit = ndigit; - - s1 = _ecvt(value, ndigit, &dp, &sign); - s2 = s; - if (sign) *s2++ = '-'; - else if (flags & FL_SIGN) - *s2++ = '+'; - else if (flags & FL_SPACE) - *s2++ = ' '; - - if (!(flags & FL_ALT)) - for (i = nndigit - 1; i > 0 && s1[i] == '0'; i--) - nndigit--; - - if (USE_EXP(dp,ndigit)) { - /* Use E format */ - dp--; - *s2++ = *s1++; - if ((nndigit > 1) || (flags & FL_ALT)) *s2++ = '.'; - while (--nndigit > 0) *s2++ = *s1++; - *s2++ = 'e'; - if (dp < 0) { - *s2++ = '-'; - dp = -dp; - } - else *s2++ = '+'; - s2 += NDIGINEXP(dp); - *s2 = 0; - for (i = NDIGINEXP(dp); i > 0; i--) { - *--s2 = dp % 10 + '0'; - dp /= 10; - } - return s; - } - /* Use f format */ - if (dp <= 0) { - if (*s1 != '0') { - /* otherwise the whole number is 0 */ - *s2++ = '0'; - *s2++ = '.'; - } - while (dp < 0) { - dp++; - *s2++ = '0'; - } - } - for (i = 1; i <= nndigit; i++) { - *s2++ = *s1++; - if (i == dp) *s2++ = '.'; - } - if (i <= dp) { - while (i++ <= dp) *s2++ = '0'; - *s2++ = '.'; - } - if ((s2[-1]=='.') && !(flags & FL_ALT)) s2--; - *s2 = '\0'; - return s; -} - -char * -_f_print(va_list *ap, int flags, char *s, char c, int precision) -{ - register char *old_s = s; - long double ld_val; - - if (flags & FL_LONGDOUBLE) ld_val = va_arg(*ap, long double); - else ld_val = (long double) va_arg(*ap, double); - - switch(c) { - case 'f': - s = _pfloat(ld_val, s, precision, flags); - break; - case 'e': - case 'E': - s = _pscien(ld_val, s, precision , flags); - break; - case 'g': - case 'G': - s = _gcvt(ld_val, precision, s, flags); - s += strlen(s); - break; - } - if ( c == 'E' || c == 'G') { - while (*old_s && *old_s != 'e') old_s++; - if (*old_s == 'e') *old_s = 'E'; - } - return s; -} -#endif /* NOFLOAT */ -/* $Header$ */ - -#include -#include "../ansi/ext_fmt.h" - -void _str_ext_cvt(const char *s, char **ss, struct EXTEND *e); -double _ext_dbl_cvt(struct EXTEND *e); - -double -strtod(const char *p, char **pp) -{ - struct EXTEND e; - - _str_ext_cvt(p, pp, &e); - return _ext_dbl_cvt(&e); -} diff --git a/lib/gnu/rts/Makefile.in b/lib/gnu/rts/Makefile.in deleted file mode 100644 index 60611073e..000000000 --- a/lib/gnu/rts/Makefile.in +++ /dev/null @@ -1,8 +0,0 @@ - -LIBRARIES=libc - -libc_FILES=" \ - __setjmp.gs \ - longjmp.gs" - -TYPE=gnu diff --git a/lib/gnu_build.sh b/lib/gnu_build.sh new file mode 100755 index 000000000..c5e4ab24b --- /dev/null +++ b/lib/gnu_build.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +export COMPILER_TYPE=gnu +export ARCH=i386 + +if [ "$COMPILER_TYPE" = 'ack' ]; then + export CC=cc + export MAKEOBJDIR=obj-ack +elif [ "$COMPILER_TYPE" = 'gnu' ]; then + export CC=gcc + export AR=gar + export MAKEOBJDIR=obj-gnu + export PATH=$PATH:/usr/gnu/bin +fi + +make $@ diff --git a/lib/i386/Makefile.in b/lib/i386/Makefile.in deleted file mode 100644 index f1e741226..000000000 --- a/lib/i386/Makefile.in +++ /dev/null @@ -1,10 +0,0 @@ -# Makefile for lib/i386. - -SUBDIRS="\ - int64 \ - math \ - misc \ - rts \ - string" - -TYPE=both diff --git a/lib/i386/math/Makefile.in b/lib/i386/math/Makefile.in deleted file mode 100644 index c955d2ae1..000000000 --- a/lib/i386/math/Makefile.in +++ /dev/null @@ -1,17 +0,0 @@ -# Makefile for lib/i386/math. - -CFLAGS="-O -D_MINIX -D_POSIX_SOURCE" - -LIBRARIES=libc - -libc_FILES=" \ - arch_compare.c \ - arch_round.c \ - fpu_cw.s \ - fpu_sw.s \ - fpu_round.s \ - fegetround.c \ - feholdexcept.c \ - fesetround.c" - -TYPE=both diff --git a/lib/i386/rts/Makefile.in b/lib/i386/rts/Makefile.in deleted file mode 100644 index 6597bb254..000000000 --- a/lib/i386/rts/Makefile.in +++ /dev/null @@ -1,18 +0,0 @@ -# Makefile for lib/i386/rts. - -CFLAGS="-O -D_MINIX -D_POSIX_SOURCE" - -LIBRARIES=libc - -libc_FILES=" \ - __sigreturn.s \ - _ipc.s \ - _senda.s \ - brksize.s" - -STARTFILES="\ - crtso.s \ - m2rtso.s \ - prtso.s" - -TYPE=both diff --git a/lib/i386/rts/m2rtso.s b/lib/i386/rts/m2rtso.s deleted file mode 100644 index 92b6ce080..000000000 --- a/lib/i386/rts/m2rtso.s +++ /dev/null @@ -1,67 +0,0 @@ -! This is the Modula-2 run-time start-off routine. It's job is to take the -! arguments as put on the stack by EXEC, and to parse them and set them up the -! way _m_a_i_n expects them. - -.sect .text; .sect .rom; .sect .data; .sect .bss - -.define begtext, begdata, begbss -.sect .text -begtext: -.sect .rom -begrom: -.sect .data -begdata: -.sect .bss -begbss: - -.define m2rtso, hol0, __penviron, __penvp, __fpu_present -.sect .text -m2rtso: - xor ebp, ebp ! clear for backtrace of core files - mov eax, (esp) ! argc - lea edx, 4(esp) ! argv - lea ecx, 8(esp)(eax*4) ! envp - - ! Test if environ is in the initialized data area and is set to our - ! magic number. If so then it is not redefined by the user. - mov ebx, _environ - cmp ebx, __edata ! within initialized data? - jae 0f - testb bl, 3 ! aligned? - jnz 0f - cmp (ebx), 0x53535353 ! is it our environ? - jne 0f - mov (__penviron), ebx ! _penviron = &environ; -0: mov ebx, (__penviron) - mov (ebx), ecx ! *_penviron = envp; - - push ecx ! push envp - push edx ! push argv - push eax ! push argc - - ! Test the EM bit of the MSW to determine if an FPU is present and - ! set __fpu_present if one is found. - smsw ax - testb al, 0x4 ! EM bit in MSW - setz (__fpu_present) ! True if not set - - call __m_a_i_n ! run Modula-2 program - - push eax ! push exit status - call __exit - - hlt ! force a trap if exit fails - -.sect .rom - .data4 0 ! Separate I&D: *NULL == 0 - ! Also keeps the first string in the - ! program from appearing at location 0! -.sect .data -__penviron: - .data4 __penvp ! Pointer to environ, or hidden pointer - -.sect .bss - .comm __penvp, 4 ! Hidden environment vector - .comm __fpu_present, 4 ! FPU present flag - -.extern endtext ! Force loading of end labels. diff --git a/lib/i386/rts/prtso.s b/lib/i386/rts/prtso.s deleted file mode 100644 index 0defa7de2..000000000 --- a/lib/i386/rts/prtso.s +++ /dev/null @@ -1,69 +0,0 @@ -! This is the Pascal run-time start-off routine. It's job is to take the -! arguments as put on the stack by EXEC, and to parse them and set them up the -! way _m_a_i_n expects them. - -.sect .text; .sect .rom; .sect .data; .sect .bss - -.define begtext, begdata, begbss -.sect .text -begtext: -.sect .rom -begrom: -.sect .data -begdata: -.sect .bss -begbss: - -.define prtso, hol0, __penviron, __penvp, __fpu_present -.sect .text -prtso: - xor ebp, ebp ! clear for backtrace of core files - mov eax, (esp) ! argc - lea edx, 4(esp) ! argv - lea ecx, 8(esp)(eax*4) ! envp - - ! Test if environ is in the initialized data area and is set to our - ! magic number. If so then it is not redefined by the user. - mov ebx, _environ - cmp ebx, __edata ! within initialized data? - jae 0f - testb bl, 3 ! aligned? - jnz 0f - cmp (ebx), 0x53535353 ! is it our environ? - jne 0f - mov (__penviron), ebx ! _penviron = &environ; -0: mov ebx, (__penviron) - mov (ebx), ecx ! *_penviron = envp; - - push ecx ! push envp - push edx ! push argv - push eax ! push argc - - ! Test the EM bit of the MSW to determine if an FPU is present and - ! set __fpu_present if one is found. - smsw ax - testb al, 0x4 ! EM bit in MSW - setz (__fpu_present) ! True if not set - - mov (.ignmask), 56 - - call __m_a_i_n ! Run Pascal program - - push eax ! push exit status - call __exit - - hlt ! force a trap if exit fails - -.sect .rom - .data4 0 ! Separate I&D: *NULL == 0 - ! Also keeps the first string in the - ! program from appearing at location 0! -.sect .data -__penviron: - .data4 __penvp ! Pointer to environ, or hidden pointer - -.sect .bss - .comm __penvp, 4 ! Hidden environment vector - .comm __fpu_present, 4 ! FPU present flag - -.extern endtext ! Force loading of end labels. diff --git a/lib/i86/em/em_adi.s b/lib/i86/em/em_adi.s deleted file mode 100644 index dc53e4bc3..000000000 --- a/lib/i86/em/em_adi.s +++ /dev/null @@ -1,24 +0,0 @@ -.define .adi - - .text -.adi: - pop bx - cmp cx,#2 - jne 1f - pop cx - add ax,cx - jmp (bx) -1: - cmp cx,#4 - jne 9f - pop dx - pop cx - add ax,cx - pop cx - adc dx,cx - push dx - jmp (bx) -9: -.extern .trpilin - push bx - jmp .trpilin diff --git a/lib/i86/em/em_and.s b/lib/i86/em/em_and.s deleted file mode 100644 index 166c853d6..000000000 --- a/lib/i86/em/em_and.s +++ /dev/null @@ -1,19 +0,0 @@ -.define .and - - ! #bytes in cx - ! save di; it might be a register variable - - .text -.and: - pop bx ! return address - mov dx,di - mov di,sp - add di,cx - sar cx,#1 -1: - pop ax - and ax,(di) - stos - loop 1b - mov di,dx - jmp (bx) diff --git a/lib/i86/em/em_blm.s b/lib/i86/em/em_blm.s deleted file mode 100644 index 058a22a99..000000000 --- a/lib/i86/em/em_blm.s +++ /dev/null @@ -1,15 +0,0 @@ -.define .blm -.text - - ! cx: count in words -.blm: - mov bx,sp - mov ax,si - mov dx,di - mov di,2(bx) - mov si,4(bx) - rep - mov - mov si,ax - mov di,dx - ret 4 diff --git a/lib/i86/em/em_cii.s b/lib/i86/em/em_cii.s deleted file mode 100644 index 2bda938d5..000000000 --- a/lib/i86/em/em_cii.s +++ /dev/null @@ -1,37 +0,0 @@ -.define .cii - -.text -.cii: - pop bx ! return address - ! pop cx, dest. size - ! pop dx, src. size - ! ax is first word of source - cmp dx,#1 - jne 2f - cbw - mov dx,#2 -2: - cmp dx,cx - je 8f - cmp dx,#2 - je 1f - cmp dx,#4 - jne 9f - cmp cx,#2 - jne 9f - pop dx -8: - jmp (bx) -1: - cmp cx,#4 - jne 9f - cwd - push dx - jmp (bx) -9: - push ax ! push low source -EILLINS = 18 -.extern .fat - mov ax,#EILLINS - push ax - jmp .fat diff --git a/lib/i86/em/em_cmi4.s b/lib/i86/em/em_cmi4.s deleted file mode 100644 index d09679bb0..000000000 --- a/lib/i86/em/em_cmi4.s +++ /dev/null @@ -1,27 +0,0 @@ -.define .cmi4 - -.text -.cmi4: - pop bx ! return address - pop cx - pop dx - pop ax - push si - mov si,sp - xchg bx,2(si) - pop si - cmp bx,dx - jg 1f - jl 2f - cmp ax,cx - ja 1f - je 3f -2: - mov ax,#-1 - ret -3: - xor ax,ax - ret -1: - mov ax,#1 - ret diff --git a/lib/i86/em/em_cms.s b/lib/i86/em/em_cms.s deleted file mode 100644 index 150395eae..000000000 --- a/lib/i86/em/em_cms.s +++ /dev/null @@ -1,23 +0,0 @@ -.define .cms - - ! #bytes in cx - .text -.cms: - pop bx ! return address - mov dx,sp - push si - push di - mov si,dx - add dx,cx - mov di,dx - add dx,cx - sar cx,#1 - repe - cmp - je 1f - inc cx -1: - pop di - pop si - mov sp,dx - jmp (bx) diff --git a/lib/i86/em/em_cmu4.s b/lib/i86/em/em_cmu4.s deleted file mode 100644 index 446a45d2d..000000000 --- a/lib/i86/em/em_cmu4.s +++ /dev/null @@ -1,27 +0,0 @@ -.define .cmu4 - -.text -.cmu4: - pop bx ! return address - pop cx - pop dx - pop ax - push si - mov si,sp - xchg bx,2(si) - pop si - cmp bx,dx - ja 1f - jb 2f - cmp ax,cx - ja 1f - je 3f -2: - mov ax,#-1 - ret -3: - xor ax,ax - ret -1: - mov ax,#1 - ret diff --git a/lib/i86/em/em_com.s b/lib/i86/em/em_com.s deleted file mode 100644 index 66a1b66d2..000000000 --- a/lib/i86/em/em_com.s +++ /dev/null @@ -1,15 +0,0 @@ -.define .com - - ! #bytes in cx - .text -.com: - mov bx,sp - inc bx - inc bx - sar cx,#1 -1: - not (bx) - inc bx - inc bx - loop 1b - ret diff --git a/lib/i86/em/em_csa2.s b/lib/i86/em/em_csa2.s deleted file mode 100644 index c2a182443..000000000 --- a/lib/i86/em/em_csa2.s +++ /dev/null @@ -1,26 +0,0 @@ -.define .csa2 - -.text -.csa2: - ! bx, descriptor address - ! ax, index - mov dx,(bx) ! default - sub ax,2(bx) - cmp ax,4(bx) - ja 1f - sal ax,#1 - add bx,ax - mov bx,6(bx) - test bx,bx - jnz 2f -1: - mov bx,dx - test bx,bx - jnz 2f -ECASE = 20 -.extern .fat - mov ax,#ECASE - push ax - jmp .fat -2: - jmp (bx) diff --git a/lib/i86/em/em_csa4.s b/lib/i86/em/em_csa4.s deleted file mode 100644 index fb78fe015..000000000 --- a/lib/i86/em/em_csa4.s +++ /dev/null @@ -1,30 +0,0 @@ -.sect .text; .sect .rom; .sect .data; .sect .bss -.define .csa4 - -.sect .text -.csa4: - ! bx, descriptor address - ! ax, dx: index - mov cx,(bx) ! default - sub ax,2(bx) - ! ignore high order word; if non-zero, the - ! case descriptor would not fit anyway - cmp ax,6(bx) - ja 1f -2: - sal ax,#1 - add bx,ax - mov bx,10(bx) - test bx,bx - jnz 2f -1: - mov bx,cx - test bx,bx - jnz 2f -ECASE = 20 -.extern .fat - mov ax,#ECASE - push ax - jmp .fat -2: - jmp (bx) diff --git a/lib/i86/em/em_csb2.s b/lib/i86/em/em_csb2.s deleted file mode 100644 index bc812eb6c..000000000 --- a/lib/i86/em/em_csb2.s +++ /dev/null @@ -1,28 +0,0 @@ -.define .csb2 - -.text -.csb2: - !bx, descriptor address - !ax, index - mov dx,(bx) - mov cx,2(bx) -1: - add bx,#4 - dec cx - jl 4f - cmp ax,(bx) - jne 1b - mov bx,2(bx) -2: - test bx,bx - jnz 3f -ECASE = 20 -.extern .fat - mov ax,#ECASE - push ax - jmp .fat -3: - jmp (bx) -4: - mov bx,dx - jmp 2b diff --git a/lib/i86/em/em_csb4.s b/lib/i86/em/em_csb4.s deleted file mode 100644 index e60a67f67..000000000 --- a/lib/i86/em/em_csb4.s +++ /dev/null @@ -1,33 +0,0 @@ -.sect .text; .sect .rom; .sect .data; .sect .bss -.define .csb4 - -.sect .text -.csb4: - !bx: descriptor address - !ax, dx: index - push (bx) ! default - mov cx,2(bx) ! count (ignore high order word, the descriptor - ! would not fit anyway) -1: - add bx,#6 - dec cx - jl 4f - cmp ax,(bx) - jne 1b - cmp dx,2(bx) - jne 1b - pop bx - mov bx,4(bx) -2: - test bx,bx - jnz 3f -ECASE = 20 -.extern .fat - mov ax,#ECASE - push ax - jmp .fat -3: - jmp (bx) -4: - pop bx - jmp 2b diff --git a/lib/i86/em/em_cuu.s b/lib/i86/em/em_cuu.s deleted file mode 100644 index 0cba3fc3b..000000000 --- a/lib/i86/em/em_cuu.s +++ /dev/null @@ -1,36 +0,0 @@ -.define .ciu -.define .cui -.define .cuu - -.text -.ciu: -.cui: -.cuu: - pop bx ! return address - ! pop cx, dest. size - ! pop dx, source size - ! ax is low word of source - cmp dx,cx - je 8f - cmp dx,#2 - je 1f - cmp dx,#4 - jne 9f - cmp cx,#2 - jne 9f - pop dx -8: - jmp (bx) -1: - cmp cx,#4 - jne 9f - xor dx,dx - push dx - jmp (bx) -9: - push ax ! to help debugging ? -EILLINS = 18 -.extern .fat - mov ax,#EILLINS - push ax - jmp .fat diff --git a/lib/i86/em/em_dup.s b/lib/i86/em/em_dup.s deleted file mode 100644 index 533fd5166..000000000 --- a/lib/i86/em/em_dup.s +++ /dev/null @@ -1,17 +0,0 @@ -.define .dup - - ! #bytes in cx - .text -.dup: - pop bx ! return address - mov ax,si - mov dx,di - mov si,sp - sub sp,cx - mov di,sp - sar cx,#1 - rep - mov - mov si,ax - mov di,dx - jmp (bx) diff --git a/lib/i86/em/em_dvi4.s b/lib/i86/em/em_dvi4.s deleted file mode 100644 index 74bc078c9..000000000 --- a/lib/i86/em/em_dvi4.s +++ /dev/null @@ -1,90 +0,0 @@ -.define .dvi4 - -yl=6 -yh=8 -xl=10 -xh=12 - -.text -.dvi4: - push si - push di - mov si,sp ! copy of sp - mov bx,yl(si) - mov ax,yh(si) - cwd - mov di,dx - cmp dx,ax - jne 7f - and dx,dx - jge 1f - neg bx - je 7f -1: - xor dx,dx - mov cx,xl(si) - mov ax,xh(si) - and ax,ax - jge 2f - neg ax - neg cx - sbb ax,dx - not di -2: - div bx - xchg ax,cx - div bx ! cx = high abs(result), ax=low abs(result) -9: - and di,di - jge 1f - neg cx - neg ax - sbb cx,#0 -1: - ! cx is high order result - ! ax is low order result - mov dx,cx - pop di - pop si - ret 8 ! result in ax/dx - -7: - push dx ! sign of y - mov di,ax - xor bx,bx - and di,di - jge 1f - neg di - neg yl(si) - sbb di,bx -1: - mov ax,xl(si) - mov dx,xh(si) - and dx,dx - jge 1f - neg dx - neg ax - sbb dx,bx - not -2(si) -1: - mov cx,#16 -1: - shl ax,#1 - rcl dx,#1 - rcl bx,#1 - cmp di,bx - ja 3f - jb 2f - cmp yl(si),dx - jbe 2f -3: - loop 1b - jmp 1f -2: - sub dx,yl(si) - sbb bx,di - inc ax - loop 1b -1: - pop di ! di=sign of result,ax= result - jmp 9b diff --git a/lib/i86/em/em_dvu4.s b/lib/i86/em/em_dvu4.s deleted file mode 100644 index 1e2455358..000000000 --- a/lib/i86/em/em_dvu4.s +++ /dev/null @@ -1,54 +0,0 @@ -.define .dvu4 - -yl=6 -yh=8 -xl=10 -xh=12 - -.text -.dvu4: - push si - push di - mov si,sp ! copy of sp - mov bx,yl(si) - mov ax,yh(si) - or ax,ax - jne 7f - xor dx,dx - mov cx,xl(si) - mov ax,xh(si) - div bx - xchg ax,cx - div bx -9: - ! cx is high order result - ! ax is low order result - mov dx,cx - pop di - pop si - ret 8 ! result in ax/dx - -7: - mov di,ax - xor bx,bx - mov ax,xl(si) - mov dx,xh(si) - mov cx,#16 -1: - shl ax,#1 - rcl dx,#1 - rcl bx,#1 - cmp di,bx - ja 3f - jb 2f - cmp yl(si),dx - jbe 2f -3: - loop 1b - jmp 9b -2: - sub dx,yl(si) - sbb bx,di - inc ax - loop 1b - jmp 9b diff --git a/lib/i86/em/em_error.s b/lib/i86/em/em_error.s deleted file mode 100644 index 4694ebb4a..000000000 --- a/lib/i86/em/em_error.s +++ /dev/null @@ -1,41 +0,0 @@ -.define .error -.define .Xtrp - - ! ax is trap number - ! all registers must be saved - ! because return is possible - ! May only be called with error no's <16 -.text -.error: - push bp - push si - push di - push dx - push cx - push bx - push ax - mov cx,ax - mov bx,#1 - sal bx,cl -.extern .ignmask -.extern .trp - test bx,.ignmask - jne 2f - call .trp -2: - pop ax - pop bx - pop cx - pop dx - pop di - pop si - pop bp - ret - -.Xtrp: - cmp ax,#16 - jge 1f - call .error - ret -1: - jmp .trp diff --git a/lib/i86/em/em_exg.s b/lib/i86/em/em_exg.s deleted file mode 100644 index 4bd40e155..000000000 --- a/lib/i86/em/em_exg.s +++ /dev/null @@ -1,21 +0,0 @@ -.define .exg - - ! #bytes in cx -.text -.exg: - push di - mov sp,di - add di,#4 - mov bx,di - add bx,cx - sar cx,#1 -1: - mov ax,(bx) - xchg ax,(di) - mov (bx),ax - add di,#2 - add bx,#2 - loop 1b -2: - pop di - ret diff --git a/lib/i86/em/em_fat.s b/lib/i86/em/em_fat.s deleted file mode 100644 index 4cfe4da15..000000000 --- a/lib/i86/em/em_fat.s +++ /dev/null @@ -1,9 +0,0 @@ -.define .fat -.text - -.fat: -.extern .trp -.extern .stop - call .trp - call .stop - ! no return diff --git a/lib/i86/em/em_fp8087.s b/lib/i86/em/em_fp8087.s deleted file mode 100644 index 4ac49ea15..000000000 --- a/lib/i86/em/em_fp8087.s +++ /dev/null @@ -1,615 +0,0 @@ -.define .adf4, .adf8, .sbf4, .sbf8, .mlf4, .mlf8, .dvf4, .dvf8 -.define .ngf4, .ngf8, .fif4, .fif8, .fef4, .fef8 -.define .cif4, .cif8, .cuf4, .cuf8, .cfi, .cfu, .cff4, .cff8 -.define .cmf4, .cmf8 -.sect .text; .sect .rom; .sect .data; .sect .bss - -! $Header$ - -! Implement interface to floating point package for Intel 8087 - - .sect .rom -one: - .data2 1 -two: - .data2 2 -bigmin: - .data2 0, -32768 - - .sect .text -.adf4: - mov bx,sp - wait - flds 2(bx) - wait - fadds 6(bx) - wait - fstps 6(bx) - wait - ret -.adf8: - mov bx,sp - wait - fldd 2(bx) - wait - faddd 10(bx) - wait - fstpd 10(bx) - wait - ret - -.sbf4: - mov bx,sp - wait - flds 6(bx) - wait - fsubs 2(bx) - wait - fstps 6(bx) - wait - ret - -.sbf8: - mov bx,sp - wait - fldd 10(bx) - wait - fsubd 2(bx) - wait - fstpd 10(bx) - wait - ret - -.mlf4: - mov bx,sp - wait - flds 2(bx) - wait - fmuls 6(bx) - wait - fstps 6(bx) - wait - ret -.mlf8: - mov bx,sp - wait - fldd 2(bx) - wait - fmuld 10(bx) - wait - fstpd 10(bx) - wait - ret - -.dvf4: - mov bx,sp - wait - flds 6(bx) - wait - fdivs 2(bx) - wait - fstps 6(bx) - wait - ret - -.dvf8: - mov bx,sp - wait - fldd 10(bx) - wait - fdivd 2(bx) - wait - fstpd 10(bx) - wait - ret - -.ngf4: - mov bx,sp - wait - flds 2(bx) - wait - fchs - wait - fstps 2(bx) - wait - ret - -.ngf8: - mov bx,sp - wait - fldd 2(bx) - wait - fchs - wait - fstpd 2(bx) - wait - ret - -.fif4: - mov bx,sp - push bx ! make room for FP status word - wait - flds 4(bx) - wait - fmuls 8(bx) ! multiply - wait - fld st ! copy result - wait - ftst ! test sign; handle negative separately - wait - fstsw -2(bx) - wait - mov ax,-2(bx) - sahf ! result of test in condition codes - jb 1f - frndint ! this one rounds (?) - wait - fcom st(1) ! compare with original; if <=, then OK - wait - fstsw -2(bx) - wait - mov ax,-2(bx) - sahf - jbe 2f - fisubs one ! else subtract 1 - wait - jmp 2f -1: ! here, negative case - frndint ! this one rounds (?) - wait - fcom st(1) ! compare with original; if >=, then OK - wait - fstsw -2(bx) - wait - mov ax,-2(bx) - sahf - jae 2f - fiadds one ! else add 1 - wait -2: - fsub st(1),st ! subtract integer part - wait - mov bx,2(bx) - fstps (bx) - wait - fstps 4(bx) - wait - pop bx - ret - -.fif8: - mov bx,sp - push bx ! make room for FP status word - wait - fldd 4(bx) - wait - fmuld 12(bx) ! multiply - wait - fld st ! and copy result - wait - ftst ! test sign; handle negative separately - wait - fstsw -2(bx) - wait - mov ax,-2(bx) - sahf ! result of test in condition codes - jb 1f - frndint ! this one rounds (?) - wait - fcom st(1) ! compare with original; if <=, then OK - wait - fstsw -2(bx) - wait - mov ax,-2(bx) - sahf - jbe 2f - fisubs one ! else subtract 1 - wait - jmp 2f -1: ! here, negative case - frndint ! this one rounds (?) - wait - fcom st(1) ! compare with original; if >=, then OK - wait - fstsw -2(bx) - wait - mov ax,-2(bx) - sahf - jae 2f - fiadds one ! else add 1 - wait -2: - fsub st(1),st ! subtract integer part - mov bx,2(bx) - fstpd (bx) - wait - fstpd 8(bx) - wait - pop bx - ret - -.fef4: - ! this could be simpler, if only the - ! fxtract instruction was emulated properly - mov bx,sp - mov ax,6(bx) - and ax,#077600 - je 1f ! zero exponent - mov cx,#7 - shr ax,cl - sub ax,#126 - mov cx,ax ! exponent in cx - mov ax,6(bx) - and ax,#0100177 - or ax,#0037400 ! load -1 exponent - mov dx,4(bx) - mov bx,2(bx) - mov 4(bx),ax - mov 2(bx),dx - mov (bx),cx - ret -1: ! we get here on zero exp - mov ax,6(bx) - and ax,#0177 - or ax,4(bx) - jne 1f ! zero result - xor ax,ax - mov bx,2(bx) - mov (bx),ax - mov 2(bx),ax - mov 4(bx),ax - ret -1: ! otherwise unnormalized number - mov cx,6(bx) - and cx,#0100177 - mov dx,cx - and cx,#0x8000 - mov ax,#-125 -2: - test dx,#0x80 - jne 1f - dec ax - shl 4(bx),#1 - rcl dx,#1 - or dx,cx - jmp 2b -1: - mov cx,4(bx) - mov bx,2(bx) - mov (bx),ax - mov 2(bx),cx - and dx,#0100177 - or dx,#0037400 ! load -1 exponent - mov 4(bx),dx - ret - -.fef8: - ! this could be simpler, if only the - ! fxtract instruction was emulated properly - mov bx,sp - mov ax,10(bx) - and ax,#077760 - je 1f ! zero exponent - mov cx,#4 - shr ax,cl - sub ax,#1022 - mov cx,ax ! exponent in cx - mov ax,10(bx) - and ax,#0100017 - or ax,#0037740 ! load -1 exponent - push 8(bx) - push 6(bx) - push 4(bx) - mov bx,2(bx) - pop 2(bx) - pop 4(bx) - pop 6(bx) - mov 8(bx),ax - mov (bx),cx - ret -1: ! we get here on zero exp - mov ax,10(bx) - and ax,#017 - or ax,8(bx) - or ax,6(bx) - or ax,4(bx) - jne 1f ! zero result - xor ax,ax - mov bx,2(bx) - mov (bx),ax - mov 2(bx),ax - mov 4(bx),ax - mov 6(bx),ax - mov 8(bx),ax - ret -1: ! otherwise unnormalized number - mov cx,10(bx) - and cx,#0100017 - mov dx,cx - and cx,#0x8000 - mov ax,#-1021 -2: - test dx,#0x10 - jne 1f - dec ax - shl 4(bx),#1 - rcl 6(bx),#1 - rcl 8(bx),#1 - rcl dx,#1 - or dx,cx - jmp 2b -1: - and dx,#0100017 - or dx,#0037740 ! load -1 exponent - mov cx,8(bx) - push 6(bx) - push 4(bx) - mov bx,2(bx) - mov (bx),ax - mov 8(bx),dx - mov 6(bx),cx - pop 2(bx) - pop 4(bx) - ret - -.cif4: - mov bx,sp - cmp 2(bx),#2 - jne 1f - wait - filds 4(bx) - wait - fstps 2(bx) - wait - ret -1: - wait - fildl 4(bx) - wait - fstps 4(bx) - wait - ret - -.cif8: - mov bx,sp - cmp 2(bx),#2 - jne 1f - wait - filds 4(bx) - wait - fstpd 2(bx) - wait - ret -1: - wait - fildl 4(bx) - wait - fstpd 2(bx) - wait - ret - -.cuf4: - mov bx,sp - cmp 2(bx),#2 - jne 1f - mov ax,4(bx) - mov 2(bx),ax - mov 4(bx),#0 - wait - fildl 2(bx) - wait - fstps 2(bx) - wait - ret -1: - wait - fildl 4(bx) - wait - cmp 6(bx),#0 - jge 1f -2: - wait - fisubl bigmin - wait - fisubl bigmin -1: - wait - fstps 4(bx) - wait - ret - -.cuf8: - mov bx,sp - cmp 2(bx),#2 - jne 1f - mov 6(bx),#0 -1: - wait - fildl 4(bx) - wait - cmp 6(bx),#0 - jge 1f -2: - wait - fisubl bigmin - wait - fisubl bigmin -1: - wait - fstpd 2(bx) - wait - ret - -.cfi: - mov bx,sp - push bx - wait - fstcw -2(bx) - wait - mov dx,-2(bx) - or -2(bx),#0xc00 ! truncating mode - wait - fldcw -2(bx) - pop ax - cmp 4(bx),#4 - jne 2f - ! loc 4 loc ? cfi - wait - flds 6(bx) - wait - fistpl 6(bx) - wait - cmp 2(bx),#2 - jne 1f - mov ax,6(bx) -1: - mov 4(bx),dx - wait - fldcw 4(bx) - wait - ret -2: - ! loc 8 loc ? cfi - wait - fldd 6(bx) - wait - fistpl 10(bx) - wait - cmp 2(bx),#2 - jne 1b - mov ax,10(bx) - jmp 1b - -.cfu: - mov bx,sp - push bx - wait - fstcw -2(bx) - wait - mov dx,-2(bx) - and -2(bx),#0xf3ff - or -2(bx),#0x400 ! to -infinity - wait - fldcw -2(bx) - wait - pop ax - cmp 4(bx),#4 - jne 2f - ! loc 4 loc ? cfu - flds 6(bx) - wait - fabs ! ??? - wait - fiaddl bigmin - fistpl 6(bx) - wait - mov ax,8(bx) - sub ax,bigmin+2 - mov 8(bx),ax - cmp 2(bx),#2 - jne 1f - mov ax,6(bx) -1: - mov 4(bx),dx - wait - fldcw 4(bx) - wait - ret -2: - wait - ! loc 8 loc ? cfu - fldd 6(bx) - wait - fabs ! ??? - wait - fiaddl bigmin - fistpl 10(bx) - wait - mov ax,12(bx) - sub ax,bigmin+2 - mov 12(bx),ax - cmp 2(bx),#2 - jne 1b - mov ax,10(bx) - jmp 1b - -.cff4: - mov bx,sp - wait - fldd 2(bx) - wait - fstcw 2(bx) - wait - mov dx,2(bx) - and 2(bx),#0xf3ff ! set to rounding mode - wait - fldcw 2(bx) - wait - fstps 6(bx) - mov 2(bx),dx - wait - fldcw 2(bx) - wait - ret - -.cff8: - mov bx,sp - wait - flds 2(bx) - wait - fstpd 2(bx) - wait - ret - -.cmf4: - mov bx,sp - push bx ! room for 8087 status word - xor cx,cx - wait - flds 6(bx) - wait - flds 2(bx) - wait - fcompp ! compare and pop operands - wait - fstsw -2(bx) - wait - mov ax,-2(bx) - sahf - je 1f - jb 2f - dec cx - jmp 1f -2: - inc cx -1: - mov ax,cx - pop bx - ret - - -.cmf8: - mov bx,sp - push bx ! room for 8087 status word - xor cx,cx - wait - fldd 10(bx) - wait - fldd 2(bx) - wait - fcompp ! compare and pop operands - wait - fstsw -2(bx) - wait - mov ax,-2(bx) - sahf - je 1f - jb 2f - dec cx - jmp 1f -2: - inc cx -1: - mov ax,cx - pop bx - ret diff --git a/lib/i86/em/em_gto.s b/lib/i86/em/em_gto.s deleted file mode 100644 index dc409fef3..000000000 --- a/lib/i86/em/em_gto.s +++ /dev/null @@ -1,7 +0,0 @@ -.define .gto -.text - -.gto: - mov bp,4(bx) - mov sp,2(bx) - jmp @(bx) diff --git a/lib/i86/em/em_hol0.s b/lib/i86/em/em_hol0.s deleted file mode 100644 index 9ee449755..000000000 --- a/lib/i86/em/em_hol0.s +++ /dev/null @@ -1,5 +0,0 @@ -.define hol0 -.data -hol0: - .data2 0, 0 - .data2 0, 0 diff --git a/lib/i86/em/em_iaar.s b/lib/i86/em/em_iaar.s deleted file mode 100644 index 9b2da555f..000000000 --- a/lib/i86/em/em_iaar.s +++ /dev/null @@ -1,17 +0,0 @@ -.define .iaar -.text - -.iaar: - pop cx - pop dx - cmp dx,#2 -.extern .unknown - jne .unknown - pop bx ! descriptor address - pop ax ! index - sub ax,(bx) - mul 4(bx) - pop bx ! array base - add bx,ax - push cx - ret diff --git a/lib/i86/em/em_ilar.s b/lib/i86/em/em_ilar.s deleted file mode 100644 index 0898136f4..000000000 --- a/lib/i86/em/em_ilar.s +++ /dev/null @@ -1,14 +0,0 @@ -.define .ilar -.text - -.ilar: - pop cx - pop dx -.extern .unknown - cmp dx,#2 - jne .unknown - pop bx ! descriptor address - pop ax ! index - push cx -.extern .lar2 - jmp .lar2 diff --git a/lib/i86/em/em_inn.s b/lib/i86/em/em_inn.s deleted file mode 100644 index 12bb0a7cc..000000000 --- a/lib/i86/em/em_inn.s +++ /dev/null @@ -1,31 +0,0 @@ -.define .inn -.text - - ! #bytes in cx - ! bit # in ax -.inn: - xor dx,dx - mov bx,#8 - div bx - mov bx,sp - add bx,#2 - add bx,ax - cmp ax,cx - jae 1f - movb al,(bx) - mov bx,dx - testb al,bits(bx) - jz 1f - mov ax,#1 - jmp 2f -1: - xor ax,ax -2: - pop bx - add sp,cx - ! ax is result - jmp (bx) - - .data -bits: - .data1 1,2,4,8,16,32,64,128 diff --git a/lib/i86/em/em_ior.s b/lib/i86/em/em_ior.s deleted file mode 100644 index 394afcfc0..000000000 --- a/lib/i86/em/em_ior.s +++ /dev/null @@ -1,17 +0,0 @@ -.define .ior -.text - - ! #bytes in cx -.ior: - pop bx ! return address - mov dx,di - mov di,sp - add di,cx - sar cx,#1 -1: - pop ax - or ax,(di) - stos - loop 1b - mov di,dx - jmp (bx) diff --git a/lib/i86/em/em_isar.s b/lib/i86/em/em_isar.s deleted file mode 100644 index 17c2694f6..000000000 --- a/lib/i86/em/em_isar.s +++ /dev/null @@ -1,14 +0,0 @@ -.define .isar -.text - -.isar: - pop cx - pop ax - cmp ax,#2 -.extern .unknown - jne .unknown - pop bx ! descriptor address - pop ax ! index - push cx -.extern .sar2 - jmp .sar2 diff --git a/lib/i86/em/em_lar2.s b/lib/i86/em/em_lar2.s deleted file mode 100644 index 728697b8c..000000000 --- a/lib/i86/em/em_lar2.s +++ /dev/null @@ -1,35 +0,0 @@ -.define .lar2 -.text - -.lar2: - ! bx, descriptor address - ! ax, index - pop cx - pop dx ! base address - push cx - push si - mov si,dx - sub ax,(bx) - mov cx,4(bx) - imul cx - add si,ax - sar cx,#1 - jnb 1f - xorb ah,ah - lodsb - pop si - pop bx - push ax - jmp (bx) -1: - pop dx ! saved si - mov ax,4(bx) - pop bx ! return address - sub sp,ax - mov ax,di ! save di - mov di,sp - rep - mov - mov di,ax - mov si,dx - jmp (bx) diff --git a/lib/i86/em/em_lfr6.s b/lib/i86/em/em_lfr6.s deleted file mode 100644 index 820a8158a..000000000 --- a/lib/i86/em/em_lfr6.s +++ /dev/null @@ -1,10 +0,0 @@ -.define .lfr6 -.text -.extern .retarea - -.lfr6: - pop bx - push .retarea+4 - push .retarea+2 - push .retarea - jmp (bx) diff --git a/lib/i86/em/em_lfr8.s b/lib/i86/em/em_lfr8.s deleted file mode 100644 index 510532892..000000000 --- a/lib/i86/em/em_lfr8.s +++ /dev/null @@ -1,11 +0,0 @@ -.define .lfr8 -.text -.extern .retarea - -.lfr8: - pop bx - push .retarea+6 - push .retarea+4 - push .retarea+2 - push .retarea - jmp (bx) diff --git a/lib/i86/em/em_loi.s b/lib/i86/em/em_loi.s deleted file mode 100644 index 96aa1d820..000000000 --- a/lib/i86/em/em_loi.s +++ /dev/null @@ -1,38 +0,0 @@ -.define .loi -.define .los -.text - - ! #bytes in cx - ! address in bx - ! save si/di. they might be register variables -.los: - mov dx,si - mov si,bx - pop bx - mov ax,cx - sar cx,#1 - jnb 1f - xorb ah,ah - lodsb - mov si,dx - push ax - jmp (bx) -1: - sub sp,ax - jmp 1f - -.loi: - ! only called with size > 4 - mov dx,si - mov si,bx - pop bx - sub sp,cx - sar cx,#1 -1: - mov ax,di - mov di,sp - rep - mov - mov si,dx - mov di,ax - jmp (bx) diff --git a/lib/i86/em/em_mli4.s b/lib/i86/em/em_mli4.s deleted file mode 100644 index 1dd31c8a6..000000000 --- a/lib/i86/em/em_mli4.s +++ /dev/null @@ -1,25 +0,0 @@ -.define .mli4 -.text - -yl=2 -yh=4 - ! x * y - ! xl in ax - ! xh in dx - -.mli4: - mov bx,sp - push dx - mov cx,ax - mul yh(bx) ! xl*yh - pop dx - push ax - mov ax,dx - mul yl(bx) ! xh * yl - pop dx - add dx,ax ! xh*yl+xl*yh - mov ax,cx - mov cx,dx - mul yl(bx) ! xl*yl - add dx,cx - ret 4 diff --git a/lib/i86/em/em_mon.s b/lib/i86/em/em_mon.s deleted file mode 100644 index c73857305..000000000 --- a/lib/i86/em/em_mon.s +++ /dev/null @@ -1,6 +0,0 @@ -.define .mon -.text - -.mon: -.extern .stop - call .stop diff --git a/lib/i86/em/em_nop.s b/lib/i86/em/em_nop.s deleted file mode 100644 index 6eaaf6486..000000000 --- a/lib/i86/em/em_nop.s +++ /dev/null @@ -1,4 +0,0 @@ -.define .nop -.text -.nop: - ret diff --git a/lib/i86/em/em_rck.s b/lib/i86/em/em_rck.s deleted file mode 100644 index e4d3dc150..000000000 --- a/lib/i86/em/em_rck.s +++ /dev/null @@ -1,19 +0,0 @@ -.define .rck -.text - - ! descriptor address in bx - ! value in ax, must be left there -.rck: - cmp ax,(bx) - jl 2f - cmp ax,2(bx) - jg 2f - ret -2: - push ax -ERANGE = 1 -.extern .error - mov ax,#ERANGE - call .error - pop ax - ret diff --git a/lib/i86/em/em_ret6.s b/lib/i86/em/em_ret6.s deleted file mode 100644 index a9972ab8e..000000000 --- a/lib/i86/em/em_ret6.s +++ /dev/null @@ -1,10 +0,0 @@ -.define .ret6 -.text -.extern .retarea - -.ret6: - pop bx - pop .retarea - pop .retarea+2 - pop .retarea+4 - jmp (bx) diff --git a/lib/i86/em/em_ret8.s b/lib/i86/em/em_ret8.s deleted file mode 100644 index 96b2e8237..000000000 --- a/lib/i86/em/em_ret8.s +++ /dev/null @@ -1,11 +0,0 @@ -.define .ret8 -.text -.extern .retarea - -.ret8: - pop bx - pop .retarea - pop .retarea+2 - pop .retarea+4 - pop .retarea+6 - jmp (bx) diff --git a/lib/i86/em/em_retarea.s b/lib/i86/em/em_retarea.s deleted file mode 100644 index ad70eeb6d..000000000 --- a/lib/i86/em/em_retarea.s +++ /dev/null @@ -1,5 +0,0 @@ -.define .retarea - -.bss -.retarea: - .zerow 8/2 diff --git a/lib/i86/em/em_return.s b/lib/i86/em/em_return.s deleted file mode 100644 index 60365635d..000000000 --- a/lib/i86/em/em_return.s +++ /dev/null @@ -1,17 +0,0 @@ -.define .sdret, .dsret, .sret, .dret, .cret -.text - -.dsret: - pop di -.sret: - pop si -.cret: - mov sp,bp - pop bp - ret - -.sdret: - pop si -.dret: - pop di - jmp .cret diff --git a/lib/i86/em/em_rmi4.s b/lib/i86/em/em_rmi4.s deleted file mode 100644 index dea9cb5d7..000000000 --- a/lib/i86/em/em_rmi4.s +++ /dev/null @@ -1,89 +0,0 @@ -.define .rmi4 -.text - -yl=6 -yh=8 -xl=10 -xh=12 - -.rmi4: - push si - push di - mov si,sp ! copy of sp - mov bx,yl(si) - mov ax,yh(si) - cwd - cmp dx,ax - jne 7f - and dx,dx - jge 1f - neg bx - je 7f -1: - xor dx,dx - mov cx,xl(si) - mov ax,xh(si) - and ax,ax - jge 2f - neg ax - neg cx - sbb ax,dx -2: - div bx - xchg ax,cx - div bx ! dx= result(low), 0=result(high) - xor bx,bx -9: - cmp xh(si),#0 - jge 1f - neg bx - neg dx - sbb bx,#0 -1: - ! bx is high order result - ! dx is low order result - mov ax,dx - mov dx,bx ! result in ax/dx - pop di - pop si - ret 8 - -7: - mov di,ax - xor bx,bx - and di,di - jge 1f - neg di - neg yl(si) - sbb di,bx -1: - mov ax,xl(si) - mov dx,xh(si) - and dx,dx - jge 1f - neg dx - neg ax - sbb dx,bx -1: - mov cx,#16 -1: - shl ax,#1 - rcl dx,#1 - rcl bx,#1 - cmp di,bx - ja 3f - jb 2f - cmp yl(si),dx - jbe 2f -3: - loop 1b - ! dx=result(low), bx=result(high) - jmp 9b -2: - sub dx,yl(si) - sbb bx,di - inc ax - loop 1b -1: - ! dx=result(low), bx=result(high) - jmp 9b diff --git a/lib/i86/em/em_rmu4.s b/lib/i86/em/em_rmu4.s deleted file mode 100644 index 3997993fe..000000000 --- a/lib/i86/em/em_rmu4.s +++ /dev/null @@ -1,61 +0,0 @@ -.define .rmu4 -.text - -yl=6 -yh=8 -xl=10 -xh=12 - -.rmu4: - push si - push di - mov si,sp ! copy of sp - mov bx,yl(si) - mov ax,yh(si) - or ax,ax - jne 7f -1: - xor dx,dx - mov cx,xl(si) - mov ax,xh(si) -2: - div bx - xchg ax,cx - div bx - xor bx,bx -9: - ! bx is high order result - ! dx is low order result - mov ax,dx - mov dx,bx - pop di - pop si - ret 8 ! result in ax/dx - -7: - mov di,ax - xor bx,bx - mov ax,xl(si) - mov dx,xh(si) - mov cx,#16 -1: - shl ax,#1 - rcl dx,#1 - rcl bx,#1 - cmp di,bx - ja 3f - jb 2f - cmp yl(si),dx - jbe 2f -3: - loop 1b - ! dx=result(low), bx=result(high) - jmp 9b -2: - sub dx,yl(si) - sbb bx,di - inc ax - loop 1b -1: - ! dx=result(low), bx=result(high) - jmp 9b diff --git a/lib/i86/em/em_sar2.s b/lib/i86/em/em_sar2.s deleted file mode 100644 index a577ed9da..000000000 --- a/lib/i86/em/em_sar2.s +++ /dev/null @@ -1,33 +0,0 @@ -.define .sar2 -.text - -.sar2: - ! bx, descriptor address - ! ax, index - pop cx - pop dx ! base address - push cx - xchg di,dx ! di = base address, dx is saved di - sub ax,(bx) - mov cx,4(bx) - push dx - imul cx - pop dx - add di,ax - sar cx,#1 - jnb 1f - pop bx - pop ax - stosb - mov di,dx - jmp (bx) -1: - pop bx - mov ax,si - mov si,sp - rep - mov - mov sp,si - mov si,ax - mov di,dx - jmp (bx) diff --git a/lib/i86/em/em_sbi.s b/lib/i86/em/em_sbi.s deleted file mode 100644 index 3fb8a9496..000000000 --- a/lib/i86/em/em_sbi.s +++ /dev/null @@ -1,27 +0,0 @@ -.define .sbi -.text - - ! #bytes in cx , top of stack in ax -.sbi: - pop bx ! return subress - cmp cx,#2 - jne 1f - pop cx - sub ax,cx - neg ax - jmp (bx) -1: - cmp cx,#4 - jne 9f - pop dx - pop cx - sub cx,ax - mov ax,cx - pop cx - sbb cx,dx - push cx - jmp (bx) -9: -.extern .trpilin - push bx - jmp .trpilin diff --git a/lib/i86/em/em_set.s b/lib/i86/em/em_set.s deleted file mode 100644 index 65a66363a..000000000 --- a/lib/i86/em/em_set.s +++ /dev/null @@ -1,43 +0,0 @@ -.define .set -.text - - ! #bytes in cx - ! bit # in ax -.set: - pop bx ! return address - xor dx,dx -!ifdef create set - sub sp,cx - push bx - push di - mov bx,sp - xor di,di - sar cx,#1 -1: - mov 4(bx)(di),dx - inc di - inc di - loop 1b -!endif - mov bx,#8 - div bx - cmp ax,di - jae 2f - mov di,dx - movb dl,bits(di) - mov di,sp - add di,ax - orb 4(di),dl - pop di - ret -2: -ESET = 2 -.extern .error - pop di - mov ax,#ESET - call .error - ret - - .data -bits: - .data1 1,2,4,8,16,32,64,128 diff --git a/lib/i86/em/em_stb.s b/lib/i86/em/em_stb.s deleted file mode 100644 index 581b91814..000000000 --- a/lib/i86/em/em_stb.s +++ /dev/null @@ -1,16 +0,0 @@ -.define ___stb -.text - - ! Routine for copying structs. -___stb: - mov bx,sp - push si - push di - mov cx,2(bx) - mov si,4(bx) - mov di,6(bx) - rep - movb - pop di - pop si - ret diff --git a/lib/i86/em/em_sti.s b/lib/i86/em/em_sti.s deleted file mode 100644 index 8c158ab92..000000000 --- a/lib/i86/em/em_sti.s +++ /dev/null @@ -1,32 +0,0 @@ -.define .sti -.define .sts -.text - - ! #bytes in cx - ! address in bx - ! save di/si. they might be register variables -.sts: - mov dx,di ! save di - mov di,bx - pop bx ! return address - sar cx,#1 - jnb 1f - pop ax - stosb - mov di,dx - jmp (bx) -.sti: - ! only called with count > 4 - mov dx,di - mov di,bx - pop bx - sar cx,#1 -1: - mov ax,si - mov si,sp - rep - mov - mov sp,si - mov di,dx - mov si,ax - jmp (bx) diff --git a/lib/i86/em/em_stop.s b/lib/i86/em/em_stop.s deleted file mode 100644 index 8b96d4ec8..000000000 --- a/lib/i86/em/em_stop.s +++ /dev/null @@ -1,4 +0,0 @@ -.define .stop -.text -.stop: - call __exit diff --git a/lib/i86/em/em_trp.s b/lib/i86/em/em_trp.s deleted file mode 100644 index d687818b2..000000000 --- a/lib/i86/em/em_trp.s +++ /dev/null @@ -1,138 +0,0 @@ -.define .trpdivz -.define .trpilin -.define .trpcase -.define .trprang -.define .trpset -.define .trpnofp -.define .trpheap -.define .trp - -.bss -.M: .zerow 24/2 - -.text -.extern .trpdivz -.extern .trpilin -.extern .trpcase -.extern .trprang -.extern .trpset -.extern .trpnofp -.extern .trpheap -.extern .trp - -.trpdivz: -mov ax,#6 -mov dx,#.Mdivz -jmp .Trp -.trpilin: -mov ax,#18 -mov dx,#.Milin -jmp .Trp -.trpcase: -mov ax,#20 -mov dx,#.Mcase -jmp .Trp -.trprang: -mov ax,#1 -mov dx,#.Mrang -jmp .Trp -.trpset: -mov ax,#2 -mov dx,#.Mset -jmp .Trp -.trpnofp: -mov ax,#18 -mov dx,#.Mnofp -jmp .Trp -.trpheap: -mov ax,#17 -mov dx,#.Mheap -jmp .Trp - -.Trp: -xor bx,bx -.extern .trppc -xchg bx,.trppc -test bx,bx -jz 2f -push ax -call (bx) -pop ax -ret -2: -mov bx,#22 -push bx -push dx -mov ax,#2 -push ax -call .Write -call __exit - -.trp: -mov dx,ax -cmp dx,#21 -jae 1f -sal dx,#1 -mov bx,#.Mtable -add bx,dx -mov bx,(bx) -test bx,bx -jz 1f -mov dx,bx -jmp 2f -1: -mov bx,#.Mtrp+14 -mov cx,#6 -mov dx,ax -1: -and dx,#7 -add dx,'0' -movb (bx),dl -dec bx -sar dx,#1 -sar dx,#1 -sar dx,#1 -loop 1b -mov dx,#.Mtrp -2: -jmp .Trp - -.Write: -push bp -mov bp,sp -mov .M+2,#4 -mov bx,4(bp) -mov .M+4,bx -mov bx,8(bp) -mov .M+6,bx -mov bx,6(bp) -mov .M+10,bx -mov ax,#.M -push ax -mov ax,#1 -push ax - -mov ax,#1 -mov bx,#.M -mov cx,#3 -int 32 -mov sp,bp -pop bp -ret - - -.data -.Mtable: - .data2 0, .Mrang, .Mset, 0, 0, 0, .Mdivz, 0 - .data2 0, 0, 0, 0, 0, 0, 0, 0 - .data2 0, .Mheap, .Milin, .Milin, .Mcase - -.Mdivz: .asciz "Error: Division by 0 \n" -.Milin: .asciz "Illegal EM instruct'n\n" -.Mcase: .asciz "Err in EM case instr \n" -.Mrang: .asciz "Variable out of range\n" -.Mset: .asciz "Err in EM set instr \n" -.Mnofp: .asciz "Floating pt not impl.\n" -.Mheap: .asciz "Heap overflow \n" - -.Mtrp: .asciz "EM trap 0000000 octal\n" diff --git a/lib/i86/em/em_unknown.s b/lib/i86/em/em_unknown.s deleted file mode 100644 index 34f81cdbc..000000000 --- a/lib/i86/em/em_unknown.s +++ /dev/null @@ -1,9 +0,0 @@ -.define .unknown -.text -.extern .fat -EILLINS = 18 - -.unknown: - mov ax,#EILLINS - push ax - jmp .fat diff --git a/lib/i86/em/em_vars.s b/lib/i86/em/em_vars.s deleted file mode 100644 index 9a73a899c..000000000 --- a/lib/i86/em/em_vars.s +++ /dev/null @@ -1,12 +0,0 @@ -.define .reghp, .limhp, .ignmask, .trppc -.extern .reghp, .limhp, .ignmask, .trppc - -.data -.reghp: - .data2 endbss -.limhp: - .data2 endbss -.ignmask: - .data2 1336 -.trppc: - .data2 0 diff --git a/lib/i86/em/em_xor.s b/lib/i86/em/em_xor.s deleted file mode 100644 index 25b7a8de0..000000000 --- a/lib/i86/em/em_xor.s +++ /dev/null @@ -1,17 +0,0 @@ -.define .xor -.text - - ! #bytes in cx -.xor: - pop bx ! return address - mov dx,di - mov di,sp - add di,cx - sar cx,#1 -1: - pop ax - xor ax,(di) - stos - loop 1b - mov di,dx - jmp (bx) diff --git a/lib/i86/int64/add64.s b/lib/i86/int64/add64.s deleted file mode 100644 index f396cfb37..000000000 --- a/lib/i86/int64/add64.s +++ /dev/null @@ -1,24 +0,0 @@ -! add64() - 64 bit addition Author: Kees J. Bot -! 24 Dec 1995 -.sect .text -.define _add64 - -_add64: ! u64_t add64(u64_t i, u64_t j); - push bp - mov bp, sp - mov bx, 4(bp) - mov ax, 6(bp) - add ax, 14(bp) - mov (bx), ax - mov ax, 8(bp) - adc ax, 16(bp) - mov 2(bx), ax - mov ax, 10(bp) - adc ax, 18(bp) - mov 4(bx), ax - mov ax, 12(bp) - adc ax, 20(bp) - mov 6(bx), ax - mov ax, bx - pop bp - ret diff --git a/lib/i86/int64/add64u.s b/lib/i86/int64/add64u.s deleted file mode 100644 index 6c3a1b379..000000000 --- a/lib/i86/int64/add64u.s +++ /dev/null @@ -1,30 +0,0 @@ -! add64u() - unsigned to 64 bit addition Author: Kees J. Bot -! 24 Dec 1995 -.sect .text -.define _add64u, _add64ul - -_add64u: ! u64_t add64u(u64_t i, unsigned j); - push bp - mov bp, sp - xor cx, cx - jmp 0f -_add64ul: ! u64_t add64ul(u64_t i, unsigned long j); - push bp - mov bp, sp - mov cx, 16(bp) -0: mov bx, 4(bp) - mov ax, 6(bp) - add ax, 14(bp) - mov (bx), ax - mov ax, 8(bp) - adc ax, cx - mov 2(bx), ax - mov ax, 10(bp) - adc ax, #0 - mov 4(bx), ax - mov ax, 12(bp) - adc ax, #0 - mov 6(bx), ax - mov ax, bx - pop bp - ret diff --git a/lib/i86/int64/cmp64.s b/lib/i86/int64/cmp64.s deleted file mode 100644 index f3623cc88..000000000 --- a/lib/i86/int64/cmp64.s +++ /dev/null @@ -1,52 +0,0 @@ -! cmp64*() - 64 bit compare Author: Kees J. Bot -! 24 Dec 1995 -.sect .text -.define _cmp64, _cmp64u, _cmp64ul - -_cmp64: ! int cmp64(u64_t i, u64_t j); - mov bx, sp -cmp64: xor ax, ax - mov dx, 2(bx) - sub dx, 10(bx) - mov dx, 4(bx) - sbb dx, 12(bx) - mov dx, 6(bx) - sbb dx, 14(bx) - mov dx, 8(bx) - sbb dx, 16(bx) - sbb ax, ax ! ax = - (i < j) - mov dx, 10(bx) - sub dx, 2(bx) - mov dx, 12(bx) - sbb dx, 4(bx) - mov dx, 14(bx) - sbb dx, 6(bx) - mov dx, 16(bx) - sbb dx, 8(bx) - adc ax, #0 ! ax = (i > j) - (i < j) - ret - -_cmp64u: ! int cmp64u(u64_t i, unsigned j); - mov bx, sp - push 16(bx) - mov 16(bx), #0 - push 14(bx) - mov 14(bx), #0 - push 12(bx) - mov 12(bx), #0 - call cmp64 - pop 12(bx) - pop 14(bx) - pop 16(bx) - ret - -_cmp64ul: ! int cmp64ul(u64_t i, unsigned long j); - mov bx, sp - push 14(bx) - mov 14(bx), #0 - push 12(bx) - mov 12(bx), #0 - call cmp64 - pop 12(bx) - pop 14(bx) - ret diff --git a/lib/i86/int64/cv64u.s b/lib/i86/int64/cv64u.s deleted file mode 100644 index 2b5e2b317..000000000 --- a/lib/i86/int64/cv64u.s +++ /dev/null @@ -1,21 +0,0 @@ -! cv64u() - 64 bit converted to unsigned Author: Kees J. Bot -! 24 Dec 1995 -.sect .text -.define _cv64u, _cv64ul - -_cv64u: ! unsigned cv64u(u64_t i); - mov bx, sp - mov cx, 4(bx) - jmp 0f - -_cv64ul: ! unsigned long cv64ul(u64_t i); - mov bx, sp - xor cx, cx -0: mov ax, 2(bx) - mov dx, 4(bx) - or cx, 6(bx) - or cx, 8(bx) ! return UINT/ULONG_MAX if really big - jz 0f - mov ax, #-1 - mov dx, ax -0: ret diff --git a/lib/i86/int64/cvu64.s b/lib/i86/int64/cvu64.s deleted file mode 100644 index d9a50873e..000000000 --- a/lib/i86/int64/cvu64.s +++ /dev/null @@ -1,21 +0,0 @@ -! cvu64() - unsigned converted to 64 bit Author: Kees J. Bot -! 24 Dec 1995 -.sect .text -.define _cvu64, _cvul64 - -_cvu64: ! u64_t cvu64(unsigned i); - mov bx, sp - xor dx, dx - jmp 0f - -_cvul64: ! u64_t cvul64(unsigned long i); - mov bx, sp - mov dx, 6(bx) -0: mov ax, 4(bx) - mov bx, 2(bx) - mov (bx), ax - mov 2(bx), dx - mov 4(bx), #0 - mov 6(bx), #0 - mov ax, bx - ret diff --git a/lib/i86/int64/diff64.s b/lib/i86/int64/diff64.s deleted file mode 100644 index 2939a0312..000000000 --- a/lib/i86/int64/diff64.s +++ /dev/null @@ -1,10 +0,0 @@ -! diff64() - 64 bit subtraction giving unsigned Author: Kees J. Bot -! 24 Dec 1995 -.sect .text -.define _diff64 - -_diff64: ! unsigned diff64(u64_t i, u64_t j); - mov bx, sp - mov ax, 2(bx) - sub ax, 10(bx) - ret diff --git a/lib/i86/int64/div64u.s b/lib/i86/int64/div64u.s deleted file mode 100644 index 8ceef4b0d..000000000 --- a/lib/i86/int64/div64u.s +++ /dev/null @@ -1,26 +0,0 @@ -! div64u() - 64 bit divided by unsigned giving unsigned long -! Author: Kees J. Bot -! 24 Dec 1995 -.sect .text -.define _div64u, _rem64u - -_div64u: ! unsigned long div64u(u64_t i, unsigned j); - mov bx, sp -div64u: xor dx, dx - mov ax, 8(bx) - div 10(bx) - mov ax, 6(bx) - div 10(bx) - mov ax, 4(bx) - div 10(bx) ! division bits 16-31 - mov cx, ax - mov ax, 2(bx) - div 10(bx) ! division bits 0-15 - xchg dx, cx ! division in dx:ax, remainder in cx - ret - -_rem64u: ! unsigned rem64u(u64_t i, unsigned j); - mov bx, sp - call div64u - mov ax, cx - ret diff --git a/lib/i86/int64/ex64.s b/lib/i86/int64/ex64.s deleted file mode 100644 index d0c60ad0e..000000000 --- a/lib/i86/int64/ex64.s +++ /dev/null @@ -1,17 +0,0 @@ -! ex64*() - extract low or high 32 bits of a 64 bit number -! Author: Kees J. Bot -! 24 Dec 1995 -.sect .text -.define _ex64lo, _ex64hi - -_ex64lo: ! unsigned long ex64lo(u64_t i); - mov bx, sp - mov ax, 2(bx) - mov dx, 4(bx) - ret - -_ex64hi: ! unsigned long ex64hi(u64_t i); - mov bx, sp - mov ax, 6(bx) - mov dx, 8(bx) - ret diff --git a/lib/i86/int64/make64.s b/lib/i86/int64/make64.s deleted file mode 100644 index 7a165c66a..000000000 --- a/lib/i86/int64/make64.s +++ /dev/null @@ -1,19 +0,0 @@ -! make64() - make a 64 bit number from two 32 bit halves -! Author: Kees J. Bot -! 24 Dec 1995 -.sect .text -.define _make64 - -_make64: ! u64_t make64(unsigned long lo, unsigned long hi); - mov bx, sp - mov ax, 4(bx) - mov dx, 6(bx) - mov cx, 8(bx) - push 10(bx) - mov bx, 2(bx) - mov (bx), ax - mov 2(bx), dx - mov 4(bx), cx - pop 6(bx) - mov ax, bx - ret diff --git a/lib/i86/int64/mul64u.s b/lib/i86/int64/mul64u.s deleted file mode 100644 index fa7397b73..000000000 --- a/lib/i86/int64/mul64u.s +++ /dev/null @@ -1,23 +0,0 @@ -! mul64u() - unsigned long by unsigned multiply giving 64 bit result -! Author: Kees J. Bot -! 24 Dec 1995 -.sect .text -.define _mul64u - -_mul64u: ! u64_t mul64u(unsigned long i, unsigned j); - push bp - mov bp, sp - mov bx, 4(bp) - mov ax, 6(bp) - mul 10(bp) - mov (bx), ax - mov 2(bx), dx - mov ax, 8(bp) - mul 10(bp) - add 2(bx), ax - adc dx, #0 - mov 4(bx), dx - mov 6(bx), #0 - mov ax, bx - pop bp - ret diff --git a/lib/i86/int64/sub64.s b/lib/i86/int64/sub64.s deleted file mode 100644 index 5f596e774..000000000 --- a/lib/i86/int64/sub64.s +++ /dev/null @@ -1,24 +0,0 @@ -! sub64() - 64 bit subtraction Author: Kees J. Bot -! 24 Dec 1995 -.sect .text -.define _sub64 - -_sub64: ! u64_t sub64(u64_t i, u64_t j); - push bp - mov bp, sp - mov bx, 4(bp) - mov ax, 6(bp) - sub ax, 14(bp) - mov (bx), ax - mov ax, 8(bp) - sbb ax, 16(bp) - mov 2(bx), ax - mov ax, 10(bp) - sbb ax, 18(bp) - mov 4(bx), ax - mov ax, 12(bp) - sbb ax, 20(bp) - mov 6(bx), ax - mov ax, bx - pop bp - ret diff --git a/lib/i86/int64/sub64u.s b/lib/i86/int64/sub64u.s deleted file mode 100644 index 722d5c3bc..000000000 --- a/lib/i86/int64/sub64u.s +++ /dev/null @@ -1,30 +0,0 @@ -! sub64u() - unsigned from 64 bit subtraction Author: Kees J. Bot -! 24 Dec 1995 -.sect .text -.define _sub64u, _sub64ul - -_sub64u: ! u64_t sub64u(u64_t i, unsigned j); - push bp - mov bp, sp - xor cx, cx - jmp 0f -_sub64ul: ! u64_t sub64ul(u64_t i, unsigned long j); - push bp - mov bp, sp - mov cx, 16(bp) -0: mov bx, 4(bp) - mov ax, 6(bp) - sub ax, 14(bp) - mov (bx), ax - mov ax, 8(bp) - sbb ax, cx - mov 2(bx), ax - mov ax, 10(bp) - sbb ax, #0 - mov 4(bx), ax - mov ax, 12(bp) - sbb ax, #0 - mov 6(bx), ax - mov ax, bx - pop bp - ret diff --git a/lib/i86/misc/alloca.s b/lib/i86/misc/alloca.s deleted file mode 100644 index 560f096d1..000000000 --- a/lib/i86/misc/alloca.s +++ /dev/null @@ -1,23 +0,0 @@ -# -! alloca() - allocate space on the stack Author: Kees J. Bot -! 26 Jan 1994 - -#if __ACK__ /* BCC can't do alloca(), register saving is wrong. */ - -.text -.define _alloca -_alloca: - pop cx ! Return address - pop ax ! Bytes to allocate - add ax, #2*2+1 ! Add space for two saved register variables - andb al, #0xFE ! Align - mov bx, sp ! Keep current sp - sub sp, ax ! Lower stack - mov ax, sp ! Return value - push 2(bx) ! Push what is probably the saved si - push (bx) ! Saved di - ! Now ACK can still do: - ! pop di; pop si; mov sp, bp; pop bp; ret - push ax ! Dummy argument - jmp (cx) -#endif diff --git a/lib/i86/misc/get_bp.s b/lib/i86/misc/get_bp.s deleted file mode 100644 index 51711f767..000000000 --- a/lib/i86/misc/get_bp.s +++ /dev/null @@ -1,15 +0,0 @@ -! get_bp.s -! -! return BP in AX -! -! Created: Sep 7, 1992 by Philip Homburg - -.sect .text; .sect .rom; .sect .data; .sect .bss - -.sect .text -.define _get_bp -_get_bp: - mov ax, bp - ret - -! $PchId: get_bp.ack.s,v 1.3 1996/02/23 08:27:48 philip Exp $ diff --git a/lib/i86/misc/getprocessor.s b/lib/i86/misc/getprocessor.s deleted file mode 100644 index ed4c1a1ae..000000000 --- a/lib/i86/misc/getprocessor.s +++ /dev/null @@ -1,92 +0,0 @@ -! getprocessor() - determine processor type Author: Kees J. Bot -! 26 Jan 1994 - -.text - - o32 = 0x66 ! 32 bit operand size prefix - -! int getprocessor(void); -! Return 86, 186, 286, 386, 486, 586, ... - -.define _getprocessor - -_getprocessor: - push bp - mov bp, sp - push sp ! see if pushed sp == sp - pop ax - cmp ax, sp - jz new_processor - mov cx, #0x0120 ! see if shifts are mod 32 - shlb ch, cl ! zero tells if 86 - mov ax, #86 - jz got_processor - mov ax, #186 - jmp got_processor - -new_processor: ! see if high bits are set in saved IDT - sub sp, #6 ! space for IDT ptr - sidt -6(bp) ! save 3 word IDT ptr - cmpb -1(bp), #0xFF ! top byte of IDT ptr is always FF on 286 - mov ax, #286 - je got_processor - -! 386, 486, 586 - and sp, #0xFFFC ! Align stack to avoid AC fault (needed?) - mov cx, #0x0004 ! Try to flip the AC bit introduced on the 486 - call flip - mov ax, #386 ! 386 if it didn't react to "flipping" - jz got_processor - mov cx, #0x0020 ! Try to flip the ID bit introduced on the 586 - call flip - mov ax, #486 ! 486 if it didn't react - jz got_processor - .data1 o32 - pushf - .data1 o32 - pusha ! Save the world - .data1 o32 - xor ax, ax - inc ax ! eax = 1 - .data1 0x0F, 0xA2 ! CPUID instruction tells the processor type - andb ah, #0x0F ! Extract the family (5, 6, ...) - movb al, ah - movb ah, #100 - mulb ah ! 500, 600, ... - add ax, #86 ! 586, 686, ... - mov bx, sp - mov 7*4(bx), ax ! Pass ax through - .data1 o32 - popa - .data1 o32 - popf - -got_processor: - mov sp, bp - pop bp - ret - -flip: - push bx ! Save bx and realign stack to multiple of 4 - .data1 o32 ! About to operate on a 32 bit object - pushf ! Push eflags - pop ax - pop dx ! dx:ax = eflags - mov bx, dx ! Save original eflags (high word only) - xor dx, cx ! Flip the bit to test - push dx - push ax ! Push modified eflags value - .data1 o32 - popf ! Load modified eflags register - .data1 o32 - pushf - pop ax - pop dx ! Get it again - push bx - push ax - .data1 o32 - popf ! Restore original eflags register - xor dx, bx ! See if the bit changed - test dx, cx - pop bx ! Restore bx - ret diff --git a/lib/i86/misc/hton86.s b/lib/i86/misc/hton86.s deleted file mode 100644 index dd2246b34..000000000 --- a/lib/i86/misc/hton86.s +++ /dev/null @@ -1,25 +0,0 @@ -! htonX(), ntohX() - Host to network byte order conversion -! Author: Kees J. Bot -! 7 Jan 1997 -! -! This is a little endian 8086, so we swap bytes to/from the big endian network -! order. The normal macros are not used, they give lousy code. - -.text -.define _htons, _ntohs -_htons: -_ntohs: - mov bx, sp - movb ah, 2(bx) ! Load bytes into ax in reverse order - movb al, 3(bx) - ret - -.define _htonl, _ntohl -_htonl: -_ntohl: - mov bx, sp - movb dh, 2(bx) ! Load bytes into dx:ax in reverse order - movb dl, 3(bx) - movb ah, 4(bx) - movb al, 5(bx) - ret diff --git a/lib/i86/misc/io_inb.s b/lib/i86/misc/io_inb.s deleted file mode 100644 index 7a213faeb..000000000 --- a/lib/i86/misc/io_inb.s +++ /dev/null @@ -1,14 +0,0 @@ -! inb() - Input one byte Author: Kees J. Bot -! 18 Mar 1996 -! unsigned inb(U16_t port); - -.sect .text -.define _inb -_inb: - push bp - mov bp, sp - mov dx, 4(bp) ! port - inb dx ! read 1 byte - xorb ah, ah - pop bp - ret diff --git a/lib/i86/misc/io_inl.s b/lib/i86/misc/io_inl.s deleted file mode 100644 index 4dab9a33d..000000000 --- a/lib/i86/misc/io_inl.s +++ /dev/null @@ -1,23 +0,0 @@ -! inl() - Input one dword Author: Kees J. Bot -! 18 Mar 1996 -! unsigned inl(U16_t port); - - o32 = 0x66 - -.sect .text -.define _inl -_inl: - push bp - mov bp, sp - pushf - cli ! eax is not interrupt safe - mov dx, 4(bp) ! port - .data1 o32 - in dx ! read 1 dword - .data1 o32 - push ax ! push eax - pop ax - pop dx ! dx:ax = eax - popf - pop bp - ret diff --git a/lib/i86/misc/io_insb.s b/lib/i86/misc/io_insb.s deleted file mode 100644 index 65c55c1db..000000000 --- a/lib/i86/misc/io_insb.s +++ /dev/null @@ -1,21 +0,0 @@ -! insb() - Input a byte array Author: Kees J. Bot -! 18 Mar 1996 -! void insb(U16_t port, void *buf, size_t count); - -.sect .text -.define _insb -_insb: - push bp - mov bp, sp - cld - push di - mov dx, 4(bp) ! port - mov di, 6(bp) ! buf - mov cx, 8(bp) ! byte count - jcxz 1f -0: inb dx ! input 1 byte - stosb ! write 1 byte - loop 0b ! many times -1: pop di - pop bp - ret diff --git a/lib/i86/misc/io_insl.s b/lib/i86/misc/io_insl.s deleted file mode 100644 index 591ceb0f3..000000000 --- a/lib/i86/misc/io_insl.s +++ /dev/null @@ -1,22 +0,0 @@ -! insl() - Input a dword array Author: Kees J. Bot -! 18 Mar 1996 -! void insl(U16_t port, void *buf, size_t count); - - o32 = 0x66 - -.sect .text -.define _insl -_insl: - push bp - mov bp, sp - cld - push di - mov dx, 4(bp) ! port - mov di, 6(bp) ! buf - mov cx, 8(bp) ! byte count - shr cx, #2 ! dword count - .data1 o32 - rep ins ! input many dwords - pop di - pop bp - ret diff --git a/lib/i86/misc/io_insw.s b/lib/i86/misc/io_insw.s deleted file mode 100644 index a4e585178..000000000 --- a/lib/i86/misc/io_insw.s +++ /dev/null @@ -1,19 +0,0 @@ -! insw() - Input a word array Author: Kees J. Bot -! 18 Mar 1996 -! void insw(U16_t port, void *buf, size_t count); - -.sect .text -.define _insw -_insw: - push bp - mov bp, sp - cld - push di - mov dx, 4(bp) ! port - mov di, 6(bp) ! buf - mov cx, 8(bp) ! byte count - shr cx, #1 ! word count - rep ins ! input many words - pop di - pop bp - ret diff --git a/lib/i86/misc/io_intr.s b/lib/i86/misc/io_intr.s deleted file mode 100644 index f29277089..000000000 --- a/lib/i86/misc/io_intr.s +++ /dev/null @@ -1,16 +0,0 @@ -! intr_disable(), intr_enable - Disable/Enable hardware interrupts. -! Author: Kees J. Bot -! 18 Mar 1996 -! void intr_disable(void); -! void intr_enable(void); - -.sect .text -.define _intr_disable -_intr_disable: - cli - ret - -.define _intr_enable -_intr_enable: - sti - ret diff --git a/lib/i86/misc/io_inw.s b/lib/i86/misc/io_inw.s deleted file mode 100644 index 5659c93f6..000000000 --- a/lib/i86/misc/io_inw.s +++ /dev/null @@ -1,13 +0,0 @@ -! inw() - Input one word Author: Kees J. Bot -! 18 Mar 1996 -! unsigned inw(U16_t port); - -.sect .text -.define _inw -_inw: - push bp - mov bp, sp - mov dx, 4(bp) ! port - in dx ! read 1 word - pop bp - ret diff --git a/lib/i86/misc/io_outb.s b/lib/i86/misc/io_outb.s deleted file mode 100644 index 1dd4c413a..000000000 --- a/lib/i86/misc/io_outb.s +++ /dev/null @@ -1,14 +0,0 @@ -! outb() - Output one byte Author: Kees J. Bot -! 18 Mar 1996 -! void outb(U16_t port, U8_t value); - -.sect .text -.define _outb -_outb: - push bp - mov bp, sp - mov dx, 4(bp) ! port - mov ax, 4+2(bp) ! value - outb dx ! output 1 byte - pop bp - ret diff --git a/lib/i86/misc/io_outl.s b/lib/i86/misc/io_outl.s deleted file mode 100644 index 81200eda5..000000000 --- a/lib/i86/misc/io_outl.s +++ /dev/null @@ -1,21 +0,0 @@ -! outl() - Output one dword Author: Kees J. Bot -! 18 Mar 1996 -! void outl(U16_t port, u32_t value); - - o32 = 0x66 - -.sect .text -.define _outl -_outl: - push bp - mov bp, sp - pushf - cli ! eax is not interrupt safe - mov dx, 4(bp) ! port - .data1 o32 - mov ax, 4+2(bp) ! value - .data1 o32 - out dx ! output 1 dword - popf - pop bp - ret diff --git a/lib/i86/misc/io_outsb.s b/lib/i86/misc/io_outsb.s deleted file mode 100644 index 0fe64d17e..000000000 --- a/lib/i86/misc/io_outsb.s +++ /dev/null @@ -1,21 +0,0 @@ -! outsb() - Output a byte array Author: Kees J. Bot -! 18 Mar 1996 -! void outsb(U16_t port, void *buf, size_t count); - -.sect .text -.define _outsb -_outsb: - push bp - mov bp, sp - cld - push si - mov dx, 4(bp) ! port - mov si, 6(bp) ! buf - mov cx, 8(bp) ! byte count - jcxz 1f -0: lodsb ! read 1 byte - outb dx ! output 1 byte - loop 0b ! many times -1: pop si - pop bp - ret diff --git a/lib/i86/misc/io_outsl.s b/lib/i86/misc/io_outsl.s deleted file mode 100644 index 6e49ffc24..000000000 --- a/lib/i86/misc/io_outsl.s +++ /dev/null @@ -1,22 +0,0 @@ -! outsl() - Output a dword array Author: Kees J. Bot -! 18 Mar 1996 -! void outsl(U16_t port, void *buf, size_t count); - - o32 = 0x66 - -.sect .text -.define _outsl -_outsl: - push bp - mov bp, sp - cld - push si - mov dx, 4(bp) ! port - mov si, 6(bp) ! buf - mov cx, 8(bp) ! byte count - shr cx, #2 ! dword count - .data1 o32 - rep outs ! output many dwords - pop si - pop bp - ret diff --git a/lib/i86/misc/io_outsw.s b/lib/i86/misc/io_outsw.s deleted file mode 100644 index 5510bfb77..000000000 --- a/lib/i86/misc/io_outsw.s +++ /dev/null @@ -1,19 +0,0 @@ -! outsw() - Output a word array Author: Kees J. Bot -! 18 Mar 1996 -! void outsw(U16_t port, void *buf, size_t count); - -.sect .text -.define _outsw -_outsw: - push bp - mov bp, sp - cld - push si - mov dx, 4(bp) ! port - mov si, 6(bp) ! buf - mov cx, 8(bp) ! byte count - shr cx, #1 ! word count - rep outs ! output many words - pop si - pop bp - ret diff --git a/lib/i86/misc/io_outw.s b/lib/i86/misc/io_outw.s deleted file mode 100644 index 064429d83..000000000 --- a/lib/i86/misc/io_outw.s +++ /dev/null @@ -1,14 +0,0 @@ -! outw() - Output one word Author: Kees J. Bot -! 18 Mar 1996 -! void outw(U16_t port, U16_t value); - -.sect .text -.define _outw -_outw: - push bp - mov bp, sp - mov dx, 4(bp) ! port - mov ax, 4+2(bp) ! value - out dx ! output 1 word - pop bp - ret diff --git a/lib/i86/misc/oneC_sum.s b/lib/i86/misc/oneC_sum.s deleted file mode 100644 index e5a6e4434..000000000 --- a/lib/i86/misc/oneC_sum.s +++ /dev/null @@ -1,68 +0,0 @@ -! oneC_sum() - One complement`s checksum Author: Kees J. Bot -! 23 May 1998 -! See RFC 1071, "Computing the Internet checksum" -! See also the C version of this code. - -.text - -.define _oneC_sum - .align 4 -_oneC_sum: - push bp - mov bp, sp - push si - push di - mov ax, 4(bp) ! Checksum of previous block - mov si, 6(bp) ! Data to compute checksum over - mov di, 8(bp) ! Number of bytes - - xor dx, dx - xorb cl, cl -align: test si, #1 ! Is the data aligned? - jz aligned - test di, di - jz 0f - movb dh, (si) ! First unaligned byte in high half of - dec di ! the dx register, i.e. rotate 8 bits -0: inc si - movb cl, #8 ! Number of bits "rotated" - ror ax, cl ! Rotate the checksum likewise -aligned:add ax, dx ! Summate the unaligned byte - adc ax, #0 ! Add carry back in for one`s complement - - jmp add6test - .align 4 -add6: add ax, (si) ! Six times unrolled loop, see below - adc ax, 2(si) - adc ax, 4(si) - adc ax, 6(si) - adc ax, 8(si) - adc ax, 10(si) - adc ax, #0 - add si, #12 -add6test: - sub di, #12 - jae add6 - add di, #12 - - jmp add1test - .align 4 -add1: add ax, (si) ! while ((di -= 2) >= 0) - adc ax, #0 ! ax += *si++; - add si, #2 ! di += 2; -add1test: - sub di, #2 - jae add1 - add di, #2 - - jz done ! Is there an extra byte? - movb dl, (si) ! Load extra byte in word - xorb dh, dh - add ax, dx ! Add in the last bits - adc ax, #0 -done: - rol ax, cl ! Undo the rotation at the beginning - pop di - pop si - pop bp - ret diff --git a/lib/i86/rts/__sigreturn.s b/lib/i86/rts/__sigreturn.s deleted file mode 100644 index 3578e3a8d..000000000 --- a/lib/i86/rts/__sigreturn.s +++ /dev/null @@ -1,10 +0,0 @@ -! This routine is the low-level code for returning from signals. -! It calls __sigreturn, which is the normal "system call" routine. -! Both ___sigreturn and __sigreturn are needed. -.sect .text; .sect .rom; .sect .data; .sect .bss -.sect .text -.define ___sigreturn -.extern __sigreturn -___sigreturn: - add sp, #8 - jmp __sigreturn diff --git a/lib/i86/rts/_sendrec.s b/lib/i86/rts/_sendrec.s deleted file mode 100644 index 71af81fd3..000000000 --- a/lib/i86/rts/_sendrec.s +++ /dev/null @@ -1,32 +0,0 @@ -.define __send, __receive, __sendrec - -! See ../h/com.h for C definitions -SEND = 1 -RECEIVE = 2 -BOTH = 3 -SYSVEC = 32 - -!*========================================================================* -! _send and _receive * -!*========================================================================* -! _send(), _receive(), _sendrec() all save bp, but destroy ax, bx, and cx. -.extern __send, __receive, __sendrec -__send: mov cx,*SEND ! _send(dest, ptr) - jmp L0 - -__receive: - mov cx,*RECEIVE ! _receive(src, ptr) - jmp L0 - -__sendrec: - mov cx,*BOTH ! _sendrec(srcdest, ptr) - jmp L0 - - L0: push bp ! save bp - mov bp,sp ! can't index off sp - mov ax,4(bp) ! ax = dest-src - mov bx,6(bp) ! bx = message pointer - int SYSVEC ! trap to the kernel - pop bp ! restore bp - ret ! return - diff --git a/lib/i86/rts/brksize.s b/lib/i86/rts/brksize.s deleted file mode 100644 index 793600bc9..000000000 --- a/lib/i86/rts/brksize.s +++ /dev/null @@ -1,4 +0,0 @@ -.define __brksize -.data -.extern endbss, __brksize -__brksize: .data2 endbss diff --git a/lib/i86/rts/ncrtso.s b/lib/i86/rts/ncrtso.s deleted file mode 100644 index 4ce989cf9..000000000 --- a/lib/i86/rts/ncrtso.s +++ /dev/null @@ -1,54 +0,0 @@ -! This is the C run-time start-off routine. It's job is to take the -! arguments as put on the stack by EXEC, and to parse them and set them up the -! way _main expects them. -! It also initializes _environ when this variable isn't defined by the -! programmer. The detection of whether _environ belong to us is rather -! simplistic. We simply check for some magic value, but there is no other -! way. - -.extern _main, _exit, crtso, __penviron, __penvp -.extern begtext, begdata, begbss, endtext, enddata, endbss -.text -begtext: -crtso: - xor bp, bp ! clear for backtrace of core files - mov bx, sp - mov ax, (bx) ! argc - lea dx, 2(bx) ! argv - lea cx, 4(bx) - add cx, ax - add cx, ax ! envp - - ! Test if environ is in the initialized data area and is set to our - ! magic number. If so then it is not redefined by the user. - mov bx, #_environ - cmp bx, #__edata ! within initialized data? - jae 0f - testb bl, #1 ! aligned? - jnz 0f - cmp (bx), #0x5353 ! is it our environ? - jne 0f - mov __penviron, bx ! _penviron = &environ; -0: mov bx, __penviron - mov (bx), cx ! *_penviron = envp; - - push cx ! push envp - push dx ! push argv - push ax ! push argc - - call _main ! main(argc, argv, envp) - - push ax ! push exit status - call _exit - - hlt ! force a trap if exit fails - -.data -begdata: - .data2 0 ! for sep I&D: *NULL == 0 -__penviron: - .data2 __penvp ! Pointer to environ, or hidden pointer - -.bss -begbss: - .comm __penvp, 2 ! Hidden environment vector diff --git a/lib/i86/rts/nm2rtso.s b/lib/i86/rts/nm2rtso.s deleted file mode 100644 index 5f6ad649b..000000000 --- a/lib/i86/rts/nm2rtso.s +++ /dev/null @@ -1,50 +0,0 @@ -! This is the Modula-2 run-time start-off routine. It's job is to take the -! arguments as put on the stack by EXEC, and to parse them and set them up the -! way _m_a_i_n expects them. - -.extern __m_a_i_n, _exit, m2rtso, hol0, __penvp -.extern begtext, begdata, begbss, endtext, enddata, endbss -.text -begtext: -m2rtso: - xor bp, bp ! clear for backtrace of core files - mov bx, sp - mov ax, (bx) ! argc - lea dx, 2(bx) ! argv - lea cx, 4(bx) - add cx, ax - add cx, ax ! envp - - ! Test if environ is in the initialized data area and is set to our - ! magic number. If so then it is not redefined by the user. - mov bx, #_environ - cmp bx, #__edata ! within initialized data? - jae 0f - testb bl, #1 ! aligned? - jnz 0f - cmp (bx), #0x5353 ! is it our environ? - jne 0f - mov __penviron, bx ! _penviron = &environ; -0: mov bx, __penviron - mov (bx), cx ! *_penviron = envp; - - push cx ! push envp - push dx ! push argv - push ax ! push argc - - call __m_a_i_n ! run Modula-2 program - - push ax ! push exit status - call __exit - - hlt ! force a trap if exit fails - -.data -begdata: - .data2 0 ! for sep I&D: *NULL == 0 -__penviron: - .data2 __penvp ! Pointer to environ, or hidden pointer - -.bss -begbss: - .comm __penvp, 2 ! Hidden environment vector diff --git a/lib/i86/rts/nprtso.s b/lib/i86/rts/nprtso.s deleted file mode 100644 index 83c2bb76f..000000000 --- a/lib/i86/rts/nprtso.s +++ /dev/null @@ -1,52 +0,0 @@ -! This is the Pascal run-time start-off routine. It's job is to take the -! arguments as put on the stack by EXEC, and to parse them and set them up the -! way _m_a_i_n expects them. - -.extern __m_a_i_n, _exit, prtso, hol0, __penvp -.extern begtext, begdata, begbss, endtext, enddata, endbss -.text -begtext: -prtso: - xor bp, bp ! clear for backtrace of core files - mov bx, sp - mov ax, (bx) ! argc - lea dx, 2(bx) ! argv - lea cx, 4(bx) - add cx, ax - add cx, ax ! envp - - ! Test if environ is in the initialized data area and is set to our - ! magic number. If so then it is not redefined by the user. - mov bx, #_environ - cmp bx, #__edata ! within initialized data? - jae 0f - testb bl, #1 ! aligned? - jnz 0f - cmp (bx), #0x5353 ! is it our environ? - jne 0f - mov __penviron, bx ! _penviron = &environ; -0: mov bx, __penviron - mov (bx), cx ! *_penviron = envp; - - push cx ! push envp - push dx ! push argv - push ax ! push argc - - mov .ignmask, #56 - - call __m_a_i_n ! run Pascal program - - push ax ! push exit status - call __exit - - hlt ! force a trap if exit fails - -.data -begdata: - .data2 0 ! for sep I&D: *NULL == 0 -__penviron: - .data2 __penvp ! Pointer to environ, or hidden pointer - -.bss -begbss: - .comm __penvp, 2 ! Hidden environment vector diff --git a/lib/i86/string/README b/lib/i86/string/README deleted file mode 100644 index e00324a01..000000000 --- a/lib/i86/string/README +++ /dev/null @@ -1,5 +0,0 @@ -Notes on i8086 string assembly routines. Author: Kees J. Bot - 27 Jan 1994 - -These routines are simply translations of the 386 code, so all comments -to that code apply here. diff --git a/lib/i86/string/_memmove.s b/lib/i86/string/_memmove.s deleted file mode 100644 index 456c2dc57..000000000 --- a/lib/i86/string/_memmove.s +++ /dev/null @@ -1,50 +0,0 @@ -! _memmove() Author: Kees J. Bot -! 27 Jan 1994 -.sect .text; .sect .rom; .sect .data; .sect .bss - -! void *_memmove(void *s1, const void *s2, size_t n) -! Copy a chunk of memory. Handle overlap. -! -.sect .text -.define __memmove, __memcpy -__memmove: - push bp - mov bp, sp - push si - push di - mov di, 4(bp) ! String s1 - mov si, 6(bp) ! String s2 - mov cx, 8(bp) ! Length - mov ax, di - sub ax, si - cmp ax, cx - jb downwards ! if (s2 - s1) < n then copy downwards -__memcpy: - cld ! Clear direction bit: upwards - cmp cx, #16 - jb upbyte ! Don't bother being smart with short arrays - mov ax, si - or ax, di - testb al, #1 - jnz upbyte ! Bit 0 set, use byte copy -upword: shr cx, #1 - rep movs ! Copy words - adc cx, cx ! One more byte? -upbyte: - rep movsb ! Copy bytes -done: mov ax, 4(bp) ! Absolutely noone cares about this value - pop di - pop si - pop bp - ret - -! Handle bad overlap by copying downwards, don't bother to do word copies. -downwards: - std ! Set direction bit: downwards - add si, cx - dec si - add di, cx - dec di - rep movsb ! Copy bytes - cld - jmp done diff --git a/lib/i86/string/_strncat.s b/lib/i86/string/_strncat.s deleted file mode 100644 index 390fed919..000000000 --- a/lib/i86/string/_strncat.s +++ /dev/null @@ -1,37 +0,0 @@ -! _strncat() Author: Kees J. Bot -! 27 Jan 1994 -.sect .text; .sect .rom; .sect .data; .sect .bss - -! char *_strncat(char *s1, const char *s2, size_t dx) -! Append string s2 to s1. -! -.sect .text -.define __strncat -__strncat: - push bp - mov bp, sp - push si - push di - mov di, 4(bp) ! String s1 - mov cx, #-1 - xorb al, al ! Null byte - cld - repne scasb ! Look for the zero byte in s1 - dec di ! Back one up (and clear 'Z' flag) - push di ! Save end of s1 - mov di, 6(bp) ! di = string s2 - mov cx, dx ! Maximum count - repne scasb ! Look for the end of s2 - jne no0 - inc cx ! Exclude null byte -no0: sub dx, cx ! Number of bytes in s2 - mov cx, dx - mov si, 6(bp) ! si = string s2 - pop di ! di = end of string s1 - rep movsb ! Copy bytes - stosb ! Add a terminating null - mov ax, 4(bp) ! Return s1 - pop di - pop si - pop bp - ret diff --git a/lib/i86/string/_strncmp.s b/lib/i86/string/_strncmp.s deleted file mode 100644 index ec2ffe975..000000000 --- a/lib/i86/string/_strncmp.s +++ /dev/null @@ -1,36 +0,0 @@ -! strncmp() Author: Kees J. Bot -! 27 Jan 1994 -.sect .text; .sect .rom; .sect .data; .sect .bss - -! int strncmp(const char *s1, const char *s2, size_t cx) -! Compare two strings. -! -.sect .text -.define __strncmp -__strncmp: - push bp - mov bp, sp - push si - push di - xor ax, ax ! Prepare return value - test cx, cx ! Max length is zero? - je equal - mov si, 4(bp) ! si = string s1 - mov di, 6(bp) ! di = string s2 - cld -compare: - cmpsb ! Compare two bytes - jne unequal - cmpb -1(si), #0 ! End of string? - je equal - dec cx ! Length limit reached? - jne compare - jmp equal -unequal: - ja after - sub ax, #2 ! if (s1 < s2) ax -= 2; -after: inc ax ! ax++, now it's -1 or 1 -equal: pop di - pop si - pop bp - ret diff --git a/lib/i86/string/_strncpy.s b/lib/i86/string/_strncpy.s deleted file mode 100644 index aa075915b..000000000 --- a/lib/i86/string/_strncpy.s +++ /dev/null @@ -1,21 +0,0 @@ -! _strncpy() Author: Kees J. Bot -! 27 Jan 1994 -.sect .text; .sect .rom; .sect .data; .sect .bss - -! char *_strncpy(char *s1, const char *s2, size_t cx) -! Copy string s2 to s1. -! -.sect .text -.define __strncpy -__strncpy: - mov di, 6(bp) ! di = string s2 - xorb al, al ! Look for a zero byte - mov dx, cx ! Save maximum count - cld - repne scasb ! Look for end of s2 - sub dx, cx ! Number of bytes in s2 including null - xchg cx, dx - mov si, 6(bp) ! si = string s2 - mov di, 4(bp) ! di = string s1 - rep movsb ! Copy bytes - ret diff --git a/lib/i86/string/_strnlen.s b/lib/i86/string/_strnlen.s deleted file mode 100644 index dd0de1f7f..000000000 --- a/lib/i86/string/_strnlen.s +++ /dev/null @@ -1,26 +0,0 @@ -! _strnlen() Author: Kees J. Bot -! 27 Jan 1994 -.sect .text; .sect .rom; .sect .data; .sect .bss - -! size_t _strnlen(const char *s, size_t cx) -! Return the length of a string. -! -.sect .text -.define __strnlen -__strnlen: - push bp - mov bp, sp - push di - mov di, 4(bp) ! di = string - xorb al, al ! Look for a zero byte - mov dx, cx ! Save maximum count - cmpb cl, #1 ! 'Z' bit must be clear if cx = 0 - cld - repne scasb ! Look for zero - jne no0 - inc cx ! Don't count zero byte -no0: mov ax, dx - sub ax, cx ! Compute bytes scanned - pop di - pop bp - ret diff --git a/lib/i86/string/bcmp.s b/lib/i86/string/bcmp.s deleted file mode 100644 index c6be9db23..000000000 --- a/lib/i86/string/bcmp.s +++ /dev/null @@ -1,28 +0,0 @@ -! bcmp() Author: Kees J. Bot -! 27 Jan 1994 -.sect .text; .sect .rom; .sect .data; .sect .bss - -! int bcmp(const void *s1, const void *s2, size_t n) -! Compare two chunks of memory. -! This is a BSD routine that escaped from the kernel. Don't use. -! (Alas it is not without some use, it reports the number of bytes -! after the bytes that are equal. So it can't be simply replaced.) -! -.sect .text -.define _bcmp -_bcmp: - push bp - mov bp, sp - push 8(bp) - push 6(bp) - push 4(bp) - call _memcmp ! Let memcmp do the work - mov sp, bp - test ax, ax - jz equal - sub dx, 4(bp) ! Memcmp was nice enough to leave "si" in dx - dec dx ! Number of bytes that are equal - mov ax, 8(bp) - sub ax, dx ! Number of bytes that are unequal -equal: pop bp - ret diff --git a/lib/i86/string/bcopy.s b/lib/i86/string/bcopy.s deleted file mode 100644 index c63f582e9..000000000 --- a/lib/i86/string/bcopy.s +++ /dev/null @@ -1,19 +0,0 @@ -! bcopy() Author: Kees J. Bot -! 27 Jan 1994 -.sect .text; .sect .rom; .sect .data; .sect .bss - -! void bcopy(const void *s1, void *s2, size_t n) -! Copy a chunk of memory. Handle overlap. -! This is a BSD routine that escaped from the kernel. Don't use. -! -.sect .text -.define _bcopy -.extern __memmove -_bcopy: - pop cx - pop ax - pop dx ! Pop return address and arguments - push ax - push dx ! Arguments reversed - push cx - jmp __memmove ! Call the proper routine diff --git a/lib/i86/string/bzero.s b/lib/i86/string/bzero.s deleted file mode 100644 index edc4397f7..000000000 --- a/lib/i86/string/bzero.s +++ /dev/null @@ -1,21 +0,0 @@ -! bzero() Author: Kees J. Bot -! 27 Jan 1994 -.sect .text; .sect .rom; .sect .data; .sect .bss - -! void bzero(void *s, size_t n) -! Set a chunk of memory to zero. -! This is a BSD routine that escaped from the kernel. Don't use. -! -.sect .text -.define _bzero -_bzero: - push bp - mov bp, sp - push 6(bp) ! Size - xor ax, ax - push ax ! Zero - push 4(bp) ! String - call _memset ! Call the proper routine - mov sp, bp - pop bp - ret diff --git a/lib/i86/string/index.s b/lib/i86/string/index.s deleted file mode 100644 index f8b60ef39..000000000 --- a/lib/i86/string/index.s +++ /dev/null @@ -1,12 +0,0 @@ -! index() Author: Kees J. Bot -! 27 Jan 1994 -.sect .text; .sect .rom; .sect .data; .sect .bss - -! char *index(const char *s, int c) -! Look for a character in a string. Has suffered from a hostile -! takeover by strchr(). -! -.sect .text -.define _index -_index: - jmp _strchr diff --git a/lib/i86/string/memchr.s b/lib/i86/string/memchr.s deleted file mode 100644 index 462efdbe4..000000000 --- a/lib/i86/string/memchr.s +++ /dev/null @@ -1,28 +0,0 @@ -! memchr() Author: Kees J. Bot -! 27 Jan 1994 -.sect .text; .sect .rom; .sect .data; .sect .bss - -! void *memchr(const void *s, int c, size_t n) -! Look for a character in a chunk of memory. -! -.sect .text -.define _memchr -_memchr: - push bp - mov bp, sp - push di - mov di, 4(bp) ! di = string - movb al, 6(bp) ! The character to look for - mov cx, 8(bp) ! Length - cmpb cl, #1 ! 'Z' bit must be clear if cx = 0 - cld - repne scasb - jne failure - lea ax, -1(di) ! Found - pop di - pop bp - ret -failure:xor ax, ax - pop di - pop bp - ret diff --git a/lib/i86/string/memcmp.s b/lib/i86/string/memcmp.s deleted file mode 100644 index 223970292..000000000 --- a/lib/i86/string/memcmp.s +++ /dev/null @@ -1,44 +0,0 @@ -! memcmp() Author: Kees J. Bot -! 27 Jan 1994 -.sect .text; .sect .rom; .sect .data; .sect .bss - -! int memcmp(const void *s1, const void *s2, size_t n) -! Compare two chunks of memory. -! -.sect .text -.define _memcmp -_memcmp: - cld - push bp - mov bp, sp - push si - push di - xor ax, ax ! Prepare return value - mov si, 4(bp) ! String s1 - mov di, 6(bp) ! String s2 - mov cx, 8(bp) ! Length - cmp cx, #16 - jb cbyte ! Don't bother being smart with short arrays - mov dx, si - or dx, di - andb dl, #1 - jnz cbyte ! Bit 0 set, use byte compare -cword: sar cx, #1 - adcb dl, dl ! Save carry - repe cmps ! Compare words - mov cx, #2 ! Recompare the last word - sub si, cx - sub di, cx - addb cl, dl ! One more byte? -cbyte: test cx, cx ! Set 'Z' flag if cx = 0 -last: - repe cmpsb ! Look for the first differing byte - je equal - ja after - sub ax, #2 ! if (s1 < s2) ax -= 2; -after: inc ax ! ax++, now it's -1 or 1 -equal: mov dx, si ! For bcmp() to play with - pop di - pop si - pop bp - ret diff --git a/lib/i86/string/memcpy.s b/lib/i86/string/memcpy.s deleted file mode 100644 index a4a9b536a..000000000 --- a/lib/i86/string/memcpy.s +++ /dev/null @@ -1,23 +0,0 @@ -! memcpy() Author: Kees J. Bot -! 27 Jan 1994 -.sect .text; .sect .rom; .sect .data; .sect .bss - -! void *memcpy(void *s1, const void *s2, size_t n) -! Copy a chunk of memory. -! This routine need not handle overlap, so it does not handle overlap. -! One could simply call __memmove, the cost of the overlap check is -! negligible, but you are dealing with a programmer who believes that -! if anything can go wrong, it should go wrong. -! -.sect .text -.define _memcpy -_memcpy: - push bp - mov bp, sp - push si - push di - mov di, 4(bp) ! String s1 - mov si, 6(bp) ! String s2 - mov cx, 8(bp) ! Length - ! No overlap check here - jmp __memcpy ! Call the part of __memmove that copies up diff --git a/lib/i86/string/memmove.s b/lib/i86/string/memmove.s deleted file mode 100644 index 834e083fd..000000000 --- a/lib/i86/string/memmove.s +++ /dev/null @@ -1,11 +0,0 @@ -! memmove() Author: Kees J. Bot -! 27 Jan 1994 -.sect .text; .sect .rom; .sect .data; .sect .bss - -! void *memmove(void *s1, const void *s2, size_t n) -! Copy a chunk of memory. Handle overlap. -! -.sect .text -.define _memmove -_memmove: - jmp __memmove ! Call common code diff --git a/lib/i86/string/memset.s b/lib/i86/string/memset.s deleted file mode 100644 index a36a31a33..000000000 --- a/lib/i86/string/memset.s +++ /dev/null @@ -1,31 +0,0 @@ -! memset() Author: Kees J. Bot -! 27 Jan 1994 -.sect .text; .sect .rom; .sect .data; .sect .bss - -! void *memset(void *s, int c, size_t n) -! Set a chunk of memory to the same byte value. -! -.sect .text -.define _memset -_memset: - push bp - mov bp, sp - push di - mov di, 4(bp) ! The string - movb al, 6(bp) ! The fill byte - mov cx, 8(bp) ! Length - cld - cmp cx, #16 - jb sbyte ! Don't bother being smart with short arrays - test di, #1 - jnz sbyte ! Bit 0 set, use byte store -sword: movb ah, al ! One byte to two bytes - sar cx, #1 - rep stos ! Store words - adc cx, cx ! One more byte? -sbyte: - rep stosb ! Store bytes -done: mov ax, 4(bp) ! Return some value you have no need for - pop di - pop bp - ret diff --git a/lib/i86/string/rindex.s b/lib/i86/string/rindex.s deleted file mode 100644 index b5f64deab..000000000 --- a/lib/i86/string/rindex.s +++ /dev/null @@ -1,12 +0,0 @@ -! rindex() Author: Kees J. Bot -! 27 Jan 1994 -.sect .text; .sect .rom; .sect .data; .sect .bss - -! char *rindex(const char *s, int c) -! Look for the last occurrence a character in a string. Has suffered -! from a hostile takeover by strrchr(). -! -.sect .text -.define _rindex -_rindex: - jmp _strrchr diff --git a/lib/i86/string/strcat.s b/lib/i86/string/strcat.s deleted file mode 100644 index 7d4d7d6ca..000000000 --- a/lib/i86/string/strcat.s +++ /dev/null @@ -1,12 +0,0 @@ -! strcat() Author: Kees J. Bot -! 27 Jan 1994 -.sect .text; .sect .rom; .sect .data; .sect .bss - -! char *strcat(char *s1, const char *s2) -! Append string s2 to s1. -! -.sect .text -.define _strcat -_strcat: - mov dx, #-1 ! Unlimited length - jmp __strncat ! Common code diff --git a/lib/i86/string/strchr.s b/lib/i86/string/strchr.s deleted file mode 100644 index 13bde0710..000000000 --- a/lib/i86/string/strchr.s +++ /dev/null @@ -1,38 +0,0 @@ -! strchr() Author: Kees J. Bot -! 27 Jan 1994 -.sect .text; .sect .rom; .sect .data; .sect .bss - -! char *strchr(const char *s, int c) -! Look for a character in a string. -! -.sect .text -.define _strchr -_strchr: - push bp - mov bp, sp - push di - cld - mov di, 4(bp) ! di = string - mov dx, #16 ! Look at small chunks of the string -next: shl dx, #1 ! Chunks become bigger each time - mov cx, dx - xorb al, al ! Look for the zero at the end - repne scasb - pushf ! Remember the flags - sub cx, dx - neg cx ! Some or all of the chunk - sub di, cx ! Step back - movb al, 6(bp) ! The character to look for - repne scasb - je found - popf ! Did we find the end of string earlier? - jne next ! No, try again - xor ax, ax ! Return NULL - pop di - pop bp - ret -found: pop ax ! Get rid of those flags - lea ax, -1(di) ! Address of byte found - pop di - pop bp - ret diff --git a/lib/i86/string/strcmp.s b/lib/i86/string/strcmp.s deleted file mode 100644 index da026a9c7..000000000 --- a/lib/i86/string/strcmp.s +++ /dev/null @@ -1,12 +0,0 @@ -! strcmp() Author: Kees J. Bot -! 27 Jan 1994 -.sect .text; .sect .rom; .sect .data; .sect .bss - -! int strcmp(const char *s1, const char *s2) -! Compare two strings. -! -.sect .text -.define _strcmp -_strcmp: - mov cx, #-1 ! Unlimited length - jmp __strncmp ! Common code diff --git a/lib/i86/string/strcpy.s b/lib/i86/string/strcpy.s deleted file mode 100644 index 0c2e55bbe..000000000 --- a/lib/i86/string/strcpy.s +++ /dev/null @@ -1,21 +0,0 @@ -! strcpy() Author: Kees J. Bot -! 27 Jan 1994 -.sect .text; .sect .rom; .sect .data; .sect .bss - -! char *strcpy(char *s1, const char *s2) -! Copy string s2 to s1. -! -.sect .text -.define _strcpy -_strcpy: - push bp - mov bp, sp - push si - push di - mov cx, #-1 ! Unlimited length - call __strncpy ! Common code - mov ax, 4(bp) ! Return s1 - pop di - pop si - pop bp - ret diff --git a/lib/i86/string/strlen.s b/lib/i86/string/strlen.s deleted file mode 100644 index 41cab909f..000000000 --- a/lib/i86/string/strlen.s +++ /dev/null @@ -1,12 +0,0 @@ -! strlen() Author: Kees J. Bot -! 27 Jan 1994 -.sect .text; .sect .rom; .sect .data; .sect .bss - -! size_t strlen(const char *s) -! Return the length of a string. -! -.sect .text -.define _strlen -_strlen: - mov cx, #-1 ! Unlimited length - jmp __strnlen ! Common code diff --git a/lib/i86/string/strncat.s b/lib/i86/string/strncat.s deleted file mode 100644 index 80afe1e91..000000000 --- a/lib/i86/string/strncat.s +++ /dev/null @@ -1,13 +0,0 @@ -! strncat() Author: Kees J. Bot -! 27 Jan 1994 -.sect .text; .sect .rom; .sect .data; .sect .bss - -! size_t strncat(char *s1, const char *s2, size_t n) -! Append string s2 to s1. -! -.sect .text -.define _strncat -_strncat: - mov bx, sp - mov dx, 6(bx) ! Maximum length - jmp __strncat ! Common code diff --git a/lib/i86/string/strncmp.s b/lib/i86/string/strncmp.s deleted file mode 100644 index 089a089ac..000000000 --- a/lib/i86/string/strncmp.s +++ /dev/null @@ -1,13 +0,0 @@ -! strncmp() Author: Kees J. Bot -! 27 Jan 1994 -.sect .text; .sect .rom; .sect .data; .sect .bss - -! int strncmp(const char *s1, const char *s2, size_t n) -! Compare two strings. -! -.sect .text -.define _strncmp -_strncmp: - mov bx, sp - mov cx, 6(bx) ! Maximum length - jmp __strncmp ! Common code diff --git a/lib/i86/string/strncpy.s b/lib/i86/string/strncpy.s deleted file mode 100644 index fb1ded00d..000000000 --- a/lib/i86/string/strncpy.s +++ /dev/null @@ -1,23 +0,0 @@ -! strncpy() Author: Kees J. Bot -! 27 Jan 1994 -.sect .text; .sect .rom; .sect .data; .sect .bss - -! char *strncpy(char *s1, const char *s2, size_t n) -! Copy string s2 to s1. -! -.sect .text -.define _strncpy -_strncpy: - push bp - mov bp, sp - push si - push di - mov cx, 8(bp) ! Maximum length - call __strncpy ! Common code - mov cx, dx ! Number of bytes not copied - rep stosb ! strncpy always copies n bytes by null padding - mov ax, 4(bp) ! Return s1 - pop di - pop si - pop bp - ret diff --git a/lib/i86/string/strnlen.s b/lib/i86/string/strnlen.s deleted file mode 100644 index b18748a34..000000000 --- a/lib/i86/string/strnlen.s +++ /dev/null @@ -1,13 +0,0 @@ -! strnlen() Author: Kees J. Bot -! 27 Jan 1994 -.sect .text; .sect .rom; .sect .data; .sect .bss - -! size_t strnlen(const char *s, size_t n) -! Return the length of a string. -! -.sect .text -.define _strnlen -_strnlen: - mov bx, sp - mov cx, 4(bx) ! Maximum length - jmp __strnlen ! Common code diff --git a/lib/i86/string/strrchr.s b/lib/i86/string/strrchr.s deleted file mode 100644 index 5daa30df0..000000000 --- a/lib/i86/string/strrchr.s +++ /dev/null @@ -1,33 +0,0 @@ -! strrchr() Author: Kees J. Bot -! 27 Jan 1994 -.sect .text; .sect .rom; .sect .data; .sect .bss - -! char *strrchr(const char *s, int c) -! Look for the last occurrence a character in a string. -! -.sect .text -.define _strrchr -_strrchr: - push bp - mov bp, sp - push di - mov di, 4(bp) ! di = string - mov cx, #-1 - xorb al, al - cld - repne scasb ! Look for the end of the string - not cx ! -1 - cx = Length of the string + null - dec di ! Put di back on the zero byte - movb al, 6(bp) ! The character to look for - std ! Downwards search - repne scasb - cld ! Direction bit back to default - jne failure - lea ax, 1(di) ! Found it - pop di - pop bp - ret -failure:xor ax, ax ! Not there - pop di - pop bp - ret diff --git a/lib/libc/Makefile b/lib/libc/Makefile new file mode 100644 index 000000000..862a90b54 --- /dev/null +++ b/lib/libc/Makefile @@ -0,0 +1,33 @@ +# Makefile for libc + +LIB= c + +CPPFLAGS+=-O -D_MINIX -D_POSIX_SOURCE + +.include "${.CURDIR}/ansi/Makefile.inc" +.include "${.CURDIR}/ip/Makefile.inc" +.include "${.CURDIR}/math/Makefile.inc" +.include "${.CURDIR}/other/Makefile.inc" +.include "${.CURDIR}/posix/Makefile.inc" +.include "${.CURDIR}/regex/Makefile.inc" +.include "${.CURDIR}/stdio/Makefile.inc" +.include "${.CURDIR}/stdtime/Makefile.inc" +.include "${.CURDIR}/syscall/Makefile.inc" +.include "${.CURDIR}/sysvipc/Makefile.inc" + +.include "${.CURDIR}/arch/${ARCH}/int64/Makefile.inc" +.include "${.CURDIR}/arch/${ARCH}/misc/Makefile.inc" +.include "${.CURDIR}/arch/${ARCH}/math/Makefile.inc" +.include "${.CURDIR}/arch/${ARCH}/rts/Makefile.inc" +.include "${.CURDIR}/arch/${ARCH}/string/Makefile.inc" + +.if (${COMPILER_TYPE} == ack) +.include "${.CURDIR}/ack/fphook/Makefile.inc" +.include "${.CURDIR}/ack/math/Makefile.inc" +.include "${.CURDIR}/ack/rts/Makefile.inc" +.elif (${COMPILER_TYPE} == gnu) +.include "${.CURDIR}/gnu/ieee_float/Makefile.inc" +.include "${.CURDIR}/gnu/arch/${ARCH}/rts/Makefile.inc" +.endif + +.include diff --git a/lib/libc/ack/fphook/Makefile.inc b/lib/libc/ack/fphook/Makefile.inc new file mode 100644 index 000000000..0a19f3b56 --- /dev/null +++ b/lib/libc/ack/fphook/Makefile.inc @@ -0,0 +1,14 @@ +# The ACK ANSI C compiler has an nice trick to reduce the size of programs +# that do not use floating point. If a program uses floating point then the +# compiler generates an external reference to the label '_fp_hook'. This makes +# the loader bring in the floating point printing and conversion routines +# '_f_print' and 'strtod' from the library libd.a. Otherwise two dummy +# routines are found in libc.a. (The printf and scanf need floating point +# for the %f formats, whether you use them or not.) + +# fphook sources +.PATH: ${.CURDIR}/ack/fphook + +CPPFLAGS.fltpr.c+=-I${.CURDIR}/stdio + +SRCS+=fltpr.c strtod.c diff --git a/lib/ack/fphook/fltpr.c b/lib/libc/ack/fphook/fltpr.c similarity index 86% rename from lib/ack/fphook/fltpr.c rename to lib/libc/ack/fphook/fltpr.c index 7ba3fb018..1972f3ba3 100644 --- a/lib/ack/fphook/fltpr.c +++ b/lib/libc/ack/fphook/fltpr.c @@ -1,6 +1,6 @@ #include #include -#include "../stdio/loc_incl.h" +#include "loc_incl.h" int _fp_hook = 1; diff --git a/lib/ack/fphook/strtod.c b/lib/libc/ack/fphook/strtod.c similarity index 100% rename from lib/ack/fphook/strtod.c rename to lib/libc/ack/fphook/strtod.c diff --git a/lib/libc/ack/math/Makefile.inc b/lib/libc/ack/math/Makefile.inc new file mode 100644 index 000000000..458e8def7 --- /dev/null +++ b/lib/libc/ack/math/Makefile.inc @@ -0,0 +1,8 @@ +# math sources +.PATH: ${.CURDIR}/ack/math + +SRCS+= \ + frexp.s \ + modf.s \ + isnan.c \ + ldexp.c diff --git a/lib/ack/math/frexp.s b/lib/libc/ack/math/frexp.s similarity index 100% rename from lib/ack/math/frexp.s rename to lib/libc/ack/math/frexp.s diff --git a/lib/ack/math/isnan.c b/lib/libc/ack/math/isnan.c similarity index 100% rename from lib/ack/math/isnan.c rename to lib/libc/ack/math/isnan.c diff --git a/lib/ack/math/ldexp.c b/lib/libc/ack/math/ldexp.c similarity index 100% rename from lib/ack/math/ldexp.c rename to lib/libc/ack/math/ldexp.c diff --git a/lib/ack/math/modf.s b/lib/libc/ack/math/modf.s similarity index 100% rename from lib/ack/math/modf.s rename to lib/libc/ack/math/modf.s diff --git a/lib/libc/ack/rts/Makefile.inc b/lib/libc/ack/rts/Makefile.inc new file mode 100644 index 000000000..725dc83ec --- /dev/null +++ b/lib/libc/ack/rts/Makefile.inc @@ -0,0 +1,4 @@ +# rts sources +.PATH: ${.CURDIR}/ack/rts + +SRCS+=setjmp.e diff --git a/lib/ack/rts/setjmp.e b/lib/libc/ack/rts/setjmp.e similarity index 100% rename from lib/ack/rts/setjmp.e rename to lib/libc/ack/rts/setjmp.e diff --git a/lib/libc/ansi/Makefile.inc b/lib/libc/ansi/Makefile.inc new file mode 100644 index 000000000..a28aad93e --- /dev/null +++ b/lib/libc/ansi/Makefile.inc @@ -0,0 +1,61 @@ +# ansi sources +.PATH: ${.CURDIR}/ansi + +SRCS+= \ + abort.c \ + abs.c \ + assert.c \ + atexit.c \ + atof.c \ + atoi.c \ + atol.c \ + bsearch.c \ + calloc.c \ + chartab.c \ + clock.c \ + difftime.c \ + div.c \ + errlist.c \ + exit.c \ + ext_comp.c \ + getenv.c \ + isalnum.c \ + isalpha.c \ + isascii.c \ + iscntrl.c \ + isdigit.c \ + isgraph.c \ + islower.c \ + isprint.c \ + ispunct.c \ + isspace.c \ + isupper.c \ + isxdigit.c \ + labs.c \ + ldiv.c \ + localeconv.c \ + malloc.c \ + mblen.c \ + mbstowcs.c \ + mbtowc.c \ + misc.c \ + qsort.c \ + raise.c \ + rand.c \ + setlocale.c \ + sigmisc.c \ + signal.c \ + strcoll.c \ + strcspn.c \ + strerror.c \ + strpbrk.c \ + strspn.c \ + strstr.c \ + strtok.c \ + strtol.c \ + strxfrm.c \ + system.c \ + tolower.c \ + toupper.c \ + wcstombs.c \ + wctomb.c diff --git a/lib/ansi/abort.c b/lib/libc/ansi/abort.c similarity index 100% rename from lib/ansi/abort.c rename to lib/libc/ansi/abort.c diff --git a/lib/ansi/abs.c b/lib/libc/ansi/abs.c similarity index 100% rename from lib/ansi/abs.c rename to lib/libc/ansi/abs.c diff --git a/lib/ansi/assert.c b/lib/libc/ansi/assert.c similarity index 100% rename from lib/ansi/assert.c rename to lib/libc/ansi/assert.c diff --git a/lib/ansi/atexit.c b/lib/libc/ansi/atexit.c similarity index 100% rename from lib/ansi/atexit.c rename to lib/libc/ansi/atexit.c diff --git a/lib/ansi/atof.c b/lib/libc/ansi/atof.c similarity index 100% rename from lib/ansi/atof.c rename to lib/libc/ansi/atof.c diff --git a/lib/ansi/atoi.c b/lib/libc/ansi/atoi.c similarity index 100% rename from lib/ansi/atoi.c rename to lib/libc/ansi/atoi.c diff --git a/lib/ansi/atol.c b/lib/libc/ansi/atol.c similarity index 100% rename from lib/ansi/atol.c rename to lib/libc/ansi/atol.c diff --git a/lib/ansi/bsearch.c b/lib/libc/ansi/bsearch.c similarity index 100% rename from lib/ansi/bsearch.c rename to lib/libc/ansi/bsearch.c diff --git a/lib/ansi/calloc.c b/lib/libc/ansi/calloc.c similarity index 100% rename from lib/ansi/calloc.c rename to lib/libc/ansi/calloc.c diff --git a/lib/ansi/chartab.c b/lib/libc/ansi/chartab.c similarity index 100% rename from lib/ansi/chartab.c rename to lib/libc/ansi/chartab.c diff --git a/lib/ansi/clock.c b/lib/libc/ansi/clock.c similarity index 100% rename from lib/ansi/clock.c rename to lib/libc/ansi/clock.c diff --git a/lib/ansi/difftime.c b/lib/libc/ansi/difftime.c similarity index 100% rename from lib/ansi/difftime.c rename to lib/libc/ansi/difftime.c diff --git a/lib/ansi/div.c b/lib/libc/ansi/div.c similarity index 100% rename from lib/ansi/div.c rename to lib/libc/ansi/div.c diff --git a/lib/ansi/errlist.c b/lib/libc/ansi/errlist.c similarity index 100% rename from lib/ansi/errlist.c rename to lib/libc/ansi/errlist.c diff --git a/lib/ansi/exit.c b/lib/libc/ansi/exit.c similarity index 100% rename from lib/ansi/exit.c rename to lib/libc/ansi/exit.c diff --git a/lib/ansi/ext_comp.c b/lib/libc/ansi/ext_comp.c similarity index 100% rename from lib/ansi/ext_comp.c rename to lib/libc/ansi/ext_comp.c diff --git a/lib/ansi/ext_fmt.h b/lib/libc/ansi/ext_fmt.h similarity index 100% rename from lib/ansi/ext_fmt.h rename to lib/libc/ansi/ext_fmt.h diff --git a/lib/ansi/getenv.c b/lib/libc/ansi/getenv.c similarity index 100% rename from lib/ansi/getenv.c rename to lib/libc/ansi/getenv.c diff --git a/lib/ansi/isalnum.c b/lib/libc/ansi/isalnum.c similarity index 100% rename from lib/ansi/isalnum.c rename to lib/libc/ansi/isalnum.c diff --git a/lib/ansi/isalpha.c b/lib/libc/ansi/isalpha.c similarity index 100% rename from lib/ansi/isalpha.c rename to lib/libc/ansi/isalpha.c diff --git a/lib/ansi/isascii.c b/lib/libc/ansi/isascii.c similarity index 100% rename from lib/ansi/isascii.c rename to lib/libc/ansi/isascii.c diff --git a/lib/ansi/iscntrl.c b/lib/libc/ansi/iscntrl.c similarity index 100% rename from lib/ansi/iscntrl.c rename to lib/libc/ansi/iscntrl.c diff --git a/lib/ansi/isdigit.c b/lib/libc/ansi/isdigit.c similarity index 100% rename from lib/ansi/isdigit.c rename to lib/libc/ansi/isdigit.c diff --git a/lib/ansi/isgraph.c b/lib/libc/ansi/isgraph.c similarity index 100% rename from lib/ansi/isgraph.c rename to lib/libc/ansi/isgraph.c diff --git a/lib/ansi/islower.c b/lib/libc/ansi/islower.c similarity index 100% rename from lib/ansi/islower.c rename to lib/libc/ansi/islower.c diff --git a/lib/ansi/isprint.c b/lib/libc/ansi/isprint.c similarity index 100% rename from lib/ansi/isprint.c rename to lib/libc/ansi/isprint.c diff --git a/lib/ansi/ispunct.c b/lib/libc/ansi/ispunct.c similarity index 100% rename from lib/ansi/ispunct.c rename to lib/libc/ansi/ispunct.c diff --git a/lib/ansi/isspace.c b/lib/libc/ansi/isspace.c similarity index 100% rename from lib/ansi/isspace.c rename to lib/libc/ansi/isspace.c diff --git a/lib/ansi/isupper.c b/lib/libc/ansi/isupper.c similarity index 100% rename from lib/ansi/isupper.c rename to lib/libc/ansi/isupper.c diff --git a/lib/ansi/isxdigit.c b/lib/libc/ansi/isxdigit.c similarity index 100% rename from lib/ansi/isxdigit.c rename to lib/libc/ansi/isxdigit.c diff --git a/lib/ansi/labs.c b/lib/libc/ansi/labs.c similarity index 100% rename from lib/ansi/labs.c rename to lib/libc/ansi/labs.c diff --git a/lib/ansi/ldiv.c b/lib/libc/ansi/ldiv.c similarity index 100% rename from lib/ansi/ldiv.c rename to lib/libc/ansi/ldiv.c diff --git a/lib/ansi/loc_time.h b/lib/libc/ansi/loc_time.h similarity index 100% rename from lib/ansi/loc_time.h rename to lib/libc/ansi/loc_time.h diff --git a/lib/ansi/localeconv.c b/lib/libc/ansi/localeconv.c similarity index 100% rename from lib/ansi/localeconv.c rename to lib/libc/ansi/localeconv.c diff --git a/lib/ansi/malloc.c b/lib/libc/ansi/malloc.c similarity index 100% rename from lib/ansi/malloc.c rename to lib/libc/ansi/malloc.c diff --git a/lib/ansi/mblen.c b/lib/libc/ansi/mblen.c similarity index 100% rename from lib/ansi/mblen.c rename to lib/libc/ansi/mblen.c diff --git a/lib/ansi/mbstowcs.c b/lib/libc/ansi/mbstowcs.c similarity index 100% rename from lib/ansi/mbstowcs.c rename to lib/libc/ansi/mbstowcs.c diff --git a/lib/ansi/mbtowc.c b/lib/libc/ansi/mbtowc.c similarity index 100% rename from lib/ansi/mbtowc.c rename to lib/libc/ansi/mbtowc.c diff --git a/lib/ansi/memchr.c b/lib/libc/ansi/memchr.c similarity index 100% rename from lib/ansi/memchr.c rename to lib/libc/ansi/memchr.c diff --git a/lib/ansi/memcmp.c b/lib/libc/ansi/memcmp.c similarity index 100% rename from lib/ansi/memcmp.c rename to lib/libc/ansi/memcmp.c diff --git a/lib/ansi/memcpy.c b/lib/libc/ansi/memcpy.c similarity index 100% rename from lib/ansi/memcpy.c rename to lib/libc/ansi/memcpy.c diff --git a/lib/ansi/memmove.c b/lib/libc/ansi/memmove.c similarity index 100% rename from lib/ansi/memmove.c rename to lib/libc/ansi/memmove.c diff --git a/lib/ansi/memset.c b/lib/libc/ansi/memset.c similarity index 100% rename from lib/ansi/memset.c rename to lib/libc/ansi/memset.c diff --git a/lib/ansi/misc.c b/lib/libc/ansi/misc.c similarity index 89% rename from lib/ansi/misc.c rename to lib/libc/ansi/misc.c index ee6c3c18a..9bb320dee 100644 --- a/lib/ansi/misc.c +++ b/lib/libc/ansi/misc.c @@ -8,32 +8,6 @@ #include #include -#if defined(__BSD4_2) - -struct timeval { - long tv_sec; /* seconds */ - long tv_usec; /* and microseconds */ -}; - -struct timezone { - int tz_minuteswest; /* minutes west of Greenwich */ - int tz_dsttime; /* type of dst correction */ -}; - -int _gettimeofday(struct timeval *tp, struct timezone *tzp); - -#elif !defined(_POSIX_SOURCE) && !defined(__USG) -#if !defined(_MINIX) /* MINIX has no ftime() */ -struct timeb { - long time; - unsigned short millitm; - short timezone; - short dstflag; -}; -void _ftime(struct timeb *bp); -#endif -#endif - #include "loc_time.h" #define RULE_LEN 120 @@ -50,13 +24,9 @@ long _timezone = 0; long _dst_off = 60 * 60; int _daylight = 0; -#if defined(__USG) || defined(_POSIX_SOURCE) - -#if defined(__USG) long timezone = 0; int daylight = 0; -#endif -#endif + static struct dsttype { char ds_type; /* Unknown, Julian, Zero-based or M */ diff --git a/lib/ansi/qsort.c b/lib/libc/ansi/qsort.c similarity index 100% rename from lib/ansi/qsort.c rename to lib/libc/ansi/qsort.c diff --git a/lib/ansi/raise.c b/lib/libc/ansi/raise.c similarity index 100% rename from lib/ansi/raise.c rename to lib/libc/ansi/raise.c diff --git a/lib/ansi/rand.c b/lib/libc/ansi/rand.c similarity index 100% rename from lib/ansi/rand.c rename to lib/libc/ansi/rand.c diff --git a/lib/ansi/setlocale.c b/lib/libc/ansi/setlocale.c similarity index 100% rename from lib/ansi/setlocale.c rename to lib/libc/ansi/setlocale.c diff --git a/lib/ansi/sigmisc.c b/lib/libc/ansi/sigmisc.c similarity index 100% rename from lib/ansi/sigmisc.c rename to lib/libc/ansi/sigmisc.c diff --git a/lib/ansi/signal.c b/lib/libc/ansi/signal.c similarity index 100% rename from lib/ansi/signal.c rename to lib/libc/ansi/signal.c diff --git a/lib/ansi/strcat.c b/lib/libc/ansi/strcat.c similarity index 100% rename from lib/ansi/strcat.c rename to lib/libc/ansi/strcat.c diff --git a/lib/ansi/strchr.c b/lib/libc/ansi/strchr.c similarity index 100% rename from lib/ansi/strchr.c rename to lib/libc/ansi/strchr.c diff --git a/lib/ansi/strcmp.c b/lib/libc/ansi/strcmp.c similarity index 100% rename from lib/ansi/strcmp.c rename to lib/libc/ansi/strcmp.c diff --git a/lib/ansi/strcoll.c b/lib/libc/ansi/strcoll.c similarity index 100% rename from lib/ansi/strcoll.c rename to lib/libc/ansi/strcoll.c diff --git a/lib/ansi/strcpy.c b/lib/libc/ansi/strcpy.c similarity index 100% rename from lib/ansi/strcpy.c rename to lib/libc/ansi/strcpy.c diff --git a/lib/ansi/strcspn.c b/lib/libc/ansi/strcspn.c similarity index 100% rename from lib/ansi/strcspn.c rename to lib/libc/ansi/strcspn.c diff --git a/lib/ansi/strerror.c b/lib/libc/ansi/strerror.c similarity index 100% rename from lib/ansi/strerror.c rename to lib/libc/ansi/strerror.c diff --git a/lib/ansi/strlen.c b/lib/libc/ansi/strlen.c similarity index 100% rename from lib/ansi/strlen.c rename to lib/libc/ansi/strlen.c diff --git a/lib/ansi/strncat.c b/lib/libc/ansi/strncat.c similarity index 100% rename from lib/ansi/strncat.c rename to lib/libc/ansi/strncat.c diff --git a/lib/ansi/strncmp.c b/lib/libc/ansi/strncmp.c similarity index 100% rename from lib/ansi/strncmp.c rename to lib/libc/ansi/strncmp.c diff --git a/lib/ansi/strncpy.c b/lib/libc/ansi/strncpy.c similarity index 100% rename from lib/ansi/strncpy.c rename to lib/libc/ansi/strncpy.c diff --git a/lib/ansi/strpbrk.c b/lib/libc/ansi/strpbrk.c similarity index 100% rename from lib/ansi/strpbrk.c rename to lib/libc/ansi/strpbrk.c diff --git a/lib/ansi/strrchr.c b/lib/libc/ansi/strrchr.c similarity index 100% rename from lib/ansi/strrchr.c rename to lib/libc/ansi/strrchr.c diff --git a/lib/ansi/strspn.c b/lib/libc/ansi/strspn.c similarity index 100% rename from lib/ansi/strspn.c rename to lib/libc/ansi/strspn.c diff --git a/lib/ansi/strstr.c b/lib/libc/ansi/strstr.c similarity index 100% rename from lib/ansi/strstr.c rename to lib/libc/ansi/strstr.c diff --git a/lib/ansi/strtok.c b/lib/libc/ansi/strtok.c similarity index 100% rename from lib/ansi/strtok.c rename to lib/libc/ansi/strtok.c diff --git a/lib/ansi/strtol.c b/lib/libc/ansi/strtol.c similarity index 100% rename from lib/ansi/strtol.c rename to lib/libc/ansi/strtol.c diff --git a/lib/ansi/strxfrm.c b/lib/libc/ansi/strxfrm.c similarity index 100% rename from lib/ansi/strxfrm.c rename to lib/libc/ansi/strxfrm.c diff --git a/lib/ansi/system.c b/lib/libc/ansi/system.c similarity index 100% rename from lib/ansi/system.c rename to lib/libc/ansi/system.c diff --git a/lib/ansi/tolower.c b/lib/libc/ansi/tolower.c similarity index 100% rename from lib/ansi/tolower.c rename to lib/libc/ansi/tolower.c diff --git a/lib/ansi/toupper.c b/lib/libc/ansi/toupper.c similarity index 100% rename from lib/ansi/toupper.c rename to lib/libc/ansi/toupper.c diff --git a/lib/ansi/wcstombs.c b/lib/libc/ansi/wcstombs.c similarity index 100% rename from lib/ansi/wcstombs.c rename to lib/libc/ansi/wcstombs.c diff --git a/lib/ansi/wctomb.c b/lib/libc/ansi/wctomb.c similarity index 100% rename from lib/ansi/wctomb.c rename to lib/libc/ansi/wctomb.c diff --git a/lib/i386/int64/Makefile.in b/lib/libc/arch/i386/int64/Makefile.inc similarity index 50% rename from lib/i386/int64/Makefile.in rename to lib/libc/arch/i386/int64/Makefile.inc index 0882e125b..259af772c 100644 --- a/lib/i386/int64/Makefile.in +++ b/lib/libc/arch/i386/int64/Makefile.inc @@ -1,10 +1,7 @@ -# Makefile for lib/i386/int64. +# int64 sources +.PATH: ${.CURDIR}/arch/${ARCH}/int64 -CFLAGS="-O -D_MINIX -D_POSIX_SOURCE" - -LIBRARIES=libc - -libc_FILES=" \ +SRCS+= \ add64.s \ add64u.s \ cmp64.s \ @@ -16,6 +13,4 @@ libc_FILES=" \ make64.s \ mul64u.s \ sub64.s \ - sub64u.s" - -TYPE=both + sub64u.s diff --git a/lib/i386/int64/add64.s b/lib/libc/arch/i386/int64/add64.s similarity index 100% rename from lib/i386/int64/add64.s rename to lib/libc/arch/i386/int64/add64.s diff --git a/lib/i386/int64/add64u.s b/lib/libc/arch/i386/int64/add64u.s similarity index 100% rename from lib/i386/int64/add64u.s rename to lib/libc/arch/i386/int64/add64u.s diff --git a/lib/i386/int64/cmp64.s b/lib/libc/arch/i386/int64/cmp64.s similarity index 100% rename from lib/i386/int64/cmp64.s rename to lib/libc/arch/i386/int64/cmp64.s diff --git a/lib/i386/int64/cv64u.s b/lib/libc/arch/i386/int64/cv64u.s similarity index 100% rename from lib/i386/int64/cv64u.s rename to lib/libc/arch/i386/int64/cv64u.s diff --git a/lib/i386/int64/cvu64.s b/lib/libc/arch/i386/int64/cvu64.s similarity index 100% rename from lib/i386/int64/cvu64.s rename to lib/libc/arch/i386/int64/cvu64.s diff --git a/lib/i386/int64/diff64.s b/lib/libc/arch/i386/int64/diff64.s similarity index 100% rename from lib/i386/int64/diff64.s rename to lib/libc/arch/i386/int64/diff64.s diff --git a/lib/i386/int64/div64u.s b/lib/libc/arch/i386/int64/div64u.s similarity index 100% rename from lib/i386/int64/div64u.s rename to lib/libc/arch/i386/int64/div64u.s diff --git a/lib/i386/int64/ex64.s b/lib/libc/arch/i386/int64/ex64.s similarity index 100% rename from lib/i386/int64/ex64.s rename to lib/libc/arch/i386/int64/ex64.s diff --git a/lib/i386/int64/make64.s b/lib/libc/arch/i386/int64/make64.s similarity index 100% rename from lib/i386/int64/make64.s rename to lib/libc/arch/i386/int64/make64.s diff --git a/lib/i386/int64/mul64u.s b/lib/libc/arch/i386/int64/mul64u.s similarity index 100% rename from lib/i386/int64/mul64u.s rename to lib/libc/arch/i386/int64/mul64u.s diff --git a/lib/i386/int64/sub64.s b/lib/libc/arch/i386/int64/sub64.s similarity index 100% rename from lib/i386/int64/sub64.s rename to lib/libc/arch/i386/int64/sub64.s diff --git a/lib/i386/int64/sub64u.s b/lib/libc/arch/i386/int64/sub64u.s similarity index 100% rename from lib/i386/int64/sub64u.s rename to lib/libc/arch/i386/int64/sub64u.s diff --git a/lib/libc/arch/i386/math/Makefile.inc b/lib/libc/arch/i386/math/Makefile.inc new file mode 100644 index 000000000..ad0624576 --- /dev/null +++ b/lib/libc/arch/i386/math/Makefile.inc @@ -0,0 +1,12 @@ +# math sources +.PATH: ${.CURDIR}/arch/${ARCH}/math + +SRCS+= \ + arch_compare.c \ + arch_round.c \ + fpu_cw.s \ + fpu_sw.s \ + fpu_round.s \ + fegetround.c \ + feholdexcept.c \ + fesetround.c diff --git a/lib/i386/math/arch_compare.c b/lib/libc/arch/i386/math/arch_compare.c similarity index 100% rename from lib/i386/math/arch_compare.c rename to lib/libc/arch/i386/math/arch_compare.c diff --git a/lib/i386/math/arch_round.c b/lib/libc/arch/i386/math/arch_round.c similarity index 100% rename from lib/i386/math/arch_round.c rename to lib/libc/arch/i386/math/arch_round.c diff --git a/lib/i386/math/fegetround.c b/lib/libc/arch/i386/math/fegetround.c similarity index 100% rename from lib/i386/math/fegetround.c rename to lib/libc/arch/i386/math/fegetround.c diff --git a/lib/i386/math/feholdexcept.c b/lib/libc/arch/i386/math/feholdexcept.c similarity index 100% rename from lib/i386/math/feholdexcept.c rename to lib/libc/arch/i386/math/feholdexcept.c diff --git a/lib/i386/math/fesetround.c b/lib/libc/arch/i386/math/fesetround.c similarity index 100% rename from lib/i386/math/fesetround.c rename to lib/libc/arch/i386/math/fesetround.c diff --git a/lib/i386/math/fpu_cw.h b/lib/libc/arch/i386/math/fpu_cw.h similarity index 100% rename from lib/i386/math/fpu_cw.h rename to lib/libc/arch/i386/math/fpu_cw.h diff --git a/lib/i386/math/fpu_cw.s b/lib/libc/arch/i386/math/fpu_cw.s similarity index 100% rename from lib/i386/math/fpu_cw.s rename to lib/libc/arch/i386/math/fpu_cw.s diff --git a/lib/i386/math/fpu_round.h b/lib/libc/arch/i386/math/fpu_round.h similarity index 100% rename from lib/i386/math/fpu_round.h rename to lib/libc/arch/i386/math/fpu_round.h diff --git a/lib/i386/math/fpu_round.s b/lib/libc/arch/i386/math/fpu_round.s similarity index 100% rename from lib/i386/math/fpu_round.s rename to lib/libc/arch/i386/math/fpu_round.s diff --git a/lib/i386/math/fpu_sw.h b/lib/libc/arch/i386/math/fpu_sw.h similarity index 100% rename from lib/i386/math/fpu_sw.h rename to lib/libc/arch/i386/math/fpu_sw.h diff --git a/lib/i386/math/fpu_sw.s b/lib/libc/arch/i386/math/fpu_sw.s similarity index 100% rename from lib/i386/math/fpu_sw.s rename to lib/libc/arch/i386/math/fpu_sw.s diff --git a/lib/i386/misc/Makefile.in b/lib/libc/arch/i386/misc/Makefile.inc similarity index 66% rename from lib/i386/misc/Makefile.in rename to lib/libc/arch/i386/misc/Makefile.inc index e76269114..8530d8017 100644 --- a/lib/i386/misc/Makefile.in +++ b/lib/libc/arch/i386/misc/Makefile.inc @@ -1,10 +1,7 @@ -# Makefile for lib/i386/misc. +# misc sources +.PATH: ${.CURDIR}/arch/${ARCH}/misc -CFLAGS="-O -D_MINIX -D_POSIX_SOURCE" - -LIBRARIES=libc - -libc_FILES=" \ +SRCS+= \ _cpuid.s \ _cpufeature.c \ alloca.s \ @@ -23,6 +20,4 @@ libc_FILES=" \ io_outsl.s \ io_outsw.s \ io_outw.s \ - oneC_sum.s" - -TYPE=both + oneC_sum.s diff --git a/lib/i386/misc/_cpufeature.c b/lib/libc/arch/i386/misc/_cpufeature.c similarity index 100% rename from lib/i386/misc/_cpufeature.c rename to lib/libc/arch/i386/misc/_cpufeature.c diff --git a/lib/i386/misc/_cpuid.s b/lib/libc/arch/i386/misc/_cpuid.s similarity index 100% rename from lib/i386/misc/_cpuid.s rename to lib/libc/arch/i386/misc/_cpuid.s diff --git a/lib/i386/misc/alloca.s b/lib/libc/arch/i386/misc/alloca.s similarity index 100% rename from lib/i386/misc/alloca.s rename to lib/libc/arch/i386/misc/alloca.s diff --git a/lib/i386/misc/get_bp.s b/lib/libc/arch/i386/misc/get_bp.s similarity index 100% rename from lib/i386/misc/get_bp.s rename to lib/libc/arch/i386/misc/get_bp.s diff --git a/lib/i386/misc/getprocessor.s b/lib/libc/arch/i386/misc/getprocessor.s similarity index 100% rename from lib/i386/misc/getprocessor.s rename to lib/libc/arch/i386/misc/getprocessor.s diff --git a/lib/i386/misc/io_inb.s b/lib/libc/arch/i386/misc/io_inb.s similarity index 100% rename from lib/i386/misc/io_inb.s rename to lib/libc/arch/i386/misc/io_inb.s diff --git a/lib/i386/misc/io_inl.s b/lib/libc/arch/i386/misc/io_inl.s similarity index 100% rename from lib/i386/misc/io_inl.s rename to lib/libc/arch/i386/misc/io_inl.s diff --git a/lib/i386/misc/io_insb.s b/lib/libc/arch/i386/misc/io_insb.s similarity index 100% rename from lib/i386/misc/io_insb.s rename to lib/libc/arch/i386/misc/io_insb.s diff --git a/lib/i386/misc/io_insl.s b/lib/libc/arch/i386/misc/io_insl.s similarity index 100% rename from lib/i386/misc/io_insl.s rename to lib/libc/arch/i386/misc/io_insl.s diff --git a/lib/i386/misc/io_insw.s b/lib/libc/arch/i386/misc/io_insw.s similarity index 100% rename from lib/i386/misc/io_insw.s rename to lib/libc/arch/i386/misc/io_insw.s diff --git a/lib/i386/misc/io_intr.s b/lib/libc/arch/i386/misc/io_intr.s similarity index 100% rename from lib/i386/misc/io_intr.s rename to lib/libc/arch/i386/misc/io_intr.s diff --git a/lib/i386/misc/io_inw.s b/lib/libc/arch/i386/misc/io_inw.s similarity index 100% rename from lib/i386/misc/io_inw.s rename to lib/libc/arch/i386/misc/io_inw.s diff --git a/lib/i386/misc/io_outb.s b/lib/libc/arch/i386/misc/io_outb.s similarity index 100% rename from lib/i386/misc/io_outb.s rename to lib/libc/arch/i386/misc/io_outb.s diff --git a/lib/i386/misc/io_outl.s b/lib/libc/arch/i386/misc/io_outl.s similarity index 100% rename from lib/i386/misc/io_outl.s rename to lib/libc/arch/i386/misc/io_outl.s diff --git a/lib/i386/misc/io_outsb.s b/lib/libc/arch/i386/misc/io_outsb.s similarity index 100% rename from lib/i386/misc/io_outsb.s rename to lib/libc/arch/i386/misc/io_outsb.s diff --git a/lib/i386/misc/io_outsl.s b/lib/libc/arch/i386/misc/io_outsl.s similarity index 100% rename from lib/i386/misc/io_outsl.s rename to lib/libc/arch/i386/misc/io_outsl.s diff --git a/lib/i386/misc/io_outsw.s b/lib/libc/arch/i386/misc/io_outsw.s similarity index 100% rename from lib/i386/misc/io_outsw.s rename to lib/libc/arch/i386/misc/io_outsw.s diff --git a/lib/i386/misc/io_outw.s b/lib/libc/arch/i386/misc/io_outw.s similarity index 100% rename from lib/i386/misc/io_outw.s rename to lib/libc/arch/i386/misc/io_outw.s diff --git a/lib/i386/misc/oneC_sum.s b/lib/libc/arch/i386/misc/oneC_sum.s similarity index 100% rename from lib/i386/misc/oneC_sum.s rename to lib/libc/arch/i386/misc/oneC_sum.s diff --git a/lib/libc/arch/i386/rts/Makefile.inc b/lib/libc/arch/i386/rts/Makefile.inc new file mode 100644 index 000000000..17610804b --- /dev/null +++ b/lib/libc/arch/i386/rts/Makefile.inc @@ -0,0 +1,8 @@ +# rts sources +.PATH: ${.CURDIR}/arch/${ARCH}/rts + +SRCS+= \ + __sigreturn.s \ + _ipc.s \ + _senda.s \ + brksize.s diff --git a/lib/i386/rts/__sigreturn.s b/lib/libc/arch/i386/rts/__sigreturn.s similarity index 100% rename from lib/i386/rts/__sigreturn.s rename to lib/libc/arch/i386/rts/__sigreturn.s diff --git a/lib/i386/rts/_ipc.s b/lib/libc/arch/i386/rts/_ipc.s similarity index 100% rename from lib/i386/rts/_ipc.s rename to lib/libc/arch/i386/rts/_ipc.s diff --git a/lib/i386/rts/_senda.s b/lib/libc/arch/i386/rts/_senda.s similarity index 100% rename from lib/i386/rts/_senda.s rename to lib/libc/arch/i386/rts/_senda.s diff --git a/lib/i386/rts/brksize.s b/lib/libc/arch/i386/rts/brksize.s similarity index 100% rename from lib/i386/rts/brksize.s rename to lib/libc/arch/i386/rts/brksize.s diff --git a/lib/i386/string/Makefile.in b/lib/libc/arch/i386/string/Makefile.inc similarity index 77% rename from lib/i386/string/Makefile.in rename to lib/libc/arch/i386/string/Makefile.inc index e7e26c883..8cc3e077f 100644 --- a/lib/i386/string/Makefile.in +++ b/lib/libc/arch/i386/string/Makefile.inc @@ -1,8 +1,7 @@ -# Makefile for lib/i386/string. +# string sources +.PATH: ${.CURDIR}/arch/${ARCH}/string -LIBRARIES=libc - -libc_FILES=" \ +SRCS+= \ _memmove.s \ _strncat.s \ _strncmp.s \ @@ -27,6 +26,4 @@ libc_FILES=" \ strncmp.s \ strncpy.s \ strnlen.s \ - strrchr.s" - -TYPE=both + strrchr.s diff --git a/lib/i386/string/README b/lib/libc/arch/i386/string/README similarity index 100% rename from lib/i386/string/README rename to lib/libc/arch/i386/string/README diff --git a/lib/i386/string/_memmove.s b/lib/libc/arch/i386/string/_memmove.s similarity index 100% rename from lib/i386/string/_memmove.s rename to lib/libc/arch/i386/string/_memmove.s diff --git a/lib/i386/string/_strncat.s b/lib/libc/arch/i386/string/_strncat.s similarity index 100% rename from lib/i386/string/_strncat.s rename to lib/libc/arch/i386/string/_strncat.s diff --git a/lib/i386/string/_strncmp.s b/lib/libc/arch/i386/string/_strncmp.s similarity index 100% rename from lib/i386/string/_strncmp.s rename to lib/libc/arch/i386/string/_strncmp.s diff --git a/lib/i386/string/_strncpy.s b/lib/libc/arch/i386/string/_strncpy.s similarity index 100% rename from lib/i386/string/_strncpy.s rename to lib/libc/arch/i386/string/_strncpy.s diff --git a/lib/i386/string/_strnlen.s b/lib/libc/arch/i386/string/_strnlen.s similarity index 100% rename from lib/i386/string/_strnlen.s rename to lib/libc/arch/i386/string/_strnlen.s diff --git a/lib/i386/string/bcmp.s b/lib/libc/arch/i386/string/bcmp.s similarity index 100% rename from lib/i386/string/bcmp.s rename to lib/libc/arch/i386/string/bcmp.s diff --git a/lib/i386/string/bcopy.s b/lib/libc/arch/i386/string/bcopy.s similarity index 100% rename from lib/i386/string/bcopy.s rename to lib/libc/arch/i386/string/bcopy.s diff --git a/lib/i386/string/bzero.s b/lib/libc/arch/i386/string/bzero.s similarity index 100% rename from lib/i386/string/bzero.s rename to lib/libc/arch/i386/string/bzero.s diff --git a/lib/i386/string/index.s b/lib/libc/arch/i386/string/index.s similarity index 100% rename from lib/i386/string/index.s rename to lib/libc/arch/i386/string/index.s diff --git a/lib/i386/string/memchr.s b/lib/libc/arch/i386/string/memchr.s similarity index 100% rename from lib/i386/string/memchr.s rename to lib/libc/arch/i386/string/memchr.s diff --git a/lib/i386/string/memcmp.s b/lib/libc/arch/i386/string/memcmp.s similarity index 100% rename from lib/i386/string/memcmp.s rename to lib/libc/arch/i386/string/memcmp.s diff --git a/lib/i386/string/memcpy.s b/lib/libc/arch/i386/string/memcpy.s similarity index 100% rename from lib/i386/string/memcpy.s rename to lib/libc/arch/i386/string/memcpy.s diff --git a/lib/i386/string/memmove.s b/lib/libc/arch/i386/string/memmove.s similarity index 100% rename from lib/i386/string/memmove.s rename to lib/libc/arch/i386/string/memmove.s diff --git a/lib/i386/string/memset.s b/lib/libc/arch/i386/string/memset.s similarity index 100% rename from lib/i386/string/memset.s rename to lib/libc/arch/i386/string/memset.s diff --git a/lib/i386/string/rindex.s b/lib/libc/arch/i386/string/rindex.s similarity index 100% rename from lib/i386/string/rindex.s rename to lib/libc/arch/i386/string/rindex.s diff --git a/lib/i386/string/strcat.s b/lib/libc/arch/i386/string/strcat.s similarity index 100% rename from lib/i386/string/strcat.s rename to lib/libc/arch/i386/string/strcat.s diff --git a/lib/i386/string/strchr.s b/lib/libc/arch/i386/string/strchr.s similarity index 100% rename from lib/i386/string/strchr.s rename to lib/libc/arch/i386/string/strchr.s diff --git a/lib/i386/string/strcmp.s b/lib/libc/arch/i386/string/strcmp.s similarity index 100% rename from lib/i386/string/strcmp.s rename to lib/libc/arch/i386/string/strcmp.s diff --git a/lib/i386/string/strcpy.s b/lib/libc/arch/i386/string/strcpy.s similarity index 100% rename from lib/i386/string/strcpy.s rename to lib/libc/arch/i386/string/strcpy.s diff --git a/lib/i386/string/strlen.s b/lib/libc/arch/i386/string/strlen.s similarity index 100% rename from lib/i386/string/strlen.s rename to lib/libc/arch/i386/string/strlen.s diff --git a/lib/i386/string/strncat.s b/lib/libc/arch/i386/string/strncat.s similarity index 100% rename from lib/i386/string/strncat.s rename to lib/libc/arch/i386/string/strncat.s diff --git a/lib/i386/string/strncmp.s b/lib/libc/arch/i386/string/strncmp.s similarity index 100% rename from lib/i386/string/strncmp.s rename to lib/libc/arch/i386/string/strncmp.s diff --git a/lib/i386/string/strncpy.s b/lib/libc/arch/i386/string/strncpy.s similarity index 100% rename from lib/i386/string/strncpy.s rename to lib/libc/arch/i386/string/strncpy.s diff --git a/lib/i386/string/strnlen.s b/lib/libc/arch/i386/string/strnlen.s similarity index 100% rename from lib/i386/string/strnlen.s rename to lib/libc/arch/i386/string/strnlen.s diff --git a/lib/i386/string/strrchr.s b/lib/libc/arch/i386/string/strrchr.s similarity index 100% rename from lib/i386/string/strrchr.s rename to lib/libc/arch/i386/string/strrchr.s diff --git a/lib/libc/gnu/arch/i386/rts/Makefile.inc b/lib/libc/gnu/arch/i386/rts/Makefile.inc new file mode 100644 index 000000000..b2a9de0e3 --- /dev/null +++ b/lib/libc/gnu/arch/i386/rts/Makefile.inc @@ -0,0 +1,6 @@ +# rts sources +.PATH: ${.CURDIR}/gnu/arch/${ARCH}/rts + +SRCS+= \ + __setjmp.gs \ + longjmp.gs diff --git a/lib/gnu/rts/__setjmp.gs b/lib/libc/gnu/arch/i386/rts/__setjmp.gs similarity index 100% rename from lib/gnu/rts/__setjmp.gs rename to lib/libc/gnu/arch/i386/rts/__setjmp.gs diff --git a/lib/gnu/rts/longjmp.gs b/lib/libc/gnu/arch/i386/rts/longjmp.gs similarity index 100% rename from lib/gnu/rts/longjmp.gs rename to lib/libc/gnu/arch/i386/rts/longjmp.gs diff --git a/lib/libc/gnu/ieee_float/Makefile.inc b/lib/libc/gnu/ieee_float/Makefile.inc new file mode 100644 index 000000000..e9865bd36 --- /dev/null +++ b/lib/libc/gnu/ieee_float/Makefile.inc @@ -0,0 +1,12 @@ +# ieee_float sources +.PATH: ${.CURDIR}/gnu/ieee_float + +CPPFLAGS.fphook.c=-I${.CURDIR}/stdio + +SRCS+= \ + frexp.c \ + isinf.c \ + isnan.c \ + ldexp.c \ + modf.c \ + fphook.c diff --git a/lib/fphook/fphook.c b/lib/libc/gnu/ieee_float/fphook.c similarity index 99% rename from lib/fphook/fphook.c rename to lib/libc/gnu/ieee_float/fphook.c index 61730d609..9f8c084ff 100644 --- a/lib/fphook/fphook.c +++ b/lib/libc/gnu/ieee_float/fphook.c @@ -6,7 +6,7 @@ #ifndef NOFLOAT #include #include -#include "../stdio/loc_incl.h" +#include "loc_incl.h" int _fp_hook = 1; static char * diff --git a/lib/gnu/ieee_float/frexp.c b/lib/libc/gnu/ieee_float/frexp.c similarity index 100% rename from lib/gnu/ieee_float/frexp.c rename to lib/libc/gnu/ieee_float/frexp.c diff --git a/lib/gnu/ieee_float/ieee_float.h b/lib/libc/gnu/ieee_float/ieee_float.h similarity index 100% rename from lib/gnu/ieee_float/ieee_float.h rename to lib/libc/gnu/ieee_float/ieee_float.h diff --git a/lib/gnu/ieee_float/isinf.c b/lib/libc/gnu/ieee_float/isinf.c similarity index 100% rename from lib/gnu/ieee_float/isinf.c rename to lib/libc/gnu/ieee_float/isinf.c diff --git a/lib/gnu/ieee_float/isnan.c b/lib/libc/gnu/ieee_float/isnan.c similarity index 100% rename from lib/gnu/ieee_float/isnan.c rename to lib/libc/gnu/ieee_float/isnan.c diff --git a/lib/gnu/ieee_float/ldexp.c b/lib/libc/gnu/ieee_float/ldexp.c similarity index 100% rename from lib/gnu/ieee_float/ldexp.c rename to lib/libc/gnu/ieee_float/ldexp.c diff --git a/lib/gnu/ieee_float/modf.c b/lib/libc/gnu/ieee_float/modf.c similarity index 100% rename from lib/gnu/ieee_float/modf.c rename to lib/libc/gnu/ieee_float/modf.c diff --git a/lib/ip/Makefile.in b/lib/libc/ip/Makefile.inc similarity index 79% rename from lib/ip/Makefile.in rename to lib/libc/ip/Makefile.inc index fdf3a18b4..e46f2c144 100644 --- a/lib/ip/Makefile.in +++ b/lib/libc/ip/Makefile.inc @@ -1,12 +1,7 @@ -# Makefile for lib/ip. -# -# Note: The oneC_sum.c file is not used if there is an assembly equivalent. +# ip sources +.PATH: ${.CURDIR}/ip -CFLAGS="-O -D_MINIX -D_POSIX_SOURCE -I. -DNDEBUG" - -LIBRARIES=libc - -libc_FILES=" \ +SRCS+= \ accept.c \ addrinfo.c \ bind.c \ @@ -61,6 +56,4 @@ libc_FILES=" \ setsockopt.c \ shutdown.c \ socket.c \ - strcasecmp.c" - -TYPE=both + strcasecmp.c diff --git a/lib/ip/accept.c b/lib/libc/ip/accept.c similarity index 100% rename from lib/ip/accept.c rename to lib/libc/ip/accept.c diff --git a/lib/ip/addrinfo.c b/lib/libc/ip/addrinfo.c similarity index 100% rename from lib/ip/addrinfo.c rename to lib/libc/ip/addrinfo.c diff --git a/lib/ip/bind.c b/lib/libc/ip/bind.c similarity index 100% rename from lib/ip/bind.c rename to lib/libc/ip/bind.c diff --git a/lib/ip/connect.c b/lib/libc/ip/connect.c similarity index 100% rename from lib/ip/connect.c rename to lib/libc/ip/connect.c diff --git a/lib/ip/dhcp_gettag.c b/lib/libc/ip/dhcp_gettag.c similarity index 100% rename from lib/ip/dhcp_gettag.c rename to lib/libc/ip/dhcp_gettag.c diff --git a/lib/ip/dhcp_settag.c b/lib/libc/ip/dhcp_settag.c similarity index 100% rename from lib/ip/dhcp_settag.c rename to lib/libc/ip/dhcp_settag.c diff --git a/lib/ip/domainname.c b/lib/libc/ip/domainname.c similarity index 100% rename from lib/ip/domainname.c rename to lib/libc/ip/domainname.c diff --git a/lib/ip/ether.h b/lib/libc/ip/ether.h similarity index 100% rename from lib/ip/ether.h rename to lib/libc/ip/ether.h diff --git a/lib/ip/ether_line.c b/lib/libc/ip/ether_line.c similarity index 100% rename from lib/ip/ether_line.c rename to lib/libc/ip/ether_line.c diff --git a/lib/ip/ethera2n.c b/lib/libc/ip/ethera2n.c similarity index 100% rename from lib/ip/ethera2n.c rename to lib/libc/ip/ethera2n.c diff --git a/lib/ip/ethere2a.c b/lib/libc/ip/ethere2a.c similarity index 100% rename from lib/ip/ethere2a.c rename to lib/libc/ip/ethere2a.c diff --git a/lib/ip/etherh2n.c b/lib/libc/ip/etherh2n.c similarity index 100% rename from lib/ip/etherh2n.c rename to lib/libc/ip/etherh2n.c diff --git a/lib/ip/ethern2h.c b/lib/libc/ip/ethern2h.c similarity index 100% rename from lib/ip/ethern2h.c rename to lib/libc/ip/ethern2h.c diff --git a/lib/ip/gai_strerror.c b/lib/libc/ip/gai_strerror.c similarity index 100% rename from lib/ip/gai_strerror.c rename to lib/libc/ip/gai_strerror.c diff --git a/lib/ip/getdomain.c b/lib/libc/ip/getdomain.c similarity index 100% rename from lib/ip/getdomain.c rename to lib/libc/ip/getdomain.c diff --git a/lib/ip/gethnmadr.c b/lib/libc/ip/gethnmadr.c similarity index 100% rename from lib/ip/gethnmadr.c rename to lib/libc/ip/gethnmadr.c diff --git a/lib/ip/gethostent.c b/lib/libc/ip/gethostent.c similarity index 100% rename from lib/ip/gethostent.c rename to lib/libc/ip/gethostent.c diff --git a/lib/ip/gethostname.c b/lib/libc/ip/gethostname.c similarity index 100% rename from lib/ip/gethostname.c rename to lib/libc/ip/gethostname.c diff --git a/lib/ip/getifaddrs.c b/lib/libc/ip/getifaddrs.c similarity index 100% rename from lib/ip/getifaddrs.c rename to lib/libc/ip/getifaddrs.c diff --git a/lib/ip/getnetbyaddr.c b/lib/libc/ip/getnetbyaddr.c similarity index 100% rename from lib/ip/getnetbyaddr.c rename to lib/libc/ip/getnetbyaddr.c diff --git a/lib/ip/getnetbyname.c b/lib/libc/ip/getnetbyname.c similarity index 100% rename from lib/ip/getnetbyname.c rename to lib/libc/ip/getnetbyname.c diff --git a/lib/ip/getnetent.c b/lib/libc/ip/getnetent.c similarity index 100% rename from lib/ip/getnetent.c rename to lib/libc/ip/getnetent.c diff --git a/lib/ip/getpeername.c b/lib/libc/ip/getpeername.c similarity index 100% rename from lib/ip/getpeername.c rename to lib/libc/ip/getpeername.c diff --git a/lib/ip/getproto.c b/lib/libc/ip/getproto.c similarity index 100% rename from lib/ip/getproto.c rename to lib/libc/ip/getproto.c diff --git a/lib/ip/getprotoent.c b/lib/libc/ip/getprotoent.c similarity index 100% rename from lib/ip/getprotoent.c rename to lib/libc/ip/getprotoent.c diff --git a/lib/ip/getprotoname.c b/lib/libc/ip/getprotoname.c similarity index 100% rename from lib/ip/getprotoname.c rename to lib/libc/ip/getprotoname.c diff --git a/lib/ip/getservent.c b/lib/libc/ip/getservent.c similarity index 100% rename from lib/ip/getservent.c rename to lib/libc/ip/getservent.c diff --git a/lib/ip/getsockname.c b/lib/libc/ip/getsockname.c similarity index 100% rename from lib/ip/getsockname.c rename to lib/libc/ip/getsockname.c diff --git a/lib/ip/getsockopt.c b/lib/libc/ip/getsockopt.c similarity index 100% rename from lib/ip/getsockopt.c rename to lib/libc/ip/getsockopt.c diff --git a/lib/ip/getsrvbyname.c b/lib/libc/ip/getsrvbyname.c similarity index 100% rename from lib/ip/getsrvbyname.c rename to lib/libc/ip/getsrvbyname.c diff --git a/lib/ip/getsrvbyport.c b/lib/libc/ip/getsrvbyport.c similarity index 100% rename from lib/ip/getsrvbyport.c rename to lib/libc/ip/getsrvbyport.c diff --git a/lib/ip/hton.c b/lib/libc/ip/hton.c similarity index 100% rename from lib/ip/hton.c rename to lib/libc/ip/hton.c diff --git a/lib/ip/inet_addr.c b/lib/libc/ip/inet_addr.c similarity index 100% rename from lib/ip/inet_addr.c rename to lib/libc/ip/inet_addr.c diff --git a/lib/ip/inet_network.c b/lib/libc/ip/inet_network.c similarity index 100% rename from lib/ip/inet_network.c rename to lib/libc/ip/inet_network.c diff --git a/lib/ip/inet_ntoa.c b/lib/libc/ip/inet_ntoa.c similarity index 100% rename from lib/ip/inet_ntoa.c rename to lib/libc/ip/inet_ntoa.c diff --git a/lib/ip/listen.c b/lib/libc/ip/listen.c similarity index 100% rename from lib/ip/listen.c rename to lib/libc/ip/listen.c diff --git a/lib/ip/memcspn.c b/lib/libc/ip/memcspn.c similarity index 100% rename from lib/ip/memcspn.c rename to lib/libc/ip/memcspn.c diff --git a/lib/ip/nameinfo.c b/lib/libc/ip/nameinfo.c similarity index 100% rename from lib/ip/nameinfo.c rename to lib/libc/ip/nameinfo.c diff --git a/lib/ip/oneC_sum.c b/lib/libc/ip/oneC_sum.c similarity index 100% rename from lib/ip/oneC_sum.c rename to lib/libc/ip/oneC_sum.c diff --git a/lib/ip/rcmd.c b/lib/libc/ip/rcmd.c similarity index 100% rename from lib/ip/rcmd.c rename to lib/libc/ip/rcmd.c diff --git a/lib/ip/recv.c b/lib/libc/ip/recv.c similarity index 100% rename from lib/ip/recv.c rename to lib/libc/ip/recv.c diff --git a/lib/ip/recvfrom.c b/lib/libc/ip/recvfrom.c similarity index 100% rename from lib/ip/recvfrom.c rename to lib/libc/ip/recvfrom.c diff --git a/lib/ip/res_comp.c b/lib/libc/ip/res_comp.c similarity index 100% rename from lib/ip/res_comp.c rename to lib/libc/ip/res_comp.c diff --git a/lib/ip/res_init.c b/lib/libc/ip/res_init.c similarity index 100% rename from lib/ip/res_init.c rename to lib/libc/ip/res_init.c diff --git a/lib/ip/res_mkquery.c b/lib/libc/ip/res_mkquery.c similarity index 100% rename from lib/ip/res_mkquery.c rename to lib/libc/ip/res_mkquery.c diff --git a/lib/ip/res_query.c b/lib/libc/ip/res_query.c similarity index 100% rename from lib/ip/res_query.c rename to lib/libc/ip/res_query.c diff --git a/lib/ip/res_send.c b/lib/libc/ip/res_send.c similarity index 100% rename from lib/ip/res_send.c rename to lib/libc/ip/res_send.c diff --git a/lib/ip/ruserok.c b/lib/libc/ip/ruserok.c similarity index 100% rename from lib/ip/ruserok.c rename to lib/libc/ip/ruserok.c diff --git a/lib/ip/send.c b/lib/libc/ip/send.c similarity index 100% rename from lib/ip/send.c rename to lib/libc/ip/send.c diff --git a/lib/ip/sendto.c b/lib/libc/ip/sendto.c similarity index 100% rename from lib/ip/sendto.c rename to lib/libc/ip/sendto.c diff --git a/lib/ip/servxcheck.c b/lib/libc/ip/servxcheck.c similarity index 100% rename from lib/ip/servxcheck.c rename to lib/libc/ip/servxcheck.c diff --git a/lib/ip/sethostent.c b/lib/libc/ip/sethostent.c similarity index 100% rename from lib/ip/sethostent.c rename to lib/libc/ip/sethostent.c diff --git a/lib/ip/setsockopt.c b/lib/libc/ip/setsockopt.c similarity index 100% rename from lib/ip/setsockopt.c rename to lib/libc/ip/setsockopt.c diff --git a/lib/ip/shutdown.c b/lib/libc/ip/shutdown.c similarity index 100% rename from lib/ip/shutdown.c rename to lib/libc/ip/shutdown.c diff --git a/lib/ip/socket.c b/lib/libc/ip/socket.c similarity index 100% rename from lib/ip/socket.c rename to lib/libc/ip/socket.c diff --git a/lib/ip/strcasecmp.c b/lib/libc/ip/strcasecmp.c similarity index 100% rename from lib/ip/strcasecmp.c rename to lib/libc/ip/strcasecmp.c diff --git a/lib/math/Makefile.in b/lib/libc/math/Makefile.inc similarity index 63% rename from lib/math/Makefile.in rename to lib/libc/math/Makefile.inc index 3d949b73f..67fa7ad34 100644 --- a/lib/math/Makefile.in +++ b/lib/libc/math/Makefile.inc @@ -1,10 +1,7 @@ -# Makefile for lib/math. +# math sources +.PATH: ${.CURDIR}/math -CFLAGS="-O -D_MINIX -D_POSIX_SOURCE" - -LIBRARIES=libc - -libc_FILES=" \ +SRCS+= \ asin.c \ atan.c \ atan2.c \ @@ -24,6 +21,4 @@ libc_FILES=" \ sinh.c \ sqrt.c \ tan.c \ - tanh.c" - -TYPE=both + tanh.c diff --git a/lib/math/asin.c b/lib/libc/math/asin.c similarity index 100% rename from lib/math/asin.c rename to lib/libc/math/asin.c diff --git a/lib/math/atan.c b/lib/libc/math/atan.c similarity index 100% rename from lib/math/atan.c rename to lib/libc/math/atan.c diff --git a/lib/math/atan2.c b/lib/libc/math/atan2.c similarity index 100% rename from lib/math/atan2.c rename to lib/libc/math/atan2.c diff --git a/lib/math/ceil.c b/lib/libc/math/ceil.c similarity index 100% rename from lib/math/ceil.c rename to lib/libc/math/ceil.c diff --git a/lib/math/compare.c b/lib/libc/math/compare.c similarity index 100% rename from lib/math/compare.c rename to lib/libc/math/compare.c diff --git a/lib/math/exp.c b/lib/libc/math/exp.c similarity index 100% rename from lib/math/exp.c rename to lib/libc/math/exp.c diff --git a/lib/math/fabs.c b/lib/libc/math/fabs.c similarity index 100% rename from lib/math/fabs.c rename to lib/libc/math/fabs.c diff --git a/lib/math/floor.c b/lib/libc/math/floor.c similarity index 100% rename from lib/math/floor.c rename to lib/libc/math/floor.c diff --git a/lib/math/fmod.c b/lib/libc/math/fmod.c similarity index 100% rename from lib/math/fmod.c rename to lib/libc/math/fmod.c diff --git a/lib/math/hugeval.c b/lib/libc/math/hugeval.c similarity index 100% rename from lib/math/hugeval.c rename to lib/libc/math/hugeval.c diff --git a/lib/math/localmath.h b/lib/libc/math/localmath.h similarity index 100% rename from lib/math/localmath.h rename to lib/libc/math/localmath.h diff --git a/lib/math/log.c b/lib/libc/math/log.c similarity index 100% rename from lib/math/log.c rename to lib/libc/math/log.c diff --git a/lib/math/log10.c b/lib/libc/math/log10.c similarity index 100% rename from lib/math/log10.c rename to lib/libc/math/log10.c diff --git a/lib/math/math_private.h b/lib/libc/math/math_private.h similarity index 100% rename from lib/math/math_private.h rename to lib/libc/math/math_private.h diff --git a/lib/math/pow.c b/lib/libc/math/pow.c similarity index 100% rename from lib/math/pow.c rename to lib/libc/math/pow.c diff --git a/lib/math/s_rint.c b/lib/libc/math/s_rint.c similarity index 100% rename from lib/math/s_rint.c rename to lib/libc/math/s_rint.c diff --git a/lib/math/scalbn.c b/lib/libc/math/scalbn.c similarity index 100% rename from lib/math/scalbn.c rename to lib/libc/math/scalbn.c diff --git a/lib/math/sin.c b/lib/libc/math/sin.c similarity index 100% rename from lib/math/sin.c rename to lib/libc/math/sin.c diff --git a/lib/math/sinh.c b/lib/libc/math/sinh.c similarity index 100% rename from lib/math/sinh.c rename to lib/libc/math/sinh.c diff --git a/lib/math/sqrt.c b/lib/libc/math/sqrt.c similarity index 100% rename from lib/math/sqrt.c rename to lib/libc/math/sqrt.c diff --git a/lib/math/tan.c b/lib/libc/math/tan.c similarity index 100% rename from lib/math/tan.c rename to lib/libc/math/tan.c diff --git a/lib/math/tanh.c b/lib/libc/math/tanh.c similarity index 100% rename from lib/math/tanh.c rename to lib/libc/math/tanh.c diff --git a/lib/other/Makefile.in b/lib/libc/other/Makefile.inc similarity index 89% rename from lib/other/Makefile.in rename to lib/libc/other/Makefile.inc index 40f65a98d..e5a451520 100644 --- a/lib/other/Makefile.in +++ b/lib/libc/other/Makefile.inc @@ -1,10 +1,10 @@ -# Makefile for lib/other. +# other sources +.PATH: ${.CURDIR}/other -CFLAGS="-O -D_MINIX -D_POSIX_SOURCE -I../../servers" +CPPFLAGS.fslib.c+=-I${.CURDIR}/../../servers +CPPFLAGS.fsversion.c+=-I${.CURDIR}/../../servers -LIBRARIES=libc - -libc_FILES=" \ +SRCS+= \ __pm_findproc.c \ _adddma.c \ _brk.c \ @@ -102,6 +102,4 @@ libc_FILES=" \ v8regsub.c \ vectorio.c \ vwarnx.c \ - warnx.c" - -TYPE=both + warnx.c diff --git a/lib/other/__pm_findproc.c b/lib/libc/other/__pm_findproc.c similarity index 100% rename from lib/other/__pm_findproc.c rename to lib/libc/other/__pm_findproc.c diff --git a/lib/other/_adddma.c b/lib/libc/other/_adddma.c similarity index 100% rename from lib/other/_adddma.c rename to lib/libc/other/_adddma.c diff --git a/lib/other/_brk.c b/lib/libc/other/_brk.c similarity index 100% rename from lib/other/_brk.c rename to lib/libc/other/_brk.c diff --git a/lib/other/_cprofile.c b/lib/libc/other/_cprofile.c similarity index 100% rename from lib/other/_cprofile.c rename to lib/libc/other/_cprofile.c diff --git a/lib/other/_deldma.c b/lib/libc/other/_deldma.c similarity index 100% rename from lib/other/_deldma.c rename to lib/libc/other/_deldma.c diff --git a/lib/other/_getdents.c b/lib/libc/other/_getdents.c similarity index 100% rename from lib/other/_getdents.c rename to lib/libc/other/_getdents.c diff --git a/lib/other/_getdma.c b/lib/libc/other/_getdma.c similarity index 100% rename from lib/other/_getdma.c rename to lib/libc/other/_getdma.c diff --git a/lib/other/_getngid.c b/lib/libc/other/_getngid.c similarity index 100% rename from lib/other/_getngid.c rename to lib/libc/other/_getngid.c diff --git a/lib/other/_getnpid.c b/lib/libc/other/_getnpid.c similarity index 100% rename from lib/other/_getnpid.c rename to lib/libc/other/_getnpid.c diff --git a/lib/other/_getnprocnr.c b/lib/libc/other/_getnprocnr.c similarity index 100% rename from lib/other/_getnprocnr.c rename to lib/libc/other/_getnprocnr.c diff --git a/lib/other/_getnuid.c b/lib/libc/other/_getnuid.c similarity index 100% rename from lib/other/_getnuid.c rename to lib/libc/other/_getnuid.c diff --git a/lib/other/_getpprocnr.c b/lib/libc/other/_getpprocnr.c similarity index 100% rename from lib/other/_getpprocnr.c rename to lib/libc/other/_getpprocnr.c diff --git a/lib/other/_getprocnr.c b/lib/libc/other/_getprocnr.c similarity index 100% rename from lib/other/_getprocnr.c rename to lib/libc/other/_getprocnr.c diff --git a/lib/other/_getsigset.c b/lib/libc/other/_getsigset.c similarity index 100% rename from lib/other/_getsigset.c rename to lib/libc/other/_getsigset.c diff --git a/lib/other/_getsysinfo.c b/lib/libc/other/_getsysinfo.c similarity index 100% rename from lib/other/_getsysinfo.c rename to lib/libc/other/_getsysinfo.c diff --git a/lib/other/_lseek64.c b/lib/libc/other/_lseek64.c similarity index 100% rename from lib/other/_lseek64.c rename to lib/libc/other/_lseek64.c diff --git a/lib/other/_mapdriver.c b/lib/libc/other/_mapdriver.c similarity index 100% rename from lib/other/_mapdriver.c rename to lib/libc/other/_mapdriver.c diff --git a/lib/other/_mount.c b/lib/libc/other/_mount.c similarity index 100% rename from lib/other/_mount.c rename to lib/libc/other/_mount.c diff --git a/lib/other/_reboot.c b/lib/libc/other/_reboot.c similarity index 100% rename from lib/other/_reboot.c rename to lib/libc/other/_reboot.c diff --git a/lib/other/_sbrk.c b/lib/libc/other/_sbrk.c similarity index 100% rename from lib/other/_sbrk.c rename to lib/libc/other/_sbrk.c diff --git a/lib/other/_seekdir.c b/lib/libc/other/_seekdir.c similarity index 100% rename from lib/other/_seekdir.c rename to lib/libc/other/_seekdir.c diff --git a/lib/other/_setgroups.c b/lib/libc/other/_setgroups.c similarity index 100% rename from lib/other/_setgroups.c rename to lib/libc/other/_setgroups.c diff --git a/lib/other/_sprofile.c b/lib/libc/other/_sprofile.c similarity index 100% rename from lib/other/_sprofile.c rename to lib/libc/other/_sprofile.c diff --git a/lib/other/_svrctl.c b/lib/libc/other/_svrctl.c similarity index 100% rename from lib/other/_svrctl.c rename to lib/libc/other/_svrctl.c diff --git a/lib/other/_sysuname.c b/lib/libc/other/_sysuname.c similarity index 100% rename from lib/other/_sysuname.c rename to lib/libc/other/_sysuname.c diff --git a/lib/other/_vm_dmacalls.c b/lib/libc/other/_vm_dmacalls.c similarity index 100% rename from lib/other/_vm_dmacalls.c rename to lib/libc/other/_vm_dmacalls.c diff --git a/lib/other/_vm_query_exit.c b/lib/libc/other/_vm_query_exit.c similarity index 100% rename from lib/other/_vm_query_exit.c rename to lib/libc/other/_vm_query_exit.c diff --git a/lib/other/_vm_set_priv.c b/lib/libc/other/_vm_set_priv.c similarity index 100% rename from lib/other/_vm_set_priv.c rename to lib/libc/other/_vm_set_priv.c diff --git a/lib/other/asynchio.c b/lib/libc/other/asynchio.c similarity index 100% rename from lib/other/asynchio.c rename to lib/libc/other/asynchio.c diff --git a/lib/other/basename.c b/lib/libc/other/basename.c similarity index 100% rename from lib/other/basename.c rename to lib/libc/other/basename.c diff --git a/lib/other/bcmp.c b/lib/libc/other/bcmp.c similarity index 100% rename from lib/other/bcmp.c rename to lib/libc/other/bcmp.c diff --git a/lib/other/bcopy.c b/lib/libc/other/bcopy.c similarity index 100% rename from lib/other/bcopy.c rename to lib/libc/other/bcopy.c diff --git a/lib/other/bzero.c b/lib/libc/other/bzero.c similarity index 100% rename from lib/other/bzero.c rename to lib/libc/other/bzero.c diff --git a/lib/other/configfile.c b/lib/libc/other/configfile.c similarity index 100% rename from lib/other/configfile.c rename to lib/libc/other/configfile.c diff --git a/lib/other/crypt.c b/lib/libc/other/crypt.c similarity index 100% rename from lib/other/crypt.c rename to lib/libc/other/crypt.c diff --git a/lib/other/ctermid.c b/lib/libc/other/ctermid.c similarity index 100% rename from lib/other/ctermid.c rename to lib/libc/other/ctermid.c diff --git a/lib/other/cuserid.c b/lib/libc/other/cuserid.c similarity index 100% rename from lib/other/cuserid.c rename to lib/libc/other/cuserid.c diff --git a/lib/other/dirname.c b/lib/libc/other/dirname.c similarity index 100% rename from lib/other/dirname.c rename to lib/libc/other/dirname.c diff --git a/lib/other/environ.c b/lib/libc/other/environ.c similarity index 100% rename from lib/other/environ.c rename to lib/libc/other/environ.c diff --git a/lib/other/errno.c b/lib/libc/other/errno.c similarity index 100% rename from lib/other/errno.c rename to lib/libc/other/errno.c diff --git a/lib/other/fdopen.c b/lib/libc/other/fdopen.c similarity index 100% rename from lib/other/fdopen.c rename to lib/libc/other/fdopen.c diff --git a/lib/other/ffs.c b/lib/libc/other/ffs.c similarity index 100% rename from lib/other/ffs.c rename to lib/libc/other/ffs.c diff --git a/lib/other/flock.c b/lib/libc/other/flock.c similarity index 100% rename from lib/other/flock.c rename to lib/libc/other/flock.c diff --git a/lib/other/fslib.c b/lib/libc/other/fslib.c similarity index 100% rename from lib/other/fslib.c rename to lib/libc/other/fslib.c diff --git a/lib/other/fsversion.c b/lib/libc/other/fsversion.c similarity index 100% rename from lib/other/fsversion.c rename to lib/libc/other/fsversion.c diff --git a/lib/other/fts.c b/lib/libc/other/fts.c similarity index 100% rename from lib/other/fts.c rename to lib/libc/other/fts.c diff --git a/lib/other/getgrent.c b/lib/libc/other/getgrent.c similarity index 100% rename from lib/other/getgrent.c rename to lib/libc/other/getgrent.c diff --git a/lib/other/getlogin.c b/lib/libc/other/getlogin.c similarity index 100% rename from lib/other/getlogin.c rename to lib/libc/other/getlogin.c diff --git a/lib/other/getopt_long.c b/lib/libc/other/getopt_long.c similarity index 100% rename from lib/other/getopt_long.c rename to lib/libc/other/getopt_long.c diff --git a/lib/other/getpagesize.c b/lib/libc/other/getpagesize.c similarity index 100% rename from lib/other/getpagesize.c rename to lib/libc/other/getpagesize.c diff --git a/lib/other/getpass.c b/lib/libc/other/getpass.c similarity index 100% rename from lib/other/getpass.c rename to lib/libc/other/getpass.c diff --git a/lib/other/getpwent.c b/lib/libc/other/getpwent.c similarity index 100% rename from lib/other/getpwent.c rename to lib/libc/other/getpwent.c diff --git a/lib/other/getttyent.c b/lib/libc/other/getttyent.c similarity index 100% rename from lib/other/getttyent.c rename to lib/libc/other/getttyent.c diff --git a/lib/other/getw.c b/lib/libc/other/getw.c similarity index 100% rename from lib/other/getw.c rename to lib/libc/other/getw.c diff --git a/lib/other/hypot.c b/lib/libc/other/hypot.c similarity index 100% rename from lib/other/hypot.c rename to lib/libc/other/hypot.c diff --git a/lib/other/index.c b/lib/libc/other/index.c similarity index 100% rename from lib/other/index.c rename to lib/libc/other/index.c diff --git a/lib/other/initgroups.c b/lib/libc/other/initgroups.c similarity index 100% rename from lib/other/initgroups.c rename to lib/libc/other/initgroups.c diff --git a/lib/other/itoa.c b/lib/libc/other/itoa.c similarity index 100% rename from lib/other/itoa.c rename to lib/libc/other/itoa.c diff --git a/lib/other/loadname.c b/lib/libc/other/loadname.c similarity index 100% rename from lib/other/loadname.c rename to lib/libc/other/loadname.c diff --git a/lib/other/lock.c b/lib/libc/other/lock.c similarity index 100% rename from lib/other/lock.c rename to lib/libc/other/lock.c diff --git a/lib/other/lrand.c b/lib/libc/other/lrand.c similarity index 100% rename from lib/other/lrand.c rename to lib/libc/other/lrand.c diff --git a/lib/other/lsearch.c b/lib/libc/other/lsearch.c similarity index 100% rename from lib/other/lsearch.c rename to lib/libc/other/lsearch.c diff --git a/lib/other/memccpy.c b/lib/libc/other/memccpy.c similarity index 100% rename from lib/other/memccpy.c rename to lib/libc/other/memccpy.c diff --git a/lib/other/minix_rs.c b/lib/libc/other/minix_rs.c similarity index 100% rename from lib/other/minix_rs.c rename to lib/libc/other/minix_rs.c diff --git a/lib/other/mstats.c b/lib/libc/other/mstats.c similarity index 100% rename from lib/other/mstats.c rename to lib/libc/other/mstats.c diff --git a/lib/other/mtab.c b/lib/libc/other/mtab.c similarity index 100% rename from lib/other/mtab.c rename to lib/libc/other/mtab.c diff --git a/lib/other/namespace.h b/lib/libc/other/namespace.h similarity index 100% rename from lib/other/namespace.h rename to lib/libc/other/namespace.h diff --git a/lib/other/nlist.c b/lib/libc/other/nlist.c similarity index 100% rename from lib/other/nlist.c rename to lib/libc/other/nlist.c diff --git a/lib/other/paramvalue.c b/lib/libc/other/paramvalue.c similarity index 100% rename from lib/other/paramvalue.c rename to lib/libc/other/paramvalue.c diff --git a/lib/other/peekpoke.c b/lib/libc/other/peekpoke.c similarity index 100% rename from lib/other/peekpoke.c rename to lib/libc/other/peekpoke.c diff --git a/lib/other/popen.c b/lib/libc/other/popen.c similarity index 100% rename from lib/other/popen.c rename to lib/libc/other/popen.c diff --git a/lib/other/putenv.c b/lib/libc/other/putenv.c similarity index 100% rename from lib/other/putenv.c rename to lib/libc/other/putenv.c diff --git a/lib/other/putw.c b/lib/libc/other/putw.c similarity index 100% rename from lib/other/putw.c rename to lib/libc/other/putw.c diff --git a/lib/other/random.c b/lib/libc/other/random.c similarity index 100% rename from lib/other/random.c rename to lib/libc/other/random.c diff --git a/lib/other/realpath.c b/lib/libc/other/realpath.c similarity index 100% rename from lib/other/realpath.c rename to lib/libc/other/realpath.c diff --git a/lib/other/rindex.c b/lib/libc/other/rindex.c similarity index 100% rename from lib/other/rindex.c rename to lib/libc/other/rindex.c diff --git a/lib/other/rlimit.c b/lib/libc/other/rlimit.c similarity index 100% rename from lib/other/rlimit.c rename to lib/libc/other/rlimit.c diff --git a/lib/other/setenv.c b/lib/libc/other/setenv.c similarity index 100% rename from lib/other/setenv.c rename to lib/libc/other/setenv.c diff --git a/lib/other/settimeofday.c b/lib/libc/other/settimeofday.c similarity index 100% rename from lib/other/settimeofday.c rename to lib/libc/other/settimeofday.c diff --git a/lib/other/stderr.c b/lib/libc/other/stderr.c similarity index 100% rename from lib/other/stderr.c rename to lib/libc/other/stderr.c diff --git a/lib/other/strdup.c b/lib/libc/other/strdup.c similarity index 100% rename from lib/other/strdup.c rename to lib/libc/other/strdup.c diff --git a/lib/other/strlcat.c b/lib/libc/other/strlcat.c similarity index 100% rename from lib/other/strlcat.c rename to lib/libc/other/strlcat.c diff --git a/lib/other/strlcpy.c b/lib/libc/other/strlcpy.c similarity index 100% rename from lib/other/strlcpy.c rename to lib/libc/other/strlcpy.c diff --git a/lib/other/strtok_r.c b/lib/libc/other/strtok_r.c similarity index 100% rename from lib/other/strtok_r.c rename to lib/libc/other/strtok_r.c diff --git a/lib/other/strtoll.c b/lib/libc/other/strtoll.c similarity index 100% rename from lib/other/strtoll.c rename to lib/libc/other/strtoll.c diff --git a/lib/other/swab.c b/lib/libc/other/swab.c similarity index 100% rename from lib/other/swab.c rename to lib/libc/other/swab.c diff --git a/lib/other/syscall.c b/lib/libc/other/syscall.c similarity index 100% rename from lib/other/syscall.c rename to lib/libc/other/syscall.c diff --git a/lib/other/sysconf.c b/lib/libc/other/sysconf.c similarity index 100% rename from lib/other/sysconf.c rename to lib/libc/other/sysconf.c diff --git a/lib/other/syslog.c b/lib/libc/other/syslog.c similarity index 100% rename from lib/other/syslog.c rename to lib/libc/other/syslog.c diff --git a/lib/other/telldir.c b/lib/libc/other/telldir.c similarity index 100% rename from lib/other/telldir.c rename to lib/libc/other/telldir.c diff --git a/lib/other/termcap.c b/lib/libc/other/termcap.c similarity index 100% rename from lib/other/termcap.c rename to lib/libc/other/termcap.c diff --git a/lib/other/ttyname.c b/lib/libc/other/ttyname.c similarity index 100% rename from lib/other/ttyname.c rename to lib/libc/other/ttyname.c diff --git a/lib/other/ttyslot.c b/lib/libc/other/ttyslot.c similarity index 100% rename from lib/other/ttyslot.c rename to lib/libc/other/ttyslot.c diff --git a/lib/other/un-namespace.h b/lib/libc/other/un-namespace.h similarity index 100% rename from lib/other/un-namespace.h rename to lib/libc/other/un-namespace.h diff --git a/lib/other/v8regerror.c b/lib/libc/other/v8regerror.c similarity index 100% rename from lib/other/v8regerror.c rename to lib/libc/other/v8regerror.c diff --git a/lib/other/v8regexp.c b/lib/libc/other/v8regexp.c similarity index 100% rename from lib/other/v8regexp.c rename to lib/libc/other/v8regexp.c diff --git a/lib/other/v8regsub.c b/lib/libc/other/v8regsub.c similarity index 100% rename from lib/other/v8regsub.c rename to lib/libc/other/v8regsub.c diff --git a/lib/other/vectorio.c b/lib/libc/other/vectorio.c similarity index 100% rename from lib/other/vectorio.c rename to lib/libc/other/vectorio.c diff --git a/lib/other/vwarnx.c b/lib/libc/other/vwarnx.c similarity index 100% rename from lib/other/vwarnx.c rename to lib/libc/other/vwarnx.c diff --git a/lib/other/warnx.c b/lib/libc/other/warnx.c similarity index 100% rename from lib/other/warnx.c rename to lib/libc/other/warnx.c diff --git a/lib/posix/Makefile.in b/lib/libc/posix/Makefile.inc similarity index 88% rename from lib/posix/Makefile.in rename to lib/libc/posix/Makefile.inc index 7c77efd0b..52d761d52 100644 --- a/lib/posix/Makefile.in +++ b/lib/libc/posix/Makefile.inc @@ -1,10 +1,7 @@ -# Makefile for lib/posix. +# posix sources +.PATH: ${.CURDIR}/posix -CFLAGS="-O -D_MINIX -D_POSIX_SOURCE" - -LIBRARIES=libc - -libc_FILES=" \ +SRCS+= \ __exit.c \ _access.c \ _alarm.c \ @@ -107,9 +104,4 @@ libc_FILES=" \ glob.c \ nice.c \ priority.c \ - usleep.c" - -TYPE=both - -#$(call ADDDEPENDENCIES,_uname.o,/usr/include/minix/config.h) - + usleep.c diff --git a/lib/posix/__exit.c b/lib/libc/posix/__exit.c similarity index 100% rename from lib/posix/__exit.c rename to lib/libc/posix/__exit.c diff --git a/lib/posix/_access.c b/lib/libc/posix/_access.c similarity index 100% rename from lib/posix/_access.c rename to lib/libc/posix/_access.c diff --git a/lib/posix/_alarm.c b/lib/libc/posix/_alarm.c similarity index 100% rename from lib/posix/_alarm.c rename to lib/libc/posix/_alarm.c diff --git a/lib/posix/_cfgetispeed.c b/lib/libc/posix/_cfgetispeed.c similarity index 100% rename from lib/posix/_cfgetispeed.c rename to lib/libc/posix/_cfgetispeed.c diff --git a/lib/posix/_cfgetospeed.c b/lib/libc/posix/_cfgetospeed.c similarity index 100% rename from lib/posix/_cfgetospeed.c rename to lib/libc/posix/_cfgetospeed.c diff --git a/lib/posix/_cfsetispeed.c b/lib/libc/posix/_cfsetispeed.c similarity index 100% rename from lib/posix/_cfsetispeed.c rename to lib/libc/posix/_cfsetispeed.c diff --git a/lib/posix/_cfsetospeed.c b/lib/libc/posix/_cfsetospeed.c similarity index 100% rename from lib/posix/_cfsetospeed.c rename to lib/libc/posix/_cfsetospeed.c diff --git a/lib/posix/_chdir.c b/lib/libc/posix/_chdir.c similarity index 100% rename from lib/posix/_chdir.c rename to lib/libc/posix/_chdir.c diff --git a/lib/posix/_chmod.c b/lib/libc/posix/_chmod.c similarity index 100% rename from lib/posix/_chmod.c rename to lib/libc/posix/_chmod.c diff --git a/lib/posix/_chown.c b/lib/libc/posix/_chown.c similarity index 100% rename from lib/posix/_chown.c rename to lib/libc/posix/_chown.c diff --git a/lib/posix/_chroot.c b/lib/libc/posix/_chroot.c similarity index 100% rename from lib/posix/_chroot.c rename to lib/libc/posix/_chroot.c diff --git a/lib/posix/_close.c b/lib/libc/posix/_close.c similarity index 100% rename from lib/posix/_close.c rename to lib/libc/posix/_close.c diff --git a/lib/posix/_closedir.c b/lib/libc/posix/_closedir.c similarity index 100% rename from lib/posix/_closedir.c rename to lib/libc/posix/_closedir.c diff --git a/lib/posix/_creat.c b/lib/libc/posix/_creat.c similarity index 100% rename from lib/posix/_creat.c rename to lib/libc/posix/_creat.c diff --git a/lib/posix/_dup.c b/lib/libc/posix/_dup.c similarity index 100% rename from lib/posix/_dup.c rename to lib/libc/posix/_dup.c diff --git a/lib/posix/_dup2.c b/lib/libc/posix/_dup2.c similarity index 100% rename from lib/posix/_dup2.c rename to lib/libc/posix/_dup2.c diff --git a/lib/posix/_execl.c b/lib/libc/posix/_execl.c similarity index 100% rename from lib/posix/_execl.c rename to lib/libc/posix/_execl.c diff --git a/lib/posix/_execle.c b/lib/libc/posix/_execle.c similarity index 100% rename from lib/posix/_execle.c rename to lib/libc/posix/_execle.c diff --git a/lib/posix/_execlp.c b/lib/libc/posix/_execlp.c similarity index 100% rename from lib/posix/_execlp.c rename to lib/libc/posix/_execlp.c diff --git a/lib/posix/_execv.c b/lib/libc/posix/_execv.c similarity index 100% rename from lib/posix/_execv.c rename to lib/libc/posix/_execv.c diff --git a/lib/posix/_execve.c b/lib/libc/posix/_execve.c similarity index 100% rename from lib/posix/_execve.c rename to lib/libc/posix/_execve.c diff --git a/lib/posix/_execvp.c b/lib/libc/posix/_execvp.c similarity index 100% rename from lib/posix/_execvp.c rename to lib/libc/posix/_execvp.c diff --git a/lib/posix/_fchmod.c b/lib/libc/posix/_fchmod.c similarity index 100% rename from lib/posix/_fchmod.c rename to lib/libc/posix/_fchmod.c diff --git a/lib/posix/_fchown.c b/lib/libc/posix/_fchown.c similarity index 100% rename from lib/posix/_fchown.c rename to lib/libc/posix/_fchown.c diff --git a/lib/posix/_fcntl.c b/lib/libc/posix/_fcntl.c similarity index 100% rename from lib/posix/_fcntl.c rename to lib/libc/posix/_fcntl.c diff --git a/lib/posix/_fork.c b/lib/libc/posix/_fork.c similarity index 100% rename from lib/posix/_fork.c rename to lib/libc/posix/_fork.c diff --git a/lib/posix/_fpathconf.c b/lib/libc/posix/_fpathconf.c similarity index 100% rename from lib/posix/_fpathconf.c rename to lib/libc/posix/_fpathconf.c diff --git a/lib/posix/_fstat.c b/lib/libc/posix/_fstat.c similarity index 100% rename from lib/posix/_fstat.c rename to lib/libc/posix/_fstat.c diff --git a/lib/posix/_fstatfs.c b/lib/libc/posix/_fstatfs.c similarity index 100% rename from lib/posix/_fstatfs.c rename to lib/libc/posix/_fstatfs.c diff --git a/lib/posix/_fsync.c b/lib/libc/posix/_fsync.c similarity index 100% rename from lib/posix/_fsync.c rename to lib/libc/posix/_fsync.c diff --git a/lib/posix/_getcwd.c b/lib/libc/posix/_getcwd.c similarity index 100% rename from lib/posix/_getcwd.c rename to lib/libc/posix/_getcwd.c diff --git a/lib/posix/_getegid.c b/lib/libc/posix/_getegid.c similarity index 100% rename from lib/posix/_getegid.c rename to lib/libc/posix/_getegid.c diff --git a/lib/posix/_geteuid.c b/lib/libc/posix/_geteuid.c similarity index 100% rename from lib/posix/_geteuid.c rename to lib/libc/posix/_geteuid.c diff --git a/lib/posix/_getgid.c b/lib/libc/posix/_getgid.c similarity index 100% rename from lib/posix/_getgid.c rename to lib/libc/posix/_getgid.c diff --git a/lib/posix/_getgroups.c b/lib/libc/posix/_getgroups.c similarity index 100% rename from lib/posix/_getgroups.c rename to lib/libc/posix/_getgroups.c diff --git a/lib/posix/_getitimer.c b/lib/libc/posix/_getitimer.c similarity index 100% rename from lib/posix/_getitimer.c rename to lib/libc/posix/_getitimer.c diff --git a/lib/posix/_getpgrp.c b/lib/libc/posix/_getpgrp.c similarity index 100% rename from lib/posix/_getpgrp.c rename to lib/libc/posix/_getpgrp.c diff --git a/lib/posix/_getpid.c b/lib/libc/posix/_getpid.c similarity index 100% rename from lib/posix/_getpid.c rename to lib/libc/posix/_getpid.c diff --git a/lib/posix/_getppid.c b/lib/libc/posix/_getppid.c similarity index 100% rename from lib/posix/_getppid.c rename to lib/libc/posix/_getppid.c diff --git a/lib/posix/_getuid.c b/lib/libc/posix/_getuid.c similarity index 100% rename from lib/posix/_getuid.c rename to lib/libc/posix/_getuid.c diff --git a/lib/posix/_ioctl.c b/lib/libc/posix/_ioctl.c similarity index 100% rename from lib/posix/_ioctl.c rename to lib/libc/posix/_ioctl.c diff --git a/lib/posix/_isatty.c b/lib/libc/posix/_isatty.c similarity index 100% rename from lib/posix/_isatty.c rename to lib/libc/posix/_isatty.c diff --git a/lib/posix/_kill.c b/lib/libc/posix/_kill.c similarity index 100% rename from lib/posix/_kill.c rename to lib/libc/posix/_kill.c diff --git a/lib/posix/_killpg.c b/lib/libc/posix/_killpg.c similarity index 100% rename from lib/posix/_killpg.c rename to lib/libc/posix/_killpg.c diff --git a/lib/posix/_link.c b/lib/libc/posix/_link.c similarity index 100% rename from lib/posix/_link.c rename to lib/libc/posix/_link.c diff --git a/lib/posix/_lseek.c b/lib/libc/posix/_lseek.c similarity index 100% rename from lib/posix/_lseek.c rename to lib/libc/posix/_lseek.c diff --git a/lib/posix/_lstat.c b/lib/libc/posix/_lstat.c similarity index 100% rename from lib/posix/_lstat.c rename to lib/libc/posix/_lstat.c diff --git a/lib/posix/_mkdir.c b/lib/libc/posix/_mkdir.c similarity index 100% rename from lib/posix/_mkdir.c rename to lib/libc/posix/_mkdir.c diff --git a/lib/posix/_mkfifo.c b/lib/libc/posix/_mkfifo.c similarity index 100% rename from lib/posix/_mkfifo.c rename to lib/libc/posix/_mkfifo.c diff --git a/lib/posix/_mknod.c b/lib/libc/posix/_mknod.c similarity index 100% rename from lib/posix/_mknod.c rename to lib/libc/posix/_mknod.c diff --git a/lib/posix/_mmap.c b/lib/libc/posix/_mmap.c similarity index 100% rename from lib/posix/_mmap.c rename to lib/libc/posix/_mmap.c diff --git a/lib/posix/_nanosleep.c b/lib/libc/posix/_nanosleep.c similarity index 100% rename from lib/posix/_nanosleep.c rename to lib/libc/posix/_nanosleep.c diff --git a/lib/posix/_open.c b/lib/libc/posix/_open.c similarity index 100% rename from lib/posix/_open.c rename to lib/libc/posix/_open.c diff --git a/lib/posix/_opendir.c b/lib/libc/posix/_opendir.c similarity index 100% rename from lib/posix/_opendir.c rename to lib/libc/posix/_opendir.c diff --git a/lib/posix/_pathconf.c b/lib/libc/posix/_pathconf.c similarity index 100% rename from lib/posix/_pathconf.c rename to lib/libc/posix/_pathconf.c diff --git a/lib/posix/_pause.c b/lib/libc/posix/_pause.c similarity index 100% rename from lib/posix/_pause.c rename to lib/libc/posix/_pause.c diff --git a/lib/posix/_pipe.c b/lib/libc/posix/_pipe.c similarity index 100% rename from lib/posix/_pipe.c rename to lib/libc/posix/_pipe.c diff --git a/lib/posix/_ptrace.c b/lib/libc/posix/_ptrace.c similarity index 100% rename from lib/posix/_ptrace.c rename to lib/libc/posix/_ptrace.c diff --git a/lib/posix/_read.c b/lib/libc/posix/_read.c similarity index 100% rename from lib/posix/_read.c rename to lib/libc/posix/_read.c diff --git a/lib/posix/_readdir.c b/lib/libc/posix/_readdir.c similarity index 100% rename from lib/posix/_readdir.c rename to lib/libc/posix/_readdir.c diff --git a/lib/posix/_readlink.c b/lib/libc/posix/_readlink.c similarity index 100% rename from lib/posix/_readlink.c rename to lib/libc/posix/_readlink.c diff --git a/lib/posix/_rename.c b/lib/libc/posix/_rename.c similarity index 100% rename from lib/posix/_rename.c rename to lib/libc/posix/_rename.c diff --git a/lib/posix/_rewinddir.c b/lib/libc/posix/_rewinddir.c similarity index 100% rename from lib/posix/_rewinddir.c rename to lib/libc/posix/_rewinddir.c diff --git a/lib/posix/_rmdir.c b/lib/libc/posix/_rmdir.c similarity index 100% rename from lib/posix/_rmdir.c rename to lib/libc/posix/_rmdir.c diff --git a/lib/posix/_select.c b/lib/libc/posix/_select.c similarity index 100% rename from lib/posix/_select.c rename to lib/libc/posix/_select.c diff --git a/lib/posix/_setgid.c b/lib/libc/posix/_setgid.c similarity index 100% rename from lib/posix/_setgid.c rename to lib/libc/posix/_setgid.c diff --git a/lib/posix/_setitimer.c b/lib/libc/posix/_setitimer.c similarity index 100% rename from lib/posix/_setitimer.c rename to lib/libc/posix/_setitimer.c diff --git a/lib/posix/_setsid.c b/lib/libc/posix/_setsid.c similarity index 100% rename from lib/posix/_setsid.c rename to lib/libc/posix/_setsid.c diff --git a/lib/posix/_setuid.c b/lib/libc/posix/_setuid.c similarity index 100% rename from lib/posix/_setuid.c rename to lib/libc/posix/_setuid.c diff --git a/lib/posix/_sigaction.c b/lib/libc/posix/_sigaction.c similarity index 100% rename from lib/posix/_sigaction.c rename to lib/libc/posix/_sigaction.c diff --git a/lib/posix/_sigpending.c b/lib/libc/posix/_sigpending.c similarity index 100% rename from lib/posix/_sigpending.c rename to lib/libc/posix/_sigpending.c diff --git a/lib/posix/_sigprocmask.c b/lib/libc/posix/_sigprocmask.c similarity index 100% rename from lib/posix/_sigprocmask.c rename to lib/libc/posix/_sigprocmask.c diff --git a/lib/posix/_sigreturn.c b/lib/libc/posix/_sigreturn.c similarity index 100% rename from lib/posix/_sigreturn.c rename to lib/libc/posix/_sigreturn.c diff --git a/lib/posix/_sigset.c b/lib/libc/posix/_sigset.c similarity index 100% rename from lib/posix/_sigset.c rename to lib/libc/posix/_sigset.c diff --git a/lib/posix/_sigsuspend.c b/lib/libc/posix/_sigsuspend.c similarity index 100% rename from lib/posix/_sigsuspend.c rename to lib/libc/posix/_sigsuspend.c diff --git a/lib/posix/_sleep.c b/lib/libc/posix/_sleep.c similarity index 100% rename from lib/posix/_sleep.c rename to lib/libc/posix/_sleep.c diff --git a/lib/posix/_stat.c b/lib/libc/posix/_stat.c similarity index 100% rename from lib/posix/_stat.c rename to lib/libc/posix/_stat.c diff --git a/lib/posix/_stime.c b/lib/libc/posix/_stime.c similarity index 100% rename from lib/posix/_stime.c rename to lib/libc/posix/_stime.c diff --git a/lib/posix/_symlink.c b/lib/libc/posix/_symlink.c similarity index 100% rename from lib/posix/_symlink.c rename to lib/libc/posix/_symlink.c diff --git a/lib/posix/_sync.c b/lib/libc/posix/_sync.c similarity index 100% rename from lib/posix/_sync.c rename to lib/libc/posix/_sync.c diff --git a/lib/posix/_tcdrain.c b/lib/libc/posix/_tcdrain.c similarity index 100% rename from lib/posix/_tcdrain.c rename to lib/libc/posix/_tcdrain.c diff --git a/lib/posix/_tcflow.c b/lib/libc/posix/_tcflow.c similarity index 100% rename from lib/posix/_tcflow.c rename to lib/libc/posix/_tcflow.c diff --git a/lib/posix/_tcflush.c b/lib/libc/posix/_tcflush.c similarity index 100% rename from lib/posix/_tcflush.c rename to lib/libc/posix/_tcflush.c diff --git a/lib/posix/_tcgetattr.c b/lib/libc/posix/_tcgetattr.c similarity index 100% rename from lib/posix/_tcgetattr.c rename to lib/libc/posix/_tcgetattr.c diff --git a/lib/posix/_tcsendbreak.c b/lib/libc/posix/_tcsendbreak.c similarity index 100% rename from lib/posix/_tcsendbreak.c rename to lib/libc/posix/_tcsendbreak.c diff --git a/lib/posix/_tcsetattr.c b/lib/libc/posix/_tcsetattr.c similarity index 100% rename from lib/posix/_tcsetattr.c rename to lib/libc/posix/_tcsetattr.c diff --git a/lib/posix/_time.c b/lib/libc/posix/_time.c similarity index 100% rename from lib/posix/_time.c rename to lib/libc/posix/_time.c diff --git a/lib/posix/_times.c b/lib/libc/posix/_times.c similarity index 100% rename from lib/posix/_times.c rename to lib/libc/posix/_times.c diff --git a/lib/posix/_truncate.c b/lib/libc/posix/_truncate.c similarity index 100% rename from lib/posix/_truncate.c rename to lib/libc/posix/_truncate.c diff --git a/lib/posix/_umask.c b/lib/libc/posix/_umask.c similarity index 100% rename from lib/posix/_umask.c rename to lib/libc/posix/_umask.c diff --git a/lib/posix/_uname.c b/lib/libc/posix/_uname.c similarity index 100% rename from lib/posix/_uname.c rename to lib/libc/posix/_uname.c diff --git a/lib/posix/_unlink.c b/lib/libc/posix/_unlink.c similarity index 100% rename from lib/posix/_unlink.c rename to lib/libc/posix/_unlink.c diff --git a/lib/posix/_utime.c b/lib/libc/posix/_utime.c similarity index 100% rename from lib/posix/_utime.c rename to lib/libc/posix/_utime.c diff --git a/lib/posix/_wait.c b/lib/libc/posix/_wait.c similarity index 100% rename from lib/posix/_wait.c rename to lib/libc/posix/_wait.c diff --git a/lib/posix/_waitpid.c b/lib/libc/posix/_waitpid.c similarity index 100% rename from lib/posix/_waitpid.c rename to lib/libc/posix/_waitpid.c diff --git a/lib/posix/_write.c b/lib/libc/posix/_write.c similarity index 100% rename from lib/posix/_write.c rename to lib/libc/posix/_write.c diff --git a/lib/posix/getloadavg.c b/lib/libc/posix/getloadavg.c similarity index 100% rename from lib/posix/getloadavg.c rename to lib/libc/posix/getloadavg.c diff --git a/lib/posix/getopt.c b/lib/libc/posix/getopt.c similarity index 100% rename from lib/posix/getopt.c rename to lib/libc/posix/getopt.c diff --git a/lib/posix/gettimeofday.c b/lib/libc/posix/gettimeofday.c similarity index 100% rename from lib/posix/gettimeofday.c rename to lib/libc/posix/gettimeofday.c diff --git a/lib/posix/glob.c b/lib/libc/posix/glob.c similarity index 100% rename from lib/posix/glob.c rename to lib/libc/posix/glob.c diff --git a/lib/posix/nice.c b/lib/libc/posix/nice.c similarity index 100% rename from lib/posix/nice.c rename to lib/libc/posix/nice.c diff --git a/lib/posix/priority.c b/lib/libc/posix/priority.c similarity index 100% rename from lib/posix/priority.c rename to lib/libc/posix/priority.c diff --git a/lib/posix/usleep.c b/lib/libc/posix/usleep.c similarity index 100% rename from lib/posix/usleep.c rename to lib/libc/posix/usleep.c diff --git a/lib/regex/COPYRIGHT b/lib/libc/regex/COPYRIGHT similarity index 100% rename from lib/regex/COPYRIGHT rename to lib/libc/regex/COPYRIGHT diff --git a/lib/libc/regex/Makefile.inc b/lib/libc/regex/Makefile.inc new file mode 100644 index 000000000..d330cf6f7 --- /dev/null +++ b/lib/libc/regex/Makefile.inc @@ -0,0 +1,8 @@ +# regex sources +.PATH: ${.CURDIR}/regex + +SRCS+= \ + regcomp.c \ + regerror.c \ + regexec.c \ + regfree.c diff --git a/lib/regex/WHATSNEW b/lib/libc/regex/WHATSNEW similarity index 100% rename from lib/regex/WHATSNEW rename to lib/libc/regex/WHATSNEW diff --git a/lib/regex/cclass.h b/lib/libc/regex/cclass.h similarity index 100% rename from lib/regex/cclass.h rename to lib/libc/regex/cclass.h diff --git a/lib/regex/cname.h b/lib/libc/regex/cname.h similarity index 100% rename from lib/regex/cname.h rename to lib/libc/regex/cname.h diff --git a/lib/regex/engine.c b/lib/libc/regex/engine.c similarity index 100% rename from lib/regex/engine.c rename to lib/libc/regex/engine.c diff --git a/lib/regex/re_format.7 b/lib/libc/regex/re_format.7 similarity index 100% rename from lib/regex/re_format.7 rename to lib/libc/regex/re_format.7 diff --git a/lib/regex/regcomp.c b/lib/libc/regex/regcomp.c similarity index 100% rename from lib/regex/regcomp.c rename to lib/libc/regex/regcomp.c diff --git a/lib/regex/regerror.c b/lib/libc/regex/regerror.c similarity index 100% rename from lib/regex/regerror.c rename to lib/libc/regex/regerror.c diff --git a/lib/regex/regex.3 b/lib/libc/regex/regex.3 similarity index 100% rename from lib/regex/regex.3 rename to lib/libc/regex/regex.3 diff --git a/lib/regex/regex2.h b/lib/libc/regex/regex2.h similarity index 100% rename from lib/regex/regex2.h rename to lib/libc/regex/regex2.h diff --git a/lib/regex/regexec.c b/lib/libc/regex/regexec.c similarity index 100% rename from lib/regex/regexec.c rename to lib/libc/regex/regexec.c diff --git a/lib/regex/regfree.c b/lib/libc/regex/regfree.c similarity index 100% rename from lib/regex/regfree.c rename to lib/libc/regex/regfree.c diff --git a/lib/regex/utils.h b/lib/libc/regex/utils.h similarity index 100% rename from lib/regex/utils.h rename to lib/libc/regex/utils.h diff --git a/lib/stdio/Makefile.in b/lib/libc/stdio/Makefile.inc similarity index 83% rename from lib/stdio/Makefile.in rename to lib/libc/stdio/Makefile.inc index 1360e8168..c4de4f8ac 100644 --- a/lib/stdio/Makefile.in +++ b/lib/libc/stdio/Makefile.inc @@ -1,10 +1,7 @@ -# Makefile for lib/stdio. +# stdio sources +.PATH: ${.CURDIR}/stdio -CFLAGS="-O -D_MINIX -D_POSIX_SOURCE" - -LIBRARIES=libc - -libc_FILES=" \ +SRCS+= \ clearerr.c \ data.c \ doprnt.c \ @@ -55,6 +52,4 @@ libc_FILES=" \ vprintf.c \ vscanf.c \ vsprintf.c \ - vsscanf.c" - -TYPE=both + vsscanf.c diff --git a/lib/stdio/clearerr.c b/lib/libc/stdio/clearerr.c similarity index 100% rename from lib/stdio/clearerr.c rename to lib/libc/stdio/clearerr.c diff --git a/lib/stdio/data.c b/lib/libc/stdio/data.c similarity index 100% rename from lib/stdio/data.c rename to lib/libc/stdio/data.c diff --git a/lib/stdio/doprnt.c b/lib/libc/stdio/doprnt.c similarity index 100% rename from lib/stdio/doprnt.c rename to lib/libc/stdio/doprnt.c diff --git a/lib/stdio/doscan.c b/lib/libc/stdio/doscan.c similarity index 100% rename from lib/stdio/doscan.c rename to lib/libc/stdio/doscan.c diff --git a/lib/stdio/ecvt.c b/lib/libc/stdio/ecvt.c similarity index 100% rename from lib/stdio/ecvt.c rename to lib/libc/stdio/ecvt.c diff --git a/lib/stdio/fclose.c b/lib/libc/stdio/fclose.c similarity index 100% rename from lib/stdio/fclose.c rename to lib/libc/stdio/fclose.c diff --git a/lib/stdio/feof.c b/lib/libc/stdio/feof.c similarity index 100% rename from lib/stdio/feof.c rename to lib/libc/stdio/feof.c diff --git a/lib/stdio/ferror.c b/lib/libc/stdio/ferror.c similarity index 100% rename from lib/stdio/ferror.c rename to lib/libc/stdio/ferror.c diff --git a/lib/stdio/fflush.c b/lib/libc/stdio/fflush.c similarity index 100% rename from lib/stdio/fflush.c rename to lib/libc/stdio/fflush.c diff --git a/lib/stdio/fgetc.c b/lib/libc/stdio/fgetc.c similarity index 100% rename from lib/stdio/fgetc.c rename to lib/libc/stdio/fgetc.c diff --git a/lib/stdio/fgetpos.c b/lib/libc/stdio/fgetpos.c similarity index 100% rename from lib/stdio/fgetpos.c rename to lib/libc/stdio/fgetpos.c diff --git a/lib/stdio/fgets.c b/lib/libc/stdio/fgets.c similarity index 100% rename from lib/stdio/fgets.c rename to lib/libc/stdio/fgets.c diff --git a/lib/stdio/fileno.c b/lib/libc/stdio/fileno.c similarity index 100% rename from lib/stdio/fileno.c rename to lib/libc/stdio/fileno.c diff --git a/lib/stdio/fillbuf.c b/lib/libc/stdio/fillbuf.c similarity index 100% rename from lib/stdio/fillbuf.c rename to lib/libc/stdio/fillbuf.c diff --git a/lib/stdio/flushbuf.c b/lib/libc/stdio/flushbuf.c similarity index 100% rename from lib/stdio/flushbuf.c rename to lib/libc/stdio/flushbuf.c diff --git a/lib/stdio/fopen.c b/lib/libc/stdio/fopen.c similarity index 100% rename from lib/stdio/fopen.c rename to lib/libc/stdio/fopen.c diff --git a/lib/stdio/fprintf.c b/lib/libc/stdio/fprintf.c similarity index 100% rename from lib/stdio/fprintf.c rename to lib/libc/stdio/fprintf.c diff --git a/lib/stdio/fputc.c b/lib/libc/stdio/fputc.c similarity index 100% rename from lib/stdio/fputc.c rename to lib/libc/stdio/fputc.c diff --git a/lib/stdio/fputs.c b/lib/libc/stdio/fputs.c similarity index 100% rename from lib/stdio/fputs.c rename to lib/libc/stdio/fputs.c diff --git a/lib/stdio/fread.c b/lib/libc/stdio/fread.c similarity index 100% rename from lib/stdio/fread.c rename to lib/libc/stdio/fread.c diff --git a/lib/stdio/freopen.c b/lib/libc/stdio/freopen.c similarity index 100% rename from lib/stdio/freopen.c rename to lib/libc/stdio/freopen.c diff --git a/lib/stdio/fscanf.c b/lib/libc/stdio/fscanf.c similarity index 100% rename from lib/stdio/fscanf.c rename to lib/libc/stdio/fscanf.c diff --git a/lib/stdio/fseek.c b/lib/libc/stdio/fseek.c similarity index 100% rename from lib/stdio/fseek.c rename to lib/libc/stdio/fseek.c diff --git a/lib/stdio/fsetpos.c b/lib/libc/stdio/fsetpos.c similarity index 100% rename from lib/stdio/fsetpos.c rename to lib/libc/stdio/fsetpos.c diff --git a/lib/stdio/ftell.c b/lib/libc/stdio/ftell.c similarity index 100% rename from lib/stdio/ftell.c rename to lib/libc/stdio/ftell.c diff --git a/lib/stdio/fwrite.c b/lib/libc/stdio/fwrite.c similarity index 100% rename from lib/stdio/fwrite.c rename to lib/libc/stdio/fwrite.c diff --git a/lib/stdio/getc.c b/lib/libc/stdio/getc.c similarity index 100% rename from lib/stdio/getc.c rename to lib/libc/stdio/getc.c diff --git a/lib/stdio/getchar.c b/lib/libc/stdio/getchar.c similarity index 100% rename from lib/stdio/getchar.c rename to lib/libc/stdio/getchar.c diff --git a/lib/stdio/gets.c b/lib/libc/stdio/gets.c similarity index 100% rename from lib/stdio/gets.c rename to lib/libc/stdio/gets.c diff --git a/lib/stdio/icompute.c b/lib/libc/stdio/icompute.c similarity index 100% rename from lib/stdio/icompute.c rename to lib/libc/stdio/icompute.c diff --git a/lib/stdio/loc_incl.h b/lib/libc/stdio/loc_incl.h similarity index 100% rename from lib/stdio/loc_incl.h rename to lib/libc/stdio/loc_incl.h diff --git a/lib/stdio/mktemp.c b/lib/libc/stdio/mktemp.c similarity index 100% rename from lib/stdio/mktemp.c rename to lib/libc/stdio/mktemp.c diff --git a/lib/stdio/perror.c b/lib/libc/stdio/perror.c similarity index 100% rename from lib/stdio/perror.c rename to lib/libc/stdio/perror.c diff --git a/lib/stdio/printf.c b/lib/libc/stdio/printf.c similarity index 100% rename from lib/stdio/printf.c rename to lib/libc/stdio/printf.c diff --git a/lib/stdio/putc.c b/lib/libc/stdio/putc.c similarity index 100% rename from lib/stdio/putc.c rename to lib/libc/stdio/putc.c diff --git a/lib/stdio/putchar.c b/lib/libc/stdio/putchar.c similarity index 100% rename from lib/stdio/putchar.c rename to lib/libc/stdio/putchar.c diff --git a/lib/stdio/puts.c b/lib/libc/stdio/puts.c similarity index 100% rename from lib/stdio/puts.c rename to lib/libc/stdio/puts.c diff --git a/lib/stdio/remove.c b/lib/libc/stdio/remove.c similarity index 100% rename from lib/stdio/remove.c rename to lib/libc/stdio/remove.c diff --git a/lib/stdio/rewind.c b/lib/libc/stdio/rewind.c similarity index 100% rename from lib/stdio/rewind.c rename to lib/libc/stdio/rewind.c diff --git a/lib/stdio/scanf.c b/lib/libc/stdio/scanf.c similarity index 100% rename from lib/stdio/scanf.c rename to lib/libc/stdio/scanf.c diff --git a/lib/stdio/setbuf.c b/lib/libc/stdio/setbuf.c similarity index 100% rename from lib/stdio/setbuf.c rename to lib/libc/stdio/setbuf.c diff --git a/lib/stdio/setvbuf.c b/lib/libc/stdio/setvbuf.c similarity index 100% rename from lib/stdio/setvbuf.c rename to lib/libc/stdio/setvbuf.c diff --git a/lib/stdio/sprintf.c b/lib/libc/stdio/sprintf.c similarity index 100% rename from lib/stdio/sprintf.c rename to lib/libc/stdio/sprintf.c diff --git a/lib/stdio/sscanf.c b/lib/libc/stdio/sscanf.c similarity index 100% rename from lib/stdio/sscanf.c rename to lib/libc/stdio/sscanf.c diff --git a/lib/stdio/tmpfile.c b/lib/libc/stdio/tmpfile.c similarity index 100% rename from lib/stdio/tmpfile.c rename to lib/libc/stdio/tmpfile.c diff --git a/lib/stdio/tmpnam.c b/lib/libc/stdio/tmpnam.c similarity index 100% rename from lib/stdio/tmpnam.c rename to lib/libc/stdio/tmpnam.c diff --git a/lib/stdio/ungetc.c b/lib/libc/stdio/ungetc.c similarity index 100% rename from lib/stdio/ungetc.c rename to lib/libc/stdio/ungetc.c diff --git a/lib/stdio/vfprintf.c b/lib/libc/stdio/vfprintf.c similarity index 100% rename from lib/stdio/vfprintf.c rename to lib/libc/stdio/vfprintf.c diff --git a/lib/stdio/vprintf.c b/lib/libc/stdio/vprintf.c similarity index 100% rename from lib/stdio/vprintf.c rename to lib/libc/stdio/vprintf.c diff --git a/lib/stdio/vscanf.c b/lib/libc/stdio/vscanf.c similarity index 100% rename from lib/stdio/vscanf.c rename to lib/libc/stdio/vscanf.c diff --git a/lib/stdio/vsprintf.c b/lib/libc/stdio/vsprintf.c similarity index 100% rename from lib/stdio/vsprintf.c rename to lib/libc/stdio/vsprintf.c diff --git a/lib/stdio/vsscanf.c b/lib/libc/stdio/vsscanf.c similarity index 100% rename from lib/stdio/vsscanf.c rename to lib/libc/stdio/vsscanf.c diff --git a/lib/libc/stdtime/Makefile.inc b/lib/libc/stdtime/Makefile.inc new file mode 100644 index 000000000..c994980c7 --- /dev/null +++ b/lib/libc/stdtime/Makefile.inc @@ -0,0 +1,14 @@ +# stdtime sources +.PATH: ${.CURDIR}/stdtime + +Z=${.CURDIR}/../../commands/zoneinfo + +CPPFLAGS.asctime.c+=-I$Z +CPPFLAGS.localtime.c+=-I$Z +CPPFLAGS.strftime.c+=-I$Z + +SRCS+= \ + ftime.c \ + asctime.c \ + localtime.c \ + strftime.c diff --git a/lib/stdtime/asctime.c b/lib/libc/stdtime/asctime.c similarity index 100% rename from lib/stdtime/asctime.c rename to lib/libc/stdtime/asctime.c diff --git a/lib/stdtime/ftime.c b/lib/libc/stdtime/ftime.c similarity index 100% rename from lib/stdtime/ftime.c rename to lib/libc/stdtime/ftime.c diff --git a/lib/stdtime/localtime.c b/lib/libc/stdtime/localtime.c similarity index 100% rename from lib/stdtime/localtime.c rename to lib/libc/stdtime/localtime.c diff --git a/lib/stdtime/strftime.c b/lib/libc/stdtime/strftime.c similarity index 100% rename from lib/stdtime/strftime.c rename to lib/libc/stdtime/strftime.c diff --git a/lib/syscall/Makefile.in b/lib/libc/syscall/Makefile.inc similarity index 95% rename from lib/syscall/Makefile.in rename to lib/libc/syscall/Makefile.inc index 5e09a2fba..502cd03c6 100644 --- a/lib/syscall/Makefile.in +++ b/lib/libc/syscall/Makefile.inc @@ -1,8 +1,7 @@ -# Makefile for lib/syscall. +# syscall sources +.PATH: ${.CURDIR}/syscall -LIBRARIES=libc - -libc_FILES=" \ +SRCS+= \ _exit.s \ _pm_findproc.s \ access.s \ @@ -134,6 +133,4 @@ libc_FILES=" \ vm_dmacalls.s \ wait.s \ waitpid.s \ - write.s" - -TYPE=both + write.s diff --git a/lib/syscall/_exit.s b/lib/libc/syscall/_exit.s similarity index 100% rename from lib/syscall/_exit.s rename to lib/libc/syscall/_exit.s diff --git a/lib/syscall/_pm_findproc.s b/lib/libc/syscall/_pm_findproc.s similarity index 100% rename from lib/syscall/_pm_findproc.s rename to lib/libc/syscall/_pm_findproc.s diff --git a/lib/syscall/access.s b/lib/libc/syscall/access.s similarity index 100% rename from lib/syscall/access.s rename to lib/libc/syscall/access.s diff --git a/lib/syscall/adddma.s b/lib/libc/syscall/adddma.s similarity index 100% rename from lib/syscall/adddma.s rename to lib/libc/syscall/adddma.s diff --git a/lib/syscall/alarm.s b/lib/libc/syscall/alarm.s similarity index 100% rename from lib/syscall/alarm.s rename to lib/libc/syscall/alarm.s diff --git a/lib/syscall/brk.s b/lib/libc/syscall/brk.s similarity index 100% rename from lib/syscall/brk.s rename to lib/libc/syscall/brk.s diff --git a/lib/syscall/cfgetispeed.s b/lib/libc/syscall/cfgetispeed.s similarity index 100% rename from lib/syscall/cfgetispeed.s rename to lib/libc/syscall/cfgetispeed.s diff --git a/lib/syscall/cfgetospeed.s b/lib/libc/syscall/cfgetospeed.s similarity index 100% rename from lib/syscall/cfgetospeed.s rename to lib/libc/syscall/cfgetospeed.s diff --git a/lib/syscall/cfsetispeed.s b/lib/libc/syscall/cfsetispeed.s similarity index 100% rename from lib/syscall/cfsetispeed.s rename to lib/libc/syscall/cfsetispeed.s diff --git a/lib/syscall/cfsetospeed.s b/lib/libc/syscall/cfsetospeed.s similarity index 100% rename from lib/syscall/cfsetospeed.s rename to lib/libc/syscall/cfsetospeed.s diff --git a/lib/syscall/chdir.s b/lib/libc/syscall/chdir.s similarity index 100% rename from lib/syscall/chdir.s rename to lib/libc/syscall/chdir.s diff --git a/lib/syscall/chmod.s b/lib/libc/syscall/chmod.s similarity index 100% rename from lib/syscall/chmod.s rename to lib/libc/syscall/chmod.s diff --git a/lib/syscall/chown.s b/lib/libc/syscall/chown.s similarity index 100% rename from lib/syscall/chown.s rename to lib/libc/syscall/chown.s diff --git a/lib/syscall/chroot.s b/lib/libc/syscall/chroot.s similarity index 100% rename from lib/syscall/chroot.s rename to lib/libc/syscall/chroot.s diff --git a/lib/syscall/close.s b/lib/libc/syscall/close.s similarity index 100% rename from lib/syscall/close.s rename to lib/libc/syscall/close.s diff --git a/lib/syscall/closedir.s b/lib/libc/syscall/closedir.s similarity index 100% rename from lib/syscall/closedir.s rename to lib/libc/syscall/closedir.s diff --git a/lib/syscall/cprofile.s b/lib/libc/syscall/cprofile.s similarity index 100% rename from lib/syscall/cprofile.s rename to lib/libc/syscall/cprofile.s diff --git a/lib/syscall/creat.s b/lib/libc/syscall/creat.s similarity index 100% rename from lib/syscall/creat.s rename to lib/libc/syscall/creat.s diff --git a/lib/syscall/deldma.s b/lib/libc/syscall/deldma.s similarity index 100% rename from lib/syscall/deldma.s rename to lib/libc/syscall/deldma.s diff --git a/lib/syscall/dup.s b/lib/libc/syscall/dup.s similarity index 100% rename from lib/syscall/dup.s rename to lib/libc/syscall/dup.s diff --git a/lib/syscall/dup2.s b/lib/libc/syscall/dup2.s similarity index 100% rename from lib/syscall/dup2.s rename to lib/libc/syscall/dup2.s diff --git a/lib/syscall/execl.s b/lib/libc/syscall/execl.s similarity index 100% rename from lib/syscall/execl.s rename to lib/libc/syscall/execl.s diff --git a/lib/syscall/execle.s b/lib/libc/syscall/execle.s similarity index 100% rename from lib/syscall/execle.s rename to lib/libc/syscall/execle.s diff --git a/lib/syscall/execlp.s b/lib/libc/syscall/execlp.s similarity index 100% rename from lib/syscall/execlp.s rename to lib/libc/syscall/execlp.s diff --git a/lib/syscall/execv.s b/lib/libc/syscall/execv.s similarity index 100% rename from lib/syscall/execv.s rename to lib/libc/syscall/execv.s diff --git a/lib/syscall/execve.s b/lib/libc/syscall/execve.s similarity index 100% rename from lib/syscall/execve.s rename to lib/libc/syscall/execve.s diff --git a/lib/syscall/execvp.s b/lib/libc/syscall/execvp.s similarity index 100% rename from lib/syscall/execvp.s rename to lib/libc/syscall/execvp.s diff --git a/lib/syscall/fchmod.s b/lib/libc/syscall/fchmod.s similarity index 100% rename from lib/syscall/fchmod.s rename to lib/libc/syscall/fchmod.s diff --git a/lib/syscall/fchown.s b/lib/libc/syscall/fchown.s similarity index 100% rename from lib/syscall/fchown.s rename to lib/libc/syscall/fchown.s diff --git a/lib/syscall/fcntl.s b/lib/libc/syscall/fcntl.s similarity index 100% rename from lib/syscall/fcntl.s rename to lib/libc/syscall/fcntl.s diff --git a/lib/syscall/fork.s b/lib/libc/syscall/fork.s similarity index 100% rename from lib/syscall/fork.s rename to lib/libc/syscall/fork.s diff --git a/lib/syscall/fpathconf.s b/lib/libc/syscall/fpathconf.s similarity index 100% rename from lib/syscall/fpathconf.s rename to lib/libc/syscall/fpathconf.s diff --git a/lib/syscall/fstat.s b/lib/libc/syscall/fstat.s similarity index 100% rename from lib/syscall/fstat.s rename to lib/libc/syscall/fstat.s diff --git a/lib/syscall/fstatfs.s b/lib/libc/syscall/fstatfs.s similarity index 100% rename from lib/syscall/fstatfs.s rename to lib/libc/syscall/fstatfs.s diff --git a/lib/syscall/getcwd.s b/lib/libc/syscall/getcwd.s similarity index 100% rename from lib/syscall/getcwd.s rename to lib/libc/syscall/getcwd.s diff --git a/lib/syscall/getdents.s b/lib/libc/syscall/getdents.s similarity index 100% rename from lib/syscall/getdents.s rename to lib/libc/syscall/getdents.s diff --git a/lib/syscall/getdma.s b/lib/libc/syscall/getdma.s similarity index 100% rename from lib/syscall/getdma.s rename to lib/libc/syscall/getdma.s diff --git a/lib/syscall/getegid.s b/lib/libc/syscall/getegid.s similarity index 100% rename from lib/syscall/getegid.s rename to lib/libc/syscall/getegid.s diff --git a/lib/syscall/geteuid.s b/lib/libc/syscall/geteuid.s similarity index 100% rename from lib/syscall/geteuid.s rename to lib/libc/syscall/geteuid.s diff --git a/lib/syscall/getgid.s b/lib/libc/syscall/getgid.s similarity index 100% rename from lib/syscall/getgid.s rename to lib/libc/syscall/getgid.s diff --git a/lib/syscall/getgroups.s b/lib/libc/syscall/getgroups.s similarity index 100% rename from lib/syscall/getgroups.s rename to lib/libc/syscall/getgroups.s diff --git a/lib/syscall/getitimer.s b/lib/libc/syscall/getitimer.s similarity index 100% rename from lib/syscall/getitimer.s rename to lib/libc/syscall/getitimer.s diff --git a/lib/syscall/getngid.s b/lib/libc/syscall/getngid.s similarity index 100% rename from lib/syscall/getngid.s rename to lib/libc/syscall/getngid.s diff --git a/lib/syscall/getnpid.s b/lib/libc/syscall/getnpid.s similarity index 100% rename from lib/syscall/getnpid.s rename to lib/libc/syscall/getnpid.s diff --git a/lib/syscall/getnprocnr.s b/lib/libc/syscall/getnprocnr.s similarity index 100% rename from lib/syscall/getnprocnr.s rename to lib/libc/syscall/getnprocnr.s diff --git a/lib/syscall/getnuid.s b/lib/libc/syscall/getnuid.s similarity index 100% rename from lib/syscall/getnuid.s rename to lib/libc/syscall/getnuid.s diff --git a/lib/syscall/getpgrp.s b/lib/libc/syscall/getpgrp.s similarity index 100% rename from lib/syscall/getpgrp.s rename to lib/libc/syscall/getpgrp.s diff --git a/lib/syscall/getpid.s b/lib/libc/syscall/getpid.s similarity index 100% rename from lib/syscall/getpid.s rename to lib/libc/syscall/getpid.s diff --git a/lib/syscall/getppid.s b/lib/libc/syscall/getppid.s similarity index 100% rename from lib/syscall/getppid.s rename to lib/libc/syscall/getppid.s diff --git a/lib/syscall/getpprocnr.s b/lib/libc/syscall/getpprocnr.s similarity index 100% rename from lib/syscall/getpprocnr.s rename to lib/libc/syscall/getpprocnr.s diff --git a/lib/syscall/getprocnr.s b/lib/libc/syscall/getprocnr.s similarity index 100% rename from lib/syscall/getprocnr.s rename to lib/libc/syscall/getprocnr.s diff --git a/lib/syscall/getsigset.s b/lib/libc/syscall/getsigset.s similarity index 100% rename from lib/syscall/getsigset.s rename to lib/libc/syscall/getsigset.s diff --git a/lib/syscall/getsysinfo.s b/lib/libc/syscall/getsysinfo.s similarity index 100% rename from lib/syscall/getsysinfo.s rename to lib/libc/syscall/getsysinfo.s diff --git a/lib/syscall/getuid.s b/lib/libc/syscall/getuid.s similarity index 100% rename from lib/syscall/getuid.s rename to lib/libc/syscall/getuid.s diff --git a/lib/syscall/ioctl.s b/lib/libc/syscall/ioctl.s similarity index 100% rename from lib/syscall/ioctl.s rename to lib/libc/syscall/ioctl.s diff --git a/lib/syscall/isatty.s b/lib/libc/syscall/isatty.s similarity index 100% rename from lib/syscall/isatty.s rename to lib/libc/syscall/isatty.s diff --git a/lib/syscall/kill.s b/lib/libc/syscall/kill.s similarity index 100% rename from lib/syscall/kill.s rename to lib/libc/syscall/kill.s diff --git a/lib/syscall/killpg.s b/lib/libc/syscall/killpg.s similarity index 100% rename from lib/syscall/killpg.s rename to lib/libc/syscall/killpg.s diff --git a/lib/syscall/link.s b/lib/libc/syscall/link.s similarity index 100% rename from lib/syscall/link.s rename to lib/libc/syscall/link.s diff --git a/lib/syscall/lseek.s b/lib/libc/syscall/lseek.s similarity index 100% rename from lib/syscall/lseek.s rename to lib/libc/syscall/lseek.s diff --git a/lib/syscall/lseek64.s b/lib/libc/syscall/lseek64.s similarity index 100% rename from lib/syscall/lseek64.s rename to lib/libc/syscall/lseek64.s diff --git a/lib/syscall/lstat.s b/lib/libc/syscall/lstat.s similarity index 100% rename from lib/syscall/lstat.s rename to lib/libc/syscall/lstat.s diff --git a/lib/syscall/mapdriver.s b/lib/libc/syscall/mapdriver.s similarity index 100% rename from lib/syscall/mapdriver.s rename to lib/libc/syscall/mapdriver.s diff --git a/lib/syscall/mkdir.s b/lib/libc/syscall/mkdir.s similarity index 100% rename from lib/syscall/mkdir.s rename to lib/libc/syscall/mkdir.s diff --git a/lib/syscall/mkfifo.s b/lib/libc/syscall/mkfifo.s similarity index 100% rename from lib/syscall/mkfifo.s rename to lib/libc/syscall/mkfifo.s diff --git a/lib/syscall/mknod.s b/lib/libc/syscall/mknod.s similarity index 100% rename from lib/syscall/mknod.s rename to lib/libc/syscall/mknod.s diff --git a/lib/syscall/mmap.s b/lib/libc/syscall/mmap.s similarity index 100% rename from lib/syscall/mmap.s rename to lib/libc/syscall/mmap.s diff --git a/lib/syscall/mount.s b/lib/libc/syscall/mount.s similarity index 100% rename from lib/syscall/mount.s rename to lib/libc/syscall/mount.s diff --git a/lib/syscall/nanosleep.s b/lib/libc/syscall/nanosleep.s similarity index 100% rename from lib/syscall/nanosleep.s rename to lib/libc/syscall/nanosleep.s diff --git a/lib/syscall/open.s b/lib/libc/syscall/open.s similarity index 100% rename from lib/syscall/open.s rename to lib/libc/syscall/open.s diff --git a/lib/syscall/opendir.s b/lib/libc/syscall/opendir.s similarity index 100% rename from lib/syscall/opendir.s rename to lib/libc/syscall/opendir.s diff --git a/lib/syscall/pathconf.s b/lib/libc/syscall/pathconf.s similarity index 100% rename from lib/syscall/pathconf.s rename to lib/libc/syscall/pathconf.s diff --git a/lib/syscall/pause.s b/lib/libc/syscall/pause.s similarity index 100% rename from lib/syscall/pause.s rename to lib/libc/syscall/pause.s diff --git a/lib/syscall/pipe.s b/lib/libc/syscall/pipe.s similarity index 100% rename from lib/syscall/pipe.s rename to lib/libc/syscall/pipe.s diff --git a/lib/syscall/ptrace.s b/lib/libc/syscall/ptrace.s similarity index 100% rename from lib/syscall/ptrace.s rename to lib/libc/syscall/ptrace.s diff --git a/lib/syscall/read.s b/lib/libc/syscall/read.s similarity index 100% rename from lib/syscall/read.s rename to lib/libc/syscall/read.s diff --git a/lib/syscall/readdir.s b/lib/libc/syscall/readdir.s similarity index 100% rename from lib/syscall/readdir.s rename to lib/libc/syscall/readdir.s diff --git a/lib/syscall/readlink.s b/lib/libc/syscall/readlink.s similarity index 100% rename from lib/syscall/readlink.s rename to lib/libc/syscall/readlink.s diff --git a/lib/syscall/reboot.s b/lib/libc/syscall/reboot.s similarity index 100% rename from lib/syscall/reboot.s rename to lib/libc/syscall/reboot.s diff --git a/lib/syscall/rename.s b/lib/libc/syscall/rename.s similarity index 100% rename from lib/syscall/rename.s rename to lib/libc/syscall/rename.s diff --git a/lib/syscall/rewinddir.s b/lib/libc/syscall/rewinddir.s similarity index 100% rename from lib/syscall/rewinddir.s rename to lib/libc/syscall/rewinddir.s diff --git a/lib/syscall/rmdir.s b/lib/libc/syscall/rmdir.s similarity index 100% rename from lib/syscall/rmdir.s rename to lib/libc/syscall/rmdir.s diff --git a/lib/syscall/sbrk.s b/lib/libc/syscall/sbrk.s similarity index 100% rename from lib/syscall/sbrk.s rename to lib/libc/syscall/sbrk.s diff --git a/lib/syscall/seekdir.s b/lib/libc/syscall/seekdir.s similarity index 100% rename from lib/syscall/seekdir.s rename to lib/libc/syscall/seekdir.s diff --git a/lib/syscall/select.s b/lib/libc/syscall/select.s similarity index 100% rename from lib/syscall/select.s rename to lib/libc/syscall/select.s diff --git a/lib/syscall/setgid.s b/lib/libc/syscall/setgid.s similarity index 100% rename from lib/syscall/setgid.s rename to lib/libc/syscall/setgid.s diff --git a/lib/syscall/setgroups.s b/lib/libc/syscall/setgroups.s similarity index 100% rename from lib/syscall/setgroups.s rename to lib/libc/syscall/setgroups.s diff --git a/lib/syscall/setitimer.s b/lib/libc/syscall/setitimer.s similarity index 100% rename from lib/syscall/setitimer.s rename to lib/libc/syscall/setitimer.s diff --git a/lib/syscall/setsid.s b/lib/libc/syscall/setsid.s similarity index 100% rename from lib/syscall/setsid.s rename to lib/libc/syscall/setsid.s diff --git a/lib/syscall/setuid.s b/lib/libc/syscall/setuid.s similarity index 100% rename from lib/syscall/setuid.s rename to lib/libc/syscall/setuid.s diff --git a/lib/syscall/sigaction.s b/lib/libc/syscall/sigaction.s similarity index 100% rename from lib/syscall/sigaction.s rename to lib/libc/syscall/sigaction.s diff --git a/lib/syscall/sigaddset.s b/lib/libc/syscall/sigaddset.s similarity index 100% rename from lib/syscall/sigaddset.s rename to lib/libc/syscall/sigaddset.s diff --git a/lib/syscall/sigdelset.s b/lib/libc/syscall/sigdelset.s similarity index 100% rename from lib/syscall/sigdelset.s rename to lib/libc/syscall/sigdelset.s diff --git a/lib/syscall/sigemptyset.s b/lib/libc/syscall/sigemptyset.s similarity index 100% rename from lib/syscall/sigemptyset.s rename to lib/libc/syscall/sigemptyset.s diff --git a/lib/syscall/sigfillset.s b/lib/libc/syscall/sigfillset.s similarity index 100% rename from lib/syscall/sigfillset.s rename to lib/libc/syscall/sigfillset.s diff --git a/lib/syscall/sigismember.s b/lib/libc/syscall/sigismember.s similarity index 100% rename from lib/syscall/sigismember.s rename to lib/libc/syscall/sigismember.s diff --git a/lib/syscall/sigpending.s b/lib/libc/syscall/sigpending.s similarity index 100% rename from lib/syscall/sigpending.s rename to lib/libc/syscall/sigpending.s diff --git a/lib/syscall/sigprocmask.s b/lib/libc/syscall/sigprocmask.s similarity index 100% rename from lib/syscall/sigprocmask.s rename to lib/libc/syscall/sigprocmask.s diff --git a/lib/syscall/sigreturn.s b/lib/libc/syscall/sigreturn.s similarity index 100% rename from lib/syscall/sigreturn.s rename to lib/libc/syscall/sigreturn.s diff --git a/lib/syscall/sigsuspend.s b/lib/libc/syscall/sigsuspend.s similarity index 100% rename from lib/syscall/sigsuspend.s rename to lib/libc/syscall/sigsuspend.s diff --git a/lib/syscall/sleep.s b/lib/libc/syscall/sleep.s similarity index 100% rename from lib/syscall/sleep.s rename to lib/libc/syscall/sleep.s diff --git a/lib/syscall/sprofile.s b/lib/libc/syscall/sprofile.s similarity index 100% rename from lib/syscall/sprofile.s rename to lib/libc/syscall/sprofile.s diff --git a/lib/syscall/stat.s b/lib/libc/syscall/stat.s similarity index 100% rename from lib/syscall/stat.s rename to lib/libc/syscall/stat.s diff --git a/lib/syscall/stime.s b/lib/libc/syscall/stime.s similarity index 100% rename from lib/syscall/stime.s rename to lib/libc/syscall/stime.s diff --git a/lib/syscall/svrctl.s b/lib/libc/syscall/svrctl.s similarity index 100% rename from lib/syscall/svrctl.s rename to lib/libc/syscall/svrctl.s diff --git a/lib/syscall/symlink.s b/lib/libc/syscall/symlink.s similarity index 100% rename from lib/syscall/symlink.s rename to lib/libc/syscall/symlink.s diff --git a/lib/syscall/sync.s b/lib/libc/syscall/sync.s similarity index 100% rename from lib/syscall/sync.s rename to lib/libc/syscall/sync.s diff --git a/lib/syscall/sysuname.s b/lib/libc/syscall/sysuname.s similarity index 100% rename from lib/syscall/sysuname.s rename to lib/libc/syscall/sysuname.s diff --git a/lib/syscall/tcdrain.s b/lib/libc/syscall/tcdrain.s similarity index 100% rename from lib/syscall/tcdrain.s rename to lib/libc/syscall/tcdrain.s diff --git a/lib/syscall/tcflow.s b/lib/libc/syscall/tcflow.s similarity index 100% rename from lib/syscall/tcflow.s rename to lib/libc/syscall/tcflow.s diff --git a/lib/syscall/tcflush.s b/lib/libc/syscall/tcflush.s similarity index 100% rename from lib/syscall/tcflush.s rename to lib/libc/syscall/tcflush.s diff --git a/lib/syscall/tcgetattr.s b/lib/libc/syscall/tcgetattr.s similarity index 100% rename from lib/syscall/tcgetattr.s rename to lib/libc/syscall/tcgetattr.s diff --git a/lib/syscall/tcsendbreak.s b/lib/libc/syscall/tcsendbreak.s similarity index 100% rename from lib/syscall/tcsendbreak.s rename to lib/libc/syscall/tcsendbreak.s diff --git a/lib/syscall/tcsetattr.s b/lib/libc/syscall/tcsetattr.s similarity index 100% rename from lib/syscall/tcsetattr.s rename to lib/libc/syscall/tcsetattr.s diff --git a/lib/syscall/time.s b/lib/libc/syscall/time.s similarity index 100% rename from lib/syscall/time.s rename to lib/libc/syscall/time.s diff --git a/lib/syscall/times.s b/lib/libc/syscall/times.s similarity index 100% rename from lib/syscall/times.s rename to lib/libc/syscall/times.s diff --git a/lib/syscall/truncate.s b/lib/libc/syscall/truncate.s similarity index 100% rename from lib/syscall/truncate.s rename to lib/libc/syscall/truncate.s diff --git a/lib/syscall/umask.s b/lib/libc/syscall/umask.s similarity index 100% rename from lib/syscall/umask.s rename to lib/libc/syscall/umask.s diff --git a/lib/syscall/umount.s b/lib/libc/syscall/umount.s similarity index 100% rename from lib/syscall/umount.s rename to lib/libc/syscall/umount.s diff --git a/lib/syscall/uname.s b/lib/libc/syscall/uname.s similarity index 100% rename from lib/syscall/uname.s rename to lib/libc/syscall/uname.s diff --git a/lib/syscall/unlink.s b/lib/libc/syscall/unlink.s similarity index 100% rename from lib/syscall/unlink.s rename to lib/libc/syscall/unlink.s diff --git a/lib/syscall/utime.s b/lib/libc/syscall/utime.s similarity index 100% rename from lib/syscall/utime.s rename to lib/libc/syscall/utime.s diff --git a/lib/syscall/vm_dmacalls.s b/lib/libc/syscall/vm_dmacalls.s similarity index 100% rename from lib/syscall/vm_dmacalls.s rename to lib/libc/syscall/vm_dmacalls.s diff --git a/lib/syscall/vm_getphys.s b/lib/libc/syscall/vm_getphys.s similarity index 100% rename from lib/syscall/vm_getphys.s rename to lib/libc/syscall/vm_getphys.s diff --git a/lib/syscall/vm_getrefcount.s b/lib/libc/syscall/vm_getrefcount.s similarity index 100% rename from lib/syscall/vm_getrefcount.s rename to lib/libc/syscall/vm_getrefcount.s diff --git a/lib/syscall/vm_query_exit.s b/lib/libc/syscall/vm_query_exit.s similarity index 100% rename from lib/syscall/vm_query_exit.s rename to lib/libc/syscall/vm_query_exit.s diff --git a/lib/syscall/vm_remap.s b/lib/libc/syscall/vm_remap.s similarity index 100% rename from lib/syscall/vm_remap.s rename to lib/libc/syscall/vm_remap.s diff --git a/lib/syscall/vm_set_priv.s b/lib/libc/syscall/vm_set_priv.s similarity index 100% rename from lib/syscall/vm_set_priv.s rename to lib/libc/syscall/vm_set_priv.s diff --git a/lib/syscall/vm_unmap.s b/lib/libc/syscall/vm_unmap.s similarity index 100% rename from lib/syscall/vm_unmap.s rename to lib/libc/syscall/vm_unmap.s diff --git a/lib/syscall/wait.s b/lib/libc/syscall/wait.s similarity index 100% rename from lib/syscall/wait.s rename to lib/libc/syscall/wait.s diff --git a/lib/syscall/waitpid.s b/lib/libc/syscall/waitpid.s similarity index 100% rename from lib/syscall/waitpid.s rename to lib/libc/syscall/waitpid.s diff --git a/lib/syscall/write.s b/lib/libc/syscall/write.s similarity index 100% rename from lib/syscall/write.s rename to lib/libc/syscall/write.s diff --git a/lib/libc/sysvipc/Makefile.inc b/lib/libc/sysvipc/Makefile.inc new file mode 100644 index 000000000..9ad78f7fe --- /dev/null +++ b/lib/libc/sysvipc/Makefile.inc @@ -0,0 +1,4 @@ +# sysvipc sources +.PATH: ${.CURDIR}/sysvipc + +SRCS+= ftok.c sem.c shm.c diff --git a/lib/sysvipc/ftok.c b/lib/libc/sysvipc/ftok.c similarity index 100% rename from lib/sysvipc/ftok.c rename to lib/libc/sysvipc/ftok.c diff --git a/lib/sysvipc/sem.c b/lib/libc/sysvipc/sem.c similarity index 100% rename from lib/sysvipc/sem.c rename to lib/libc/sysvipc/sem.c diff --git a/lib/sysvipc/shm.c b/lib/libc/sysvipc/shm.c similarity index 100% rename from lib/sysvipc/shm.c rename to lib/libc/sysvipc/shm.c diff --git a/lib/curses/Makefile.in b/lib/libcurses/Makefile similarity index 78% rename from lib/curses/Makefile.in rename to lib/libcurses/Makefile index 47fa2ca88..fc4a23219 100644 --- a/lib/curses/Makefile.in +++ b/lib/libcurses/Makefile @@ -1,10 +1,9 @@ -# Makefile for lib/curses. +# Makefile for libcurses -CFLAGS="-O -D_MINIX -D_POSIX_SOURCE" +LIB= curses +CPPFLAGS+= -O -D_MINIX -D_POSIX_SOURCE -LIBRARIES=libcurses - -libcurses_FILES=" \ +SRCS= \ beep.c \ charpick.c \ curs_set.c \ @@ -42,6 +41,6 @@ libcurses_FILES=" \ winsch.c \ winscrol.c \ winsertln.c \ - wintouch.c" + wintouch.c -TYPE=both +.include diff --git a/lib/curses/beep.c b/lib/libcurses/beep.c similarity index 100% rename from lib/curses/beep.c rename to lib/libcurses/beep.c diff --git a/lib/curses/charpick.c b/lib/libcurses/charpick.c similarity index 100% rename from lib/curses/charpick.c rename to lib/libcurses/charpick.c diff --git a/lib/curses/curs_set.c b/lib/libcurses/curs_set.c similarity index 100% rename from lib/curses/curs_set.c rename to lib/libcurses/curs_set.c diff --git a/lib/curses/cursesio.c b/lib/libcurses/cursesio.c similarity index 100% rename from lib/curses/cursesio.c rename to lib/libcurses/cursesio.c diff --git a/lib/curses/curspriv.h b/lib/libcurses/curspriv.h similarity index 100% rename from lib/curses/curspriv.h rename to lib/libcurses/curspriv.h diff --git a/lib/curses/endwin.c b/lib/libcurses/endwin.c similarity index 100% rename from lib/curses/endwin.c rename to lib/libcurses/endwin.c diff --git a/lib/curses/flash.c b/lib/libcurses/flash.c similarity index 100% rename from lib/curses/flash.c rename to lib/libcurses/flash.c diff --git a/lib/curses/initscr.c b/lib/libcurses/initscr.c similarity index 100% rename from lib/curses/initscr.c rename to lib/libcurses/initscr.c diff --git a/lib/curses/longname.c b/lib/libcurses/longname.c similarity index 100% rename from lib/curses/longname.c rename to lib/libcurses/longname.c diff --git a/lib/curses/move.c b/lib/libcurses/move.c similarity index 100% rename from lib/curses/move.c rename to lib/libcurses/move.c diff --git a/lib/curses/mvcursor.c b/lib/libcurses/mvcursor.c similarity index 100% rename from lib/curses/mvcursor.c rename to lib/libcurses/mvcursor.c diff --git a/lib/curses/newwin.c b/lib/libcurses/newwin.c similarity index 100% rename from lib/curses/newwin.c rename to lib/libcurses/newwin.c diff --git a/lib/curses/options.c b/lib/libcurses/options.c similarity index 100% rename from lib/curses/options.c rename to lib/libcurses/options.c diff --git a/lib/curses/overlay.c b/lib/libcurses/overlay.c similarity index 100% rename from lib/curses/overlay.c rename to lib/libcurses/overlay.c diff --git a/lib/curses/prntscan.c b/lib/libcurses/prntscan.c similarity index 100% rename from lib/curses/prntscan.c rename to lib/libcurses/prntscan.c diff --git a/lib/curses/refresh.c b/lib/libcurses/refresh.c similarity index 100% rename from lib/curses/refresh.c rename to lib/libcurses/refresh.c diff --git a/lib/curses/scrreg.c b/lib/libcurses/scrreg.c similarity index 100% rename from lib/curses/scrreg.c rename to lib/libcurses/scrreg.c diff --git a/lib/curses/setterm.c b/lib/libcurses/setterm.c similarity index 100% rename from lib/curses/setterm.c rename to lib/libcurses/setterm.c diff --git a/lib/curses/tabsize.c b/lib/libcurses/tabsize.c similarity index 100% rename from lib/curses/tabsize.c rename to lib/libcurses/tabsize.c diff --git a/lib/curses/termmisc.c b/lib/libcurses/termmisc.c similarity index 100% rename from lib/curses/termmisc.c rename to lib/libcurses/termmisc.c diff --git a/lib/curses/unctrl.c b/lib/libcurses/unctrl.c similarity index 100% rename from lib/curses/unctrl.c rename to lib/libcurses/unctrl.c diff --git a/lib/curses/update.c b/lib/libcurses/update.c similarity index 100% rename from lib/curses/update.c rename to lib/libcurses/update.c diff --git a/lib/curses/waddch.c b/lib/libcurses/waddch.c similarity index 100% rename from lib/curses/waddch.c rename to lib/libcurses/waddch.c diff --git a/lib/curses/waddstr.c b/lib/libcurses/waddstr.c similarity index 100% rename from lib/curses/waddstr.c rename to lib/libcurses/waddstr.c diff --git a/lib/curses/wbox.c b/lib/libcurses/wbox.c similarity index 100% rename from lib/curses/wbox.c rename to lib/libcurses/wbox.c diff --git a/lib/curses/wclear.c b/lib/libcurses/wclear.c similarity index 100% rename from lib/curses/wclear.c rename to lib/libcurses/wclear.c diff --git a/lib/curses/wclrtobot.c b/lib/libcurses/wclrtobot.c similarity index 100% rename from lib/curses/wclrtobot.c rename to lib/libcurses/wclrtobot.c diff --git a/lib/curses/wclrtoeol.c b/lib/libcurses/wclrtoeol.c similarity index 100% rename from lib/curses/wclrtoeol.c rename to lib/libcurses/wclrtoeol.c diff --git a/lib/curses/wdelch.c b/lib/libcurses/wdelch.c similarity index 100% rename from lib/curses/wdelch.c rename to lib/libcurses/wdelch.c diff --git a/lib/curses/wdeleteln.c b/lib/libcurses/wdeleteln.c similarity index 100% rename from lib/curses/wdeleteln.c rename to lib/libcurses/wdeleteln.c diff --git a/lib/curses/werase.c b/lib/libcurses/werase.c similarity index 100% rename from lib/curses/werase.c rename to lib/libcurses/werase.c diff --git a/lib/curses/wgetch.c b/lib/libcurses/wgetch.c similarity index 100% rename from lib/curses/wgetch.c rename to lib/libcurses/wgetch.c diff --git a/lib/curses/wgetstr.c b/lib/libcurses/wgetstr.c similarity index 100% rename from lib/curses/wgetstr.c rename to lib/libcurses/wgetstr.c diff --git a/lib/curses/windel.c b/lib/libcurses/windel.c similarity index 100% rename from lib/curses/windel.c rename to lib/libcurses/windel.c diff --git a/lib/curses/winmove.c b/lib/libcurses/winmove.c similarity index 100% rename from lib/curses/winmove.c rename to lib/libcurses/winmove.c diff --git a/lib/curses/winsch.c b/lib/libcurses/winsch.c similarity index 100% rename from lib/curses/winsch.c rename to lib/libcurses/winsch.c diff --git a/lib/curses/winscrol.c b/lib/libcurses/winscrol.c similarity index 100% rename from lib/curses/winscrol.c rename to lib/libcurses/winscrol.c diff --git a/lib/curses/winsertln.c b/lib/libcurses/winsertln.c similarity index 100% rename from lib/curses/winsertln.c rename to lib/libcurses/winsertln.c diff --git a/lib/curses/wintouch.c b/lib/libcurses/wintouch.c similarity index 100% rename from lib/curses/wintouch.c rename to lib/libcurses/wintouch.c diff --git a/lib/editline/Makefile.in b/lib/libedit/Makefile similarity index 51% rename from lib/editline/Makefile.in rename to lib/libedit/Makefile index 77c93c4f6..9728a1f3e 100644 --- a/lib/editline/Makefile.in +++ b/lib/libedit/Makefile @@ -3,6 +3,7 @@ ## Unix makefile for editline library. ## +LIB= edit ## Set your options: ## -DANSI_ARROWS ANSI arrows keys work like emacs. @@ -18,27 +19,11 @@ ## -DUSE_TERMCAP Use the termcap library for terminal size ## see LDFLAGS, below, if you set this. ## -DNEED_PERROR Don't have (used in testit) -DEFS="-DANSI_ARROWS -DHAVE_STDLIB -DHAVE_TCGETATTR -DHIDE -DUSE_DIRENT \ - -DHIST_SIZE=100 -DUSE_TERMCAP -DSYS_UNIX" -#-DNEED_STRDUP +DEFS=-DANSI_ARROWS -DHAVE_STDLIB -DHAVE_TCGETATTR -DHIDE -DUSE_DIRENT \ + -DHIST_SIZE=100 -DUSE_TERMCAP -DSYS_UNIX -CFLAGS="-O -D_MINIX -D_POSIX_SOURCE $DEFS -wo" -#CC1 = $(CC) $(CFLAGS) -c +CPPFLAGS+=-O -D_MINIX -D_POSIX_SOURCE ${DEFS} -wo -## If you have -DUSE_TERMCAP, set this as appropriate: -#LDFLAGS = -ltermlib -#LDFLAGS = -ltermcap +SRCS= editline.c complete.c sysunix.c -## End of configuration. - -#SOURCES = editline.c complete.c sysunix.c -#LIBRARY = ../libedit.a -LIBRARIES=libedit -#OBJECTS = editline.o complete.o sysunix.o -libedit_FILES="editline.c complete.c sysunix.c" -#SHARFILES = README Makefile editline.3 editline.h unix.h editline.c \ - -TYPE=both -#include ../Makefile.inc - -#$(call ADDDEPENDENCIES,$(libedit_OBJECTS),editline.h) +.include diff --git a/lib/editline/README b/lib/libedit/README similarity index 100% rename from lib/editline/README rename to lib/libedit/README diff --git a/lib/editline/complete.c b/lib/libedit/complete.c similarity index 100% rename from lib/editline/complete.c rename to lib/libedit/complete.c diff --git a/lib/editline/editline.c b/lib/libedit/editline.c similarity index 100% rename from lib/editline/editline.c rename to lib/libedit/editline.c diff --git a/lib/editline/editline.h b/lib/libedit/editline.h similarity index 100% rename from lib/editline/editline.h rename to lib/libedit/editline.h diff --git a/lib/editline/sysunix.c b/lib/libedit/sysunix.c similarity index 100% rename from lib/editline/sysunix.c rename to lib/libedit/sysunix.c diff --git a/lib/editline/testit.c b/lib/libedit/testit.c similarity index 100% rename from lib/editline/testit.c rename to lib/libedit/testit.c diff --git a/lib/editline/unix.h b/lib/libedit/unix.h similarity index 100% rename from lib/editline/unix.h rename to lib/libedit/unix.h diff --git a/lib/libend/Makefile b/lib/libend/Makefile new file mode 100644 index 000000000..d9af4637d --- /dev/null +++ b/lib/libend/Makefile @@ -0,0 +1,15 @@ +# Makefile for libend + +LIB=end + +SRCS= \ + edata.s \ + em_end.s \ + end.s \ + etext.s + +.if (${COMPILER_TYPE} == gnu) +.include "${.CURDIR}/gnu/Makefile.inc" +.endif + +.include diff --git a/lib/end/edata.s b/lib/libend/edata.s similarity index 100% rename from lib/end/edata.s rename to lib/libend/edata.s diff --git a/lib/end/em_end.s b/lib/libend/em_end.s similarity index 100% rename from lib/end/em_end.s rename to lib/libend/em_end.s diff --git a/lib/end/end.s b/lib/libend/end.s similarity index 100% rename from lib/end/end.s rename to lib/libend/end.s diff --git a/lib/end/etext.s b/lib/libend/etext.s similarity index 100% rename from lib/end/etext.s rename to lib/libend/etext.s diff --git a/lib/libend/gnu/Makefile.inc b/lib/libend/gnu/Makefile.inc new file mode 100644 index 000000000..a348fb239 --- /dev/null +++ b/lib/libend/gnu/Makefile.inc @@ -0,0 +1,5 @@ +# end sources +.PATH: ${.CURDIR}/gnu + +SRCS+=gnu_end.gs + diff --git a/lib/gnu/end/gnu_end.gs b/lib/libend/gnu/gnu_end.gs similarity index 100% rename from lib/gnu/end/gnu_end.gs rename to lib/libend/gnu/gnu_end.gs diff --git a/lib/libm/Makefile b/lib/libm/Makefile new file mode 100644 index 000000000..84c94a367 --- /dev/null +++ b/lib/libm/Makefile @@ -0,0 +1,9 @@ +# Makefile for libm + +# Make a dummy libm library so that -lm works. + +LIB= m + +SRCS= dummy.c + +.include diff --git a/lib/dummy/dummy.c b/lib/libm/dummy.c similarity index 100% rename from lib/dummy/dummy.c rename to lib/libm/dummy.c diff --git a/lib/syslib/Makefile.in b/lib/libsys/Makefile similarity index 74% rename from lib/syslib/Makefile.in rename to lib/libsys/Makefile index fb66c52cf..e6eaaa517 100644 --- a/lib/syslib/Makefile.in +++ b/lib/libsys/Makefile @@ -1,10 +1,10 @@ -# Makefile for lib/syslib. +# Makefile for libsys -CFLAGS="-O -D_MINIX -D_POSIX_SOURCE" +LIB= sys -LIBRARIES=libsys +CPPFLAGS+=-O -D_MINIX -D_POSIX_SOURCE -libsys_FILES=" \ +SRCS= \ alloc_util.c \ assert.c \ kernel_call.c \ @@ -88,6 +88,29 @@ libsys_FILES=" \ vm_info.c \ vm_map_phys.c \ vm_umap.c \ - vm_push_sig.c" + vm_push_sig.c \ + asynsend.c \ + kprintf.c \ + kputc.c \ + tickdelay.c \ + get_randomness.c \ + getidle.c \ + getuptime.c \ + getuptime2.c \ + env_get_prm.c \ + env_parse.c \ + env_panic.c \ + env_prefix.c \ + fkey_ctl.c \ + tsc_util.c \ + report.c \ + read_tsc.s \ + read_tsc_64.c \ + ser_putc.c \ + stacktrace.c \ + sys_hz.c \ + timing.c \ + profile_extern.c \ + profile.c -TYPE=both +.include diff --git a/lib/syslib/alloc_util.c b/lib/libsys/alloc_util.c similarity index 100% rename from lib/syslib/alloc_util.c rename to lib/libsys/alloc_util.c diff --git a/lib/syslib/assert.c b/lib/libsys/assert.c similarity index 100% rename from lib/syslib/assert.c rename to lib/libsys/assert.c diff --git a/lib/sysutil/asynsend.c b/lib/libsys/asynsend.c similarity index 100% rename from lib/sysutil/asynsend.c rename to lib/libsys/asynsend.c diff --git a/lib/syslib/ds.c b/lib/libsys/ds.c similarity index 100% rename from lib/syslib/ds.c rename to lib/libsys/ds.c diff --git a/lib/sysutil/env_get_prm.c b/lib/libsys/env_get_prm.c similarity index 100% rename from lib/sysutil/env_get_prm.c rename to lib/libsys/env_get_prm.c diff --git a/lib/sysutil/env_panic.c b/lib/libsys/env_panic.c similarity index 100% rename from lib/sysutil/env_panic.c rename to lib/libsys/env_panic.c diff --git a/lib/sysutil/env_parse.c b/lib/libsys/env_parse.c similarity index 100% rename from lib/sysutil/env_parse.c rename to lib/libsys/env_parse.c diff --git a/lib/sysutil/env_prefix.c b/lib/libsys/env_prefix.c similarity index 100% rename from lib/sysutil/env_prefix.c rename to lib/libsys/env_prefix.c diff --git a/lib/sysutil/fkey_ctl.c b/lib/libsys/fkey_ctl.c similarity index 100% rename from lib/sysutil/fkey_ctl.c rename to lib/libsys/fkey_ctl.c diff --git a/lib/sysutil/get_randomness.c b/lib/libsys/get_randomness.c similarity index 100% rename from lib/sysutil/get_randomness.c rename to lib/libsys/get_randomness.c diff --git a/lib/sysutil/getidle.c b/lib/libsys/getidle.c similarity index 100% rename from lib/sysutil/getidle.c rename to lib/libsys/getidle.c diff --git a/lib/sysutil/getuptime.c b/lib/libsys/getuptime.c similarity index 100% rename from lib/sysutil/getuptime.c rename to lib/libsys/getuptime.c diff --git a/lib/sysutil/getuptime2.c b/lib/libsys/getuptime2.c similarity index 100% rename from lib/sysutil/getuptime2.c rename to lib/libsys/getuptime2.c diff --git a/lib/syslib/kernel_call.c b/lib/libsys/kernel_call.c similarity index 100% rename from lib/syslib/kernel_call.c rename to lib/libsys/kernel_call.c diff --git a/lib/sysutil/kprintf.c b/lib/libsys/kprintf.c similarity index 100% rename from lib/sysutil/kprintf.c rename to lib/libsys/kprintf.c diff --git a/lib/sysutil/kputc.c b/lib/libsys/kputc.c similarity index 100% rename from lib/sysutil/kputc.c rename to lib/libsys/kputc.c diff --git a/lib/syslib/panic.c b/lib/libsys/panic.c similarity index 100% rename from lib/syslib/panic.c rename to lib/libsys/panic.c diff --git a/lib/syslib/pci.h b/lib/libsys/pci.h similarity index 100% rename from lib/syslib/pci.h rename to lib/libsys/pci.h diff --git a/lib/syslib/pci_attr_r16.c b/lib/libsys/pci_attr_r16.c similarity index 100% rename from lib/syslib/pci_attr_r16.c rename to lib/libsys/pci_attr_r16.c diff --git a/lib/syslib/pci_attr_r32.c b/lib/libsys/pci_attr_r32.c similarity index 100% rename from lib/syslib/pci_attr_r32.c rename to lib/libsys/pci_attr_r32.c diff --git a/lib/syslib/pci_attr_r8.c b/lib/libsys/pci_attr_r8.c similarity index 100% rename from lib/syslib/pci_attr_r8.c rename to lib/libsys/pci_attr_r8.c diff --git a/lib/syslib/pci_attr_w16.c b/lib/libsys/pci_attr_w16.c similarity index 100% rename from lib/syslib/pci_attr_w16.c rename to lib/libsys/pci_attr_w16.c diff --git a/lib/syslib/pci_attr_w32.c b/lib/libsys/pci_attr_w32.c similarity index 100% rename from lib/syslib/pci_attr_w32.c rename to lib/libsys/pci_attr_w32.c diff --git a/lib/syslib/pci_attr_w8.c b/lib/libsys/pci_attr_w8.c similarity index 100% rename from lib/syslib/pci_attr_w8.c rename to lib/libsys/pci_attr_w8.c diff --git a/lib/syslib/pci_del_acl.c b/lib/libsys/pci_del_acl.c similarity index 100% rename from lib/syslib/pci_del_acl.c rename to lib/libsys/pci_del_acl.c diff --git a/lib/syslib/pci_dev_name.c b/lib/libsys/pci_dev_name.c similarity index 100% rename from lib/syslib/pci_dev_name.c rename to lib/libsys/pci_dev_name.c diff --git a/lib/syslib/pci_find_dev.c b/lib/libsys/pci_find_dev.c similarity index 100% rename from lib/syslib/pci_find_dev.c rename to lib/libsys/pci_find_dev.c diff --git a/lib/syslib/pci_first_dev.c b/lib/libsys/pci_first_dev.c similarity index 100% rename from lib/syslib/pci_first_dev.c rename to lib/libsys/pci_first_dev.c diff --git a/lib/syslib/pci_ids.c b/lib/libsys/pci_ids.c similarity index 100% rename from lib/syslib/pci_ids.c rename to lib/libsys/pci_ids.c diff --git a/lib/syslib/pci_init.c b/lib/libsys/pci_init.c similarity index 100% rename from lib/syslib/pci_init.c rename to lib/libsys/pci_init.c diff --git a/lib/syslib/pci_init1.c b/lib/libsys/pci_init1.c similarity index 100% rename from lib/syslib/pci_init1.c rename to lib/libsys/pci_init1.c diff --git a/lib/syslib/pci_next_dev.c b/lib/libsys/pci_next_dev.c similarity index 100% rename from lib/syslib/pci_next_dev.c rename to lib/libsys/pci_next_dev.c diff --git a/lib/syslib/pci_rescan_bus.c b/lib/libsys/pci_rescan_bus.c similarity index 100% rename from lib/syslib/pci_rescan_bus.c rename to lib/libsys/pci_rescan_bus.c diff --git a/lib/syslib/pci_reserve.c b/lib/libsys/pci_reserve.c similarity index 100% rename from lib/syslib/pci_reserve.c rename to lib/libsys/pci_reserve.c diff --git a/lib/syslib/pci_set_acl.c b/lib/libsys/pci_set_acl.c similarity index 100% rename from lib/syslib/pci_set_acl.c rename to lib/libsys/pci_set_acl.c diff --git a/lib/syslib/pci_slot_name.c b/lib/libsys/pci_slot_name.c similarity index 100% rename from lib/syslib/pci_slot_name.c rename to lib/libsys/pci_slot_name.c diff --git a/lib/sysutil/profile.c b/lib/libsys/profile.c similarity index 100% rename from lib/sysutil/profile.c rename to lib/libsys/profile.c diff --git a/lib/sysutil/profile_extern.c b/lib/libsys/profile_extern.c similarity index 100% rename from lib/sysutil/profile_extern.c rename to lib/libsys/profile_extern.c diff --git a/lib/sysutil/read_tsc.s b/lib/libsys/read_tsc.s similarity index 100% rename from lib/sysutil/read_tsc.s rename to lib/libsys/read_tsc.s diff --git a/lib/sysutil/read_tsc_64.c b/lib/libsys/read_tsc_64.c similarity index 100% rename from lib/sysutil/read_tsc_64.c rename to lib/libsys/read_tsc_64.c diff --git a/lib/sysutil/report.c b/lib/libsys/report.c similarity index 100% rename from lib/sysutil/report.c rename to lib/libsys/report.c diff --git a/lib/syslib/safecopies.c b/lib/libsys/safecopies.c similarity index 100% rename from lib/syslib/safecopies.c rename to lib/libsys/safecopies.c diff --git a/lib/syslib/sef.c b/lib/libsys/sef.c similarity index 100% rename from lib/syslib/sef.c rename to lib/libsys/sef.c diff --git a/lib/syslib/sef_init.c b/lib/libsys/sef_init.c similarity index 100% rename from lib/syslib/sef_init.c rename to lib/libsys/sef_init.c diff --git a/lib/syslib/sef_liveupdate.c b/lib/libsys/sef_liveupdate.c similarity index 100% rename from lib/syslib/sef_liveupdate.c rename to lib/libsys/sef_liveupdate.c diff --git a/lib/syslib/sef_ping.c b/lib/libsys/sef_ping.c similarity index 100% rename from lib/syslib/sef_ping.c rename to lib/libsys/sef_ping.c diff --git a/lib/sysutil/ser_putc.c b/lib/libsys/ser_putc.c similarity index 100% rename from lib/sysutil/ser_putc.c rename to lib/libsys/ser_putc.c diff --git a/lib/sysutil/stacktrace.c b/lib/libsys/stacktrace.c similarity index 100% rename from lib/sysutil/stacktrace.c rename to lib/libsys/stacktrace.c diff --git a/lib/syslib/sys_abort.c b/lib/libsys/sys_abort.c similarity index 100% rename from lib/syslib/sys_abort.c rename to lib/libsys/sys_abort.c diff --git a/lib/syslib/sys_cprof.c b/lib/libsys/sys_cprof.c similarity index 100% rename from lib/syslib/sys_cprof.c rename to lib/libsys/sys_cprof.c diff --git a/lib/syslib/sys_endsig.c b/lib/libsys/sys_endsig.c similarity index 100% rename from lib/syslib/sys_endsig.c rename to lib/libsys/sys_endsig.c diff --git a/lib/syslib/sys_eniop.c b/lib/libsys/sys_eniop.c similarity index 100% rename from lib/syslib/sys_eniop.c rename to lib/libsys/sys_eniop.c diff --git a/lib/syslib/sys_exec.c b/lib/libsys/sys_exec.c similarity index 100% rename from lib/syslib/sys_exec.c rename to lib/libsys/sys_exec.c diff --git a/lib/syslib/sys_exit.c b/lib/libsys/sys_exit.c similarity index 100% rename from lib/syslib/sys_exit.c rename to lib/libsys/sys_exit.c diff --git a/lib/syslib/sys_fork.c b/lib/libsys/sys_fork.c similarity index 100% rename from lib/syslib/sys_fork.c rename to lib/libsys/sys_fork.c diff --git a/lib/syslib/sys_getinfo.c b/lib/libsys/sys_getinfo.c similarity index 100% rename from lib/syslib/sys_getinfo.c rename to lib/libsys/sys_getinfo.c diff --git a/lib/syslib/sys_getsig.c b/lib/libsys/sys_getsig.c similarity index 100% rename from lib/syslib/sys_getsig.c rename to lib/libsys/sys_getsig.c diff --git a/lib/sysutil/sys_hz.c b/lib/libsys/sys_hz.c similarity index 100% rename from lib/sysutil/sys_hz.c rename to lib/libsys/sys_hz.c diff --git a/lib/syslib/sys_in.c b/lib/libsys/sys_in.c similarity index 100% rename from lib/syslib/sys_in.c rename to lib/libsys/sys_in.c diff --git a/lib/syslib/sys_int86.c b/lib/libsys/sys_int86.c similarity index 100% rename from lib/syslib/sys_int86.c rename to lib/libsys/sys_int86.c diff --git a/lib/syslib/sys_irqctl.c b/lib/libsys/sys_irqctl.c similarity index 100% rename from lib/syslib/sys_irqctl.c rename to lib/libsys/sys_irqctl.c diff --git a/lib/syslib/sys_kill.c b/lib/libsys/sys_kill.c similarity index 100% rename from lib/syslib/sys_kill.c rename to lib/libsys/sys_kill.c diff --git a/lib/syslib/sys_memset.c b/lib/libsys/sys_memset.c similarity index 100% rename from lib/syslib/sys_memset.c rename to lib/libsys/sys_memset.c diff --git a/lib/syslib/sys_newmap.c b/lib/libsys/sys_newmap.c similarity index 100% rename from lib/syslib/sys_newmap.c rename to lib/libsys/sys_newmap.c diff --git a/lib/syslib/sys_nice.c b/lib/libsys/sys_nice.c similarity index 100% rename from lib/syslib/sys_nice.c rename to lib/libsys/sys_nice.c diff --git a/lib/syslib/sys_out.c b/lib/libsys/sys_out.c similarity index 100% rename from lib/syslib/sys_out.c rename to lib/libsys/sys_out.c diff --git a/lib/syslib/sys_physcopy.c b/lib/libsys/sys_physcopy.c similarity index 100% rename from lib/syslib/sys_physcopy.c rename to lib/libsys/sys_physcopy.c diff --git a/lib/syslib/sys_privctl.c b/lib/libsys/sys_privctl.c similarity index 100% rename from lib/syslib/sys_privctl.c rename to lib/libsys/sys_privctl.c diff --git a/lib/syslib/sys_profbuf.c b/lib/libsys/sys_profbuf.c similarity index 100% rename from lib/syslib/sys_profbuf.c rename to lib/libsys/sys_profbuf.c diff --git a/lib/syslib/sys_readbios.c b/lib/libsys/sys_readbios.c similarity index 100% rename from lib/syslib/sys_readbios.c rename to lib/libsys/sys_readbios.c diff --git a/lib/syslib/sys_runctl.c b/lib/libsys/sys_runctl.c similarity index 100% rename from lib/syslib/sys_runctl.c rename to lib/libsys/sys_runctl.c diff --git a/lib/syslib/sys_safecopy.c b/lib/libsys/sys_safecopy.c similarity index 100% rename from lib/syslib/sys_safecopy.c rename to lib/libsys/sys_safecopy.c diff --git a/lib/syslib/sys_safemap.c b/lib/libsys/sys_safemap.c similarity index 100% rename from lib/syslib/sys_safemap.c rename to lib/libsys/sys_safemap.c diff --git a/lib/syslib/sys_sdevio.c b/lib/libsys/sys_sdevio.c similarity index 100% rename from lib/syslib/sys_sdevio.c rename to lib/libsys/sys_sdevio.c diff --git a/lib/syslib/sys_segctl.c b/lib/libsys/sys_segctl.c similarity index 100% rename from lib/syslib/sys_segctl.c rename to lib/libsys/sys_segctl.c diff --git a/lib/syslib/sys_setalarm.c b/lib/libsys/sys_setalarm.c similarity index 100% rename from lib/syslib/sys_setalarm.c rename to lib/libsys/sys_setalarm.c diff --git a/lib/syslib/sys_setgrant.c b/lib/libsys/sys_setgrant.c similarity index 100% rename from lib/syslib/sys_setgrant.c rename to lib/libsys/sys_setgrant.c diff --git a/lib/syslib/sys_sigreturn.c b/lib/libsys/sys_sigreturn.c similarity index 100% rename from lib/syslib/sys_sigreturn.c rename to lib/libsys/sys_sigreturn.c diff --git a/lib/syslib/sys_sigsend.c b/lib/libsys/sys_sigsend.c similarity index 100% rename from lib/syslib/sys_sigsend.c rename to lib/libsys/sys_sigsend.c diff --git a/lib/syslib/sys_sprof.c b/lib/libsys/sys_sprof.c similarity index 100% rename from lib/syslib/sys_sprof.c rename to lib/libsys/sys_sprof.c diff --git a/lib/syslib/sys_stime.c b/lib/libsys/sys_stime.c similarity index 100% rename from lib/syslib/sys_stime.c rename to lib/libsys/sys_stime.c diff --git a/lib/syslib/sys_sysctl.c b/lib/libsys/sys_sysctl.c similarity index 100% rename from lib/syslib/sys_sysctl.c rename to lib/libsys/sys_sysctl.c diff --git a/lib/syslib/sys_times.c b/lib/libsys/sys_times.c similarity index 100% rename from lib/syslib/sys_times.c rename to lib/libsys/sys_times.c diff --git a/lib/syslib/sys_trace.c b/lib/libsys/sys_trace.c similarity index 100% rename from lib/syslib/sys_trace.c rename to lib/libsys/sys_trace.c diff --git a/lib/syslib/sys_umap.c b/lib/libsys/sys_umap.c similarity index 100% rename from lib/syslib/sys_umap.c rename to lib/libsys/sys_umap.c diff --git a/lib/syslib/sys_vinb.c b/lib/libsys/sys_vinb.c similarity index 100% rename from lib/syslib/sys_vinb.c rename to lib/libsys/sys_vinb.c diff --git a/lib/syslib/sys_vinl.c b/lib/libsys/sys_vinl.c similarity index 100% rename from lib/syslib/sys_vinl.c rename to lib/libsys/sys_vinl.c diff --git a/lib/syslib/sys_vinw.c b/lib/libsys/sys_vinw.c similarity index 100% rename from lib/syslib/sys_vinw.c rename to lib/libsys/sys_vinw.c diff --git a/lib/syslib/sys_vircopy.c b/lib/libsys/sys_vircopy.c similarity index 100% rename from lib/syslib/sys_vircopy.c rename to lib/libsys/sys_vircopy.c diff --git a/lib/syslib/sys_vmctl.c b/lib/libsys/sys_vmctl.c similarity index 100% rename from lib/syslib/sys_vmctl.c rename to lib/libsys/sys_vmctl.c diff --git a/lib/syslib/sys_voutb.c b/lib/libsys/sys_voutb.c similarity index 100% rename from lib/syslib/sys_voutb.c rename to lib/libsys/sys_voutb.c diff --git a/lib/syslib/sys_voutl.c b/lib/libsys/sys_voutl.c similarity index 100% rename from lib/syslib/sys_voutl.c rename to lib/libsys/sys_voutl.c diff --git a/lib/syslib/sys_voutw.c b/lib/libsys/sys_voutw.c similarity index 100% rename from lib/syslib/sys_voutw.c rename to lib/libsys/sys_voutw.c diff --git a/lib/syslib/sys_vsafecopy.c b/lib/libsys/sys_vsafecopy.c similarity index 100% rename from lib/syslib/sys_vsafecopy.c rename to lib/libsys/sys_vsafecopy.c diff --git a/lib/syslib/sys_vtimer.c b/lib/libsys/sys_vtimer.c similarity index 100% rename from lib/syslib/sys_vtimer.c rename to lib/libsys/sys_vtimer.c diff --git a/lib/syslib/syslib.h b/lib/libsys/syslib.h similarity index 100% rename from lib/syslib/syslib.h rename to lib/libsys/syslib.h diff --git a/lib/sysutil/sysutil.h b/lib/libsys/sysutil.h similarity index 100% rename from lib/sysutil/sysutil.h rename to lib/libsys/sysutil.h diff --git a/lib/syslib/taskcall.c b/lib/libsys/taskcall.c similarity index 100% rename from lib/syslib/taskcall.c rename to lib/libsys/taskcall.c diff --git a/lib/sysutil/tickdelay.c b/lib/libsys/tickdelay.c similarity index 100% rename from lib/sysutil/tickdelay.c rename to lib/libsys/tickdelay.c diff --git a/lib/sysutil/timing.c b/lib/libsys/timing.c similarity index 100% rename from lib/sysutil/timing.c rename to lib/libsys/timing.c diff --git a/lib/sysutil/tsc_util.c b/lib/libsys/tsc_util.c similarity index 100% rename from lib/sysutil/tsc_util.c rename to lib/libsys/tsc_util.c diff --git a/lib/syslib/vm_brk.c b/lib/libsys/vm_brk.c similarity index 100% rename from lib/syslib/vm_brk.c rename to lib/libsys/vm_brk.c diff --git a/lib/syslib/vm_exec_newmem.c b/lib/libsys/vm_exec_newmem.c similarity index 100% rename from lib/syslib/vm_exec_newmem.c rename to lib/libsys/vm_exec_newmem.c diff --git a/lib/syslib/vm_exit.c b/lib/libsys/vm_exit.c similarity index 100% rename from lib/syslib/vm_exit.c rename to lib/libsys/vm_exit.c diff --git a/lib/syslib/vm_fork.c b/lib/libsys/vm_fork.c similarity index 100% rename from lib/syslib/vm_fork.c rename to lib/libsys/vm_fork.c diff --git a/lib/syslib/vm_info.c b/lib/libsys/vm_info.c similarity index 100% rename from lib/syslib/vm_info.c rename to lib/libsys/vm_info.c diff --git a/lib/syslib/vm_map_phys.c b/lib/libsys/vm_map_phys.c similarity index 100% rename from lib/syslib/vm_map_phys.c rename to lib/libsys/vm_map_phys.c diff --git a/lib/syslib/vm_notify_sig.c b/lib/libsys/vm_notify_sig.c similarity index 100% rename from lib/syslib/vm_notify_sig.c rename to lib/libsys/vm_notify_sig.c diff --git a/lib/syslib/vm_push_sig.c b/lib/libsys/vm_push_sig.c similarity index 100% rename from lib/syslib/vm_push_sig.c rename to lib/libsys/vm_push_sig.c diff --git a/lib/syslib/vm_umap.c b/lib/libsys/vm_umap.c similarity index 100% rename from lib/syslib/vm_umap.c rename to lib/libsys/vm_umap.c diff --git a/lib/libtimers/Makefile b/lib/libtimers/Makefile new file mode 100644 index 000000000..1fbc03c3b --- /dev/null +++ b/lib/libtimers/Makefile @@ -0,0 +1,12 @@ +# Makefile for libtimers + +CPPFLAGS+=-O -D_MINIX -D_POSIX_SOURCE + +LIB= timers + +SRCS= \ + tmrs_set.c \ + tmrs_clr.c \ + tmrs_exp.c + +.include diff --git a/lib/timers/timers.h b/lib/libtimers/timers.h similarity index 100% rename from lib/timers/timers.h rename to lib/libtimers/timers.h diff --git a/lib/timers/tmrs_clr.c b/lib/libtimers/tmrs_clr.c similarity index 100% rename from lib/timers/tmrs_clr.c rename to lib/libtimers/tmrs_clr.c diff --git a/lib/timers/tmrs_exp.c b/lib/libtimers/tmrs_exp.c similarity index 100% rename from lib/timers/tmrs_exp.c rename to lib/libtimers/tmrs_exp.c diff --git a/lib/timers/tmrs_set.c b/lib/libtimers/tmrs_set.c similarity index 100% rename from lib/timers/tmrs_set.c rename to lib/libtimers/tmrs_set.c diff --git a/lib/libutil/Makefile b/lib/libutil/Makefile new file mode 100644 index 000000000..87b0cc488 --- /dev/null +++ b/lib/libutil/Makefile @@ -0,0 +1,9 @@ +# Makefile for libutil + +CPPFLAGS+=-O -D_MINIX -D_POSIX_SOURCE + +LIB= util + +SRCS= openpty.c + +.include diff --git a/lib/util/openpty.c b/lib/libutil/openpty.c similarity index 100% rename from lib/util/openpty.c rename to lib/libutil/openpty.c diff --git a/lib/regex/Makefile.in b/lib/regex/Makefile.in deleted file mode 100644 index 41b55e292..000000000 --- a/lib/regex/Makefile.in +++ /dev/null @@ -1,13 +0,0 @@ -# Makefile for lib/regex. - -CFLAGS="-O -D_MINIX -D_POSIX_SOURCE" - -LIBRARIES=libc - -libc_FILES=" \ - regcomp.c \ - regerror.c \ - regexec.c \ - regfree.c" - -TYPE=both diff --git a/lib/stdtime/Makefile.in b/lib/stdtime/Makefile.in deleted file mode 100644 index 64eb936a5..000000000 --- a/lib/stdtime/Makefile.in +++ /dev/null @@ -1,15 +0,0 @@ -# Makefile for lib/stdtime. - -Z=../../commands/zoneinfo - -CFLAGS="-D_MINIX -D_POSIX_SOURCE -D__USG -I$Z" - -LIBRARIES=libc -libc_FILES=" - ftime.c - asctime.c - localtime.c - strftime.c - " - -TYPE=both diff --git a/lib/sysutil/Makefile.in b/lib/sysutil/Makefile.in deleted file mode 100644 index 710a7b810..000000000 --- a/lib/sysutil/Makefile.in +++ /dev/null @@ -1,32 +0,0 @@ -# Makefile for lib/sysutil. - -CFLAGS="-O -D_MINIX -D_POSIX_SOURCE" - -LIBRARIES=libsys - -libsys_FILES=" \ - asynsend.c \ - kprintf.c \ - kputc.c \ - tickdelay.c \ - get_randomness.c \ - getidle.c \ - getuptime.c \ - getuptime2.c \ - env_get_prm.c \ - env_parse.c \ - env_panic.c \ - env_prefix.c \ - fkey_ctl.c \ - tsc_util.c \ - report.c \ - read_tsc.s \ - read_tsc_64.c \ - ser_putc.c \ - stacktrace.c \ - sys_hz.c \ - timing.c \ - profile_extern.c \ - profile.c" - -TYPE=both diff --git a/lib/sysvipc/Makefile.in b/lib/sysvipc/Makefile.in deleted file mode 100644 index 67f72e61c..000000000 --- a/lib/sysvipc/Makefile.in +++ /dev/null @@ -1,10 +0,0 @@ -# Makefile for lib/posix. - -CFLAGS="-O -D_MINIX -D_POSIX_SOURCE" - -LIBRARIES=libc - -libc_FILES="ftok.c sem.c shm.c" - -TYPE=both - diff --git a/lib/timers/Makefile.in b/lib/timers/Makefile.in deleted file mode 100644 index a01d94228..000000000 --- a/lib/timers/Makefile.in +++ /dev/null @@ -1,12 +0,0 @@ -# Makefile for lib/tmrslib. - -CFLAGS="-O -D_MINIX -D_POSIX_SOURCE" - -LIBRARIES=libtimers - -libtimers_FILES=" \ - tmrs_set.c \ - tmrs_clr.c \ - tmrs_exp.c" - -TYPE=both diff --git a/lib/util/Makefile.in b/lib/util/Makefile.in deleted file mode 100644 index 3ef1cb817..000000000 --- a/lib/util/Makefile.in +++ /dev/null @@ -1,9 +0,0 @@ -# Makefile for lib/util. - -CFLAGS="-O -D_MINIX -D_POSIX_SOURCE" - -LIBRARIES=libutil - -libutil_FILES=openpty.c - -TYPE=both diff --git a/man/man1/cc.1 b/man/man1/cc.1 index df903e0c5..e1ff13341 100644 --- a/man/man1/cc.1 +++ b/man/man1/cc.1 @@ -1,6 +1,6 @@ .TH CC 1 .SH NAME -cc, pc, m2 \- MINIX 3 C, Pascal, and Modula-2 compilers +cc \- MINIX 3 C compiler .SH SYNOPSIS .in +.5i .ti -.5i diff --git a/man/man1/make.1 b/man/man1/make.1 index 7e87f8a2d..efd7d0a16 100644 --- a/man/man1/make.1 +++ b/man/man1/make.1 @@ -1,76 +1,1846 @@ -.TH MAKE 1 -.SH NAME -make \- a program for maintaining large programs -.SH SYNOPSIS -\fBmake\fR [\fB\-f \fIfile\fR]\fR [\fB\-adeiknpqrst\fR] [\fIoption\fR] ... [\fItarget\fR]\fR -.br -.de FL -.TP -\\fB\\$1\\fR -\\$2 -.. -.de EX -.TP 20 -\\fB\\$1\\fR -# \\$2 -.. -.SH OPTIONS -.FL "\-f" "Use \fIfile\fP as the makefile" -.FL "\-d" "Print debugging information" -.FL "\-e" "Environment overrides makefile macros" -.FL "\-i" "Ignore status returned by commands" -.FL "\-k" "On error, skip to next command" -.FL "\-n" "Report, but do not execute" -.FL "\-p" "Print macros and targets" -.FL "\-q" "Question up-to-dateness of target" -.FL "\-r" "Rule inhibit; do not use default rules" -.FL "\-s" "Silent mode" -.FL "\-t" "Touch files instead of making them" -.SH EXAMPLES -.EX "make kernel" "Make \fIkernel\fP up to date" -.EX "make \-n \-f mfile" "Tell what needs to be done" -.SH DESCRIPTION -.PP -.I Make -is a program that is normally used for developing large programs consisting of -multiple files. -It keeps track of which object files depend on which source and header files. -When called, it does the minimum amount of recompilation to bring the target -file up to date. -.PP -The file dependencies are expected in -.I makefile +.\" $NetBSD: make.1,v 1.166 2009/11/19 06:48:37 wiz Exp $ +.\" +.\" Copyright (c) 1990, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)make.1 8.4 (Berkeley) 3/19/94 +.\" +.Dd November 15, 2009 +.Dt MAKE 1 +.Os +.Sh NAME +.Nm make +.Nd maintain program dependencies +.Sh SYNOPSIS +.Nm +.Op Fl BeikNnqrstWX +.Bk -words +.Op Fl C Ar directory +.Ek +.Bk -words +.Op Fl D Ar variable +.Ek +.Bk -words +.Op Fl d Ar flags +.Ek +.Bk -words +.Op Fl f Ar makefile +.Ek +.Bk -words +.Op Fl I Ar directory +.Ek +.Bk -words +.Op Fl J Ar private +.Ek +.Bk -words +.Op Fl j Ar max_jobs +.Ek +.Bk -words +.Op Fl m Ar directory +.Ek +.Bk -words +.Op Fl T Ar file +.Ek +.Bk -words +.Op Fl V Ar variable +.Ek +.Op Ar variable=value +.Bk -words +.Op Ar target ... +.Ek +.Sh DESCRIPTION +.Nm +is a program designed to simplify the maintenance of other programs. +Its input is a list of specifications as to the files upon which programs +and other files depend. +If no +.Fl f Ar makefile +makefile option is given, +.Nm +will try to open +.Ql Pa makefile +then +.Ql Pa Makefile +in order to find the specifications. +If the file +.Ql Pa .depend +exists, it is read (see +.Xr mkdep 1 ) . +.Pp +This manual page is intended as a reference document only. +For a more thorough description of +.Nm +and makefiles, please refer to +.%T "Make \- A Tutorial" . +.Pp +.Nm +will prepend the contents of the +.Va MAKEFLAGS +environment variable to the command line arguments before parsing them. +.Pp +The options are as follows: +.Bl -tag -width Ds +.It Fl B +Try to be backwards compatible by executing a single shell per command and +by executing the commands to make the sources of a dependency line in sequence. +.It Fl C Ar directory +Change to +.Ar directory +before reading the makefiles or doing anything else. +If multiple +.Fl C +options are specified, each is interpreted relative to the previous one: +.Fl C Pa / Fl C Pa etc +is equivalent to +.Fl C Pa /etc . +.It Fl D Ar variable +Define +.Ar variable +to be 1, in the global context. +.It Fl d Ar [-]flags +Turn on debugging, and specify which portions of +.Nm +are to print debugging information. +Unless the flags are preceded by +.Ql - +they are added to the +.Va MAKEFLAGS +environment variable and will be processed by any child make processes. +By default, debugging information is printed to standard error, +but this can be changed using the +.Ar F +debugging flag. +The debugging output is always unbuffered; in addition, if debugging +is enabled but debugging output is not directed to standard output, +then the standard output is line buffered. +.Ar Flags +is one or more of the following: +.Bl -tag -width Ds +.It Ar A +Print all possible debugging information; +equivalent to specifying all of the debugging flags. +.It Ar a +Print debugging information about archive searching and caching. +.It Ar C +Print debugging information about current working directory. +.It Ar c +Print debugging information about conditional evaluation. +.It Ar d +Print debugging information about directory searching and caching. +.It Ar e +Print debugging information about failed commands and targets. +.It Ar F Ns Oo Sy \&+ Oc Ns Ar filename +Specify where debugging output is written. +This must be the last flag, because it consumes the remainder of +the argument. +If the character immediately after the +.Ql F +flag is +.Ql \&+ , +then the file will be opened in append mode; +otherwise the file will be overwritten. +If the file name is +.Ql stdout or -.I Makefile , -unless another file is specified with \fB\-f\fR. -.I Make -has some default rules built in, for example, it knows how to make -.I .o -files -from -.I .c +.Ql stderr +then debugging output will be written to the +standard output or standard error output file descriptors respectively +(and the +.Ql \&+ +option has no effect). +Otherwise, the output will be written to the named file. +If the file name ends +.Ql .%d +then the +.Ql %d +is replaced by the pid. +.It Ar f +Print debugging information about loop evaluation. +.It Ar "g1" +Print the input graph before making anything. +.It Ar "g2" +Print the input graph after making everything, or before exiting +on error. +.It Ar "g3" +Print the input graph before exiting on error. +.It Ar j +Print debugging information about running multiple shells. +.It Ar l +Print commands in Makefiles regardless of whether or not they are prefixed by +.Ql @ +or other "quiet" flags. +Also known as "loud" behavior. +.It Ar m +Print debugging information about making targets, including modification +dates. +.It Ar n +Don't delete the temporary command scripts created when running commands. +These temporary scripts are created in the directory +referred to by the +.Ev TMPDIR +environment variable, or in +.Pa /tmp +if +.Ev TMPDIR +is unset or set to the empty string. +The temporary scripts are created by +.Xr mkstemp 3 , +and have names of the form +.Pa makeXXXXXX . +.Em NOTE : +This can create many files in +.Ev TMPDIR +or +.Pa /tmp , +so use with care. +.It Ar p +Print debugging information about makefile parsing. +.It Ar s +Print debugging information about suffix-transformation rules. +.It Ar t +Print debugging information about target list maintenance. +.It Ar v +Print debugging information about variable assignment. +.It Ar x +Run shell commands with +.Fl x +so the actual commands are printed as they are executed. +.El +.It Fl e +Specify that environment variables override macro assignments within +makefiles. +.It Fl f Ar makefile +Specify a makefile to read instead of the default +.Ql Pa makefile . +If +.Ar makefile +is +.Ql Fl , +standard input is read. +Multiple makefiles may be specified, and are read in the order specified. +.It Fl I Ar directory +Specify a directory in which to search for makefiles and included makefiles. +The system makefile directory (or directories, see the +.Fl m +option) is automatically included as part of this list. +.It Fl i +Ignore non-zero exit of shell commands in the makefile. +Equivalent to specifying +.Ql Fl +before each command line in the makefile. +.It Fl J Ar private +This option should +.Em not +be specified by the user. +.Pp +When the +.Ar j +option is in use in a recursive build, this option is passed by a make +to child makes to allow all the make processes in the build to +cooperate to avoid overloading the system. +.It Fl j Ar max_jobs +Specify the maximum number of jobs that +.Nm +may have running at any one time. +Turns compatibility mode off, unless the +.Ar B +flag is also specified. +When compatibility mode is off, all commands associated with a +target are executed in a single shell invocation as opposed to the +traditional one shell invocation per line. +This can break traditional scripts which change directories on each +command invocation and then expect to start with a fresh environment +on the next line. +It is more efficient to correct the scripts rather than turn backwards +compatibility on. +.It Fl k +Continue processing after errors are encountered, but only on those targets +that do not depend on the target whose creation caused the error. +.It Fl m Ar directory +Specify a directory in which to search for sys.mk and makefiles included +via the +.Ao Ar file Ac Ns -style +include statement. +The +.Fl m +option can be used multiple times to form a search path. +This path will override the default system include path: /etc/mk. +Furthermore the system include path will be appended to the search path used +for +.Qo Ar file Qc Ns -style +include statements (see the +.Fl I +option). +.Pp +If a file or directory name in the +.Fl m +argument (or the +.Ev MAKESYSPATH +environment variable) starts with the string +.Qq \&.../ +then +.Nm +will search for the specified file or directory named in the remaining part +of the argument string. +The search starts with the current directory of +the Makefile and then works upward towards the root of the filesystem. +If the search is successful, then the resulting directory replaces the +.Qq \&.../ +specification in the +.Fl m +argument. +If used, this feature allows +.Nm +to easily search in the current source tree for customized sys.mk files +(e.g., by using +.Qq \&.../mk/sys.mk +as an argument). +.It Fl n +Display the commands that would have been executed, but do not +actually execute them unless the target depends on the .MAKE special +source (see below). +.It Fl N +Display the commands which would have been executed, but do not +actually execute any of them; useful for debugging top-level makefiles +without descending into subdirectories. +.It Fl q +Do not execute any commands, but exit 0 if the specified targets are +up-to-date and 1, otherwise. +.It Fl r +Do not use the built-in rules specified in the system makefile. +.It Fl s +Do not echo any commands as they are executed. +Equivalent to specifying +.Ql Ic @ +before each command line in the makefile. +.It Fl T Ar tracefile +When used with the +.Fl j +flag, +append a trace record to +.Ar tracefile +for each job started and completed. +.It Fl t +Rather than re-building a target as specified in the makefile, create it +or update its modification time to make it appear up-to-date. +.It Fl V Ar variable +Print +.Nm Ns 's +idea of the value of +.Ar variable , +in the global context. +Do not build any targets. +Multiple instances of this option may be specified; +the variables will be printed one per line, +with a blank line for each null or undefined variable. +If +.Ar variable +contains a +.Ql \&$ +then the value will be expanded before printing. +.It Fl W +Treat any warnings during makefile parsing as errors. +.It Fl X +Don't export variables passed on the command line to the environment +individually. +Variables passed on the command line are still exported +via the +.Va MAKEFLAGS +environment variable. +This option may be useful on systems which have a small limit on the +size of command arguments. +.It Ar variable=value +Set the value of the variable +.Ar variable +to +.Ar value . +Normally, all values passed on the command line are also exported to +sub-makes in the environment. +The +.Fl X +flag disables this behavior. +Variable assignments should follow options for POSIX compatibility +but no ordering is enforced. +.El +.Pp +There are seven different types of lines in a makefile: file dependency +specifications, shell commands, variable assignments, include statements, +conditional directives, for loops, and comments. +.Pp +In general, lines may be continued from one line to the next by ending +them with a backslash +.Pq Ql \e . +The trailing newline character and initial whitespace on the following +line are compressed into a single space. +.Sh FILE DEPENDENCY SPECIFICATIONS +Dependency lines consist of one or more targets, an operator, and zero +or more sources. +This creates a relationship where the targets +.Dq depend +on the sources +and are usually created from them. +The exact relationship between the target and the source is determined +by the operator that separates them. +The three operators are as follows: +.Bl -tag -width flag +.It Ic \&: +A target is considered out-of-date if its modification time is less than +those of any of its sources. +Sources for a target accumulate over dependency lines when this operator +is used. +The target is removed if +.Nm +is interrupted. +.It Ic \&! +Targets are always re-created, but not until all sources have been +examined and re-created as necessary. +Sources for a target accumulate over dependency lines when this operator +is used. +The target is removed if +.Nm +is interrupted. +.It Ic \&:: +If no sources are specified, the target is always re-created. +Otherwise, a target is considered out-of-date if any of its sources has +been modified more recently than the target. +Sources for a target do not accumulate over dependency lines when this +operator is used. +The target will not be removed if +.Nm +is interrupted. +.El +.Pp +Targets and sources may contain the shell wildcard values +.Ql \&? , +.Ql * , +.Ql [] , +and +.Ql {} . +The values +.Ql \&? , +.Ql * , +and +.Ql [] +may only be used as part of the final +component of the target or source, and must be used to describe existing files. -Here is a sample -.I makefile . -.PP -.nf -.ta +0.2i +\w'program:'u+1m +\w'cc \-o program head.o tail.o'u+2m - d=/user/ast # \fId\fP is a macro - program: head.o tail.o # \fIprogram\fR depends on these - cc \-o program head.o tail.o # tells how to make \fIprogram\fP - echo Program done. # announce completion - head.o: $d/def.h head.c # \fIhead.o\fP depends on these +The value +.Ql {} +need not necessarily be used to describe existing files. +Expansion is in directory order, not alphabetically as done in the shell. +.Sh SHELL COMMANDS +Each target may have associated with it a series of shell commands, normally +used to create the target. +Each of the commands in this script +.Em must +be preceded by a tab. +While any target may appear on a dependency line, only one of these +dependencies may be followed by a creation script, unless the +.Ql Ic \&:: +operator is used. +.Pp +If the first characters of the command line are any combination of +.Ql Ic @ , +.Ql Ic + , +or +.Ql Ic \- , +the command is treated specially. +A +.Ql Ic @ +causes the command not to be echoed before it is executed. +A +.Ql Ic + +causes the command to be executed even when +.Fl n +is given. +This is similar to the effect of the .MAKE special source, +except that the effect can be limited to a single line of a script. +A +.Ql Ic \- +causes any non-zero exit status of the command line to be ignored. +.Sh VARIABLE ASSIGNMENTS +Variables in make are much like variables in the shell, and, by tradition, +consist of all upper-case letters. +.Ss Variable assignment modifiers +The five operators that can be used to assign values to variables are as +follows: +.Bl -tag -width Ds +.It Ic \&= +Assign the value to the variable. +Any previous value is overridden. +.It Ic \&+= +Append the value to the current value of the variable. +.It Ic \&?= +Assign the value to the variable if it is not already defined. +.It Ic \&:= +Assign with expansion, i.e. expand the value before assigning it +to the variable. +Normally, expansion is not done until the variable is referenced. +.Em NOTE : +References to undefined variables are +.Em not +expanded. +This can cause problems when variable modifiers are used. +.It Ic \&!= +Expand the value and pass it to the shell for execution and assign +the result to the variable. +Any newlines in the result are replaced with spaces. +.El +.Pp +Any white-space before the assigned +.Ar value +is removed; if the value is being appended, a single space is inserted +between the previous contents of the variable and the appended value. +.Pp +Variables are expanded by surrounding the variable name with either +curly braces +.Pq Ql {} +or parentheses +.Pq Ql () +and preceding it with +a dollar sign +.Pq Ql \&$ . +If the variable name contains only a single letter, the surrounding +braces or parentheses are not required. +This shorter form is not recommended. +.Pp +If the variable name contains a dollar, then the name itself is expanded first. +This allows almost arbitrary variable names, however names containing dollar, +braces, parenthesis, or whitespace are really best avoided! +.Pp +If the result of expanding a variable contains a dollar sign +.Pq Ql \&$ +the string is expanded again. +.Pp +Variable substitution occurs at two distinct times, depending on where +the variable is being used. +Variables in dependency lines are expanded as the line is read. +Variables in shell commands are expanded when the shell command is +executed. +.Ss Variable classes +The four different classes of variables (in order of increasing precedence) +are: +.Bl -tag -width Ds +.It Environment variables +Variables defined as part of +.Nm Ns 's +environment. +.It Global variables +Variables defined in the makefile or in included makefiles. +.It Command line variables +Variables defined as part of the command line. +.It Local variables +Variables that are defined specific to a certain target. +The seven local variables are as follows: +.Bl -tag -width ".ARCHIVE" +.It Va .ALLSRC +The list of all sources for this target; also known as +.Ql Va \&\*[Gt] . +.It Va .ARCHIVE +The name of the archive file. +.It Va .IMPSRC +In suffix-transformation rules, the name/path of the source from which the +target is to be transformed (the +.Dq implied +source); also known as +.Ql Va \&\*[Lt] . +It is not defined in explicit rules. +.It Va .MEMBER +The name of the archive member. +.It Va .OODATE +The list of sources for this target that were deemed out-of-date; also +known as +.Ql Va \&? . +.It Va .PREFIX +The file prefix of the file, containing only the file portion, no suffix +or preceding directory components; also known as +.Ql Va * . +.It Va .TARGET +The name of the target; also known as +.Ql Va @ . +.El +.Pp +The shorter forms +.Ql Va @ , +.Ql Va \&? , +.Ql Va \&\*[Lt] , +.Ql Va \&\*[Gt] , +and +.Ql Va * +are permitted for backward +compatibility with historical makefiles and are not recommended. +The six variables +.Ql Va "@F" , +.Ql Va "@D" , +.Ql Va "\*[Lt]F" , +.Ql Va "\*[Lt]D" , +.Ql Va "*F" , +and +.Ql Va "*D" +are permitted for compatibility with +.At V +makefiles and are not recommended. +.Pp +Four of the local variables may be used in sources on dependency lines +because they expand to the proper value for each target on the line. +These variables are +.Ql Va .TARGET , +.Ql Va .PREFIX , +.Ql Va .ARCHIVE , +and +.Ql Va .MEMBER . +.El +.Ss Additional built-in variables +In addition, +.Nm +sets or knows about the following variables: +.Bl -tag -width .MAKEOVERRIDES +.It Va \&$ +A single dollar sign +.Ql \&$ , +i.e. +.Ql \&$$ +expands to a single dollar +sign. +.It Va .ALLTARGETS +The list of all targets encountered in the Makefile. +If evaluated during +Makefile parsing, lists only those targets encountered thus far. +.It Va .CURDIR +A path to the directory where +.Nm +was executed. +Refer to the description of +.Ql Ev PWD +for more details. +.It Ev MAKE +The name that +.Nm +was executed with +.Pq Va argv[0] . +For compatibility +.Nm +also sets +.Va .MAKE +with the same value. +The preferred variable to use is the environment variable +.Ev MAKE +because it is more compatible with other versions of +.Nm +and cannot be confused with the special target with the same name. +.It Va .MAKE.EXPORTED +The list of variables exported by +.Nm . +.It Va .MAKE.MAKEFILES +The list of makefiles read by +.Nm , +which is useful for tracking dependencies. +Each makefile is recorded only once, regardless of the number of times read. +.It Va .MAKE.LEVEL +The recursion depth of +.Nm . +The initial instance of +.Nm +will be 0, and an incremented value is put into the environment +to be seen by the next generation. +This allows tests like: +.Li .if ${.MAKE.LEVEL} == 0 +to protect things which should only be evaluated in the initial instance of +.Nm . +.It Va .MAKE.PID +The process-id of +.Nm . +.It Va .MAKE.PPID +The parent process-id of +.Nm . +.It Va .MAKE.JOB.PREFIX +If +.Nm +is run with +.Ar j +then output for each target is prefixed with a token +.Ql --- target --- +the first part of which can be controlled via +.Va .MAKE.JOB.PREFIX . .br - tail.o: $d/var.h tail.c # \fItail.o\fP depends on these -.PP -.fi -A complete description of \fImake\fR would require too much space here. -Many books on -\s-2UNIX\s+2 -discuss -.I make . -Study the numerous \fIMakefiles\fR in the -\s-1MINIX 3\s-1 -source tree for examples. -.SH "SEE ALSO" -.BR cc (1). +For example: +.Li .MAKE.JOB.PREFIX=${.newline}---${.MAKE:T}[${.MAKE.PID}] +would produce tokens like +.Ql ---make[1234] target --- +making it easier to track the degree of parallelism being achieved. +.It Ev MAKEFLAGS +The environment variable +.Ql Ev MAKEFLAGS +may contain anything that +may be specified on +.Nm Ns 's +command line. +Anything specified on +.Nm Ns 's +command line is appended to the +.Ql Ev MAKEFLAGS +variable which is then +entered into the environment for all programs which +.Nm +executes. +.It Va .MAKEOVERRIDES +This variable is used to record the names of variables assigned to +on the command line, so that they may be exported as part of +.Ql Ev MAKEFLAGS . +This behaviour can be disabled by assigning an empty value to +.Ql Va .MAKEOVERRIDES +within a makefile. +Extra variables can be exported from a makefile +by appending their names to +.Ql Va .MAKEOVERRIDES . +.Ql Ev MAKEFLAGS +is re-exported whenever +.Ql Va .MAKEOVERRIDES +is modified. +.It Va MAKE_PRINT_VAR_ON_ERROR +When +.Nm +stops due to an error, it prints its name and the value of +.Ql Va .CURDIR +as well as the value of any variables named in +.Ql Va MAKE_PRINT_VAR_ON_ERROR . +.It Va .newline +This variable is simply assigned a newline character as its value. +This allows expansions using the +.Cm \&:@ +modifier to put a newline between +iterations of the loop rather than a space. +For example, the printing of +.Ql Va MAKE_PRINT_VAR_ON_ERROR +could be done as ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}. +.It Va .OBJDIR +A path to the directory where the targets are built. +Its value is determined by trying to +.Xr chdir 2 +to the following directories in order and using the first match: +.Bl -enum +.It +.Ev ${MAKEOBJDIRPREFIX}${.CURDIR} +.Pp +(Only if +.Ql Ev MAKEOBJDIRPREFIX +is set in the environment or on the command line.) +.It +.Ev ${MAKEOBJDIR} +.Pp +(Only if +.Ql Ev MAKEOBJDIR +is set in the environment or on the command line.) +.It +.Ev ${.CURDIR} Ns Pa /obj. Ns Ev ${MACHINE} +.It +.Ev ${.CURDIR} Ns Pa /obj +.It +.Pa /usr/obj/ Ns Ev ${.CURDIR} +.It +.Ev ${.CURDIR} +.El +.Pp +Variable expansion is performed on the value before it's used, +so expressions such as +.Dl ${.CURDIR:C,^/usr/src,/var/obj,} +may be used. +.Pp +.Ql Va .OBJDIR +may be modified in the makefile as a global variable. +In all cases, +.Nm +will +.Xr chdir 2 +to +.Ql Va .OBJDIR +and set +.Ql Ev PWD +to that directory before executing any targets. +. +.It Va .PARSEDIR +A path to the directory of the current +.Ql Pa Makefile +being parsed. +.It Va .PARSEFILE +The basename of the current +.Ql Pa Makefile +being parsed. +This variable and +.Ql Va .PARSEDIR +are both set only while the +.Ql Pa Makefiles +are being parsed. +.It Va .PATH +A variable that represents the list of directories that +.Nm +will search for files. +The search list should be updated using the target +.Ql Va .PATH +rather than the variable. +.It Ev PWD +Alternate path to the current directory. +.Nm +normally sets +.Ql Va .CURDIR +to the canonical path given by +.Xr getcwd 3 . +However, if the environment variable +.Ql Ev PWD +is set and gives a path to the current directory, then +.Nm +sets +.Ql Va .CURDIR +to the value of +.Ql Ev PWD +instead. +This behaviour is disabled if +.Ql Ev MAKEOBJDIRPREFIX +is set or +.Ql Ev MAKEOBJDIR +contains a variable transform. +.Ql Ev PWD +is set to the value of +.Ql Va .OBJDIR +for all programs which +.Nm +executes. +.It Ev VPATH +Colon-separated +.Pq Dq \&: +lists of directories that +.Nm +will search for files. +The variable is supported for compatibility with old make programs only, +use +.Ql Va .PATH +instead. +.El +.Ss Variable modifiers +Variable expansion may be modified to select or modify each word of the +variable (where a +.Dq word +is white-space delimited sequence of characters). +The general format of a variable expansion is as follows: +.Pp +.Dl ${variable[:modifier[:...]]} +.Pp +Each modifier begins with a colon, +which may be escaped with a backslash +.Pq Ql \e . +.Pp +A set of modifiers can be specified via a variable, as follows: +.Pp +.Dl modifier_variable=modifier[:...] +.Dl ${variable:${modifier_variable}[:...]} +.Pp +In this case the first modifier in the modifier_variable does not +start with a colon, since that must appear in the referencing +variable. +If any of the modifiers in the modifier_variable contain a dollar sign +.Pq Ql $ , +these must be doubled to avoid early expansion. +.Pp +The supported modifiers are: +.Bl -tag -width EEE +.It Cm \&:E +Replaces each word in the variable with its suffix. +.It Cm \&:H +Replaces each word in the variable with everything but the last component. +.It Cm \&:M Ns Ar pattern +Select only those words that match +.Ar pattern . +The standard shell wildcard characters +.Pf ( Ql * , +.Ql \&? , +and +.Ql Op ) +may +be used. +The wildcard characters may be escaped with a backslash +.Pq Ql \e . +.It Cm \&:N Ns Ar pattern +This is identical to +.Ql Cm \&:M , +but selects all words which do not match +.Ar pattern . +.It Cm \&:O +Order every word in variable alphabetically. +To sort words in +reverse order use the +.Ql Cm \&:O:[-1..1] +combination of modifiers. +.It Cm \&:Ox +Randomize words in variable. +The results will be different each time you are referring to the +modified variable; use the assignment with expansion +.Pq Ql Cm \&:= +to prevent such behaviour. +For example, +.Bd -literal -offset indent +LIST= uno due tre quattro +RANDOM_LIST= ${LIST:Ox} +STATIC_RANDOM_LIST:= ${LIST:Ox} + +all: + @echo "${RANDOM_LIST}" + @echo "${RANDOM_LIST}" + @echo "${STATIC_RANDOM_LIST}" + @echo "${STATIC_RANDOM_LIST}" +.Ed +may produce output similar to: +.Bd -literal -offset indent +quattro due tre uno +tre due quattro uno +due uno quattro tre +due uno quattro tre +.Ed +.It Cm \&:Q +Quotes every shell meta-character in the variable, so that it can be passed +safely through recursive invocations of +.Nm . +.It Cm \&:R +Replaces each word in the variable with everything but its suffix. +.It Cm \&:tl +Converts variable to lower-case letters. +.It Cm \&:ts Ns Ar c +Words in the variable are normally separated by a space on expansion. +This modifier sets the separator to the character +.Ar c . +If +.Ar c +is omitted, then no separator is used. +.It Cm \&:tu +Converts variable to upper-case letters. +.It Cm \&:tW +Causes the value to be treated as a single word +(possibly containing embedded white space). +See also +.Ql Cm \&:[*] . +.It Cm \&:tw +Causes the value to be treated as a sequence of +words delimited by white space. +See also +.Ql Cm \&:[@] . +.Sm off +.It Cm \&:S No \&/ Ar old_string No \&/ Ar new_string No \&/ Op Cm 1gW +.Sm on +Modify the first occurrence of +.Ar old_string +in the variable's value, replacing it with +.Ar new_string . +If a +.Ql g +is appended to the last slash of the pattern, all occurrences +in each word are replaced. +If a +.Ql 1 +is appended to the last slash of the pattern, only the first word +is affected. +If a +.Ql W +is appended to the last slash of the pattern, +then the value is treated as a single word +(possibly containing embedded white space). +If +.Ar old_string +begins with a caret +.Pq Ql ^ , +.Ar old_string +is anchored at the beginning of each word. +If +.Ar old_string +ends with a dollar sign +.Pq Ql \&$ , +it is anchored at the end of each word. +Inside +.Ar new_string , +an ampersand +.Pq Ql \*[Am] +is replaced by +.Ar old_string +(without any +.Ql ^ +or +.Ql \&$ ) . +Any character may be used as a delimiter for the parts of the modifier +string. +The anchoring, ampersand and delimiter characters may be escaped with a +backslash +.Pq Ql \e . +.Pp +Variable expansion occurs in the normal fashion inside both +.Ar old_string +and +.Ar new_string +with the single exception that a backslash is used to prevent the expansion +of a dollar sign +.Pq Ql \&$ , +not a preceding dollar sign as is usual. +.Sm off +.It Cm \&:C No \&/ Ar pattern No \&/ Ar replacement No \&/ Op Cm 1gW +.Sm on +The +.Cm \&:C +modifier is just like the +.Cm \&:S +modifier except that the old and new strings, instead of being +simple strings, are a regular expression (see +.Xr regex 3 ) +string +.Ar pattern +and an +.Xr ed 1 Ns \-style +string +.Ar replacement . +Normally, the first occurrence of the pattern +.Ar pattern +in each word of the value is substituted with +.Ar replacement . +The +.Ql 1 +modifier causes the substitution to apply to at most one word; the +.Ql g +modifier causes the substitution to apply to as many instances of the +search pattern +.Ar pattern +as occur in the word or words it is found in; the +.Ql W +modifier causes the value to be treated as a single word +(possibly containing embedded white space). +Note that +.Ql 1 +and +.Ql g +are orthogonal; the former specifies whether multiple words are +potentially affected, the latter whether multiple substitutions can +potentially occur within each affected word. +.It Cm \&:T +Replaces each word in the variable with its last component. +.It Cm \&:u +Remove adjacent duplicate words (like +.Xr uniq 1 ) . +.Sm off +.It Cm \&:\&? Ar true_string Cm \&: Ar false_string +.Sm on +If the variable name (not its value), when parsed as a .if conditional +expression, evaluates to true, return as its value the +.Ar true_string , +otherwise return the +.Ar false_string . +Since the variable name is used as the expression, \&:\&? must be the +first modifier after the variable name itself - which will, of course, +usually contain variable expansions. +A common error is trying to use expressions like +.Dl ${NUMBERS:M42:?match:no} +which actually tests defined(NUMBERS), +to determine is any words match "42" you need to use something like: +.Dl ${${NUMBERS:M42} != "":?match:no} . +.It Ar :old_string=new_string +This is the +.At V +style variable substitution. +It must be the last modifier specified. +If +.Ar old_string +or +.Ar new_string +do not contain the pattern matching character +.Ar % +then it is assumed that they are +anchored at the end of each word, so only suffixes or entire +words may be replaced. +Otherwise +.Ar % +is the substring of +.Ar old_string +to be replaced in +.Ar new_string . +.Pp +Variable expansion occurs in the normal fashion inside both +.Ar old_string +and +.Ar new_string +with the single exception that a backslash is used to prevent the +expansion of a dollar sign +.Pq Ql \&$ , +not a preceding dollar sign as is usual. +.Sm off +.It Cm \&:@ Ar temp Cm @ Ar string Cm @ +.Sm on +This is the loop expansion mechanism from the OSF Development +Environment (ODE) make. +Unlike +.Cm \&.for +loops expansion occurs at the time of +reference. +Assign +.Ar temp +to each word in the variable and evaluate +.Ar string . +The ODE convention is that +.Ar temp +should start and end with a period. +For example. +.Dl ${LINKS:@.LINK.@${LN} ${TARGET} ${.LINK.}@} +.It Cm \&:U Ns Ar newval +If the variable is undefined +.Ar newval +is the value. +If the variable is defined, the existing value is returned. +This is another ODE make feature. +It is handy for setting per-target CFLAGS for instance: +.Dl ${_${.TARGET:T}_CFLAGS:U${DEF_CFLAGS}} +If a value is only required if the variable is undefined, use: +.Dl ${VAR:D:Unewval} +.It Cm \&:D Ns Ar newval +If the variable is defined +.Ar newval +is the value. +.It Cm \&:L +The name of the variable is the value. +.It Cm \&:P +The path of the node which has the same name as the variable +is the value. +If no such node exists or its path is null, then the +name of the variable is used. +.Sm off +.It Cm \&:\&! Ar cmd Cm \&! +.Sm on +The output of running +.Ar cmd +is the value. +.It Cm \&:sh +If the variable is non-empty it is run as a command and the output +becomes the new value. +.It Cm \&::= Ns Ar str +The variable is assigned the value +.Ar str +after substitution. +This modifier and its variations are useful in +obscure situations such as wanting to set a variable when shell commands +are being parsed. +These assignment modifiers always expand to +nothing, so if appearing in a rule line by themselves should be +preceded with something to keep +.Nm +happy. +.Pp +The +.Ql Cm \&:: +helps avoid false matches with the +.At V +style +.Cm \&:= +modifier and since substitution always occurs the +.Cm \&::= +form is vaguely appropriate. +.It Cm \&::?= Ns Ar str +As for +.Cm \&::= +but only if the variable does not already have a value. +.It Cm \&::+= Ns Ar str +Append +.Ar str +to the variable. +.It Cm \&::!= Ns Ar cmd +Assign the output of +.Ar cmd +to the variable. +.It Cm \&:\&[ Ns Ar range Ns Cm \&] +Selects one or more words from the value, +or performs other operations related to the way in which the +value is divided into words. +.Pp +Ordinarily, a value is treated as a sequence of words +delimited by white space. +Some modifiers suppress this behaviour, +causing a value to be treated as a single word +(possibly containing embedded white space). +An empty value, or a value that consists entirely of white-space, +is treated as a single word. +For the purposes of the +.Ql Cm \&:[] +modifier, the words are indexed both forwards using positive integers +(where index 1 represents the first word), +and backwards using negative integers +(where index -1 represents the last word). +.Pp +The +.Ar range +is subjected to variable expansion, and the expanded result is +then interpreted as follows: +.Bl -tag -width index +.\" :[n] +.It Ar index +Selects a single word from the value. +.\" :[start..end] +.It Ar start Ns Cm \&.. Ns Ar end +Selects all words from +.Ar start +to +.Ar end , +inclusive. +For example, +.Ql Cm \&:[2..-1] +selects all words from the second word to the last word. +If +.Ar start +is greater than +.Ar end , +then the words are output in reverse order. +For example, +.Ql Cm \&:[-1..1] +selects all the words from last to first. +.\" :[*] +.It Cm \&* +Causes subsequent modifiers to treat the value as a single word +(possibly containing embedded white space). +Analogous to the effect of +\&"$*\&" +in Bourne shell. +.\" :[0] +.It 0 +Means the same as +.Ql Cm \&:[*] . +.\" :[*] +.It Cm \&@ +Causes subsequent modifiers to treat the value as a sequence of words +delimited by white space. +Analogous to the effect of +\&"$@\&" +in Bourne shell. +.\" :[#] +.It Cm \&# +Returns the number of words in the value. +.El \" :[range] +.El +.Sh INCLUDE STATEMENTS, CONDITIONALS AND FOR LOOPS +Makefile inclusion, conditional structures and for loops reminiscent +of the C programming language are provided in +.Nm . +All such structures are identified by a line beginning with a single +dot +.Pq Ql \&. +character. +Files are included with either +.Cm \&.include Aq Ar file +or +.Cm \&.include Pf \*q Ar file Ns \*q . +Variables between the angle brackets or double quotes are expanded +to form the file name. +If angle brackets are used, the included makefile is expected to be in +the system makefile directory. +If double quotes are used, the including makefile's directory and any +directories specified using the +.Fl I +option are searched before the system +makefile directory. +For compatibility with other versions of +.Nm +.Ql include file ... +is also accepted. +If the include statement is written as +.Cm .-include +or as +.Cm .sinclude +then errors locating and/or opening include files are ignored. +.Pp +Conditional expressions are also preceded by a single dot as the first +character of a line. +The possible conditionals are as follows: +.Bl -tag -width Ds +.It Ic .export Ar variable ... +Export the specified global variable. +If no variable list is provided, all globals are exported +except for internal variables (those that start with +.Ql \&. ) . +This is not affected by the +.Fl X +flag, so should be used with caution. +.Pp +Appending a variable name to +.Va .MAKE.EXPORTED +is equivalent to exporting a variable. +.It Ic .unexport Ar variable ... +The opposite of +.Ql .export . +The specified global +.Va variable +will be removed from +.Va .MAKE.EXPORTED . +If no variable list is provided, all globals are unexported, +and +.Va .MAKE.EXPORTED +deleted. +.It Ic .unexport-env +Unexport all globals previously exported and +clear the environment inherited from the parent. +This operation will cause a memory leak of the original environment, +so should be used sparingly. +Testing for +.Va .MAKE.LEVEL +being 0, would make sense. +Also note that any variables which originated in the parent environment +should be explicitly preserved if desired. +For example: +.Bd -literal -offset indent +.Li .if ${.MAKE.LEVEL} == 0 +PATH := ${PATH} +.Li .unexport-env +.Li .export PATH +.Li .endif +.Pp +.Ed +Would result in an environment containing only +.Ql Ev PATH , +which is the minimal useful environment. +Actually +.Ql Ev .MAKE.LEVEL +will also be pushed into the new environment. +.It Ic .undef Ar variable +Un-define the specified global variable. +Only global variables may be un-defined. +.It Ic \&.if Oo \&! Oc Ns Ar expression Op Ar operator expression ... +Test the value of an expression. +.It Ic .ifdef Oo \&! Oc Ns Ar variable Op Ar operator variable ... +Test the value of a variable. +.It Ic .ifndef Oo \&! Oc Ns Ar variable Op Ar operator variable ... +Test the value of a variable. +.It Ic .ifmake Oo \&! Oc Ns Ar target Op Ar operator target ... +Test the target being built. +.It Ic .ifnmake Oo \&! Ns Oc Ar target Op Ar operator target ... +Test the target being built. +.It Ic .else +Reverse the sense of the last conditional. +.It Ic .elif Oo \&! Ns Oc Ar expression Op Ar operator expression ... +A combination of +.Ql Ic .else +followed by +.Ql Ic .if . +.It Ic .elifdef Oo \&! Oc Ns Ar variable Op Ar operator variable ... +A combination of +.Ql Ic .else +followed by +.Ql Ic .ifdef . +.It Ic .elifndef Oo \&! Oc Ns Ar variable Op Ar operator variable ... +A combination of +.Ql Ic .else +followed by +.Ql Ic .ifndef . +.It Ic .elifmake Oo \&! Oc Ns Ar target Op Ar operator target ... +A combination of +.Ql Ic .else +followed by +.Ql Ic .ifmake . +.It Ic .elifnmake Oo \&! Oc Ns Ar target Op Ar operator target ... +A combination of +.Ql Ic .else +followed by +.Ql Ic .ifnmake . +.It Ic .endif +End the body of the conditional. +.El +.Pp +The +.Ar operator +may be any one of the following: +.Bl -tag -width "Cm XX" +.It Cm \&|\&| +Logical OR. +.It Cm \&\*[Am]\*[Am] +Logical +.Tn AND ; +of higher precedence than +.Dq \&|\&| . +.El +.Pp +As in C, +.Nm +will only evaluate a conditional as far as is necessary to determine +its value. +Parentheses may be used to change the order of evaluation. +The boolean operator +.Ql Ic \&! +may be used to logically negate an entire +conditional. +It is of higher precedence than +.Ql Ic \&\*[Am]\*[Am] . +.Pp +The value of +.Ar expression +may be any of the following: +.Bl -tag -width defined +.It Ic defined +Takes a variable name as an argument and evaluates to true if the variable +has been defined. +.It Ic make +Takes a target name as an argument and evaluates to true if the target +was specified as part of +.Nm Ns 's +command line or was declared the default target (either implicitly or +explicitly, see +.Va .MAIN ) +before the line containing the conditional. +.It Ic empty +Takes a variable, with possible modifiers, and evaluates to true if +the expansion of the variable would result in an empty string. +.It Ic exists +Takes a file name as an argument and evaluates to true if the file exists. +The file is searched for on the system search path (see +.Va .PATH ) . +.It Ic target +Takes a target name as an argument and evaluates to true if the target +has been defined. +.It Ic commands +Takes a target name as an argument and evaluates to true if the target +has been defined and has commands associated with it. +.El +.Pp +.Ar Expression +may also be an arithmetic or string comparison. +Variable expansion is +performed on both sides of the comparison, after which the integral +values are compared. +A value is interpreted as hexadecimal if it is +preceded by 0x, otherwise it is decimal; octal numbers are not supported. +The standard C relational operators are all supported. +If after +variable expansion, either the left or right hand side of a +.Ql Ic == +or +.Ql Ic "!=" +operator is not an integral value, then +string comparison is performed between the expanded +variables. +If no relational operator is given, it is assumed that the expanded +variable is being compared against 0 or an empty string in the case +of a string comparison. +.Pp +When +.Nm +is evaluating one of these conditional expressions, and it encounters +a (white-space separated) word it doesn't recognize, either the +.Dq make +or +.Dq defined +expression is applied to it, depending on the form of the conditional. +If the form is +.Ql Ic .ifdef , +.Ql Ic .ifndef , +or +.Ql Ic .if +the +.Dq defined +expression is applied. +Similarly, if the form is +.Ql Ic .ifmake +or +.Ql Ic .ifnmake , the +.Dq make +expression is applied. +.Pp +If the conditional evaluates to true the parsing of the makefile continues +as before. +If it evaluates to false, the following lines are skipped. +In both cases this continues until a +.Ql Ic .else +or +.Ql Ic .endif +is found. +.Pp +For loops are typically used to apply a set of rules to a list of files. +The syntax of a for loop is: +.Pp +.Bl -tag -compact -width Ds +.It Ic \&.for Ar variable Oo Ar variable ... Oc Ic in Ar expression +.It Aq make-rules +.It Ic \&.endfor +.El +.Pp +After the for +.Ic expression +is evaluated, it is split into words. +On each iteration of the loop, one word is taken and assigned to each +.Ic variable , +in order, and these +.Ic variables +are substituted into the +.Ic make-rules +inside the body of the for loop. +The number of words must come out even; that is, if there are three +iteration variables, the number of words provided must be a multiple +of three. +.Sh COMMENTS +Comments begin with a hash +.Pq Ql \&# +character, anywhere but in a shell +command line, and continue to the end of an unescaped new line. +.Sh SPECIAL SOURCES (ATTRIBUTES) +.Bl -tag -width .IGNOREx +.It Ic .EXEC +Target is never out of date, but always execute commands anyway. +.It Ic .IGNORE +Ignore any errors from the commands associated with this target, exactly +as if they all were preceded by a dash +.Pq Ql \- . +.\" .It Ic .INVISIBLE +.\" XXX +.\" .It Ic .JOIN +.\" XXX +.It Ic .MADE +Mark all sources of this target as being up-to-date. +.It Ic .MAKE +Execute the commands associated with this target even if the +.Fl n +or +.Fl t +options were specified. +Normally used to mark recursive +.Nm Ns 's . +.It Ic .NOPATH +Do not search for the target in the directories specified by +.Ic .PATH . +.It Ic .NOTMAIN +Normally +.Nm +selects the first target it encounters as the default target to be built +if no target was specified. +This source prevents this target from being selected. +.It Ic .OPTIONAL +If a target is marked with this attribute and +.Nm +can't figure out how to create it, it will ignore this fact and assume +the file isn't needed or already exists. +.It Ic .PHONY +The target does not +correspond to an actual file; it is always considered to be out of date, +and will not be created with the +.Fl t +option. +.It Ic .PRECIOUS +When +.Nm +is interrupted, it normally removes any partially made targets. +This source prevents the target from being removed. +.It Ic .RECURSIVE +Synonym for +.Ic .MAKE . +.It Ic .SILENT +Do not echo any of the commands associated with this target, exactly +as if they all were preceded by an at sign +.Pq Ql @ . +.It Ic .USE +Turn the target into +.Nm Ns 's +version of a macro. +When the target is used as a source for another target, the other target +acquires the commands, sources, and attributes (except for +.Ic .USE ) +of the +source. +If the target already has commands, the +.Ic .USE +target's commands are appended +to them. +.It Ic .USEBEFORE +Exactly like +.Ic .USE , +but prepend the +.Ic .USEBEFORE +target commands to the target. +.It Ic .WAIT +If +.Ic .WAIT +appears in a dependency line, the sources that precede it are +made before the sources that succeed it in the line. +Since the dependents of files are not made until the file itself +could be made, this also stops the dependents being built unless they +are needed for another branch of the dependency tree. +So given: +.Bd -literal +x: a .WAIT b + echo x +a: + echo a +b: b1 + echo b +b1: + echo b1 + +.Ed +the output is always +.Ql a , +.Ql b1 , +.Ql b , +.Ql x . +.br +The ordering imposed by +.Ic .WAIT +is only relevant for parallel makes. +.El +.Sh SPECIAL TARGETS +Special targets may not be included with other targets, i.e. they must be +the only target specified. +.Bl -tag -width .BEGINx +.It Ic .BEGIN +Any command lines attached to this target are executed before anything +else is done. +.It Ic .DEFAULT +This is sort of a +.Ic .USE +rule for any target (that was used only as a +source) that +.Nm +can't figure out any other way to create. +Only the shell script is used. +The +.Ic .IMPSRC +variable of a target that inherits +.Ic .DEFAULT Ns 's +commands is set +to the target's own name. +.It Ic .END +Any command lines attached to this target are executed after everything +else is done. +.It Ic .IGNORE +Mark each of the sources with the +.Ic .IGNORE +attribute. +If no sources are specified, this is the equivalent of specifying the +.Fl i +option. +.It Ic .INTERRUPT +If +.Nm +is interrupted, the commands for this target will be executed. +.It Ic .MAIN +If no target is specified when +.Nm +is invoked, this target will be built. +.It Ic .MAKEFLAGS +This target provides a way to specify flags for +.Nm +when the makefile is used. +The flags are as if typed to the shell, though the +.Fl f +option will have +no effect. +.\" XXX: NOT YET!!!! +.\" .It Ic .NOTPARALLEL +.\" The named targets are executed in non parallel mode. +.\" If no targets are +.\" specified, then all targets are executed in non parallel mode. +.It Ic .NOPATH +Apply the +.Ic .NOPATH +attribute to any specified sources. +.It Ic .NOTPARALLEL +Disable parallel mode. +.It Ic .NO_PARALLEL +Synonym for +.Ic .NOTPARALLEL , +for compatibility with other pmake variants. +.It Ic .ORDER +The named targets are made in sequence. +This ordering does not add targets to the list of targets to be made. +Since the dependents of a target do not get built until the target itself +could be built, unless +.Ql a +is built by another part of the dependency graph, +the following is a dependency loop: +.Bd -literal +\&.ORDER: a b +b: a +.Ed +.Pp +The ordering imposed by +.Ic .ORDER +is only relevant for parallel makes. +.\" XXX: NOT YET!!!! +.\" .It Ic .PARALLEL +.\" The named targets are executed in parallel mode. +.\" If no targets are +.\" specified, then all targets are executed in parallel mode. +.It Ic .PATH +The sources are directories which are to be searched for files not +found in the current directory. +If no sources are specified, any previously specified directories are +deleted. +If the source is the special +.Ic .DOTLAST +target, then the current working +directory is searched last. +.It Ic .PHONY +Apply the +.Ic .PHONY +attribute to any specified sources. +.It Ic .PRECIOUS +Apply the +.Ic .PRECIOUS +attribute to any specified sources. +If no sources are specified, the +.Ic .PRECIOUS +attribute is applied to every +target in the file. +.It Ic .SHELL +Sets the shell that +.Nm +will use to execute commands. +The sources are a set of +.Ar field=value +pairs. +.Bl -tag -width hasErrCtls +.It Ar name +This is the minimal specification, used to select one of the builtin +shell specs; +.Ar sh , +.Ar ksh , +and +.Ar csh . +.It Ar path +Specifies the path to the shell. +.It Ar hasErrCtl +Indicates whether the shell supports exit on error. +.It Ar check +The command to turn on error checking. +.It Ar ignore +The command to disable error checking. +.It Ar echo +The command to turn on echoing of commands executed. +.It Ar quiet +The command to turn off echoing of commands executed. +.It Ar filter +The output to filter after issuing the +.Ar quiet +command. +It is typically identical to +.Ar quiet . +.It Ar errFlag +The flag to pass the shell to enable error checking. +.It Ar echoFlag +The flag to pass the shell to enable command echoing. +.It Ar newline +The string literal to pass the shell that results in a single newline +character when used outside of any quoting characters. +.El +Example: +.Bd -literal +\&.SHELL: name=ksh path=/bin/ksh hasErrCtl=true \\ + check="set -e" ignore="set +e" \\ + echo="set -v" quiet="set +v" filter="set +v" \\ + echoFlag=v errFlag=e newline="'\\n'" +.Ed +.It Ic .SILENT +Apply the +.Ic .SILENT +attribute to any specified sources. +If no sources are specified, the +.Ic .SILENT +attribute is applied to every +command in the file. +.It Ic .SUFFIXES +Each source specifies a suffix to +.Nm . +If no sources are specified, any previously specified suffixes are deleted. +It allows the creation of suffix-transformation rules. +.Pp +Example: +.Bd -literal +\&.SUFFIXES: .o +\&.c.o: + cc -o ${.TARGET} -c ${.IMPSRC} +.Ed +.El +.Sh ENVIRONMENT +.Nm +uses the following environment variables, if they exist: +.Ev MACHINE , +.Ev MACHINE_ARCH , +.Ev MAKE , +.Ev MAKEFLAGS , +.Ev MAKEOBJDIR , +.Ev MAKEOBJDIRPREFIX , +.Ev MAKESYSPATH , +.Ev PWD , +and +.Ev TMPDIR . +.Pp +.Ev MAKEOBJDIRPREFIX +and +.Ev MAKEOBJDIR +may only be set in the environment or on the command line to +.Nm +and not as makefile variables; +see the description of +.Ql Va .OBJDIR +for more details. +.Sh FILES +.Bl -tag -width /etc/mk -compact +.It .depend +list of dependencies +.It Makefile +list of dependencies +.It makefile +list of dependencies +.It sys.mk +system makefile +.It /etc/mk +system makefile directory +.El +.Sh COMPATIBILITY +The basic make syntax is compatible between different versions of make, +however the special variables, variable modifiers and conditionals are not. +.Pp +The way that parallel makes are scheduled changed in +.Nx 4.0 +so that .ORDER and .WAIT apply recursively to the dependant nodes. +The algorithms used may change again in the future. +.Pp +The way that .for loop variables are substituted changed after +.Nx 5.0 +so that they still appear to be variable expansions. +In particular this stops them being treated as syntax, and removes some +obscure problems using them in .if statements. +.Sh SEE ALSO +.Xr mkdep 1 +.Sh HISTORY +A +.Nm +command appeared in +.At v7 . +.Sh BUGS +The +.Nm +syntax is difficult to parse without actually acting of the data. +For instance finding the end of a variable use should involve scanning each +the modifiers using the correct terminator for each field. +In many places +.Nm +just counts {} and () in order to find the end of a variable expansion. +.Pp +There is no way of escaping a space character in a filename. diff --git a/man/man1/mkdep.1 b/man/man1/mkdep.1 index 7d4ec0517..c6fd291ef 100755 --- a/man/man1/mkdep.1 +++ b/man/man1/mkdep.1 @@ -53,9 +53,6 @@ For C, the typical idiom is to add in all your cd sub2 && $(MAKE) -$(MAKEFLAGS) $@ # repeat for each subdirectory mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend -.PP - # Include generated dependencies. - include .depend .PP .fi .SH "SEE ALSO" diff --git a/servers/ds/Makefile b/servers/ds/Makefile index b92f429df..a99761000 100644 --- a/servers/ds/Makefile +++ b/servers/ds/Makefile @@ -35,6 +35,4 @@ clean: depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend -# Include generated dependencies. -include .depend diff --git a/servers/hgfs/Makefile b/servers/hgfs/Makefile index 109fdf647..98b7d5e6a 100644 --- a/servers/hgfs/Makefile +++ b/servers/hgfs/Makefile @@ -29,6 +29,3 @@ clean: depend: cd $(LIBHGFSDIR) && $(MAKE) $@ mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend - -# Include generated dependencies. -include .depend diff --git a/servers/hgfs/libhgfs/Makefile b/servers/hgfs/libhgfs/Makefile index 302d767e7..486b2f079 100644 --- a/servers/hgfs/libhgfs/Makefile +++ b/servers/hgfs/libhgfs/Makefile @@ -21,6 +21,3 @@ clean distclean: depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend - -# Include generated dependencies. -include .depend diff --git a/servers/inet/Makefile b/servers/inet/Makefile index 632387b23..356e91293 100644 --- a/servers/inet/Makefile +++ b/servers/inet/Makefile @@ -29,7 +29,7 @@ inet: $(OBJ) $(CC) -o $@ $(LDFLAGS) $(OBJ) version.c $(LIBS) install: inet - install -c $< /usr/sbin/inet + install -c inet /usr/sbin/inet clean: rm -f $(OBJ) inet *.bak @@ -37,8 +37,6 @@ clean: depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c generic/*.c > .depend -# Include generated dependencies. -include .depend # # $PchId: Makefile.mnx3,v 1.1 2005/06/28 14:28:45 philip Exp $ diff --git a/servers/init/Makefile b/servers/init/Makefile index 9f8cf822b..6815e791a 100644 --- a/servers/init/Makefile +++ b/servers/init/Makefile @@ -33,6 +33,4 @@ clean: depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend -# Include generated dependencies. -include .depend diff --git a/servers/ipc/Makefile b/servers/ipc/Makefile index 390af0394..e8152c7a4 100644 --- a/servers/ipc/Makefile +++ b/servers/ipc/Makefile @@ -13,7 +13,7 @@ CFLAGS = $(CPROFILE) $(CPPFLAGS) all build: $(SERVER) install: $(SERVER) - install -o root -c $< /usr/sbin/$(SERVER) + install -o root -c $(SERVER) /usr/sbin/$(SERVER) $(SERVER): $(OBJ) $(CC) -o $@ $(LDFLAGS) $(OBJ) -lsys @@ -25,6 +25,4 @@ clean: depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend -# Include generated dependencies. -include .depend diff --git a/servers/is/Makefile b/servers/is/Makefile index 59404167e..a6af2bbd6 100644 --- a/servers/is/Makefile +++ b/servers/is/Makefile @@ -30,7 +30,7 @@ $(SERVER): $(OBJ) # install with other servers install: $(SERVER) - install -o root -c $< /sbin/$(SERVER) + install -o root -c $(SERVER) /sbin/$(SERVER) # clean up local files clean: @@ -39,6 +39,4 @@ clean: depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend -# Include generated dependencies. -include .depend diff --git a/servers/iso9660fs/Makefile b/servers/iso9660fs/Makefile index 35aff9ddc..51540fb88 100644 --- a/servers/iso9660fs/Makefile +++ b/servers/iso9660fs/Makefile @@ -33,5 +33,3 @@ clean: depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend -# Include generated dependencies. -include .depend diff --git a/servers/mfs/Makefile b/servers/mfs/Makefile index 828664151..4f8f2692b 100644 --- a/servers/mfs/Makefile +++ b/servers/mfs/Makefile @@ -37,7 +37,5 @@ clean: depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend -# Include generated dependencies. -include .depend diff --git a/servers/pfs/Makefile b/servers/pfs/Makefile index 1af893e90..cee68f7b9 100644 --- a/servers/pfs/Makefile +++ b/servers/pfs/Makefile @@ -29,8 +29,3 @@ clean: depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend - -# Include generated dependencies. -include .depend - - diff --git a/servers/pm/Makefile b/servers/pm/Makefile index eb43f436f..f76be6867 100644 --- a/servers/pm/Makefile +++ b/servers/pm/Makefile @@ -38,6 +38,4 @@ clean: depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend -# Include generated dependencies. -include .depend diff --git a/servers/rs/Makefile b/servers/rs/Makefile index 7c820a8fc..1e35b7c28 100644 --- a/servers/rs/Makefile +++ b/servers/rs/Makefile @@ -43,6 +43,4 @@ clean: depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend -# Include generated dependencies. -include .depend diff --git a/servers/vfs/Makefile b/servers/vfs/Makefile index 27faf2f04..4373a9bc6 100644 --- a/servers/vfs/Makefile +++ b/servers/vfs/Makefile @@ -33,5 +33,3 @@ clean: depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend -# Include generated dependencies. -include .depend diff --git a/servers/vm/Makefile b/servers/vm/Makefile index 5fc74c7b7..8d844d84e 100644 --- a/servers/vm/Makefile +++ b/servers/vm/Makefile @@ -31,6 +31,4 @@ depend: phony: @: -# Include generated dependencies. -include .depend diff --git a/servers/vm/i386/Makefile b/servers/vm/i386/Makefile index 805296e8c..77eb97c16 100644 --- a/servers/vm/i386/Makefile +++ b/servers/vm/i386/Makefile @@ -14,6 +14,4 @@ clean: depend: mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend -# Include generated dependencies. -include .depend diff --git a/tools/Makefile b/tools/Makefile index e41743c53..803367f44 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -29,7 +29,6 @@ usage: @echo " make depend # Generate dependency files" >&2 @echo " make libraries # Make system libraries" >&2 @echo " make services # Compile and install all services" >&2 - @echo " make fresh # Make clean, libraries, and services" >&2 @echo " make image # Make needed services and create boot image" >&2 @echo " make install # Make image, and install to hard disk" >&2 @echo " make hdboot # Make image, and install to hard disk" >&2 @@ -42,12 +41,6 @@ usage: @echo " make fresh install # new everything" >&2 @echo " " >&2 -# create a fresh configuration or system image -fresh: - cd ../lib && $(MAKE) clean - $(MAKE) clean - $(MAKE) libraries services - all: services image image: includes @@ -75,10 +68,7 @@ services: includes cd ../drivers && $(MAKE) install libraries: includes - cd ../lib && $(MAKE) clean - cd ../lib && $(MAKE) all - cd ../lib && $(MAKE) install - + cd ../lib && sh ack_build.sh clean obj depend all install # make bootable and place system images bootable: diff --git a/tools/chrootmake.sh b/tools/chrootmake.sh index 40d4b650e..98ce9f782 100755 --- a/tools/chrootmake.sh +++ b/tools/chrootmake.sh @@ -3,11 +3,11 @@ set -e export SHELL=/bin/sh cd /usr/src make etcfiles -su bin -c 'make world install' +su bin -c 'make world' cd tools rm revision rm /boot/image/* -make install +make install cp /boot/image/* /boot/image_big # Make big image accessible by this name cp ../boot/boot /boot/boot cd /usr/src diff --git a/tools/release.sh b/tools/release.sh index 4bb2e4c49..ba7dc87d7 100755 --- a/tools/release.sh +++ b/tools/release.sh @@ -236,7 +236,7 @@ echo " * Transfering bootstrap dirs to $RELEASEDIR" cp -p /bin/* /usr/bin/* $RELEASEDIR/$XBIN cp -rp /usr/lib $RELEASEDIR/usr cp -rp /bin/bigsh /bin/sh /bin/echo $RELEASEDIR/bin -cp -rp /usr/bin/make /usr/bin/install /usr/bin/yacc /usr/bin/flex $RELEASEDIR/usr/bin +cp -rp /usr/bin/make /usr/bin/install /usr/bin/yacc /usr/bin/flex /usr/bin/asmconv $RELEASEDIR/usr/bin if [ -d $PACKAGEDIR -a -d $PACKAGESOURCEDIR -a -f $PACKAGELIST -a -f $PACKAGESOURCELIST -a $PACKAGES -ne 0 ] then echo " * Transfering $PACKAGEDIR to $RELEASEPACKAGE" @@ -320,6 +320,9 @@ then date >$RELEASEDIR/CD fi echo " * Chroot build" cp chrootmake.sh $RELEASEDIR/usr/$SRC/tools/chrootmake.sh +mkdir -p $RELEASEDIR/etc/mk +chmod -R 755 $RELEASEDIR/etc/ +cp ../etc/mk/* $RELEASEDIR/etc/mk/ chroot $RELEASEDIR "PATH=/$XBIN sh -x /usr/$SRC/tools/chrootmake.sh" || exit 1 # Copy built images for cd booting cp $RELEASEDIR/boot/image_big image