ICU-1868 shorten .c and .o filenames on AS400

X-SVN-Rev: 9589
This commit is contained in:
Steven R. Loomis 2002-08-06 19:06:31 +00:00
parent a9412507e7
commit ecdf1b3bb9
4 changed files with 100 additions and 119 deletions

View File

@ -28,69 +28,6 @@
#include "pkgtypes.h"
#include "makefile.h"
static void
writeObjRules(UPKGOptions *o, FileStream *makefile, CharList **objects)
{
const char *p, *baseName;
char *tmpPtr;
char tmp[1024];
char stanza[1024];
char cfile[1024];
CharList *oTail = NULL;
CharList *infiles;
CharList *parents = NULL, *commands = NULL;
infiles = o->filePaths;
for(;infiles;infiles = infiles->next) {
baseName = findBasename(infiles->str);
p = uprv_strrchr(baseName, '.');
if( (p == NULL) || (*p == '\0' ) ) {
continue;
}
uprv_strncpy(tmp, baseName, p-baseName);
p++;
uprv_strcpy(tmp+(p-1-baseName), "_"); /* to append */
uprv_strcat(tmp, p);
uprv_strcat(tmp, OBJ_SUFFIX);
/* iSeries cannot have '-' in the .o objects. */
for( tmpPtr = tmp; *tmpPtr; tmpPtr++ ) {
if ( *tmpPtr == '-' ) {
*tmpPtr = '_';
}
}
*objects = pkg_appendToList(*objects, &oTail, uprv_strdup(tmp));
/* write source list */
strcpy(cfile,tmp);
strcpy(cfile+strlen(cfile)-strlen(OBJ_SUFFIX), ".c" );
/* Make up parents.. */
parents = pkg_appendToList(parents, NULL, uprv_strdup(infiles->str));
/* make up commands.. */
sprintf(stanza, "$(INVOKE) $(GENCCODE) -n $(ENTRYPOINT) -d $(TEMP_DIR) $<");
commands = pkg_appendToList(commands, NULL, uprv_strdup(stanza));
sprintf(stanza, "$(COMPILE.c) -o $@ $(TEMP_DIR)/%s", cfile);
commands = pkg_appendToList(commands, NULL, uprv_strdup(stanza));
sprintf(stanza, "$(TEMP_DIR)/%s", tmp);
pkg_mak_writeStanza(makefile, o, stanza, parents, commands);
pkg_deleteList(parents);
pkg_deleteList(commands);
parents = NULL;
commands = NULL;
}
}
void pkg_mode_dll(UPKGOptions *o, FileStream *makefile, UErrorCode *status)
{
@ -173,7 +110,7 @@ void pkg_mode_dll(UPKGOptions *o, FileStream *makefile, UErrorCode *status)
T_FileStream_writeLine(makefile, tmp);
/* Write compile rules */
writeObjRules(o, makefile, &objects);
pkg_mak_writeObjRules(o, makefile, &objects, OBJ_SUFFIX);
sprintf(tmp, "# List file for gencmn:\n"
"CMNLIST=%s%s$(NAME)_dll.lst\n\n",

View File

@ -15,6 +15,14 @@
* Emit a GNU makefile
*/
#include "unicode/utypes.h"
#include "cmemory.h"
#include "cstring.h"
#include "filestrm.h"
#include "toolutil.h"
#include "unewdata.h"
#include "uoptions.h"
#include "pkgtypes.h"
#include "makefile.h"
#include <stdio.h>
#include <string.h>
@ -130,3 +138,84 @@ pkg_mak_writeFooter(FileStream *f, const UPKGOptions *o)
/* nothing */
}
void
pkg_mak_writeObjRules(UPKGOptions *o, FileStream *makefile, CharList **objects, const char* objSuffix)
{
const char *p, *baseName;
char *tmpPtr;
char tmp[1024];
char stanza[1024];
char cfile[1024];
CharList *oTail = NULL;
CharList *infiles;
CharList *parents = NULL, *commands = NULL;
int32_t genFileOffset = 0; /* offset from beginning of .c and .o file name, use to chop off package name for AS/400 */
infiles = o->filePaths;
#if defined (OS400)
if(infiles != NULL) {
baseName = findBasename(infiles->str);
p = uprv_strchr(baseName, '_');
if(p != NULL) {
genFileOffset = (p-baseName)+1; /* "package_" - name + underscore */
}
}
#endif
for(;infiles;infiles = infiles->next) {
baseName = findBasename(infiles->str);
p = uprv_strrchr(baseName, '.');
if( (p == NULL) || (*p == '\0' ) ) {
continue;
}
uprv_strncpy(tmp, baseName, p-baseName);
p++;
uprv_strcpy(tmp+(p-1-baseName), "_"); /* to append */
uprv_strcat(tmp, p);
uprv_strcat(tmp, objSuffix );
/* iSeries cannot have '-' in the .o objects. */
for( tmpPtr = tmp; *tmpPtr; tmpPtr++ ) {
if ( *tmpPtr == '-' ) {
*tmpPtr = '_';
}
}
*objects = pkg_appendToList(*objects, &oTail, uprv_strdup(tmp + genFileOffset)); /* Offset for AS/400 */
/* write source list */
strcpy(cfile,tmp);
strcpy(cfile+strlen(cfile)-strlen(objSuffix), ".c" ); /* replace .o with .c */
/* Make up parents.. */
parents = pkg_appendToList(parents, NULL, uprv_strdup(infiles->str));
/* make up commands.. */
sprintf(stanza, "@$(INVOKE) $(GENCCODE) -n $(ENTRYPOINT) -d $(TEMP_DIR) $<");
commands = pkg_appendToList(commands, NULL, uprv_strdup(stanza));
if(genFileOffset > 0) { /* for AS/400 */
sprintf(stanza, "@mv $(TEMP_PATH)%s $(TEMP_PATH)%s", cfile, cfile+genFileOffset);
commands = pkg_appendToList(commands, NULL, uprv_strdup(stanza));
}
sprintf(stanza, "@$(COMPILE.c) -o $@ $(TEMP_DIR)/%s", cfile+genFileOffset); /* for AS/400 */
commands = pkg_appendToList(commands, NULL, uprv_strdup(stanza));
sprintf(stanza, "@$(RMV) $(TEMP_DIR)/%s", cfile+genFileOffset);
commands = pkg_appendToList(commands, NULL, uprv_strdup(stanza));
sprintf(stanza, "$(TEMP_PATH)%s", tmp+genFileOffset); /* for AS/400 */
pkg_mak_writeStanza(makefile, o, stanza, parents, commands);
pkg_deleteList(parents);
pkg_deleteList(commands);
parents = NULL;
commands = NULL;
}
}

View File

@ -44,6 +44,15 @@ pkg_mak_writeFooter(FileStream *f, const UPKGOptions *o);
#ifdef WIN32
extern void pkg_mode_windows(UPKGOptions *o, FileStream *makefile, UErrorCode *status);
#else /*#ifdef WIN32*/
/**
* Write stanzas for generating .o (and .c) files for each data file in 'o->filePaths'.
* @param o Package options struct
* @param makefile Current makefile being written
* @param objects On output, list of object files
* @param objSuffix Suffix of object files including dot, typically OBJ_SUFFIX or ".o" or ".obj"
*/
extern void
pkg_mak_writeObjRules(UPKGOptions *o, FileStream *makefile, CharList **objects, const char* objSuffix);
#ifdef UDATA_SO_SUFFIX
extern void pkg_mode_dll(UPKGOptions* o, FileStream *stream, UErrorCode *status);
extern void pkg_mode_static(UPKGOptions* o, FileStream *stream, UErrorCode *status);

View File

@ -109,60 +109,6 @@ void pkg_sttc_writeReadme(struct UPKGOptions_ *o, const char *libName, UErrorCod
#include "makefile.h"
static void
writeObjRules(UPKGOptions *o, FileStream *makefile, CharList **objects)
{
const char *p, *baseName;
char tmp[1024];
char stanza[1024];
char cfile[1024];
CharList *oTail = NULL;
CharList *infiles;
CharList *parents = NULL, *commands = NULL;
infiles = o->filePaths;
for(;infiles;infiles = infiles->next) {
baseName = findBasename(infiles->str);
p = uprv_strrchr(baseName, '.');
if( (p == NULL) || (*p == '\0' ) ) {
continue;
}
uprv_strncpy(tmp, baseName, p-baseName);
p++;
uprv_strcpy(tmp+(p-1-baseName), "_"); /* to append */
uprv_strcat(tmp, p);
uprv_strcat(tmp, ".$(STATIC_O)");
*objects = pkg_appendToList(*objects, &oTail, uprv_strdup(tmp));
/* write source list */
strcpy(cfile,tmp);
strcpy(cfile+strlen(cfile)-strlen(".$(STATIC_O)"), ".c" );
/* Make up parents.. */
parents = pkg_appendToList(parents, NULL, uprv_strdup(infiles->str));
/* make up commands.. */
sprintf(stanza, "$(INVOKE) $(GENCCODE) -n $(ENTRYPOINT) -d $(TEMP_DIR) $<");
commands = pkg_appendToList(commands, NULL, uprv_strdup(stanza));
sprintf(stanza, "$(COMPILE.c) -o $@ $(TEMP_PATH)%s", cfile);
commands = pkg_appendToList(commands, NULL, uprv_strdup(stanza));
sprintf(stanza, "$(TEMP_PATH)%s", tmp);
pkg_mak_writeStanza(makefile, o, stanza, parents, commands);
pkg_deleteList(parents);
pkg_deleteList(commands);
parents = NULL;
commands = NULL;
}
}
void pkg_mode_static(UPKGOptions *o, FileStream *makefile, UErrorCode *status)
{
@ -220,7 +166,7 @@ void pkg_mode_static(UPKGOptions *o, FileStream *makefile, UErrorCode *status)
T_FileStream_writeLine(makefile, tmp);
/* Write compile rules */
writeObjRules(o, makefile, &objects);
pkg_mak_writeObjRules(o, makefile, &objects, ".$(STATIC_O)"); /* use special .o suffix */
sprintf(tmp, "# List file for gencmn:\n"
"CMNLIST=%s%s$(NAME)_static.lst\n\n",