diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2010-07-16 11:58:26 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2010-07-16 11:58:26 +0300 |
commit | 765c7494b3dac62207e6cd57fb839997e237f292 (patch) | |
tree | f7da12ffdb85d9f82671cb3122775b2ce73f7ad9 /atari | |
parent | cce5115e21db1702e0617afdca36633e7e2c9eae (diff) | |
download | egawk-765c7494b3dac62207e6cd57fb839997e237f292.tar.gz egawk-765c7494b3dac62207e6cd57fb839997e237f292.tar.bz2 egawk-765c7494b3dac62207e6cd57fb839997e237f292.zip |
Moving to 2.13.2.
Diffstat (limited to 'atari')
-rw-r--r-- | atari/Makefile.st | 172 | ||||
-rw-r--r-- | atari/mkconf.g | 18 | ||||
-rw-r--r-- | atari/mkscrpt.sed | 15 | ||||
-rw-r--r-- | atari/stack.c | 6 | ||||
-rw-r--r-- | atari/system.c | 112 | ||||
-rw-r--r-- | atari/textrd.c | 30 | ||||
-rw-r--r-- | atari/tmpnam.c | 47 |
7 files changed, 400 insertions, 0 deletions
diff --git a/atari/Makefile.st b/atari/Makefile.st new file mode 100644 index 00000000..36bf0ae3 --- /dev/null +++ b/atari/Makefile.st @@ -0,0 +1,172 @@ +# Makefile for GNU Awk - ST version +# +# This is a subset of the full Makefile cut down for Atari ST +# gcc compiler is assumed +# It is known to work with gulam shell. +# It may need some customization depending on your setup! +# Replace with it 'Makefile' from the source directory. +# +# You need sed.ttp for an automatic creation of config.h file! +# Check gulam script mkconf.g in atari directory. +# In a pinch you may create one by checking config/atari file and +# editing config.h-dist by hand. +# +# Copyright (C) 1986, 1988, 1989 the Free Software Foundation, Inc. +# +# This file is part of GAWK, the GNU implementation of the +# AWK Progamming Language. +# +# GAWK is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 1, or (at your option) +# any later version. +# +# GAWK is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GAWK; see the file COPYING. If not, write to +# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + +# User tunable macros + +DESTDIR= +BINDIR= c:\bin +MANDIR= c:\man\manl +MANEXT= l +RM=rm -f + +# CFLAGS: options to the C compiler +# +# -O optimize +# -mshort use integers which are 16-bits wide (a "correct" size on ST) +# +# Set LIBS to any libraries that are machine specific + + +# Comment out the next line if you don't have gcc. +# Also choose just one of -g and -O. +CC= gcc +# if cross-compiler +#CC= cgcc +LIBS = -lpml16 + +OPTIMIZE= -O -fstrength-reduce -fcombine-regs -fomit-frame-pointer +#OPTIMIZE= -O +AFLAGS = -G -x -mshort # -Wall +DEBUG= #-DMALLOCDEBUG #-DMEMDEBUG #-DDEBUG #-DFUNC_TRACE #-DMPROF +WARN= #-W -Wunused -Wimplicit -Wreturn-type -Wcomment # for gcc only + +# Parser to use on grammar -- if you don't have bison use the first one +#PARSER = yacc +PARSER = byacc +#PARSER = bison -y + +# +# With the exception of names of parser output files +# need to customize this file below this point. +# + +FLAGS= $(DEBUG) $(AFLAGS) +CFLAGS= $(FLAGS) $(LINKSTATIC) $(PROFILE) $(OPTIMIZE) $(WARN) + +# object files +AWKOBJS = main.o eval.o builtin.o msg.o iop.o io.o field.o \ + array.o node.o missing.o re.o version.o + +# basename of parser output +#POUTPUT = awk.tab +POUTPUT = awk_tab + +ALLOBJS = $(AWKOBJS) $(POUTPUT).o + +# GNUOBJS +# GNU stuff that gawk uses as library routines. +GNUOBJS= regex.o dfa.o $(ALLOCA) + +# source and documentation files +SRC = main.c eval.c builtin.c msg.c \ + iop.c io.c field.c array.c node.c missing.c re.c version.c + +ALLSRC= $(SRC) $(POUTPUT).c +#ALLSRC= $(SRC) awk_tab.c + +AWKSRC= awk.h awk.y $(ALLSRC) patchlevel.h protos.h config.h-dist + +GNUSRC = alloca.c alloca.s dfa.c dfa.h regex.c regex.h + +COPIES = missing/getopt.c missing/system.c missing/tzset.c \ + missing/memcmp.c missing/memcpy.c missing/memset.c \ + missing/random.c missing/strcase.c missing/strchr.c \ + missing/strerror.c missing/strtod.c missing/vprintf.c \ + missing/strftime.c missing/strftime.3 missing/strtol.c + +SUPPORT = support/texindex.c support/texinfo.tex + +DOCS= gawk.1 gawk.texinfo + +#INFOFILES= gawk-info gawk-info-1 gawk-info-2 gawk-info-3 gawk-info-4 \ +# gawk-info-5 gawk-info-6 gawk.aux gawk.cp gawk.cps gawk.fn \ +# gawk.fns gawk.ky gawk.kys gawk.pg gawk.pgs gawk.toc \ +# gawk.tp gawk.tps gawk.vr gawk.vrs + +ALLDOC= gawk.dvi $(INFOFILES) + +# rules to build gawk +gawk: $(ALLOBJS) $(GNUOBJS) $(REOBJS) + $(CC) -o gawk.ttp $(CFLAGS) $(ALLOBJS) $(GNUOBJS) $(REOBJS) $(LIBS) + toglclr gawk.ttp + +$(AWKOBJS): awk.h config.h + +dfa.o: awk.h config.h dfa.h +regex.o: awk.h config.h regex.h +main.o: patchlevel.h + +$(POUTPUT).o: awk.h $(POUTPUT).c + +$(POUTPUT).c: awk.y awk.h + $(PARSER) awk.y + sed '/^extern char .malloc(), .realloc();$$/d' ytab.c > $(POTPUT).c + rm ytab.c + +config.h: config.h-dist + pushd atari + mkconf.g + popd + +# One of these rules should have already been selected by running mkconf. + +##MAKE_ALLOCA_S## alloca.o: alloca.s +##MAKE_ALLOCA_S## /lib/cpp < alloca.s | sed '/^#/d' > t.s +##MAKE_ALLOCA_S## as t.s -o alloca.o +##MAKE_ALLOCA_S## rm t.s +##MAKE_ALLOCA_C## alloca.o: alloca.c +install: gawk + cp gawk.ttp $(DESTDIR)$(BINDIR) + cp gawk.1 $(DESTDIR)$(MANDIR)/gawk.$(MANEXT) + +clean: + $(RM) gawk.ttp *.o core awk.output $(POUTPUT).c gmon.out make.out \ + y.output + +clobber: clean + $(RM) $(ALLDOC) gawk.log + +gawk.dvi: gawk.texinfo + tex gawk.texinfo ; texindex gawk.?? + tex gawk.texinfo ; texindex gawk.?? + tex gawk.texinfo + +#$(INFOFILES): gawk.texinfo +# makeinfo gawk.texinfo + +# Many tests in test directory depend on having Bourne shell around. +# Before using this target edit test Makefile and test scripts adapting +# them to your local conditions. +test: gawk + pushd test + make + popd diff --git a/atari/mkconf.g b/atari/mkconf.g new file mode 100644 index 00000000..b7db88a9 --- /dev/null +++ b/atari/mkconf.g @@ -0,0 +1,18 @@ +# +# gulam script to produce configuration file for Atari ST; +# performs the same job as mkconf, but only for this specific configuration; +# it is assumed that it is located in a subdirectory .\atari +# +if { -e ..\config\atari } + sed -n -f mkscrpt.sed ..\config\atari > sedscr + sed -f sedscr ..\config.h-d > config.h + sed -n '/^#echo./s///p' ..\config\atari + rm sedscr + mv config.h .. +ef + echo "'..\config\atari' was lost somewhere" + echo "Either construct one based on the examples in the config directory," + echo "or, in source directory, copy config.h-dist to config.h and edit it." + exit 1 +endif +exit 0 diff --git a/atari/mkscrpt.sed b/atari/mkscrpt.sed new file mode 100644 index 00000000..949d9c59 --- /dev/null +++ b/atari/mkscrpt.sed @@ -0,0 +1,15 @@ +# there is no automatic editing of Makefile for Atari right now +# but lines starting with "MAKE_" string are processed for consistency +# with other configuration files and in a case they would be needed +# in a future +:start + /^MAKE_/d + /^[^#]/s/.*/s~__SYSTEM__~&~/p + t cont + n + b start +:cont + n + /^MAKE_/d + /^[^#]/s:^\([^ ]*\)[ ].*:s~^/\\* #define[ ]*\1.*~#define &~:p +b cont diff --git a/atari/stack.c b/atari/stack.c new file mode 100644 index 00000000..c57880da --- /dev/null +++ b/atari/stack.c @@ -0,0 +1,6 @@ +/* + * This value indicates an amount of reserved memory for a stack + * in executables - see source of a startup code for details. + * It can be changed without recompilation with fixstk.ttp utility. + */ +long _stksize = 2L; /* keep half of memory */ diff --git a/atari/system.c b/atari/system.c new file mode 100644 index 00000000..26943bb4 --- /dev/null +++ b/atari/system.c @@ -0,0 +1,112 @@ +/* + * function system() - slightly modified from sources dLibs 1.2 + * - a freely distributable C library for Atari ST. + * Authors: Dale Schumacher and John Stanley, I believe. + * Changes for gcc compiler and gnulib.olb - Michal Jaegermann + */ + +#include <osbind.h> +#include <stdio.h> +#include <string.h> +#include <basepage.h> +#ifdef __GNUC__ +#include <process.h> +#define ERROR 2 +#endif + +/* #define DEBUG */ +#ifdef DEBUG +#define _COOKIE(x) puts(x);putchar('\n') +#endif + +void static +parse_args(char *cmdln, register char **argv) +{ + register char *p; + static char delim[] = " \t\r\n"; + + if(p = strtok(cmdln, delim)) { + do { + *argv++ = p; + } while(p = strtok(NULL, delim)); + } +} + +#ifdef __GNUC__ +/* this is used by assembler statement to keep a copy of registers */ +static volatile long savearea[16]; +#endif + +int +system(const char *command) +{ + register char *p; + register int (*shell)(); +#ifndef __GNUC__ + char rv[2]; +#endif + char cmdln[1024]; + char *args[64]; + char *getenv(); + + if(!command) + return(ERROR); + + /* get _shell_p value */ + p = (char *) Super(0L); /* supervisor mode */ + shell = (int (*)()) *((long *) 0x4F6L); + (void) Super(p); /* restore user mode */ + + /* validate _shell_p */ + if((shell) && /* Shell available. */ + (((long) shell) < ((long) _base)) && /* Reasonable shell pointer. */ + (strncmp((char *)shell, "PATH", 4))) /* Not corrupted */ + { +#ifdef __GNUC__ + int ret; +#endif + /* execute the command */ +#ifdef DEBUG +_COOKIE("system: using _shell_p"); +printf("'shell' got value 0x%08lx\n", (long)shell); +#endif +/* a bit of paranoia caused by some misbehaving programs */ +#ifdef __GNUC__ +asm("moveml d1-d7/a0-a7,_savearea"); + ret = (*shell)(command); +asm("moveml _savearea,d1-d7/a0-a7"); + return (ret); +#else + return ((*shell)(command)); +#endif + } + + strcpy(cmdln, command); /* copy the command line for parsing */ + + if((p = getenv("SHELL")) && (*p)) /* SHELL= variable? */ + { + args[0] = p; + parse_args(cmdln, (args + 1)); +#ifdef DEBUG +_COOKIE("system: executing SHELL"); +_COOKIE(p); +#endif + } + else /* attempt to find first token as a program on the path */ + { + parse_args(cmdln, args); + p = args[0]; +#ifdef DEBUG +_COOKIE("system: directly executing program"); +_COOKIE(p); +#endif + } + +#ifdef __GNUC__ + return(spawnvp(0, p, args)); +#else /* original from dLibs */ + forkvpe(p, args, NULL); + wait(rv); + return((rv[1] == 0) ? rv[0] : rv[1]); +#endif +} diff --git a/atari/textrd.c b/atari/textrd.c new file mode 100644 index 00000000..07ed0905 --- /dev/null +++ b/atari/textrd.c @@ -0,0 +1,30 @@ +/* + * From gnulib Atari ST sources - with a fix for a bug causing + * a premature EOF when only characters read are CR's. + * Written by Eric R. Smith and placed in the public domain. + * Fix - Michal Jaegermann, June 1991. + */ +#include <stdio.h> +#include <unistd.h> +int +_text_read(fd, buf, nbytes) + int fd; + char *buf; + int nbytes; +{ + char *to, *from; + int r; + do { + r = read(fd, buf, nbytes); + if (r <= 0) /* if EOF or read error - return */ + return r; + to = from = buf; + do { + if (*from == '\r') + from++; + else + *to++ = *from++; + } while (--r); + } while (buf == to); /* only '\r's? - try to read next nbytes */ + return (to - buf); +} diff --git a/atari/tmpnam.c b/atari/tmpnam.c new file mode 100644 index 00000000..bd68c4c0 --- /dev/null +++ b/atari/tmpnam.c @@ -0,0 +1,47 @@ +/* tmpnam.c : return a temporary file name */ +/* written by Eric R. Smith and placed in the public domain */ +/** + * - modified for gawk needs - pattern /$$XXXXXX from the original + * code creates names which are hard to remove when somethig + * goes wrong + * - retuned name can be passed outside via system(); other programs + * may not dig '/' as a path separator + * - somehow more frugal in a memory use + * (mj - October 1990) + **/ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +extern char * getenv(const char *); +extern char * mktemp(char *); +extern char * strcpy(char *, const char *); +extern char * strcat(char *, const char *); +extern size_t strlen(const char *s); +static char pattern[] = "\\gwkXXXXX"; + +char *tmpnam(buf) + char *buf; +{ + char *tmpdir; + + if (!(tmpdir = getenv("TEMP")) && !(tmpdir = getenv("TMPDIR"))) + tmpdir = "."; + + if (!buf) { + size_t blen; + + blen = strlen (tmpdir) + sizeof(pattern); + if (NULL == (buf = malloc(blen))) + return NULL; + } + (void) strcat(strcpy(buf, tmpdir), pattern); + return(mktemp(buf)); +} + +/* used by gawk_popen() */ +char *tempnam(path, base) +const char *path, *base; /* ignored */ +{ + return tmpnam(NULL); +} |