# Makefile for MBSE BBS under Linux
# Copyright (c) 1998, 2004 by M. Broek.
# $Id$

include ../Makefile.global

SRCS		= mball.c dlcount.c mblang.c mbstat.c mbtoberep.c mbuser.c mbbw.c
HDRS		= mball.h dlcount.h mbstat.h mbuser.h
MBALL_OBJS	= mball.o dlcount.o
MBALL_LIBS	= ../lib/libmbse.a ../lib/libdbase.a
MBLANG_OBJS	= mblang.o
MBLANG_LIBS	= ../lib/libmbse.a ../lib/libdbase.a
MBSTAT_OBJS	= mbstat.o
MBSTAT_LIBS	= ../lib/libmbse.a ../lib/libdbase.a
MBTOBE_OBJS	= mbtoberep.o
MBTOBE_LIBS	= ../lib/libmbse.a ../lib/libdbase.a
MBUSER_OBJS	= mbuser.o
MBUSER_LIBS	= ../lib/libmbse.a ../lib/libdbase.a
MBBW_OBJS	= mbbw.o
MBBW_LIBS	= ../lib/libmbse.a ../lib/libdbase.a
OTHER		= Makefile
TARGET		= mball mblang mbstat mbtoberep mbuser mbbw

#############################################################################################################

.c.o:
		${CC} ${CFLAGS} ${INCLUDES} ${DEFINES} -c $<

all:		${TARGET}

clean: 
		rm -f ${TARGET} *.o *.h~ *.c~ core filelist Makefile.bak

mball:		${MBALL_OBJS} ${MBALL_LIBS}
		${CC} -o mball   ${MBALL_OBJS} ${LDFLAGS} ${LIBS} ${MBALL_LIBS}

mblang:		${MBLANG_OBJS} ${MBLANG_LIBS}
		${CC} -o mblang  ${MBLANG_OBJS} ${LDFLAGS} ${LIBS} ${MBLANG_LIBS}

mbstat:		${MBSTAT_OBJS} ${MBSTAT_LIBS}
		${CC} -o mbstat ${MBSTAT_OBJS} ${LDFLAGS} ${LIBS} ${MBSTAT_LIBS}

mbtoberep:	${MBTOBE_OBJS} ${MBTOBE_LIBS}
		${CC} -o mbtoberep ${MBTOBE_OBJS} ${LDFLAGS} ${LIBS} ${MBTOBE_LIBS}

mbuser:		${MBUSER_OBJS} ${MBUSER_LIBS}
		${CC} -o mbuser ${MBUSER_OBJS} ${LDFLAGS} ${LIBS} ${MBUSER_LIBS}

mbbw:		${MBBW_OBJS} ${MBBW_LIBS}
		${CC} -o mbbw ${MBBW_OBJS} ${LDFLAGS} ${LIBS} ${MBBW_LIBS}

install:	all
		@if [ "`id -un`" != "root" ] ; then \
			echo; echo " Must be root to install!"; echo; exit 3; \
		fi
		${INSTALL} -c -s -o ${OWNER} -g ${GROUP}  -m 0700 mball     ${BINDIR}
		${INSTALL} -c -s -o ${OWNER} -g ${GROUP}  -m 0700 mblang    ${BINDIR}
		${INSTALL} -c -s -o ${OWNER} -g ${GROUP}  -m 0750 mbstat    ${BINDIR}
		${INSTALL} -c -s -o ${OWNER} -g ${GROUP}  -m 0700 mbtoberep ${BINDIR}
		${INSTALL} -c -s -o ${ROWNER} -g ${RGROUP} -m 6711 mbuser    ${BINDIR}
		${INSTALL} -c -s -o ${OWNER} -g ${GROUP}  -m 0750 mbbw      ${BINDIR}
		@rm -f mbchat

filelist:	Makefile
		BASE=`pwd`; \
		BASE=`basename $${BASE}`; \
		(for f in ${SRCS} ${HDRS} ${OTHER} ; do echo ${PACKAGE}-${VERSION}/$${BASE}/$$f; done) >filelist

depend:
		@rm -f Makefile.bak; \
		mv Makefile Makefile.bak; \
		sed -e '/^# DO NOT DELETE/,$$d' Makefile.bak >Makefile; \
		${ECHO} '# DO NOT DELETE THIS LINE - MAKE DEPEND RELIES ON IT' \
		>>Makefile; \
		${ECHO} '# Dependencies generated by make depend' >>Makefile; \
		for f in ${SRCS}; \
		do \
		${ECHO} "Dependencies for $$f:\c"; \
		${ECHO} "`basename $$f .c`.o:\c" >>Makefile; \
		for h in `sed -n -e \
			's/^#[ 	]*include[ 	]*"\([^"]*\)".*/\1/p' $$f`; \
		do \
			${ECHO} " $$h\c"; \
			${ECHO} " $$h\c" >>Makefile; \
		done; \
		${ECHO} " done."; \
		${ECHO} "" >>Makefile; \
		done; \
		${ECHO} '# End of generated dependencies' >>Makefile

# DO NOT DELETE THIS LINE - MAKE DEPEND RELIES ON IT
# Dependencies generated by make depend
mball.o: ../config.h ../lib/mbselib.h ../lib/mbse.h ../lib/users.h ../lib/mbsedb.h dlcount.h mball.h
dlcount.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbsedb.h dlcount.h
mblang.o: ../config.h ../lib/mbselib.h
mbstat.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbsedb.h mbstat.h
mbtoberep.o: ../config.h ../lib/mbselib.h
mbuser.o: ../config.h ../lib/mbselib.h ../lib/users.h ../lib/mbsedb.h mbuser.h
mbbw.o: ../config.h ../lib/mbselib.h ../lib/bluewave.h
# End of generated dependencies