#
# Makefile
#
# Version:      $Id: Makefile,v 1.20.4.6 2006/04/12 20:45:20 aland Exp $
#

include ../../Make.inc

SRCS		= crypt.c dict.c filters.c hash.c hmac.c hmacsha1.c \
		  isaac.c log.c misc.c missing.c md4.c md5.c print.c \
		  radius.c rbtree.c sha1.c snprintf.c token.c udpfromto.c \
		  valuepair.c

LT_OBJS		= $(SRCS:.c=.o)

INCLUDES	= ../include/radius.h ../include/libradius.h \
		  ../include/autoconf.h ../include/missing.h 

CFLAGS		+= 

# if you have problems with things that need SHA1-HMAC, this will
# dump the key and the input to the hash so you can compare to what
# the other end is doing.
#CFLAGS += -DHMAC_SHA1_DATA_PROBLEMS

ifeq ($(USE_SHARED_LIBS),yes)
LINK_MODE	= -export-dynamic
else
LINK_MODE	= -static
endif

TARGET		= $(LIBPREFIX)radius

# Define new rule for libtool objects
%.o : %.c
	$(CC) -D_LIBRADIUS -D_DRAYOS -I../include $(CFLAGS) -c $<

all: libradius.so

libradius.so: $(LT_OBJS)
#	$(AR) rcv $@ $(LT_OBJS)
#	/opt/buildroot-gcc342/bin/mipsel-linux-uclibc-ld -r -o $@ $(LT_OBJS)
	$(CC) -shared -o $@ $(LT_OBJS)
$(LT_OBJS): $(INCLUDES)

clean:
	rm -f *.o *.lo *.so $(TARGET).a
	rm -rf .libs

install: all
	$(INSTALL) -d -m 755	$(R)$(libdir)
	$(LIBTOOL) --mode=install $(INSTALL) -c $(TARGET).la \
		$(R)$(libdir)/$(TARGET).la
	rm -f $(R)$(libdir)/$(TARGET)-$(RADIUSD_VERSION).la;
	ln -s $(TARGET).la $(R)$(libdir)/$(TARGET)-$(RADIUSD_VERSION).la
