# Makefile for GNU cpio.
# Copyright (C) 1988, 1989, 1990 Free Software Foundation, Inc.

# 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 1, 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.

# $Header: e:/gnu/cpio/RCS/makefile 1.1.0.2 90/09/23 23:41:08 tho Exp $

.PHONY: all install clean veryclean

# Where `make install' should put the binaries:
BINDIR	= c:/bin

# Where the gnulib lives
VPATH	= d:/usr/lib;d:/usr/include

PROGRAM	= cpio
VERSION	= 1.1

INSTALL = cp -v
DISK	= b
ZIPFILE = $(PROGRAM)

# DEFS can contain:
# -DUSG			System V strings, headers, ndir.h.
# -DDIRENT		If you have dirent.h.
# -DSYSNDIR		Old Xenix systems (selects sys/ndir.h).
# -DMTIO_MISSING	If you lack sys/mtio.h.
# -DVPRINTF_MISSING	If you lack vprintf function (but have _doprnt).
# -DBCOPY_MISSING	If you lack bcopy function.
# -DMKDIR_MISSING	If you lack mkdir and rmdir system calls.

MODEL	= C
CFLAGS	= -A$(MODEL) -Ox -W4 -Za -DUSG -DMTIO_MISSING \
	  -DSTDC_HEADERS -DSMART_SHELL
LDFLAGS	= /e/st:0x2000/noe/far/packcode setargv

LOADLIBES= gnulib_$(MODEL)

SRCS	= copyin.c copyout.c copypass.c dstring.c global.c main.c \
	  util.c filemode.c version.c

OBJS	= copyin.obj copyout.obj copypass.obj dstring.obj global.obj \
	  main.obj util.obj filemode.obj version.obj _cwild.obj
INCS	= cpio.h dstring.h extern.h


RCSFILES= $(SRCS) $(INCS) makefile
MISC	= readme copying make.inc todo changelog \
	  $(addprefix RCS/, glob.c getopt.h error.c getopt.c getopt1.c \
			    msd_dir.h msd_pwd.h)

# Targets
all: $(PROGRAM).exe

$(PROGRAM).exe: $(OBJS)
	$(LINK) $(LDFLAGS) $^, $@, nul, $(LOADLIBES),

copyin.obj copyout.obj copypass.obj main.obj: cpio.h dstring.h extern.h
dstring.obj: dstring.h
global.obj: cpio.h dstring.h
util.obj: extern.h

install: $(BINDIR)/$(PROGRAM).exe

$(BINDIR)/%: %
	$(INSTALL) $< $@

tags: $(SRCS)
	etags -t *.c

clean:
	$(RM) *.obj patches *~ *.tar

veryclean: clean
	$(RM) *.exe errs tags *.uue
	rcsclean *.c *.h makefile

include make.inc

.PHONY: dist
dist: $(PROGRAM).uue

$(PROGRAM).tar: readme copying makefile patches $(PROGRAM).exe

patches: $(SRCS) $(INCS) $(addprefix RCS/, $(RCSFILES))
	rcsdiff -c -r$(VERSION) *.[ch] > $@

.PHONY: test-dist
test-dist: $(PROGRAM).uue $(addprefix RCS/, $(RCSFILES))
	$(CO) -f -r$(VERSION) *.[ch]
	sed /\.tar\.Z/s//.Z/ $< | uudecode
	compress -d < $(PROGRAM).Z | tar -xOf -  patches | patch -s
	rcsdiff -q *.[ch]
