###########################################################################
# Makefile for Samba SMB client/server for unix
# Copyright Andrew Tridgell 1992,1993,1994
###########################################################################

# The base manpages directory to put the man pages in
# Note: $(MANDIR)/man1, $(MANDIR)/man5 and $(MANDIR)/man8 must exist.
MANDIR = /usr/local/man

# The directory to put the executables in
INSTALLDIR = /usr/local/samba

# The permissions to give the server executables
INSTALLPERMS_S = 0755

# The permissions to give the client and test executables
INSTALLPERMS_C = 0755

# Add any optimisation or debugging flags here
FLAGS1 = -O
LIBS1 = 

# If you have the gcc compiler then use it, otherwise any ansi-C compiler
CC = gcc

# set these to where to find various files
# These can be overridden by command line switches (see smbd(8))
FLAGS2 = -DDEBUGFILE=\"/usr/local/samba/log\"
FLAGS3 = -DSERVICES=\"/usr/local/samba/smb.conf\"

# 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))
FLAGS4 = -DGUEST_ACCOUNT=\"nobody\"

# what mode mask to use when creating files and directories
# This can be overridden in the runtime configuration file (see smb.conf(5))
FLAGS5 = -DDEF_CREATE_MASK=0755


#####################################
# WHICH OPERATING SYSTEM?
# UNCOMMENT ONE OF THE SECTIONS BELOW
# MAKE SURE ONLY *ONE* IS UNCOMMENTED
#
# The following are additional flags that may apply
#   -DNETGROUP if your machine supports yp netgroups
#   -DSHADOW_PWD if you are using shadow passwords
#   -DPWDAUTH if your library has a pwdauth() call
#   -DUSE_DIRECT if your library uses direct rather than dirent structures
#####################################

# This is for SUNOS
FLAGSM = -DSUN -DPWDAUTH
LIBSM =   

# Use this for Linux with shadow passwords
# FLAGSM = -DLINUX -DSHADOW_PWD
# LIBSM = -lshadow

# Use this for Linux without shadow passwords
# FLAGSM = -DLINUX
# LIBSM = 

# This is for SOLARIS
# FLAGSM = -DSOLARIS -DSHADOW_PWD -DNETGROUP -DBSD_COMP
# LIBSM = -lsocket -lnsl

# This is for SVR4
# FLAGSM = -DSVR4 -DSHADOW_PWD
# LIBSM = -lsocket -lnsl -lc -L/usr/ucblib -lucb

# This is for ULTRIX
# FLAGSM = -DULTRIX -DUSE_DIRECT
# LIBSM =   

# This is for OSF1 (Alpha)
# FLAGSM = -DOSF1
# LIBSM =

# This is for AIX
# FLAGSM = -DAIX
# LIBSM =   

# This is for BSDI
# FLAGSM = -DBSDI -DPWDAUTH -DUSE_DIRECT
# LIBSM =   

# This is for NetBSD
# FLAGSM = -DNETBSD -DUSE_DIRECT -DSHADOW_PWD
# LIBSM = -lcrypt 

# This is for SEQUENT. Can someone test this please?
# FLAGSM = -DSEQUENT -DPWDAUTH -DUSE_DIRECT
# LIBSM =   

# This is for HP-UX
# FLAGSM = -DHPUX -Aa -D_HPUX_SOURCE -D_POSIX_SOURCE
# LIBSM = 

# This is for SGI. Can someone test this please?
# FLAGSM = -DSGI -DPWDAUTH -DUSE_DIRECT
# LIBSM =   

# This is for FreeBSD
# FLAGSM = -DFreeBSD -DUSE_DIRECT
# LIBSM = -lcrypt 

# This is for NeXT
# FLAGSM = -DNEXT -posix
# LIBSM = 

# This is for ISC SVR3V4
# FLAGSM = -posix -D_SYSV3 -fpcc-struct-return -DISC -DSHADOW_PWD \
#      -DHAVE_TIMEZONE
# LIBSM = -lsec -lcrypt -linet



######################################################################
# DON'T EDIT BELOW THIS LINE
######################################################################
CFLAGS = $(FLAGS1) $(FLAGS2) $(FLAGS3) $(FLAGS4) $(FLAGS5) $(FLAGSM)
LIBS = $(LIBS1) $(LIBSM)

all: smbd smbclient nmbd testparm testprns

INCLUDES = local.h includes.h smb.h loadparm.h params.h pcap.h

smbd: server.o util.o loadparm.o params.o access.o pcap.o
	$(CC) $(CFLAGS) -o smbd server.o util.o loadparm.o params.o \
                        access.o pcap.o $(LIBS)

nmbd: nameserv.o util.o
	$(CC) $(CFLAGS) -o nmbd nameserv.o util.o $(LIBS)

smbclient: client.o util.o
	$(CC) $(CFLAGS) -o smbclient client.o util.o $(LIBS)

testparm: testparm.o util.o loadparm.o params.o access.o pcap.o
	$(CC) $(CFLAGS) -o testparm testparm.o util.o loadparm.o params.o \
                        access.o pcap.o $(LIBS)

testprns: testprns.o loadparm.o params.o util.o pcap.o
	$(CC) $(CFLAGS) -o testprns testprns.o loadparm.o params.o util.o \
                        pcap.o $(LIBS)

install: installbin installman

installbin: all
	cp smbd smbclient nmbd testparm testprns $(INSTALLDIR)
	chmod $(INSTALLPERMS_S) $(INSTALLDIR)/smbd
	chmod $(INSTALLPERMS_S) $(INSTALLDIR)/nmbd
	chmod $(INSTALLPERMS_C) $(INSTALLDIR)/smbclient
	chmod $(INSTALLPERMS_C) $(INSTALLDIR)/testparm
	chmod $(INSTALLPERMS_C) $(INSTALLDIR)/testprns

installman:
	cp *.1 $(MANDIR)/man1
	cp *.5 $(MANDIR)/man5
	cp *.8 $(MANDIR)/man8
	chmod u=rw,go=r $(MANDIR)/man1/smbclient.1
	chmod u=rw,go=r $(MANDIR)/man1/testparm.1
	chmod u=rw,go=r $(MANDIR)/man1/testprns.1
	chmod u=rw,go=r $(MANDIR)/man5/smb.conf.5
	chmod u=rw,go=r $(MANDIR)/man8/smbd.8
	chmod u=rw,go=r $(MANDIR)/man8/nmbd.8
	
source:
	tar cfv sources.tar COPYING README THANKS \
                            Makefile announce bugs change-log \
                            history smb.conf.sample \
                            *.c *.h *.[158]

.c.o: $(INCLUDES)
	$(CC) $(CFLAGS) -c $*.c

clean:
	rm -f core *.o *~ smbd smbclient nmbd testparm testprns

