CFLAGS = -g -Wall
RANLIB = ranlib
OS != uname -s

sources = lrmi.c lrmi.h
objects = lrmi.o
pic_objects = lrmi.lo
all = liblrmi.a liblrmi.so vbetest
.if ${OS}=="NetBSD" || ${OS}=="OpenBSD"
libs=	-li386
.endif

all: $(all)

.c.o:
	$(CC) -c $(CPPFLAGS) $(CFLAGS) -o ${.TARGET} ${.IMPSRC}

.SUFFIXES: .lo
.c.lo:
	$(CC) -c $(CPPFLAGS) $(CFLAGS) -fPIC -o ${.TARGET} ${.IMPSRC}

liblrmi.a: $(objects)
	$(AR) -r ${.TARGET} ${.ALLSRC}
	$(RANLIB) ${.TARGET}

liblrmi.so: $(pic_objects)
	$(CC) $(CPPFLAGS) $(CFLAGS) -fPIC -shared -o ${.TARGET} ${.ALLSRC} ${libs}

vbetest: vbetest.o liblrmi.a
	$(CC) $(CPPFLAGS) $(CFLAGS) -o ${.TARGET} ${.ALLSRC} ${libs}

.PHONY: clean
clean:
	rm -f $(objects) $(pic_objects) vbetest.o $(all) *.core
