]>
Commit | Line | Data |
---|---|---|
b75a7d8f A |
1 | /****************************************************************************** |
2 | * | |
3 | * Copyright (C) 2000-2003, International Business Machines | |
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 | ||
19 | #include <stdio.h> | |
20 | #include <stdlib.h> | |
21 | #include "unicode/utypes.h" | |
22 | #include "unicode/putil.h" | |
23 | #include "cmemory.h" | |
24 | #include "cstring.h" | |
25 | #include "filestrm.h" | |
26 | #include "toolutil.h" | |
27 | #include "unewdata.h" | |
28 | #include "uoptions.h" | |
29 | #include "pkgtypes.h" | |
30 | #include "makefile.h" | |
31 | ||
32 | #ifdef WIN32 | |
33 | #define WINBUILDMODE (*(o->options)=='R'?"Release":"Debug") | |
34 | ||
35 | void writeCmnRules(UPKGOptions *o, FileStream *makefile) | |
36 | { | |
37 | char tmp[1024]; | |
38 | CharList *infiles; | |
39 | ||
40 | infiles = o->filePaths; | |
41 | ||
42 | sprintf(tmp, "\"$(TARGETDIR)\\$(CMNTARGET)\" : $(DATAFILEPATHS)\n\t@\"$(GENCMN)\" -C \"%s\" -d \"%s\" -n \"$(NAME)\" 0 <<\n", | |
43 | o->comment, o->targetDir); | |
44 | T_FileStream_writeLine(makefile, tmp); | |
45 | ||
46 | pkg_writeCharList(makefile, infiles, "\n", -1); | |
47 | /* | |
48 | for(;infiles;infiles = infiles->next) { | |
49 | if(infiles->str[0] != '"' && infiles->str[uprv_strlen(infiles->str)-1] != '"') { | |
50 | sprintf(tmp, "\"%s\"\n", infiles->str); | |
51 | } else { | |
52 | sprintf(tmp, "%s\n", infiles->str); | |
53 | } | |
54 | T_FileStream_writeLine(makefile, tmp); | |
55 | } | |
56 | */ | |
57 | sprintf(tmp, "\n<<\n"); | |
58 | T_FileStream_writeLine(makefile, tmp); | |
59 | } | |
60 | ||
61 | ||
62 | ||
63 | void pkg_mode_windows(UPKGOptions *o, FileStream *makefile, UErrorCode *status) { | |
64 | char tmp[1024]; | |
65 | char tmp2[1024]; | |
66 | const char *separator = o->icuroot[uprv_strlen(o->icuroot)-1]=='\\'?"":"\\"; | |
67 | UBool isDll = (UBool)(uprv_strcmp(o->mode, "dll") == 0); | |
68 | UBool isStatic = (UBool)(uprv_strcmp(o->mode, "static") == 0); | |
69 | ||
70 | if(U_FAILURE(*status)) { | |
71 | return; | |
72 | } | |
73 | ||
74 | sprintf(tmp2, "ICUROOT=%s\n\n", o->icuroot); | |
75 | T_FileStream_writeLine(makefile, tmp2); | |
76 | ||
77 | sprintf(tmp2, | |
78 | "GENCMN = $(ICUROOT)%sbin\\gencmn.exe\n", separator); | |
79 | T_FileStream_writeLine(makefile, tmp2); | |
80 | ||
81 | if(isDll) { | |
82 | uprv_strcpy(tmp, LIB_PREFIX); | |
83 | uprv_strcat(tmp, o->cShortName); | |
84 | uprv_strcat(tmp, UDATA_SO_SUFFIX); | |
85 | ||
86 | if(o->nooutput || o->verbose) { | |
87 | fprintf(stdout, "# Output %s file: %s%s%s\n", UDATA_SO_SUFFIX, o->targetDir, U_FILE_SEP_STRING, tmp); | |
88 | } | |
89 | ||
90 | if(o->nooutput) { | |
91 | *status = U_ZERO_ERROR; | |
92 | return; | |
93 | } | |
94 | ||
95 | sprintf(tmp2, "# DLL file to make:\nDLLTARGET=%s\n\n", tmp); | |
96 | T_FileStream_writeLine(makefile, tmp2); | |
97 | ||
98 | sprintf(tmp2, | |
99 | "LINK32 = link.exe\n" | |
100 | "LINK32_FLAGS = /nologo /out:\"$(TARGETDIR)\\$(DLLTARGET)\" /DLL /NOENTRY /base:\"0x4ad00000\" /implib:\"$(TARGETDIR)\\$(ENTRYPOINT).lib\" /comment:\"%s\"\n", | |
101 | o->comment | |
102 | ); | |
103 | T_FileStream_writeLine(makefile, tmp2); | |
104 | ||
105 | sprintf(tmp2, | |
106 | "GENCCODE = $(ICUROOT)%sbin\\genccode.exe\n", separator); | |
107 | T_FileStream_writeLine(makefile, tmp2); | |
108 | ||
109 | T_FileStream_writeLine(makefile, "\n" | |
110 | "# Windows specific DLL version information.\n" | |
111 | "!IF EXISTS(\".\\$(NAME)_icudata.res\")\n" | |
112 | "DATA_VER_INFO=\".\\$(NAME)_icudata.res\"\n" | |
113 | "!ELSE\n" | |
114 | "DATA_VER_INFO=\n" | |
115 | "!ENDIF\n\n"); | |
116 | ||
117 | ||
118 | uprv_strcpy(tmp, UDATA_CMN_PREFIX "$(NAME)" UDATA_CMN_INTERMEDIATE_SUFFIX OBJ_SUFFIX); | |
119 | ||
120 | sprintf(tmp2, "# intermediate obj file:\nCMNOBJTARGET=%s\n\n", tmp); | |
121 | T_FileStream_writeLine(makefile, tmp2); | |
122 | } | |
123 | else if (isStatic) | |
124 | { | |
125 | uprv_strcpy(tmp, LIB_PREFIX); | |
126 | uprv_strcat(tmp, o->cShortName); | |
127 | uprv_strcat(tmp, UDATA_LIB_SUFFIX); | |
128 | ||
129 | pkg_sttc_writeReadme(o, tmp, status); | |
130 | if(U_FAILURE(*status)) | |
131 | { | |
132 | return; | |
133 | } | |
134 | ||
135 | if(o->nooutput || o->verbose) { | |
136 | fprintf(stdout, "# Output %s file: %s%s%s\n", UDATA_SO_SUFFIX, o->targetDir, U_FILE_SEP_STRING, tmp); | |
137 | } | |
138 | ||
139 | if(o->nooutput) { | |
140 | *status = U_ZERO_ERROR; | |
141 | return; | |
142 | } | |
143 | ||
144 | sprintf(tmp2, "# LIB file to make:\nDLLTARGET=%s\n\n", tmp); | |
145 | T_FileStream_writeLine(makefile, tmp2); | |
146 | ||
147 | sprintf(tmp2, | |
148 | "LINK32 = LIB.exe\n" | |
149 | "LINK32_FLAGS = /nologo /out:\"$(TARGETDIR)\\$(DLLTARGET)\" /EXPORT:\"%s\"\n", | |
150 | o->cShortName | |
151 | ); | |
152 | T_FileStream_writeLine(makefile, tmp2); | |
153 | ||
154 | sprintf(tmp2, | |
155 | "GENCCODE = $(ICUROOT)%sbin\\genccode.exe\n", separator); | |
156 | T_FileStream_writeLine(makefile, tmp2); | |
157 | ||
158 | T_FileStream_writeLine(makefile, "\n" | |
159 | "# Windows specific LIB version information.\n" | |
160 | "!IF EXISTS(\".\\$(NAME)_icudata.res\")\n" | |
161 | "DATA_VER_INFO=\".\\$(NAME)_icudata.res\"\n" | |
162 | "!ELSE\n" | |
163 | "DATA_VER_INFO=\n" | |
164 | "!ENDIF\n\n"); | |
165 | ||
166 | ||
167 | uprv_strcpy(tmp, UDATA_CMN_PREFIX "$(NAME)" UDATA_CMN_INTERMEDIATE_SUFFIX OBJ_SUFFIX); | |
168 | ||
169 | sprintf(tmp2, "# intermediate obj file:\nCMNOBJTARGET=%s\n\n", tmp); | |
170 | T_FileStream_writeLine(makefile, tmp2); | |
171 | } | |
172 | uprv_strcpy(tmp, UDATA_CMN_PREFIX); | |
173 | uprv_strcat(tmp, o->cShortName); | |
174 | uprv_strcat(tmp, UDATA_CMN_SUFFIX); | |
175 | ||
176 | if(o->nooutput || o->verbose) { | |
177 | fprintf(stdout, "# Output file: %s%s%s\n", o->targetDir, U_FILE_SEP_STRING, tmp); | |
178 | } | |
179 | ||
180 | if(o->nooutput) { | |
181 | *status = U_ZERO_ERROR; | |
182 | return; | |
183 | } | |
184 | ||
185 | sprintf(tmp2, "# common file to make:\nCMNTARGET=%s\n\n", tmp); | |
186 | T_FileStream_writeLine(makefile, tmp2); | |
187 | ||
188 | ||
189 | if(isDll || isStatic) { | |
190 | sprintf(tmp, "all: \"$(TARGETDIR)\\$(DLLTARGET)\"\n\n"); | |
191 | T_FileStream_writeLine(makefile, tmp); | |
192 | ||
193 | sprintf(tmp, "\"$(TARGETDIR)\\$(DLLTARGET)\": \"$(TARGETDIR)\\$(CMNOBJTARGET)\"\n" | |
194 | "\t$(LINK32) $(LINK32_FLAGS) \"$(TARGETDIR)\\$(CMNOBJTARGET)\" $(DATA_VER_INFO)\n\n"); | |
195 | T_FileStream_writeLine(makefile, tmp); | |
196 | sprintf(tmp, "\"$(TARGETDIR)\\$(CMNOBJTARGET)\": \"$(TARGETDIR)\\$(CMNTARGET)\"\n" | |
197 | "\t@\"$(GENCCODE)\" $(GENCOPTIONS) -e $(ENTRYPOINT) -o -d \"$(TARGETDIR)\" \"$(TARGETDIR)\\$(CMNTARGET)\"\n\n"); | |
198 | T_FileStream_writeLine(makefile, tmp); | |
199 | ||
200 | sprintf(tmp2, | |
201 | "clean:\n" | |
202 | "\t-@erase \"$(TARGETDIR)\\$(DLLTARGET)\"\n" | |
203 | "\t-@erase \"$(TARGETDIR)\\$(CMNOBJTARGET)\"\n" | |
204 | "\t-@erase \"$(TARGETDIR)\\$(CMNTARGET)\"\n\n"); | |
205 | T_FileStream_writeLine(makefile, tmp2); | |
206 | } else { /* common */ | |
207 | sprintf(tmp, "all: \"$(TARGETDIR)\\$(CMNTARGET)\"\n\n"); | |
208 | T_FileStream_writeLine(makefile, tmp); | |
209 | ||
210 | sprintf(tmp2, | |
211 | "clean:\n" | |
212 | "\t-@erase \"$(TARGETDIR)\\$(CMNTARGET)\"\n\n"); | |
213 | T_FileStream_writeLine(makefile, tmp2); | |
214 | } | |
215 | ||
216 | sprintf(tmp2, "rebuild: clean all\n\n"); | |
217 | T_FileStream_writeLine(makefile, tmp2); | |
218 | ||
219 | /* Write compile rules */ | |
220 | writeCmnRules(o, makefile); | |
221 | } | |
222 | ||
223 | #endif |