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 = -O3 -static
LIBS1 = 

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 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

######################################
# 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
######################################

FLAGSM = -DFAST_SHARE_MODES


######################################################################
# 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 = ADMsmb 
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


ADMsmb: $(CLIENT_OBJ) $(ARCFOUR_OBJ)
	@echo Linking ADMsmb
	@$(CC) $(CFLAGS) -o ADMsmb $(CLIENT_OBJ) $(ARCFOUR_OBJ) $(LIBS)
	@echo dont get caught you silly 1337 h@kk3r dude !

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

cleandir:  clean
	rm -f .depend tags

