Commit b4aeb19e authored by simonm's avatar simonm

[project @ 1996-09-24 16:36:40 by simonm]

new build-ify
parent 102394e7
PROGRAMS = lndir \
runstdtest \
mkdependC \
mkdirhier \
fastmake \
ltx
all:: $(PROGRAMS)
/* stuff to have before we get going */
MsubNeededHere($(PROGRAMS))
/* === BUILD STUFF (installation, etc., below) ========== */
/* std X11 stuff: used in installing ghc/hslibs */
MsubProgramScriptTarget(BourneShell,mkdirhier,mkdirhier.sh,,)
BuildPgmFromOneCFile(lndir)
MsubMakefileDependentProgramScriptTarget(PerlCmd,runstdtest,runstdtest.prl,,)
MsubMakefileDependentProgramScriptTarget(PerlCmd,ltx,ltx.prl,,)
MsubProgramScriptTarget(PerlCmd,fastmake,fastmake.prl,,)
/*
mkdependC has to go in "bin" directory, because there may be
machine-dependent ideas of what CC to use, etc.
ltx, runstdtest: ditto, but only because of TMPDIR
*/
MsubMakefileDependentProgramScriptTarget(PerlCmd,mkdependC,mkdependC.prl,/*noflags*/,/*Makefile*/)
/* === INSTALLATION ======== */
/* the rest of these vary from std/useful to hackish dans le extreme */
MakeDirectories(install, $(INSTBINDIR) $(INSTSCRIPTDIR))
InstallScriptTarget(fastmake, $(INSTSCRIPTDIR))
InstallBinaryTarget(lndir, $(INSTBINDIR))
InstallScriptTarget(ltx, $(INSTBINDIR))
InstallScriptTarget(mkdependC, $(INSTBINDIR))
InstallScriptTarget(runstdtest, $(INSTBINDIR))
InstallManPageTarget(lndir,$(INSTCOMMANDIR),$(COMMANSUFFIX))
InstallManPageTarget(mkdirhier,$(INSTCOMMANDIR),$(COMMANSUFFIX))
/* === OTHER STUFF ========= */
ExtraStuffToClean($(PROGRAMS))
ClearTagsFile()
PerlTagsTarget( *.prl ) /* nothing for the Bourne shell scripts */
#! /usr/local/bin/perl
#
($Pgm = $0) =~ s/.*\/([^\/]+)$/\1/;
$Usage = "\n" . <<EOUSAGE;
Usage:
$Pgm [-? or -help] [-k] [-n] [-v] [-t] dir/module-target(s)
This script runs `make' to build the requested target, WITHOUT
including the dependencies generated by `mkdependHS' (i.e., all those
derived from import declarations).
With a -t flag, it also sets the modification time of the resulting
.hi file (one target only, please) to some EARLY date, so that changes
to that interface will not trigger much useless recompilation.
Typical uses, for module "Bar" in directory "foo":
(1) You've changed "Bar" and you want to recompile it; you know that
other module interfaces are stable, so you'd rather do without all
of `make''s prognostications:
$Pgm foo/Bar.s
(2) You've ADDED a new function to "Bar"; you want to recompile that
module, BUT NOT TRIGGER LOTS OF FURTHER COMPILATION because of the
"changed" interface file:
$Pgm -t foo/Bar.s
USE AT YOUR OWN RISK: you can make a big mess with this script!
EOUSAGE
$Makefile = 'Makefile';
if ( $ENV{'TMPDIR'} ) { # where to make tmp file names
$Tmpfile = $ENV{'TMPDIR'} . "/Makefile$$";
} else {
$Tmpfile = "$(TMPDIR)/Makefile$$";
$ENV{'TMPDIR'} = '$(TMPDIR)'; # set the env var as well
}
$SleazyTouch = '/usr/5bin/touch';
$DoTouch = 0;
$Verbose = 0;
$MakeFlags = '';
sub rm_temp_file {
print STDERR "rm $Tmpfile\n" if $Verbose;
unlink $Tmpfile;
exit(1);
}
$SIG{'INT'} = 'rm_temp_file';
$SIG{'QUIT'} = 'rm_temp_file';
$Target = '';
$DirMod = ''; # the dir/module-file to make
# process ARGV
while ($_ = $ARGV[0]) {
shift(@ARGV);
if (/^-\?$/ || /^-help$/) {
print $Usage;
exit 1;
} elsif (/^-v$/) {
$Verbose = 1;
} elsif (/^-t$/) {
$Do_touch = 1;
} elsif (/^-k$/) {
$MakeFlags .= ' -k';
} elsif (/^-n$/) {
$MakeFlags .= ' -n';
} elsif (/^-d$/) {
$MakeFlags .= ' -d';
} elsif (/^-/) {
print STDERR "$Pgm: unknown option: $_\n\n$Usage";
exit 1;
} elsif (/^([A-Z_]+)=(.+)/) {
$MakeFlags .= " $1=\"$2\"";
} elsif ($Do_touch) { # the module file
$Target = $_;
if ( /([^\/]+\/[^\/\.]+)\.[a-z]+/ ) {
$DirMod = $1;
} else {
print STDERR "$Pgm: argument not of the form: directory/Module.suffix: $_\n\n$Usage";
exit 1;
}
} else { # accumulate as "Target"...
$Target .= " $_";
}
}
if ($Do_touch && $Target =~ / /) {
print STDERR "$Pgm: too many arguments\n\n$Usage";
exit 1;
}
open(INF, "<$Makefile") || die "Can't open $Makefile for input\n";
open(OUTF,">$Tmpfile") || die "Can't open $Tmpfile for output\n";
select(OUTF);
$_ = <INF>;
# copy through until ...
while ( $_ && ! /^# DO NOT DELETE: Beginning of Haskell dependencies/ ) {
print $_;
$_ = <INF>;
}
# now copy through 'til the end, omitting the %.{o,s,hc} : %.hi dependencies
while ( $_ ) {
print $_ if ! /^\S+ : \S+\.hi$/;
$_ = <INF>;
}
close(INF);
close(OUTF);
$Make = 'make JMAKE=jmake LIT2PGM=lit2pgm LIT2LATEX=lit2latex LIT2TEXI=lit2texi MKDEPENDLIT=mkdependlit MAKEINFO=makeinfo POSTMAKEINFO=postmakeinfo';
print STDERR "$Make $MakeFlags -f $Tmpfile $Target; rm $Tmpfile\n" if $Verbose;
system( "$Make $MakeFlags -f $Tmpfile $Target; rm $Tmpfile" );
if ($Do_touch) {
print STDERR "$SleazyTouch -m 01010101 $DirMod\.hi\n" if $Verbose;
system( "$SleazyTouch -m 01010101 $DirMod\.hi" );
}
/*
* $XConsortium: Xos.h,v 1.47 91/08/17 17:14:38 rws Exp $
*
* Copyright 1987 by the Massachusetts Institute of Technology
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in advertising
* or publicity pertaining to distribution of the software without specific,
* written prior permission. M.I.T. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* The X Window System is a Trademark of MIT.
*
*/
/* This is a collection of things to try and minimize system dependencies
* in a "signficant" number of source files.
*/
#ifndef _XOS_H_
#define _XOS_H_
#include "lndir-Xosdefs.h"
/*
* Get major data types (esp. caddr_t)
*/
#ifdef USG
#ifndef __TYPES__
#ifdef CRAY
#define word word_t
#endif /* CRAY */
#include <sys/types.h> /* forgot to protect it... */
#define __TYPES__
#endif /* __TYPES__ */
#else /* USG */
#if defined(_POSIX_SOURCE) && defined(MOTOROLA)
#undef _POSIX_SOURCE
#include <sys/types.h>
#define _POSIX_SOURCE
#else
#include <sys/types.h>
#endif
#endif /* USG */
/*
* Just about everyone needs the strings routines. We provide both forms here,
* index/rindex and strchr/strrchr, so any systems that don't provide them all
* need to have #defines here.
*/
#ifndef X_NOT_STDC_ENV
#include <string.h>
#define index strchr
#define rindex strrchr
#else
#ifdef SYSV
#include <string.h>
#define index strchr
#define rindex strrchr
#else
#include <strings.h>
#define strchr index
#define strrchr rindex
#endif
#endif
/*
* Get open(2) constants
*/
#ifdef X_NOT_POSIX
#include <fcntl.h>
#ifdef USL
#include <unistd.h>
#endif /* USL */
#ifdef CRAY
#include <unistd.h>
#endif /* CRAY */
#ifdef MOTOROLA
#include <unistd.h>
#endif /* MOTOROLA */
#ifdef SYSV386
#include <unistd.h>
#endif /* SYSV386 */
#include <sys/file.h>
#else /* X_NOT_POSIX */
#if !defined(_POSIX_SOURCE) && defined(macII)
#define _POSIX_SOURCE
#include <fcntl.h>
#undef _POSIX_SOURCE
#else
#include <fcntl.h>
#endif
#include <unistd.h>
#endif /* X_NOT_POSIX else */
/*
* Get struct timeval
*/
#ifdef SYSV
#ifndef USL
#include <sys/time.h>
#endif
#include <time.h>
#ifdef CRAY
#undef word
#endif /* CRAY */
#if defined(USG) && !defined(CRAY) && !defined(MOTOROLA)
struct timeval {
long tv_sec;
long tv_usec;
};
#ifndef USL_SHARELIB
struct timezone {
int tz_minuteswest;
int tz_dsttime;
};
#endif /* USL_SHARELIB */
#endif /* USG */
#else /* not SYSV */
#if defined(_POSIX_SOURCE) && defined(SVR4)
/* need to omit _POSIX_SOURCE in order to get what we want in SVR4 */
#undef _POSIX_SOURCE
#include <sys/time.h>
#define _POSIX_SOURCE
#else
#include <sys/time.h>
#endif
#endif /* SYSV */
/* use POSIX name for signal */
#if defined(X_NOT_POSIX) && defined(SYSV) && !defined(SIGCHLD)
#define SIGCHLD SIGCLD
#endif
#ifdef ISC
#include <sys/bsdtypes.h>
#endif
#endif /* _XOS_H_ */
/*
* O/S-dependent (mis)feature macro definitions
*
* $XConsortium: Xosdefs.h,v 1.7 91/07/19 23:22:19 rws Exp $
*
* Copyright 1991 Massachusetts Institute of Technology
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. M.I.T. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _XOSDEFS_H_
#define _XOSDEFS_H_
/*
* X_NOT_STDC_ENV means does not have ANSI C header files. Lack of this
* symbol does NOT mean that the system has stdarg.h.
*
* X_NOT_POSIX means does not have POSIX header files. Lack of this
* symbol does NOT mean that the POSIX environment is the default.
* You may still have to define _POSIX_SOURCE to get it.
*/
#ifdef NOSTDHDRS
#define X_NOT_POSIX
#define X_NOT_STDC_ENV
#endif
#ifdef NeXT
#define X_NOT_POSIX
#endif
#ifdef sony
#ifndef SYSTYPE_SYSV
#define X_NOT_POSIX
#endif
#endif
#ifdef UTEK
#define X_NOT_POSIX
#define X_NOT_STDC_ENV
#endif
#ifdef CRAY
#define X_NOT_POSIX
#endif
#ifdef vax
#ifndef ultrix /* assume vanilla BSD */
#define X_NOT_POSIX
#define X_NOT_STDC_ENV
#endif
#endif
#ifdef luna
#define X_NOT_POSIX
#define X_NOT_STDC_ENV
#endif
#ifdef Mips
#define X_NOT_POSIX
#define X_NOT_STDC_ENV
#endif
#ifdef USL
#ifdef SYSV /* (release 3.2) */
#define X_NOT_POSIX
#define X_NOT_STDC_ENV
#endif
#endif
#ifdef SYSV386
#ifdef SYSV
#define X_NOT_POSIX
#define X_NOT_STDC_ENV
#endif
#endif
#ifdef MOTOROLA
#ifdef SYSV
#define X_NOT_STDC_ENV
#endif
#endif
#endif /* _XOSDEFS_H_ */
/* $XConsortium: lndir.c,v 1.5 91/07/21 15:52:11 rws Exp $ */
/* Create shadow link tree (after X11R4 script of the same name)
Mark Reinhold (mbr@lcs.mit.edu)/3 January 1990 */
/* Copyright 1990, Massachusetts Institute of Technology
Permission to use, copy, modify, and distribute this program for any purpose
and without fee is hereby granted, provided that this copyright and
permission notice appear on all copies and supporting documentation, that
the name of MIT not be used in advertising or publicity pertaining to
distribution of this program without specific prior permission, and that
notice be given in supporting documentation that copying and distribution is
by permission of MIT. MIT makes no representations about the suitability of
this software for any purpose. It is provided "as is" without expressed or
implied warranty.
*/
/* From the original /bin/sh script:
Used to create a copy of the a directory tree that has links for all
non-directories (except those named RCS or SCCS). If you are
building the distribution on more than one machine, you should use
this script.
If your master sources are located in /usr/local/src/X and you would like
your link tree to be in /usr/local/src/new-X, do the following:
% mkdir /usr/local/src/new-X
% cd /usr/local/src/new-X
% lndir ../X
*/
#include "lndir-Xos.h"
#include <stdio.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <errno.h>
#ifndef X_NOT_POSIX
#include <dirent.h>
#else
#ifdef SYSV
#include <dirent.h>
#else
#ifdef USG
#include <dirent.h>
#else
#include <sys/dir.h>
#ifndef dirent
#define dirent direct
#endif
#endif
#endif
#endif
extern int errno;
int silent;
void
quit (code, fmt, a1, a2, a3)
char *fmt;
int code, a1, a2, a3; /* partain */
{
fprintf (stderr, fmt, a1, a2, a3);
putc ('\n', stderr);
exit (code);
}
void
quiterr (code, s)
char *s;
int code; /* partain */
{
perror (s);
exit (code);
}
void
msg (fmt, a1, a2, a3)
char *fmt;
int a1, a2, a3; /* partain */
{
fprintf (stderr, fmt, a1, a2, a3);
putc ('\n', stderr);
}
/* Recursively create symbolic links from the current directory to the "from"
directory. Assumes that files described by fs and ts are directories. */
int
dodir (fn, fs, ts, rel)
char *fn; /* name of "from" directory, either absolute or
relative to cwd */
struct stat *fs, *ts; /* stats for the "from" directory and cwd */
int rel; /* if true, prepend "../" to fn before using */
{
DIR *df;
struct dirent *dp;
char buf[MAXPATHLEN + 1], *p;
char symbuf[MAXPATHLEN + 1];
struct stat sb, sc;
int n_dirs;
if ((fs->st_dev == ts->st_dev) && (fs->st_ino == ts->st_ino)) {
msg ("%s: From and to directories are identical!", fn);
return 1;
}
if (rel)
strcpy (buf, "../");
else
buf[0] = '\0';
strcat (buf, fn);
if (!(df = opendir (buf))) {
msg ("%s: Cannot opendir", buf);
return 1;
}
p = buf + strlen (buf);
*p++ = '/';
n_dirs = fs->st_nlink;
while (dp = readdir (df)) {
strcpy (p, dp->d_name);
if (n_dirs > 0) {
if (stat (buf, &sb) < 0) {
perror (buf);
continue;
}
if (sb.st_mode & S_IFDIR) {
/* directory */
n_dirs--;
if (dp->d_name[0] == '.' &&
(dp->d_name[1] == '\0' || (dp->d_name[1] == '.' &&
dp->d_name[2] == '\0')))
continue;
if (!strcmp (dp->d_name, "CVS")) /* partain */
continue;
if (!strcmp (dp->d_name, "RCS"))
continue;
if (!strcmp (dp->d_name, "SCCS"))
continue;
if (!silent)
printf ("%s:\n", buf);
if ((stat (dp->d_name, &sc) < 0) && (errno == ENOENT)) {
if (mkdir (dp->d_name, 0777) < 0 ||
stat (dp->d_name, &sc) < 0) {
perror (dp->d_name);
continue;
}
}
if (readlink (dp->d_name, symbuf, sizeof(symbuf) - 1) >= 0) {
msg ("%s: is a link instead of a directory\n", dp->d_name);
continue;
}
if (chdir (dp->d_name) < 0) {
perror (dp->d_name);
continue;
}
dodir (buf, &sb, &sc, (buf[0] != '/'));
if (chdir ("..") < 0)
quiterr (1, "..");
continue;
}
}
/* non-directory */
if (symlink (buf, dp->d_name) < 0) {
int saverrno = errno;
int symlen;
symlen = readlink(dp->d_name, symbuf, sizeof(symbuf) - 1);
errno = saverrno;
if (symlen > 0)
symbuf[symlen] = '\0';
if (symlen < 0 || strcmp(symbuf, buf))
perror (dp->d_name);
}
}
closedir (df);
return 0;
}
void
main (ac, av)
int ac;
char **av;
{
char *fn, *tn;
struct stat fs, ts;
silent = 0;
if (ac > 1 && !strcmp(av[1], "-silent")) {
silent = 1;
}
if (ac < silent + 2 || ac > silent