#
# Makefile for rplay
#

#
# Makefile options:
# 
# RPLAY_CONF - rplay configuration file
# BIN_DIR - directory to place rplay binaries
# LIB_DIR - directory to place the rplay library
# INCLUDE_DIR - directory to place the rplay include file
# FIND_SOUNDS - shell command to find all your sounds
# DEFS - defines for the compiler, options are:
#        INETD - create code with inetd support
#        RPLAY_CONF - same as above RPLAY_CONF
#

RPLAY_CONF=	/usr/local/etc/rplay.conf
BIN_DIR=	/usr/local/bin
LIB_DIR=	/usr/local/lib
INCLUDE_DIR=	/usr/local/include
FIND_SOUNDS=	find '*.au'

DEFS=		-DINETD -DRPLAY_CONF=\"$(RPLAY_CONF)\"
#DEFS=		-DRPLAY_CONF=\"$(RPLAY_CONF)\"
CFLAGS=		-O $(DEFS)
CC=		cc

RPLAY=		rplay
RPLAY_OBJS=	rplay.o
RPLAY_LIBS=	-L. -lrplay
RPLAYD=		rplayd
RPLAYD_OBJS=	rplayd.o libst.o
RPLAYD_LIBS=	-L. -lrplay -llwp
LIBRPLAY=	librplay.a
LIBRPLAY_OBJS=	librplay.o

all:		$(LIBRPLAY) $(RPLAY) $(RPLAYD)

world:		all install rplay.conf

$(RPLAY):	$(RPLAY_OBJS) $(LIBRPLAY)
		$(CC) $(CFLAGS) $(RPLAY_OBJS) -o $@ $(RPLAY_LIBS)

$(RPLAYD):	$(RPLAYD_OBJS) $(LIBRPLAY)
		$(CC) $(CFLAGS) $(RPLAYD_OBJS) -o $@ $(RPLAYD_LIBS)

$(LIBRPLAY):	$(LIBRPLAY_OBJS)
		ar rcv $@ $(LIBRPLAY_OBJS)
		ranlib $@

rplay.conf:	
		$(FIND_SOUNDS) > $(RPLAY_CONF)
		
install:	$(RPLAY) $(RPLAYD) $(LIBRPLAY)
		cp rplay rplayd $(BIN_DIR)
		cp librplay.a $(LIB_DIR)
		cp rplay.h $(INCLUDE_DIR)
		ranlib $(LIB_DIR)/librplay.a

clean:
		rm -f $(RPLAY_OBJS) $(RPLAYD_OBJS) $(LIBRPLAY_OBJS) core a.out

shar:
		shar -o rplay rplay.c rplayd.c librplay.c rplay.h version.h \
		libst.c libst.h Makefile README INSTALL WARNING
