home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 March / PCWELT_3_2006.ISO / base / 05_common.mo / usr / man / Makefile next >
Encoding:
Makefile  |  2003-02-04  |  2.0 KB  |  70 lines

  1. # Do "make screen" first, if you want to protect already installed,
  2. # more up-to-date manual pages than the ones included in this package.
  3. # Do "make install" to copy the pages to their destination.
  4. # Do "make gz" or "make bz2" first if you use compressed source pages.
  5.  
  6. MANDIR=$(prefix)/usr/share/man
  7.  
  8. GZIP=gzip -9
  9. BZIP2=bzip2 -9
  10.  
  11. all: screen remove install
  12.  
  13. allgz: gz all
  14.  
  15. allbz: bz2 all
  16.  
  17. # Unfortunately, due to BSD brain damage codified by POSIX,
  18. # code like "for i in dir/*; do STH; done" does not loop over
  19. # all files in dir - indeed, when dir is empty it does STH
  20. # once instead of zero times. David Balazic found that he
  21. # lost his files and noticed the cause.
  22. # [If we knew for sure this was using bash, we could set
  23. #  allow_null_glob_expansion.]
  24.  
  25. screen:
  26.     -mkdir not_installed
  27.     files=man?/*; \
  28.     if [ "$$files" != "man\?/\*" ]; then for i in $$files; do \
  29.         if [ $(MANDIR)/$$i -nt $$i ]; then \
  30.             diff -q $(MANDIR)/$$i $$i > /dev/null 2>&1; \
  31.             if [ $$? != 0 ]; then mv $$i not_installed; fi; \
  32.         fi; \
  33.     done; fi
  34.  
  35. remove:
  36.     files=man?/*; \
  37.     if [ "$$files" != "man\?/\*" ]; then for i in $$files; do \
  38.         rm -f $(MANDIR)/$$i $(MANDIR)/$$i.gz $(MANDIR)/$$i.bz2; \
  39.     done; fi
  40.  
  41. gz:
  42.     for i in man?; do $(GZIP) $$i/*; done
  43.  
  44. bz2:
  45.     for i in man?; do $(BZIP2) $$i/*; done
  46.  
  47. # Use with
  48. #  make HTDIR=/some/dir HTOPTS=whatever html
  49. # The sed removes the lines "Content-type: text/html\n\n"
  50. html:
  51.     @if [ x$(HTDIR) = x ]; then echo "You must set HTDIR."; else \
  52.     for i in man?; do \
  53.         [ -d $(HTDIR)/$$i ] || mkdir -p $(HTDIR)/$$i; \
  54.         find "$$i/" -type f | while read f; do \
  55.             (cd $$i; man2html $(HTOPTS) `basename $$f`) | \
  56.             sed -e '1,2d' > $(HTDIR)/$$i/`basename $$f`.html; \
  57.         done; \
  58.     done; fi
  59.  
  60. README=$(MANDIR)/man1/README
  61. install:
  62.     for i in man?; do \
  63.         install -d -m 755 $(MANDIR)/$$i; \
  64.         install -m 644 $$i/* $(MANDIR)/$$i; \
  65.     done; \
  66.     rm -f $(README) $(README).gz $(README).bz2
  67.  
  68. # someone might also want to look at /var/catman/cat2 or so ...
  69. # a problem is that the location of cat pages varies a lot
  70.