]>
git.saurik.com Git - apple/icu.git/blob - icuSources/tools/pkgdata/dllmode.c
1 /******************************************************************************
3 * Copyright (C) 2000-2004, International Business Machines
4 * Corporation and others. All Rights Reserved.
6 *******************************************************************************
8 * encoding: ANSI X3.4 (1968)
9 * tab size: 8 (not used)
12 * created on: 2000may15
13 * created by: Steven \u24C7 Loomis
15 * This program packages the ICU data into different forms
16 * (DLL, common data, etc.)
21 #include "unicode/utypes.h"
22 #include "unicode/putil.h"
24 #ifndef U_MAKE_IS_NMAKE
35 void pkg_mode_dll(UPKGOptions
*o
, FileStream
*makefile
, UErrorCode
*status
)
38 CharList
*tail
= NULL
;
39 CharList
*objects
= NULL
;
41 if(U_FAILURE(*status
)) {
45 uprv_strcpy(tmp
, LIB_PREFIX
"$(LIBNAME)" UDATA_SO_SUFFIX
);
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
));
50 if(o
->nooutput
|| o
->verbose
) {
51 fprintf(stdout
, "# Output file: %s%s%s\n", o
->targetDir
, U_FILE_SEP_STRING
, tmp
);
55 *status
= U_ZERO_ERROR
;
59 /* begin writing makefile ========================= */
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
);
73 T_FileStream_writeLine(makefile
, "# Version numbers:\nVERSIONED=");
75 sprintf(tmp
, ".%s", o
->version
);
76 if (!uprv_strchr(o
->version
, '.')) {
77 uprv_strcat(tmp
, ".0");
79 T_FileStream_writeLine(makefile
, tmp
);
80 T_FileStream_writeLine(makefile
, "\nDLL_LDFLAGS=$(LD_SONAME) $(RPATH_LDFLAGS) $(BIR_LDFLAGS)\nDLL_DEPS=$(BIR_DEPS)\n");
82 T_FileStream_writeLine(makefile
, "\nDLL_LDFLAGS=$(BIR_LDFLAGS)\nDLL_DEPS=$(BIR_DEPS)\n");
84 T_FileStream_writeLine(makefile
, "\n");
86 sprintf(tmp
, "# File to make:\nTARGET=%s\n\n", o
->outFiles
->str
);
87 T_FileStream_writeLine(makefile
, tmp
);
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
) {
102 T_FileStream_writeLine(makefile
, tmp
);
104 T_FileStream_writeLine(makefile
, "FINAL_SO_TARGET=$(TARGET)\n");
105 T_FileStream_writeLine(makefile
, "MIDDLE_SO_TARGET=$(TARGET)\n");
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");
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
);
120 uprv_strcpy(tmp
, "all: $(TARGETDIR)/$(FINAL_SO_TARGET) $(BATCH_TARGET)");
122 uprv_strcat(tmp
, " $(TARGETDIR)/$(MIDDLE_SO_TARGET) $(TARGETDIR)/$(SO_TARGET)");
124 uprv_strcat(tmp
, "\n\n");
125 T_FileStream_writeLine(makefile
, tmp
);
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
);
134 /* Write compile rules */
135 pkg_mak_writeObjRules(o
, makefile
, &objects
, OBJ_SUFFIX
);
137 sprintf(tmp
, "# List file for gencmn:\n"
138 "CMNLIST=%s%s$(NAME)_dll.lst\n\n",
141 T_FileStream_writeLine(makefile
, tmp
);
143 if(o
->hadStdin
== FALSE
) { /* shortcut */
144 T_FileStream_writeLine(makefile
, "$(CMNLIST): $(LISTFILES)\n"
145 "\tcat $(LISTFILES) > $(CMNLIST)\n\n");
147 T_FileStream_writeLine(makefile
, "$(CMNLIST): \n"
148 "\t@echo \"generating $@ (list of data files)\"\n"
150 "\t@for file in $(DATAFILEPATHS); do \\\n"
151 "\t echo $$file >> $@; \\\n"
155 pkg_mak_writeAssemblyHeader(makefile
, o
);
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
);
161 T_FileStream_writeLine(makefile
, "# 'TOCOBJ' contains C Table of Contents objects [if any]\n");
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");
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");
171 T_FileStream_writeLine(makefile
, tmp
);
172 sprintf(tmp
, "TOCOBJ= $(NAME)_dat%s \n\n", OBJ_SUFFIX
);
173 T_FileStream_writeLine(makefile
, tmp
);
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
);
181 T_FileStream_writeLine(makefile
, "# 'ALLDATAOBJ' contains all .c data structures\n");
183 sprintf(tmp
, "ALLDATAOBJ= $(NAME)all%s \n\n", OBJ_SUFFIX
);
184 T_FileStream_writeLine(makefile
, tmp
);
187 sprintf(tmp
, "TOCSYM= %s_dat \n\n", o
->entryName
); /* entrypoint not always shortname! */
188 T_FileStream_writeLine(makefile
, tmp
);
190 T_FileStream_writeLine(makefile
, "BASE_OBJECTS= $(TOCOBJ) ");
192 T_FileStream_writeLine(makefile
, "$(ALLDATAOBJ) ");
194 pkg_writeCharListWrap(makefile
, objects
, " ", " \\\n",0);
196 pkg_mak_writeAssemblyFooter(makefile
, o
);
198 T_FileStream_writeLine(makefile
, "\n\n");
199 T_FileStream_writeLine(makefile
, "OBJECTS=$(BASE_OBJECTS:%=$(TEMP_DIR)/%)\n\n");
201 T_FileStream_writeLine(makefile
,"$(TEMP_DIR)/%.o: $(TEMP_DIR)/%.c\n\t$(COMPILE.c) $(DYNAMICCPPFLAGS) $(DYNAMICCXXFLAGS) -o $@ $<\n\n");
203 T_FileStream_writeLine(makefile
,"build-objs: $(SOURCES) $(OBJECTS)\n\n$(OBJECTS): $(SOURCES)\n\n");
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"
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"
213 "$(TEMP_DIR)/hpux_junk_obj.o: $(TEMP_DIR)/hpux_junk_obj.cpp\n"
214 "\t$(COMPILE.cc) $(DYNAMICCPPFLAGS) $(DYNAMICCXXFLAGS) -o $@ $<\n"
220 T_FileStream_writeLine(makefile
, "$(BATCH_TARGET): $(OBJECTS) $(LISTFILES) $(DLL_DEPS)\n"
221 "\t$(SHLIB.c) -o $@ $(OBJECTS) $(DLL_LDFLAGS)\n\n");
224 T_FileStream_writeLine(makefile
, "$(TARGETDIR)/$(FINAL_SO_TARGET): $(OBJECTS) $(LISTFILES) $(DLL_DEPS)\n"
225 "\t$(SHLIB.c) -o $@ $(OBJECTS) $(DLL_LDFLAGS)\n"
230 jdc26: The above link resolves to
232 -o ../data/out/libicudata26.0.dll
236 -o ../data/out/libicudata_stub26.0.dll
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
245 T_FileStream_writeLine(makefile
, "\t-cp -f ./$(basename $(FINAL_SO_TARGET))$(IMPORT_LIB_EXT) $(TARGETDIR)/$(basename $(FINAL_SO_TARGET))$(IMPORT_LIB_EXT)\n");
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");
252 T_FileStream_writeLine(makefile
, "install: $(TARGETDIR)/$(FINAL_SO_TARGET)\n"
253 "\t$(INSTALL-L) $(TARGETDIR)/$(FINAL_SO_TARGET) $(INSTALLTO)/$(FINAL_SO_TARGET)\n");
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");
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");
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");
273 T_FileStream_writeLine(makefile
, "\n");
276 T_FileStream_writeLine(makefile
, "$(NAME).map:\n\techo \"{global: $(TOCSYM); local: *; };\" > $@\n\n");
280 T_FileStream_writeLine(makefile
, "$(NAME).map:\n\techo \"$(TOCSYM)\" > $@\n\n");
284 *status
= U_ZERO_ERROR
;
288 #endif /* #ifndef U_MAKE_IS_NMAKE */