srcdir = @srcdir@
VPATH  = @srcdir@

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

SRCS=		macports.tcl macports_dlist.tcl macports_util.tcl \
		macports_autoconf.tcl diagnose.tcl reclaim.tcl selfupdate.tcl
OBJS=		macports.o get_systemconfiguration_proxies.o sysctl.o
SHLIB_NAME=	MacPorts${SHLIB_SUFFIX}

INSTALLDIR=	${TCL_PACKAGE_PATH}/macports1.0
OLDINSTALLDIR= ${datadir}/macports/Tcl

ifeq (@HAVE_FRAMEWORK_COREFOUNDATION@,yes)
ifeq (@HAVE_FRAMEWORK_SYSTEMCONFIGURATION@,yes)
	LIBS+= -framework CoreFoundation -framework SystemConfiguration
endif
endif

pkgIndex.tcl: $(SRCS)

ifeq (darwin,@OS_PLATFORM@)
SHLIB_LDFLAGS+= -install_name ${INSTALLDIR}/${SHLIB_NAME}
endif

test::
	$(TCLSH) $(srcdir)/../tests/test.tcl -nocolor

distclean:: clean
	rm -f macports_autoconf.tcl macports_test_autoconf.tcl ${SHLIB_NAME}
	rm -f Makefile

install:: all
	@# Clean up old instances of the MacPorts Tcl packages
	if test -z "${DESTDIR}"; then rm -rf "${OLDINSTALLDIR}"; fi

	@# Remove the previously installed link if it still exists. Without this,
	@# creating the directory will fail.
	if test -L "${DESTDIR}${INSTALLDIR}"; then rm -rf "${DESTDIR}${INSTALLDIR}"; fi

	$(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 "$$file" "${DESTDIR}${INSTALLDIR}/$$file"; \
	done

	$(INSTALL) -o "${DSTUSR}" -g "${DSTGRP}" -m 444 pkgIndex.tcl "${DESTDIR}${INSTALLDIR}"


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

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