source: trunk/third/gettext2/os2/Makefile @ 22167

Revision 22167, 8.0 KB checked in by ghudson, 19 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r22166, which included commits to RCS files with non-trunk default branches.
Line 
1#
2# OS/2 GNU Makefile for building gettext with GNU Make and GNU C compiler
3#
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
17#
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.
20#
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.
24#
25
26# Use CMD.EXE as shell since its way faster
27SHELL = $(COMSPEC)
28# An Unix-like shell (needed for running config.charset)
29UNIXSHELL = sh.exe
30
31# Debug mode (1) or optimize mode (0)
32DEBUG = 0
33
34# The version of INTL.DLL (the name suffix)
35INTLDLLVER =
36
37# Pack the DLL and executables with lxlite
38LXLITE = 1
39
40# Output directory
41OUT = out/$(OUT.SUFFIX)/
42# Root package directory
43ROOT = ../
44# The base directory for distribution archive (emx/ or usr/)
45INST = emx/
46
47# Tools
48CC = gcc -c
49CFLAGS = -Wall -Zmt $(INCLUDE) $(DEFS)
50INCLUDE = -I. -I$(ROOT) -I$(ROOT)intl -I$(ROOT)src -I$(ROOT)lib -I$(ROOT)libuniname
51DEFS = -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\"
56
57
58LD = gcc
59LDFLAGS = -Zmt -Zcrtdll
60LDFLAGS.SHARED = -Zmt -Zcrtdll -Zdll
61LIBS = -liconv -liberty -lgcc
62
63AR = ar
64ARFLAGS = crs
65
66MKDIR = mkdir.exe -p
67COPY = cp -p
68
69LINKINTL = $(OUT)intl.a
70
71ifeq ($(DEBUG),0)
72  CFLAGS += -s -O2
73  LDFLAGS += -s -Zexe
74  LDFLAGS.SHARED += -s
75  OUT.SUFFIX = release
76else
77  CFLAGS += -g
78  LDFLAGS += -g -Zexe
79  LDFLAGS.SHARED += -g
80  OUT.SUFFIX = debug
81  LXLITE := 0
82  LINKINTL = $(OUT)intl_s.a
83endif
84
85# Languages with encodings unsupported by OS/2 API (BIG5)
86BAD.LINGUAS=zh
87
88# The list of languages to be included in binary distribution
89LINGUAS = $(filter-out $(BAD.LINGUAS),$(shell sed -e "/^\#/d" $(ROOT)po/LINGUAS))
90
91# Fetch version number from configure.in
92VERSION = $(shell sed ../configure.in -ne "/AM_INIT_AUTOMAKE/{" -e "s/.*(gettext, *\\(.*\\))/\\1/" -e "p" -e "}")
93
94# Fetch the list of source files for libintl from intl/Makefile.in
95INTL.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"))))))
101INTL.OBJECTS = $(addprefix $(OUT),$(subst $(ROOT),,$(INTL.SOURCES:.c=.o)))
102
103PROGRAMS = $(addsuffix .exe,$(subst bin_PROGRAMS = ,,\
104  $(subst \,,\
105  $(shell sed $(ROOT)src/Makefile.am -ne "/^bin_PROGRAMS =/,/[^\]$$/p"))))
106PROGRAMS.EXE = $(addprefix $(OUT),$(PROGRAMS))
107SRC.SOURCES = $(filter-out $(addprefix $(ROOT)src/,$(PROGRAMS:.exe=.c)),\
108  $(wildcard $(ROOT)src/*.c))
109SRC.OBJECTS = $(addprefix $(OUT),$(subst $(ROOT),,$(SRC.SOURCES:.c=.o)))
110LIB.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"))))))
116LIB.OBJECTS = $(addprefix $(OUT),$(subst $(ROOT),,$(LIB.SOURCES:.c=.o)))
117
118LIBUNINAME.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")))))
123LIBUNINAME.OBJECTS = $(addprefix $(OUT),$(subst $(ROOT),,$(LIBUNINAME.SOURCES:.c=.o)))
124
125OUTDIRS = $(OUT) $(sort $(dir $(INTL.OBJECTS) $(SRC.OBJECTS) $(LIB.OBJECTS) \
126  $(LIBUNINAME.OBJECTS) $(INSTALL.FILES)))
127
128INSTALL.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)
135
136.SUFFIXES:
137.SUFFIXES: .o .a .def .exe .dll .po .mo
138.PRECIOUS: $(OUT)%.o $(OUT)%.a
139
140.PHONY: all depend clean distr rmzip
141
142$(OUT)%.o: $(ROOT)%.c
143        $(CC) $(CFLAGS) -o $@ $<
144
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)
151ifeq ($(LXLITE),1)
152        lxlite /b- $@
153endif
154
155all: 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)
158
159define MAKEDEP
160        echo $(OUT)PATH = FILENAME
161        makedep $(INCLUDE) $(DEFS) -p $$(OUT)PATH -r -a FILENAME -c -f depend.mak
162
163endef
164
165depend: $(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))))
170
171clean:
172        rm -rf out emx config.h
173
174distr: all rmzip gettext-os2-$(VERSION)-bin.zip
175
176rmzip:
177        rm -f gettext-os2-$(VERSION)-bin.zip
178
179# How to configure without configure...
180config.h: ../config.h.in ./configure.awk
181        gawk -f configure.awk -v PACKAGE=gettext -v VERSION=$(VERSION) $< >config.h
182
183$(OUTDIRS):
184        $(MKDIR) $(@:/=)
185
186$(OUT)intl_s.a: $(INTL.OBJECTS)
187        $(AR) $(ARFLAGS) $@ $^
188
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 $^ >>$@
196
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)
202ifeq ($(LXLITE),1)
203        lxlite $@
204endif
205
206# How to build an import library from a .DEF file
207$(OUT)%.a: $(OUT)%.def
208        emximp -o $@ $<
209
210$(OUT)util.a: $(SRC.OBJECTS) $(LIB.OBJECTS)
211        $(AR) $(ARFLAGS) $@ $^
212
213$(OUT)uniname.a: $(LIBUNINAME.OBJECTS)
214        $(AR) $(ARFLAGS) $@ $^
215
216$(ROOT)src/po-gram-gen2.h: $(ROOT)src/po-gram-gen.h
217        sed -e "s/[yY][yY]/po_gram_/g" $< > $@
218
219$(ROOT)intl/libintl.h: $(ROOT)intl/libgnuintl.h
220        $(COPY) $< $@
221
222$(ROOT)lib/stdbool.h: $(ROOT)lib/stdbool.h.in
223        $(COPY) $< $@
224
225gettext-os2-$(VERSION)-bin.zip: $(INSTALL.FILES)
226        @rm -f $@
227        zip -9XD $@ $^
228
229# The following rules are for `make distr' target only
230
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 $@ $<"
247
248-include depend.mak
Note: See TracBrowser for help on using the repository browser.