Home | History | Annotate | Line # | Download | only in os2
      1  1.1  christos #
      2  1.1  christos # OS/2 GNU Makefile for building gettext with GNU Make and GNU C compiler
      3  1.1  christos #
      4  1.1  christos # OS/2 still supports the regular configure/make building mechanism, but its
      5  1.1  christos # way more clumsy, complicated and error prone. It is highly recommended to
      6  1.1  christos # use this makefile instead, because :
      7  1.1  christos # - this makefile builds an optimized static and dynamic version of the
      8  1.1  christos #   library
      9  1.1  christos # - it is able to build both optimized and debug versions of the library
     10  1.1  christos #   without any reconfiguring
     11  1.1  christos # - this makefile builds an backward compatible DLL. When building with
     12  1.1  christos #   configure you will get a DLL which is compatible only with the 0.10.40
     13  1.1  christos #   and later DLLs of gettext; this makefile builds a DLL which is binary
     14  1.1  christos #   compatible with gettext 0.10.35 (exports by ordinal matter).
     15  1.1  christos # - it is able to generate a complete OS/2 binary distribution (make distr)
     16  1.1  christos # - besides its simply alot faster than configure generated makefiles
     17  1.1  christos #
     18  1.1  christos # The makefile is designed to be more or less gettext version independent,
     19  1.1  christos # so it is likely to work with future versions of gettext as well.
     20  1.1  christos #
     21  1.1  christos # If you get unresolved dependencies (e.g. "don't know how to make somefile.h
     22  1.1  christos # which is required for zzz.o) remove (or rebuild, if you have the makedep tool)
     23  1.1  christos # the depend.mak file which contains all the dependencies.
     24  1.1  christos #
     25  1.1  christos 
     26  1.1  christos # Use CMD.EXE as shell since its way faster
     27  1.1  christos SHELL = $(COMSPEC)
     28  1.1  christos # An Unix-like shell (needed for running config.charset)
     29  1.1  christos UNIXSHELL = sh.exe
     30  1.1  christos 
     31  1.1  christos # Debug mode (1) or optimize mode (0)
     32  1.1  christos DEBUG = 0
     33  1.1  christos 
     34  1.1  christos # The version of INTL.DLL (the name suffix)
     35  1.1  christos INTLDLLVER =
     36  1.1  christos 
     37  1.1  christos # Pack the DLL and executables with lxlite
     38  1.1  christos LXLITE = 1
     39  1.1  christos 
     40  1.1  christos # Output directory
     41  1.1  christos OUT = out/$(OUT.SUFFIX)/
     42  1.1  christos # Root package directory
     43  1.1  christos ROOT = ../
     44  1.1  christos # The base directory for distribution archive (emx/ or usr/)
     45  1.1  christos INST = emx/
     46  1.1  christos 
     47  1.1  christos # Tools
     48  1.1  christos CC = gcc -c
     49  1.1  christos CFLAGS = -Wall -Zmt $(INCLUDE) $(DEFS)
     50  1.1  christos INCLUDE = -I. -I$(ROOT) -I$(ROOT)intl -I$(ROOT)src -I$(ROOT)lib -I$(ROOT)libuniname
     51  1.1  christos DEFS = -DHAVE_CONFIG_H -DLIBDIR=\"/usr/lib\" \
     52  1.1  christos   -DLOCALEDIR=\"/usr/share/locale\" -DLOCALE_ALIAS_PATH=\"/usr/share/locale\" \
     53  1.1  christos   -DGETTEXTDATADIR=\"/usr/share/gettext\" \
     54  1.1  christos   -DPROJECTSDIR=\"/usr/share/gettext/projects\" \
     55  1.1  christos   -DGETTEXTJAR=\"/usr/share/gettext/gettext.jar\"
     56  1.1  christos 
     57  1.1  christos 
     58  1.1  christos LD = gcc
     59  1.1  christos LDFLAGS = -Zmt -Zcrtdll
     60  1.1  christos LDFLAGS.SHARED = -Zmt -Zcrtdll -Zdll
     61  1.1  christos LIBS = -liconv -liberty -lgcc
     62  1.1  christos 
     63  1.1  christos AR = ar
     64  1.1  christos ARFLAGS = crs
     65  1.1  christos 
     66  1.1  christos MKDIR = mkdir.exe -p
     67  1.1  christos COPY = cp -p
     68  1.1  christos 
     69  1.1  christos LINKINTL = $(OUT)intl.a
     70  1.1  christos 
     71  1.1  christos ifeq ($(DEBUG),0)
     72  1.1  christos   CFLAGS += -s -O2
     73  1.1  christos   LDFLAGS += -s -Zexe
     74  1.1  christos   LDFLAGS.SHARED += -s
     75  1.1  christos   OUT.SUFFIX = release
     76  1.1  christos else
     77  1.1  christos   CFLAGS += -g
     78  1.1  christos   LDFLAGS += -g -Zexe
     79  1.1  christos   LDFLAGS.SHARED += -g
     80  1.1  christos   OUT.SUFFIX = debug
     81  1.1  christos   LXLITE := 0
     82  1.1  christos   LINKINTL = $(OUT)intl_s.a
     83  1.1  christos endif
     84  1.1  christos 
     85  1.1  christos # Languages with encodings unsupported by OS/2 API (BIG5)
     86  1.1  christos BAD.LINGUAS=zh
     87  1.1  christos 
     88  1.1  christos # The list of languages to be included in binary distribution
     89  1.1  christos LINGUAS = $(filter-out $(BAD.LINGUAS),$(shell sed -e "/^\#/d" $(ROOT)po/LINGUAS))
     90  1.1  christos 
     91  1.1  christos # Fetch version number from configure.in
     92  1.1  christos VERSION = $(shell sed ../configure.in -ne "/AM_INIT_AUTOMAKE/{" -e "s/.*(gettext, *\\(.*\\))/\\1/" -e "p" -e "}")
     93  1.1  christos 
     94  1.1  christos # Fetch the list of source files for libintl from intl/Makefile.in
     95  1.1  christos INTL.SOURCES = $(addprefix $(ROOT)intl/,\
     96  1.1  christos   $(subst $$lo,c,\
     97  1.1  christos   $(subst @INTLOBJS@,intl-compat.c,\
     98  1.1  christos   $(subst OBJECTS = ,,\
     99  1.1  christos   $(subst \,,\
    100  1.1  christos   $(shell sed $(ROOT)intl/Makefile.in -ne "/^OBJECTS =/,/[^\]$$/p"))))))
    101  1.1  christos INTL.OBJECTS = $(addprefix $(OUT),$(subst $(ROOT),,$(INTL.SOURCES:.c=.o)))
    102  1.1  christos 
    103  1.1  christos PROGRAMS = $(addsuffix .exe,$(subst bin_PROGRAMS = ,,\
    104  1.1  christos   $(subst \,,\
    105  1.1  christos   $(shell sed $(ROOT)src/Makefile.am -ne "/^bin_PROGRAMS =/,/[^\]$$/p"))))
    106  1.1  christos PROGRAMS.EXE = $(addprefix $(OUT),$(PROGRAMS))
    107  1.1  christos SRC.SOURCES = $(filter-out $(addprefix $(ROOT)src/,$(PROGRAMS:.exe=.c)),\
    108  1.1  christos   $(wildcard $(ROOT)src/*.c))
    109  1.1  christos SRC.OBJECTS = $(addprefix $(OUT),$(subst $(ROOT),,$(SRC.SOURCES:.c=.o)))
    110  1.1  christos LIB.SOURCES = $(addprefix $(ROOT)lib/, error.c stpcpy.c stpncpy.c mkdtemp.c getline.c \
    111  1.1  christos   $(subst libgettextlib_la_SOURCES = ,,\
    112  1.1  christos   $(subst \,,\
    113  1.1  christos   $(patsubst %.h,,\
    114  1.1  christos   $(patsubst getopt%.c,,\
    115  1.1  christos   $(shell sed $(ROOT)lib/Makefile.am -ne "/^libgettextlib_la_SOURCES =/,/[^\]$$/p"))))))
    116  1.1  christos LIB.OBJECTS = $(addprefix $(OUT),$(subst $(ROOT),,$(LIB.SOURCES:.c=.o)))
    117  1.1  christos 
    118  1.1  christos LIBUNINAME.SOURCES = $(addprefix $(ROOT)libuniname/, \
    119  1.1  christos   $(subst libuniname_a_SOURCES = ,,\
    120  1.1  christos   $(subst \,,\
    121  1.1  christos   $(patsubst %.h,,\
    122  1.1  christos   $(shell sed $(ROOT)libuniname/Makefile.am -ne "/^libuniname_a_SOURCES =/,/^$$/p")))))
    123  1.1  christos LIBUNINAME.OBJECTS = $(addprefix $(OUT),$(subst $(ROOT),,$(LIBUNINAME.SOURCES:.c=.o)))
    124  1.1  christos 
    125  1.1  christos OUTDIRS = $(OUT) $(sort $(dir $(INTL.OBJECTS) $(SRC.OBJECTS) $(LIB.OBJECTS) \
    126  1.1  christos   $(LIBUNINAME.OBJECTS) $(INSTALL.FILES)))
    127  1.1  christos 
    128  1.1  christos INSTALL.FILES = $(addprefix $(INST)bin/,$(PROGRAMS)) \
    129  1.1  christos   $(INST)lib/intl.a $(INST)lib/intl_s.a $(INST)include/libintl.h \
    130  1.1  christos   $(INST)dll/intl.dll $(INST)share/locale/charset.alias \
    131  1.1  christos   $(INST)share/locale/locale.alias $(INST)doc/gettext-$(VERSION)/README.OS2 \
    132  1.1  christos   $(INST)doc/gettext-$(VERSION)/COPYING $(INST)doc/gettext-$(VERSION)/README \
    133  1.1  christos   $(addsuffix /LC_MESSAGES/gettext.mo,$(addprefix $(INST)share/locale/,$(LINGUAS))) \
    134  1.1  christos   $(INSTALL.DIFF)
    135  1.1  christos 
    136  1.1  christos .SUFFIXES:
    137  1.1  christos .SUFFIXES: .o .a .def .exe .dll .po .mo
    138  1.1  christos .PRECIOUS: $(OUT)%.o $(OUT)%.a
    139  1.1  christos 
    140  1.1  christos .PHONY: all depend clean distr rmzip
    141  1.1  christos 
    142  1.1  christos $(OUT)%.o: $(ROOT)%.c
    143  1.1  christos 	$(CC) $(CFLAGS) -o $@ $<
    144  1.1  christos 
    145  1.1  christos # To avoid playing with object file lists for every program we will build
    146  1.1  christos # instead a library containing all the object files from src directory, and
    147  1.1  christos # then link the library against the main program module, so that linker can
    148  1.1  christos # pull all the required functions from there
    149  1.1  christos $(OUT)%.exe: $(OUT)src/%.o $(OUT)util.a $(OUT)uniname.a $(LINKINTL)
    150  1.1  christos 	$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
    151  1.1  christos ifeq ($(LXLITE),1)
    152  1.1  christos 	lxlite /b- $@
    153  1.1  christos endif
    154  1.1  christos 
    155  1.1  christos all: config.h $(OUTDIRS) $(ROOT)src/po-gram-gen2.h $(ROOT)lib/stdbool.h \
    156  1.1  christos   $(ROOT)intl/libintl.h $(OUT)intl.a $(OUT)intl_s.a $(OUT)intl$(INTLDLLVER).dll \
    157  1.1  christos   $(PROGRAMS.EXE)
    158  1.1  christos 
    159  1.1  christos define MAKEDEP
    160  1.1  christos 	echo $(OUT)PATH = FILENAME
    161  1.1  christos 	makedep $(INCLUDE) $(DEFS) -p $$(OUT)PATH -r -a FILENAME -c -f depend.mak
    162  1.1  christos 
    163  1.1  christos endef
    164  1.1  christos 
    165  1.1  christos depend: $(INTL.SOURCES) $(SRC.SOURCES)
    166  1.1  christos # Remove all dependencies
    167  1.1  christos 	rm -f depend.mak
    168  1.1  christos # Build dependencies, by one file (to avoid 1024 chars command line length limit)
    169  1.1  christos 	@$(foreach fn,$^,$(subst PATH,$(subst ../,,$(dir $(fn))),$(subst FILENAME,$(fn),$(MAKEDEP))))
    170  1.1  christos 
    171  1.1  christos clean:
    172  1.1  christos 	rm -rf out emx config.h
    173  1.1  christos 
    174  1.1  christos distr: all rmzip gettext-os2-$(VERSION)-bin.zip
    175  1.1  christos 
    176  1.1  christos rmzip:
    177  1.1  christos 	rm -f gettext-os2-$(VERSION)-bin.zip
    178  1.1  christos 
    179  1.1  christos # How to configure without configure...
    180  1.1  christos config.h: ../config.h.in ./configure.awk
    181  1.1  christos 	gawk -f configure.awk -v PACKAGE=gettext -v VERSION=$(VERSION) $< >config.h
    182  1.1  christos 
    183  1.1  christos $(OUTDIRS):
    184  1.1  christos 	$(MKDIR) $(@:/=)
    185  1.1  christos 
    186  1.1  christos $(OUT)intl_s.a: $(INTL.OBJECTS)
    187  1.1  christos 	$(AR) $(ARFLAGS) $@ $^
    188  1.1  christos 
    189  1.1  christos $(OUT)intl.def: $(INTL.OBJECTS)
    190  1.1  christos 	@echo LIBRARY INTL$(INTLDLLVER) INITINSTANCE TERMINSTANCE>$@
    191  1.1  christos 	@echo DESCRIPTION "GNU gettext internationalization library version $(VERSION)">>$@
    192  1.1  christos 	@echo DATA MULTIPLE NONSHARED>>$@
    193  1.1  christos 	@echo EXPORTS>>$@
    194  1.1  christos 	type backward.def>>$@
    195  1.1  christos 	emxexp -u $^ >>$@
    196  1.1  christos 
    197  1.1  christos $(OUT)intl$(INTLDLLVER).dll: $(INTL.OBJECTS) $(OUT)intl.def
    198  1.1  christos 	@echo *********************************************************
    199  1.1  christos 	@echo *** YOU CAN SAFELY IGNORE WARNINGS FROM EMXBIND BELOW ***
    200  1.1  christos 	@echo *********************************************************
    201  1.1  christos 	$(LD) $(LDFLAGS.SHARED) -o $@ $^ $(LIBS)
    202  1.1  christos ifeq ($(LXLITE),1)
    203  1.1  christos 	lxlite $@
    204  1.1  christos endif
    205  1.1  christos 
    206  1.1  christos # How to build an import library from a .DEF file
    207  1.1  christos $(OUT)%.a: $(OUT)%.def
    208  1.1  christos 	emximp -o $@ $<
    209  1.1  christos 
    210  1.1  christos $(OUT)util.a: $(SRC.OBJECTS) $(LIB.OBJECTS)
    211  1.1  christos 	$(AR) $(ARFLAGS) $@ $^
    212  1.1  christos 
    213  1.1  christos $(OUT)uniname.a: $(LIBUNINAME.OBJECTS)
    214  1.1  christos 	$(AR) $(ARFLAGS) $@ $^
    215  1.1  christos 
    216  1.1  christos $(ROOT)src/po-gram-gen2.h: $(ROOT)src/po-gram-gen.h
    217  1.1  christos 	sed -e "s/[yY][yY]/po_gram_/g" $< > $@
    218  1.1  christos 
    219  1.1  christos $(ROOT)intl/libintl.h: $(ROOT)intl/libgnuintl.h 
    220  1.1  christos 	$(COPY) $< $@
    221  1.1  christos 
    222  1.1  christos $(ROOT)lib/stdbool.h: $(ROOT)lib/stdbool.h.in
    223  1.1  christos 	$(COPY) $< $@
    224  1.1  christos 
    225  1.1  christos gettext-os2-$(VERSION)-bin.zip: $(INSTALL.FILES)
    226  1.1  christos 	@rm -f $@
    227  1.1  christos 	zip -9XD $@ $^
    228  1.1  christos 
    229  1.1  christos # The following rules are for `make distr' target only
    230  1.1  christos 
    231  1.1  christos $(INST)share/locale/charset.alias: $(ROOT)lib/config.charset
    232  1.1  christos 	$(UNIXSHELL) $< i386-pc-os2-emx >$@
    233  1.1  christos $(INST)share/locale/locale.alias: $(ROOT)intl/locale.alias
    234  1.1  christos 	$(COPY) $< $@
    235  1.1  christos $(INST)bin/% $(INST)lib/% $(INST)dll/%: $(OUT)%
    236  1.1  christos 	$(COPY) $< $@
    237  1.1  christos $(INST)include/%: $(ROOT)intl/%
    238  1.1  christos 	$(COPY) $< $@
    239  1.1  christos $(INST)doc/gettext-$(VERSION)/%: $(ROOT)%
    240  1.1  christos 	$(COPY) $< $@
    241  1.1  christos $(INST)doc/gettext-$(VERSION)/% $(INST)include/%: %
    242  1.1  christos 	$(COPY) $< $@
    243  1.1  christos $(INST)share/locale/%/LC_MESSAGES/gettext.mo: $(ROOT)po/%.po
    244  1.1  christos 	$(MKDIR) $(dir $@)
    245  1.1  christos 	$(COMSPEC) /c "$(subst /,\\,set BEGINLIBPATH=$(OUT:/=) && \
    246  1.1  christos 	  $(OUT)msgfmt.exe) --statistics --verbose -o $@ $<"
    247  1.1  christos 
    248  1.1  christos -include depend.mak
    249