# $Header: /home/morgan/pam/Linux-PAM-0.50/libpam_misc/RCS/Makefile,v 1.3 1996/07/07 23:59:38 morgan Exp $
#
# $Log: Makefile,v $
# Revision 1.3  1996/07/07 23:59:38  morgan
# changes for making this a public library, it has also been renamed
# to libpam_misc
#
#

dummy:

	@echo "*** This is not a top-level Makefile!"

# ///////////////////////////////////////////////////////////////////

# uncomment if you wnat libpam_misc to be made as a dynamic library
# AGM has had some segfaulting from libdl when I did this. I have not
# investigated the cause...

# MAKE_DYNAMIC=yes

LIBNAME = pam_misc
LIBMAJOR=0
LIBMINOR=50

FILES=xstrdup misc_conv

#
# Probably no need to alter anything below here.
#

# build dynamic library names

ifdef MAKE_DYNAMIC

LIBDYNAMIC=lib$(LIBNAME).so
LIBDYNMAJ=$(LIBDYNAMIC).$(LIBMAJOR)
LIBDYNMIN=$(LIBDYNMAJ).$(LIBMINOR)

endif

# static library name

LIBSTATIC = lib$(LIBNAME).a

# sources and object files

LIBSRC = $(addsuffix .c,$(FILES))
LIBOBJ = $(addsuffix .o,$(FILES))

# rules

all: $(LIBSTATIC) $(LIBDYNAMIC)

$(LIBDYNAMIC): $(LIBOBJ)
	$(LD) -soname $(LIBDYNMAJ) -x --shared -o $@ $(LIBOBJ)

$(LIBSTATIC): $(LIBOBJ)
	$(AR) $@ $(LIBOBJ)
	$(RANLIB) $@

install: 
	mkdir -p $(INCLUDEDIR)
	install -m644 ./pam_misc.h $(INCLUDEDIR)
ifdef MAKE_DYNAMIC
	install -m644 $(LIBDYNAMIC) $(LIBDIR)/$(LIBDYNMIN)
	$(LDCONFIG)
	( cd $(LIBDIR) ; ln -sf $(LIBDYNMAJ) $(LIBDYNAMIC) )
endif
	install -m644 $(LIBSTATIC) $(LIBDIR)

clean:
	rm -f *.so *.a core a.out *~

remove:
	rm -f $(INCLUDEDIR)/pam_misc.h
	rm -f $(LIBDIR)/$(LIBDYNAMIC).*
	$(LDCONFIG)
	rm -f $(LIBDIR)/$(LIBSTATIC)

.c.o:
	$(CC) -c $(DEFS) $(CFLAGS) $<

extraclean:
	@make clean
	rm -f *.o *.bak

