# NcFTP Makefile
PKGNAME=ncftp
VERSION=2.0.4

# List of .c files to compile:
CFILES=\
Cmdline.c    Cmdlist.c    Cmds.c       Cpp.c        DateSize.c   FTP.c \
Find.c       Get.c        GetPass.c    Getopt.c     Glob.c       Hostwin.c \
LGets.c      LineList.c   List.c       Macro.c      Main.c       MakeArgv.c \
Open.c       Poll.c       Prefs.c      Progress.c   Put.c        RCmd.c \
Recent.c     Strn.c       Tips.c       Util.c       WGets.c      Win.c \
Xfer.c

# List of .o object files to generate:
OFILES=${CFILES:.c=.o}

HFILES=\
COPYRIGHT.h   Cmdline.h     Cmds.h        Config.h      Cpp.h \
Curses.h      DateSize.h    Defaults.h    FTP.h         Find.h \
Get.h         GetPass.h     Getopt.h      Glob.h        Hostwin.h \
LGets.h       LineList.h    List.h        Macro.h       Main.h \
MakeArgv.h    Open.h        Poll.h        Prefs.h       Progress.h \
Put.h         RCmd.h        Recent.h      Strn.h        Sys.h \
Tips.h        Util.h        Version.h     WGets.h       Win.h \
Xfer.h        acconfig.h

# Compiled executable's pathname:
PROG=ncftp

SHELL=/bin/sh
.SUFFIXES: .c .o

CC=@CC@
#CFLAGS=-g -Wall -Wshadow -Wconversion -Wstrict-prototypes -Wmissing-prototypes
CFLAGS=@CFLAGS@
VPATH=@srcdir@
CPPFLAGS=@CPPFLAGS@ -I.

LIBS=@LIBS@
LDFLAGS=@LDFLAGS@

# Any -D definitions:
DEFS=@DEFS@

# File permissions for chmod:
MODE=755

README=./README
DOCFILES=$(README) ncftp.1 CHANGELOG WHATSNEW
CFGFILES=Config.h.in Config.h.top configure.in configure Makefile.in
CFGJUNK=Config.h Makefile config.*

# This is everything that is copied when you make a shar or tar.
PACKAGE=$(DOCFILES) $(CFILES) $(HFILES) $(CFGFILES)

all: $(PROG)
	chmod $(MODE) $(PROG)
	@ls -l $(PROG)
	@echo 'Done.'

$(PROG): $(OFILES)
	$(CC) $(OFILES) -o $@ $(LDFLAGS) $(LIBS)

.c.o:
	$(CC) $(CFLAGS) $(DEFS) $(CPPFLAGS) $< -c

### Archiving #################################################################

TARDIR=$(PKGNAME)-$(VERSION)
TARFILE=$(TARDIR).tar
TGZFILE=$(TARDIR).tgz
SAVEDPWD=$(PWD)

shar:
	shar $(PACKAGE) | cat $(README) - > $(PROG).shar

tar: $(PACKAGE)
	-@mkdir /usr/tmp/TAR
	-@mkdir /usr/tmp/TAR/$(TARDIR)
	-@chmod ga+r $(PACKAGE)
	-@chmod 755 /usr/tmp/TAR/$(TARDIR)
	cp -pr $(PACKAGE) /usr/tmp/TAR/$(TARDIR)
	( cd /usr/tmp/TAR ; tar cf $(SAVEDPWD)/$(TARFILE) ./$(TARDIR) )
	-@chmod 644 $(TARFILE)
	-@rm -rf /usr/tmp/TAR
	-@ls -l $(TARFILE)

gz: tar
	gzip -c $(TARFILE) > $(TGZFILE)
	-@rm $(TARFILE)
	-@chmod 644 $(TGZFILE)
	-@ls -l $(TGZFILE)

### Cleaning supplies ########################################################

clean:
	-/bin/rm -f $(OFILES) $(PROG) core

distclean:
	-/bin/rm -f $(CFGJUNK)

realclean mostlyclean: clean distclean

### Junk for me ##############################################################

tarsrc:
	-@chmod ga+r $(PACKAGE)
	tar cvf - $(CFILES) $(HFILES) | gzip -f > $(TARFILE)

tarcfg:
	tar cvf - $(CFGFILES) | gzip -f > cfg.$(TARFILE)

lint:
	lint $(CFILES) $(DEFS) > $(PROG).lint

### Dependencies #############################################################

GLOBAL_H=Util.h Strn.h LineList.h Win.h Sys.h Config.h

Cmdline.o: $(GLOBAL_H) Cmdline.h Cmds.h Main.h MakeArgv.h

Cmdlist.o: $(GLOBAL_H) Main.h Open.h Cmds.h List.h Get.h Put.h Hostwin.h
Cmdlist.o: Prefs.h Cmdline.h Find.h

Cmds.o: $(GLOBAL_H) RCmd.h Cmdline.h MakeArgv.h Macro.h Main.h DateSize.h Open.h
Cmds.o: Glob.h Getopt.h FTP.h Recent.h Cpp.h Prefs.h Tips.h Cmds.h Version.h

Cpp.o: $(GLOBAL_H) Curses.h Cpp.h

DateSize.o: $(GLOBAL_H) RCmd.h Cmds.h Xfer.h List.h DateSize.h

Find.o: $(GLOBAL_H) RCmd.h Xfer.h Cmds.h Find.h Get.h

FTP.o: $(GLOBAL_H) FTP.h RCmd.h

Get.o: $(GLOBAL_H) RCmd.h Xfer.h Cmds.h Get.h Glob.h DateSize.h List.h
Get.o: Getopt.h

Getopt.o: $(GLOBAL_H) Getopt.h

GetPass.o: $(GLOBAL_H) GetPass.h

Glob.o: $(GLOBAL_H) List.h Glob.h RCmd.h Xfer.h Main.h

Hostwin.o:  $(GLOBAL_H) Util.h Curses.h Hostwin.h Recent.h Open.h Cmds.h WGets.h

LGets.o: $(GLOBAL_H) LGets.h

LineList.o: $(GLOBAL_H) Sys.h Config.h LineList.h

List.o: $(GLOBAL_H) RCmd.h Xfer.h Cmds.h List.h

Macro.o: $(GLOBAL_H) Macro.h Cmdline.h MakeArgv.h

Main.o: $(GLOBAL_H) Main.h Cmds.h Open.h Cmdline.h DateSize.h Recent.h Prefs.h
Main.o: FTP.h Getopt.h Xfer.h Tips.h Version.h

MakeArgv.o: $(GLOBAL_H) MakeArgv.h

Open.o: $(GLOBAL_H) Open.h GetPass.h Cmds.h RCmd.h Recent.h FTP.h Get.h Getopt.h
Open.o: Macro.h Hostwin.h Main.h

Poll.o: $(GLOBAL_H) Xfer.h Progress.h Poll.h

Prefs.o: $(GLOBAL_H) Cmds.h Progress.h Hostwin.h Prefs.h RCmd.h Recent.h Main.h
Prefs.o: WGets.h Main.h

Progress.o: $(GLOBAL_H) Cmds.h Xfer.h Progress.h GetPass.h

Put.o: $(GLOBAL_H) RCmd.h Xfer.h Cmds.h Get.h Put.h

RCmd.o: $(GLOBAL_H) RCmd.h Open.h Main.h Xfer.h FTP.h

Recent.o: $(GLOBAL_H) Recent.h FTP.h

Strn.o: $(GLOBAL_H) Strn.h

Tips.o: $(GLOBAL_H) Tips.h

Util.o: $(GLOBAL_H) Main.h Recent.h

Win.o: $(GLOBAL_H) Curses.h Main.h Recent.h RCmd.h LGets.h GetPass.h WGets.h Version.h

WGets.o: $(GLOBAL_H) Curses.h WGets.h

Xfer.o: $(GLOBAL_H) Main.h Xfer.h RCmd.h FTP.h Progress.h Poll.h

# eof
