2 # OS/2 GNU Makefile for building gettext with GNU Make and GNU C compiler
4 # OS/2 still supports the regular configure/make building mechanism, but its
5 # way more clumsy, complicated and error prone. It is highly recommended to
6 # use this makefile instead, because :
7 # - this makefile builds an optimized static and dynamic version of the
9 # - it is able to build both optimized and debug versions of the library
10 # without any reconfiguring
11 # - this makefile builds an backward compatible DLL. When building with
12 # configure you will get a DLL which is compatible only with the 0.10.40
13 # and later DLLs of gettext; this makefile builds a DLL which is binary
14 # compatible with gettext 0.10.35 (exports by ordinal matter).
15 # - it is able to generate a complete OS/2 binary distribution (make distr)
16 # - besides its simply alot faster than configure generated makefiles
18 # The makefile is designed to be more or less gettext version independent,
19 # so it is likely to work with future versions of gettext as well.
21 # If you get unresolved dependencies (e.g. "don't know how to make somefile.h
22 # which is required for zzz.o) remove (or rebuild, if you have the makedep tool)
23 # the depend.mak file which contains all the dependencies.
26 # Use CMD.EXE as shell since its way faster
28 # An Unix-like shell (needed for running config.charset)
31 # Debug mode (1) or optimize mode (0)
34 # The version of INTL.DLL (the name suffix)
37 # Pack the DLL and executables with lxlite
41 OUT = out/$(OUT.SUFFIX)/
42 # Root package directory
44 # The base directory for distribution archive (emx/ or usr/)
49 CFLAGS = -Wall -Zmt $(INCLUDE) $(DEFS)
50 INCLUDE = -I. -I$(ROOT) -I$(ROOT)intl -I$(ROOT)src -I$(ROOT)lib
51 DEFS = -DHAVE_CONFIG_H -DLIBDIR=\"/usr/lib\" \
52 -DLOCALEDIR=\"/usr/share/locale\" -DLOCALE_ALIAS_PATH=\"/usr/share/locale\" \
53 -DGETTEXTDATADIR=\"/usr/share/gettext\" \
54 -DPROJECTSDIR=\"/usr/share/gettext/projects\" \
55 -DGETTEXTJAR=\"/usr/share/gettext/gettext.jar\"
59 LDFLAGS = -Zmt -Zcrtdll
60 LDFLAGS.SHARED = -Zmt -Zcrtdll -Zdll
61 LIBS = -liconv -liberty -lgcc
69 LINKINTL = $(OUT)intl.a
82 LINKINTL = $(OUT)intl_s.a
85 # Languages with encodings unsupported by OS/2 API (BIG5)
88 # The list of languages to be included in binary distribution
89 LINGUAS = $(filter-out $(BAD.LINGUAS),$(shell sed -e "/^\#/d" $(ROOT)po/LINGUAS))
91 # Fetch version number from configure.in
92 VERSION = $(shell sed ../configure.in -ne "/AM_INIT_AUTOMAKE/{" -e "s/.*(gettext, *\\(.*\\))/\\1/" -e "p" -e "}")
94 # Fetch the list of source files for libintl from intl/Makefile.in
95 INTL.SOURCES = $(addprefix $(ROOT)intl/,\
97 $(subst @INTLOBJS@,intl-compat.c,\
100 $(shell sed $(ROOT)intl/Makefile.in -ne "/^OBJECTS =/,/[^\]$$/p"))))))
101 INTL.OBJECTS = $(addprefix $(OUT),$(subst $(ROOT),,$(INTL.SOURCES:.c=.o)))
103 PROGRAMS = $(addsuffix .exe,$(subst bin_PROGRAMS = ,,\
105 $(shell sed $(ROOT)src/Makefile.am -ne "/^bin_PROGRAMS =/,/[^\]$$/p"))))
106 PROGRAMS.EXE = $(addprefix $(OUT),$(PROGRAMS))
107 SRC.SOURCES = $(filter-out $(addprefix $(ROOT)src/,$(PROGRAMS:.exe=.c)),\
108 $(wildcard $(ROOT)src/*.c))
109 SRC.OBJECTS = $(addprefix $(OUT),$(subst $(ROOT),,$(SRC.SOURCES:.c=.o)))
110 LIB.SOURCES = $(addprefix $(ROOT)lib/, error.c stpcpy.c stpncpy.c mkdtemp.c getline.c \
111 $(subst libgettextlib_la_SOURCES = ,,\
114 $(patsubst getopt%.c,,\
115 $(shell sed $(ROOT)lib/Makefile.am -ne "/^libgettextlib_la_SOURCES =/,/[^\]$$/p"))))))
116 LIB.OBJECTS = $(addprefix $(OUT),$(subst $(ROOT),,$(LIB.SOURCES:.c=.o)))
118 OUTDIRS = $(OUT) $(sort $(dir $(INTL.OBJECTS) $(SRC.OBJECTS) $(LIB.OBJECTS) \
119 $(LIBUNINAME.OBJECTS) $(INSTALL.FILES)))
121 INSTALL.FILES = $(addprefix $(INST)bin/,$(PROGRAMS)) \
122 $(INST)lib/intl.a $(INST)lib/intl_s.a $(INST)include/libintl.h \
123 $(INST)dll/intl.dll $(INST)share/locale/charset.alias \
124 $(INST)share/locale/locale.alias $(INST)doc/gettext-$(VERSION)/README.OS2 \
125 $(INST)doc/gettext-$(VERSION)/COPYING $(INST)doc/gettext-$(VERSION)/README \
126 $(addsuffix /LC_MESSAGES/gettext.mo,$(addprefix $(INST)share/locale/,$(LINGUAS))) \
130 .SUFFIXES: .o .a .def .exe .dll .po .mo
131 .PRECIOUS: $(OUT)%.o $(OUT)%.a
133 .PHONY: all depend clean distr rmzip
135 $(OUT)%.o: $(ROOT)%.c
136 $(CC) $(CFLAGS) -o $@ $<
138 # To avoid playing with object file lists for every program we will build
139 # instead a library containing all the object files from src directory, and
140 # then link the library against the main program module, so that linker can
141 # pull all the required functions from there
142 $(OUT)%.exe: $(OUT)src/%.o $(OUT)util.a $(OUT)uniname.a $(LINKINTL)
143 $(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
148 all: config.h $(OUTDIRS) $(ROOT)src/po-gram-gen2.h $(ROOT)lib/stdbool.h \
149 $(ROOT)intl/libintl.h $(OUT)intl.a $(OUT)intl_s.a $(OUT)intl$(INTLDLLVER).dll \
153 echo $(OUT)PATH = FILENAME
154 makedep $(INCLUDE) $(DEFS) -p $$(OUT)PATH -r -a FILENAME -c -f depend.mak
158 depend: $(INTL.SOURCES) $(SRC.SOURCES)
159 # Remove all dependencies
161 # Build dependencies, by one file (to avoid 1024 chars command line length limit)
162 @$(foreach fn,$^,$(subst PATH,$(subst ../,,$(dir $(fn))),$(subst FILENAME,$(fn),$(MAKEDEP))))
165 rm -rf out emx config.h
167 distr: all rmzip gettext-os2-$(VERSION)-bin.zip
170 rm -f gettext-os2-$(VERSION)-bin.zip
172 # How to configure without configure...
173 config.h: ../config.h.in ./configure.awk
174 gawk -f configure.awk -v PACKAGE=gettext -v VERSION=$(VERSION) $< >config.h
179 $(OUT)intl_s.a: $(INTL.OBJECTS)
180 $(AR) $(ARFLAGS) $@ $^
182 $(OUT)intl.def: $(INTL.OBJECTS)
183 @echo LIBRARY INTL$(INTLDLLVER) INITINSTANCE TERMINSTANCE>$@
184 @echo DESCRIPTION "GNU gettext internationalization library version $(VERSION)">>$@
185 @echo DATA MULTIPLE NONSHARED>>$@
187 type backward.def>>$@
190 $(OUT)intl$(INTLDLLVER).dll: $(INTL.OBJECTS) $(OUT)intl.def
191 @echo *********************************************************
192 @echo *** YOU CAN SAFELY IGNORE WARNINGS FROM EMXBIND BELOW ***
193 @echo *********************************************************
194 $(LD) $(LDFLAGS.SHARED) -o $@ $^ $(LIBS)
199 # How to build an import library from a .DEF file
200 $(OUT)%.a: $(OUT)%.def
203 $(OUT)util.a: $(SRC.OBJECTS) $(LIB.OBJECTS)
204 $(AR) $(ARFLAGS) $@ $^
206 $(OUT)uniname.a: $(LIBUNINAME.OBJECTS)
207 $(AR) $(ARFLAGS) $@ $^
209 $(ROOT)src/po-gram-gen2.h: $(ROOT)src/po-gram-gen.h
210 sed -e "s/[yY][yY]/po_gram_/g" $< > $@
212 $(ROOT)intl/libintl.h: $(ROOT)intl/libgnuintl.h
215 $(ROOT)lib/stdbool.h: $(ROOT)lib/stdbool.h.in
218 gettext-os2-$(VERSION)-bin.zip: $(INSTALL.FILES)
222 # The following rules are for `make distr' target only
224 $(INST)share/locale/charset.alias: $(ROOT)lib/config.charset
225 $(UNIXSHELL) $< i386-pc-os2-emx >$@
226 $(INST)share/locale/locale.alias: $(ROOT)intl/locale.alias
228 $(INST)bin/% $(INST)lib/% $(INST)dll/%: $(OUT)%
230 $(INST)include/%: $(ROOT)intl/%
232 $(INST)doc/gettext-$(VERSION)/%: $(ROOT)%
234 $(INST)doc/gettext-$(VERSION)/% $(INST)include/%: %
236 $(INST)share/locale/%/LC_MESSAGES/gettext.mo: $(ROOT)po/%.po
238 $(COMSPEC) /c "$(subst /,\\,set BEGINLIBPATH=$(OUT:/=) && \
239 $(OUT)msgfmt.exe) --statistics --verbose -o $@ $<"