
srcdir = @srcdir@
VPATH  = @srcdir@

include ../../Mk/macports.autoconf.mk

SRCS_AUTOCONF = registry_autoconf.tcl
SRCS = registry.tcl registry_util.tcl receipt_flat.tcl receipt_sqlite.tcl portimage.tcl portuninstall.tcl
OBJS = registry.o util.o \
	entry.o entryobj.o \
	file.o fileobj.o \
	portgroup.o portgroupobj.o \
	snapshot.o snapshotobj.o

SHLIB_NAME= registry${SHLIB_SUFFIX}
INSTALLDIR= ${TCL_PACKAGE_PATH}/registry2.0

include $(srcdir)/../../Mk/macports.tea.mk

CPPFLAGS+=-D_XOPEN_SOURCE=600

pkgIndex.tcl: $(SRCS) $(SRCS_AUTOCONF)

CPPFLAGS :=	${SQLITE3_CPPFLAGS} ${CPPFLAGS}
LIBS :=	${SQLITE3_LIBS} ${LIBS} ../cregistry/cregistry.a
ifeq (darwin,@OS_PLATFORM@)
SHLIB_LDFLAGS+= -install_name @loader_path/../registry2.0/${SHLIB_NAME}
endif

${SHLIB_NAME}: ../cregistry/cregistry.a

.PHONY: test codesign

test:: ${SHLIB_NAME}
	${TEST_TCLSH} $(srcdir)/tests/entry.tcl ./${SHLIB_NAME}
	${TEST_TCLSH} $(srcdir)/tests/depends.tcl ./${SHLIB_NAME}

distclean:: clean
	rm -f registry_autoconf.tcl
	rm -f Makefile

install:: all $(SHLIB_NAME)
	$(INSTALL) -d -o "${DSTUSR}" -g "${DSTGRP}" -m "${DSTMODE}" "${DESTDIR}${INSTALLDIR}"
	$(SILENT) set -x; for file in ${SRCS}; do \
		$(INSTALL) -o "${DSTUSR}" -g "${DSTGRP}" -m 444 "$(srcdir)/$$file" "${DESTDIR}${INSTALLDIR}/$$file"; \
	done
	$(SILENT) set -x; for file in ${SRCS_AUTOCONF}; do \
		$(INSTALL) -o "${DSTUSR}" -g "${DSTGRP}" -m 444 "$$file" "${DESTDIR}${INSTALLDIR}/$$file"; \
	done

codesign:: $(SHLIB_NAME)
	../codesign.sh $?
