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
-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
\"
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 LIBUNINAME.SOURCES
= $(addprefix $(ROOT
)libuniname
/, \
119 $(subst libuniname_a_SOURCES
= ,,\
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
))) \
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
)
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 \
160 echo
$(OUT
)PATH
= FILENAME
161 makedep
$(INCLUDE
) $(DEFS
) -p
$$(OUT
)PATH
-r
-a FILENAME
-c
-f depend.mak
165 depend
: $(INTL.SOURCES
) $(SRC.SOURCES
)
166 # Remove all dependencies
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
))))
172 rm -rf out emx config.h
174 distr
: all rmzip gettext-os2-
$(VERSION
)-bin.zip
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
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
>>$@
194 type backward.def
>>$@
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
)
206 # How to build an import library from a .DEF file
207 $(OUT
)%.a
: $(OUT
)%.def
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
222 $(ROOT
)lib
/stdbool.h
: $(ROOT
)lib
/stdbool.h.in
225 gettext-os2-
$(VERSION
)-bin.zip
: $(INSTALL.FILES
)
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
235 $(INST
)bin
/% $(INST
)lib
/% $(INST
)dll
/%: $(OUT
)%
237 $(INST
)include/%: $(ROOT
)intl
/%
239 $(INST
)doc
/gettext-
$(VERSION
)/%: $(ROOT
)%
241 $(INST
)doc
/gettext-
$(VERSION
)/% $(INST
)include/%: %
243 $(INST
)share
/locale
/%/LC_MESSAGES
/gettext.mo
: $(ROOT
)po
/%.po
245 $(COMSPEC
) /c
"$(subst /,\\,set BEGINLIBPATH=$(OUT:/=) && \
246 $(OUT)msgfmt.exe) --statistics --verbose -o $@ $<"