2000-07-17 05:37:48 +00:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
2004-05-20 00:15:42 +00:00
|
|
|
* Copyright (C) 2000-2004, International Business Machines
|
2000-07-17 05:37:48 +00:00
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
*
|
|
|
|
*******************************************************************************
|
|
|
|
* file name: winmode.c
|
|
|
|
* encoding: ANSI X3.4 (1968)
|
|
|
|
* tab size: 8 (not used)
|
|
|
|
* indentation:4
|
|
|
|
*
|
|
|
|
* created on: 2000july14
|
|
|
|
* created by: Vladimir Weinstein
|
|
|
|
*
|
|
|
|
* This program packages the ICU data into different forms
|
2002-04-02 02:55:31 +00:00
|
|
|
* (DLL, common data, etc.)
|
2000-07-17 05:37:48 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "unicode/utypes.h"
|
2003-09-19 16:39:58 +00:00
|
|
|
|
2004-11-02 00:27:43 +00:00
|
|
|
#ifdef U_MAKE_IS_NMAKE
|
2003-09-19 16:39:58 +00:00
|
|
|
|
2000-07-19 06:45:14 +00:00
|
|
|
#include "unicode/putil.h"
|
2000-07-17 05:37:48 +00:00
|
|
|
#include "cmemory.h"
|
|
|
|
#include "cstring.h"
|
|
|
|
#include "filestrm.h"
|
|
|
|
#include "toolutil.h"
|
|
|
|
#include "unewdata.h"
|
|
|
|
#include "uoptions.h"
|
|
|
|
#include "pkgtypes.h"
|
|
|
|
#include "makefile.h"
|
2003-09-19 16:39:58 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2000-07-17 05:37:48 +00:00
|
|
|
|
2003-09-20 19:27:38 +00:00
|
|
|
/*#define WINBUILDMODE (*(o->options)=='R'?"Release":"Debug")*/
|
|
|
|
#define CONTAINS_REAL_PATH(o) (*(o->options)==PKGDATA_DERIVED_PATH)
|
2000-07-19 06:45:14 +00:00
|
|
|
|
2000-10-06 17:39:09 +00:00
|
|
|
void writeCmnRules(UPKGOptions *o, FileStream *makefile)
|
2000-07-17 05:37:48 +00:00
|
|
|
{
|
2002-04-02 02:55:31 +00:00
|
|
|
char tmp[1024];
|
|
|
|
CharList *infiles;
|
2000-07-17 05:37:48 +00:00
|
|
|
|
2004-04-22 23:27:20 +00:00
|
|
|
if(!o->embed) {
|
2004-04-14 20:08:16 +00:00
|
|
|
infiles = o->files;
|
|
|
|
} else {
|
|
|
|
infiles = o->filePaths;
|
|
|
|
}
|
2003-09-15 22:42:00 +00:00
|
|
|
sprintf(tmp, "\"$(TARGETDIR)\\$(CMNTARGET)\" : $(DATAFILEPATHS)\n"
|
2004-04-22 23:27:20 +00:00
|
|
|
"\t%s\"$(GENCMN)\" %s%s%s-d \"$(TARGETDIR)\" %s %s -n \"$(NAME)\" 0 <<\n",
|
|
|
|
(o->verbose ? "" : "@"),
|
2003-09-15 22:42:00 +00:00
|
|
|
(o->comment ? "-C \"" : ""),
|
|
|
|
(o->comment ? o->comment : ""),
|
2004-04-14 20:08:16 +00:00
|
|
|
(o->comment ? "\" " : ""),
|
2004-04-22 23:27:20 +00:00
|
|
|
(o->embed ? "-E" : ""),
|
|
|
|
o->embed ? "" : "-s \"$(SRCDIR)\"");
|
2000-07-19 06:45:14 +00:00
|
|
|
T_FileStream_writeLine(makefile, tmp);
|
2000-07-17 05:37:48 +00:00
|
|
|
|
2002-04-02 02:55:31 +00:00
|
|
|
pkg_writeCharList(makefile, infiles, "\n", -1);
|
2000-08-08 23:20:37 +00:00
|
|
|
/*
|
2002-04-02 02:55:31 +00:00
|
|
|
for(;infiles;infiles = infiles->next) {
|
|
|
|
if(infiles->str[0] != '"' && infiles->str[uprv_strlen(infiles->str)-1] != '"') {
|
|
|
|
sprintf(tmp, "\"%s\"\n", infiles->str);
|
|
|
|
} else {
|
|
|
|
sprintf(tmp, "%s\n", infiles->str);
|
|
|
|
}
|
|
|
|
T_FileStream_writeLine(makefile, tmp);
|
|
|
|
}
|
2000-08-08 23:20:37 +00:00
|
|
|
*/
|
2002-04-02 02:55:31 +00:00
|
|
|
sprintf(tmp, "\n<<\n");
|
|
|
|
T_FileStream_writeLine(makefile, tmp);
|
2000-07-17 05:37:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void pkg_mode_windows(UPKGOptions *o, FileStream *makefile, UErrorCode *status) {
|
2002-04-02 02:55:31 +00:00
|
|
|
char tmp[1024];
|
|
|
|
char tmp2[1024];
|
|
|
|
const char *separator = o->icuroot[uprv_strlen(o->icuroot)-1]=='\\'?"":"\\";
|
|
|
|
UBool isDll = (UBool)(uprv_strcmp(o->mode, "dll") == 0);
|
|
|
|
UBool isStatic = (UBool)(uprv_strcmp(o->mode, "static") == 0);
|
2000-07-17 05:37:48 +00:00
|
|
|
|
2002-04-02 02:55:31 +00:00
|
|
|
if(U_FAILURE(*status)) {
|
|
|
|
return;
|
|
|
|
}
|
2000-07-19 06:45:14 +00:00
|
|
|
|
2002-04-02 02:55:31 +00:00
|
|
|
sprintf(tmp2, "ICUROOT=%s\n\n", o->icuroot);
|
|
|
|
T_FileStream_writeLine(makefile, tmp2);
|
2000-07-17 05:37:48 +00:00
|
|
|
|
2003-09-20 19:27:38 +00:00
|
|
|
if (CONTAINS_REAL_PATH(o)) {
|
|
|
|
sprintf(tmp2,
|
|
|
|
"GENCMN = $(ICUROOT)%sgencmn.exe\n", separator);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
sprintf(tmp2,
|
|
|
|
"GENCMN = $(ICUROOT)%sbin\\gencmn.exe\n", separator);
|
|
|
|
}
|
2002-04-02 02:55:31 +00:00
|
|
|
T_FileStream_writeLine(makefile, tmp2);
|
2000-07-17 05:37:48 +00:00
|
|
|
|
2002-04-02 02:55:31 +00:00
|
|
|
if(isDll) {
|
|
|
|
uprv_strcpy(tmp, LIB_PREFIX);
|
2004-05-06 00:39:17 +00:00
|
|
|
uprv_strcat(tmp, o->libName);
|
2003-09-26 04:46:24 +00:00
|
|
|
if (o->version) {
|
|
|
|
uprv_strcat(tmp, "$(TARGET_VERSION)");
|
|
|
|
}
|
2002-04-02 02:55:31 +00:00
|
|
|
uprv_strcat(tmp, UDATA_SO_SUFFIX);
|
|
|
|
|
|
|
|
if(o->nooutput || o->verbose) {
|
|
|
|
fprintf(stdout, "# Output %s file: %s%s%s\n", UDATA_SO_SUFFIX, o->targetDir, U_FILE_SEP_STRING, tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(o->nooutput) {
|
|
|
|
*status = U_ZERO_ERROR;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(tmp2, "# DLL file to make:\nDLLTARGET=%s\n\n", tmp);
|
|
|
|
T_FileStream_writeLine(makefile, tmp2);
|
|
|
|
|
|
|
|
sprintf(tmp2,
|
|
|
|
"LINK32 = link.exe\n"
|
2004-12-07 22:14:25 +00:00
|
|
|
"LINK32_FLAGS = /nologo /out:\"$(TARGETDIR)\\$(DLLTARGET)\" /DLL /NOENTRY $(LDFLAGS) $(PKGDATA_LDFLAGS) /implib:\"$(TARGETDIR)\\$(LIBNAME).lib\" %s%s%s\n",
|
2003-09-15 22:42:00 +00:00
|
|
|
(o->comment ? "/comment:\"" : ""),
|
|
|
|
(o->comment ? o->comment : ""),
|
|
|
|
(o->comment ? "\"" : ""),
|
2002-04-02 02:55:31 +00:00
|
|
|
o->comment
|
|
|
|
);
|
|
|
|
T_FileStream_writeLine(makefile, tmp2);
|
|
|
|
|
2003-09-20 19:27:38 +00:00
|
|
|
if (CONTAINS_REAL_PATH(o)) {
|
|
|
|
sprintf(tmp2,
|
|
|
|
"GENCCODE = $(ICUROOT)%sgenccode.exe\n", separator);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
sprintf(tmp2,
|
|
|
|
"GENCCODE = $(ICUROOT)%sbin\\genccode.exe\n", separator);
|
|
|
|
}
|
2002-04-02 02:55:31 +00:00
|
|
|
T_FileStream_writeLine(makefile, tmp2);
|
|
|
|
|
2004-05-17 17:49:49 +00:00
|
|
|
/* If you modify this, remember to modify makedata.mak too. */
|
2002-04-02 02:55:31 +00:00
|
|
|
T_FileStream_writeLine(makefile, "\n"
|
|
|
|
"# Windows specific DLL version information.\n"
|
2004-05-17 19:09:26 +00:00
|
|
|
"!IF EXISTS(\"$(TEMP_DIR)\\icudata.res\")\n"
|
|
|
|
"DATA_VER_INFO=\"$(TEMP_DIR)\\icudata.res\"\n"
|
2002-04-02 02:55:31 +00:00
|
|
|
"!ELSE\n"
|
|
|
|
"DATA_VER_INFO=\n"
|
|
|
|
"!ENDIF\n\n");
|
|
|
|
|
|
|
|
|
|
|
|
uprv_strcpy(tmp, UDATA_CMN_PREFIX "$(NAME)" UDATA_CMN_INTERMEDIATE_SUFFIX OBJ_SUFFIX);
|
|
|
|
|
|
|
|
sprintf(tmp2, "# intermediate obj file:\nCMNOBJTARGET=%s\n\n", tmp);
|
|
|
|
T_FileStream_writeLine(makefile, tmp2);
|
|
|
|
}
|
|
|
|
else if (isStatic)
|
|
|
|
{
|
|
|
|
uprv_strcpy(tmp, LIB_PREFIX);
|
2004-05-12 19:58:49 +00:00
|
|
|
uprv_strcat(tmp, o->libName);
|
2002-04-02 02:55:31 +00:00
|
|
|
uprv_strcat(tmp, UDATA_LIB_SUFFIX);
|
|
|
|
|
2004-05-12 19:58:49 +00:00
|
|
|
if (!o->quiet) {
|
|
|
|
pkg_sttc_writeReadme(o, tmp, status);
|
|
|
|
}
|
2002-04-02 02:55:31 +00:00
|
|
|
if(U_FAILURE(*status))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(o->nooutput || o->verbose) {
|
|
|
|
fprintf(stdout, "# Output %s file: %s%s%s\n", UDATA_SO_SUFFIX, o->targetDir, U_FILE_SEP_STRING, tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(o->nooutput) {
|
|
|
|
*status = U_ZERO_ERROR;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(tmp2, "# LIB file to make:\nDLLTARGET=%s\n\n", tmp);
|
|
|
|
T_FileStream_writeLine(makefile, tmp2);
|
|
|
|
|
|
|
|
sprintf(tmp2,
|
|
|
|
"LINK32 = LIB.exe\n"
|
|
|
|
"LINK32_FLAGS = /nologo /out:\"$(TARGETDIR)\\$(DLLTARGET)\" /EXPORT:\"%s\"\n",
|
2004-05-12 19:58:49 +00:00
|
|
|
o->libName
|
2002-04-02 02:55:31 +00:00
|
|
|
);
|
|
|
|
T_FileStream_writeLine(makefile, tmp2);
|
|
|
|
|
2003-09-20 19:27:38 +00:00
|
|
|
|
|
|
|
if (CONTAINS_REAL_PATH(o)) {
|
|
|
|
sprintf(tmp2,
|
|
|
|
"GENCCODE = $(ICUROOT)%sgenccode.exe\n", separator);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
sprintf(tmp2,
|
|
|
|
"GENCCODE = $(ICUROOT)%sbin\\genccode.exe\n", separator);
|
|
|
|
}
|
2002-04-02 02:55:31 +00:00
|
|
|
T_FileStream_writeLine(makefile, tmp2);
|
|
|
|
|
|
|
|
uprv_strcpy(tmp, UDATA_CMN_PREFIX "$(NAME)" UDATA_CMN_INTERMEDIATE_SUFFIX OBJ_SUFFIX);
|
|
|
|
|
2004-05-12 19:58:49 +00:00
|
|
|
sprintf(tmp2, "# intermediate obj file\nCMNOBJTARGET=%s\n\n", tmp);
|
2002-04-02 02:55:31 +00:00
|
|
|
T_FileStream_writeLine(makefile, tmp2);
|
|
|
|
}
|
|
|
|
uprv_strcpy(tmp, UDATA_CMN_PREFIX);
|
|
|
|
uprv_strcat(tmp, o->cShortName);
|
2004-05-12 19:58:49 +00:00
|
|
|
if (o->version && !uprv_strstr(o->shortName,o->version)) {
|
2003-09-26 04:46:24 +00:00
|
|
|
uprv_strcat(tmp, "$(TARGET_VERSION)");
|
|
|
|
}
|
2002-04-02 02:55:31 +00:00
|
|
|
uprv_strcat(tmp, UDATA_CMN_SUFFIX);
|
|
|
|
|
|
|
|
if(o->nooutput || o->verbose) {
|
|
|
|
fprintf(stdout, "# Output file: %s%s%s\n", o->targetDir, U_FILE_SEP_STRING, tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(o->nooutput) {
|
2000-07-17 22:50:10 +00:00
|
|
|
*status = U_ZERO_ERROR;
|
|
|
|
return;
|
2002-04-02 02:55:31 +00:00
|
|
|
}
|
2000-07-17 05:37:48 +00:00
|
|
|
|
2000-07-17 22:50:10 +00:00
|
|
|
sprintf(tmp2, "# common file to make:\nCMNTARGET=%s\n\n", tmp);
|
|
|
|
T_FileStream_writeLine(makefile, tmp2);
|
|
|
|
|
2000-07-19 20:58:13 +00:00
|
|
|
|
2002-04-02 02:55:31 +00:00
|
|
|
if(isDll || isStatic) {
|
|
|
|
sprintf(tmp, "all: \"$(TARGETDIR)\\$(DLLTARGET)\"\n\n");
|
|
|
|
T_FileStream_writeLine(makefile, tmp);
|
|
|
|
|
2004-05-12 19:58:49 +00:00
|
|
|
sprintf(tmp, "\"$(TARGETDIR)\\$(DLLTARGET)\": \"$(TEMP_DIR)\\$(CMNOBJTARGET)\"\n"
|
|
|
|
"\t$(LINK32) $(LINK32_FLAGS) \"$(TEMP_DIR)\\$(CMNOBJTARGET)\" $(DATA_VER_INFO)\n\n");
|
2002-04-02 02:55:31 +00:00
|
|
|
T_FileStream_writeLine(makefile, tmp);
|
2004-05-12 19:58:49 +00:00
|
|
|
sprintf(tmp, "\"$(TEMP_DIR)\\$(CMNOBJTARGET)\": \"$(TARGETDIR)\\$(CMNTARGET)\"\n"
|
|
|
|
"\t@\"$(GENCCODE)\" $(GENCOPTIONS) -e $(ENTRYPOINT) -o -d \"$(TEMP_DIR)\" \"$(TARGETDIR)\\$(CMNTARGET)\"\n\n");
|
2002-04-02 02:55:31 +00:00
|
|
|
T_FileStream_writeLine(makefile, tmp);
|
|
|
|
|
|
|
|
sprintf(tmp2,
|
|
|
|
"clean:\n"
|
|
|
|
"\t-@erase \"$(TARGETDIR)\\$(DLLTARGET)\"\n"
|
|
|
|
"\t-@erase \"$(TARGETDIR)\\$(CMNOBJTARGET)\"\n"
|
|
|
|
"\t-@erase \"$(TARGETDIR)\\$(CMNTARGET)\"\n\n");
|
|
|
|
T_FileStream_writeLine(makefile, tmp2);
|
2004-05-17 06:37:28 +00:00
|
|
|
|
|
|
|
T_FileStream_writeLine(makefile, "install: \"$(TARGETDIR)\\$(DLLTARGET)\"\n"
|
|
|
|
"\tcopy \"$(TARGETDIR)\\$(DLLTARGET)\" \"$(INSTALLTO)\\$(DLLTARGET)\"\n\n");
|
2002-04-02 02:55:31 +00:00
|
|
|
} else { /* common */
|
|
|
|
sprintf(tmp, "all: \"$(TARGETDIR)\\$(CMNTARGET)\"\n\n");
|
|
|
|
T_FileStream_writeLine(makefile, tmp);
|
|
|
|
|
|
|
|
sprintf(tmp2,
|
|
|
|
"clean:\n"
|
|
|
|
"\t-@erase \"$(TARGETDIR)\\$(CMNTARGET)\"\n\n");
|
|
|
|
T_FileStream_writeLine(makefile, tmp2);
|
|
|
|
|
2004-05-17 06:37:28 +00:00
|
|
|
T_FileStream_writeLine(makefile, "install: \"$(TARGETDIR)\\$(CMNTARGET)\"\n"
|
|
|
|
"\tcopy \"$(TARGETDIR)\\$(CMNTARGET)\" \"$(INSTALLTO)\\$(CMNTARGET)\"\n\n");
|
|
|
|
}
|
2004-05-05 17:40:53 +00:00
|
|
|
|
|
|
|
T_FileStream_writeLine(makefile, "rebuild: clean all\n\n");
|
2002-04-02 02:55:31 +00:00
|
|
|
|
|
|
|
/* Write compile rules */
|
|
|
|
writeCmnRules(o, makefile);
|
2000-07-17 05:37:48 +00:00
|
|
|
}
|
|
|
|
|
2003-02-11 00:25:29 +00:00
|
|
|
#endif
|