#!/usr/bin/make -f

DESTDIR=$(CURDIR)/familiar/ipkg
LIBIPKG_DESTDIR=$(CURDIR)/familiar/libipkg
CONTROLDIR=$(DESTDIR)/CONTROL
DOCDIR=$(DESTDIR)/usr/share/doc/ipkg

Makefile:
	./configure

configure: Makefile

build: configure
	$(MAKE)

clean:
	-$(MAKE) distclean

install: build
	rm -rf $(DESTDIR)
	$(MAKE) install-strip DESTDIR=$(DESTDIR) prefix=/usr

# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.

# Build architecture-dependent files here.
binary-arch: build install
	rm -fr $(CONTROLDIR) $(LIBIPKG_DESTDIR)
	mkdir -p $(CONTROLDIR) $(LIBIPKG_DESTDIR)
	mkdir -p $(LIBIPKG_DESTDIR)/usr $(LIBIPKG_DESTDIR)/CONTROL
	cp familiar/control $(CONTROLDIR)
	cp familiar/postinst $(CONTROLDIR)
	mkdir -p $(DESTDIR)/usr/bin
	mkdir -p $(DOCDIR)
	cp copyright $(DOCDIR)
	mv -f $(DESTDIR)/usr/lib $(LIBIPKG_DESTDIR)/usr
	mv -f $(DESTDIR)/usr/include $(LIBIPKG_DESTDIR)/usr
	cp familiar/libipkg-control $(LIBIPKG_DESTDIR)/CONTROL/control
	ipkg-build -o root -g root $(DESTDIR)
	ipkg-build -o root -g root $(LIBIPKG_DESTDIR)

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install configure
