2000-06-14 00:50:58 +00:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Copyright (C) 2000, International Business Machines
|
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
*
|
|
|
|
*******************************************************************************
|
|
|
|
* file name: pkgdata.c
|
|
|
|
* encoding: ANSI X3.4 (1968)
|
|
|
|
* tab size: 8 (not used)
|
|
|
|
* indentation:4
|
|
|
|
*
|
|
|
|
* created on: 2000may15
|
|
|
|
* created by: Steven \u24C7 Loomis
|
|
|
|
*
|
|
|
|
* This program packages the ICU data into different forms
|
|
|
|
* (DLL, common data, etc.)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#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"
|
|
|
|
|
2000-07-10 17:53:01 +00:00
|
|
|
void writeObjRules(UPKGOptions *o, FileStream *makefile, CharList **objects)
|
2000-06-14 00:50:58 +00:00
|
|
|
{
|
2000-07-25 17:00:23 +00:00
|
|
|
const char *p, *baseName;
|
2000-06-14 00:50:58 +00:00
|
|
|
char tmp[1024];
|
2000-07-10 17:53:01 +00:00
|
|
|
char stanza[1024];
|
|
|
|
char cfile[1024];
|
|
|
|
CharList *oTail = NULL;
|
|
|
|
CharList *infiles;
|
|
|
|
CharList *parents = NULL, *commands = NULL;
|
|
|
|
|
|
|
|
infiles = o->filePaths;
|
|
|
|
|
2000-06-14 00:50:58 +00:00
|
|
|
for(;infiles;infiles = infiles->next) {
|
2000-07-10 17:53:01 +00:00
|
|
|
baseName = findBasename(infiles->str);
|
|
|
|
p = uprv_strrchr(baseName, '.');
|
2000-06-14 00:50:58 +00:00
|
|
|
if( (p == NULL) || (*p == '\0' ) ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2000-07-10 17:53:01 +00:00
|
|
|
uprv_strncpy(tmp, baseName, p-baseName);
|
2000-06-14 00:50:58 +00:00
|
|
|
p++;
|
|
|
|
|
2000-07-10 17:53:01 +00:00
|
|
|
uprv_strcpy(tmp+(p-1-baseName), "_"); /* to append */
|
2000-06-14 00:50:58 +00:00
|
|
|
uprv_strcat(tmp, p);
|
|
|
|
uprv_strcat(tmp, OBJ_SUFFIX);
|
|
|
|
|
|
|
|
*objects = pkg_appendToList(*objects, &oTail, uprv_strdup(tmp));
|
|
|
|
|
2000-07-10 17:53:01 +00:00
|
|
|
/* 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));
|
2000-06-14 00:50:58 +00:00
|
|
|
|
2000-07-10 17:53:01 +00:00
|
|
|
/* make up commands.. */
|
|
|
|
sprintf(stanza, "$(TOOL) $(GENCCODE) -d $(TEMP_DIR) $<");
|
|
|
|
commands = pkg_appendToList(commands, NULL, uprv_strdup(stanza));
|
|
|
|
|
2000-08-15 21:39:36 +00:00
|
|
|
sprintf(stanza, "$(COMPILE.c) -o $@ $(TEMP_DIR)/%s", cfile);
|
2000-07-10 17:53:01 +00:00
|
|
|
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;
|
2000-06-14 00:50:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void pkg_mode_dll(UPKGOptions *o, FileStream *makefile, UErrorCode *status)
|
|
|
|
{
|
|
|
|
char tmp[1024];
|
|
|
|
CharList *tail = NULL;
|
2000-07-10 17:53:01 +00:00
|
|
|
CharList *objects = NULL;
|
2000-06-14 00:50:58 +00:00
|
|
|
CharList *iter;
|
|
|
|
|
|
|
|
if(U_FAILURE(*status)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
uprv_strcpy(tmp, LIB_PREFIX);
|
|
|
|
uprv_strcat(tmp, o->shortName);
|
|
|
|
uprv_strcat(tmp, UDATA_SO_SUFFIX);
|
|
|
|
|
|
|
|
/* We should be the only item. So we don't care about the order. */
|
|
|
|
o->outFiles = pkg_appendToList(o->outFiles, &tail, uprv_strdup(tmp));
|
|
|
|
|
|
|
|
if(o->nooutput || o->verbose) {
|
|
|
|
fprintf(stderr, "# Output file: %s%s%s\n", o->targetDir, U_FILE_SEP_STRING, tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(o->nooutput) {
|
|
|
|
*status = U_ZERO_ERROR;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* begin writing makefile ========================= */
|
|
|
|
|
|
|
|
|
|
|
|
sprintf(tmp, "# File to make:\nTARGET=%s\n\n", o->outFiles->str);
|
|
|
|
T_FileStream_writeLine(makefile, tmp);
|
|
|
|
|
|
|
|
sprintf(tmp, "all: $(TARGETDIR)/$(TARGET)\n\n");
|
|
|
|
T_FileStream_writeLine(makefile, tmp);
|
|
|
|
|
|
|
|
/* Write compile rules */
|
2000-07-10 17:53:01 +00:00
|
|
|
writeObjRules(o, makefile, &objects);
|
2000-06-14 00:50:58 +00:00
|
|
|
|
|
|
|
sprintf(tmp, "# List file for gencmn:\n"
|
|
|
|
"CMNLIST=%s%s%s_dll.lst\n\n",
|
|
|
|
o->tmpDir,
|
|
|
|
U_FILE_SEP_STRING,
|
|
|
|
o->shortName);
|
|
|
|
T_FileStream_writeLine(makefile, tmp);
|
|
|
|
|
|
|
|
if(o->hadStdin == FALSE) { /* shortcut */
|
|
|
|
T_FileStream_writeLine(makefile, "$(CMNLIST): $(LISTFILES)\n"
|
|
|
|
"\tcat $(LISTFILES) > $(CMNLIST)\n\n");
|
|
|
|
} else {
|
|
|
|
T_FileStream_writeLine(makefile, "$(CMNLIST): \n"
|
|
|
|
"\t@echo Generating $@ list of data files\n"
|
|
|
|
"\t@-$(RMV) $@\n"
|
|
|
|
"\t@for file in $(DATAFILEPATHS); do \\\n"
|
|
|
|
"\t echo $$file >> $@; \\\n"
|
|
|
|
"\tdone;\n\n");
|
|
|
|
}
|
|
|
|
|
2000-07-20 20:24:53 +00:00
|
|
|
T_FileStream_writeLine(makefile, "$(TEMP_DIR)/icudata_dat.o : $(TEMP_DIR)/icudata_dat.c\n"
|
2000-08-15 21:39:36 +00:00
|
|
|
"\t$(COMPILE.c) -o $@ $<\n\n");
|
2000-07-20 20:24:53 +00:00
|
|
|
|
2000-07-10 17:53:01 +00:00
|
|
|
T_FileStream_writeLine(makefile, "# 'TOCOBJ' contains C Table of Contents objects [if any]\n");
|
|
|
|
if(!strcmp(o->shortName, "icudata")) {
|
2000-07-20 20:24:53 +00:00
|
|
|
T_FileStream_writeLine(makefile, "$(TEMP_DIR)/icudata_dat.c: $(CMNLIST)\n"
|
2000-07-10 17:53:01 +00:00
|
|
|
"\t$(TOOL) $(GENCMN) -S -d $(TEMP_DIR) 0 $(CMNLIST)\n\n");
|
|
|
|
sprintf(tmp, "TOCOBJ= icudata_dat%s \n\n", OBJ_SUFFIX);
|
|
|
|
T_FileStream_writeLine(makefile, tmp);
|
|
|
|
}
|
2000-06-14 00:50:58 +00:00
|
|
|
|
2000-07-10 17:53:01 +00:00
|
|
|
T_FileStream_writeLine(makefile, "BASE_OBJECTS= $(TOCOBJ) ");
|
2000-06-14 00:50:58 +00:00
|
|
|
|
|
|
|
pkg_writeCharListWrap(makefile, objects, " ", " \\\n");
|
|
|
|
T_FileStream_writeLine(makefile, "\n\n");
|
2000-07-10 17:53:01 +00:00
|
|
|
T_FileStream_writeLine(makefile, "OBJECTS=$(BASE_OBJECTS:%=$(TEMP_DIR)/%)\n\n");
|
2000-06-14 00:50:58 +00:00
|
|
|
|
2000-07-10 17:53:01 +00:00
|
|
|
#if 0
|
2000-06-14 00:50:58 +00:00
|
|
|
for(iter=suffixes; iter; iter = iter->next) {
|
2000-07-10 17:53:01 +00:00
|
|
|
sprintf(tmp, "$(TEMP_DIR)/%%_%s.c: %%.%s\n\t$(TOOL) $(GENCCODE) -d $(TEMP_DIR) $<\n\n",
|
2000-06-14 00:50:58 +00:00
|
|
|
iter->str,iter->str);
|
|
|
|
T_FileStream_writeLine(makefile, tmp);
|
|
|
|
}
|
2000-07-10 17:53:01 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
for(iter=objects; iter; iter = iter->next) {
|
|
|
|
char sourcefile[200];
|
|
|
|
strcpy(sourcefile,iter->str);
|
|
|
|
strcpy(sourcefile+strlen(sourcefile)-strlen(OBJ_SUFFIX), ".c" );
|
2000-08-15 21:39:36 +00:00
|
|
|
sprintf(tmp, "$(TEMP_DIR)/%s: $(TEMP_DIR)/%s\n\t$(COMPILE.c) -o $@ $<\n\n",
|
2000-07-10 17:53:01 +00:00
|
|
|
iter->str,sourcefile);
|
|
|
|
T_FileStream_writeLine(makefile, tmp);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2000-08-15 21:39:36 +00:00
|
|
|
T_FileStream_writeLine(makefile,"$(TEMP_DIR)/%.o: $(TEMP_DIR)/%.c\n\t $(COMPILE.c) -o $@ $<\n\n");
|
2000-07-10 17:53:01 +00:00
|
|
|
|
|
|
|
T_FileStream_writeLine(makefile,"build-objs: $(SOURCES) $(OBJECTS)\n\n$(OBJECTS): $(SOURCES)\n\n");
|
2000-06-14 00:50:58 +00:00
|
|
|
|
|
|
|
T_FileStream_writeLine(makefile, "$(TARGETDIR)/$(TARGET): $(OBJECTS) $(HPUX_JUNK_OBJ) $(LISTFILES)\n"
|
2000-08-16 00:24:30 +00:00
|
|
|
"\t$(SHLIB.cc) -o $@ $(OBJECTS) $(HPUX_JUNK_OBJ)\n"
|
2000-06-14 00:50:58 +00:00
|
|
|
"\t-ls -l $@\n\n");
|
|
|
|
|
2000-07-10 17:53:01 +00:00
|
|
|
T_FileStream_writeLine(makefile, "$(TEMP_DIR)/hpux_junk_obj.cpp:\n"
|
2000-08-15 02:41:58 +00:00
|
|
|
" echo \"void to_emit_cxx_stuff_in_the_linker(){}\" >> $(TEMP_DIR)/hpux_junk_obj.cpp\n"
|
2000-06-14 00:50:58 +00:00
|
|
|
"\n"
|
2000-07-10 17:53:01 +00:00
|
|
|
"$(TEMP_DIR)/hpux_junk_obj.o: $(TEMP_DIR)/hpux_junk_obj.cpp\n"
|
2000-08-16 00:24:30 +00:00
|
|
|
" $(COMPILE.cc) -o $@ $<\n"
|
2000-06-14 00:50:58 +00:00
|
|
|
"\n");
|
|
|
|
|
|
|
|
T_FileStream_writeLine(makefile, "CLEANFILES= $(OBJECTS) $(HPUX_JUNK_OBJ) $(TARGETDIR)/$(TARGET)\n\nclean:\n\t-$(RMV) $(CLEANFILES) $(MAKEFILE)");
|
|
|
|
T_FileStream_writeLine(makefile, "\n\n");
|
|
|
|
|
|
|
|
T_FileStream_writeLine(makefile, "install: $(TARGETDIR)/$(TARGET)\n"
|
2000-07-10 17:53:01 +00:00
|
|
|
"\t$(INSTALL-S) $(TARGETDIR)/$(TARGET) $(INSTALLTO)/$(TARGET)\n\n");
|
2000-06-14 00:50:58 +00:00
|
|
|
|
|
|
|
*status = U_ZERO_ERROR;
|
|
|
|
|
|
|
|
}
|
|
|
|
|