Makefile 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. VERSION = 3.20
  25. SHELL = /bin/sh
  26. #MAGIC = /etc/magic
  27. MAGIC = /usr/local/etc/magic
  28. DEFS = -DMAGIC='"$(MAGIC)"' # -Dvoid=int
  29. CC = cc
  30. COPTS = -O -g # newer compilers allow both; else drop -O
  31. # For truly antique environments, use this for (dummy) include files:
  32. COPTS = -O # -Ilocalinc
  33. CFLAGS = $(COPTS) $(DEFS)
  34. LDFLAGS = $(COPTS) # -Bstatic # older gdb couldn't handle shared libs
  35. SHAR = bundle
  36. OFILE = /usr/bin/file # old or distributed version, for comparison
  37. # Where new binary lives; typically /usr/local (BSD), /usr/lbin (USG).
  38. BINDIR = /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. MANCDIR = /usr/local/man/man1
  57. MANCEXT = 1
  58. MANFDIR = /usr/local/man/man4
  59. MANFEXT = 4
  60. # There are no system-dependant configuration options (except maybe CFLAGS).
  61. # Uncomment any of these that is missing from your "standard" library.
  62. LOCALSRCS = # localsrc/getopt.c localsrc/strtol.c \
  63. # localsrc/strtok.c localsrc/strchr.c
  64. LOCALOBJS = # localsrc/getopt.o localsrc/strtol.o \
  65. # localsrc/strtok.o localsrc/strchr.o
  66. # These are not compiled in unless you use -Ilocalinc, but
  67. # are not commented out as "make dist" &c use them.
  68. LOCALINC = # localinc/*.h localinc/sys/*.h
  69. SRCS = file.c apprentice.c fsmagic.c softmagic.c ascmagic.c \
  70. compress.c is_tar.c \
  71. print.c $(LOCALSRCS) $(LOCALINC)
  72. OBJS = file.o apprentice.o fsmagic.o softmagic.o ascmagic.o \
  73. compress.o is_tar.o \
  74. print.o $(LOCALOBJS)
  75. ALLSRC = LEGAL.NOTICE README MAINT PORTING $(SRCS) *.h \
  76. Makefile file.man magic.man
  77. ALLMAGIC = Magdir/Makefile Magdir/Localstuff Magdir/Header Magdir/[a-z]*
  78. all: file magic file.${MANCEXT} magic.${MANFEXT}
  79. TESTFILES = * tst/*
  80. try: all $(OFILE)
  81. cd tst; $(MAKE)
  82. time $(OFILE) $(TESTFILES) >/tmp/t1 # can't use ./magic
  83. time ./file -m ./magic $(TESTFILES) >/tmp/t2
  84. -diff -b /tmp/t[12]
  85. what ./file >lastnocore
  86. file: $(OBJS)
  87. $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $@
  88. lint: $(SRCS)
  89. lint -ha $(DEFS) $(SRCS) | tee $@
  90. magic: Magdir
  91. # Magdir/Makefile's "install" mv's magic to here for testing.
  92. cd Magdir; $(MAKE) install
  93. ascmagic.o: names.h
  94. compress.o apprentice.o ascmagic.o file.o fsmagic.o print.o softmagic.o: file.h
  95. install: file magic
  96. cp file $(BINDIR)/file
  97. cp magic $(MAGIC)
  98. install.man: file.${MANCEXT} magic.${MANFEXT}
  99. cp file.${MANCEXT} $(MANCDIR)/file.$(MANCEXT)
  100. cp magic.${MANFEXT} $(MANFDIR)/magic.$(MANFEXT)
  101. clean:
  102. rm -f *.o core file magic lint dist.* MANIFEST \
  103. magic.${MANFEXT} file.${MANCEXT}
  104. clobber:
  105. cd tst; $(MAKE) clean
  106. magic.${MANFEXT} : Makefile magic.man
  107. @rm -f $@
  108. sed -e s@__CSECTION__@${MANCEXT}@g \
  109. -e s@__FSECTION__@${MANFEXT}@g \
  110. -e s@__VERSION__@${VERSION}@g \
  111. -e s@__MAGIC__@${MAGIC}@g magic.man > $@
  112. file.${MANCEXT} : Makefile file.man
  113. @rm -f $@
  114. sed -e s@__CSECTION__@${MANCEXT}@g \
  115. -e s@__FSECTION__@${MANFEXT}@g \
  116. -e s@__VERSION__@${VERSION}@g \
  117. -e s@__MAGIC__@${MAGIC}@g file.man > $@
  118. send: dist
  119. ftp ftp.cs
  120. dist: dist.src dist.magic
  121. @echo Now check this patchlevel!
  122. ident patchlevel.h
  123. dist.src: $(ALLSRC) MANIFEST
  124. # Some versions of shar can't handle a single file from
  125. # a subdirectory, so we manually insert mkdir as needed.
  126. # The point is to exclude all the generable targets in tst.
  127. (echo mkdir localinc localinc/sys localsrc tst; \
  128. $(SHAR) $(ALLSRC) MANIFEST) > $@
  129. rcsdiff: $(ALLSRC)
  130. rcsdiff -q RCS/*
  131. MANIFEST: $(ALLSRC)
  132. ident $(ALLSRC) > MANIFEST
  133. dist.magic: Magdir
  134. # As above, but to exclude Magdir/RCS from being shipped.
  135. (echo mkdir Magdir; $(SHAR) $(ALLMAGIC)) >$@
  136. tar: $(ALLSRC) $(ALLMAGIC)
  137. -rm -fr file-${VERSION}
  138. -mkdir file-${VERSION} file-${VERSION}/Magdir
  139. ln $(ALLSRC) file-${VERSION}
  140. ln ${ALLMAGIC} file-${VERSION}/Magdir
  141. tar cvf file-${VERSION}.tar file-${VERSION}
  142. -rm -fr file-${VERSION}