#$Id: Makefile, 2014/08/15 18:22:00 dboland Exp $

PREFIX = /usr
BINDIR = $(PREFIX)/bin
LIBDIR = $(PREFIX)/lib
INCDIR = $(PREFIX)/include

LIBTOOLFLAGS = #--silent

all: libfakesu.a

cygfakesu.o:
	gcc -c cygfakesu.c

libfakesu.a: cygfakesu.o
	ar cru libfakesu.a cygfakesu.o

target-dirs:
	mkdir -p $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBDIR) $(DESTDIR)$(INCDIR)

install: target-dirs
	cp libfakesu.a $(DESTDIR)$(LIBDIR)/
	cp -rv fakesu $(DESTDIR)$(INCDIR)/
	cp fakesu.h $(DESTDIR)$(INCDIR)/
	cp fakesu.sh $(DESTDIR)$(BINDIR)/fakesu

clean:
	rm -rf *.a *.o *.dll *.lo *.la .libs

cygfakesu.dll: cygfakesu.o
	@echo Linking shared library $@
	gcc -shared -o cygfakesu.dll -Wl,--out-implib=libfakesu.dll.a cygfakesu.o

shared: libfakesu.a cygfakesu.dll

install-shared: install
	cp cygfakesu.dll $(DESTDIR)$(BINDIR)/
	cp libfakesu.dll.a $(DESTDIR)$(LIBDIR)/

cygfakesu.lo:
	libtool --mode=compile gcc -g -O -c cygfakesu.c

cygfakesu.la: cygfakesu.lo
	@echo Linking shared library $@
	libtool --mode=link $(LIBTOOLFLAGS) gcc -g -O2 -o libfakesu.la cygfakesu.lo \
		-static -rpath $(BINDIR) -version-info 1:2 -no-undefined

with-libtool: cygfakesu.la

install-with-libtool: target-dirs
	libtool --mode=install install -c libfakesu.la $(DESTDIR)$(LIBDIR)/libfakesu.la

