diff --git a/Make.inc b/Make.inc index bdb7cf4..64cdc5b 100644 --- a/Make.inc +++ b/Make.inc @@ -1,6 +1,11 @@ # -*- mode: makefile-gmake -*- OS := $(shell uname) +VERSION = 0.1.0 +VERSION_SPLIT = $(subst ., , $(VERSION)) +DESTDIR = +PREFIX = /usr/local +libdir = $(PREFIX)/lib FC = gfortran FFLAGS += -O3 diff --git a/Makefile b/Makefile index fa22d37..0db517b 100644 --- a/Makefile +++ b/Makefile @@ -26,11 +26,23 @@ all: libopenlibm.a libopenlibm.$(SHLIB_EXT) libopenlibm.a: $(OBJS) $(AR) -rcs libopenlibm.a $(OBJS) libopenlibm.$(SHLIB_EXT): $(OBJS) - $(FC) -shared $(OBJS) $(LDFLAGS) -o libopenlibm.$(SHLIB_EXT) + $(FC) -shared $(OBJS) $(LDFLAGS) -o libopenlibm.$(SHLIB_EXT).$(VERSION) + ln -s libopenlibm.$(SHLIB_EXT).$(VERSION) libopenlibm.$(SHLIB_EXT).$(word 1,$(VERSION_SPLIT)).$(word 2,$(VERSION_SPLIT)) + ln -s libopenlibm.$(SHLIB_EXT).$(VERSION) libopenlibm.$(SHLIB_EXT).$(word 1,$(VERSION_SPLIT)) + ln -s libopenlibm.$(SHLIB_EXT).$(VERSION) libopenlibm.$(SHLIB_EXT) + clean: - rm -fr {./,*}/*{.o,~} + @for dir in $(SUBDIRS) .; do \ + rm -fr $$dir/*.o $$dir/*.a $$dir/*.$(SHLIB_EXT)*; \ + done distclean: rm -f $(OBJS) *.a *.$(SHLIB_EXT) $(MAKE) -C test clean + +install: all + mkdir -p $(DESTDIR)$(libdir) + mkdir -p $(DESTDIR)$(PREFIX)/include + cp -a libopenlibm.$(SHLIB_EXT)* libopenlibm.a $(DESTDIR)$(libdir)/ + cp -a src/openlibm.h $(DESTDIR)$(PREFIX)/include/