]>
Commit | Line | Data |
---|---|---|
b75a7d8f A |
1 | /****************************************************************************** |
2 | * | |
374ca955 | 3 | * Copyright (C) 2000-2004, International Business Machines |
b75a7d8f A |
4 | * Corporation and others. All Rights Reserved. |
5 | * | |
6 | ******************************************************************************* | |
7 | * file name: winmode.c | |
8 | * encoding: ANSI X3.4 (1968) | |
9 | * tab size: 8 (not used) | |
10 | * indentation:4 | |
11 | * | |
12 | * created on: 2000july14 | |
13 | * created by: Vladimir Weinstein | |
14 | * | |
15 | * This program packages the ICU data into different forms | |
16 | * (DLL, common data, etc.) | |
17 | */ | |
18 | ||
b75a7d8f | 19 | #include "unicode/utypes.h" |
374ca955 A |
20 | |
21 | #ifdef U_MAKE_IS_NMAKE | |
22 | ||
b75a7d8f A |
23 | #include "unicode/putil.h" |
24 | #include "cmemory.h" | |
25 | #include "cstring.h" | |
26 | #include "filestrm.h" | |
27 | #include "toolutil.h" | |
28 | #include "unewdata.h" | |
29 | #include "uoptions.h" | |
30 | #include "pkgtypes.h" | |
31 | #include "makefile.h" | |
374ca955 A |
32 | #include <stdio.h> |
33 | #include <stdlib.h> | |
b75a7d8f | 34 | |
374ca955 A |
35 | /*#define WINBUILDMODE (*(o->options)=='R'?"Release":"Debug")*/ |
36 | #define CONTAINS_REAL_PATH(o) (*(o->options)==PKGDATA_DERIVED_PATH) | |
b75a7d8f A |
37 | |
38 | void writeCmnRules(UPKGOptions *o, FileStream *makefile) | |
39 | { | |
40 | char tmp[1024]; | |
41 | CharList *infiles; | |
42 | ||
374ca955 A |
43 | if(!o->embed) { |
44 | infiles = o->files; | |
45 | } else { | |
46 | infiles = o->filePaths; | |
47 | } | |
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)\""); | |
b75a7d8f A |
56 | T_FileStream_writeLine(makefile, tmp); |
57 | ||
58 | pkg_writeCharList(makefile, infiles, "\n", -1); | |
59 | /* | |
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); | |
63 | } else { | |
64 | sprintf(tmp, "%s\n", infiles->str); | |
65 | } | |
66 | T_FileStream_writeLine(makefile, tmp); | |
67 | } | |
68 | */ | |
69 | sprintf(tmp, "\n<<\n"); | |
70 | T_FileStream_writeLine(makefile, tmp); | |
71 | } | |
72 | ||
73 | ||
74 | ||
75 | void pkg_mode_windows(UPKGOptions *o, FileStream *makefile, UErrorCode *status) { | |
76 | char tmp[1024]; | |
77 | char tmp2[1024]; | |
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); | |
81 | ||
82 | if(U_FAILURE(*status)) { | |
83 | return; | |
84 | } | |
85 | ||
86 | sprintf(tmp2, "ICUROOT=%s\n\n", o->icuroot); | |
87 | T_FileStream_writeLine(makefile, tmp2); | |
88 | ||
374ca955 A |
89 | if (CONTAINS_REAL_PATH(o)) { |
90 | sprintf(tmp2, | |
91 | "GENCMN = $(ICUROOT)%sgencmn.exe\n", separator); | |
92 | } | |
93 | else { | |
94 | sprintf(tmp2, | |
95 | "GENCMN = $(ICUROOT)%sbin\\gencmn.exe\n", separator); | |
96 | } | |
b75a7d8f A |
97 | T_FileStream_writeLine(makefile, tmp2); |
98 | ||
99 | if(isDll) { | |
100 | uprv_strcpy(tmp, LIB_PREFIX); | |
374ca955 A |
101 | uprv_strcat(tmp, o->libName); |
102 | if (o->version) { | |
103 | uprv_strcat(tmp, "$(TARGET_VERSION)"); | |
104 | } | |
b75a7d8f A |
105 | uprv_strcat(tmp, UDATA_SO_SUFFIX); |
106 | ||
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); | |
109 | } | |
110 | ||
111 | if(o->nooutput) { | |
112 | *status = U_ZERO_ERROR; | |
113 | return; | |
114 | } | |
115 | ||
116 | sprintf(tmp2, "# DLL file to make:\nDLLTARGET=%s\n\n", tmp); | |
117 | T_FileStream_writeLine(makefile, tmp2); | |
118 | ||
119 | sprintf(tmp2, | |
120 | "LINK32 = link.exe\n" | |
374ca955 A |
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 ? "\"" : ""), | |
b75a7d8f A |
125 | o->comment |
126 | ); | |
127 | T_FileStream_writeLine(makefile, tmp2); | |
128 | ||
374ca955 A |
129 | if (CONTAINS_REAL_PATH(o)) { |
130 | sprintf(tmp2, | |
131 | "GENCCODE = $(ICUROOT)%sgenccode.exe\n", separator); | |
132 | } | |
133 | else { | |
134 | sprintf(tmp2, | |
135 | "GENCCODE = $(ICUROOT)%sbin\\genccode.exe\n", separator); | |
136 | } | |
b75a7d8f A |
137 | T_FileStream_writeLine(makefile, tmp2); |
138 | ||
374ca955 | 139 | /* If you modify this, remember to modify makedata.mak too. */ |
b75a7d8f A |
140 | T_FileStream_writeLine(makefile, "\n" |
141 | "# Windows specific DLL version information.\n" | |
374ca955 A |
142 | "!IF EXISTS(\"$(TEMP_DIR)\\icudata.res\")\n" |
143 | "DATA_VER_INFO=\"$(TEMP_DIR)\\icudata.res\"\n" | |
b75a7d8f A |
144 | "!ELSE\n" |
145 | "DATA_VER_INFO=\n" | |
146 | "!ENDIF\n\n"); | |
147 | ||
148 | ||
149 | uprv_strcpy(tmp, UDATA_CMN_PREFIX "$(NAME)" UDATA_CMN_INTERMEDIATE_SUFFIX OBJ_SUFFIX); | |
150 | ||
151 | sprintf(tmp2, "# intermediate obj file:\nCMNOBJTARGET=%s\n\n", tmp); | |
152 | T_FileStream_writeLine(makefile, tmp2); | |
153 | } | |
154 | else if (isStatic) | |
155 | { | |
156 | uprv_strcpy(tmp, LIB_PREFIX); | |
374ca955 | 157 | uprv_strcat(tmp, o->libName); |
b75a7d8f A |
158 | uprv_strcat(tmp, UDATA_LIB_SUFFIX); |
159 | ||
374ca955 A |
160 | if (!o->quiet) { |
161 | pkg_sttc_writeReadme(o, tmp, status); | |
162 | } | |
b75a7d8f A |
163 | if(U_FAILURE(*status)) |
164 | { | |
165 | return; | |
166 | } | |
167 | ||
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); | |
170 | } | |
171 | ||
172 | if(o->nooutput) { | |
173 | *status = U_ZERO_ERROR; | |
174 | return; | |
175 | } | |
176 | ||
177 | sprintf(tmp2, "# LIB file to make:\nDLLTARGET=%s\n\n", tmp); | |
178 | T_FileStream_writeLine(makefile, tmp2); | |
179 | ||
180 | sprintf(tmp2, | |
181 | "LINK32 = LIB.exe\n" | |
182 | "LINK32_FLAGS = /nologo /out:\"$(TARGETDIR)\\$(DLLTARGET)\" /EXPORT:\"%s\"\n", | |
374ca955 | 183 | o->libName |
b75a7d8f A |
184 | ); |
185 | T_FileStream_writeLine(makefile, tmp2); | |
186 | ||
b75a7d8f | 187 | |
374ca955 A |
188 | if (CONTAINS_REAL_PATH(o)) { |
189 | sprintf(tmp2, | |
190 | "GENCCODE = $(ICUROOT)%sgenccode.exe\n", separator); | |
191 | } | |
192 | else { | |
193 | sprintf(tmp2, | |
194 | "GENCCODE = $(ICUROOT)%sbin\\genccode.exe\n", separator); | |
195 | } | |
196 | T_FileStream_writeLine(makefile, tmp2); | |
b75a7d8f A |
197 | |
198 | uprv_strcpy(tmp, UDATA_CMN_PREFIX "$(NAME)" UDATA_CMN_INTERMEDIATE_SUFFIX OBJ_SUFFIX); | |
199 | ||
374ca955 | 200 | sprintf(tmp2, "# intermediate obj file\nCMNOBJTARGET=%s\n\n", tmp); |
b75a7d8f A |
201 | T_FileStream_writeLine(makefile, tmp2); |
202 | } | |
203 | uprv_strcpy(tmp, UDATA_CMN_PREFIX); | |
204 | uprv_strcat(tmp, o->cShortName); | |
374ca955 A |
205 | if (o->version && !uprv_strstr(o->shortName,o->version)) { |
206 | uprv_strcat(tmp, "$(TARGET_VERSION)"); | |
207 | } | |
b75a7d8f A |
208 | uprv_strcat(tmp, UDATA_CMN_SUFFIX); |
209 | ||
210 | if(o->nooutput || o->verbose) { | |
211 | fprintf(stdout, "# Output file: %s%s%s\n", o->targetDir, U_FILE_SEP_STRING, tmp); | |
212 | } | |
213 | ||
214 | if(o->nooutput) { | |
215 | *status = U_ZERO_ERROR; | |
216 | return; | |
217 | } | |
218 | ||
219 | sprintf(tmp2, "# common file to make:\nCMNTARGET=%s\n\n", tmp); | |
220 | T_FileStream_writeLine(makefile, tmp2); | |
221 | ||
222 | ||
223 | if(isDll || isStatic) { | |
224 | sprintf(tmp, "all: \"$(TARGETDIR)\\$(DLLTARGET)\"\n\n"); | |
225 | T_FileStream_writeLine(makefile, tmp); | |
226 | ||
374ca955 A |
227 | sprintf(tmp, "\"$(TARGETDIR)\\$(DLLTARGET)\": \"$(TEMP_DIR)\\$(CMNOBJTARGET)\"\n" |
228 | "\t$(LINK32) $(LINK32_FLAGS) \"$(TEMP_DIR)\\$(CMNOBJTARGET)\" $(DATA_VER_INFO)\n\n"); | |
b75a7d8f | 229 | T_FileStream_writeLine(makefile, tmp); |
374ca955 A |
230 | sprintf(tmp, "\"$(TEMP_DIR)\\$(CMNOBJTARGET)\": \"$(TARGETDIR)\\$(CMNTARGET)\"\n" |
231 | "\t@\"$(GENCCODE)\" $(GENCOPTIONS) -e $(ENTRYPOINT) -o -d \"$(TEMP_DIR)\" \"$(TARGETDIR)\\$(CMNTARGET)\"\n\n"); | |
b75a7d8f A |
232 | T_FileStream_writeLine(makefile, tmp); |
233 | ||
234 | sprintf(tmp2, | |
235 | "clean:\n" | |
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); | |
374ca955 A |
240 | |
241 | T_FileStream_writeLine(makefile, "install: \"$(TARGETDIR)\\$(DLLTARGET)\"\n" | |
242 | "\tcopy \"$(TARGETDIR)\\$(DLLTARGET)\" \"$(INSTALLTO)\\$(DLLTARGET)\"\n\n"); | |
b75a7d8f A |
243 | } else { /* common */ |
244 | sprintf(tmp, "all: \"$(TARGETDIR)\\$(CMNTARGET)\"\n\n"); | |
245 | T_FileStream_writeLine(makefile, tmp); | |
246 | ||
247 | sprintf(tmp2, | |
248 | "clean:\n" | |
249 | "\t-@erase \"$(TARGETDIR)\\$(CMNTARGET)\"\n\n"); | |
250 | T_FileStream_writeLine(makefile, tmp2); | |
374ca955 A |
251 | |
252 | T_FileStream_writeLine(makefile, "install: \"$(TARGETDIR)\\$(CMNTARGET)\"\n" | |
253 | "\tcopy \"$(TARGETDIR)\\$(CMNTARGET)\" \"$(INSTALLTO)\\$(CMNTARGET)\"\n\n"); | |
b75a7d8f A |
254 | } |
255 | ||
374ca955 | 256 | T_FileStream_writeLine(makefile, "rebuild: clean all\n\n"); |
b75a7d8f A |
257 | |
258 | /* Write compile rules */ | |
259 | writeCmnRules(o, makefile); | |
260 | } | |
261 | ||
262 | #endif |