# 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.

SHELL = /bin/sh
# If you use gcc, you should either run the fixincludes script that
# comes with it or else use gcc with the -traditional option.  Otherwise
# ioctl calls will be compiled incorrectly on some systems.
CC = gcc

# 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 system call.
DEFS = -I. -DDIRENT
CFLAGS = -g $(DEFS)

LDFLAGS = -g

LIBS = #-ldir -lx

SRCS = copyin.c copyout.c copypass.c dstring.c glob.c global.c main.c \
	util.c error.c getopt.c getopt1.c filemode.c version.c
OBJS = copyin.o copyout.o copypass.o dstring.o glob.o global.o main.o \
	util.o error.o getopt.o getopt1.o filemode.o version.o
HDRS = cpio.h dstring.h extern.h getopt.h
DISTFILES = $(SRCS) $(HDRS) COPYING ChangeLog Makefile README

all:	cpio
.PHONY: all

cpio:	$(OBJS)
	$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)

copyin.o:	cpio.h dstring.h extern.h
copyout.o:	cpio.h dstring.h extern.h
copypass.o:	cpio.h dstring.h extern.h
dstring.o:	dstring.h
global.o:	cpio.h dstring.h
main.o:		cpio.h dstring.h extern.h
util.o:		extern.h

LINT:	$(SRCS) $(HDRS)
	lint $(DEFS) $(SRCS) > LINT

tags:	$(SRCS)
	ctags $(SRCS)

TAGS:	$(SRCS)
	etags $(SRCS)

dist:
	echo cpio-`sed -e '/version_string/!d' -e 's/[^0-9.]*\([0-9.]*\).*/\1/' -e q < version.c` > .fname
	rm -rf `cat .fname`
	mkdir `cat .fname`
	ln $(DISTFILES) `cat .fname`
	tar chZf `cat .fname`.tar.Z `cat .fname`
	rm -rf `cat .fname` .fname
.PHONY: dist

clean:
	rm -f cpio *.o core tags TAGS a.out
.PHONY: clean
