
###########################################################################
# Makefile for Samba SMB client/server for unix
# Copyright Andrew Tridgell 1992-1998
# Copyright John H Terpstra 1995-1998
# modified by the ADM Crew for ADM smb
###########################################################################


# The directories to put things in. If you use multiple
# architectures or share the samba binaries across NFS then
# you will probably want to change this layout.
# Note: The SBINDIR is for files you do not want users to access
#       normally only applies to nmbd and smbd
#       SBINDIR implies a secure binary directory
BINDIR = $(BASEDIR)/bin
SBINDIR = $(BASEDIR)/bin
LIBDIR = $(BASEDIR)/lib
VARDIR = $(BASEDIR)/var

# The permissions to give the executables
INSTALLPERMS = 0755

# Add any optimisation or debugging flags here
# add -DSYSLOG for syslog support
FLAGS1 = -O
LIBS1 = 

# You will need to use a ANSI C compiler. This means under SunOS 4 you can't 
# use cc, instead you will have to use gcc. 
# CC = gcc

# This may help with some versions of make
SHELL = /bin/sh

# The following can be useful for compiling on multiple architectures
# just uncommment them putting the right directory in.
# srcdir=./
# VPATH=$(srcdir)

# 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))
#SMBLOGFILE = $(VARDIR)/log.smb
#NMBLOGFILE = $(VARDIR)/log.nmb
#CONFIGFILE = $(LIBDIR)/smb.conf

#LMHOSTSFILE = $(LIBDIR)/lmhosts
#DRIVERFILE = $(LIBDIR)/printers.def
#SMB_PASSWD = $(BINDIR)/smbpasswd
#SMB_PASSWD_FILE = $(BASEDIR)/private/smbpasswd
#WEB_ROOT = $(BASEDIR)

# the directory where lock files go
#LOCKDIR = $(VARDIR)/locks

# The directory where code page definition files go
#CODEPAGEDIR = $(LIBDIR)/codepages
# The current codepage definition list.
#CODEPAGELIST= 437 850 852 932 866 949 950 936

# set this to the default group you want your machine to appear in
# for browsing. This can also be set in nmbd (see nmbd(8))
WORKGROUP = WORKGROUP

# set this to the name of the default account, which is the one
# to use when no username or password is specified.  This can be overridden
# in the runtime configuration file (see smb.conf(5))
# NOTE: The account "nobody" may not be a good one as
# on many unixes it may not be able to print. Thus you
# might have to create a separate guest account that can print.
GUESTACCOUNT = nobody

# where you are going to have the smbrun binary. This defaults to the 
# install directory. This binary is needed for correct printing
# and magic script execution. This should be an absolute path!
# Also not that this should include the name "smbrun" on the end (the
# name of the executable)
#SMBRUN = $(BINDIR)/smbrun


######################################
# WHICH AWK? awk is used for automatic prototype generation. GNU awk works
# where inferior awks don't. Sun is one manufacturer who supplies both
# a broken awk called 'awk' and a fixed one called 'nawk'. mkproto.awk will
# only work with the latter, and even that isn't as good as free GNU awk.
#
# Leave this uncommented; the OS-specific stuff will override it if required
AWK = awk
######################################

# If you are using Linux kernel version 2.1.70 and later, you should
# uncomment the following line to compile the smbmount utilities
# together with Samba. If you are using Linux kernel version 2.0.x
# you must use the smbfs utilities from
# ftp://ftp.gwdg.de/pub/linux/misc/smbfs

# MOUNT_PROGS = smbmount smbmnt smbumount

# Use this for Linux with shadow passwords - but not using PAM!
# contributed by Andrew.Tridgell@anu.edu.au
# add -DLINUX_BIGCRYPT is you have shadow passwords but don't have the
# right libraries and includes
# FLAGSM = -DLINUX -DSHADOW_PWD -DFAST_SHARE_MODES
# LIBSM = -lshadow

# Use this for Linux without shadow passwords or for any Linux
# system that uses PAM (eg: RedHat) in which case it handles ALL
# authentication methods that are supported by the version of
# PAM that is available on your system.
# contributed by Andrew.Tridgell@anu.edu.au & John.Terpstra@aquasoft.com.au
# AXPROC defines DEC Alpha Processor
# FLAGSM = -DLINUX -DAXPROC -DFAST_SHARE_MODES
# FLAGSM = -DLINUX -DFAST_SHARE_MODES
# LIBSM = 

# Use this for Linux with shadow passwords and quota - but not using PAM!
# contributed by xeno@mix.hive.no
# Tested on the 1.3.57 kernel and ext2fs filesystem.
# Notes:
# /usr/include/sys/quota.h must be a symlink to /usr/include/linux/quota.h
# The directory quota here must be a symlink to your quota package.
# I just do 'ln -sf /usr/src/quota-1.50 quota' in this directory to get it to work.
# FLAGSM = -O3 -m486 -DLINUX -DSHADOW_PWD -DQUOTAS -DFAST_SHARE_MODES
# LIBSM = -lshadow

# Use this for Linux with quota and glibc2 - not using PAM!
# contributed by Thorvald Natvig <slicer@bimbo.hive.no>
# Tested on the 2.0.30 kernel and ext2fs filesystem.
# FLAGSM = -DLINUX -DQUOTAS -DNO_ASMSIGNALH -DGLIBC2 -DFAST_SHARE_MODES
# LIBSM = -L/lib/libc5-compat -lcrypt

# Use this for Linux with glibc2 (libc6)
# contributed by Eloy Paris <peloy@ven.ra.rockwell.com>
# FLAGSM = -DLINUX -DNETGROUP -DSHADOW_PWD -DALLOW_CHANGE_PASSWORD -DFAST_SHARE_MODES -DNO_ASMSIGNALH -DGLIBC2
# LIBSM = -lnsl -lcrypt

# Use this for Linux with glibc2 (libc6) - RedHat Linux v5.0 with PAM
# contributed by John H Terpstra <jht@aquasoft.com.au>
 FLAGSM = -DLINUX -DNETGROUP -DALLOW_CHANGE_PASSWORD -DFAST_SHARE_MODES -DNO_ASMSIGNALH -DGLIBC2
 LIBSM = -lnsl -lcrypt

# FOR OPEN BSD (thnx to jobe )
# FLAGSM = -DFAST_SHARE_MODES -DBSD44 


######################################################################
# DON'T EDIT BELOW THIS LINE
######################################################################

PASSWD_FLAGS = -DSMB_PASSWD=\"$(SMB_PASSWD)\" -DSMB_PASSWD_FILE=\"$(SMB_PASSWD_FILE)\"
CFLAGS1 = $(FLAGS1) -DSMBLOGFILE=\"$(SMBLOGFILE)\" -DNMBLOGFILE=\"$(NMBLOGFILE)\"
CFLAGS2 = -DCONFIGFILE=\"$(CONFIGFILE)\" -DLMHOSTSFILE=\"$(LMHOSTSFILE)\" -DWEB_ROOT=\"$(WEB_ROOT)\"
CFLAGS3 = -DLOCKDIR=\"$(LOCKDIR)\" -DSMBRUN=\"$(SMBRUN)\" -DCODEPAGEDIR=\"$(CODEPAGEDIR)\"
CFLAGS4 = -DWORKGROUP=\"$(WORKGROUP)\" -DGUEST_ACCOUNT=\"$(GUESTACCOUNT)\" -DDRIVERFILE=\"$(DRIVERFILE)\"
CFLAGS5 = $(CFLAGS1) $(CFLAGS2) $(CFLAGS3) $(CFLAGS4) $(FLAGSM) $(AFS_FLAGS) $(KRB5_FLAGS) $(KRB4_FLAGS) $(RPM_OPT_FLAGS)
CFLAGS  = $(CFLAGS5) $(PAM_FLAGS) $(DCE_FLAGS) $(DES_FLAGS) $(PASSWD_FLAGS) $(VTP_FLAGS)
LIBS = $(LIBS1) $(LIBSM) $(PAM_LIBS) $(DCE_LIBS) $(KRB5_LIBS) $(KRB4_LIBS) $(DES_LIB)

INCLUDES1 = $(srcdir)version.h $(srcdir)local.h $(srcdir)includes.h $(srcdir)smb.h 
INCLUDES2 = $(srcdir)trans2.h 
INCLUDES = $(INCLUDES1) $(INCLUDES2)

PROGS1 = ADM-smb 
PROGS = $(PROGS1)

SCRIPTS = smbtar addtosmbpass


######################################################################
# object modules
######################################################################

# client specific object code in the rpc_pipes directory
RPC_CLI_OBJ = rpc_pipes/ntclientpipe.o rpc_pipes/ntclientlsa.o rpc_pipes/ntclientnet.o 

# server object files in the rpc_pipes subdirectory
RPC_OBJ1 = rpc_pipes/srvparse.o rpc_pipes/smbparse.o rpc_pipes/lsaparse.o rpc_pipes/pipeutil.o 
RPC_OBJ2 = rpc_pipes/pipe_hnd.o rpc_pipes/samrparse.o rpc_pipes/wksparse.o rpc_pipes/lsa_hnd.o
RPC_OBJ = $(RPC_OBJ1) $(RPC_OBJ2) 

# general utility object files
UTILOBJ1 = util.o system.o charset.o kanji.o fault.o smbencrypt.o smbdes.o charcnv.o
UTILOBJ2 = $(UTILOBJ1) md4.o loadparm.o params.o pcap.o username.o time.o namequery.o nmblib.o
UTILOBJ = $(UTILOBJ2) interface.o replace.o print_svid.o smberr.o mem_man/mem_man.o slprintf.o


# object files for smbclient
CLIENT_OBJ = client.o ntclient.o credentials.o clientutil.o  getsmbpass.o $(UTILOBJ) $(RPC_CLI_OBJ) $(RPC_OBJ)

# object files for smbmount
MOUNT_OBJ = smbmount.o ntclient.o credentials.o clientutil.o getsmbpass.o $(UTILOBJ) $(RPC_CLI_OBJ) $(RPC_OBJ)


# object files to be auto-prototyped
PROTOOBJ = $(UTILOBJ) $(SMBDOBJ) $(NMBDOBJ) $(LOCKOBJ) $(CLIENT_OBJ) $(STATUS_OBJ) cgi.o namequery.o


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

all : CHECK $(SPROGS) $(PROGS) 

CHECK :
	@$(SHELL) $(srcdir)checkos.sh $(FLAGSM)
	@echo "Using CFLAGS = $(CFLAGS)"
	@echo "Using LIBS = $(LIBS)"

.SUFFIXES:
.SUFFIXES: .c .o .h

.c.o: $(INCLUDES)
	@echo Compiling $*.c
	@$(CC) $(CFLAGS) -c $(srcdir)$*.c -o $(srcdir)$*.o


ADM-smb: $(CLIENT_OBJ) $(ARCFOUR_OBJ)
	@echo Linking ADM-smb
	@$(CC) $(CFLAGS) -o ADM-smb $(CLIENT_OBJ) $(ARCFOUR_OBJ) $(LIBS)


clean:
	rm -f core *.o */*.o *~ $(PROGS) $(SPROGS)

cleandir:  clean
	rm -f .depend tags

