#
# $Id$
#

TARGET      = @targetname@
SRCS        = rlm_eap.c eap.c mem.c
HEADERS     = eap.h rlm_eap.h
RLM_CFLAGS  = $(INCLTDL) -Ilibeap
CLIENTLIBS  = libeap/$(LIBPREFIX)freeradius-eap.la
RLM_LIBS    = libeap/$(LIBPREFIX)freeradius-eap.la $(LIBLTDL)
RLM_INSTALL = install-subdirs
RLM_SUBDIRS = libeap @eaptypes@
RLM_UTILS   = radeapclient

#
# Not using shared libraries, add in ALL known static modules
# at build time.
#
#ifneq ($(USE_SHARED_LIBS),yes)
#RLM_LIBS  += $(shell for x in types/rlm_eap*/rlm_eap*.la;do echo -dlpreopen $$x;done)
#endif

.PHONY: all install-subdirs common

#
# We need $(LIBPREFIX)freeradius-eap.la before we can build anything else
#
all: common

$(LT_OBJS): $(HEADERS)

radeapclient: radeapclient.lo $(CLIENTLIBS)
	$(LIBTOOL) --mode=link $(CC) $(LDFLAGS) $(RLM_LDFLAGS) -o radeapclient radeapclient.lo $(CLIENTLIBS) $(LIBS) $(OPENSSL_LIBS)

radeapclient.lo: radeapclient.c $(HEADERS)
	$(LIBTOOL) --mode=compile $(CC) $(CFLAGS) $(RLM_CFLAGS) -c radeapclient.c

install-subdirs:
	@$(MAKE) $(MFLAGS) WHAT_TO_MAKE=install common
	$(LIBTOOL) --mode=install $(INSTALL) -m 755 $(INSTALLSTRIP) radeapclient$(EXEEXT) $(R)$(bindir)

.PHONY: common $(RLM_SUBDIRS)

common: $(RLM_SUBDIRS)

types: libeap

$(RLM_SUBDIRS):
	@echo "Making $(WHAT_TO_MAKE) in $@..."
	@$(MAKE) $(MFLAGS) -C $@ $(WHAT_TO_MAKE)

libeap/$(LIBPREFIX)freeradius-eap.la: libeap

## this uses the RLM_CFLAGS and RLM_LIBS and SRCS defs to make TARGET.
include ../rules.mak
