[comp.lang.modula3] AIX PS/2 Libraries and Long Names

orgass+@rchland.ibm.com (Dick Orgass) (05/03/91)

The ar command for AIX PS/2 is restricted to file names whose length is
less than or equal to 14 characters.  Name truncation occurs while a
file is added and a new file whose name matches an old file in the first
14 characters replaces the old file even if the name is different beyond
the first 14 characters.

I never saw the problem when working with the SRC distribution; this may
reflect the fact that there are no files whose names are too long.

A small C program, fixobjs.c, is attached.  Using this program, it's
possible to build Modula-3 libraries when there are files whose names
fail to satisfy the 14 character name restriction.

An example of a make file fragment to use this program to create a
library follows.  In this example, the make macro INTOBJS contains a
list of the .io files that are to be placed into the library and MODOBJS
contains a list of .mo files to be placed in the library.  Finally,
EXTOBJS contains a list of plain .o files to be placed in the library.
The value of AR is the program ar, typically /bin/ar and the value of
ARFLAGS is the options to be passed to ar.

liboli.a: $(INTOBJS) $(MODOBJS) $(EXTOBJS)
	-rm -f liboli.a liboli.ma fixints fixmods
	ls *.io | fixobjs -i > fixints
	chmod +x fixints
	fixints
	$(AR) $(ARFLAGS) liboli.a `ls I*.o`
	ls *.mo | fixobjs -m > fixmods
	chmod +x fixmods
	fixmods
	$(AR) $(ARFLAGS) liboli.a `ls M*.o`
	$(AR) $(ARFLAGS) liboli.a $(EXTOBJS)
	-rm -f fixobjs fixmods I*.o M*.o

liboli.ma:	liboli.a
	$(M3AR) liboli.a

Of course, liboli.ma appears in the list of dependencies of all.

Dick

------------------- fixobjs.c -----------------------
/* File fixobjs.c created by Dick Orgass at 12:32:20 on Wed May  1 1991. */

/* Copyright (C) by IBM Corporation, 1991. */

#include <stdio.h>
#include <sys/dir.h>

extern char *strchr(char*, char);

#define private static

private char ibmid[] = "Copyright(c) by IBM Corporation, 1991.";
private char rcsHeader[] = "$Header$";
private char rcsRevision[] = "$Revision$";
private char rcsDate[] = "$Date$";

private void error() {
  printf("%s: Must specify exactly one of -i or -m.\n");
  exit(1);
}

void main (int argc, char **argv) {
  int fileNumber = 0;
  char leadingChar;
  char buff[MAXNAMLEN] = {'\0'};
  char *tmp;

  if ((argc == 1) || (argc > 2)) error();
  if (argv[1][0] != '-') error();
  switch (argv[1][1]) {
      case 'i':
	  leadingChar = 'I';
	  break;
      case 'm':
	  leadingChar = 'M';
	  break;
      default:
	  error();
  }
  printf("#! /bin/csh\n");
  while (TRUE) {
    if (fgets(buff, sizeof(buff), stdin) == NULL) break;
    tmp = strchr(buff, '\n');
    *tmp = '\0';
    printf("ln -s %s %c%.5d.o\n", buff, leadingChar, fileNumber);
    fileNumber++;
  }

}

/*

<date> by <name>

Brief description of the change and why it was made.

$Log$
*/
-----------------------  End ---------------------------