Makefile 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. # Makefile for file(1) cmd.
  2. # Copyright (c) Ian F. Darwin 86/09/01 - see LEGAL.NOTICE.
  3. # @(#)$Id: Makefile,v 1.51 1996/06/22 22:05:07 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.
  24. # Optimized for Linux because sunsite.unc.edu, tsx-11.mit.edu,
  25. # ftp.redhat.com, ftp.funet.fi, and other Linux sites never get
  26. # a copy uploaded to them. Most still had 3.15 + a patch at the
  27. # time of this hack. -- Albert Cahalan <acahalan@cs.uml.edu>
  28. # Was 3.20, number changed as requested.
  29. VERSION = 3.20.1
  30. SHELL = /bin/sh
  31. MAGIC = /etc/magic
  32. #MAGIC = /usr/local/etc/magic
  33. DEFS = -DMAGIC='"$(MAGIC)"' # -Dvoid=int
  34. CC = gcc
  35. COPTS = -s -O2 -fno-strength-reduce -fomit-frame-pointer
  36. CFLAGS = $(COPTS) $(DEFS)
  37. LDFLAGS = $(COPTS) # -Bstatic # older gdb couldn't handle shared libs
  38. SHAR = bundle
  39. OFILE = /usr/bin/file # old or distributed version, for comparison
  40. # Where new binary lives; typically /usr/local (BSD), /usr/lbin (USG).
  41. BINDIR = /usr/bin
  42. # For installing our man pages;
  43. # MANCxxx is manual section for Commands, MANFxxx is section for file formats.
  44. # MANxDIR is directory names; MANxEXT is the filename extention. Usual values:
  45. # Variable V7 4BSD Sys V
  46. # MANCDIR /usr/man/man1 /usr/man/man1 /usr/man/u_man/man1
  47. # MANFDIR /usr/man/man5 /usr/man/man5 /usr/man/u_man/man4
  48. # MANCEXT 1 1 1
  49. # MANFEXT 5 5 4
  50. # --- possible alternative for 4BSD ---
  51. # MANCDIR /usr/local/man/man1
  52. # MANCEXT 1
  53. # or
  54. # MANCDIR /usr/man/manl
  55. # MANCEXT l
  56. # --- possible alternative for USG ---
  57. # MANCDIR /usr/man/local/man1
  58. # MANCEXT 1
  59. MANCDIR = /usr/man/man1
  60. MANCEXT = 1
  61. MANFDIR = /usr/man/man5
  62. MANFEXT = 5
  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
  72. SRCS = file.c apprentice.c fsmagic.c softmagic.c ascmagic.c \
  73. compress.c is_tar.c \
  74. print.c $(LOCALSRCS) $(LOCALINC)
  75. OBJS = file.o apprentice.o fsmagic.o softmagic.o ascmagic.o \
  76. compress.o is_tar.o \
  77. print.o $(LOCALOBJS)
  78. ALLSRC = LEGAL.NOTICE README MAINT PORTING $(SRCS) *.h \
  79. Makefile file.man magic.man
  80. ALLMAGIC = Magdir/Makefile Magdir/Localstuff Magdir/Header Magdir/[a-z]*
  81. all: file magic file.${MANCEXT} magic.${MANFEXT}
  82. TESTFILES = * tst/*
  83. try: all $(OFILE)
  84. cd tst; $(MAKE)
  85. time $(OFILE) $(TESTFILES) >/tmp/t1 # can't use ./magic
  86. time ./file -m ./magic $(TESTFILES) >/tmp/t2
  87. -diff -b /tmp/t[12]
  88. what ./file >lastnocore
  89. file: $(OBJS)
  90. $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $@
  91. lint: $(SRCS)
  92. lint -ha $(DEFS) $(SRCS) | tee $@
  93. magic: Magdir
  94. # Magdir/Makefile's "install" mv's magic to here for testing.
  95. cd Magdir; $(MAKE) install
  96. ascmagic.o: names.h
  97. compress.o apprentice.o ascmagic.o file.o fsmagic.o print.o softmagic.o: file.h
  98. install: file magic
  99. cp file $(DESTDIR)$(BINDIR)/file
  100. cp magic $(DESTDIR)$(MAGIC)
  101. install.man: file.${MANCEXT} magic.${MANFEXT}
  102. cp file.${MANCEXT} $(DESTDIR)$(MANCDIR)/file.$(MANCEXT)
  103. cp magic.${MANFEXT} $(DESTDIR)$(MANFDIR)/magic.$(MANFEXT)
  104. clean:
  105. rm -f *.o core file magic lint dist.* MANIFEST \
  106. magic.${MANFEXT} file.${MANCEXT}
  107. clobber:
  108. cd tst; $(MAKE) clean
  109. magic.${MANFEXT} : Makefile magic.man
  110. @rm -f $@
  111. sed -e s@__CSECTION__@${MANCEXT}@g \
  112. -e s@__FSECTION__@${MANFEXT}@g \
  113. -e s@__VERSION__@${VERSION}@g \
  114. -e s@__MAGIC__@${MAGIC}@g magic.man > $@
  115. file.${MANCEXT} : Makefile file.man
  116. @rm -f $@
  117. sed -e s@__CSECTION__@${MANCEXT}@g \
  118. -e s@__FSECTION__@${MANFEXT}@g \
  119. -e s@__VERSION__@${VERSION}@g \
  120. -e s@__MAGIC__@${MAGIC}@g file.man > $@
  121. send: dist
  122. ftp ftp.cs
  123. dist: dist.src dist.magic
  124. @echo Now check this patchlevel!
  125. ident patchlevel.h
  126. dist.src: $(ALLSRC) MANIFEST
  127. # Some versions of shar can't handle a single file from
  128. # a subdirectory, so we manually insert mkdir as needed.
  129. # The point is to exclude all the generable targets in tst.
  130. (echo mkdir localinc localinc/sys localsrc tst; \
  131. $(SHAR) $(ALLSRC) MANIFEST) > $@
  132. rcsdiff: $(ALLSRC)
  133. rcsdiff -q RCS/*
  134. MANIFEST: $(ALLSRC)
  135. ident $(ALLSRC) > MANIFEST
  136. dist.magic: Magdir
  137. # As above, but to exclude Magdir/RCS from being shipped.
  138. (echo mkdir Magdir; $(SHAR) $(ALLMAGIC)) >$@
  139. tar: $(ALLSRC) $(ALLMAGIC)
  140. -rm -fr file-${VERSION}
  141. -mkdir file-${VERSION} file-${VERSION}/Magdir
  142. ln $(ALLSRC) file-${VERSION}
  143. ln ${ALLMAGIC} file-${VERSION}/Magdir
  144. tar cvf file-${VERSION}.tar file-${VERSION}
  145. -rm -fr file-${VERSION}