1 /******************************************************************************
3 * Copyright (C) 2000-2006, 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
)
44 sprintf(tmp
, "\"$(TARGETDIR)\\$(CMNTARGET)\" : $(DATAFILEPATHS)\n"
45 "\t%s\"$(GENCMN)\" %s%s%s-d \"$(TARGETDIR)\" -s \"$(SRCDIR)\" -n \"$(NAME)\" 0 <<\n",
46 (o
->verbose
? "" : "@"),
47 (o
->comment
? "-C \"" : ""),
48 (o
->comment
? o
->comment
: ""),
49 (o
->comment
? "\" " : ""));
50 T_FileStream_writeLine(makefile
, tmp
);
52 pkg_writeCharList(makefile
, infiles
, "\n", -1);
54 for(;infiles;infiles = infiles->next) {
55 if(infiles->str[0] != '"' && infiles->str[uprv_strlen(infiles->str)-1] != '"') {
56 sprintf(tmp, "\"%s\"\n", infiles->str);
58 sprintf(tmp, "%s\n", infiles->str);
60 T_FileStream_writeLine(makefile, tmp);
63 sprintf(tmp
, "\n<<\n");
64 T_FileStream_writeLine(makefile
, tmp
);
69 void pkg_mode_windows(UPKGOptions
*o
, FileStream
*makefile
, UErrorCode
*status
) {
72 const char *separator
= o
->icuroot
[uprv_strlen(o
->icuroot
)-1]=='\\'?"":"\\";
73 UBool isDll
= (UBool
)(uprv_strcmp(o
->mode
, "dll") == 0);
74 UBool isStatic
= (UBool
)(uprv_strcmp(o
->mode
, "static") == 0);
76 if(U_FAILURE(*status
)) {
80 sprintf(tmp2
, "ICUROOT=%s\n\n", o
->icuroot
);
81 T_FileStream_writeLine(makefile
, tmp2
);
83 if (CONTAINS_REAL_PATH(o
)) {
85 "GENCMN = $(ICUROOT)%sgencmn.exe\n", separator
);
89 "GENCMN = $(ICUROOT)%sbin\\gencmn.exe\n", separator
);
91 T_FileStream_writeLine(makefile
, tmp2
);
94 uprv_strcpy(tmp
, LIB_PREFIX
);
95 uprv_strcat(tmp
, o
->libName
);
97 uprv_strcat(tmp
, "$(TARGET_VERSION)");
99 uprv_strcat(tmp
, UDATA_SO_SUFFIX
);
101 if(o
->nooutput
|| o
->verbose
) {
102 fprintf(stdout
, "# Output %s file: %s%s%s\n", UDATA_SO_SUFFIX
, o
->targetDir
, U_FILE_SEP_STRING
, tmp
);
106 *status
= U_ZERO_ERROR
;
110 sprintf(tmp2
, "# DLL file to make:\nDLLTARGET=%s\n\n", tmp
);
111 T_FileStream_writeLine(makefile
, tmp2
);
114 "LINK32 = link.exe\n"
115 "LINK32_FLAGS = /nologo /out:\"$(TARGETDIR)\\$(DLLTARGET)\" /DLL /NOENTRY $(LDFLAGS) $(PKGDATA_LDFLAGS) /implib:\"$(TARGETDIR)\\$(LIBNAME).lib\" %s%s%s\n",
116 (o
->comment
? "/comment:\"" : ""),
117 (o
->comment
? o
->comment
: ""),
118 (o
->comment
? "\"" : ""),
121 T_FileStream_writeLine(makefile
, tmp2
);
123 if (CONTAINS_REAL_PATH(o
)) {
125 "GENCCODE = $(ICUROOT)%sgenccode.exe\n", separator
);
129 "GENCCODE = $(ICUROOT)%sbin\\genccode.exe\n", separator
);
131 T_FileStream_writeLine(makefile
, tmp2
);
133 /* If you modify this, remember to modify makedata.mak too. */
134 T_FileStream_writeLine(makefile
, "\n"
135 "# Windows specific DLL version information.\n"
136 "!IF EXISTS(\"$(TEMP_DIR)\\icudata.res\")\n"
137 "DATA_VER_INFO=\"$(TEMP_DIR)\\icudata.res\"\n"
143 uprv_strcpy(tmp
, UDATA_CMN_PREFIX
"$(NAME)" UDATA_CMN_INTERMEDIATE_SUFFIX OBJ_SUFFIX
);
145 sprintf(tmp2
, "# intermediate obj file:\nCMNOBJTARGET=%s\n\n", tmp
);
146 T_FileStream_writeLine(makefile
, tmp2
);
150 uprv_strcpy(tmp
, LIB_PREFIX
);
151 uprv_strcat(tmp
, o
->libName
);
152 uprv_strcat(tmp
, UDATA_LIB_SUFFIX
);
155 pkg_sttc_writeReadme(o
, tmp
, status
);
157 if(U_FAILURE(*status
))
162 if(o
->nooutput
|| o
->verbose
) {
163 fprintf(stdout
, "# Output %s file: %s%s%s\n", UDATA_SO_SUFFIX
, o
->targetDir
, U_FILE_SEP_STRING
, tmp
);
167 *status
= U_ZERO_ERROR
;
171 sprintf(tmp2
, "# LIB file to make:\nDLLTARGET=%s\n\n", tmp
);
172 T_FileStream_writeLine(makefile
, tmp2
);
176 "LINK32_FLAGS = /nologo /out:\"$(TARGETDIR)\\$(DLLTARGET)\" /EXPORT:\"%s\"\n",
179 T_FileStream_writeLine(makefile
, tmp2
);
182 if (CONTAINS_REAL_PATH(o
)) {
184 "GENCCODE = $(ICUROOT)%sgenccode.exe\n", separator
);
188 "GENCCODE = $(ICUROOT)%sbin\\genccode.exe\n", separator
);
190 T_FileStream_writeLine(makefile
, tmp2
);
192 uprv_strcpy(tmp
, UDATA_CMN_PREFIX
"$(NAME)" UDATA_CMN_INTERMEDIATE_SUFFIX OBJ_SUFFIX
);
194 sprintf(tmp2
, "# intermediate obj file\nCMNOBJTARGET=%s\n\n", tmp
);
195 T_FileStream_writeLine(makefile
, tmp2
);
197 uprv_strcpy(tmp
, UDATA_CMN_PREFIX
);
198 uprv_strcat(tmp
, o
->cShortName
);
199 if (o
->version
&& !uprv_strstr(o
->shortName
,o
->version
)) {
200 uprv_strcat(tmp
, "$(TARGET_VERSION)");
202 uprv_strcat(tmp
, UDATA_CMN_SUFFIX
);
204 if(o
->nooutput
|| o
->verbose
) {
205 fprintf(stdout
, "# Output file: %s%s%s\n", o
->targetDir
, U_FILE_SEP_STRING
, tmp
);
209 *status
= U_ZERO_ERROR
;
213 sprintf(tmp2
, "# common file to make:\nCMNTARGET=%s\n\n", tmp
);
214 T_FileStream_writeLine(makefile
, tmp2
);
217 if(isDll
|| isStatic
) {
218 sprintf(tmp
, "all: \"$(TARGETDIR)\\$(DLLTARGET)\"\n\n");
219 T_FileStream_writeLine(makefile
, tmp
);
221 sprintf(tmp
, "\"$(TARGETDIR)\\$(DLLTARGET)\": \"$(TEMP_DIR)\\$(CMNOBJTARGET)\"\n"
222 "\t$(LINK32) $(LINK32_FLAGS) \"$(TEMP_DIR)\\$(CMNOBJTARGET)\" $(DATA_VER_INFO)\n\n");
223 T_FileStream_writeLine(makefile
, tmp
);
224 sprintf(tmp
, "\"$(TEMP_DIR)\\$(CMNOBJTARGET)\": \"$(TARGETDIR)\\$(CMNTARGET)\"\n"
225 "\t@\"$(GENCCODE)\" $(GENCOPTIONS) -e $(ENTRYPOINT) -o -d \"$(TEMP_DIR)\" \"$(TARGETDIR)\\$(CMNTARGET)\"\n\n");
226 T_FileStream_writeLine(makefile
, tmp
);
230 "\t-@erase \"$(TARGETDIR)\\$(DLLTARGET)\"\n"
231 "\t-@erase \"$(TARGETDIR)\\$(CMNOBJTARGET)\"\n"
232 "\t-@erase \"$(TARGETDIR)\\$(CMNTARGET)\"\n\n");
233 T_FileStream_writeLine(makefile
, tmp2
);
235 T_FileStream_writeLine(makefile
, "install: \"$(TARGETDIR)\\$(DLLTARGET)\"\n"
236 "\tcopy \"$(TARGETDIR)\\$(DLLTARGET)\" \"$(INSTALLTO)\\$(DLLTARGET)\"\n\n");
237 } else { /* common */
238 sprintf(tmp
, "all: \"$(TARGETDIR)\\$(CMNTARGET)\"\n\n");
239 T_FileStream_writeLine(makefile
, tmp
);
243 "\t-@erase \"$(TARGETDIR)\\$(CMNTARGET)\"\n\n");
244 T_FileStream_writeLine(makefile
, tmp2
);
246 T_FileStream_writeLine(makefile
, "install: \"$(TARGETDIR)\\$(CMNTARGET)\"\n"
247 "\tcopy \"$(TARGETDIR)\\$(CMNTARGET)\" \"$(INSTALLTO)\\$(CMNTARGET)\"\n\n");
250 T_FileStream_writeLine(makefile
, "rebuild: clean all\n\n");
252 /* Write compile rules */
253 writeCmnRules(o
, makefile
);