Makefile revision 2480
1# Makefile for file(1) cmd. 2# Copyright (c) Ian F. Darwin 86/09/01 - see LEGAL.NOTICE. 3# @(#)$Id: Makefile,v 1.43 1994/05/03 17:57:59 christos Exp $ 4# 5# This software is not subject to any license of the American Telephone 6# and Telegraph Company or of the Regents of the University of California. 7# 8# Permission is granted to anyone to use this software for any purpose on 9# any computer system, and to alter it and redistribute it freely, subject 10# to the following restrictions: 11# 12# 1. The author is not responsible for the consequences of use of this 13# software, no matter how awful, even if they arise from flaws in it. 14# 15# 2. The origin of this software must not be misrepresented, either by 16# explicit claim or by omission. Since few users ever read sources, 17# credits must appear in the documentation. 18# 19# 3. Altered versions must be plainly marked as such, and must not be 20# misrepresented as being the original software. Since few users 21# ever read sources, credits must appear in the documentation. 22# 23# 4. This notice may not be removed or altered. 24VERSION = 3.14 25SHELL = /bin/sh 26#MAGIC = /etc/magic 27MAGIC = /usr/local/etc/magic 28DEFS = -DMAGIC='"$(MAGIC)"' # -Dvoid=int 29CC = cc 30COPTS = -O -g # newer compilers allow both; else drop -O 31# For truly antique environments, use this for (dummy) include files: 32COPTS = -O # -Ilocalinc 33CFLAGS = $(COPTS) $(DEFS) 34LDFLAGS = $(COPTS) # -Bstatic # older gdb couldn't handle shared libs 35SHAR = bundle 36OFILE = /usr/bin/file # old or distributed version, for comparison 37# Where new binary lives; typically /usr/local (BSD), /usr/lbin (USG). 38BINDIR = /usr/local/bin 39# For installing our man pages; 40# MANCxxx is manual section for Commands, MANFxxx is section for file formats. 41# MANxDIR is directory names; MANxEXT is the filename extention. Usual values: 42# Variable V7 4BSD Sys V 43# MANCDIR /usr/man/man1 /usr/man/man1 /usr/man/u_man/man1 44# MANFDIR /usr/man/man5 /usr/man/man5 /usr/man/u_man/man4 45# MANCEXT 1 1 1 46# MANFEXT 5 5 4 47# --- possible alternative for 4BSD --- 48# MANCDIR /usr/local/man/man1 49# MANCEXT 1 50# or 51# MANCDIR /usr/man/manl 52# MANCEXT l 53# --- possible alternative for USG --- 54# MANCDIR /usr/man/local/man1 55# MANCEXT 1 56 57MANCDIR = /usr/local/man/man1 58MANCEXT = 1 59MANFDIR = /usr/local/man/man4 60MANFEXT = 4 61 62# There are no system-dependant configuration options (except maybe CFLAGS). 63# Uncomment any of these that is missing from your "standard" library. 64LOCALSRCS = # localsrc/getopt.c localsrc/strtol.c \ 65# localsrc/strtok.c localsrc/strchr.c 66LOCALOBJS = # localsrc/getopt.o localsrc/strtol.o \ 67# localsrc/strtok.o localsrc/strchr.o 68# These are not compiled in unless you use -Ilocalinc, but 69# are not commented out as "make dist" &c use them. 70LOCALINC = # localinc/*.h localinc/sys/*.h 71 72SRCS = file.c apprentice.c fsmagic.c softmagic.c ascmagic.c \ 73 compress.c is_tar.c \ 74 print.c $(LOCALSRCS) $(LOCALINC) 75OBJS = file.o apprentice.o fsmagic.o softmagic.o ascmagic.o \ 76 compress.o is_tar.o \ 77 print.o $(LOCALOBJS) 78 79ALLSRC = LEGAL.NOTICE README MAINT PORTING $(SRCS) *.h \ 80 Makefile file.man magic.man 81ALLMAGIC = Magdir/Makefile Magdir/Localstuff Magdir/Header Magdir/[a-z]* 82 83all: file magic file.${MANCEXT} magic.${MANFEXT} 84 85TESTFILES = * tst/* 86try: all $(OFILE) 87 cd tst; $(MAKE) 88 time $(OFILE) $(TESTFILES) >/tmp/t1 # can't use ./magic 89 time ./file -m ./magic $(TESTFILES) >/tmp/t2 90 -diff -b /tmp/t[12] 91 what ./file >lastnocore 92 93file: $(OBJS) 94 $(CC) $(CFLAGS) $(OBJS) -o $@ 95lint: $(SRCS) 96 lint -ha $(DEFS) $(SRCS) | tee $@ 97magic: Magdir 98# Magdir/Makefile's "install" mv's magic to here for testing. 99 cd Magdir; $(MAKE) install 100 101ascmagic.o: names.h 102 103compress.o apprentice.o ascmagic.o file.o fsmagic.o print.o softmagic.o: file.h 104 105install: file magic 106 cp file $(BINDIR)/file 107 cp magic $(MAGIC) 108 109install.man: file.${MANCEXT} magic.${MANFEXT} 110 cp file.${MANCEXT} $(MANCDIR)/file.$(MANCEXT) 111 cp magic.${MANFEXT} $(MANFDIR)/magic.$(MANFEXT) 112 113clean: 114 rm -f *.o core file magic lint dist.* MANIFEST \ 115 magic.${MANFEXT} file.${MANCEXT} 116clobber: 117 cd tst; $(MAKE) clean 118 119 120magic.${MANFEXT} : Makefile magic.man 121 @rm -f $@ 122 sed -e s@__SECTION__@${MANFEXT}@g \ 123 -e s@__MAGIC__@${MAGIC}@g magic.man > $@ 124 125file.${MANCEXT} : Makefile file.man 126 @rm -f $@ 127 sed -e s@__SECTION__@${MANCEXT}@g \ 128 -e s@__MAGIC__@${MAGIC}@g file.man > $@ 129 130send: dist 131 ftp ftp.cs 132 133dist: dist.src dist.magic 134 @echo Now check this patchlevel! 135 ident patchlevel.h 136 137dist.src: $(ALLSRC) MANIFEST 138# Some versions of shar can't handle a single file from 139# a subdirectory, so we manually insert mkdir as needed. 140# The point is to exclude all the generable targets in tst. 141 (echo mkdir localinc localinc/sys localsrc tst; \ 142 $(SHAR) $(ALLSRC) MANIFEST) > $@ 143 144rcsdiff: $(ALLSRC) 145 rcsdiff -q RCS/* 146 147MANIFEST: $(ALLSRC) 148 ident $(ALLSRC) > MANIFEST 149dist.magic: Magdir 150# As above, but to exclude Magdir/RCS from being shipped. 151 (echo mkdir Magdir; $(SHAR) $(ALLMAGIC)) >$@ 152 153tar: $(ALLSRC) $(ALLMAGIC) 154 -rm -fr file-${VERSION} 155 -mkdir file-${VERSION} file-${VERSION}/Magdir 156 ln $(ALLSRC) file-${VERSION} 157 ln ${ALLMAGIC} file-${VERSION}/Magdir 158 tar cvf file-${VERSION}.tar file-${VERSION} 159 -rm -fr file-${VERSION} 160