]>
git.saurik.com Git - apple/icu.git/blob - icuSources/tools/pkgdata/dllmode.c
1 /******************************************************************************
3 * Copyright (C) 2000-2006, 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");
72 T_FileStream_writeLine(makefile
, tmp
);
75 T_FileStream_writeLine(makefile
, "# Version numbers:\nVERSIONED=");
77 sprintf(tmp
, ".%s", o
->version
);
78 if (!uprv_strchr(o
->version
, '.')) {
79 uprv_strcat(tmp
, ".0");
81 T_FileStream_writeLine(makefile
, tmp
);
82 T_FileStream_writeLine(makefile
, "\nDLL_LDFLAGS=$(LD_SONAME) $(RPATH_LDFLAGS) $(BIR_LDFLAGS)\nDLL_DEPS=$(BIR_DEPS)\n");
84 T_FileStream_writeLine(makefile
, "\nDLL_LDFLAGS=$(BIR_LDFLAGS)\nDLL_DEPS=$(BIR_DEPS)\n");
86 T_FileStream_writeLine(makefile
, "\n");
88 sprintf(tmp
, "# File to make:\nTARGET=%s\n\n", o
->outFiles
->str
);
89 T_FileStream_writeLine(makefile
, tmp
);
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
) {
104 T_FileStream_writeLine(makefile
, tmp
);
106 T_FileStream_writeLine(makefile
, "FINAL_SO_TARGET=$(TARGET)\n");
107 T_FileStream_writeLine(makefile
, "MIDDLE_SO_TARGET=$(TARGET)\n");
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");
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
);
122 uprv_strcpy(tmp
, "all: $(TARGETDIR)/$(FINAL_SO_TARGET) $(BATCH_TARGET)");
124 uprv_strcat(tmp
, " $(TARGETDIR)/$(MIDDLE_SO_TARGET) $(TARGETDIR)/$(SO_TARGET)");
126 uprv_strcat(tmp
, "\n\n");
127 T_FileStream_writeLine(makefile
, tmp
);
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
);
136 /* Write compile rules */
137 pkg_mak_writeObjRules(o
, makefile
, &objects
, OBJ_SUFFIX
);
139 sprintf(tmp
, "# List file for gencmn:\n"
140 "CMNLIST=%s%s$(NAME)_dll.lst\n\n",
143 T_FileStream_writeLine(makefile
, tmp
);
145 if(o
->hadStdin
== FALSE
) { /* shortcut */
146 T_FileStream_writeLine(makefile
, "$(CMNLIST): $(LISTFILES)\n"
147 "\tcat $(LISTFILES) > $(CMNLIST)\n\n");
149 T_FileStream_writeLine(makefile
, "$(CMNLIST): \n"
150 "\t@echo \"generating $@ (list of data files)\"\n"
152 "\t@for file in $(DATAFILEPATHS); do \\\n"
153 "\t echo $$file >> $@; \\\n"
157 sprintf(tmp
, "TOCSYM= %s_dat \n\n", o
->entryName
); /* entrypoint not always shortname! */
158 T_FileStream_writeLine(makefile
, tmp
);
160 pkg_mak_writeAssemblyHeader(makefile
, o
);
162 sprintf(tmp
,"$(TEMP_DIR)/$(NAME)_dat.o : $(TEMP_DIR)/$(NAME)_dat.c\n"
163 "\t$(COMPILE.c) $(DYNAMICCPPFLAGS) $(DYNAMICCXXFLAGS) -o $@ $<\n\n");
164 T_FileStream_writeLine(makefile
, tmp
);
166 T_FileStream_writeLine(makefile
, "# 'TOCOBJ' contains C Table of Contents objects [if any]\n");
168 sprintf(tmp
, "$(TEMP_DIR)/$(NAME)_dat.c: $(CMNLIST)\n"
169 "\t$(INVOKE) $(GENCMN) -e $(ENTRYPOINT) -n $(NAME) -S -s $(SRCDIR) -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 T_FileStream_writeLine(makefile
, "BASE_OBJECTS= $(TOCOBJ) ");
189 T_FileStream_writeLine(makefile
, "$(ALLDATAOBJ) ");
191 pkg_writeCharListWrap(makefile
, objects
, " ", " \\\n",0);
193 pkg_mak_writeAssemblyFooter(makefile
, o
);
195 T_FileStream_writeLine(makefile
, "\n\n");
196 T_FileStream_writeLine(makefile
, "OBJECTS=$(BASE_OBJECTS:%=$(TEMP_DIR)/%)\n\n");
198 T_FileStream_writeLine(makefile
,"$(TEMP_DIR)/%.o: $(TEMP_DIR)/%.c\n\t$(COMPILE.c) $(DYNAMICCPPFLAGS) $(DYNAMICCXXFLAGS) -o $@ $<\n\n");
200 T_FileStream_writeLine(makefile
,"build-objs: $(SOURCES) $(OBJECTS)\n\n$(OBJECTS): $(SOURCES)\n\n");
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"
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"
210 "$(TEMP_DIR)/hpux_junk_obj.o: $(TEMP_DIR)/hpux_junk_obj.cpp\n"
211 "\t$(COMPILE.cc) $(DYNAMICCPPFLAGS) $(DYNAMICCXXFLAGS) -o $@ $<\n"
217 T_FileStream_writeLine(makefile
, "$(BATCH_TARGET): $(OBJECTS) $(LISTFILES) $(DLL_DEPS)\n"
218 "\t$(SHLIB.c) -o $@ $(OBJECTS) $(DLL_LDFLAGS)\n\n");
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");
227 T_FileStream_writeLine(makefile
, "$(TARGETDIR)/$(FINAL_SO_TARGET): $(OBJECTS) $(LISTFILES) $(DLL_DEPS)\n"
228 "\t$(SHLIB.c) -o $@ $(OBJECTS) $(DLL_LDFLAGS)\n"
234 jdc26: The above link resolves to
236 -o ../data/out/libicudata26.0.dll
240 -o ../data/out/libicudata_stub26.0.dll
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
249 T_FileStream_writeLine(makefile
, "\t-cp -f ./$(basename $(FINAL_SO_TARGET))$(IMPORT_LIB_EXT) $(TARGETDIR)/$(basename $(FINAL_SO_TARGET))$(IMPORT_LIB_EXT)\n");
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");
256 T_FileStream_writeLine(makefile
, "install: $(TARGETDIR)/$(FINAL_SO_TARGET)\n"
257 "\t$(INSTALL-L) $(TARGETDIR)/$(FINAL_SO_TARGET) $(INSTALLTO)/$(FINAL_SO_TARGET)\n");
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");
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");
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");
277 T_FileStream_writeLine(makefile
, "\n");
280 T_FileStream_writeLine(makefile
, "$(NAME).map:\n\techo \"{global: $(TOCSYM); local: *; };\" > $@\n\n");
284 T_FileStream_writeLine(makefile
, "$(NAME).map:\n\techo \"$(TOCSYM)\" > $@\n\n");
288 *status
= U_ZERO_ERROR
;
292 #endif /* #ifndef U_MAKE_IS_NMAKE */