#
# Copyright (C) 1997 Kai 'Oswald' Seidler <oswald@cs.tu-berlin.de>
#
#     This program is free software; you can redistribute it and/or modify
#     it under the terms of the GNU General Public License as published by
#     the Free Software Foundation; either VERSION 2 of the License, or
#     (at your option) any later VERSION.
#
#     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, write to the Free Software
#     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#

prefix=/server/irc/ircnet/noteserv
bindir=${prefix}/bin

CFLAGS=-g -O2 -Wall
VERSION=0.8-4th.sunscreen+hybrid_0.3

# Path to libgdbm.a
GDBM_LDFLAGS=gdbm-1.8.3/.libs/libgdbm.a
GDBM_CFLAGS=-Igdbm-1.8.3/

# Debug
DEBUG=0

# System dependend defines
# IRIX & Linux & FreeBSD
SYSTEM=-DSYSTIME

# LD flags
LDFLAGS=${GDBM_LDFLAGS}

# You shouldn't need to change anything below this line
OCFLAGS=${CFLAGS} ${GDBM_CFLAGS} -DDEBUG=${DEBUG}

OBJS=client.o key.o list.o misc.o service.o user.o match.o
SOURCE=client.c key.c list.c misc.c service.c user.c match.c

binfile=${bindir}/noteserv-${VERSION}

DEFS=${SYSTEM} -DDIRECTORY=\"${prefix}\" -DVERSION=\"${VERSION}\"

all: noteserv ns-dumpdb

noteserv: $(OBJS) 
	${CC} -o noteserv ${DEFS} $(OBJS) ${LDFLAGS}

ns-dumpdb: ns-dumpdb.c
	${CC} -o ns-dumpdb ${GDBM_CFLAGS} ns-dumpdb.c ${LDFLAGS}

.c.o: noteserv.h Makefile
	$(CC) $(DEFS) $(OCFLAGS) -c $<

install: all installhelp
	mkdir -p ${bindir}
	touch ${binfile}
	rm ${binfile}
	cp noteserv ${binfile}
	cp ns-dumpdb ${bindir}
	cp messages.dat ${prefix}
	chmod 700 ${binfile}
	ln -fs noteserv-${VERSION} ${bindir}/noteserv

installhelp:
	mkdir -p ${prefix}/help
	cp -fr help ${prefix}

clean:
	rm -f noteserv ns-dumpdb *~ *.o

depend:
	$(CC) -MM $(OCFLAGS) $(SOURCE) > .depend

include .depend
