Sync usage with man page.
[netbsd-mini2440.git] / gnu / dist / gettext / os2 / Makefile
blobcb31fb4b1135161f2c3ed2dcdde91b515ea56e03
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
8 # library
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
27 SHELL = $(COMSPEC)
28 # An Unix-like shell (needed for running config.charset)
29 UNIXSHELL = sh.exe
31 # Debug mode (1) or optimize mode (0)
32 DEBUG = 0
34 # The version of INTL.DLL (the name suffix)
35 INTLDLLVER =
37 # Pack the DLL and executables with lxlite
38 LXLITE = 1
40 # Output directory
41 OUT = out/$(OUT.SUFFIX)/
42 # Root package directory
43 ROOT = ../
44 # The base directory for distribution archive (emx/ or usr/)
45 INST = emx/
47 # Tools
48 CC = gcc -c
49 CFLAGS = -Wall -Zmt $(INCLUDE) $(DEFS)
50 INCLUDE = -I. -I$(ROOT) -I$(ROOT)intl -I$(ROOT)src -I$(ROOT)lib -I$(ROOT)libuniname
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\"
58 LD = gcc
59 LDFLAGS = -Zmt -Zcrtdll
60 LDFLAGS.SHARED = -Zmt -Zcrtdll -Zdll
61 LIBS = -liconv -liberty -lgcc
63 AR = ar
64 ARFLAGS = crs
66 MKDIR = mkdir.exe -p
67 COPY = cp -p
69 LINKINTL = $(OUT)intl.a
71 ifeq ($(DEBUG),0)
72 CFLAGS += -s -O2
73 LDFLAGS += -s -Zexe
74 LDFLAGS.SHARED += -s
75 OUT.SUFFIX = release
76 else
77 CFLAGS += -g
78 LDFLAGS += -g -Zexe
79 LDFLAGS.SHARED += -g
80 OUT.SUFFIX = debug
81 LXLITE := 0
82 LINKINTL = $(OUT)intl_s.a
83 endif
85 # Languages with encodings unsupported by OS/2 API (BIG5)
86 BAD.LINGUAS=zh
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/,\
96 $(subst $$lo,c,\
97 $(subst @INTLOBJS@,intl-compat.c,\
98 $(subst OBJECTS = ,,\
99 $(subst \,,\
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 = ,,\
104 $(subst \,,\
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 = ,,\
112 $(subst \,,\
113 $(patsubst %.h,,\
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 LIBUNINAME.SOURCES = $(addprefix $(ROOT)libuniname/, \
119 $(subst libuniname_a_SOURCES = ,,\
120 $(subst \,,\
121 $(patsubst %.h,,\
122 $(shell sed $(ROOT)libuniname/Makefile.am -ne "/^libuniname_a_SOURCES =/,/^$$/p")))))
123 LIBUNINAME.OBJECTS = $(addprefix $(OUT),$(subst $(ROOT),,$(LIBUNINAME.SOURCES:.c=.o)))
125 OUTDIRS = $(OUT) $(sort $(dir $(INTL.OBJECTS) $(SRC.OBJECTS) $(LIB.OBJECTS) \
126 $(LIBUNINAME.OBJECTS) $(INSTALL.FILES)))
128 INSTALL.FILES = $(addprefix $(INST)bin/,$(PROGRAMS)) \
129 $(INST)lib/intl.a $(INST)lib/intl_s.a $(INST)include/libintl.h \
130 $(INST)dll/intl.dll $(INST)share/locale/charset.alias \
131 $(INST)share/locale/locale.alias $(INST)doc/gettext-$(VERSION)/README.OS2 \
132 $(INST)doc/gettext-$(VERSION)/COPYING $(INST)doc/gettext-$(VERSION)/README \
133 $(addsuffix /LC_MESSAGES/gettext.mo,$(addprefix $(INST)share/locale/,$(LINGUAS))) \
134 $(INSTALL.DIFF)
136 .SUFFIXES:
137 .SUFFIXES: .o .a .def .exe .dll .po .mo
138 .PRECIOUS: $(OUT)%.o $(OUT)%.a
140 .PHONY: all depend clean distr rmzip
142 $(OUT)%.o: $(ROOT)%.c
143 $(CC) $(CFLAGS) -o $@ $<
145 # To avoid playing with object file lists for every program we will build
146 # instead a library containing all the object files from src directory, and
147 # then link the library against the main program module, so that linker can
148 # pull all the required functions from there
149 $(OUT)%.exe: $(OUT)src/%.o $(OUT)util.a $(OUT)uniname.a $(LINKINTL)
150 $(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
151 ifeq ($(LXLITE),1)
152 lxlite /b- $@
153 endif
155 all: config.h $(OUTDIRS) $(ROOT)src/po-gram-gen2.h $(ROOT)lib/stdbool.h \
156 $(ROOT)intl/libintl.h $(OUT)intl.a $(OUT)intl_s.a $(OUT)intl$(INTLDLLVER).dll \
157 $(PROGRAMS.EXE)
159 define MAKEDEP
160 echo $(OUT)PATH = FILENAME
161 makedep $(INCLUDE) $(DEFS) -p $$(OUT)PATH -r -a FILENAME -c -f depend.mak
163 endef
165 depend: $(INTL.SOURCES) $(SRC.SOURCES)
166 # Remove all dependencies
167 rm -f depend.mak
168 # Build dependencies, by one file (to avoid 1024 chars command line length limit)
169 @$(foreach fn,$^,$(subst PATH,$(subst ../,,$(dir $(fn))),$(subst FILENAME,$(fn),$(MAKEDEP))))
171 clean:
172 rm -rf out emx config.h
174 distr: all rmzip gettext-os2-$(VERSION)-bin.zip
176 rmzip:
177 rm -f gettext-os2-$(VERSION)-bin.zip
179 # How to configure without configure...
180 config.h: ../config.h.in ./configure.awk
181 gawk -f configure.awk -v PACKAGE=gettext -v VERSION=$(VERSION) $< >config.h
183 $(OUTDIRS):
184 $(MKDIR) $(@:/=)
186 $(OUT)intl_s.a: $(INTL.OBJECTS)
187 $(AR) $(ARFLAGS) $@ $^
189 $(OUT)intl.def: $(INTL.OBJECTS)
190 @echo LIBRARY INTL$(INTLDLLVER) INITINSTANCE TERMINSTANCE>$@
191 @echo DESCRIPTION "GNU gettext internationalization library version $(VERSION)">>$@
192 @echo DATA MULTIPLE NONSHARED>>$@
193 @echo EXPORTS>>$@
194 type backward.def>>$@
195 emxexp -u $^ >>$@
197 $(OUT)intl$(INTLDLLVER).dll: $(INTL.OBJECTS) $(OUT)intl.def
198 @echo *********************************************************
199 @echo *** YOU CAN SAFELY IGNORE WARNINGS FROM EMXBIND BELOW ***
200 @echo *********************************************************
201 $(LD) $(LDFLAGS.SHARED) -o $@ $^ $(LIBS)
202 ifeq ($(LXLITE),1)
203 lxlite $@
204 endif
206 # How to build an import library from a .DEF file
207 $(OUT)%.a: $(OUT)%.def
208 emximp -o $@ $<
210 $(OUT)util.a: $(SRC.OBJECTS) $(LIB.OBJECTS)
211 $(AR) $(ARFLAGS) $@ $^
213 $(OUT)uniname.a: $(LIBUNINAME.OBJECTS)
214 $(AR) $(ARFLAGS) $@ $^
216 $(ROOT)src/po-gram-gen2.h: $(ROOT)src/po-gram-gen.h
217 sed -e "s/[yY][yY]/po_gram_/g" $< > $@
219 $(ROOT)intl/libintl.h: $(ROOT)intl/libgnuintl.h
220 $(COPY) $< $@
222 $(ROOT)lib/stdbool.h: $(ROOT)lib/stdbool.h.in
223 $(COPY) $< $@
225 gettext-os2-$(VERSION)-bin.zip: $(INSTALL.FILES)
226 @rm -f $@
227 zip -9XD $@ $^
229 # The following rules are for `make distr' target only
231 $(INST)share/locale/charset.alias: $(ROOT)lib/config.charset
232 $(UNIXSHELL) $< i386-pc-os2-emx >$@
233 $(INST)share/locale/locale.alias: $(ROOT)intl/locale.alias
234 $(COPY) $< $@
235 $(INST)bin/% $(INST)lib/% $(INST)dll/%: $(OUT)%
236 $(COPY) $< $@
237 $(INST)include/%: $(ROOT)intl/%
238 $(COPY) $< $@
239 $(INST)doc/gettext-$(VERSION)/%: $(ROOT)%
240 $(COPY) $< $@
241 $(INST)doc/gettext-$(VERSION)/% $(INST)include/%: %
242 $(COPY) $< $@
243 $(INST)share/locale/%/LC_MESSAGES/gettext.mo: $(ROOT)po/%.po
244 $(MKDIR) $(dir $@)
245 $(COMSPEC) /c "$(subst /,\\,set BEGINLIBPATH=$(OUT:/=) && \
246 $(OUT)msgfmt.exe) --statistics --verbose -o $@ $<"
248 -include depend.mak