1 # Makefile for file(1) cmd.
2 # Copyright (c) Ian F. Darwin 86/09/01 - see LEGAL.NOTICE.
3 # @(#)$Id: Makefile.std,v 1.15 2002/07/03 18:57:52 christos Exp $
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.
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:
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.
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.
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.
23 # 4. This notice may not be removed or altered.
28 MAGIC = /usr/local/etc/magic
29 DEFS = -DMAGIC='"$(MAGIC)"' -DBUILTIN_ELF # -Dvoid=int
31 COPTS = -O -g # newer compilers allow both; else drop -O
32 # For truly antique environments, use this for (dummy) include files:
33 COPTS = -O # -Ilocalinc
34 CFLAGS = $(COPTS) $(DEFS)
35 LDFLAGS = $(COPTS) # -Bstatic # older gdb couldn't handle shared libs
37 OFILE = /usr/bin/file # old or distributed version, for comparison
38 # Where new binary lives; typically /usr/local (BSD), /usr/lbin (USG).
39 BINDIR = /usr/local/bin
40 # For installing our man pages;
41 # MANCxxx is manual section for Commands, MANFxxx is section for file formats.
42 # MANxDIR is directory names; MANxEXT is the filename extention. Usual values:
43 # Variable V7 4BSD Sys V
44 # MANCDIR /usr/man/man1 /usr/man/man1 /usr/man/u_man/man1
45 # MANFDIR /usr/man/man5 /usr/man/man5 /usr/man/u_man/man4
48 # --- possible alternative for 4BSD ---
49 # MANCDIR /usr/local/man/man1
52 # MANCDIR /usr/man/manl
54 # --- possible alternative for USG ---
55 # MANCDIR /usr/man/local/man1
58 MANCDIR = /usr/local/man/man1
60 MANFDIR = /usr/local/man/man4
63 # There are no system-dependant configuration options (except maybe CFLAGS).
64 # Uncomment any of these that is missing from your "standard" library.
65 LOCALSRCS = # localsrc/getopt.c localsrc/strtol.c \
66 # localsrc/strtok.c localsrc/strchr.c
67 LOCALOBJS = # localsrc/getopt.o localsrc/strtol.o \
68 # localsrc/strtok.o localsrc/strchr.o
69 # These are not compiled in unless you use -Ilocalinc, but
70 # are not commented out as "make dist" &c use them.
71 LOCALINC = # localinc/*.h localinc/sys/*.h
73 SRCS = file.c apprentice.c fsmagic.c softmagic.c ascmagic.c \
74 compress.c is_tar.c readelf.c \
75 print.c $(LOCALSRCS) $(LOCALINC)
76 OBJS = file.o apprentice.o fsmagic.o softmagic.o ascmagic.o \
77 compress.o is_tar.o readelf.o \
79 HDRS = file.h names.h patchlevel.h readelf.h tar.h
81 AUTOSRC=configure configure.in install-sh config.h.in Makefile.in
82 ALLSRC = LEGAL.NOTICE README MAINT PORTING $(SRCS) $(HDRS) \
83 Makefile.std file.man magic.man magic2mime $(AUTOSRC) \
85 ALLMAGIC = Magdir/[a-z]*
87 all: file magic file.${MANCEXT} magic.${MANFEXT}
92 time $(OFILE) $(TESTFILES) >/tmp/t1 # can't use ./magic
93 time ./file -m ./magic $(TESTFILES) >/tmp/t2
95 what ./file >lastnocore
98 $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $@
100 lint -ha $(DEFS) $(SRCS) | tee $@
101 magic: Localstuff Header Magdir
102 cat Header Localstuff Magdir/[a-z] > $@
106 compress.o apprentice.o ascmagic.o file.o fsmagic.o print.o softmagic.o: file.h
109 cp file $(BINDIR)/file
112 install.man: file.${MANCEXT} magic.${MANFEXT}
113 cp file.${MANCEXT} $(MANCDIR)/file.$(MANCEXT)
114 cp magic.${MANFEXT} $(MANFDIR)/magic.$(MANFEXT)
117 rm -f *.o core file magic lint dist.* MANIFEST \
118 magic.${MANFEXT} file.${MANCEXT} \
119 config.h config.status config.cache config.log
121 cd tst; $(MAKE) clean
124 magic.${MANFEXT} : Makefile magic.man
126 sed -e s@__CSECTION__@${MANCEXT}@g \
127 -e s@__FSECTION__@${MANFEXT}@g \
128 -e s@__VERSION__@${VERSION}@g \
129 -e s@__MAGIC__@${MAGIC}@g magic.man > $@
131 file.${MANCEXT} : Makefile file.man
133 sed -e s@__CSECTION__@${MANCEXT}@g \
134 -e s@__FSECTION__@${MANFEXT}@g \
135 -e s@__VERSION__@${VERSION}@g \
136 -e s@__MAGIC__@${MAGIC}@g file.man > $@
141 dist: dist.src dist.magic
142 @echo Now check this patchlevel!
145 dist.src: $(ALLSRC) MANIFEST
146 # Some versions of shar can't handle a single file from
147 # a subdirectory, so we manually insert mkdir as needed.
148 # The point is to exclude all the generable targets in tst.
149 (echo mkdir localinc localinc/sys localsrc tst; \
150 $(SHAR) $(ALLSRC) MANIFEST) > $@
156 ident $(ALLSRC) > MANIFEST
158 # As above, but to exclude Magdir/RCS from being shipped.
159 (echo mkdir Magdir; $(SHAR) $(ALLMAGIC)) >$@
161 tar: $(ALLSRC) $(ALLMAGIC)
162 -rm -fr file-${VERSION}
163 -mkdir file-${VERSION} file-${VERSION}/Magdir
164 ln $(ALLSRC) file-${VERSION}
165 ln ${ALLMAGIC} file-${VERSION}/Magdir
166 tar cvf file-${VERSION}.tar file-${VERSION}
167 -rm -fr file-${VERSION}