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 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 118OUTDIRS = $(OUT) $(sort $(dir $(INTL.OBJECTS) $(SRC.OBJECTS) $(LIB.OBJECTS) \ 119 $(LIBUNINAME.OBJECTS) $(INSTALL.FILES))) 120 121INSTALL.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))) \ 127 $(INSTALL.DIFF) 128 129.SUFFIXES: 130.SUFFIXES: .o .a .def .exe .dll .po .mo 131.PRECIOUS: $(OUT)%.o $(OUT)%.a 132 133.PHONY: all depend clean distr rmzip 134 135$(OUT)%.o: $(ROOT)%.c 136 $(CC) $(CFLAGS) -o $@ $< 137 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) 144ifeq ($(LXLITE),1) 145 lxlite /b- $@ 146endif 147 148all: 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 \ 150 $(PROGRAMS.EXE) 151 152define MAKEDEP 153 echo $(OUT)PATH = FILENAME 154 makedep $(INCLUDE) $(DEFS) -p $$(OUT)PATH -r -a FILENAME -c -f depend.mak 155 156endef 157 158depend: $(INTL.SOURCES) $(SRC.SOURCES) 159# Remove all dependencies 160 rm -f depend.mak 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)))) 163 164clean: 165 rm -rf out emx config.h 166 167distr: all rmzip gettext-os2-$(VERSION)-bin.zip 168 169rmzip: 170 rm -f gettext-os2-$(VERSION)-bin.zip 171 172# How to configure without configure... 173config.h: ../config.h.in ./configure.awk 174 gawk -f configure.awk -v PACKAGE=gettext -v VERSION=$(VERSION) $< >config.h 175 176$(OUTDIRS): 177 $(MKDIR) $(@:/=) 178 179$(OUT)intl_s.a: $(INTL.OBJECTS) 180 $(AR) $(ARFLAGS) $@ $^ 181 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>>$@ 186 @echo EXPORTS>>$@ 187 type backward.def>>$@ 188 emxexp -u $^ >>$@ 189 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) 195ifeq ($(LXLITE),1) 196 lxlite $@ 197endif 198 199# How to build an import library from a .DEF file 200$(OUT)%.a: $(OUT)%.def 201 emximp -o $@ $< 202 203$(OUT)util.a: $(SRC.OBJECTS) $(LIB.OBJECTS) 204 $(AR) $(ARFLAGS) $@ $^ 205 206$(OUT)uniname.a: $(LIBUNINAME.OBJECTS) 207 $(AR) $(ARFLAGS) $@ $^ 208 209$(ROOT)src/po-gram-gen2.h: $(ROOT)src/po-gram-gen.h 210 sed -e "s/[yY][yY]/po_gram_/g" $< > $@ 211 212$(ROOT)intl/libintl.h: $(ROOT)intl/libgnuintl.h 213 $(COPY) $< $@ 214 215$(ROOT)lib/stdbool.h: $(ROOT)lib/stdbool.h.in 216 $(COPY) $< $@ 217 218gettext-os2-$(VERSION)-bin.zip: $(INSTALL.FILES) 219 @rm -f $@ 220 zip -9XD $@ $^ 221 222# The following rules are for `make distr' target only 223 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 227 $(COPY) $< $@ 228$(INST)bin/% $(INST)lib/% $(INST)dll/%: $(OUT)% 229 $(COPY) $< $@ 230$(INST)include/%: $(ROOT)intl/% 231 $(COPY) $< $@ 232$(INST)doc/gettext-$(VERSION)/%: $(ROOT)% 233 $(COPY) $< $@ 234$(INST)doc/gettext-$(VERSION)/% $(INST)include/%: % 235 $(COPY) $< $@ 236$(INST)share/locale/%/LC_MESSAGES/gettext.mo: $(ROOT)po/%.po 237 $(MKDIR) $(dir $@) 238 $(COMSPEC) /c "$(subst /,\\,set BEGINLIBPATH=$(OUT:/=) && \ 239 $(OUT)msgfmt.exe) --statistics --verbose -o $@ $<" 240 241-include depend.mak 242