From 482840e61f86ca321838a91e902c41d40c098bbb Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Wed, 24 Dec 2014 07:38:37 +0000 Subject: Imported from /home/lorry/working-area/delta_gettext-tarball/gettext-0.19.4.tar.xz. --- os2/Makefile | 241 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ os2/README.OS2 | 182 +++++++++++++++++++++++++++++++++++++++++ os2/backward.def | 13 +++ os2/configure.awk | 81 ++++++++++++++++++ 4 files changed, 517 insertions(+) create mode 100644 os2/Makefile create mode 100644 os2/README.OS2 create mode 100644 os2/backward.def create mode 100644 os2/configure.awk (limited to 'os2') diff --git a/os2/Makefile b/os2/Makefile new file mode 100644 index 0000000..5824dee --- /dev/null +++ b/os2/Makefile @@ -0,0 +1,241 @@ +# +# OS/2 GNU Makefile for building gettext with GNU Make and GNU C compiler +# +# OS/2 still supports the regular configure/make building mechanism, but its +# way more clumsy, complicated and error prone. It is highly recommended to +# use this makefile instead, because : +# - this makefile builds an optimized static and dynamic version of the +# library +# - it is able to build both optimized and debug versions of the library +# without any reconfiguring +# - this makefile builds an backward compatible DLL. When building with +# configure you will get a DLL which is compatible only with the 0.10.40 +# and later DLLs of gettext; this makefile builds a DLL which is binary +# compatible with gettext 0.10.35 (exports by ordinal matter). +# - it is able to generate a complete OS/2 binary distribution (make distr) +# - besides its simply alot faster than configure generated makefiles +# +# The makefile is designed to be more or less gettext version independent, +# so it is likely to work with future versions of gettext as well. +# +# If you get unresolved dependencies (e.g. "don't know how to make somefile.h +# which is required for zzz.o) remove (or rebuild, if you have the makedep tool) +# the depend.mak file which contains all the dependencies. +# + +# Use CMD.EXE as shell since its way faster +SHELL = $(COMSPEC) +# An Unix-like shell (needed for running config.charset) +UNIXSHELL = sh.exe + +# Debug mode (1) or optimize mode (0) +DEBUG = 0 + +# The version of INTL.DLL (the name suffix) +INTLDLLVER = + +# Pack the DLL and executables with lxlite +LXLITE = 1 + +# Output directory +OUT = out/$(OUT.SUFFIX)/ +# Root package directory +ROOT = ../ +# The base directory for distribution archive (emx/ or usr/) +INST = emx/ + +# Tools +CC = gcc -c +CFLAGS = -Wall -Zmt $(INCLUDE) $(DEFS) +INCLUDE = -I. -I$(ROOT) -I$(ROOT)intl -I$(ROOT)src -I$(ROOT)lib +DEFS = -DHAVE_CONFIG_H -DLIBDIR=\"/usr/lib\" \ + -DLOCALEDIR=\"/usr/share/locale\" -DLOCALE_ALIAS_PATH=\"/usr/share/locale\" \ + -DGETTEXTDATADIR=\"/usr/share/gettext\" \ + -DPROJECTSDIR=\"/usr/share/gettext/projects\" \ + -DGETTEXTJAR=\"/usr/share/gettext/gettext.jar\" + + +LD = gcc +LDFLAGS = -Zmt -Zcrtdll +LDFLAGS.SHARED = -Zmt -Zcrtdll -Zdll +LIBS = -liconv -liberty -lgcc + +AR = ar +ARFLAGS = crs + +MKDIR = mkdir.exe -p +COPY = cp -p + +LINKINTL = $(OUT)intl.a + +ifeq ($(DEBUG),0) + CFLAGS += -s -O2 + LDFLAGS += -s -Zexe + LDFLAGS.SHARED += -s + OUT.SUFFIX = release +else + CFLAGS += -g + LDFLAGS += -g -Zexe + LDFLAGS.SHARED += -g + OUT.SUFFIX = debug + LXLITE := 0 + LINKINTL = $(OUT)intl_s.a +endif + +# Languages with encodings unsupported by OS/2 API (BIG5) +BAD.LINGUAS=zh + +# The list of languages to be included in binary distribution +LINGUAS = $(filter-out $(BAD.LINGUAS),$(shell sed -e "/^\#/d" $(ROOT)po/LINGUAS)) + +# Fetch version number from configure.in +VERSION = $(shell sed ../configure.in -ne "/AM_INIT_AUTOMAKE/{" -e "s/.*(gettext, *\\(.*\\))/\\1/" -e "p" -e "}") + +# Fetch the list of source files for libintl from intl/Makefile.in +INTL.SOURCES = $(addprefix $(ROOT)intl/,\ + $(subst $$lo,c,\ + $(subst @INTLOBJS@,intl-compat.c,\ + $(subst OBJECTS = ,,\ + $(subst \,,\ + $(shell sed $(ROOT)intl/Makefile.in -ne "/^OBJECTS =/,/[^\]$$/p")))))) +INTL.OBJECTS = $(addprefix $(OUT),$(subst $(ROOT),,$(INTL.SOURCES:.c=.o))) + +PROGRAMS = $(addsuffix .exe,$(subst bin_PROGRAMS = ,,\ + $(subst \,,\ + $(shell sed $(ROOT)src/Makefile.am -ne "/^bin_PROGRAMS =/,/[^\]$$/p")))) +PROGRAMS.EXE = $(addprefix $(OUT),$(PROGRAMS)) +SRC.SOURCES = $(filter-out $(addprefix $(ROOT)src/,$(PROGRAMS:.exe=.c)),\ + $(wildcard $(ROOT)src/*.c)) +SRC.OBJECTS = $(addprefix $(OUT),$(subst $(ROOT),,$(SRC.SOURCES:.c=.o))) +LIB.SOURCES = $(addprefix $(ROOT)lib/, error.c stpcpy.c stpncpy.c mkdtemp.c getline.c \ + $(subst libgettextlib_la_SOURCES = ,,\ + $(subst \,,\ + $(patsubst %.h,,\ + $(patsubst getopt%.c,,\ + $(shell sed $(ROOT)lib/Makefile.am -ne "/^libgettextlib_la_SOURCES =/,/[^\]$$/p")))))) +LIB.OBJECTS = $(addprefix $(OUT),$(subst $(ROOT),,$(LIB.SOURCES:.c=.o))) + +OUTDIRS = $(OUT) $(sort $(dir $(INTL.OBJECTS) $(SRC.OBJECTS) $(LIB.OBJECTS) \ + $(LIBUNINAME.OBJECTS) $(INSTALL.FILES))) + +INSTALL.FILES = $(addprefix $(INST)bin/,$(PROGRAMS)) \ + $(INST)lib/intl.a $(INST)lib/intl_s.a $(INST)include/libintl.h \ + $(INST)dll/intl.dll $(INST)share/locale/charset.alias \ + $(INST)share/locale/locale.alias $(INST)doc/gettext-$(VERSION)/README.OS2 \ + $(INST)doc/gettext-$(VERSION)/COPYING $(INST)doc/gettext-$(VERSION)/README \ + $(addsuffix /LC_MESSAGES/gettext.mo,$(addprefix $(INST)share/locale/,$(LINGUAS))) \ + $(INSTALL.DIFF) + +.SUFFIXES: +.SUFFIXES: .o .a .def .exe .dll .po .mo +.PRECIOUS: $(OUT)%.o $(OUT)%.a + +.PHONY: all depend clean distr rmzip + +$(OUT)%.o: $(ROOT)%.c + $(CC) $(CFLAGS) -o $@ $< + +# To avoid playing with object file lists for every program we will build +# instead a library containing all the object files from src directory, and +# then link the library against the main program module, so that linker can +# pull all the required functions from there +$(OUT)%.exe: $(OUT)src/%.o $(OUT)util.a $(OUT)uniname.a $(LINKINTL) + $(LD) $(LDFLAGS) -o $@ $^ $(LIBS) +ifeq ($(LXLITE),1) + lxlite /b- $@ +endif + +all: config.h $(OUTDIRS) $(ROOT)src/po-gram-gen2.h $(ROOT)lib/stdbool.h \ + $(ROOT)intl/libintl.h $(OUT)intl.a $(OUT)intl_s.a $(OUT)intl$(INTLDLLVER).dll \ + $(PROGRAMS.EXE) + +define MAKEDEP + echo $(OUT)PATH = FILENAME + makedep $(INCLUDE) $(DEFS) -p $$(OUT)PATH -r -a FILENAME -c -f depend.mak + +endef + +depend: $(INTL.SOURCES) $(SRC.SOURCES) +# Remove all dependencies + rm -f depend.mak +# Build dependencies, by one file (to avoid 1024 chars command line length limit) + @$(foreach fn,$^,$(subst PATH,$(subst ../,,$(dir $(fn))),$(subst FILENAME,$(fn),$(MAKEDEP)))) + +clean: + rm -rf out emx config.h + +distr: all rmzip gettext-os2-$(VERSION)-bin.zip + +rmzip: + rm -f gettext-os2-$(VERSION)-bin.zip + +# How to configure without configure... +config.h: ../config.h.in ./configure.awk + gawk -f configure.awk -v PACKAGE=gettext -v VERSION=$(VERSION) $< >config.h + +$(OUTDIRS): + $(MKDIR) $(@:/=) + +$(OUT)intl_s.a: $(INTL.OBJECTS) + $(AR) $(ARFLAGS) $@ $^ + +$(OUT)intl.def: $(INTL.OBJECTS) + @echo LIBRARY INTL$(INTLDLLVER) INITINSTANCE TERMINSTANCE>$@ + @echo DESCRIPTION "GNU gettext internationalization library version $(VERSION)">>$@ + @echo DATA MULTIPLE NONSHARED>>$@ + @echo EXPORTS>>$@ + type backward.def>>$@ + emxexp -u $^ >>$@ + +$(OUT)intl$(INTLDLLVER).dll: $(INTL.OBJECTS) $(OUT)intl.def + @echo ********************************************************* + @echo *** YOU CAN SAFELY IGNORE WARNINGS FROM EMXBIND BELOW *** + @echo ********************************************************* + $(LD) $(LDFLAGS.SHARED) -o $@ $^ $(LIBS) +ifeq ($(LXLITE),1) + lxlite $@ +endif + +# How to build an import library from a .DEF file +$(OUT)%.a: $(OUT)%.def + emximp -o $@ $< + +$(OUT)util.a: $(SRC.OBJECTS) $(LIB.OBJECTS) + $(AR) $(ARFLAGS) $@ $^ + +$(OUT)uniname.a: $(LIBUNINAME.OBJECTS) + $(AR) $(ARFLAGS) $@ $^ + +$(ROOT)src/po-gram-gen2.h: $(ROOT)src/po-gram-gen.h + sed -e "s/[yY][yY]/po_gram_/g" $< > $@ + +$(ROOT)intl/libintl.h: $(ROOT)intl/libgnuintl.h + $(COPY) $< $@ + +$(ROOT)lib/stdbool.h: $(ROOT)lib/stdbool.h.in + $(COPY) $< $@ + +gettext-os2-$(VERSION)-bin.zip: $(INSTALL.FILES) + @rm -f $@ + zip -9XD $@ $^ + +# The following rules are for `make distr' target only + +$(INST)share/locale/charset.alias: $(ROOT)lib/config.charset + $(UNIXSHELL) $< i386-pc-os2-emx >$@ +$(INST)share/locale/locale.alias: $(ROOT)intl/locale.alias + $(COPY) $< $@ +$(INST)bin/% $(INST)lib/% $(INST)dll/%: $(OUT)% + $(COPY) $< $@ +$(INST)include/%: $(ROOT)intl/% + $(COPY) $< $@ +$(INST)doc/gettext-$(VERSION)/%: $(ROOT)% + $(COPY) $< $@ +$(INST)doc/gettext-$(VERSION)/% $(INST)include/%: % + $(COPY) $< $@ +$(INST)share/locale/%/LC_MESSAGES/gettext.mo: $(ROOT)po/%.po + $(MKDIR) $(dir $@) + $(COMSPEC) /c "$(subst /,\\,set BEGINLIBPATH=$(OUT:/=) && \ + $(OUT)msgfmt.exe) --statistics --verbose -o $@ $<" + +-include depend.mak diff --git a/os2/README.OS2 b/os2/README.OS2 new file mode 100644 index 0000000..732942e --- /dev/null +++ b/os2/README.OS2 @@ -0,0 +1,182 @@ + +Welcome! +======== + +This is the OS/2 port of GNU gettext internationalization library. + + +Compatibility +============= + +The library has been compiled with -Zmt flag, but it doesn't matter as soon +as you use the EMX single-threaded runtime fix (emx-strt-fix-0.0.2.zip). + +The library is fully compatible with the previous port of gettext library +(0.10.35) which is largely used especialy by XFree86/2 programs. All the +old programs that I have with gettext support run fine with the new version +of the DLL. + + +Installation +============ + +If you set the GNULOCALEDIR environment variable to point to your +x:/xxx/share/locale directory, it will override any other setting. That is, +unpack the binary distribution over /emx, set GNULOCALEDIR=x:/emx/share/locale +(where x: is the drive letter of your EMX installation) and that's all. + +If you use the UNIXROOT environment variable, the default catalogue search +paths will be like on Unices, e.g. $(UNIXROOT)/usr/lib and +$(UNIXROOT)/usr/share/locale. GNULOCALEDIR always overrides this. + +Now if you haven't did it earlier, set the language identifier that you use. +This is done by adding a "SET LANG=xxx" environment setting to your CONFIG.SYS, +where xxx is the identifier of your language (example: en_UK for English in UK, +ru_RU for Russian in Russia. Also you can use names like "russian", "italian" +and so on - see the share/locale/locale.alias file). + +This port of gettext supports character set conversions. This means that if +your .mo files were written using new gettext guidelines, e.g. they contain a +message like this: + +msgid "" +msgstr "Content-Type: text/plain; charset=koi8-r\n" + +the messages will be properly converted to your active codepage using OS/2 +Unicode API. For example, russian message catalog gettext.mo is in the +KOI8-R (codepage 878) encoding while OS/2 uses codepage 866. Now when you +run any of these tools it detects that the active OS/2 codepage is 866 and +performs the translation from CP878 -> CP866 for every message. + +If you want to override the character set used to output messages (for example +in XFree86 for Russian the KOI8-R encoding (codepage 878) is used) you can +set the output character set by adding a postfix to the LANG environment +variable, this way: + +set LANG=ru_RU.KOI8-R + +or (equivalent): + +set LANG=ru_RU.CP878 + +or (same effect): + +set LANG=ru_RU.IBM-878 + +If the output character set is ommited from the LANG variable, the default +codepage is ALWAYS taken from the operating system (e.g. the codepage setting +from locale.alias is always ignored, so "russian" stays just for "ru_RU" and +not for "ru_RU.ISO-8859-5"); you may want to set it just if you want to +override the active OS/2 codepage. + + +XFree86 setup +============= + +If you use XFree86 and the OS/2 default character set is different from the +XFree86 default character set (e.g. for Russain CP866 vs KOI8-R), you can add +the following (or similar) statement to your startx.cmd file (after the +commands dealing with HOME and X11SHELL): + +call VALUE 'LANG', 'ru_RU.KOI8-R', env + +Otherwise you can get incorrect (wrong codepage) output from programs that +previously worked (e.g. GIMP 1.22). This is because earlier versions of gettext +didn't support character set translations. + + +Implementation remarks +====================== + +The codepage conversion code uses OS/2 Unicode API, thus it falls under the +limits that OS/2 Unicode API has. For example, OS/2 Unicode API does not +support the BIG5 East Asian character set nor ISO-8859-X where X > 9 (at +least with Warp4 with fixpack 14 that I have). If someone knows the +OS/2 API identifiers for BIG5 or ISO8859-10,... encodings, please tell me! + +Since gettext 0.11 iconv emulation layer supports correctly UTF-8. Also +I have added theoretical support for the following East Asian encodings: +EUC-JP, EUC-KR, EUC-TW, EUC-CN. However, these encodings are (I believe) +supported only on East Asian editions of OS/2. The code pages for them are +listed in the \language\codepage\ucstbl.lst file but the codepage files +themselves are missing; I believe they are ommited from European OS/2's +due to their large size. + +Also I have added "support" for the BIG5 codeset as an alias for IBM-950 +codepage. However, I'm not very sure about this; in any case OS/2 does not +support (as far as I know) anything closer to BIG5. + + +Additional API +============== + +This package provides additionaly the iconv() API that can be used by +developers for doing more feature-full Unix ports. The iconv() API is used +to convert text between various codepages. The intl.h header file contains +the prototypes and definitions needed for iconv(); if you configure software +with autoconf it possibly will find intl.h and set up the software accordingly. + +All these functions are exported from INTL.DLL. The iconv.a import library +imports all the iconv* functions from INTL.DLL. So, like on Unix, now you can +#include , then link with -liconv and you will get a fully functional +iconv implementation. + + +Rebuilding the library +====================== + +The library is quite easy to rebuild. Since the OS/2 support is provided now +out-of-the-box in gettext, you just have to download and unpack the source +archive. Now there are two ways to rebuild the gettext library: + +1. If you're a masochist you can go the clumsy configure/make Unix way. This +is not recommended however as I found no way to tell libtool to generate a +slightly non-standard DLL which will be backward compatible with gettext +0.10.35. The compatibility is achieved by prepending backward.def to the +export definition file generated with emximp or somehow else. Thus it is +highly recommended you build using the second way, if it is possible. + +2. Go to os2 and just run `make'. If you have all the required tools, +it should painlessly compile. Finally, if you want a binary distribution +archive, do `make distr'. The weak side of building this way is that makefile +is somewhat fragile. This means that if the makefile is left unmodified and +a new version of gettext is rolled out, it *may* not work. But every possible +attempt was made to ensure that the makefile takes most important build +parameters from their autoconf counterparts. + +WARNING: Due to bugs in GNU Make 3.76.1 (at least in its OS/2 port) you can +get sometimes (depending on make version and makefile modification :) funny +messages like these: + +zip warning: name not matched: emx/src/gettext-0.10.40/support/os2/iconv.h + +or even: + +*** No rule to make target `out/release/intl.a', needed by `all'. Stop. + +Such messages are a bad joke. Ignore it, and re-run make. This is a +long-standing bug in GNU make, alas. + +If you want a debug version of library, you can do `make DEBUG=1'. + +If you don't have the LxLite tool installed, do `make LXLITE=0' + +NB: For best results, it is highly recommended that you use at least emxbind.exe +and ld.exe from gcc 3.0.2 or later, since they contain a number of fixes that +will help you generate a more optimal DLL. + + +Contributors +============ + +Hung-Chi Chu + the original port of gettext (0.10.35) + +Jun SAWATAISHI + some more work on it and submitted the patches to GNU team, although + they were not completely integrated. + +Andrew Zabolotny + Succeeded to remove almost all OS/2-specific #ifdef's from mainstream + source code, wrote the dedicated OS/2 makefile, wrote the iconv wrapper + around OS/2 Unicode API, added support for locale translations. diff --git a/os2/backward.def b/os2/backward.def new file mode 100644 index 0000000..3183f9f --- /dev/null +++ b/os2/backward.def @@ -0,0 +1,13 @@ +; These exports are for backward compatibility with older ports +; of gettext for OS/2 that export everything by ordinals. + _$gettext=gettext @1 NONAME + _$gettext__=gettext__ @2 NONAME + _$dgettext=dgettext @3 NONAME + _$dgettext__=dgettext__ @4 NONAME + _$dcgettext=dcgettext @5 NONAME + _$dcgettext__=dcgettext__ @6 NONAME + _$textdomain=textdomain @7 NONAME + _$textdomain__=textdomain__ @8 NONAME + _$bindtextdomain=bindtextdomain @9 NONAME + _$bindtextdomain__=bindtextdomain__ @10 NONAME + _$_nl_msg_cat_cntr=_nl_msg_cat_cntr @11 NONAME diff --git a/os2/configure.awk b/os2/configure.awk new file mode 100644 index 0000000..ccf60e3 --- /dev/null +++ b/os2/configure.awk @@ -0,0 +1,81 @@ +#!/usr/bin/gawk -f +# A script for emulating configure on OS/2 without having even a Unix-like +# shell. Designed specifically for compiling gettext with gcc+emx. + +BEGIN{ + print "/* config.h. Generated automatically by configure.awk. */" + + cfg["HAVE_ALLOCA"] = 1; + cfg["HAVE_ALLOCA_H"] = 1; + cfg["HAVE_LONG_FILE_NAMES"] = 1; + cfg["STDC_HEADERS"] = 1; + cfg["HAVE_GETCWD"] = 1; + cfg["HAVE_GETEGID"] = 1; + cfg["HAVE_GETEUID"] = 1; + cfg["HAVE_GETGID"] = 1; + cfg["HAVE_GETPAGESIZE"] = 1; + cfg["HAVE_GETUID"] = 1; + cfg["HAVE_ISASCII"] = 1; + cfg["HAVE_MBLEN"] = 1; + cfg["HAVE_MEMCPY"] = 1; + cfg["HAVE_MEMMOVE"] = 1; + cfg["HAVE_MEMSET"] = 1; + cfg["HAVE_PUTENV"] = 1; + cfg["HAVE_SETLOCALE"] = 1; + cfg["HAVE_STRCHR"] = 1; + cfg["HAVE_STRCSPN"] = 1; + cfg["HAVE_STRDUP"] = 1; + cfg["HAVE_STRERROR"] = 1; + cfg["HAVE_STRSTR"] = 1; + cfg["HAVE_STRTOUL"] = 1; + cfg["HAVE_UNAME"] = 1; + cfg["HAVE_LIMITS_H"] = 1; + cfg["HAVE_LOCALE_H"] = 1; + cfg["HAVE_MALLOC_H"] = 1; + cfg["HAVE_STDDEF_H"] = 1; + cfg["HAVE_STDLIB_H"] = 1; + cfg["HAVE_STRING_H"] = 1; + cfg["HAVE_SYS_PARAM_H"] = 1; + cfg["HAVE_UNISTD_H"] = 1; + cfg["HAVE_GETTIMEOFDAY"] = 1; + cfg["HAVE_PATHCONF"] = 1; + cfg["HAVE_RAISE"] = 1; + cfg["HAVE_SELECT"] = 1; + cfg["HAVE_STRPBRK"] = 1; + cfg["HAVE_UTIME"] = 1; + cfg["HAVE_UTIMES"] = 1; + cfg["HAVE_WAITPID"] = 1; + cfg["HAVE_ARPA_INET_H"] = 1; + cfg["HAVE_DIRENT_H"] = 1; + cfg["HAVE_FCNTL_H"] = 1; + cfg["HAVE_SYS_TIME_H"] = 1; + cfg["HAVE_TIME_H"] = 1; + cfg["HAVE_POSIX_SIGNALBLOCKING"] = 1; + cfg["HAVE_ERRNO_DECL"] = 1; + cfg["HAVE_ICONV"] = 1; + cfg["ICONV_CONST"] = "const"; + cfg["_GNU_SOURCE"] = 1; + cfg["HAVE_UNSIGNED_LONG_LONG"] = 1; + cfg["HAVE_PTRDIFF_T"] = 1; + cfg["vfork"] = "fork"; + cfg["uintmax_t"] = "unsigned long long"; + cfg["HAVE_DECL_WCWIDTH"] = 0; + cfg["mbstate_t"] = "int"; + cfg["SETLOCALE_CONST"] = "const"; + cfg["ENABLE_NLS"] = 1; + + cfg["PACKAGE"] = "\""PACKAGE"\""; + cfg["VERSION"] = "\""VERSION"\""; +} + +/^#undef/ { + if (cfg[$2] != "") + print "#define "$2" "cfg[$2]; + else + print "/* #undef "$2" */"; + next +} + +{ + print $0 +} -- cgit v1.2.1