#############################################################################
# Copyright (c) 2002-2003 Pelle Johansson.                                    #
# All rights reserved.                                                        #
#                                                                             #
# This file is part of the moftpd package. Use and distribution of            #
# this software is governed by the terms in the file LICENCE, which           #
# should have come with this package.                                         #
 #############################################################################

# $moftpd: Makefile.in 1249 2004-12-09 15:14:38Z morth $

subdirs =utf8fs

program =moftpd
OBJS    =main.o server.o connection.o commands.o user.o confparse.o compat.o \
	 com_file.o com_info.o com_login.o com_misc.o com_navigation.o \
	 com_port.o com_security.o com_settings.o com_transfer.o transfer.o \
	 accounter.o events.o sql.o
INCS    =main.h server.h connection.h commands.h user.h confparse.h compat.h \
	 defaults.h accounter.h events.h system.h
EXTRA	=config.tab.o utf8fs/libutf8fs.a

admin   =moftpadmin
ADMOBJS =admin.o compat.o
ADMEXTRA=utf8fs/libutf8fs.a

# End of configuration part.

# Variables from configure.
PACKAGE_NAME		=@PACKAGE_NAME@
PACKAGE_TARNAME		=@PACKAGE_TARNAME@
PACKAGE_VERSION		=@PACKAGE_VERSION@
PACKAGE_STRING		=@PACKAGE_STRING@
prefix			=@prefix@
exec_prefix		=@exec_prefix@
sbindir			=@sbindir@
datadir			=@datadir@
sysconfdir		=@sysconfdir@
mandir			=@mandir@
localstatedir		=@localstatedir@
DEFS			=@DEFS@
LIBS			=@LIBS@
CC			=@CC@
CFLAGS			=@CFLAGS@
LDFLAGS			=@LDFLAGS@
PRECOMP			=@PRECOMP@
PRECOMPEXT		=@PRECOMPEXT@
YACC			=@YACC@
INSTALL			=@INSTALL@
INSTALL_PROGRAM		=@INSTALL_PROGRAM@
INSTALL_DATA		=@INSTALL_DATA@
STRIP			=@STRIP@
srcdir			=@srcdir@
events_obj		=@events_obj@
tls_obj			=@tls_obj@
pam_enabled		=@pam_enabled@
# End variables from configure

OBJS      += $(events_obj) $(tls_obj)
SRCS	   =$(OBJS:o=c) $(ADMOBJS:o=c) config.tab.c
CFLAGS    += -I. -I$(srcdir) -I$(srcdir)/utf8fs
topobjdir  =.

all:	Makefile autopaths.h subdirs $(program) $(admin) README docs/moftpd.8

subdirs:: Makefile system$(PRECOMPEXT)
	@for i in $(subdirs); do cd $$i; $(MAKE); done

install: all
	-mkdir -p $(sbindir) $(sysconfdir) $(datadir)/$(PACKAGE_NAME)/locale $(mandir)/man8
	-mkdir -p $(localstatedir)/run $(datadir)/examples
	$(INSTALL_PROGRAM) $(program) $(sbindir)
	$(INSTALL_PROGRAM) $(admin) $(sbindir)
	$(STRIP) $(sbindir)/$(program) $(sbindir)/$(admin)
	$(INSTALL_DATA) $(srcdir)/docs/moftpd.conf.dist $(datadir)/examples
	$(INSTALL_DATA) docs/moftpd.8 $(mandir)/man8
	$(INSTALL_DATA) $(srcdir)/docs/moftpadmin.8 $(mandir)/man8
	for i in $(srcdir)/locale/*.loc; do \
	  $(INSTALL_DATA) $$i $(datadir)/$(PACKAGE_NAME)/locale; \
	done
	@echo ===========================================================
	@echo Installation done.
	@if test "$(pam_enabled)" = yes; then \
	  echo You will also need to configure PAM for moftpd if you don\'t; \
	  echo have a default ftpd PAM rule.; \
	  echo See docs/moftpd.pam for an example.; \
	fi

clean:
	@for i in $(subdirs); do cd $$i; $(MAKE) clean; cd ..; done
	-rm -rf system$(PRECOMPEXT) $(program) $(OBJS) *.tab.[cho] autopaths.h
	-rm -rf $(admin) $(ADMOBJS)

distclean: clean
	@for i in $(subdirs); do cd $$i; $(MAKE) distclean; done
	-rm -rf *core Makefile config.log config.status autoconf.h system.h
	-rm -rf autom4te.cache .depend autoscan.log configure.scan
	-rm -rf .DS_Store ._* .\#*
	-rm -rf $(PACKAGE_TARNAME)-*.tar.gz $(PACKAGE_TARNAME)-*.tar.bz2
	-find . -name "*~" -exec rm {} \;

autoclean: distclean
	-rm -rf aclocal.m4 autoconf.h.in configure README docs/readme.html

tarball: locale/messages distclean README docs/moftpd.8 html
	@DIRNAME=$(PACKAGE_TARNAME)-$(PACKAGE_VERSION); \
	if test `basename $$PWD` != $$DIRNAME; then \
	  echo "The name of this directory should be $$DIRNAME."; \
	  exit 1; \
	fi; \
	cd ..; \
	echo tar --exclude=.svn cf $${DIRNAME}.tar $$DIRNAME; \
	tar cf $${DIRNAME}.tar $$DIRNAME; \
	echo gzip -c $${DIRNAME}.tar > $${DIRNAME}.tar.gz; \
	gzip -c $${DIRNAME}.tar > $${DIRNAME}.tar.gz; \
	echo bzip2 $${DIRNAME}.tar; \
	bzip2 $${DIRNAME}.tar; \
	mv $${DIRNAME}.tar.gz $$DIRNAME; \
	mv $${DIRNAME}.tar.bz2 $$DIRNAME

html:
	(cd $(srcdir)/docs && ./make_html.pl)

$(program): Makefile $(OBJS) $(EXTRA)
	$(CC) $(LDFLAGS) -o $(program) $(OBJS) $(EXTRA) $(LIBS)

$(admin): Makefile $(ADMOBJS) $(ADMEXTRA)
	$(CC) $(LDFLAGS) -o $(admin) $(ADMOBJS) $(ADMEXTRA) $(LIBS)

system$(PRECOMPEXT): system.h autoconf.h autopaths.h $(srcdir)/compat.h
	$(PRECOMP)

system.h: $(srcdir)/system.h.in
	cp $(srcdir)/system.h.in system.h

# Sigh ADMOBJS here gives warning.
$(OBJS) admin.o: system$(PRECOMPEXT)
	$(CC) $(CFLAGS) $(DEFS) -c $(srcdir)/$(@:o=c)

config.tab.o: config.tab.c
	$(CC) $(CFLAGS) $(DEFS) -c $(@:o=c)

confparse.o user.o: config.tab.c

config.tab.h: config.tab.c

config.tab.c: $(srcdir)/config.y
	$(YACC) -d -b config $(srcdir)/config.y

$(srcdir)/configure:: $(srcdir)/configure.ac $(srcdir)/acinclude.m4
	(cd $(srcdir) && \
	aclocal && \
	autoconf && \
	autoheader )

config.status:: $(srcdir)/configure
	./config.status --recheck
	./config.status autoconf.h

Makefile:: $(srcdir)/Makefile.in config.status
	./config.status Makefile
	@$(MAKE) $${MAKEFLAGS} ${.TARGETS}

depend:: $(SRCS) $(INCS)
	@for i in $(subdirs); do cd $$i; $(MAKE) depend; done
	mkdep $(DEFS) $(SRCS)
	for i in $(OBJS:.o=) $(ADMOBJS:.o=); do \
	  echo $${i}.o: $(srcdir)/$${i}.c >> .depend; \
	done

README: $(srcdir)/docs/readme.troff
	nroff $(srcdir)/docs/readme.troff > $@
	-groff -Thtml $(srcdir)/docs/readme.troff > docs/readme.html

autoconf.h: $(srcdir)/autoconf.h.in
	./config.status autoconf.h

autopaths.h: Makefile $(srcdir)/autopaths.h.in
# Hrm protect agains \ and , in paths?
	sed -e 's,"sysconfdir","$(sysconfdir)",' -e 's,"datadir","$(datadir)",' -e 's,"localstatedir","$(localstatedir)",' $(srcdir)/autopaths.h.in > $@

docs/moftpd.8: $(srcdir)/docs/moftpd.8.in
	./config.status docs/moftpd.8

locale/messages: $(SRCS)
	printf "\xEF\xBB\xBF" > $@
	grep -hE '(reply(_spont)? *\([^,]*,|quit_all_connections *\() *"[0-9%]' *.c | sed -E -e 's/^.*(reply(_spont)? *\([^,]*,|quit_all_connections *\() *"(([^"\]|\\.)*)".*$$/\3/' -e 's/\\//g' -e '/^.{0,8}$$/d' | sort | uniq >> $@

.PATH: $(srcdir)

FORCE:

include .depend


syntax highlighted by Code2HTML, v. 0.9.1