Makefile 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. # Makefile for Qi.
  2. #
  3. # Copyright (c) 2015-2022 Matias Fonzo, <selk@dragora.org>.
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. project = qi
  17. version = 2.8
  18. ## DO NOT MAKE CHANGES HERE.
  19. #
  20. # Use config.mak to override any of the following variables:
  21. prefix = /usr/local
  22. exec_prefix = $(prefix)
  23. bindir = $(exec_prefix)/bin
  24. sbindir = $(exec_prefix)/sbin
  25. libexecdir = $(exec_prefix)/libexec
  26. sysconfdir = $(prefix)/etc
  27. localstatedir = $(prefix)/var
  28. datarootdir = $(prefix)/share
  29. infodir = $(datarootdir)/info
  30. mandir = $(datarootdir)/man
  31. docdir = $(datarootdir)/doc
  32. packagedir = /usr/local/pkgs
  33. targetdir = /usr/local
  34. arch = $(shell uname -m)
  35. ##
  36. DISTNAME = ${project}-${version}
  37. MAKEINFO = makeinfo
  38. INSTALL = install
  39. INSTALL_PROGRAM = ${INSTALL} -p -m 755
  40. INSTALL_DATA = ${INSTALL} -p -m 644
  41. INSTALL_DIR = mkdir -p -m 755
  42. HELP2MAN_OPTS = --locale=C --version-string=${version}
  43. .PHONY: all \
  44. doc info man html \
  45. dist distclean clean \
  46. install install-info \
  47. uninstall uninstall-info
  48. -include config.mak
  49. all : $(project) $(project)rc
  50. $(project) : src/$(project)
  51. src/$(project) : src/$(project).in
  52. @echo "Making src/$(project) ..."
  53. @echo ""
  54. sed -e "s|@VERSION@|$(version)|g" \
  55. -e "s|@PREFIX@|$(prefix)|g" \
  56. -e "s|@BINDIR@|$(bindir)|g" \
  57. -e "s|@SBINDIR@|$(sbindir)|g" \
  58. -e "s|@LIBEXECDIR@|$(libexecdir)|g" \
  59. -e "s|@SYSCONFDIR@|$(sysconfdir)|g" \
  60. -e "s|@LOCALSTATEDIR@|$(localstatedir)|g" \
  61. -e "s|@INFODIR@|$(infodir)|g" \
  62. -e "s|@MANDIR@|$(mandir)|g" \
  63. -e "s|@DOCDIR@|$(docdir)|g" \
  64. -e "s|@PACKAGEDIR@|$(packagedir)|g" \
  65. -e "s|@TARGETDIR@|$(targetdir)|g" \
  66. -e "s|@ARCH@|$(arch)|g" \
  67. $< > $@ && \
  68. chmod 755 $@
  69. $(project)rc : etc/$(project)rc
  70. etc/$(project)rc : etc/$(project)rc.in
  71. @echo "Making config: etc/$(project)rc ..."
  72. @echo ""
  73. sed -e "s|@PREFIX@|$(prefix)|g" \
  74. -e "s|@BINDIR@|$(bindir)|g" \
  75. -e "s|@SBINDIR@|$(sbindir)|g" \
  76. -e "s|@LIBEXECDIR@|$(libexecdir)|g" \
  77. -e "s|@SYSCONFDIR@|$(sysconfdir)|g" \
  78. -e "s|@LOCALSTATEDIR@|$(localstatedir)|g" \
  79. -e "s|@INFODIR@|$(infodir)|g" \
  80. -e "s|@MANDIR@|$(mandir)|g" \
  81. -e "s|@DOCDIR@|$(docdir)|g" \
  82. -e "s|@PACKAGEDIR@|$(packagedir)|g" \
  83. -e "s|@TARGETDIR@|$(targetdir)|g" \
  84. -e "s|@ARCH@|$(arch)|g" \
  85. $< > $@ && \
  86. chmod 644 $@
  87. doc : info man html
  88. info : doc/$(project).info
  89. doc/$(project).info : doc/$(project)-header.texi doc/$(project)-content.texi
  90. cd doc && env LANG=C $(MAKEINFO) $(project)-header.texi -o $(project).info
  91. man : doc/$(project).1
  92. doc/qi.1 : doc/$(project).1.in src/$(project).in
  93. env LANG=C help2man ${HELP2MAN_OPTS} \
  94. --name="a simple but well-integrated package manager" \
  95. --info-page=qi \
  96. --output=$@ doc/$(project).1.in
  97. sed -e "s#QI.1.IN#QI#g" -e "s#qi.1.in#qi#g" -i $@
  98. html : doc/$(project).html
  99. doc/$(project).html : doc/$(project)-header.texi doc/$(project)-content.texi
  100. cd doc && env LANG=C $(MAKEINFO) --html --no-split \
  101. $(project)-header.texi -o $(project).html
  102. dist : doc
  103. rm -f $(DISTNAME)
  104. ln -sf . $(DISTNAME)
  105. tarlz --solid -9 -cvf $(DISTNAME).tar.lz \
  106. $(DISTNAME)/AUTHORS \
  107. $(DISTNAME)/COPYING \
  108. $(DISTNAME)/CREDITS \
  109. $(DISTNAME)/Makefile \
  110. $(DISTNAME)/NEWS \
  111. $(DISTNAME)/README.md \
  112. $(DISTNAME)/configure \
  113. $(DISTNAME)/doc/example.order \
  114. $(DISTNAME)/doc/fdl.txt \
  115. $(DISTNAME)/doc/qi.1 \
  116. $(DISTNAME)/doc/qi.1.in \
  117. $(DISTNAME)/doc/$(project).html \
  118. $(DISTNAME)/doc/$(project).info \
  119. $(DISTNAME)/doc/$(project)-header.texi \
  120. $(DISTNAME)/doc/$(project)-content.texi \
  121. $(DISTNAME)/doc/recipe1 \
  122. $(DISTNAME)/doc/recipe2 \
  123. $(DISTNAME)/doc/recipe3 \
  124. $(DISTNAME)/etc/$(project)rc.in \
  125. $(DISTNAME)/src/qi.in
  126. rm -f $(DISTNAME)
  127. sha256sum $(DISTNAME).tar.lz > $(DISTNAME).tar.lz.sha256
  128. distclean : clean
  129. -rm -f *.tar *.tar.lz *.tar.lz.*
  130. clean :
  131. -rm -f src/$(project) etc/$(project)rc config.mak
  132. install : all install-info install-man
  133. @echo ""
  134. @echo "* Checking required directories ..."
  135. if [ ! -d "$(DESTDIR)${bindir}" ] ; then \
  136. $(INSTALL_DIR) "$(DESTDIR)${bindir}" ; \
  137. fi
  138. if [ ! -d "$(DESTDIR)${sysconfdir}" ] ; then \
  139. $(INSTALL_DIR) "$(DESTDIR)${sysconfdir}" ; \
  140. fi
  141. @echo ""
  142. @echo "* Installing on $(DESTDIR)${bindir} ..."
  143. $(INSTALL_PROGRAM) src/$(project) "$(DESTDIR)${bindir}/$(project)"
  144. @echo ""
  145. @echo "* Installing config file on $(DESTDIR)${sysconfdir} ..."
  146. $(INSTALL_DATA) etc/$(project)rc "$(DESTDIR)${sysconfdir}/$(project)rc"
  147. @echo ""
  148. @echo "* Creating package and target directory (if needed) ..."
  149. if [ ! -d "$(DESTDIR)${packagedir}" ] ; then \
  150. $(INSTALL_DIR) "$(DESTDIR)${packagedir}" ; \
  151. fi
  152. if [ ! -d "$(DESTDIR)${targetdir}" ] ; then \
  153. $(INSTALL_DIR) "$(DESTDIR)${targetdir}" ; \
  154. fi
  155. @echo ""
  156. @echo "Done."
  157. install-info :
  158. @echo ""
  159. @echo "* Installing Info document on $(DESTDIR)${infodir} ..."
  160. if [ ! -d "$(DESTDIR)${infodir}" ] ; then \
  161. $(INSTALL_DIR) "$(DESTDIR)${infodir}" ; \
  162. fi
  163. $(INSTALL_DATA) doc/$(project).info \
  164. "$(DESTDIR)${infodir}/$(project).info"
  165. -install-info --info-dir="$(DESTDIR)${infodir}" \
  166. "$(DESTDIR)${infodir}/$(project).info"
  167. install-man :
  168. @echo ""
  169. @echo "* Installing manual pages on $(DESTDIR)${mandir}/man1 ..."
  170. if [ ! -d "$(DESTDIR)${mandir}/man1" ] ; then \
  171. $(INSTALL_DIR) "$(DESTDIR)${mandir}/man1" ; \
  172. fi
  173. $(INSTALL_DATA) doc/$(project).1 "$(DESTDIR)${mandir}/man1"
  174. uninstall : uninstall-info uninstall-man
  175. @echo ""
  176. @echo "* Uninstalling from $(DESTDIR)${bindir} ..."
  177. -rm -f "$(DESTDIR)${bindir}/$(project)"
  178. -rm -f "$(DESTDIR)${sysconfdir}/$(project)rc"
  179. uninstall-info :
  180. -install-info \
  181. --info-dir="$(DESTDIR)${infodir}" \
  182. --remove "$(DESTDIR)${infodir}/$(project).info"
  183. -rm -f "$(DESTDIR)${infodir}/$(project).info"
  184. uninstall-man :
  185. -rm -f "$(DESTDIR)${mandir}/man1/$(project).1"