CHDIR = cd
RM    = rm
TOUCH = touch

all: library

library:
	$(RM) -f .build_done
	($(CHDIR) src && $(MAKE) library)
	$(TOUCH) .build_done

library-only:
	$(RM) -f .build_done
	($(CHDIR) src && $(MAKE) library-only)
	$(TOUCH) .build_done

.build_done: library


check: library

subset:
	@if [ -z "$(DESTDIR)" ]; then \
		echo 'error: DESTDIR must be specified.' 1>&2; \
	else \
		./bin/make-subset --prefix=`pwd` \
				  --libraries="$(LIBRARIES)" \
				  --destdir="$(DESTDIR)"; \
	fi

clean:
	$(RM) -f .build_done
	($(CHDIR) src && $(MAKE) clean)

.PHONY: all library library-only check subset clean
