2000-06-14 00:50:58 +00:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
2001-03-21 23:22:16 +00:00
|
|
|
* Copyright (C) 2000-2001, International Business Machines
|
2000-06-14 00:50:58 +00:00
|
|
|
* 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
|
2001-03-21 23:22:16 +00:00
|
|
|
* (DLL, common data, etc.)
|
2000-06-14 00:50:58 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#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"
|
|
|
|
|
2001-03-26 20:34:11 +00:00
|
|
|
static 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.. */
|
2002-03-20 01:37:12 +00:00
|
|
|
sprintf(stanza, "$(INVOKE) $(GENCCODE) -n $(ENTRYPOINT) -d $(TEMP_DIR) $<");
|
2002-03-16 02:26:17 +00:00
|
|
|
|
2000-07-10 17:53:01 +00:00
|
|
|
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
|
|
|
|
2001-03-21 23:22:16 +00:00
|
|
|
if(U_FAILURE(*status)) {
|
2000-06-14 00:50:58 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-03-16 21:16:02 +00:00
|
|
|
uprv_strcpy(tmp, LIB_PREFIX "$(NAME)" UDATA_SO_SUFFIX);
|
2000-06-14 00:50:58 +00:00
|
|
|
|
|
|
|
/* 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) {
|
2000-08-30 20:14:58 +00:00
|
|
|
fprintf(stdout, "# Output file: %s%s%s\n", o->targetDir, U_FILE_SEP_STRING, tmp);
|
2000-06-14 00:50:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(o->nooutput) {
|
|
|
|
*status = U_ZERO_ERROR;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* begin writing makefile ========================= */
|
|
|
|
|
2000-12-05 03:04:50 +00:00
|
|
|
|
2001-02-06 23:27:07 +00:00
|
|
|
/*390port start*/
|
2001-07-10 18:14:23 +00:00
|
|
|
#ifdef OS390BATCH
|
2001-03-15 00:31:08 +00:00
|
|
|
if (uprv_strcmp(o->shortName, U_ICUDATA_NAME) == 0)
|
2001-12-05 17:51:11 +00:00
|
|
|
sprintf(tmp, "# File to make:\nBATCH_TARGET=\"//'${LOADMOD}(IXMI" U_ICU_VERSION_SHORT "DA)'\"\n\n");
|
2001-03-15 00:31:08 +00:00
|
|
|
else if (uprv_strcmp(o->shortName, "testdata") == 0)
|
2001-12-05 17:51:11 +00:00
|
|
|
sprintf(tmp, "# File to make:\nBATCH_TARGET=\"//'${LOADMOD}(IXMI" U_ICU_VERSION_SHORT "TE)'\"\n\n");
|
2001-03-15 00:31:08 +00:00
|
|
|
else if (uprv_strcmp(o->shortName, U_ICUDATA_NAME"_390") == 0)
|
2001-12-05 17:51:11 +00:00
|
|
|
sprintf(tmp, "# File to make:\nBATCH_TARGET=\"//'${LOADMOD}(IXMI" U_ICU_VERSION_SHORT "D1)'\"\n\n");
|
2001-03-15 00:31:08 +00:00
|
|
|
T_FileStream_writeLine(makefile, tmp);
|
2001-03-08 18:40:27 +00:00
|
|
|
#endif
|
2001-02-06 23:27:07 +00:00
|
|
|
|
2001-12-21 20:09:18 +00:00
|
|
|
T_FileStream_writeLine(makefile, "# Version numbers:\nVERSIONED=");
|
|
|
|
if (o->version) {
|
|
|
|
sprintf(tmp, ".%s", o->version);
|
|
|
|
if (!uprv_strchr(o->version, '.')) {
|
2002-03-16 02:26:17 +00:00
|
|
|
uprv_strcat(tmp, ".0");
|
2001-12-21 20:09:18 +00:00
|
|
|
}
|
|
|
|
T_FileStream_writeLine(makefile, tmp);
|
2002-03-16 02:26:17 +00:00
|
|
|
T_FileStream_writeLine(makefile, "\nDLL_LDFLAGS=$(LD_SONAME) $(RPATH_LDFLAGS) $(BIR_LDFLAGS)\nDLL_DEPS=$(BIR_DEPS)\n");
|
2001-12-21 20:09:18 +00:00
|
|
|
} else {
|
|
|
|
T_FileStream_writeLine(makefile, "\nDLL_LDFLAGS=$(BIR_LDFLAGS)\nDLL_DEPS=$(BIR_DEPS)\n");
|
|
|
|
}
|
|
|
|
T_FileStream_writeLine(makefile, "\n");
|
|
|
|
|
2000-06-14 00:50:58 +00:00
|
|
|
sprintf(tmp, "# File to make:\nTARGET=%s\n\n", o->outFiles->str);
|
|
|
|
T_FileStream_writeLine(makefile, tmp);
|
2001-12-21 20:09:18 +00:00
|
|
|
if (o->version) {
|
|
|
|
char *p;
|
|
|
|
const char *v;
|
|
|
|
|
|
|
|
T_FileStream_writeLine(makefile, "SO_TARGET=$(TARGET)\n");
|
|
|
|
sprintf(tmp, "SO_TARGET_VERSION=%s\n", o->version);
|
|
|
|
T_FileStream_writeLine(makefile, tmp);
|
|
|
|
uprv_strcpy(tmp, "SO_TARGET_VERSION_MAJOR=");
|
|
|
|
for (p = tmp + uprv_strlen(tmp), v = o->version; *v && *v != '.'; ++v) {
|
2002-03-16 02:26:17 +00:00
|
|
|
*p++ = *v;
|
2001-12-21 20:09:18 +00:00
|
|
|
}
|
|
|
|
*p++ = '\n';
|
|
|
|
*p++ = '\n';
|
|
|
|
*p++ = 0;
|
|
|
|
T_FileStream_writeLine(makefile, tmp);
|
|
|
|
} else {
|
|
|
|
T_FileStream_writeLine(makefile, "FINAL_SO_TARGET=$(TARGET)\n");
|
|
|
|
}
|
2000-06-14 00:50:58 +00:00
|
|
|
|
2001-12-21 20:09:18 +00:00
|
|
|
uprv_strcpy(tmp, "all: $(TARGETDIR)/$(FINAL_SO_TARGET) $(BATCH_TARGET)");
|
|
|
|
if (o->version) {
|
|
|
|
uprv_strcat(tmp, " $(TARGETDIR)/$(MIDDLE_SO_TARGET) $(TARGETDIR)/$(SO_TARGET)");
|
|
|
|
}
|
|
|
|
uprv_strcat(tmp, "\n\n");
|
2000-06-14 00:50:58 +00:00
|
|
|
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"
|
2002-03-16 21:19:35 +00:00
|
|
|
"CMNLIST=%s%s$(NAME)_dll.lst\n\n",
|
2000-06-14 00:50:58 +00:00
|
|
|
o->tmpDir,
|
2002-03-16 21:16:02 +00:00
|
|
|
U_FILE_SEP_STRING);
|
2000-06-14 00:50:58 +00:00
|
|
|
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"
|
2002-01-04 23:48:46 +00:00
|
|
|
"\t@echo \"generating $@ (list of data files)\"\n"
|
2000-06-14 00:50:58 +00:00
|
|
|
"\t@-$(RMV) $@\n"
|
|
|
|
"\t@for file in $(DATAFILEPATHS); do \\\n"
|
|
|
|
"\t echo $$file >> $@; \\\n"
|
|
|
|
"\tdone;\n\n");
|
|
|
|
}
|
|
|
|
|
2002-03-20 01:37:12 +00:00
|
|
|
sprintf(tmp,"$(TEMP_DIR)/$(NAME)_dat.o : $(TEMP_DIR)/$(NAME)_dat.c\n"
|
2002-03-16 21:16:02 +00:00
|
|
|
"\t$(COMPILE.c) -o $@ $<\n\n");
|
2000-08-30 23:58:24 +00:00
|
|
|
T_FileStream_writeLine(makefile, tmp);
|
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");
|
2000-08-30 23:58:24 +00:00
|
|
|
|
2002-03-20 01:37:12 +00:00
|
|
|
sprintf(tmp, "$(TEMP_DIR)/$(NAME)_dat.c: $(CMNLIST)\n"
|
|
|
|
"\t$(INVOKE) $(GENCMN) -e $(ENTRYPOINT) -n $(NAME) -S -d $(TEMP_DIR) 0 $(CMNLIST)\n\n");
|
2002-03-16 02:26:17 +00:00
|
|
|
|
2000-08-30 23:58:24 +00:00
|
|
|
T_FileStream_writeLine(makefile, tmp);
|
2002-03-20 01:37:12 +00:00
|
|
|
sprintf(tmp, "TOCOBJ= $(NAME)_dat%s \n\n", OBJ_SUFFIX);
|
2000-08-30 23:58:24 +00:00
|
|
|
T_FileStream_writeLine(makefile, tmp);
|
2000-12-06 10:07:41 +00:00
|
|
|
sprintf(tmp, "TOCSYM= %s_dat \n\n", o->entryName); /* entrypoint not always shortname! */
|
2000-11-04 02:16:12 +00:00
|
|
|
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
|
|
|
|
2000-10-06 17:39:09 +00:00
|
|
|
pkg_writeCharListWrap(makefile, objects, " ", " \\\n",0);
|
2000-06-14 00:50:58 +00:00
|
|
|
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-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");
|
2001-03-21 23:22:16 +00:00
|
|
|
|
|
|
|
#ifdef HPUX
|
2001-12-21 20:09:18 +00:00
|
|
|
T_FileStream_writeLine(makefile, "$(TARGETDIR)/$(FINAL_SO_TARGET): $(OBJECTS) $(HPUX_JUNK_OBJ) $(LISTFILES) $(DLL_DEPS)\n"
|
|
|
|
"\t$(SHLIB.cc) -o $@ $(OBJECTS) $(HPUX_JUNK_OBJ) $(DLL_LDFLAGS)\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-12-05 20:33:36 +00:00
|
|
|
"\techo \"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-12-05 20:33:36 +00:00
|
|
|
"\t$(COMPILE.cc) -o $@ $<\n"
|
2000-06-14 00:50:58 +00:00
|
|
|
"\n");
|
2000-08-16 17:16:44 +00:00
|
|
|
#else
|
2001-02-06 23:27:07 +00:00
|
|
|
|
|
|
|
/*390port*/
|
|
|
|
#ifdef OS390BATCH
|
2001-12-21 20:09:18 +00:00
|
|
|
T_FileStream_writeLine(makefile, "$(BATCH_TARGET): $(OBJECTS) $(LISTFILES) $(DLL_DEPS)\n"
|
|
|
|
"\t$(SHLIB.c) -o $@ $(OBJECTS) $(DLL_LDFLAGS)\n"
|
2001-02-06 23:27:07 +00:00
|
|
|
"# \t-ls -l $@\n\n");
|
|
|
|
#endif
|
|
|
|
|
2001-12-21 20:09:18 +00:00
|
|
|
T_FileStream_writeLine(makefile, "$(TARGETDIR)/$(FINAL_SO_TARGET): $(OBJECTS) $(LISTFILES) $(DLL_DEPS)\n"
|
|
|
|
"\t$(SHLIB.c) -o $@ $(OBJECTS) $(DLL_LDFLAGS)\n"
|
2000-08-16 17:16:44 +00:00
|
|
|
"\t-ls -l $@\n\n");
|
|
|
|
#endif
|
2000-06-14 00:50:58 +00:00
|
|
|
|
2002-01-05 02:28:32 +00:00
|
|
|
T_FileStream_writeLine(makefile, "CLEANFILES= $(CMNLIST) $(OBJECTS) $(HPUX_JUNK_OBJ) $(TARGETDIR)/$(FINAL_SO_TARGET) $(TARGETDIR)/$(MIDDLE_SO_TARGET) $(TARGETDIR)/$(TARGET)\n\nclean:\n\t-$(RMV) $(CLEANFILES) $(MAKEFILE)");
|
2000-06-14 00:50:58 +00:00
|
|
|
T_FileStream_writeLine(makefile, "\n\n");
|
2001-03-21 23:22:16 +00:00
|
|
|
|
2001-12-21 20:09:18 +00:00
|
|
|
T_FileStream_writeLine(makefile, "install: $(TARGETDIR)/$(FINAL_SO_TARGET)\n"
|
|
|
|
"\t$(INSTALL-L) $(TARGETDIR)/$(FINAL_SO_TARGET) $(INSTALLTO)/$(FINAL_SO_TARGET)\n");
|
|
|
|
if (o->version) {
|
|
|
|
T_FileStream_writeLine(makefile, "\tcd $(INSTALLTO) && $(RM) $(MIDDLE_SO_TARGET) && ln -s $(FINAL_SO_TARGET) $(MIDDLE_SO_TARGET)\n\tcd $(INSTALLTO) && $(RM) $(SO_TARGET) && ln -s $(FINAL_SO_TARGET) $(SO_TARGET)\n");
|
|
|
|
}
|
|
|
|
T_FileStream_writeLine(makefile, "\n");
|
2000-06-14 00:50:58 +00:00
|
|
|
|
2000-11-04 02:16:12 +00:00
|
|
|
#ifdef U_SOLARIS
|
|
|
|
T_FileStream_writeLine(makefile, "$(NAME).map:\n\techo \"{global: $(TOCSYM); local: *; };\" > $@\n\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef AIX
|
|
|
|
T_FileStream_writeLine(makefile, "$(NAME).map:\n\techo \"$(TOCSYM)\" > $@\n\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2000-06-14 00:50:58 +00:00
|
|
|
*status = U_ZERO_ERROR;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-12-05 20:33:36 +00:00
|
|
|
|
|
|
|
|