#!/usr/bin/make -f
# Makefile - Makefile for ndisc
# $Id: Makefile 47 2005-08-26 20:31:31Z remi $

# ***********************************************************************
# *  Copyright (C) 2004-2005 Remi Denis-Courmont.                       *
# *  This program is free software; you can redistribute and/or modify  *
# *  it under the terms of the GNU General Public License as published  *
# *  by the Free Software Foundation; version 2 of the license.         *
# *                                                                     *
# *  This program is distributed in the hope that it will be useful,    *
# *  but WITHOUT ANY WARRANTY; without even the implied warranty of     *
# *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               *
# *  See the GNU General Public License for more details.               *
# *                                                                     *
# *  You should have received a copy of the GNU General Public License  *
# *  along with this program; if not, you can get it from:              *
# *  http://www.gnu.org/copyleft/gpl.html                               *
# ***********************************************************************

CC = gcc
CFLAGS = -O2 -Wall -g
LDFLAGS =
#LD = ld
INSTALL = install -c
prefix = /usr/local


TARGETS = ndisc6 rdisc6
PACKAGE = ndisc6
VERSION = 0.1.5
DEFS = -DPACKAGE_VERSION=\"$(VERSION)\"
ndisc6_DEFS =
rdisc6_DEFS = -DRDISC

all: $(TARGETS)

$(TARGETS): %: ndisc.c
	$(CC) $(DEFS) $($*_DEFS) $(CFLAGS) $(LDFLAGS) -o $@ $<

install: all install-man
	mkdir -p $(DESTDIR)$(prefix)/bin
	for f in $(TARGETS); do \
		$(INSTALL) -m 04755 $$f $(DESTDIR)$(prefix)/bin/$$f || \
			exit $$? ; \
	done

install-strip: all install-man
	mkdir -p $(DESTDIR)$(prefix)/bin
	for f in $(TARGETS); do \
		$(INSTALL) -s -m 04755 $$f $(DESTDIR)$(prefix)/bin/$$f || \
			exit $$? ; \
	done

install-man:
	mkdir -p $(DESTDIR)$(prefix)/man/man8
	for f in $(TARGETS); do \
		$(INSTALL) -m 0644 $$f.8 $(DESTDIR)$(prefix)/man/man8/$$f.8 || \
			exit $$? ; \
	done

uninstall:
	rm -f $(TARGETS:%=$(DESTDIR)$(prefix)/bin/%) \
		$(TARGETS:%=$(DESTDIR)$(prefix)/man/man8/%.8)

mostlyclean:
	rm -f $(TARGETS)

clean: mostlyclean

distclean: clean

dist:
	mkdir -v $(PACKAGE)-$(VERSION)
	cp ndisc.c $(TARGETS:%=%.8) Makefile README $(PACKAGE)-$(VERSION)/
	cp /usr/share/common-licenses/GPL-2 $(PACKAGE)-$(VERSION)/COPYING
	svn -v log > $(PACKAGE)-$(VERSION)/ChangeLog
	tar c $(PACKAGE)-$(VERSION) | bzip2 > $(PACKAGE)-$(VERSION).tar.bz2
	rm -Rf $(PACKAGE)-$(VERSION)

.PHONY: clean mostlyclean distclean all install install-man install-strip

