PROFIL=
#PROFIL=-pg

LIBS=@LIBS@ $(EXTRALIBS)
CC=@CC@
SRCDIR=@srcdir@
prefix=@prefix@
VPATH=@srcdir@

@SET_MAKE@

HAVE_SHUFFLE=@shuffle@

OTHERFLAGS=@CFLAGS@

CFLAGS=@DEFS@ @CFLAGS@ $(PREFLAGS) $(OTHERFLAGS)
PREFLAGS=-I. -I$(SRCDIR) -I$(SRCDIR)/../.. -I../..

LDFLAGS=@LDFLAGS@

all: cgi fcgi

pure: purecgi

no: 
none:
no-install: 
none-install:
no-localinstall: 
none-localinstall:
-localinstall:
-install:

fcgi: force
	(cd fast_cgi; $(MAKE) "CFLAGSUP=$(CFLAGS)" "LDFLAGS=$(LDFLAGS)" "CC=$(CC)")
	-@if test -f fcgi ; then \
	  if test -f fgci.old ; then \
	    rm -f fcgi.old ; \
	  fi ; \
	  mv fcgi fcgi.old ; \
	fi
	cp fast_cgi/cgi-fcgi/cgi-fcgi fcgi
	@(strip fcgi || echo)

force:

cgi: cgi.o config.h
	$(CC) $(LDFLAGS) -o cgi cgi.o $(LIBS)

purecgi: cgi.o
	purify $(CC) $(LDFLAGS) -o cgi cgi.o $(LIBS)

shuffle:	shuffle.o
	$(CC) -O $(LDFLAGS) -o shuffle shuffle.o -lthread -lsocket $(LIBS)
	@(strip shuffle || echo)

pureshuffle:	shuffle.o
	purify $(CC) -O $(LDFLAGS) -o shuffle shuffle.o -lthread -lsocket $(LIBS)

shuffle-install: shuffle
	-/bin/rm -f $(prefix)/roxen/server/bin/shuffle
	/bin/cp shuffle $(prefix)/roxen/server/bin

shuffle-localinstall: shuffle
	-/bin/rm -f $(SRCDIR)/../server/bin/shuffle
	/bin/cp shuffle $(SRCDIR)/../server/bin

install: fcgi cgi
	@for f in fcgi cgi; do \
		echo Installing $$f...; \
		/bin/rm -f $(prefix)/roxen/server/bin/$$f; \
		if /bin/cp $$f $(prefix)/roxen/server/bin/; then :; \
		else exit 1; fi; \
	done
	-@ln -s $(prefix)/roxen/server/bin/cgi $(prefix)/roxen/server/bin/cgi-bin
	@echo Done.

localinstall: fcgi cgi
	@for f in fcgi cgi; do \
		echo Installing $$f...; \
		/bin/rm -f $(SRCDIR)/../server/bin/$$f; \
		if /bin/cp $$f $(SRCDIR)/../server/bin/; then :; \
		else exit 1; fi; \
	done
	@echo Done.

.c.o:
	$(CC) -c -I. -I$(SRCDIR) $(CFLAGS) $<

clean: 
	@rm -f cgi shuffle fcgi *.o  core
	@(cd fast_cgi; $(MAKE) clean "CFLAGSUP=$(CFLAGS)" "LDFLAGS=$(LDFLAGS)" "CC=$(CC)")

spotless: clean
	@rm -f config.* stamp-h

distribute: spotless
	@rm -f Makefile

cgi.o : config.h

shuffle.o : config.h

config.h : stamp-h

stamp-h: $(SRCDIR)/config.h.in config.status
	CONFIG_FILES="" CONFIG_HEADERS=config.h ./config.status

$(SRCDIR)/config.h.in : $(SRCDIR)/stamp-h.in

$(SRCDIR)/stamp-h.in : $(SRCDIR)/configure.in $(SRCDIR)/acconfig.h
	cd $(SRCDIR) && autoheader
	echo foo > $(SRCDIR)/stamp-h.in
