CC=g++
LDFLAGS=-lncurses -lpthread
CFLAGS=-O2 -Wall
#CFLAGS=-O2 -Wall -DDEBUG
objects=main.o functions.o screen.o server.o user.o messages.o signals.o parameter.o userdb.o
DESTDIR=/usr
BINNAME=netwalker
MANPAGE=netwalker.1

#if you alter this you also have to alter the config.h file!!!
HELP_DIR=$(DESTDIR)/share/netwalker-ircc/

all:	notice echo_for_objects make_objects link_the_binary
	

clean:
	@echo "--== CLEANING ==--"
	rm -f *.o $(BINNAME)

install: notice
	@echo "--== INSTALLING ==--"
	mkdir -p $(DESTDIR)/bin
	mkdir -p $(DESTDIR)/share/man/man1
	mkdir -p $(HELP_DIR)
	install --mode=0755 $(BINNAME) $(DESTDIR)/bin/$(BINNAME)
	install --mode=0644 $(MANPAGE) $(DESTDIR)/share/man/man1/$(MANPAGE)
	install --mode=0644 help/* $(HELP_DIR)
	@echo "=============================================="
	@echo "||                                          ||"
	@echo "||      Thank you for installing the        ||"
	@echo "||          netwalker irc-client.           ||"
	@echo "||                                          ||"
	@echo "||       You should now create a new        ||"
	@echo "||      config-file with the command:       ||"
	@echo "||              netwalker -c                ||"
	@echo "||                                          ||"
	@echo "||  Please report bugs and/or wishes to:    ||"
	@echo "||         bugs@lancelot2k.dyndns.org       ||"
	@echo "||                                          ||"
	@echo "=============================================="

uninstall:
	@echo "--== UNINSTALLING ==--"
	rm -f $(DESTDIR)/bin/$(BINNAME)
	rm -f $(DESTDIR)/share/man/man1/$(MANPAGE)
	rm -rf $(DESTDIR)$(HELP_DIR)

update: notice uninstall clean all install

echo_for_objects:
	@echo "--== BUILDING OBJECT FILES ==--"

make_objects:	$(objects)

link_the_binary:
	@echo "--== LINKING THE BINARY ==--"
	$(CC) $(LDFLAGS) $(objects) -o $(BINNAME)

help:
	@echo "Available Options:"
	@echo ""
	@echo "all                  builds the netwalker irc-client binary"
	@echo "clean                deletes all object files and binarys"
	@echo "install              installs the netwalker irc-client"
	@echo "uninstall            uninstalls this software"
	@echo "update               updates an installed netwalker irc-client"

notice:
	@echo "=============================================="
	@echo "||                                          ||"
	@echo "||      This is the Makesystem of the       ||"
	@echo "||           netwalker irc-client           ||"
	@echo "||                                          ||"
	@echo "||      If you dont know what to do:        ||"
	@echo "||             try \"make help\"              ||"
	@echo "=============================================="
	@echo ""

main.o:
	$(CC) $(CFLAGS) -c main.cc              -o main.o

functions.o:
	$(CC) $(CFLAGS) -c functions.cc         -o functions.o

screen.o:
	$(CC) $(CFLAGS) -c screen.cc            -o screen.o

server.o:
	$(CC) $(CFLAGS) -c server.cc            -o server.o

user.o:
	$(CC) $(CFLAGS) -c user.cc              -o user.o

messages.o:
	$(CC) $(CFLAGS) -c messages.cc          -o messages.o

signals.o:
	$(CC) $(CFLAGS) -c signals.cc           -o signals.o

parameter.o:
	$(CC) $(CFLAGS) -c parameter.cc         -o parameter.o

userdb.o:
	$(CC) $(CFLAGS) -c userdb.cc            -o userdb.o


syntax highlighted by Code2HTML, v. 0.9.1