[27058] in Source-Commits

home help back first fref pref prev next nref lref last post

/svn/athena r25919 - in trunk/athena/bin/athdir: . man src

daemon@ATHENA.MIT.EDU (Alexander Chernyakhovsky)
Mon Apr 15 00:09:29 2013

Date: Mon, 15 Apr 2013 00:09:23 -0400
From: Alexander Chernyakhovsky <achernya@MIT.EDU>
Message-Id: <201304150409.r3F49NMu015893@drugstore.mit.edu>
To: source-commits@MIT.EDU
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Author: achernya
Date: 2013-04-15 00:09:22 -0400 (Mon, 15 Apr 2013)
New Revision: 25919

Added:
   trunk/athena/bin/athdir/Makefile.am
   trunk/athena/bin/athdir/m4/
   trunk/athena/bin/athdir/man/
   trunk/athena/bin/athdir/man/Makefile.am
   trunk/athena/bin/athdir/man/athdir.1
   trunk/athena/bin/athdir/src/
   trunk/athena/bin/athdir/src/Makefile.am
   trunk/athena/bin/athdir/src/athdir.c
Removed:
   trunk/athena/bin/athdir/Makefile.in
   trunk/athena/bin/athdir/athdir.1
   trunk/athena/bin/athdir/athdir.c
Modified:
   trunk/athena/bin/athdir/configure.ac
Log:
Convert athdir to automake

Added: trunk/athena/bin/athdir/Makefile.am
===================================================================
--- trunk/athena/bin/athdir/Makefile.am	                        (rev 0)
+++ trunk/athena/bin/athdir/Makefile.am	2013-04-15 04:09:22 UTC (rev 25919)
@@ -0,0 +1,2 @@
+ACLOCAL_AMFLAGS = --install -I m4
+SUBDIRS = src man

Modified: trunk/athena/bin/athdir/configure.ac
===================================================================
--- trunk/athena/bin/athdir/configure.ac	2013-04-12 21:23:10 UTC (rev 25918)
+++ trunk/athena/bin/athdir/configure.ac	2013-04-15 04:09:22 UTC (rev 25919)
@@ -1,17 +1,41 @@
-dnl Process this file with autoconf to produce a configure script.
-AC_INIT
-AC_CONFIG_SRCDIR([athdir.c])
+#                                               -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
 
+AC_PREREQ([2.65])
+AC_INIT([athdir], [10.1], [debathena@mit.edu])
+AM_INIT_AUTOMAKE([foreign -Wall])
+AM_MAINTAINER_MODE([enable])
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
+AC_CONFIG_MACRO_DIR([m4])
+AC_CONFIG_SRCDIR([src/athdir.c])
+AC_CONFIG_HEADERS([config.h])
+
+# Checks for programs.
 AC_PROG_CC
-AC_PROG_INSTALL
-AC_PROG_MKDIR_P
+AM_PROG_CC_C_O
+# automake 1.12 seems to require this, but automake 1.11 doesn't recognize it
+m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
+LT_INIT
 
-PKG_CHECK_MODULES([ATHDIR], [athdir])
+# Checks for libraries.
 
-AC_MSG_NOTICE([Adding athdir CFLAGS ${ATHDIR_CFLAGS}])
-CFLAGS="${ATHDIR_CFLAGS} ${CFLAGS}"
-AC_MSG_NOTICE([Adding athdir LIBS ${ATHDIR_LIBS}])
-LIBS="${ATHDIR_LIBS} ${LIBS}"
+# Checks for header files.
+AC_CHECK_HEADERS([stdlib.h string.h sys/param.h])
 
-AC_CONFIG_FILES([Makefile])
+# Checks for typedefs, structures, and compiler characteristics.
+
+# Checks for library functions.
+AC_FUNC_MALLOC
+AC_FUNC_REALLOC
+AC_CHECK_FUNCS([strchr])
+
+# More stuff
+PKG_CHECK_MODULES([LIBATHDIR], [athdir])
+AC_SUBST([LIBATHDIR_CFLAGS])
+AC_SUBST([LIBATHDIR_LIBS])
+
+AC_CONFIG_FILES([Makefile
+                 src/Makefile
+		 man/Makefile
+])
 AC_OUTPUT

Added: trunk/athena/bin/athdir/man/Makefile.am
===================================================================
--- trunk/athena/bin/athdir/man/Makefile.am	                        (rev 0)
+++ trunk/athena/bin/athdir/man/Makefile.am	2013-04-15 04:09:22 UTC (rev 25919)
@@ -0,0 +1 @@
+dist_man1_MANS = athdir.1

Copied: trunk/athena/bin/athdir/man/athdir.1 (from rev 25918, trunk/athena/bin/athdir/athdir.1)
===================================================================
--- trunk/athena/bin/athdir/man/athdir.1	                        (rev 0)
+++ trunk/athena/bin/athdir/man/athdir.1	2013-04-15 04:09:22 UTC (rev 25919)
@@ -0,0 +1,171 @@
+.TH ATHDIR 1 "7 March 1998"
+.ds ]W MIT Athena
+.SH NAME
+athdir \- find machine specific directories using Athena conventions
+.SH SYNOPSIS
+.nf
+athdir \fIlockerpath\fR [\fItype\fR]
+
+athdir [-t \fItype\fR] [-p \fIlockerpath\fR ...] [-e] [-c] [-l] [-i | -d]
+       [-r \fIrecsep\fR] [-f \fIformat\fR] [-s \fIsysname\fR] [-m \fImachtype\fR]
+.fi
+.SH DESCRIPTION
+\fIathdir\fR provides the most reliable way to determine the location
+in a locker of specific types of machine dependent files. While in C
+shell scripts the shell variable \fIbindir\fR is typically available,
+that information is not available in all environments (such as
+makefiles) and not necessarily as reliable, as it contains no
+intelligence. Similarly, while the environment variable
+\fIATHENA_SYS\fR is widely available, attempting to use it in
+makefiles or resource files may fail on older lockers that have not
+yet been upgraded to use the new conventions, or in lockers that have
+not been updated to support the latest operating system releases. (See
+\fIlockers\fR(7) for more information on locker directory
+conventions.)
+
+In the first invocation shown above, \fIathdir\fR does not accept
+command line options other than the two listed, and they must be in
+the listed order. If \fItype\fR is not specified, ``bin'' is assumed.
+
+In the second invocation above, no particular option is required,
+though at least one option is.  \fItype\fR has no default value, and
+the options may be specified in any order.
+.SH EXAMPLES
+\fIathdir\fR may be used to find directories for any sort of machine
+dependent or potentially machine dependent files. In its most common
+form, it should be used to replace \fImachtype\fR(1) (as in
+``/mit/locker/`machtype`bin''). For example,
+
+     set path=($path `athdir /mit/locker`)
+
+will append ``/mit/locker/arch/pmax_ul4/bin'' to the user's search
+path if the locker supports that as the machine specific binary
+directory, or ``/mit/locker/decmipsbin'' otherwise. Note that in this
+case, no type argument is specified, so ``bin'' is assumed. The
+example is shorthand for using `athdir /mit/locker bin`. Similarly,
+one might have in one's .twmrc file:
+
+    "meow"   f.exec "`athdir /mit/sipb`/oneko &"
+
+to replace:
+
+    "meow"   f.exec "/mit/sipb/`machtype`bin/oneko &"
+
+The rest of this manual page will probably not be of interest to most
+users, but may be of interest to developers.
+
+Another useful application for \fIathdir\fR is in makefiles. For
+example, suppose you wish to build a program against the x11 locker.
+You might start with
+
+     INCLUDES = `athdir /mit/x11 include`
+     LIBS = `athdir /mit/x11 lib`
+
+to find the appropriate directories in the locker. For dependencies
+on multiple lockers, you might have
+
+     INCLUDES = `athdir -t include -p /mit/motif /mit/x11`
+     LIBS = `athdir -t lib -p /mit/motif /mit/x11`
+
+which might resolve to
+
+     INCLUDES = /mit/motif/include /mit/x11/include
+     LIBS = /mit/motif/sun4lib /mit/x11/arch/sun4m_53/lib
+
+Note that this example allows for the possibility of machine dependent
+include files as well as libraries.
+
+In general, \fItype\fRs are treated as random strings by
+\fIathdir\fR. \fIathdir\fR checks the locker first for
+arch/$ATHENA_SYS/\fItype\fR. Next it checks for arch/COMPAT/\fitype\fR,
+where COMPAT iterates over the values in $ATHENA_SYS_COMPAT.
+Then it checks for `machtype`\fItype\fR. Finally it looks for \fItype\fR
+alone. Exceptions to this rule are cases where
+a convention is never expected to be used, or where a convention is
+explicitly discouraged and has never been supported. Note that if any
+future conventions arise, \fIathdir\fR will know about them and act
+accordingly. Thus, in theory, the usage of \fIathdir\fR should be
+forward compatible, and is encouraged.
+.SH OPTIONS
+\fIathdir\fR provides a few options for modifying its default behavior
+and providing other useful information.
+.TP 8
+.B \-e
+This option causes \fIathdir\fR to not engage in potentially annoying
+editorial behavior. It will not implement the above mentioned
+exceptions on conventions not expected or discouraged.
+.TP 8
+.B \-c
+This option causes \fIathdir\fR to not check for the usage of
+different possible conventions, and simply return output in the form
+of currently favored convention (arch). This is useful, for example,
+in makefiles that may wish to ``\fImkdir\fR -p'' target directories.
+.TP 8
+.B \-d
+This option, when used with \-c, tells \fIathdir\fR that you wish it
+to use the favored machine dependent directory convention when
+returning a pathname. \fIathdir\fR makes assumptions, based on
+\fItype\fR, what kind of directory should be returned. For example, if
+the \fItype\fR were ``include,'' \fIathdir\fR would ordinarily return
+something like ``/mit/locker/include.'' If you specify \-d, it would
+return ``/mit/locker/arch/$ATHENA_SYS/include'' instead.
+.TP 8
+.B \-i
+This option, when used with \-c, tells \fIathdir\fR that you wish it
+to use the favored machine independent directory convention when
+returning a pathname. This is basically the reverse of the \-d option.
+\fIathdir\fR, when it does not recognize a \fItype\fR, assumes the
+type to be machine dependent, so \-i may be used to override that.
+.TP 8
+.B \-l
+This option causes \fIathdir\fR to list the locations it would look
+for the \fItype\fR of directory requested, rather than looking in them
+and returning a single value. If a directory path is not specified,
+\fIathdir\fR will output a ``%p'' in its place; if a \fItype\fR is not
+specified, a ``%t'' will be output in its place, and all three above
+mentioned possibilities will be output.
+.TP 8
+.B \-f \fIformat\fR
+This option passes a format string to \fIathdir\fR to be used as a
+style for searching for directories. It is used as the preferred
+path style, with the built-in styles as fallbacks. It makes the following
+substitutions:
+
+        %p   path (as passed by -p)
+        %t   type (as passed by -t)
+        %s   sysname
+        %m   machtype value
+
+For example, the arch convention uses the string %p/arch/%s/%t. When
+making the substitution for %s, \fIATHENA_SYS_COMPAT\fR values will be
+substituted after the \fIATHENA_SYS\fR value as necessary.
+.TP 8
+.B \-r \fIrecsep\fR
+Specify the record separator when multiple paths are output. By default this
+is a newline. It may be useful to specify it to be a space or colon on
+various occasions.
+.TP 8
+.B \-s \fIsysname\fR
+This option allows a command line override for the \fIATHENA_SYS\fR
+value used in generating new style machine directories.
+.TP 8
+.B \-m \fImachtype\fR
+This option allows a command line override for the \fImachtype\fR
+value used in generating old style machine directories.
+.SH VARIABLES
+The environment variable \fIATHENA_SYS\fR is used to determine the
+sysname value when determining path names for new style paths, unless
+overridden by the \-s option.
+
+The environment variable \fIATHENA_SYS_COMPAT\fR is a colon-separated
+list of fallback sysname values which are known to be generally
+compatible with the current system. Thus, on a Solaris 2.6 machine,
+\fIATHENA_SYS\fR may be set to sun4x_56, with \fIATHENA_SYS_COMPAT\fR
+set to sun4x_55:sun4m_54. Then if there is no arch/sun4x_56 directory
+available, arch/sun4x_55 will be checked, etc.
+.SH SEE ALSO
+machtype(1), lockers(7), mkdir(1)
+.SH AUTHOR
+Craig Fields, MIT Information Systems
+.br
+Copyright (c) 1995, Massachusetts Institute of Technology

Added: trunk/athena/bin/athdir/src/Makefile.am
===================================================================
--- trunk/athena/bin/athdir/src/Makefile.am	                        (rev 0)
+++ trunk/athena/bin/athdir/src/Makefile.am	2013-04-15 04:09:22 UTC (rev 25919)
@@ -0,0 +1,4 @@
+bin_PROGRAMS = athdir
+athdir_SOURCES = athdir.c
+athdir_CFLAGS = @LIBATHDIR_CFLAGS@
+athdir_LDADD = @LIBATHDIR_LIBS@

Copied: trunk/athena/bin/athdir/src/athdir.c (from rev 25918, trunk/athena/bin/athdir/athdir.c)
===================================================================
--- trunk/athena/bin/athdir/src/athdir.c	                        (rev 0)
+++ trunk/athena/bin/athdir/src/athdir.c	2013-04-15 04:09:22 UTC (rev 25919)
@@ -0,0 +1,253 @@
+/* Copyright 1998 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.
+ */
+
+static const char rcsid[] = "$Id: athdir.c,v 1.4 1999-09-15 23:57:14 danw Exp $";
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <athdir.h>
+
+char *progName;
+
+void usage(void);
+void repeatflag(char *option);
+
+int main(int argc, char **argv)
+{
+  int num_dirs = 0, flags = 0;
+  char **dir_list, *type = NULL, *athsys = NULL, *hosttype = NULL;
+  char *auxconvention = NULL, *recsep = NULL, **ptr;
+  char **path_list;
+  int i;
+  int match = 0;
+
+  progName = strrchr(argv[0], '/');
+  if (progName != NULL)
+    progName++;
+  else
+    progName = argv[0];
+
+  if (argc == 1)
+    usage();
+
+  if (argc)
+    dir_list = malloc((argc + 1) * sizeof(char *));
+
+  if (dir_list == NULL)
+    {
+      fprintf(stderr, "%s: out of memory\n", progName);
+      exit(1);
+    }
+
+  if (argv[1][0] != '-')
+    {
+      if (argc > 3)
+	usage();
+
+      dir_list[num_dirs++] = argv[1];
+
+      if (argv[2])
+	{
+	  if (argv[2][0] == '-')
+	    usage();
+
+	  type = argv[2];
+	}
+      else
+	type = "bin";
+    }
+  else
+    {
+      argv++;
+
+      while (*argv)
+	{
+	  if (**argv != '-' || (*argv)[2] != '\0')
+	    {
+	      fprintf(stderr, "%s: unknown option: %s\n", progName, *argv);
+	      usage();
+	    }
+
+	  switch((*argv)[1])
+	    {
+	    case 't':
+	      if (type)
+		repeatflag(*argv);
+	      argv++;
+	      if (*argv == NULL)
+		usage();
+	      type = *argv++;
+	      break;
+
+	    case 'p':
+	      if (num_dirs != 0)
+		repeatflag(*argv);
+
+	      argv++;
+	      if (*argv == NULL)
+		usage();
+	      while (*argv != NULL && **argv != '-')
+		dir_list[num_dirs++] = *argv++;
+	      break;
+
+	    case 'e':
+	      if (flags & ATHDIR_SUPPRESSEDITORIALS)
+		repeatflag(*argv);
+	      argv++;
+	      flags |= ATHDIR_SUPPRESSEDITORIALS;
+	      break;
+
+	    case 'c':
+	      if (flags & ATHDIR_SUPPRESSSEARCH)
+		repeatflag(*argv);
+	      argv++;
+	      flags |= ATHDIR_SUPPRESSSEARCH;
+	      break;
+
+	    case 'l':
+	      if (flags & ATHDIR_LISTSEARCHDIRECTORIES)
+		repeatflag(*argv);
+	      argv++;
+	      flags |= ATHDIR_LISTSEARCHDIRECTORIES;
+	      break;
+
+	    case 's':
+	      if (athsys)
+		repeatflag(*argv);
+	      argv++;
+	      if (*argv == NULL)
+		usage();
+	      athsys = *argv++;
+	      break;
+
+	    case 'm':
+	      if (hosttype != NULL)
+		repeatflag(*argv);
+	      argv++;
+	      if (*argv == NULL)
+		usage();
+	      hosttype = *argv++;
+	      break;
+
+	    case 'f':
+	      if (auxconvention)
+		repeatflag(*argv);
+	      argv++;
+	      if (*argv == NULL)
+		usage();
+	      auxconvention = *argv++;
+	      break;
+
+	    case 'r':
+	      if (recsep != NULL)
+		repeatflag(*argv);
+	      argv++;
+	      if (*argv == NULL)
+		usage();
+	      recsep = *argv++;
+	      break;
+
+	    case 'd':
+	      if (flags & ATHDIR_MACHINEDEPENDENT)
+	        repeatflag(*argv);
+	      argv++;
+	      flags |= ATHDIR_MACHINEDEPENDENT;
+	      break;
+
+	    case 'i':
+	      if (flags & ATHDIR_MACHINEINDEPENDENT)
+	        repeatflag(*argv);
+	      argv++;
+	      flags |= ATHDIR_MACHINEINDEPENDENT;
+	      break;
+
+	    default:
+	      fprintf(stderr, "%s: unknown option: %s\n", progName, *argv);
+	      usage();
+	      break;
+	    }
+	}
+    }
+
+  if (!num_dirs)
+    dir_list[num_dirs++] = NULL;
+
+  /* Default record separator is a newline. */
+  if (!recsep)
+    recsep = "\n";
+
+  for (i = 0; i < num_dirs; i++)
+    {
+      path_list = athdir_get_paths(dir_list[i], type, athsys, NULL, hosttype,
+				   auxconvention, flags);
+      if (path_list != NULL)
+	{
+	  for (ptr = path_list; *ptr != NULL; ptr++)
+	    {
+	      if (match == 1)
+		fprintf(stdout, "%s", recsep);
+	      match = 1;
+	      fprintf(stdout, "%s", *ptr);
+	    }
+
+	  athdir_free_paths(path_list);
+	}
+    }
+
+  if (match)
+    fprintf(stdout, "\n");
+
+#ifdef DEBUG
+  fprintf(stdout, "%s ", progName);
+  if (type != NULL)
+    fprintf(stdout, "-t %s ", type);
+  if (num_dirs)
+    {
+      fprintf(stdout, "-p ");
+      for (i = 0; i < num_dirs; i++)
+	fprintf(stdout, "%s ", dir_list[i]);
+    }
+  if (ATHDIR_SUPPRESSEDITORIALS & flags)
+    fprintf(stdout, "-e ");
+  if (ATHDIR_SUPPRESSSEARCH & flags)
+    fprintf(stdout, "-c ");
+  if (ATHDIR_LISTSEARCHDIRECTORIES & flags)
+    fprintf(stdout, "-l ");
+  fprintf(stdout, "\n");
+#endif
+
+  return match == 0;
+}
+
+void usage(void)
+{
+  fprintf(stderr, "usage: %s path [type]\n", progName);
+  fprintf(stderr,
+	  "   or: %s [-t type] [-p path ...] [-e] [-c] [-l] [-d | -i]\n",
+	  progName);
+  fprintf(stderr,
+	  "       [-r recsep] [-f format] [-s sysname] [-m machtype]\n");
+  exit(1);
+}
+
+void repeatflag(char *option)
+{
+  fprintf(stderr, "%s: %s already specified.\n", progName, option);
+  usage();
+}


home help back first fref pref prev next nref lref last post