#
# makefile for wserver, part of W
# (C) 1994,95,96 by Torsten Scherer (TeSche)
# itschere@techfak.uni-bielefeld.de
#

include ../.config


#
# targets, partly system dependent
#

SUBDIRS = graph
CFLAGS = $(ADDCFLAGS) $(SERVERADDCFLAGS)
LDFLAGS = $(ADDLDFLAGS) $(SERVERADDLDFLAGS) -Lgraph
LDLIBS  = -ltermcap -lgraph $(SERVERADDLDLIBS)
TARGETS = subdirs wserver
DEPEND = graph/libgraph.a

ifeq ($(ARCH),MiNT)
CFLAGS += -Iutil
LDFLAGS += -Lutil
LDLIBS += -lutil -lsocket
DEPEND += util/libutil.a
LIBUTIL = 1
XCONOUT2 = 1
endif

ifeq ($(ARCH),sun4c)
CFLAGS += -Iutil
LDFLAGS += -Lutil
LDLIBS += -lutil
SUBDIRS += util
DEPEND += util/libutil.a
LIBUTIL = 1
endif


#
# some definitions
#

WHDR =	config.h proto.h types.h

SRCS = $(wildcard *.c)

OBJS = $(patsubst %.c, %.o, $(SRCS))


#
# rules
#

all: subdirs wserver

subdirs:
	make -C graph
ifdef LIBUTIL
	make -C util
endif
ifdef XCONOUT2
	make -C xconout2
endif

wserver: $(OBJS) $(DEPEND)
	$(CC) $(LDFLAGS) $(OBJS) $(LDLIBS) -o wserver

#####

font.o: font.c
	$(CC) $(CPPFLAGS) $(CFLAGS)  -DFONTDIR=\"$(FONTDIR)\" -c $< -o $@

main.o: main.c
	$(CC) $(CPPFLAGS) $(CFLAGS)  -DLIBDIR=\"$(LIBDIR)\" -c $< -o $@

install: wserver startw
ifdef BINDIR
	$(INSTALL) -s -m 755 wserver $(BINDIR)
	$(INSTALL) -m 755 startw $(BINDIR)
ifeq ($(ARCH),MiNT)
	$(MAKE) -C xconout2 install
endif
endif

clean:
	$(RM) *~ *.rej *.orig *.o
	$(MAKE) -C graph clean
	$(MAKE) -C util clean
	$(MAKE) -C xconout2 clean

veryclean:
	$(RM) *~ *.rej *.orig *.o wserver
	$(MAKE) -C graph veryclean
	$(MAKE) -C util veryclean
	$(MAKE) -C xconout2 veryclean


#
# additional object dependencies
#

window.o: window.h
rect.o: rect.h
