#
# This makefile will create OMF libraries from A.OUT-format libraries
# The libraries will only be created if the timestamp of OMF library
# is earlier than on the a.out library or the OMF library is missing.
#

SHELL=$(COMSPEC)
.SUFFIXES: .a .lib
.PHONY: all

AOUT.LIBS=$(wildcard *.a st/*.a mt/*.a)
OMF.LIBS=$(AOUT.LIBS:.a=.lib)

%.lib: %.a
	emxomf -w -o $@ $<

all: os2.a os2_p.a $(OMF.LIBS)

define ADDMEMBERS
	emximp __EMXIMPFLAGS__ -o _tmp_.a unicode.imp
	if exist _tmp_ rm -rf _tmp_
	mkdir _tmp_ && cd _tmp_ && ar x ../_tmp_.a && ren IMPORT* UNICDE*
	rm -f _tmp_.a
	ar r $@ _tmp_/*.*
	rm -rf _tmp_
endef

os2.a: unicode.imp
	$(subst __EMXIMPFLAGS__,,$(ADDMEMBERS))

os2_p.a: unicode.imp
	$(subst __EMXIMPFLAGS__,-m,$(ADDMEMBERS))
