#
# Makefile for linux
#
# Copyright (c) 2001 Network Appliance, Inc.
# All rights reserved.
#

#
# Modified Cobion AG
# 2002-09-12
#

SHELL = /bin/sh
CC=/usr/bin/gcc

API = api_filter
#API = banner_stripper
OBJS = iserver.o threadpool.o stream.o header.o gbuf.o api.o auth.o
EXEC = iserver10
#EXEC = iserver10 filter

#INCL = -I/usr/include 
#CFLAGS = -g -ggdb3 -D_DEBUG -DDEBUG -DTHREAD_SAFE -D_REENTRANT		# -g for debug information
CFLAGS = -s -DNDEBUG -DTHREAD_SAFE -D_REENTRANT		# -g for debug information
RFLAGS =
LLIBS = -lpthread -lm -lgif -lungif
RLIBS = 
LIBS =  
HDRS = 
LIB = libicap_server.a

.PHONY: all

all: libicap_server.a copylib

$(EXEC): $(OBJS) $(HDRS)
	$(CC) -o $@ $(OBJS) $(INCL) $(DFLAGS) $(CFLAGS) $(RFLAGS) $(LLIBS) $(RLIBS) $(LIBS)
	chmod 700 $@

$(LIB): $(OBJS)

copylib:
	@echo Copying libicap_server.a ...
	@cp -f libicap_server.a ../binx/
		
%.o: %.cxx
	$(CC) -c $(DFLAGS) $(CFLAGS) $(INCL) $<

%.o: %.c
	$(CC) -c $(DFLAGS) $(CFLAGS) $(INCL) $<

%.a %.o:
	ar r $@ $^
	ranlib $@

filter: valspeak

.c: $*
	$(CC) -o $* $*.c -ll

.l.c: $*.l
	lex $*.l
	mv lex.yy.c $*.c

valspeak.c: valspeak.l

clean: 
	rm -f $(EXEC)
	rm -f  *.o core *~
	rm -f $@
	rm -f valspeak.c
	rm -f ../binx/libicap_server.a