# Copyright (C) 1999 Beau Kuiper

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */

# **** TRY TO LEAVE EVERYTHING BELOW HERE ALONE!

include ../Makefile.defs

prefix=
exec_prefix=${prefix}

# where the binary is stored
BINDIR=${exec_prefix}/bin

SRC = acl.c auth.c authanon.c authdisable.c authint.c authpam.c authunix.c \
      bufread.c cfloader.c checkip.c cmd.c config.c datasock.c dir.c file.c \
      ftp.c ftplist.c ftpout.c ftpsite.c ftpstat.c ftpstate.c ftptrans.c \
      init.c logger.c main.c myglob.c newfile.c procnum.c proxy.c ratio.c \
      select.c shmem.c socket.c string.c utils.c version.c \
      util/pwgrent.c util/snprintf.c util/strerror.c

WHOSRC = ftpwho.c util/strerror.c utils.c string.c config.c newfile.c \
         version.c util/snprintf.c util/pwgrent.c

MUDPASSWDSRC = mudpasswd.c util/strerror.c version.c util/snprintf.c

RATIOTOOLSRC = ratiotool.c util/strerror.c version.c utils.c util/snprintf.c \
	       util/pwgrent.c

MUDLOGDSRC = mudlogd.c util/strerror.c util/snprintf.c util/pwgrent.c \
	     config.c utils.c newfile.c version.c string.c

ifdef NEWMALLOC
SRC += malloc.c
WHOSRC += malloc.c
MUDPASSWDSRC += malloc.c
RATIOTOOLSRC += malloc.c
endif

# Build a debug version (NOT RECOMMENDED FOR REAL USE)
#DEBUG = 1

# these flags are needed regardless of if DEBUG is used 

CC=cc
DEFS=-DHAVE_CONFIG_H -D$(shell uname)
LIBS=-lpam 
CFLAGSSHD:=$(DEFS) -fno-common

# Set for debugging mode

ifdef DEBUG
CFLAGS=$(DEFS) -g -Wall -Wshadow -Wpointer-arith -Waggregate-return -Wstrict-prototypes -DDEBUG #-Werror
# else set for optimising output code
else
CFLAGS=$(CFLAGSSHD)
endif

OBJ = $(SRC:.c=.o)
WHOOBJ = $(WHOSRC:.c=.o)
MUDPASSWDOBJ = $(MUDPASSWDSRC:.c=.o)
RATIOTOOLOBJ = $(RATIOTOOLSRC:.c=.o)
MUDLOGDOBJ = $(MUDLOGDSRC:.c=.o)

TARGETS = $(MUDOUTPROG) $(WHOPROG) $(MUDPASSWDPROG) $(RATIOTOOLPROG) \
	  $(MUDLOGD)

all: $(TARGETS)

# always force rebuilding of version.c, so it always has the current
# date
.PHONY : version.o
version.o:
	$(CC) $(CFLAGS) -DDATESTR="\"$(shell date)\"" -c $(@:.o=.c) -o $@

$(WHOPROG): $(WHOOBJ)
	$(CC) $(CFLAGS) $(LIBS) -o $(WHOPROG) $(WHOOBJ)

$(MUDPASSWDPROG): $(MUDPASSWDOBJ)
	$(CC) $(CFLAGS) $(LIBS) -o $(MUDPASSWDPROG) $(MUDPASSWDOBJ)

$(RATIOTOOLPROG): $(RATIOTOOLOBJ)
	$(CC) $(CFLAGS) $(LIBS) -o $(RATIOTOOLPROG) $(RATIOTOOLOBJ)

$(MUDOUTPROG): $(OBJ)
	$(CC) $(CFLAGS) $(LIBS) -o $(MUDOUTPROG) $(OBJ)

$(MUDLOGD): $(MUDLOGDOBJ)
	$(CC) $(CFLAGS) $(LIBS) -o $(MUDLOGD) $(MUDLOGDOBJ)

install: all
	mkdir -p $(BINDIR)

	install $(MUDOUTPROG) -m 755 $(BINDIR)
	install $(WHOPROG) -m 755 $(BINDIR)
	install $(MUDPASSWDPROG) -m 755 $(BINDIR)
	install $(MUDLOGD) -m 755 $(BINDIR)

clean:
	rm -f $(MUDOUTPROG) $(WHOPROG) *.o *~ core DEADJOE util/*.o
	rm -f $(MUDPASSWDPROG) $(RATIOTOOLPROG) $(MUDLOGD)

distclean: clean
	rm -f Makefile

maintainer-clean: distclean


syntax highlighted by Code2HTML, v. 0.9.1