# Makefile for library files used by GNU shell utilities.
# Do not use this makefile directly, but only from `../Makefile'.
# Copyright (C) 1991 Free Software Foundation, Inc.

OBJECTS = basename$O error$O stripslash$O xmalloc$O xstrdup$O \
putenv$O getopt$O getopt1$O getdate$O posixtm$O utsname$O stime$O \
gethostname$O xgethostname$O xgetcwd$O strftime$O full-write$O
REGEX = regex$O

.SUFFIXES: .c $O

.c$O:
	$(CC) $(CFLAGS) -c $<

.PHONY: lib dll
lib: shu.a
dll: shu.lib gnushu.dll regex.lib gnuregex.dll

shu.a: $(OBJECTS) $(REGEX)
	rm -f $@
	$(AR) r $@ $(OBJECTS) $(REGEX)
	$(RANLIB) $@

shu.lib: gnushu.def
	emximp -o libshu.imp gnushu.def
	emximp -o $@ libshu.imp
	rm -f libshu.imp

regex.lib: gnuregex.def
	emximp -o libregex.imp gnuregex.def
	emximp -o $@ libregex.imp
	rm -f libregex.imp

gnushu.dll: gnushu.def $(OBJECTS)
	$(CC) -Zdll gnushu.def -o $@ $(OBJECTS)

gnuregex.dll: gnuregex.def $(REGEX)
	$(CC) -Zdll gnuregex.def -o $@ $(REGEX)

getdate.c: getdate.y
	@echo expect 8 shift/reduce conflicts
	bison -o getdate.c getdate.y

# Make the rename atomic, in case sed is interrupted and later rerun.
posixtm.c: posixtm.y
	bison -o posixtm.tab.c posixtm.y
	sed -e "s/yy/zz/g" posixtm.tab.c > $@
	rm -f posixtm.tab.c

getopt1$O: getopt.h
regex$O: regex.h

clean:
	rm -f *.o *.obj *.a *.lib *.imp
