# Makefile
#
# Keepalived OpenSource project.
#
# Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>

TARFILES = AUTHOR bin ChangeLog configure configure.in CONTRIBUTORS COPYING \
	   doc genhash INSTALL install-sh keepalived keepalived.spec.in lib Makefile.in \
	   README TODO VERSION

TARBALL = keepalived-@VERSION@.tar.gz

all:
	$(MAKE) -C lib || exit 1;
	$(MAKE) -C keepalived
	$(MAKE) -C genhash
	@echo ""
	@echo "Make complete"

debug:
	$(MAKE) -C lib || exit 1;
	$(MAKE) -C keepalived debug
	@echo ""
	@echo "Make complete"

profile:
	$(MAKE) -C lib || exit 1;
	$(MAKE) -C keepalived profile
	@echo ""
	@echo "Make complete"

clean:
	$(MAKE) -C lib clean
	$(MAKE) -C keepalived clean
	$(MAKE) -C genhash clean

id: ID
 		
ID: 
	find . -name "*.[chCH]" -print | xargs mkid -fID 

tags: TAGS

TAGS:
	find . -name "*.[chCH]" -print | etags -

distclean:
	$(MAKE) -C lib distclean
	$(MAKE) -C keepalived distclean
	$(MAKE) -C genhash distclean
	rm -f Makefile
	rm -f keepalived.spec
	rm -f TAGS ID

mrproper: distclean
	rm -f config.*

uninstall:
	$(MAKE) -C keepalived uninstall
	$(MAKE) -C genhash uninstall

install:
	$(MAKE) -C keepalived install
	$(MAKE) -C genhash install
ifeq (@SNMP_SUPPORT@, _WITH_SNMP_)
	mkdir -p $(DESTDIR)/usr/share/snmp/mibs/
	cp -f doc/VRRP-MIB $(DESTDIR)/usr/share/snmp/mibs/
	cp -f doc/KEEPALIVED-MIB $(DESTDIR)/usr/share/snmp/mibs/
endif

tarball: mrproper
	mkdir keepalived-@VERSION@
	cp -a $(TARFILES) keepalived-@VERSION@
	tar --exclude .git -czf $(TARBALL) keepalived-@VERSION@
	rm -rf keepalived-@VERSION@

rpm:
	rpmbuild -ba keepalived.spec
