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

include ../Makevars


#
# targets, system dependent
#

ifdef MINT
CFLAGS = $(ADDCFLAGS)
LDFLAGS = $(ADDLDFLAGS) -Lgraph
LDLIBS = -ltermcap -lgraph -lsocket
TARGETS = wserver xconout2.xdd
endif

ifdef UNIX
CFLAGS = $(ADDCFLAGS) $(SERVERADDCFLAGS)
LDFLAGS = $(ADDLDFLAGS) $(SERVERADDLDFLAGS) -Lgraph
LDLIBS = -ltermcap -lgraph
TARGETS = wserver
endif


#
# some definitions
#

WHDR =	config.h proto.h types.h
WOBJ =	client_block.o client_noret.o client_others.o client_ret.o font.o \
	hash.o init.o kbd.o main.o menu.o misc.o mouse.o rect.o term.o \
	wfuncs_server.o window.o

#
# rules
#

all: wserver

startw:

libgraph.a:
	$(MAKE) -C graph

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

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

wserver: libgraph.a $(WOBJ)
	$(CC) $(LDFLAGS) $(WOBJ) $(LDLIBS) -o $@

xconout2.xdd: xconinit.o xconout2.o
	$(CC) -nostdlib -mshort xconinit.o xconout2.o -lc -o xconout2.xdd

xconinit.o: xconinit.s

xconout2.o: xconout2.c
	$(CC) $(CFLAGS) -I. -mshort -c $< -o $@

install: $(TARGETS) startw
ifdef BINDIR
	$(INSTALL) -m 755 wserver $(BINDIR)
	$(INSTALL) -m 755 startw $(BINDIR)
ifdef MINT
	$(INSTALL) -m 755 xconout2.xdd /c/mint
endif
endif

clean:
	find -name '*.[o~]' | xargs $(RM)
	find -name '*.orig' | xargs $(RM)
	find -name '*.rej' | xargs $(RM)

veryclean: clean
	find -name '*.a' | xargs $(RM)
	$(RM) wserver

#
# additional object dependencies
#

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