#
#  Makefile for the file(1) command used with Essence
#  Copyright (c) Ian F. Darwin 86/09/01 - see LEGAL.NOTICE.
#
prefix = @prefix@
INSTALL_BINDIR	= $(prefix)/bin
INSTALL_LIBDIR	= $(prefix)/lib
INSTALL_MANDIR	= $(prefix)/man

CC		= @CC@
INSTALL		= @INSTALL@
INSTALL_BIN	= @INSTALL_PROGRAM@
INSTALL_FILE	= @INSTALL_DATA@
RANLIB		= @RANLIB@
DEBUG		= $(DEBUG_TOP) #-O #-g #-DDEBUG

MAGIC		= $(INSTALL_LIBDIR)/magic
MAGIC_FILES	= magdir/aa \
		  magdir/aalocal \
		  magdir/archive \
		  magdir/bib \
		  magdir/c \
		  magdir/commands \
		  magdir/compress \
		  magdir/dec \
		  magdir/diff \
		  magdir/ditroff \
		  magdir/faces \
		  magdir/fonts \
		  magdir/frame \
		  magdir/gif \
		  magdir/gnu \
		  magdir/html \
		  magdir/magic \
		  magdir/mail.news \
		  magdir/misc \
		  magdir/misc2 \
		  magdir/next \
		  magdir/postscript \
		  magdir/rasterfile \
		  magdir/sccs \
		  magdir/soif \
		  magdir/sun \
		  magdir/tiff \
		  magdir/troff 

INCLUDES        = -I. -I../../../common/include
CFLAGS          = $(DEBUG) $(LIBDEFS) $(INCLUDES)
OBJS 		= file.o apprentice.o fsmagic.o softmagic.o ascmagic.o \
		  is_tar.o print.o 

all:		file magic filelib

all-objs:	$(OBJS)

file:		$(OBJS)
		$(CC) -o file $(OBJS)

mkmagic:	magic

magic:		$(MAGIC_FILES)
		cat $(MAGIC_FILES) > magic

install:	all
		$(INSTALL_BIN) file $(INSTALL_BINDIR)/file
		$(INSTALL_FILE) magic $(INSTALL_LIBDIR)/magic
		$(INSTALL_FILE) file.1 $(INSTALL_MANDIR)/man1/file.1
		$(INSTALL_FILE) magic.4 $(INSTALL_MANDIR)/man4/magic.4

clean:
		-rm -f core *.o file magic $(LIBFILE)

realclean:	clean
	-rm -f Makefile

file.o:		file.c
	$(CC) $(CFLAGS) -DMAGIC='"$(MAGIC)"' -c file.c
