###########################################################################
# Makefile.in for Samba - rewritten for autoconf support
# Copyright Andrew Tridgell 1992-1998
###########################################################################

prefix=@prefix@
exec_prefix=@exec_prefix@
mandir=@mandir@

CC=@CC@
CFLAGS=@CFLAGS@
CPPFLAGS=@CPPFLAGS@
LDFLAGS=@LDFLAGS@
AWK=@AWK@
AR=@AR@

INSTALLCMD=@INSTALL@

VPATH=@srcdir@
srcdir=@srcdir@
builddir=@builddir@
SHELL=@SHELL@

BASEDIR= @prefix@
LIBDIR = @libdir@
VARDIR = @localstatedir@

# The permissions to give the executables
INSTALLPERMS = 0755

# set these to where to find various files
# These can be overridden by command line switches (see smbd(8))
# or in smb.conf (see smb.conf(5))
CONFIGFILE = @configdir@/smb.conf
LMHOSTSFILE = @configdir@/lmhosts
DRIVERFILE = $(LIBDIR)/printers.def

# The directory where code page definition files go
CODEPAGEDIR = @codepagedir@

FLAGS1 = $(CFLAGS) -Iinclude -I$(srcdir)/include $(CPPFLAGS)
FLAGS2 = -DCONFIGFILE=\"$(CONFIGFILE)\" -DLMHOSTSFILE=\"$(LMHOSTSFILE)\"
FLAGS3 = -DCODEPAGEDIR=\"$(CODEPAGEDIR)\"
FLAGS4 = -DDRIVERFILE=\"$(DRIVERFILE)\"
FLAGS = $(ISA) $(FLAGS1) $(FLAGS2) $(FLAGS3) $(FLAGS4) -DHAVE_INCLUDES_H

######################################################################
# object file lists
######################################################################

SAMBAFILES=			\
	param/loadparm.o 	\
	param/params.o 	\
	lib/time.o 	\
	lib/slprintf.o 	\
	lib/util.o 	\
	lib/debug.o 	\
	lib/system.o 	\
	lib/util_str.o 	\
	lib/kanji.o 	\
	lib/charcnv.o 	\
	lib/charset.o 	\
	lib/username.o 	\
	lib/util_file.o 	\
	lib/util_sock.o 	\
	lib/md4.o 	\
	lib/interface.o 	\
	lib/netmask.o 	\
	libsmb/clientgen.o 	\
	libsmb/pwd_cache.o 	\
	libsmb/smbencrypt.o 	\
	libsmb/smbdes.o 	\
	libsmb/nmblib.o 	\
	libsmb/namequery.o\
	libsmb/nterr.o 	\
	libsmb/smberr.o

######################################################################
# now the rules...
######################################################################

all : CHECK libsamba.a

.SUFFIXES:
.SUFFIXES: .c .o

CHECK:
	@echo "Using FLAGS = $(FLAGS)"

MAKEDIR = || exec false; \
	  if test -d "$$dir"; then :; else \
	  echo mkdir "$$dir"; \
	  mkdir -p "$$dir" >/dev/null 2>&1 || \
	  test -d "$$dir" || \
	  mkdir "$$dir" || \
	  exec false; fi || exec false

libsamba.a: $(SAMBAFILES)
	$(AR) cr libsamba.a $(SAMBAFILES)

.c.o:
	@if (: >> $@ || : > $@) >/dev/null 2>&1; then rm -f $@; else \
	 dir=`echo $@ | sed 's,/[^/]*$$,,;s,^$$,.,'` $(MAKEDIR); fi
	@echo Compiling $*.c
	@$(CC) -I. -I$(srcdir) $(FLAGS) -c $< \
	  -o $@
@BROKEN_CC@	-mv `echo $@ | sed 's%^.*/%%g'` $@

etags:
	etags `find . -name "*.[ch]"`

ctags:
	ctags `find . -name "*.[ch]"`

mostlyclean:
	rm -f core */*~ *~ */*.o config.log

clean: mostlyclean
	rm -f *.a

distclean: clean
	rm -f config.log
	rm -f include/config.h include/stamp-h Makefile
	rm -f config.status config.cache so_locations

# this target is really just for my use. It only works on a limited
# range of machines and is used to produce a list of potentially
# dead (ie. unused) functions in the code. (tridge)
finddead:
	nm */*.o |grep 'U ' | awk '{print $$2}' | sort -u > nmused.txt
	nm */*.o |grep 'T ' | awk '{print $$3}' | sort -u > nmfns.txt
	comm -13 nmused.txt nmfns.txt 

# Rules for maintainers (--enable-maintainer-mode)
AUTOCONF=@AUTOCONF@
AUTOHEADER=@AUTOHEADER@

# when configure.ac is updated, reconfigure
$(srcdir)/configure: @MAINT@ $(srcdir)/configure.ac $(srcdir)/aclocal.m4
	cd $(srcdir) && $(AUTOCONF)

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

Makefile: $(srcdir)/Makefile.in config.status \
	  include/stamp-h # just to ensure that config.h is up-to-date
	CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status

# note that nothing depends on config.h, so will probably be rebuilt
# only when explicitly requested, unless dependency tracking is enabled
include/config.h: include/stamp-h
	@:

include/stamp-h: $(srcdir)/include/config.h.in config.status
	CONFIG_FILES= CONFIG_HEADERS=include/config.h $(SHELL) ./config.status
	@echo > include/stamp-h

$(srcdir)/include/config.h.in: $(srcdir)/include/stamp-h.in
	@:

$(srcdir)/include/stamp-h.in: @MAINT@ $(srcdir)/configure.ac
	cd $(srcdir) && $(AUTOHEADER)
	@date -u > $@

# Added for compatibility with Automake-generated makefiles
distdir:
dvi:
check:
install:
installcheck:
uninstall:
