
SHELL = /bin/sh

#### Start of system configuration section. ####

srcdir = .
topdir = /usr/local/lib/ruby/1.8/alpha-openbsd
hdrdir = $(topdir)
VPATH = $(srcdir):$(topdir):$(hdrdir)
exec_prefix = $(prefix)
prefix = $(DESTDIR)/usr/local
datarootdir = $(prefix)/share
rubylibdir = $(libdir)/ruby/$(ruby_version)
infodir = $(DESTDIR)/usr/local/info
sharedstatedir = $(prefix)/com
pdfdir = $(docdir)
oldincludedir = $(DESTDIR)/usr/include
datadir = $(datarootdir)
sitearchdir = $(sitelibdir)/$(sitearch)
libdir = $(exec_prefix)/lib
localedir = $(datarootdir)/locale
psdir = $(docdir)
vendordir = $(libdir)/ruby/vendor_ruby
sitelibdir = $(sitedir)/$(ruby_version)
vendorlibdir = $(vendordir)/$(ruby_version)
localstatedir = $(DESTDIR)/var
dvidir = $(docdir)
includedir = $(prefix)/include
bindir = $(exec_prefix)/bin
archdir = $(rubylibdir)/$(arch)
vendorarchdir = $(vendorlibdir)/$(sitearch)
htmldir = $(docdir)
sbindir = $(exec_prefix)/sbin
docdir = $(datarootdir)/doc/$(PACKAGE)
sysconfdir = $(DESTDIR)/etc
sitedir = $(libdir)/ruby/site_ruby
mandir = $(DESTDIR)/usr/local/man
libexecdir = $(exec_prefix)/libexec

CC = cc
LIBRUBY = $(LIBRUBY_SO)
LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
LIBRUBYARG_SHARED = -Wl,-R -Wl,$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static

RUBY_EXTCONF_H = 
CFLAGS   =  -fPIC -mieee -O2 -pipe  -fPIC $(cflags) 
INCFLAGS = -I. -I. -I/usr/local/lib/ruby/1.8/alpha-openbsd -I.
DEFS     = 
CPPFLAGS = -DUSE_OPENLDAP2 -DUSE_OPENLDAP -DLDAP_DEPRECATED -D_REENTRANT -DHAVE_LDAP_H -DHAVE_LBER_H -DHAVE_OPENSSL_SSL_H -DHAVE_OPENSSL_CRYPTO_H -DHAVE_LDAP_INIT -DHAVE_LDAP_SET_OPTION -DHAVE_LDAP_GET_OPTION -DHAVE_LDAP_START_TLS_S -DHAVE_LDAP_MEMFREE -DHAVE_LDAP_PERROR -DHAVE_LDAP_SORT_ENTRIES -DHAVE_LDAP_SASL_BIND_S -DHAVE_LDAP_COMPARE_S -DHAVE_LDAP_ADD_EXT_S -DHAVE_LDAP_COMPARE_EXT_S -DHAVE_LDAP_DELETE_EXT_S -DHAVE_LDAP_MODIFY_EXT_S -DHAVE_LDAP_SEARCH_EXT_S -DHAVE_LDAP_UNBIND_EXT_S -DHAVE_LDAP_SASL_INTERACTIVE_BIND_S -DRUBY_VERSION_CODE=187 -DOPENSSL_NO_STATIC_ENGINE -I/usr/local/include  -DOPENSSL_NO_STATIC_ENGINE -I/usr/local/include
CXXFLAGS = $(CFLAGS) 
ldflags  = -L. -L/usr/local/lib -Wl,-E
dldflags = 
archflag = 
DLDFLAGS = $(ldflags) $(dldflags) $(archflag)
LDSHARED = $(CC) -shared  -fPIC
AR = ar
EXEEXT = 

RUBY_INSTALL_NAME = ruby18
RUBY_SO_NAME = ruby18
arch = alpha-openbsd
sitearch = alpha-openbsd
ruby_version = 1.8
ruby = /usr/local/bin/ruby18
RUBY = $(ruby)
RM = rm -f
MAKEDIRS = mkdir -p
INSTALL = /usr/bin/install -c 
INSTALL_PROG = $(INSTALL) -m 0755
INSTALL_DATA = install -c  -m 444
COPY = cp

#### End of system configuration section. ####

preload = 

libpath = . $(libdir) /usr/local/lib
LIBPATH =  -L. -L$(libdir) -Wl,-R$(libdir) -L/usr/local/lib -Wl,-R/usr/local/lib
DEFFILE = 

CLEANFILES = mkmf.log
DISTCLEANFILES = 

extout = 
extout_prefix = 
target_prefix = 
LOCAL_LIBS = 
LIBS = $(LIBRUBYARG_SHARED) -lldap_r -llber -lpthread -lssl -lcrypto  -lm   -lc -pthread
SRCS = clientauth.c conn.c entry.c ldap.c misc.c mod.c saslconn.c sslconn.c
OBJS = clientauth.o conn.o entry.o ldap.o misc.o mod.o saslconn.o sslconn.o
TARGET = ldap
DLLIB = $(TARGET).so
EXTSTATIC = 
STATIC_LIB = 

BINDIR        = $(bindir)
RUBYCOMMONDIR = $(sitedir)$(target_prefix)
RUBYLIBDIR = /usr/obj/ports/ldap-0.9.12-ruby18/gem-tmp/.gem/ruby/1.8/gems/ruby-ldap-0.9.12/lib$(target_prefix)
RUBYARCHDIR = /usr/obj/ports/ldap-0.9.12-ruby18/gem-tmp/.gem/ruby/1.8/gems/ruby-ldap-0.9.12/lib$(target_prefix)

TARGET_SO     = $(DLLIB)
CLEANLIBS     = $(TARGET).so $(TARGET).il? $(TARGET).tds $(TARGET).map
CLEANOBJS     = *.o *.a *.s[ol] *.pdb *.exp *.bak

all:		$(DLLIB)
static:		$(STATIC_LIB)

clean:
		@-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)

distclean:	clean
		@-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
		@-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)

realclean:	distclean
install: install-so install-rb

install-so: $(RUBYARCHDIR)
install-so: $(RUBYARCHDIR)/$(DLLIB)
$(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
	$(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
install-rb: pre-install-rb install-rb-default
install-rb-default: pre-install-rb-default
pre-install-rb: Makefile
pre-install-rb-default: Makefile
pre-install-rb-default: $(RUBYLIBDIR)/ldap
install-rb-default: $(RUBYLIBDIR)/ldap/control.rb
$(RUBYLIBDIR)/ldap/control.rb: $(srcdir)/lib/ldap/control.rb $(RUBYLIBDIR)/ldap
	$(INSTALL_DATA) $(srcdir)/lib/ldap/control.rb $(@D)
install-rb-default: $(RUBYLIBDIR)/ldap/ldif.rb
$(RUBYLIBDIR)/ldap/ldif.rb: $(srcdir)/lib/ldap/ldif.rb $(RUBYLIBDIR)/ldap
	$(INSTALL_DATA) $(srcdir)/lib/ldap/ldif.rb $(@D)
install-rb-default: $(RUBYLIBDIR)/ldap/schema.rb
$(RUBYLIBDIR)/ldap/schema.rb: $(srcdir)/lib/ldap/schema.rb $(RUBYLIBDIR)/ldap
	$(INSTALL_DATA) $(srcdir)/lib/ldap/schema.rb $(@D)
$(RUBYARCHDIR):
	$(MAKEDIRS) $@
$(RUBYLIBDIR)/ldap:
	$(MAKEDIRS) $@

site-install: site-install-so site-install-rb
site-install-so: install-so
site-install-rb: install-rb

.SUFFIXES: .c .m .cc .cxx .cpp .C .o

.cc.o:
	$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<

.cxx.o:
	$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<

.cpp.o:
	$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<

.C.o:
	$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<

.c.o:
	$(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $<

$(DLLIB): $(OBJS) Makefile
	@-$(RM) $@
	$(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)



$(OBJS): ruby.h defines.h

test::
	/bin/sh $(srcdir)/test/test.sh ruby18 newcert; /bin/sh $(srcdir)/test/test.sh ruby18 openldap2-ssl /usr/local/libexec/slapd /usr/local/etc/openldap

testclean: test-clean

test-clean::
	(cd $(srcdir); /bin/sh test/test.sh clean)

reconfig::
	$(RUBY_INSTALL_NAME) $(srcdir)/extconf.rb --without-libldap

doc:
#	$(RUBY_INSTALL_NAME) -rrdoc/ri/ri_paths -e 'puts RI::Paths::PATH[0]'
	rdoc --ri-site *.c lib/ldap

unit:
	(cd test; $(RUBY_INSTALL_NAME) tc_ldif.rb)

.PHONY: doc
