#
# Makefile for Server
#
# $Id: Makefile,v 1.28 2005/05/31 17:43:48 graziano Exp $
#

# include common variables
include ../Makedefs

# headers we depend upon
HDRS	=		../Include/nws_nameserver.h \
			../Include/nws_memory.h \
			../Include/nws_state.h \
			../Include/nws_db.h \
			../Include/config_nws.h

# objects we create here 
OBJS	=		$(buildobjdir)/nws_state.o \
			$(buildobjdir)/nws_cache.o \
			$(buildobjdir)/nws_db.o 
# and objects we depends upon
OBJS	+=		$(buildobjdir)/nws_daemon.o

# library we depend upon 
DEP_LIB	=		$(buildlibdir)/$(LIBNWSNAME)

# the programs we are building and aliases
PROGRAMS	= 	$(buildbindir)/nws_nameserver \
			$(buildbindir)/nws_memory \
			$(buildbindir)/nws_proxy 

# what to do with nws_timeout ?

.PHONY : all clean dist install

all: $(PROGRAMS)

clean:
	@$(RM) -f $(OBJS)

dist:
	@$(INSTALL) -d  $(DIST_ROOT)/Server
	@$(CP) Makefile *.1 *.c $(DIST_ROOT)/Server

install:
	@echo "Installing servers ..."
	@$(CP) $(PROGRAMS) $(bindir)
	@echo "Installing servers man pages ..."
	@$(CP) *.1 $(mandir)/man1

# Compilation rules for C.
$(buildobjdir)/%.o : %.c $(HDRS)
	$(CC) $(INCLUDES) $(CFLAGS) -c $< -o $@

# linking rules
$(buildbindir)/% : $(buildobjdir)/%.o $(OBJS) $(DEP_LIB) $(HDRS)
	$(CC) $(INCLUDES) $(CFLAGS) -o $@ $< $(OBJS) $(DEP_LIB) $(LDFLAGS)
