]>
Commit | Line | Data |
---|---|---|
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: pkgdata.c | |
8 | * encoding: ANSI X3.4 (1968) | |
9 | * tab size: 8 (not used) | |
10 | * indentation:4 | |
11 | * | |
12 | * created on: 2000may15 | |
13 | * created by: Steven \u24C7 Loomis | |
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" | |
374ca955 A |
22 | #include "unicode/putil.h" |
23 | ||
24 | #ifndef U_MAKE_IS_NMAKE | |
b75a7d8f A |
25 | #include "cmemory.h" |
26 | #include "cstring.h" | |
27 | #include "filestrm.h" | |
28 | #include "toolutil.h" | |
29 | #include "unewdata.h" | |
30 | #include "uoptions.h" | |
31 | #include "pkgtypes.h" | |
32 | #include "makefile.h" | |
33 | ||
34 | ||
35 | void pkg_mode_dll(UPKGOptions *o, FileStream *makefile, UErrorCode *status) | |
36 | { | |
37 | char tmp[1024]; | |
38 | CharList *tail = NULL; | |
39 | CharList *objects = NULL; | |
40 | ||
41 | if(U_FAILURE(*status)) { | |
42 | return; | |
43 | } | |
44 | ||
374ca955 | 45 | uprv_strcpy(tmp, LIB_PREFIX "$(LIBNAME)" UDATA_SO_SUFFIX); |
b75a7d8f A |
46 | |
47 | /* We should be the only item. So we don't care about the order. */ | |
48 | o->outFiles = pkg_appendToList(o->outFiles, &tail, uprv_strdup(tmp)); | |
49 | ||
50 | if(o->nooutput || o->verbose) { | |
51 | fprintf(stdout, "# Output file: %s%s%s\n", o->targetDir, U_FILE_SEP_STRING, tmp); | |
52 | } | |
53 | ||
54 | if(o->nooutput) { | |
55 | *status = U_ZERO_ERROR; | |
56 | return; | |
57 | } | |
58 | ||
59 | /* begin writing makefile ========================= */ | |
60 | ||
61 | ||
62 | /*390port start*/ | |
63 | #ifdef OS390BATCH | |
374ca955 | 64 | if (uprv_strcmp(o->libName, U_LIBICUDATA_NAME) == 0) |
b75a7d8f | 65 | sprintf(tmp, "# File to make:\nBATCH_TARGET=\"//'${LOADMOD}(IXMI" U_ICU_VERSION_SHORT "DA)'\"\n\n"); |
374ca955 | 66 | else if (uprv_strcmp(o->libName, "testdata") == 0) |
b75a7d8f | 67 | sprintf(tmp, "# File to make:\nBATCH_TARGET=\"//'${LOADMOD}(IXMI" U_ICU_VERSION_SHORT "TE)'\"\n\n"); |
374ca955 | 68 | else if (uprv_strcmp(o->libName, U_LIBICUDATA_NAME"_stub") == 0) |
b75a7d8f | 69 | sprintf(tmp, "# File to make:\nBATCH_TARGET=\"//'${LOADMOD}(IXMI" U_ICU_VERSION_SHORT "D1)'\"\n\n"); |
73c04bcf A |
70 | else |
71 | sprintf(tmp, "\n"); | |
b75a7d8f A |
72 | T_FileStream_writeLine(makefile, tmp); |
73 | #endif | |
74 | ||
75 | T_FileStream_writeLine(makefile, "# Version numbers:\nVERSIONED="); | |
76 | if (o->version) { | |
77 | sprintf(tmp, ".%s", o->version); | |
78 | if (!uprv_strchr(o->version, '.')) { | |
79 | uprv_strcat(tmp, ".0"); | |
80 | } | |
81 | T_FileStream_writeLine(makefile, tmp); | |
82 | T_FileStream_writeLine(makefile, "\nDLL_LDFLAGS=$(LD_SONAME) $(RPATH_LDFLAGS) $(BIR_LDFLAGS)\nDLL_DEPS=$(BIR_DEPS)\n"); | |
83 | } else { | |
84 | T_FileStream_writeLine(makefile, "\nDLL_LDFLAGS=$(BIR_LDFLAGS)\nDLL_DEPS=$(BIR_DEPS)\n"); | |
85 | } | |
86 | T_FileStream_writeLine(makefile, "\n"); | |
87 | ||
88 | sprintf(tmp, "# File to make:\nTARGET=%s\n\n", o->outFiles->str); | |
89 | T_FileStream_writeLine(makefile, tmp); | |
90 | if (o->version) { | |
91 | char *p; | |
92 | const char *v; | |
93 | ||
94 | T_FileStream_writeLine(makefile, "SO_TARGET=$(TARGET)\n"); | |
95 | sprintf(tmp, "SO_TARGET_VERSION=%s\n", o->version); | |
96 | T_FileStream_writeLine(makefile, tmp); | |
97 | uprv_strcpy(tmp, "SO_TARGET_VERSION_MAJOR="); | |
98 | for (p = tmp + uprv_strlen(tmp), v = o->version; *v && *v != '.'; ++v) { | |
99 | *p++ = *v; | |
100 | } | |
101 | *p++ = '\n'; | |
102 | *p++ = '\n'; | |
103 | *p++ = 0; | |
104 | T_FileStream_writeLine(makefile, tmp); | |
105 | } else { | |
106 | T_FileStream_writeLine(makefile, "FINAL_SO_TARGET=$(TARGET)\n"); | |
107 | T_FileStream_writeLine(makefile, "MIDDLE_SO_TARGET=$(TARGET)\n"); | |
108 | } | |
374ca955 A |
109 | |
110 | T_FileStream_writeLine(makefile, "DYNAMICCPPFLAGS=$(SHAREDLIBCPPFLAGS)\n"); | |
111 | T_FileStream_writeLine(makefile, "DYNAMICCFLAGS=$(SHAREDLIBCFLAGS)\n"); | |
112 | T_FileStream_writeLine(makefile, "DYNAMICCXXFLAGS=$(SHAREDLIBCXXFLAGS)\n"); | |
113 | T_FileStream_writeLine(makefile, "\n"); | |
b75a7d8f | 114 | |
374ca955 A |
115 | #ifdef OS400 |
116 | sprintf(tmp, "# Force override for iSeries compilation since data does not need to be\n" | |
117 | "# nor can excessively large files be compiled for debug\n" | |
118 | "override COMPILE.c= $(CC) $(DEFS) $(CPPFLAGS) -O4 -c -qTERASPACE=*YES -qSTGMDL=*INHERIT -qPFROPT=*STRDONLY\n\n"); | |
119 | T_FileStream_writeLine(makefile, tmp); | |
120 | #endif | |
121 | ||
b75a7d8f A |
122 | uprv_strcpy(tmp, "all: $(TARGETDIR)/$(FINAL_SO_TARGET) $(BATCH_TARGET)"); |
123 | if (o->version) { | |
124 | uprv_strcat(tmp, " $(TARGETDIR)/$(MIDDLE_SO_TARGET) $(TARGETDIR)/$(SO_TARGET)"); | |
125 | } | |
126 | uprv_strcat(tmp, "\n\n"); | |
127 | T_FileStream_writeLine(makefile, tmp); | |
128 | ||
374ca955 A |
129 | #ifdef OS400 |
130 | /* New for iSeries: All packaged data in one .c */ | |
131 | sprintf(tmp, "# Create a file which contains all .c data files/structures\n" | |
132 | "$(TEMP_DIR)/$(NAME)all.c: $(CMNLIST)\n\n"); | |
133 | T_FileStream_writeLine(makefile, tmp); | |
134 | #endif | |
135 | ||
b75a7d8f A |
136 | /* Write compile rules */ |
137 | pkg_mak_writeObjRules(o, makefile, &objects, OBJ_SUFFIX); | |
138 | ||
139 | sprintf(tmp, "# List file for gencmn:\n" | |
140 | "CMNLIST=%s%s$(NAME)_dll.lst\n\n", | |
141 | o->tmpDir, | |
142 | U_FILE_SEP_STRING); | |
143 | T_FileStream_writeLine(makefile, tmp); | |
144 | ||
145 | if(o->hadStdin == FALSE) { /* shortcut */ | |
146 | T_FileStream_writeLine(makefile, "$(CMNLIST): $(LISTFILES)\n" | |
147 | "\tcat $(LISTFILES) > $(CMNLIST)\n\n"); | |
148 | } else { | |
149 | T_FileStream_writeLine(makefile, "$(CMNLIST): \n" | |
150 | "\t@echo \"generating $@ (list of data files)\"\n" | |
151 | "\t@-$(RMV) $@\n" | |
152 | "\t@for file in $(DATAFILEPATHS); do \\\n" | |
153 | "\t echo $$file >> $@; \\\n" | |
154 | "\tdone;\n\n"); | |
155 | } | |
73c04bcf A |
156 | |
157 | sprintf(tmp, "TOCSYM= %s_dat \n\n", o->entryName); /* entrypoint not always shortname! */ | |
158 | T_FileStream_writeLine(makefile, tmp); | |
159 | ||
374ca955 A |
160 | pkg_mak_writeAssemblyHeader(makefile, o); |
161 | ||
b75a7d8f | 162 | sprintf(tmp,"$(TEMP_DIR)/$(NAME)_dat.o : $(TEMP_DIR)/$(NAME)_dat.c\n" |
374ca955 | 163 | "\t$(COMPILE.c) $(DYNAMICCPPFLAGS) $(DYNAMICCXXFLAGS) -o $@ $<\n\n"); |
b75a7d8f A |
164 | T_FileStream_writeLine(makefile, tmp); |
165 | ||
166 | T_FileStream_writeLine(makefile, "# 'TOCOBJ' contains C Table of Contents objects [if any]\n"); | |
167 | ||
73c04bcf | 168 | sprintf(tmp, "$(TEMP_DIR)/$(NAME)_dat.c: $(CMNLIST)\n" |
374ca955 | 169 | "\t$(INVOKE) $(GENCMN) -e $(ENTRYPOINT) -n $(NAME) -S -s $(SRCDIR) -d $(TEMP_DIR) 0 $(CMNLIST)\n\n"); |
374ca955 | 170 | |
b75a7d8f A |
171 | T_FileStream_writeLine(makefile, tmp); |
172 | sprintf(tmp, "TOCOBJ= $(NAME)_dat%s \n\n", OBJ_SUFFIX); | |
173 | T_FileStream_writeLine(makefile, tmp); | |
374ca955 A |
174 | |
175 | #ifdef OS400 | |
176 | /* New for iSeries: All packaged data in one .c */ | |
177 | sprintf(tmp, "$(TEMP_DIR)/$(NAME)all.o : $(TEMP_DIR)/$(NAME)all.c\n" | |
178 | "\t$(COMPILE.c) $(DYNAMICCPPFLAGS) $(DYNAMICCXXFLAGS) -o $@ $<\n\n"); | |
179 | T_FileStream_writeLine(makefile, tmp); | |
180 | ||
181 | T_FileStream_writeLine(makefile, "# 'ALLDATAOBJ' contains all .c data structures\n"); | |
182 | ||
183 | sprintf(tmp, "ALLDATAOBJ= $(NAME)all%s \n\n", OBJ_SUFFIX); | |
184 | T_FileStream_writeLine(makefile, tmp); | |
185 | #endif | |
186 | ||
b75a7d8f | 187 | T_FileStream_writeLine(makefile, "BASE_OBJECTS= $(TOCOBJ) "); |
374ca955 A |
188 | #ifdef OS400 |
189 | T_FileStream_writeLine(makefile, "$(ALLDATAOBJ) "); | |
190 | #else | |
b75a7d8f | 191 | pkg_writeCharListWrap(makefile, objects, " ", " \\\n",0); |
374ca955 A |
192 | #endif |
193 | pkg_mak_writeAssemblyFooter(makefile, o); | |
194 | ||
b75a7d8f A |
195 | T_FileStream_writeLine(makefile, "\n\n"); |
196 | T_FileStream_writeLine(makefile, "OBJECTS=$(BASE_OBJECTS:%=$(TEMP_DIR)/%)\n\n"); | |
197 | ||
374ca955 | 198 | T_FileStream_writeLine(makefile,"$(TEMP_DIR)/%.o: $(TEMP_DIR)/%.c\n\t$(COMPILE.c) $(DYNAMICCPPFLAGS) $(DYNAMICCXXFLAGS) -o $@ $<\n\n"); |
b75a7d8f A |
199 | |
200 | T_FileStream_writeLine(makefile,"build-objs: $(SOURCES) $(OBJECTS)\n\n$(OBJECTS): $(SOURCES)\n\n"); | |
201 | ||
374ca955 | 202 | #ifdef U_HPUX |
b75a7d8f A |
203 | T_FileStream_writeLine(makefile, "$(TARGETDIR)/$(FINAL_SO_TARGET): $(OBJECTS) $(HPUX_JUNK_OBJ) $(LISTFILES) $(DLL_DEPS)\n" |
204 | "\t$(SHLIB.cc) -o $@ $(OBJECTS) $(HPUX_JUNK_OBJ) $(DLL_LDFLAGS)\n" | |
205 | "\t-ls -l $@\n\n"); | |
206 | ||
207 | T_FileStream_writeLine(makefile, "$(TEMP_DIR)/hpux_junk_obj.cpp:\n" | |
208 | "\techo \"void to_emit_cxx_stuff_in_the_linker(){}\" >> $(TEMP_DIR)/hpux_junk_obj.cpp\n" | |
209 | "\n" | |
210 | "$(TEMP_DIR)/hpux_junk_obj.o: $(TEMP_DIR)/hpux_junk_obj.cpp\n" | |
374ca955 | 211 | "\t$(COMPILE.cc) $(DYNAMICCPPFLAGS) $(DYNAMICCXXFLAGS) -o $@ $<\n" |
b75a7d8f A |
212 | "\n"); |
213 | #else | |
214 | ||
215 | /*390port*/ | |
216 | #ifdef OS390BATCH | |
217 | T_FileStream_writeLine(makefile, "$(BATCH_TARGET): $(OBJECTS) $(LISTFILES) $(DLL_DEPS)\n" | |
218 | "\t$(SHLIB.c) -o $@ $(OBJECTS) $(DLL_LDFLAGS)\n\n"); | |
219 | #endif | |
220 | ||
73c04bcf A |
221 | #ifdef U_AIX |
222 | T_FileStream_writeLine(makefile, "$(TARGETDIR)/$(FINAL_SO_TARGET): $(OBJECTS) $(LISTFILES) $(DLL_DEPS)\n" | |
223 | "\t$(SHLIB.c) -o $(FINAL_SO_TARGET:.$(SO)=.$(SOBJ)) $(OBJECTS) $(DLL_LDFLAGS)\n" | |
224 | "\t$(AR) $(ARFLAGS) $@ $(FINAL_SO_TARGET:.$(SO)=.$(SOBJ))\n" | |
225 | "\t-$(AR) vt $@\n\n"); | |
226 | #else | |
b75a7d8f A |
227 | T_FileStream_writeLine(makefile, "$(TARGETDIR)/$(FINAL_SO_TARGET): $(OBJECTS) $(LISTFILES) $(DLL_DEPS)\n" |
228 | "\t$(SHLIB.c) -o $@ $(OBJECTS) $(DLL_LDFLAGS)\n" | |
229 | "\t-ls -l $@\n\n"); | |
73c04bcf | 230 | #endif |
b75a7d8f A |
231 | |
232 | #ifdef OS390 | |
233 | /* | |
234 | jdc26: The above link resolves to | |
235 | ||
236 | -o ../data/out/libicudata26.0.dll | |
237 | ||
238 | the first time or | |
239 | ||
240 | -o ../data/out/libicudata_stub26.0.dll | |
241 | ||
242 | the second time in the build. OS/390 puts each DLL into | |
243 | the specified directory and the sidedeck into the current | |
244 | directory. Move the sidedeck into the same directory as | |
245 | the DLL so it can be found with the DLL later in the | |
246 | build. | |
247 | ||
248 | */ | |
249 | T_FileStream_writeLine(makefile, "\t-cp -f ./$(basename $(FINAL_SO_TARGET))$(IMPORT_LIB_EXT) $(TARGETDIR)/$(basename $(FINAL_SO_TARGET))$(IMPORT_LIB_EXT)\n"); | |
250 | #endif /* OS/390 */ | |
251 | #endif | |
252 | ||
253 | T_FileStream_writeLine(makefile, "CLEANFILES= $(CMNLIST) $(OBJECTS) $(HPUX_JUNK_OBJ) $(TARGETDIR)/$(FINAL_SO_TARGET) $(TARGETDIR)/$(MIDDLE_SO_TARGET) $(TARGETDIR)/$(TARGET)\n\nclean:\n\t-$(RMV) $(CLEANFILES) $(MAKEFILE)"); | |
254 | T_FileStream_writeLine(makefile, "\n\n"); | |
255 | ||
256 | T_FileStream_writeLine(makefile, "install: $(TARGETDIR)/$(FINAL_SO_TARGET)\n" | |
257 | "\t$(INSTALL-L) $(TARGETDIR)/$(FINAL_SO_TARGET) $(INSTALLTO)/$(FINAL_SO_TARGET)\n"); | |
258 | ||
259 | T_FileStream_writeLine(makefile, "ifneq ($(IMPORT_LIB_EXT),)\n"); | |
260 | T_FileStream_writeLine(makefile, "\t$(INSTALL-L) $(TARGETDIR)/$(basename $(FINAL_SO_TARGET))$(IMPORT_LIB_EXT) $(INSTALLTO)/$(basename( $(FINAL_SO_TARGET))$(IMPORT_LIB_EXT)\n"); | |
261 | T_FileStream_writeLine(makefile, "endif\n"); | |
262 | if (o->version) { | |
263 | T_FileStream_writeLine(makefile, "ifneq ($(FINAL_SO_TARGET),$(SO_TARGET))\n"); | |
264 | T_FileStream_writeLine(makefile, "\tcd $(INSTALLTO) && $(RM) $(SO_TARGET) && ln -s $(FINAL_SO_TARGET) $(SO_TARGET)\n"); | |
265 | T_FileStream_writeLine(makefile, "ifneq ($(FINAL_SO_TARGET),$(MIDDLE_SO_TARGET))\n"); | |
266 | T_FileStream_writeLine(makefile, "\tcd $(INSTALLTO) && $(RM) $(MIDDLE_SO_TARGET) && ln -s $(FINAL_SO_TARGET) $(MIDDLE_SO_TARGET)\n"); | |
267 | T_FileStream_writeLine(makefile, "endif\n"); | |
268 | T_FileStream_writeLine(makefile, "endif\n"); | |
269 | ||
270 | #ifdef OS390 | |
271 | T_FileStream_writeLine(makefile, "ifneq ($(IMPORT_LIB_EXT),)\n"); | |
272 | T_FileStream_writeLine(makefile, "\tcd $(INSTALLTO) && $(RM) $(basename $(MIDDLE_SO_TARGET))$(IMPORT_LIB_EXT) && ln -s $(basename $(FINAL_SO_TARGET))$(IMPORT_LIB_EXT) $(basename $(MIDDLE_SO_TARGET))$(IMPORT_LIB_EXT)\n"); | |
273 | T_FileStream_writeLine(makefile, "\tcd $(INSTALLTO) && $(RM) $(basename $(SO_TARGET))$(IMPORT_LIB_EXT) && ln -s $(basename $(FINAL_SO_TARGET))$(IMPORT_LIB_EXT) $(basename $(SO_TARGET))$(IMPORT_LIB_EXT)\n"); | |
274 | T_FileStream_writeLine(makefile, "endif\n"); | |
275 | #endif | |
276 | } | |
277 | T_FileStream_writeLine(makefile, "\n"); | |
278 | ||
279 | #ifdef U_SOLARIS | |
280 | T_FileStream_writeLine(makefile, "$(NAME).map:\n\techo \"{global: $(TOCSYM); local: *; };\" > $@\n\n"); | |
281 | #endif | |
282 | ||
374ca955 | 283 | #ifdef U_AIX |
b75a7d8f A |
284 | T_FileStream_writeLine(makefile, "$(NAME).map:\n\techo \"$(TOCSYM)\" > $@\n\n"); |
285 | #endif | |
286 | ||
287 | ||
288 | *status = U_ZERO_ERROR; | |
289 | ||
290 | } | |
291 | ||
374ca955 | 292 | #endif /* #ifndef U_MAKE_IS_NMAKE */ |
b75a7d8f | 293 |