# Copyright 1998 Juniper Networks, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
#	$FreeBSD: src/lib/libradius/Makefile,v 1.1.1.1 1998/11/13 00:53:01 jdp Exp $

PREFIX=	/usr/local

RM=		rm -f
LN=		ln
CC=		cc
CFLAGS= -O2

# linux -L$(PREFIX)/lib -lmd
LIBMD= -L$(PREFIX)/lib -lmd

# netbsd - it's in libc
#LIBMD= -L/usr/lib -lc


LIB=    radius
OBJS=   radlib.o

all:    lib$(LIB).a


lib$(LIB).a:    $(OBJS)
	ar cru $@ $(OBJS)
	ranlib $@

radlib.o:       radlib.c
	$(CC) $(CFLAGS) -c radlib.c -o radlib_r.o
	ld -r -o radlib.o radlib_r.o -L$(PREFIX)/lib $(LIBMD)
	$(CC) -shared radlib_r.o -o libradius.so.1.0  -L$(PREFIX)/lib $(LIBMD)
	$(RM) radlib_r.o

clean:
	$(RM) *.o

clobber:	clean
	$(RM) lib$(LIB).a

install:	all
	install -c -m 644 -o bin -g bin lib$(LIB).a $(PREFIX)/lib
	install -c -m 644 -o bin -g bin lib$(LIB).so.1.0 $(PREFIX)/lib
	$(LN) -sf $(PREFIX)/lib/lib$(LIB).so.1.0 $(PREFIX)/lib/lib$(LIB).so
	install -c -m 444 -o bin -g bin radlib.h $(PREFIX)/include
	install -c -m 444 -o bin -g bin libradius.3 $(PREFIX)/man/man3
	install -c -m 444 -o bin -g bin radius.conf.5 $(PREFIX)/man/man5
