MKDIR=mkdir -p
CP=cp
PREFIX=/usr/local
LIBDIR=$(install_root)$(DESTDIR)$(PREFIX)/lib
INCDIR=$(install_root)$(DESTDIR)$(PREFIX)/include/libpsrand
CFLAGS_DEBUG = -Wall -g -std=c89 --pedantic
CFLAGS = -I.. $(CFLAGS_DEBUG)

OBJS = minstd.o mtw.o xorshift.o


all: $(OBJS)

minstd.o: minstd.c minstd.h

mtw.o: mtw.c mtw.h

xorshift.o: xorshift.c xorshift.h

static: libpsrand.a

libpsrand.a: $(OBJS)
	-rm libpsrand.a
	ar r libpsrand.a $(OBJS)

shared: libpsrand.so

libpsrand.so: $(OBJS)
	$(CC) $(LDFLAGS) -shared -o libpsrand.so $(OBJS)

install:
	$(MKDIR) $(INCDIR) $(LIBDIR)
	$(CP) minstd.h mtw.h xorshift.h $(INCDIR)
	-$(CP) libpsrand.a $(LIBDIR)
	-$(CP) libpsrand.so $(LIBDIR)

uninstall:
	rm $(INCDIR)/minstd.h $(INCDIR)/mtw.h $(INCDIR)/xorshift.h
	-rmdir $(INCDIR)
	-rm $(LIBDIR)/libpsrand.a $(LIBDIR)/libpsrand.so

clean:
	rm $(OBJS) libpsrand.a libpsrand.so
