]>
Commit | Line | Data |
---|---|---|
1 | /****************************************************************************** | |
2 | * | |
3 | * Copyright (C) 2000-2004, International Business Machines | |
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" | |
22 | #include "unicode/putil.h" | |
23 | ||
24 | #ifndef U_MAKE_IS_NMAKE | |
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 | ||
45 | uprv_strcpy(tmp, LIB_PREFIX "$(LIBNAME)" UDATA_SO_SUFFIX); | |
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 | |
64 | if (uprv_strcmp(o->libName, U_LIBICUDATA_NAME) == 0) | |
65 | sprintf(tmp, "# File to make:\nBATCH_TARGET=\"//'${LOADMOD}(IXMI" U_ICU_VERSION_SHORT "DA)'\"\n\n"); | |
66 | else if (uprv_strcmp(o->libName, "testdata") == 0) | |
67 | sprintf(tmp, "# File to make:\nBATCH_TARGET=\"//'${LOADMOD}(IXMI" U_ICU_VERSION_SHORT "TE)'\"\n\n"); | |
68 | else if (uprv_strcmp(o->libName, U_LIBICUDATA_NAME"_stub") == 0) | |
69 | sprintf(tmp, "# File to make:\nBATCH_TARGET=\"//'${LOADMOD}(IXMI" U_ICU_VERSION_SHORT "D1)'\"\n\n"); | |
70 | T_FileStream_writeLine(makefile, tmp); | |
71 | #endif | |
72 | ||
73 | T_FileStream_writeLine(makefile, "# Version numbers:\nVERSIONED="); | |
74 | if (o->version) { | |
75 | sprintf(tmp, ".%s", o->version); | |
76 | if (!uprv_strchr(o->version, '.')) { | |
77 | uprv_strcat(tmp, ".0"); | |
78 | } | |
79 | T_FileStream_writeLine(makefile, tmp); | |
80 | T_FileStream_writeLine(makefile, "\nDLL_LDFLAGS=$(LD_SONAME) $(RPATH_LDFLAGS) $(BIR_LDFLAGS)\nDLL_DEPS=$(BIR_DEPS)\n"); | |
81 | } else { | |
82 | T_FileStream_writeLine(makefile, "\nDLL_LDFLAGS=$(BIR_LDFLAGS)\nDLL_DEPS=$(BIR_DEPS)\n"); | |
83 | } | |
84 | T_FileStream_writeLine(makefile, "\n"); | |
85 | ||
86 | sprintf(tmp, "# File to make:\nTARGET=%s\n\n", o->outFiles->str); | |
87 | T_FileStream_writeLine(makefile, tmp); | |
88 | if (o->version) { | |
89 | char *p; | |
90 | const char *v; | |
91 | ||
92 | T_FileStream_writeLine(makefile, "SO_TARGET=$(TARGET)\n"); | |
93 | sprintf(tmp, "SO_TARGET_VERSION=%s\n", o->version); | |
94 | T_FileStream_writeLine(makefile, tmp); | |
95 | uprv_strcpy(tmp, "SO_TARGET_VERSION_MAJOR="); | |
96 | for (p = tmp + uprv_strlen(tmp), v = o->version; *v && *v != '.'; ++v) { | |
97 | *p++ = *v; | |
98 | } | |
99 | *p++ = '\n'; | |
100 | *p++ = '\n'; | |
101 | *p++ = 0; | |
102 | T_FileStream_writeLine(makefile, tmp); | |
103 | } else { | |
104 | T_FileStream_writeLine(makefile, "FINAL_SO_TARGET=$(TARGET)\n"); | |
105 | T_FileStream_writeLine(makefile, "MIDDLE_SO_TARGET=$(TARGET)\n"); | |
106 | } | |
107 | ||
108 | T_FileStream_writeLine(makefile, "DYNAMICCPPFLAGS=$(SHAREDLIBCPPFLAGS)\n"); | |
109 | T_FileStream_writeLine(makefile, "DYNAMICCFLAGS=$(SHAREDLIBCFLAGS)\n"); | |
110 | T_FileStream_writeLine(makefile, "DYNAMICCXXFLAGS=$(SHAREDLIBCXXFLAGS)\n"); | |
111 | T_FileStream_writeLine(makefile, "\n"); | |
112 | ||
113 | #ifdef OS400 | |
114 | sprintf(tmp, "# Force override for iSeries compilation since data does not need to be\n" | |
115 | "# nor can excessively large files be compiled for debug\n" | |
116 | "override COMPILE.c= $(CC) $(DEFS) $(CPPFLAGS) -O4 -c -qTERASPACE=*YES -qSTGMDL=*INHERIT -qPFROPT=*STRDONLY\n\n"); | |
117 | T_FileStream_writeLine(makefile, tmp); | |
118 | #endif | |
119 | ||
120 | uprv_strcpy(tmp, "all: $(TARGETDIR)/$(FINAL_SO_TARGET) $(BATCH_TARGET)"); | |
121 | if (o->version) { | |
122 | uprv_strcat(tmp, " $(TARGETDIR)/$(MIDDLE_SO_TARGET) $(TARGETDIR)/$(SO_TARGET)"); | |
123 | } | |
124 | uprv_strcat(tmp, "\n\n"); | |
125 | T_FileStream_writeLine(makefile, tmp); | |
126 | ||
127 | #ifdef OS400 | |
128 | /* New for iSeries: All packaged data in one .c */ | |
129 | sprintf(tmp, "# Create a file which contains all .c data files/structures\n" | |
130 | "$(TEMP_DIR)/$(NAME)all.c: $(CMNLIST)\n\n"); | |
131 | T_FileStream_writeLine(makefile, tmp); | |
132 | #endif | |
133 | ||
134 | /* Write compile rules */ | |
135 | pkg_mak_writeObjRules(o, makefile, &objects, OBJ_SUFFIX); | |
136 | ||
137 | sprintf(tmp, "# List file for gencmn:\n" | |
138 | "CMNLIST=%s%s$(NAME)_dll.lst\n\n", | |
139 | o->tmpDir, | |
140 | U_FILE_SEP_STRING); | |
141 | T_FileStream_writeLine(makefile, tmp); | |
142 | ||
143 | if(o->hadStdin == FALSE) { /* shortcut */ | |
144 | T_FileStream_writeLine(makefile, "$(CMNLIST): $(LISTFILES)\n" | |
145 | "\tcat $(LISTFILES) > $(CMNLIST)\n\n"); | |
146 | } else { | |
147 | T_FileStream_writeLine(makefile, "$(CMNLIST): \n" | |
148 | "\t@echo \"generating $@ (list of data files)\"\n" | |
149 | "\t@-$(RMV) $@\n" | |
150 | "\t@for file in $(DATAFILEPATHS); do \\\n" | |
151 | "\t echo $$file >> $@; \\\n" | |
152 | "\tdone;\n\n"); | |
153 | } | |
154 | ||
155 | pkg_mak_writeAssemblyHeader(makefile, o); | |
156 | ||
157 | sprintf(tmp,"$(TEMP_DIR)/$(NAME)_dat.o : $(TEMP_DIR)/$(NAME)_dat.c\n" | |
158 | "\t$(COMPILE.c) $(DYNAMICCPPFLAGS) $(DYNAMICCXXFLAGS) -o $@ $<\n\n"); | |
159 | T_FileStream_writeLine(makefile, tmp); | |
160 | ||
161 | T_FileStream_writeLine(makefile, "# 'TOCOBJ' contains C Table of Contents objects [if any]\n"); | |
162 | ||
163 | if(!o->embed) { | |
164 | sprintf(tmp, "$(TEMP_DIR)/$(NAME)_dat.c: $(CMNLIST)\n" | |
165 | "\t$(INVOKE) $(GENCMN) -e $(ENTRYPOINT) -n $(NAME) -S -s $(SRCDIR) -d $(TEMP_DIR) 0 $(CMNLIST)\n\n"); | |
166 | } else { | |
167 | sprintf(tmp, "$(TEMP_DIR)/$(NAME)_dat.c: $(CMNLIST)\n" | |
168 | "\t$(INVOKE) $(GENCMN) -e $(ENTRYPOINT) -n $(NAME) -S -E -d $(TEMP_DIR) 0 $(CMNLIST)\n\n"); | |
169 | } | |
170 | ||
171 | T_FileStream_writeLine(makefile, tmp); | |
172 | sprintf(tmp, "TOCOBJ= $(NAME)_dat%s \n\n", OBJ_SUFFIX); | |
173 | T_FileStream_writeLine(makefile, tmp); | |
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 | ||
187 | sprintf(tmp, "TOCSYM= %s_dat \n\n", o->entryName); /* entrypoint not always shortname! */ | |
188 | T_FileStream_writeLine(makefile, tmp); | |
189 | ||
190 | T_FileStream_writeLine(makefile, "BASE_OBJECTS= $(TOCOBJ) "); | |
191 | #ifdef OS400 | |
192 | T_FileStream_writeLine(makefile, "$(ALLDATAOBJ) "); | |
193 | #else | |
194 | pkg_writeCharListWrap(makefile, objects, " ", " \\\n",0); | |
195 | #endif | |
196 | pkg_mak_writeAssemblyFooter(makefile, o); | |
197 | ||
198 | T_FileStream_writeLine(makefile, "\n\n"); | |
199 | T_FileStream_writeLine(makefile, "OBJECTS=$(BASE_OBJECTS:%=$(TEMP_DIR)/%)\n\n"); | |
200 | ||
201 | T_FileStream_writeLine(makefile,"$(TEMP_DIR)/%.o: $(TEMP_DIR)/%.c\n\t$(COMPILE.c) $(DYNAMICCPPFLAGS) $(DYNAMICCXXFLAGS) -o $@ $<\n\n"); | |
202 | ||
203 | T_FileStream_writeLine(makefile,"build-objs: $(SOURCES) $(OBJECTS)\n\n$(OBJECTS): $(SOURCES)\n\n"); | |
204 | ||
205 | #ifdef U_HPUX | |
206 | T_FileStream_writeLine(makefile, "$(TARGETDIR)/$(FINAL_SO_TARGET): $(OBJECTS) $(HPUX_JUNK_OBJ) $(LISTFILES) $(DLL_DEPS)\n" | |
207 | "\t$(SHLIB.cc) -o $@ $(OBJECTS) $(HPUX_JUNK_OBJ) $(DLL_LDFLAGS)\n" | |
208 | "\t-ls -l $@\n\n"); | |
209 | ||
210 | T_FileStream_writeLine(makefile, "$(TEMP_DIR)/hpux_junk_obj.cpp:\n" | |
211 | "\techo \"void to_emit_cxx_stuff_in_the_linker(){}\" >> $(TEMP_DIR)/hpux_junk_obj.cpp\n" | |
212 | "\n" | |
213 | "$(TEMP_DIR)/hpux_junk_obj.o: $(TEMP_DIR)/hpux_junk_obj.cpp\n" | |
214 | "\t$(COMPILE.cc) $(DYNAMICCPPFLAGS) $(DYNAMICCXXFLAGS) -o $@ $<\n" | |
215 | "\n"); | |
216 | #else | |
217 | ||
218 | /*390port*/ | |
219 | #ifdef OS390BATCH | |
220 | T_FileStream_writeLine(makefile, "$(BATCH_TARGET): $(OBJECTS) $(LISTFILES) $(DLL_DEPS)\n" | |
221 | "\t$(SHLIB.c) -o $@ $(OBJECTS) $(DLL_LDFLAGS)\n\n"); | |
222 | #endif | |
223 | ||
224 | T_FileStream_writeLine(makefile, "$(TARGETDIR)/$(FINAL_SO_TARGET): $(OBJECTS) $(LISTFILES) $(DLL_DEPS)\n" | |
225 | "\t$(SHLIB.c) -o $@ $(OBJECTS) $(DLL_LDFLAGS)\n" | |
226 | "\t-ls -l $@\n\n"); | |
227 | ||
228 | #ifdef OS390 | |
229 | /* | |
230 | jdc26: The above link resolves to | |
231 | ||
232 | -o ../data/out/libicudata26.0.dll | |
233 | ||
234 | the first time or | |
235 | ||
236 | -o ../data/out/libicudata_stub26.0.dll | |
237 | ||
238 | the second time in the build. OS/390 puts each DLL into | |
239 | the specified directory and the sidedeck into the current | |
240 | directory. Move the sidedeck into the same directory as | |
241 | the DLL so it can be found with the DLL later in the | |
242 | build. | |
243 | ||
244 | */ | |
245 | T_FileStream_writeLine(makefile, "\t-cp -f ./$(basename $(FINAL_SO_TARGET))$(IMPORT_LIB_EXT) $(TARGETDIR)/$(basename $(FINAL_SO_TARGET))$(IMPORT_LIB_EXT)\n"); | |
246 | #endif /* OS/390 */ | |
247 | #endif | |
248 | ||
249 | 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)"); | |
250 | T_FileStream_writeLine(makefile, "\n\n"); | |
251 | ||
252 | T_FileStream_writeLine(makefile, "install: $(TARGETDIR)/$(FINAL_SO_TARGET)\n" | |
253 | "\t$(INSTALL-L) $(TARGETDIR)/$(FINAL_SO_TARGET) $(INSTALLTO)/$(FINAL_SO_TARGET)\n"); | |
254 | ||
255 | T_FileStream_writeLine(makefile, "ifneq ($(IMPORT_LIB_EXT),)\n"); | |
256 | T_FileStream_writeLine(makefile, "\t$(INSTALL-L) $(TARGETDIR)/$(basename $(FINAL_SO_TARGET))$(IMPORT_LIB_EXT) $(INSTALLTO)/$(basename( $(FINAL_SO_TARGET))$(IMPORT_LIB_EXT)\n"); | |
257 | T_FileStream_writeLine(makefile, "endif\n"); | |
258 | if (o->version) { | |
259 | T_FileStream_writeLine(makefile, "ifneq ($(FINAL_SO_TARGET),$(SO_TARGET))\n"); | |
260 | T_FileStream_writeLine(makefile, "\tcd $(INSTALLTO) && $(RM) $(SO_TARGET) && ln -s $(FINAL_SO_TARGET) $(SO_TARGET)\n"); | |
261 | T_FileStream_writeLine(makefile, "ifneq ($(FINAL_SO_TARGET),$(MIDDLE_SO_TARGET))\n"); | |
262 | T_FileStream_writeLine(makefile, "\tcd $(INSTALLTO) && $(RM) $(MIDDLE_SO_TARGET) && ln -s $(FINAL_SO_TARGET) $(MIDDLE_SO_TARGET)\n"); | |
263 | T_FileStream_writeLine(makefile, "endif\n"); | |
264 | T_FileStream_writeLine(makefile, "endif\n"); | |
265 | ||
266 | #ifdef OS390 | |
267 | T_FileStream_writeLine(makefile, "ifneq ($(IMPORT_LIB_EXT),)\n"); | |
268 | 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"); | |
269 | 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"); | |
270 | T_FileStream_writeLine(makefile, "endif\n"); | |
271 | #endif | |
272 | } | |
273 | T_FileStream_writeLine(makefile, "\n"); | |
274 | ||
275 | #ifdef U_SOLARIS | |
276 | T_FileStream_writeLine(makefile, "$(NAME).map:\n\techo \"{global: $(TOCSYM); local: *; };\" > $@\n\n"); | |
277 | #endif | |
278 | ||
279 | #ifdef U_AIX | |
280 | T_FileStream_writeLine(makefile, "$(NAME).map:\n\techo \"$(TOCSYM)\" > $@\n\n"); | |
281 | #endif | |
282 | ||
283 | ||
284 | *status = U_ZERO_ERROR; | |
285 | ||
286 | } | |
287 | ||
288 | #endif /* #ifndef U_MAKE_IS_NMAKE */ | |
289 |