]> git.saurik.com Git - apple/icu.git/blame - icuSources/tools/pkgdata/winmode.c
ICU-8.11.1.tar.gz
[apple/icu.git] / icuSources / tools / pkgdata / winmode.c
CommitLineData
b75a7d8f
A
1/******************************************************************************
2*
73c04bcf 3* Copyright (C) 2000-2006, 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
38void writeCmnRules(UPKGOptions *o, FileStream *makefile)
39{
40 char tmp[1024];
41 CharList *infiles;
42
73c04bcf 43 infiles = o->files;
374ca955 44 sprintf(tmp, "\"$(TARGETDIR)\\$(CMNTARGET)\" : $(DATAFILEPATHS)\n"
73c04bcf 45 "\t%s\"$(GENCMN)\" %s%s%s-d \"$(TARGETDIR)\" -s \"$(SRCDIR)\" -n \"$(NAME)\" 0 <<\n",
374ca955
A
46 (o->verbose ? "" : "@"),
47 (o->comment ? "-C \"" : ""),
48 (o->comment ? o->comment : ""),
73c04bcf 49 (o->comment ? "\" " : ""));
b75a7d8f
A
50 T_FileStream_writeLine(makefile, tmp);
51
52 pkg_writeCharList(makefile, infiles, "\n", -1);
53/*
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);
57 } else {
58 sprintf(tmp, "%s\n", infiles->str);
59 }
60 T_FileStream_writeLine(makefile, tmp);
61 }
62*/
63 sprintf(tmp, "\n<<\n");
64 T_FileStream_writeLine(makefile, tmp);
65}
66
67
68
69void pkg_mode_windows(UPKGOptions *o, FileStream *makefile, UErrorCode *status) {
70 char tmp[1024];
71 char tmp2[1024];
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);
75
76 if(U_FAILURE(*status)) {
77 return;
78 }
79
80 sprintf(tmp2, "ICUROOT=%s\n\n", o->icuroot);
81 T_FileStream_writeLine(makefile, tmp2);
82
374ca955
A
83 if (CONTAINS_REAL_PATH(o)) {
84 sprintf(tmp2,
85 "GENCMN = $(ICUROOT)%sgencmn.exe\n", separator);
86 }
87 else {
88 sprintf(tmp2,
89 "GENCMN = $(ICUROOT)%sbin\\gencmn.exe\n", separator);
90 }
b75a7d8f
A
91 T_FileStream_writeLine(makefile, tmp2);
92
93 if(isDll) {
94 uprv_strcpy(tmp, LIB_PREFIX);
374ca955
A
95 uprv_strcat(tmp, o->libName);
96 if (o->version) {
97 uprv_strcat(tmp, "$(TARGET_VERSION)");
98 }
b75a7d8f
A
99 uprv_strcat(tmp, UDATA_SO_SUFFIX);
100
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);
103 }
104
105 if(o->nooutput) {
106 *status = U_ZERO_ERROR;
107 return;
108 }
109
110 sprintf(tmp2, "# DLL file to make:\nDLLTARGET=%s\n\n", tmp);
111 T_FileStream_writeLine(makefile, tmp2);
112
113 sprintf(tmp2,
114 "LINK32 = link.exe\n"
73c04bcf 115 "LINK32_FLAGS = /nologo /out:\"$(TARGETDIR)\\$(DLLTARGET)\" /DLL /NOENTRY $(LDFLAGS) $(PKGDATA_LDFLAGS) /implib:\"$(TARGETDIR)\\$(LIBNAME).lib\" %s%s%s\n",
374ca955
A
116 (o->comment ? "/comment:\"" : ""),
117 (o->comment ? o->comment : ""),
118 (o->comment ? "\"" : ""),
b75a7d8f
A
119 o->comment
120 );
121 T_FileStream_writeLine(makefile, tmp2);
122
374ca955
A
123 if (CONTAINS_REAL_PATH(o)) {
124 sprintf(tmp2,
125 "GENCCODE = $(ICUROOT)%sgenccode.exe\n", separator);
126 }
127 else {
128 sprintf(tmp2,
129 "GENCCODE = $(ICUROOT)%sbin\\genccode.exe\n", separator);
130 }
b75a7d8f
A
131 T_FileStream_writeLine(makefile, tmp2);
132
374ca955 133 /* If you modify this, remember to modify makedata.mak too. */
b75a7d8f
A
134 T_FileStream_writeLine(makefile, "\n"
135 "# Windows specific DLL version information.\n"
374ca955
A
136 "!IF EXISTS(\"$(TEMP_DIR)\\icudata.res\")\n"
137 "DATA_VER_INFO=\"$(TEMP_DIR)\\icudata.res\"\n"
b75a7d8f
A
138 "!ELSE\n"
139 "DATA_VER_INFO=\n"
140 "!ENDIF\n\n");
141
142
143 uprv_strcpy(tmp, UDATA_CMN_PREFIX "$(NAME)" UDATA_CMN_INTERMEDIATE_SUFFIX OBJ_SUFFIX);
144
145 sprintf(tmp2, "# intermediate obj file:\nCMNOBJTARGET=%s\n\n", tmp);
146 T_FileStream_writeLine(makefile, tmp2);
147 }
148 else if (isStatic)
149 {
150 uprv_strcpy(tmp, LIB_PREFIX);
374ca955 151 uprv_strcat(tmp, o->libName);
b75a7d8f
A
152 uprv_strcat(tmp, UDATA_LIB_SUFFIX);
153
374ca955
A
154 if (!o->quiet) {
155 pkg_sttc_writeReadme(o, tmp, status);
156 }
b75a7d8f
A
157 if(U_FAILURE(*status))
158 {
159 return;
160 }
161
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);
164 }
165
166 if(o->nooutput) {
167 *status = U_ZERO_ERROR;
168 return;
169 }
170
171 sprintf(tmp2, "# LIB file to make:\nDLLTARGET=%s\n\n", tmp);
172 T_FileStream_writeLine(makefile, tmp2);
173
174 sprintf(tmp2,
175 "LINK32 = LIB.exe\n"
176 "LINK32_FLAGS = /nologo /out:\"$(TARGETDIR)\\$(DLLTARGET)\" /EXPORT:\"%s\"\n",
374ca955 177 o->libName
b75a7d8f
A
178 );
179 T_FileStream_writeLine(makefile, tmp2);
180
b75a7d8f 181
374ca955
A
182 if (CONTAINS_REAL_PATH(o)) {
183 sprintf(tmp2,
184 "GENCCODE = $(ICUROOT)%sgenccode.exe\n", separator);
185 }
186 else {
187 sprintf(tmp2,
188 "GENCCODE = $(ICUROOT)%sbin\\genccode.exe\n", separator);
189 }
190 T_FileStream_writeLine(makefile, tmp2);
b75a7d8f
A
191
192 uprv_strcpy(tmp, UDATA_CMN_PREFIX "$(NAME)" UDATA_CMN_INTERMEDIATE_SUFFIX OBJ_SUFFIX);
193
374ca955 194 sprintf(tmp2, "# intermediate obj file\nCMNOBJTARGET=%s\n\n", tmp);
b75a7d8f
A
195 T_FileStream_writeLine(makefile, tmp2);
196 }
197 uprv_strcpy(tmp, UDATA_CMN_PREFIX);
198 uprv_strcat(tmp, o->cShortName);
374ca955
A
199 if (o->version && !uprv_strstr(o->shortName,o->version)) {
200 uprv_strcat(tmp, "$(TARGET_VERSION)");
201 }
b75a7d8f
A
202 uprv_strcat(tmp, UDATA_CMN_SUFFIX);
203
204 if(o->nooutput || o->verbose) {
205 fprintf(stdout, "# Output file: %s%s%s\n", o->targetDir, U_FILE_SEP_STRING, tmp);
206 }
207
208 if(o->nooutput) {
209 *status = U_ZERO_ERROR;
210 return;
211 }
212
213 sprintf(tmp2, "# common file to make:\nCMNTARGET=%s\n\n", tmp);
214 T_FileStream_writeLine(makefile, tmp2);
215
216
217 if(isDll || isStatic) {
218 sprintf(tmp, "all: \"$(TARGETDIR)\\$(DLLTARGET)\"\n\n");
219 T_FileStream_writeLine(makefile, tmp);
220
374ca955
A
221 sprintf(tmp, "\"$(TARGETDIR)\\$(DLLTARGET)\": \"$(TEMP_DIR)\\$(CMNOBJTARGET)\"\n"
222 "\t$(LINK32) $(LINK32_FLAGS) \"$(TEMP_DIR)\\$(CMNOBJTARGET)\" $(DATA_VER_INFO)\n\n");
b75a7d8f 223 T_FileStream_writeLine(makefile, tmp);
374ca955
A
224 sprintf(tmp, "\"$(TEMP_DIR)\\$(CMNOBJTARGET)\": \"$(TARGETDIR)\\$(CMNTARGET)\"\n"
225 "\t@\"$(GENCCODE)\" $(GENCOPTIONS) -e $(ENTRYPOINT) -o -d \"$(TEMP_DIR)\" \"$(TARGETDIR)\\$(CMNTARGET)\"\n\n");
b75a7d8f
A
226 T_FileStream_writeLine(makefile, tmp);
227
228 sprintf(tmp2,
229 "clean:\n"
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);
374ca955
A
234
235 T_FileStream_writeLine(makefile, "install: \"$(TARGETDIR)\\$(DLLTARGET)\"\n"
236 "\tcopy \"$(TARGETDIR)\\$(DLLTARGET)\" \"$(INSTALLTO)\\$(DLLTARGET)\"\n\n");
b75a7d8f
A
237 } else { /* common */
238 sprintf(tmp, "all: \"$(TARGETDIR)\\$(CMNTARGET)\"\n\n");
239 T_FileStream_writeLine(makefile, tmp);
240
241 sprintf(tmp2,
242 "clean:\n"
243 "\t-@erase \"$(TARGETDIR)\\$(CMNTARGET)\"\n\n");
244 T_FileStream_writeLine(makefile, tmp2);
374ca955
A
245
246 T_FileStream_writeLine(makefile, "install: \"$(TARGETDIR)\\$(CMNTARGET)\"\n"
247 "\tcopy \"$(TARGETDIR)\\$(CMNTARGET)\" \"$(INSTALLTO)\\$(CMNTARGET)\"\n\n");
b75a7d8f
A
248 }
249
374ca955 250 T_FileStream_writeLine(makefile, "rebuild: clean all\n\n");
b75a7d8f
A
251
252 /* Write compile rules */
253 writeCmnRules(o, makefile);
254}
255
256#endif