1 /******************************************************************************
3 * Copyright (C) 2000-2004, International Business Machines
4 * Corporation and others. All Rights Reserved.
6 *******************************************************************************
8 * encoding: ANSI X3.4 (1968)
9 * tab size: 8 (not used)
12 * created on: 2000july14
13 * created by: Vladimir Weinstein
15 * This program packages the ICU data into different forms
16 * (DLL, common data, etc.)
19 #include "unicode/utypes.h"
21 #ifdef U_MAKE_IS_NMAKE
23 #include "unicode/putil.h"
35 /*#define WINBUILDMODE (*(o->options)=='R'?"Release":"Debug")*/
36 #define CONTAINS_REAL_PATH(o) (*(o->options)==PKGDATA_DERIVED_PATH)
38 void writeCmnRules(UPKGOptions
*o
, FileStream
*makefile
)
46 infiles
= o
->filePaths
;
48 sprintf(tmp
, "\"$(TARGETDIR)\\$(CMNTARGET)\" : $(DATAFILEPATHS)\n"
49 "\t%s\"$(GENCMN)\" %s%s%s-d \"$(TARGETDIR)\" %s %s -n \"$(NAME)\" 0 <<\n",
50 (o
->verbose
? "" : "@"),
51 (o
->comment
? "-C \"" : ""),
52 (o
->comment
? o
->comment
: ""),
53 (o
->comment
? "\" " : ""),
54 (o
->embed
? "-E" : ""),
55 o
->embed
? "" : "-s \"$(SRCDIR)\"");
56 T_FileStream_writeLine(makefile
, tmp
);
58 pkg_writeCharList(makefile
, infiles
, "\n", -1);
60 for(;infiles;infiles = infiles->next) {
61 if(infiles->str[0] != '"' && infiles->str[uprv_strlen(infiles->str)-1] != '"') {
62 sprintf(tmp, "\"%s\"\n", infiles->str);
64 sprintf(tmp, "%s\n", infiles->str);
66 T_FileStream_writeLine(makefile, tmp);
69 sprintf(tmp
, "\n<<\n");
70 T_FileStream_writeLine(makefile
, tmp
);
75 void pkg_mode_windows(UPKGOptions
*o
, FileStream
*makefile
, UErrorCode
*status
) {
78 const char *separator
= o
->icuroot
[uprv_strlen(o
->icuroot
)-1]=='\\'?"":"\\";
79 UBool isDll
= (UBool
)(uprv_strcmp(o
->mode
, "dll") == 0);
80 UBool isStatic
= (UBool
)(uprv_strcmp(o
->mode
, "static") == 0);
82 if(U_FAILURE(*status
)) {
86 sprintf(tmp2
, "ICUROOT=%s\n\n", o
->icuroot
);
87 T_FileStream_writeLine(makefile
, tmp2
);
89 if (CONTAINS_REAL_PATH(o
)) {
91 "GENCMN = $(ICUROOT)%sgencmn.exe\n", separator
);
95 "GENCMN = $(ICUROOT)%sbin\\gencmn.exe\n", separator
);
97 T_FileStream_writeLine(makefile
, tmp2
);
100 uprv_strcpy(tmp
, LIB_PREFIX
);
101 uprv_strcat(tmp
, o
->libName
);
103 uprv_strcat(tmp
, "$(TARGET_VERSION)");
105 uprv_strcat(tmp
, UDATA_SO_SUFFIX
);
107 if(o
->nooutput
|| o
->verbose
) {
108 fprintf(stdout
, "# Output %s file: %s%s%s\n", UDATA_SO_SUFFIX
, o
->targetDir
, U_FILE_SEP_STRING
, tmp
);
112 *status
= U_ZERO_ERROR
;
116 sprintf(tmp2
, "# DLL file to make:\nDLLTARGET=%s\n\n", tmp
);
117 T_FileStream_writeLine(makefile
, tmp2
);
120 "LINK32 = link.exe\n"
121 "LINK32_FLAGS = /nologo /out:\"$(TARGETDIR)\\$(DLLTARGET)\" /DLL /NOENTRY /base:\"0x4ad00000\" /implib:\"$(TARGETDIR)\\$(LIBNAME).lib\" %s%s%s\n",
122 (o
->comment
? "/comment:\"" : ""),
123 (o
->comment
? o
->comment
: ""),
124 (o
->comment
? "\"" : ""),
127 T_FileStream_writeLine(makefile
, tmp2
);
129 if (CONTAINS_REAL_PATH(o
)) {
131 "GENCCODE = $(ICUROOT)%sgenccode.exe\n", separator
);
135 "GENCCODE = $(ICUROOT)%sbin\\genccode.exe\n", separator
);
137 T_FileStream_writeLine(makefile
, tmp2
);
139 /* If you modify this, remember to modify makedata.mak too. */
140 T_FileStream_writeLine(makefile
, "\n"
141 "# Windows specific DLL version information.\n"
142 "!IF EXISTS(\"$(TEMP_DIR)\\icudata.res\")\n"
143 "DATA_VER_INFO=\"$(TEMP_DIR)\\icudata.res\"\n"
149 uprv_strcpy(tmp
, UDATA_CMN_PREFIX
"$(NAME)" UDATA_CMN_INTERMEDIATE_SUFFIX OBJ_SUFFIX
);
151 sprintf(tmp2
, "# intermediate obj file:\nCMNOBJTARGET=%s\n\n", tmp
);
152 T_FileStream_writeLine(makefile
, tmp2
);
156 uprv_strcpy(tmp
, LIB_PREFIX
);
157 uprv_strcat(tmp
, o
->libName
);
158 uprv_strcat(tmp
, UDATA_LIB_SUFFIX
);
161 pkg_sttc_writeReadme(o
, tmp
, status
);
163 if(U_FAILURE(*status
))
168 if(o
->nooutput
|| o
->verbose
) {
169 fprintf(stdout
, "# Output %s file: %s%s%s\n", UDATA_SO_SUFFIX
, o
->targetDir
, U_FILE_SEP_STRING
, tmp
);
173 *status
= U_ZERO_ERROR
;
177 sprintf(tmp2
, "# LIB file to make:\nDLLTARGET=%s\n\n", tmp
);
178 T_FileStream_writeLine(makefile
, tmp2
);
182 "LINK32_FLAGS = /nologo /out:\"$(TARGETDIR)\\$(DLLTARGET)\" /EXPORT:\"%s\"\n",
185 T_FileStream_writeLine(makefile
, tmp2
);
188 if (CONTAINS_REAL_PATH(o
)) {
190 "GENCCODE = $(ICUROOT)%sgenccode.exe\n", separator
);
194 "GENCCODE = $(ICUROOT)%sbin\\genccode.exe\n", separator
);
196 T_FileStream_writeLine(makefile
, tmp2
);
198 uprv_strcpy(tmp
, UDATA_CMN_PREFIX
"$(NAME)" UDATA_CMN_INTERMEDIATE_SUFFIX OBJ_SUFFIX
);
200 sprintf(tmp2
, "# intermediate obj file\nCMNOBJTARGET=%s\n\n", tmp
);
201 T_FileStream_writeLine(makefile
, tmp2
);
203 uprv_strcpy(tmp
, UDATA_CMN_PREFIX
);
204 uprv_strcat(tmp
, o
->cShortName
);
205 if (o
->version
&& !uprv_strstr(o
->shortName
,o
->version
)) {
206 uprv_strcat(tmp
, "$(TARGET_VERSION)");
208 uprv_strcat(tmp
, UDATA_CMN_SUFFIX
);
210 if(o
->nooutput
|| o
->verbose
) {
211 fprintf(stdout
, "# Output file: %s%s%s\n", o
->targetDir
, U_FILE_SEP_STRING
, tmp
);
215 *status
= U_ZERO_ERROR
;
219 sprintf(tmp2
, "# common file to make:\nCMNTARGET=%s\n\n", tmp
);
220 T_FileStream_writeLine(makefile
, tmp2
);
223 if(isDll
|| isStatic
) {
224 sprintf(tmp
, "all: \"$(TARGETDIR)\\$(DLLTARGET)\"\n\n");
225 T_FileStream_writeLine(makefile
, tmp
);
227 sprintf(tmp
, "\"$(TARGETDIR)\\$(DLLTARGET)\": \"$(TEMP_DIR)\\$(CMNOBJTARGET)\"\n"
228 "\t$(LINK32) $(LINK32_FLAGS) \"$(TEMP_DIR)\\$(CMNOBJTARGET)\" $(DATA_VER_INFO)\n\n");
229 T_FileStream_writeLine(makefile
, tmp
);
230 sprintf(tmp
, "\"$(TEMP_DIR)\\$(CMNOBJTARGET)\": \"$(TARGETDIR)\\$(CMNTARGET)\"\n"
231 "\t@\"$(GENCCODE)\" $(GENCOPTIONS) -e $(ENTRYPOINT) -o -d \"$(TEMP_DIR)\" \"$(TARGETDIR)\\$(CMNTARGET)\"\n\n");
232 T_FileStream_writeLine(makefile
, tmp
);
236 "\t-@erase \"$(TARGETDIR)\\$(DLLTARGET)\"\n"
237 "\t-@erase \"$(TARGETDIR)\\$(CMNOBJTARGET)\"\n"
238 "\t-@erase \"$(TARGETDIR)\\$(CMNTARGET)\"\n\n");
239 T_FileStream_writeLine(makefile
, tmp2
);
241 T_FileStream_writeLine(makefile
, "install: \"$(TARGETDIR)\\$(DLLTARGET)\"\n"
242 "\tcopy \"$(TARGETDIR)\\$(DLLTARGET)\" \"$(INSTALLTO)\\$(DLLTARGET)\"\n\n");
243 } else { /* common */
244 sprintf(tmp
, "all: \"$(TARGETDIR)\\$(CMNTARGET)\"\n\n");
245 T_FileStream_writeLine(makefile
, tmp
);
249 "\t-@erase \"$(TARGETDIR)\\$(CMNTARGET)\"\n\n");
250 T_FileStream_writeLine(makefile
, tmp2
);
252 T_FileStream_writeLine(makefile
, "install: \"$(TARGETDIR)\\$(CMNTARGET)\"\n"
253 "\tcopy \"$(TARGETDIR)\\$(CMNTARGET)\" \"$(INSTALLTO)\\$(CMNTARGET)\"\n\n");
256 T_FileStream_writeLine(makefile
, "rebuild: clean all\n\n");
258 /* Write compile rules */
259 writeCmnRules(o
, makefile
);