# Basic makefile for libaesgm
# http://gladman.plushost.co.uk/oldsite/AES/

VERSION_MAJOR = 0
VERSION_MINOR = 0
VERSION_RELEASE = 0
VERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_RELEASE)

SHARED_LIB = libaesgm.so

LIBAESGM = aescrypt.o aeskey.o aes_modes.o aestab.o
LINKOBJ = $(LIBAESGM)

PREFIX = /usr
LIBDIR = /usr/lib
INCLUDEDIR = $(PREFIX)/include/
DESTDIR =
CFLAGS = 

all: sharedlib

sharedlib: $(LINKOBJ)
	$(CC) $(CFLAGS) -shared -Wl,-soname,$(SHARED_LIB).$(VERSION_MAJOR) -o $(SHARED_LIB).$(VERSION) $^ $(LDFLAGS)

clean:
	$(RM) $(LINKOBJ) $(SHARED_LIB).$(VERSION)

install:
	mkdir -p $(DESTDIR)$(INCLUDEDIR)/aes/
	cp -p *.h $(DESTDIR)$(INCLUDEDIR)/aes/
	mkdir -p $(DESTDIR)$(LIBDIR)
	cp -p $(SHARED_LIB).$(VERSION) $(DESTDIR)$(LIBDIR)
	cd $(DESTDIR)$(LIBDIR) && ln -s -f $(SHARED_LIB).$(VERSION) $(SHARED_LIB) && ln -s -f $(SHARED_LIB).$(VERSION) $(SHARED_LIB).$(VERSION_MAJOR)
