Commit of 3.99.2 version

This commit is contained in:
Erick Gallesio
2019-10-31 12:07:40 +01:00
parent 3c98caa84e
commit dd57fe2b2a
56 changed files with 11456 additions and 8166 deletions
+26 -11
View File
@@ -1,20 +1,22 @@
Extensions directory
--------------------
This file contains extensions of the core interpreter which can be dynamically
loaded. See the file README in the release main directory to see the systems
for which dynamic loading support exists.
Two extensions are provided as exemples:
STk Extensions directory
------------------------
This file contains extensions of the core interpreter which can be
dynamically loaded. See the file README in the release main directory
to see the systems for which dynamic loading support exists.
Two extensions are provided as examples:
- stack.c: a (very simple) package providing the stack type to the
interpreter. This package is presented in the documentation
about STk interpreter extension.
- when.c: an implementation of when and unless
Other extensions ar more "useful":
Other extensions are more "useful":
- stklos.c + gf.c: all that is necessary for STklos
- hash.c: a package for hash-table in Scheme (the one used by STklos)
- pixmap.c: an extension for adding the XPM (pixmap) format to Tk4.0
This extension is due to:
@@ -24,12 +26,25 @@ Other extensions ar more "useful":
Aachen, Germany
- html.c: a little extensions useful for (fast) html management
- process.c: an extension which provide process access to STk
- posix.c: a set of POSIX.1 fucntions for STk. Must be completed
- posix.c: a set of POSIX.1 functions for STk. Must be completed
- socket.c: simple support (and hence limited) for sockets. It allows you
to make simple clients and servers program using TCP/IP
- sregexp.c Regular expressions
For more informations on extension building, read the document "Extending the
STk Interpreter" provided with the package.
For more informations on extension building, read the document
"Extending the STk Interpreter" provided with the package.
Automatic generation of Makefiles
=================================
The script stk-genmake which is available in this directory can be
used to automatically build a Makefile for a set of extensions. The
Makefile is generated on standard output. For example, type
$ stk-genmake stack when > Makefile.example
To generate a makefile for the two small extensions provided with the
package. The generated Makfile takes into account the specificities of
your achitecture and is generated by configure.
+7 -3
View File
@@ -12,7 +12,7 @@
#
# Author: Erick Gallesio [eg@kaolin.unice.fr]
# Creation date: 6-Mar-1994 15:49
# Last file update: 30-Apr-1998 10:57
# Last file update: 2-Jun-1998 17:44
include ../config.make
@@ -32,6 +32,7 @@ CFLAGS= $(SH_CCFLAGS) $(STKCFLAGS) $(DFLGS) -DUSE_TK @DEFS@ \
##############################################################################
all: $(EXTRA_OBJ)
chmod 0755 stk-genmake
# Following lines are needed for weird make commands. Use Gnu make....
hash.$(SH_SUFFIX): hash.o
@@ -48,7 +49,10 @@ install:
if test "$(EXTRA_OBJ)" != "" ; then $(CP) $(EXTRA_OBJ) $(execdir); fi
install.libs:
-if [ ! -d $(bindir) ] ; then mkdir -p $(bindir); fi
cp stk-genmake $(bindir)
chmod 0755 $(bindir)/stk-genmake
clean:
@/bin/rm -f *.o *.$(SH_SUFFIX) core *~ Makefile config.status config.log
@/bin/rm -f *.o *.$(SH_SUFFIX) core *~ Makefile config.status \
config.log stk-genmake
-99
View File
@@ -1,99 +0,0 @@
#
# M a k e f i l e . s a m p l e -- A Makefile prototype for compiling
# extensions which are dynamically
# loaded
# Copyright © 1993-1996 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
#
#
# Permission to use, copy, and/or distribute this software and its
# documentation for any purpose and without fee is hereby granted, provided
# that both the above copyright notice and this permission notice appear in
# all copies and derived works. Fees for distribution or use of this
# software or derived works may only be charged with express written
# permission of the copyright holder.
# This software is provided ``as is'' without express or implied warranty.
#
# Author: Erick Gallesio [eg@kaolin.unice.fr]
# Creation date: 17-Mar-1995 10:20
# Last file update: 17-Mar-1995 10:48
#####
##### Start of configuration section
#####
CC=gcc
LIBMALLOC=
INCLUDES = -I../Tk -I../Tcl -I../Src -I../Mp
# Define the 4 next line if you are running SUNOS4
# Use -pic if using acc and fpic if using gcc
SH_CCFLAGS=-fpic
SH_LDFLAGS=-assert pure-text -o
SH_LOADER=ld
SH_SUFFIX=so
# Define the 4 next lines if you are running SUNOS5
# SH_CCFLAGS=-K pic
# SH_LDFLAGS=-G -z text -h
# SH_LOADER=ld
# SH_SUFFIX=so
# Define the 4 next lines if you are running OSF1
# SH_CCFLAGS=-fpic
# SH_LDFLAGS=-shared -o
# SH_LOADER=ld
# SH_SUFFIX=so
# Define the 4 next lines if you are running NETBSD1)
# SH_CCFLAGS=-fpic
# SH_LDFLAGS=-Bshareable -o
# SH_LOADER=ld
# SH_SUFFIX=so
# Define the 5 next lines if you are running HPUX
# SH_CCFLAGS=+Z
# SH_LDFLAGS=-b -o
# SH_LOADER=ld
# SH_SUFFIX=sl
# CFLAGS=$CFLAGS -Wl,-E
# Define the 5 next lines if you are running FREEBSD
# SH_CCFLAGS=-pic
# SH_LDFLAGS=-Bshareable -o
# SH_LOADER=ld
# LIB_MALLOC=/usr/lib/libgnumalloc.a
# SH_SUFFIX=so
# Define the 4 next lines if you are running IRIX5
# SH_CCFLAGS=-fpic
# SH_LDFLAGS=-shared -o
# SH_LOADER=$CC
# SH_SUFFIX=so
# Define the 4 next lines if you are running LINUX
# SH_CCFLAGS=
# SH_LDFLAGS=-r -o
# SH_LOADER=ld
# SH_SUFFIX=so
#
####
#### End of of configuration section
####
##############################################################################
.SUFFIXES: .$(SH_SUFFIX) .o .c
.c.$(SH_SUFFIX):
$(CC) $(CFLAGS) -c -o $*.o $*.c
$(SH_LOADER) $(SH_LDFLAGS) $*.$(SH_SUFFIX) $*.o
if test -f a.out ;then mv a.out $*.$(SH_SUFFIX); fi
.o.$(SH_SUFFIX):
$(SH_LOADER) $(SH_LDFLAGS) $*.$(SH_SUFFIX) $<
if test -f a.out ;then mv a.out $*.$(SH_SUFFIX); fi
##############################################################################
CFLAGS = $(SH_CCFLAGS) $(INCLUDES)
help:
@echo "To make a new xxx.$(SH_SUFFIX) file, just type"
@echo " make xxx.$(SH_SUFFIX)"
clean:
@/bin/rm -f *.o *.$(SH_SUFFIX) core *~
+2 -2
View File
@@ -756,7 +756,7 @@ done
ac_given_srcdir=$srcdir
trap 'rm -fr `echo "Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
trap 'rm -fr `echo "Makefile stk-genmake" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
EOF
cat >> $CONFIG_STATUS <<EOF
@@ -792,7 +792,7 @@ CEOF
EOF
cat >> $CONFIG_STATUS <<EOF
CONFIG_FILES=\${CONFIG_FILES-"Makefile"}
CONFIG_FILES=\${CONFIG_FILES-"Makefile stk-genmake"}
EOF
cat >> $CONFIG_STATUS <<\EOF
for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
+1 -1
View File
@@ -7,4 +7,4 @@ AC_INIT(process.c)
CC=${CC-gcc}
AC_HAVE_HEADERS(unistd.h limits.h)
AC_HAVE_FUNCS(sigaction)
AC_OUTPUT(Makefile)
AC_OUTPUT(Makefile stk-genmake)
+128 -73
View File
@@ -2,7 +2,7 @@
*
* h t m l . c -- Html support for STk
*
* Copyright © 1993-1996 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
* Copyright © 1993-1998 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
*
*
* Permission to use, copy, and/or distribute this software and its
@@ -17,11 +17,14 @@
*
* Author: Erick Gallesio [eg@kaolin.unice.fr]
* Creation date: 1-Sep-1995 23:10
* Last file update: 11-Oct-1996 15:54
* Last file update: 28-May-1998 21:57
*/
#include <ctype.h>
#include "stk.h"
#define MAXTOKEN 40
struct char_type {
char *name;
unsigned char c;
@@ -77,95 +80,147 @@ static void skip_spaces(FILE *f)
}
}
}
static PRIMITIVE STk_html_next_token(SCM iport)
/* next_entity: Read an entity such as <A HREF=x.html> */
static SCM next_entity(FILE *f)
{
/* Return next HTML token */
char ch, *t, token[256];
int c;
Tcl_DString dStr1, dStr2;
int c;
char ch;
SCM z;
FILE *f;
if (!INP(iport)) Err("%Html:next-token: bad port", iport);
f = PORT_FILE(iport);
if (Eof(f) || ((c = Getc(f)) == EOF)) return STk_eof_object;
Tcl_DStringInit(&dStr1); Tcl_DStringInit(&dStr2);
if (c == '<') {
skip_spaces(f);
while ((c = Getc(f)) != EOF && (c != '>') && (c != ' ') && (c != '\t')) {
ch = tolower(c);
Tcl_DStringAppend(&dStr1, &ch, 1);
}
if (c == ' ' || c == '\t') {
/* Read the argument */
skip_spaces(f);
while ((c = Getc(f)) != EOF && (c != '>') && (c != ' ') && (c != '\t')) {
ch = tolower(c);
Tcl_DStringAppend(&dStr1, &ch, 1);
}
if (c == ' ' || c == '\t') {
/* Read the argument */
skip_spaces(f);
while ((c = Getc(f)) != EOF && (c != '>')) {
ch = c;
Tcl_DStringAppend(&dStr2, &ch, 1);
}
while ((c = Getc(f)) != EOF && (c != '>')) {
ch = c;
Tcl_DStringAppend(&dStr2, &ch, 1);
}
}
if (Tcl_DStringValue(&dStr1)[0] == '\0')
z = STk_makestring("<>");
else
if (Tcl_DStringValue(&dStr1)[0]=='/' && Tcl_DStringValue(&dStr1)[1] == '\0')
z = STk_makestring("</>");
else
z = Cons(STk_makestring(Tcl_DStringValue(&dStr1)),
STk_makestring(Tcl_DStringValue(&dStr2)));
}
else {
if (c == '&') {
t = token;
while ((c = Getc(f)) != EOF && c != ';' && isalpha(c)) *t++ = c;
*t = 0;
if (c != ';') Ungetc(c, f);
/* Search the given token in the translation table */
{
int i;
for (i = 0; table[i].c; i++)
if (strcmp(token, table[i].name) == 0) {
Tcl_DStringAppend(&dStr1, &table[i].c, 1);
break;
}
if (!table[i].c) /* Not found */ Tcl_DStringAppend(&dStr1, token, -1);
}
}
else {
do {
if (c == '<' || c == '&') {
Ungetc(c, f);
break;
}
ch = c;
Tcl_DStringAppend(&dStr1, &ch, 1);
}
while ((c = Getc(f)) != EOF);
}
z = STk_makestring(Tcl_DStringValue(&dStr1));
}
if (Tcl_DStringValue(&dStr1)[0] == '\0')
z = STk_makestring("<>");
else
if (Tcl_DStringValue(&dStr1)[0]=='/' && Tcl_DStringValue(&dStr1)[1] == '\0')
z = STk_makestring("</>");
else
z = Cons(STk_makestring(Tcl_DStringValue(&dStr1)),
STk_makestring(Tcl_DStringValue(&dStr2)));
Tcl_DStringFree(&dStr1); Tcl_DStringFree(&dStr2);
return z;
}
static PRIMITIVE STk_html_clean_spaces(SCM str, SCM ignore_spaces)
/* Read an entity such as &amp; */
static void next_character(Tcl_DString *dStr, FILE *f)
{
char *t, ch, token[MAXTOKEN];
int c, i;
token[0] = '&';
if ((c=Getc(f)) == '#') { /* Read a &#000; entity */
token[1] = '#';
t = token + 2;
while ((c=Getc(f)) != EOF && isdigit(c) && t < &token[MAXTOKEN-1]) {
*t++ = c;
}
*t = '\0';
if (c != ';')
/* Unget the terminator character for next reading */
Ungetc(c, f);
ch = (char) atoi(token+2);
if (ch > 10) {
Tcl_DStringAppend(dStr, &ch, 1);
return;
}
}
else { /* Read a &aaaaa; entity */
t = token + 1;
while (c != EOF && isalpha(c) && t < &token[MAXTOKEN-1]) {
*t++ = c;
c = Getc(f);
}
*t = '\0';
if (c != ';')
/* Unget the terminator character for next reading */
Ungetc(c, f);
/* Search the given token in the translation table */
for (i = 0; table[i].c; i++)
if (strcmp(token+1, table[i].name) == 0) {
Tcl_DStringAppend(dStr, &table[i].c, 1);
return;
}
}
/* If we are here, we have not found the item in table or the number was
* ill formed => bad syntax. */
Tcl_DStringAppend(dStr, token, -1);
if (c == ';') Tcl_DStringAppend(dStr, ";", 1); /* as netscape */
}
static PRIMITIVE html_next_token(SCM iport) /* Return next HTML token */
{
int c;
FILE *f;
ENTER_PRIMITIVE("%html:next-token");
if (!INP(iport)) Serror("bad port", iport);
f = PORT_FILE(iport);
if (Eof(f) || ((c = Getc(f)) == EOF)) return STk_eof_object;
if (c == '<')
return next_entity(f);
else {
SCM z;
Tcl_DString dStr;
char ch;
Tcl_DStringInit(&dStr);
do {
if (c == '<') {
Ungetc(c, f);
break;
}
else {
if (c == '&')
next_character(&dStr, f);
else {
ch = c;
Tcl_DStringAppend(&dStr, &ch, 1);
}
}
}
while ((c = Getc(f)) != EOF);
z = STk_makestring(Tcl_DStringValue(&dStr));
return z;
}
}
static PRIMITIVE html_clean_spaces(SCM str, SCM ignore_spaces)
{
Tcl_DString dString;
char c, *s;
int only_spaces = TRUE;
SCM z;
if (!STRINGP(str)) Err("%html:clean-spaces: bad string", str);
ENTER_PRIMITIVE("%html:clean-spaces");
if (!STRINGP(str)) Serror("bad string", str);
Tcl_DStringInit(&dString);
for (s = CHARS(str); c = *s; s++) {
@@ -190,7 +245,7 @@ static PRIMITIVE STk_html_clean_spaces(SCM str, SCM ignore_spaces)
PRIMITIVE STk_init_html(void)
{
STk_add_new_primitive("%html:clean-spaces", tc_subr_2, STk_html_clean_spaces);
STk_add_new_primitive("%html:next-token", tc_subr_1, STk_html_next_token);
STk_add_new_primitive("%html:clean-spaces", tc_subr_2, html_clean_spaces);
STk_add_new_primitive("%html:next-token", tc_subr_1, html_next_token);
return UNDEFINED;
}
+49 -32
View File
@@ -89,15 +89,21 @@ static int internal_process_alivep(SCM process)
else {
/* Use waitpid to gain the info. */
res = waitpid(PROCPID(process), &info, WNOHANG);
if (res == 0)
if (res == 0)
/* process is still running */
return TRUE;
else {
/* process has terminated and we must save this information */
PROCESS(process)->exited = TRUE;
PROCESS(process)->exit_status = info;
return FALSE;
}
else
if (res == PROCPID(process)) {
/* process has terminated and we must save this information */
PROCESS(process)->exited = TRUE;
PROCESS(process)->exit_status = info;
return FALSE;
}
else {
/* might not have found process because we've already waited for it */
/* if so, then status has already been updated */
return FALSE;
}
}
}
@@ -176,7 +182,7 @@ static void cannot_run(int pipes[3][2], char **argv, char *msg, SCM obj)
if (pipes[i][1] != -1) close(pipes[i][1]);
}
free(argv);
Err(msg, obj);
STk_procedure_error("run-process", msg, obj);
}
@@ -205,15 +211,14 @@ static PRIMITIVE run_process(SCM l, int len)
int i = -1;
if (NCONSP(CDR(l)))
cannot_run(pipes, argv_start,"run-process: no argument after keyword", tmp);
cannot_run(pipes, argv_start,"no argument after keyword", tmp);
l = CDR(l); /* Go to next item */
if (STk_eqv(tmp, STk_makekey(key_hst)) == Truth) {
/* :host keyword processing */
if (NSTRINGP(CAR(l)))
cannot_run(pipes, argv_start,
"run-process: string expected. It was", CAR(l));
cannot_run(pipes, argv_start, "string expected. It was", CAR(l));
strcpy(host, CHARS(CAR(l))); /* to avoid GC problems */
/* Shift argv to point the start of allocated zone. This avoid a copy
* of arguments already processed.
@@ -227,8 +232,7 @@ static PRIMITIVE run_process(SCM l, int len)
if (STk_eqv(tmp, STk_makekey(key_wit)) == Truth) {
/* :wait option processing */
if (NBOOLEANP(CAR(l)))
cannot_run(pipes, argv_start,
"run-process: boolean expected. It was", CAR(l));
cannot_run(pipes, argv_start, "boolean expected. It was", CAR(l));
waiting = (CAR(l) == Truth);
}
@@ -238,7 +242,7 @@ static PRIMITIVE run_process(SCM l, int len)
if (STk_eqv(tmp, STk_makekey(key_out)) == Truth) i = 1; else
if (STk_eqv(tmp, STk_makekey(key_err)) == Truth) i = 2;
if (i < 0) cannot_run(pipes, argv_start, "run-process: bad keyword", tmp);
if (i < 0) cannot_run(pipes, argv_start, "bad keyword", tmp);
redirection[i] = CAR(l);
if (STRINGP(redirection[i])) {
@@ -263,7 +267,7 @@ static PRIMITIVE run_process(SCM l, int len)
if (stat_i.st_dev==stat_j.st_dev && stat_i.st_ino==stat_j.st_ino) {
/* Same file was cited 2 times */
if (i == 0 || j == 0) {
sprintf(msg, "run-process: read/write on the same file: %s",
sprintf(msg, "read/write on the same file: %s",
CHARS(redirection[i]));
cannot_run(pipes, argv_start, msg, NIL);
}
@@ -287,7 +291,7 @@ static PRIMITIVE run_process(SCM l, int len)
}
if(pipes[i][0] < 0) {
sprintf(msg, "run-process: can't redirect standard %s to file %s",
sprintf(msg, "can't redirect standard %s to file %s",
stdStreams[i], CHARS(redirection[i]));
cannot_run(pipes, argv_start, msg, NIL);
}
@@ -296,7 +300,7 @@ static PRIMITIVE run_process(SCM l, int len)
if (KEYWORDP(redirection[i])) {
/* Redirection in a pipe */
if (pipe(pipes[i]) < 0) {
sprintf(msg, "run-process: can't create stream for standard %s",
sprintf(msg, "can't create stream for standard %s",
stdStreams[i]);
cannot_run(pipes, argv_start, msg, NIL);
}
@@ -307,13 +311,13 @@ static PRIMITIVE run_process(SCM l, int len)
else {
/* Normal arg. Put it in argv */
if (NSTRINGP(tmp))
cannot_run(pipes, argv_start, "run-process: bad string", tmp);
cannot_run(pipes, argv_start, "bad string", tmp);
argv[argc++] = CHARS(tmp);
}
}
argv[argc] = NULL;
if (argc == 0) cannot_run(pipes, argv_start,"run-process: no command given", NIL);
if (argc == 0) cannot_run(pipes, argv_start,"no command given", NIL);
/* Build a process object */
proc = make_process();
@@ -321,7 +325,7 @@ static PRIMITIVE run_process(SCM l, int len)
/* Fork another process */
switch (pid = fork()) {
case -1: cannot_run(pipes,argv,"run-process: can't create child process", NIL);
case -1: cannot_run(pipes,argv,"can't create child process", NIL);
case 0: /* Child */
for(i = 0; i < 3; i++) {
if (STRINGP(redirection[i])) {
@@ -366,7 +370,7 @@ static PRIMITIVE run_process(SCM l, int len)
f = (i == 0)? fdopen(pipes[i][1],"w"):fdopen(pipes[i][0],"r");
if (f == NULL)
cannot_run(pipes, argv, "run-process: cannot fdopen", proc);
cannot_run(pipes, argv, "cannot fdopen", proc);
sprintf(msg, "pipe-%s-%d", stdStreams[i], pid);
@@ -453,44 +457,57 @@ static PRIMITIVE process_wait(SCM process)
if (PROCESS(process)->exited) return Ntruth;
else {
int ret = waitpid(PROCPID(process), &PROCESS(process)->exit_status, 0);
PROCESS(process)->exited = TRUE;
return (ret == 0) ? Ntruth : Truth;
int info, res;
res = waitpid(PROCPID(process), &info, 0);
if (res == PROCPID(process)) {
PROCESS(process)->exit_status = info;
PROCESS(process)->exited = TRUE;
return Truth;
}
else
return Ntruth;
}
}
static PRIMITIVE process_xstatus(SCM process)
{
int info, n;
int info, n, res;
PURGE_PROCESS_TABLE();
if (NPROCESSP(process)) Err("process-exit-status: bad process", process);
if (PROCESS(process)->exited) n = PROCESS(process)->exit_status;
if (PROCESS(process)->exited)
n = WEXITSTATUS(PROCESS(process)->exit_status);
else {
if (waitpid(PROCPID(process), &info, WNOHANG) == 0) {
res = waitpid(PROCPID(process), &info, WNOHANG);
if (res == 0) {
/* Process is still running */
return Ntruth;
}
else {
else if (res == PROCPID(process)) {
/* Process is now terminated */
PROCESS(process)->exited = TRUE;
PROCESS(process)->exit_status = info;
n = WEXITSTATUS(info);
}
else
return Ntruth;
}
return STk_makeinteger((long) n);
}
static PRIMITIVE process_send_signal(SCM process, SCM signal)
{
ENTER_PRIMITIVE("process-send-signal");
PURGE_PROCESS_TABLE();
if (NPROCESSP(process)) Err("process-send-signal: bad process", process);
if (NINTEGERP(signal)) Err("process-send-signal: bad integer", signal);
if (NPROCESSP(process)) Serror("bad process", process);
if (NINTEGERP(signal)) Serror("bad integer", signal);
kill(PROCPID(process), STk_integer_value(signal));
return UNDEFINED;
+8 -6
View File
@@ -57,10 +57,10 @@ static PRIMITIVE string_to_regexp (SCM obj)
struct regexp *r;
SCM z;
if (NSTRINGP (obj)) err ("not a string", obj);
ENTER_PRIMITIVE("string->regexp");
if ((r=TclRegComp(CHARS (obj))) == NULL)
Err("string->regexp: error compiling regexp", obj);
if (NSTRINGP (obj)) Serror("not a string", obj);
if ((r=TclRegComp(CHARS (obj))) == NULL) Serror("error compiling regexp", obj);
/* Regexp is Ok. Make a new cell and return it */
NEWCELL(z, tc_regexp);
@@ -72,15 +72,17 @@ static PRIMITIVE string_to_regexp (SCM obj)
* Try to match string against regular expression. Returns sub-match
* object, or #f if no match.
*/
static PRIMITIVE apply_regexp(SCM regexp, SCM l, SCM env)
static SCM apply_regexp(SCM regexp, SCM l, SCM env)
{
SCM string;
char *the_chars;
if (STk_llength (l) != 1) err ("apply: bad number of args", l);
ENTER_SCM("apply-regexp");
if (STk_llength (l) != 1) Serror("bad number of args", l);
string = CAR (l);
if (NSTRINGP (string)) err ("regexp: bad string", string);
if (NSTRINGP (string)) Serror("bad string", string);
the_chars = CHARS (string);
if (TclRegExec(REGEXP(regexp), the_chars, the_chars)) {
+80
View File
@@ -0,0 +1,80 @@
#!/bin/sh
:;exec snow -f "$0" "$@" # -*- Scheme -*-
;;;;
;;;;
;;;; stk-genmake -- Generate a Makefile for STk extensions
;;;;
;;;; Copyright © 1998 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
;;;;
;;;; Permission to use, copy, and/or distribute this software and its
;;;; documentation for any purpose and without fee is hereby granted, provided
;;;; that both the above copyright notice and this permission notice appear in
;;;; all copies and derived works. Fees for distribution or use of this
;;;; software or derived works may only be charged with express written
;;;; permission of the copyright holder.
;;;; This software is provided ``as is'' without express or implied warranty.
;;;;
;;;; $Id: stk-genmake.in 1.1 Sat, 06 Jun 1998 12:19:03 +0000 eg $
;;;;
;;;; Author: Erick Gallesio [eg@unice.fr]
;;;; Creation date: 1-Jun-1998 18:44
;;;; Last file update: 2-Jun-1998 17:51
(define version "0.1")
(define config.make-file ; Complete path name of the Config.make file
(string-append (%library-location) "/" (machine-type) "/Config/config.make"))
(define (abort . l)
(apply format (current-error-port) l)
(newline (current-error-port))
(exit 0))
(define (generate-prelude targets)
(format #t "# Makefile automatically generated by ~A version ~A. DO NOT EDIT\n"
*program-name* version)
(if (file-exists? config.make-file)
;; Copy the content of config.make
(with-input-from-file config.make-file
(lambda ()
(do ((l (read-line) (read-line)))
((eof-object? l) l)
(format #t "~A\n" l))))
;; config.make doesn't exists
(abort "~A: File ~S does not exist (you probably need a \"make install.libs\""
*program-name*))
;; Generate the .SUFFIXES rules
(format #t "CFLAGS= $(SH_CCFLAGS) $(STKCFLAGS) $(DFLGS) -DUSE_TK @DEFS@ \\\n")
(format #t "-I$(incdir)\n\n\n")
(format #t ".SUFFIXES: .$(SH_SUFFIX) .o .c\n\n")
(format #t ".o.$(SH_SUFFIX):\n")
(format #t "\t$(SH_LOADER) $(SH_LDFLAGS) $*.$(SH_SUFFIX) $<\n")
(format #t "\tif test -f a.out ;then mv a.out $*.$(SH_SUFFIX); fi\n\n")
;; Generate the main target
(format #t "\nall:\t")
(for-each (lambda (x) (format #t "~A.$(SH_SUFFIX) " x)) targets)
(format #t "\n\n"))
(define (generate-target target)
(format #t "\n~A.$(SH_SUFFIX): ~A.o\n\n" target target))
(define (generate-postlude)
(format #t "clean:\n")
(format #t "\t@/bin/rm -f *.o *.$(SH_SUFFIX) core *~\n")
(format #t "#End of Makefile\n"))
;;;;
;;;; Program starts here
;;;;
(if (zero? *argc*)
(abort "Usage: ~A target [target ...]" *program-name*))
(generate-prelude *argv*)
(for-each generate-target *argv*)
(generate-postlude)