Makefile 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. # Makefile for Qi.
  2. #
  3. # Copyright (c) 2015-2023 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.12-rc2
  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. arch = $(shell uname -m)
  33. packagedir = $(prefix)/pkgs
  34. targetdir = $(prefix)
  35. outdir = $(localstatedir)/cache/qi/packages
  36. ##
  37. DISTNAME = ${project}-${version}
  38. MAKEINFO = makeinfo
  39. INSTALL = install
  40. INSTALL_PROGRAM = ${INSTALL} -p -m 755
  41. INSTALL_DATA = ${INSTALL} -p -m 644
  42. INSTALL_DIR = mkdir -p -m 755
  43. HELP2MAN_OPTS = --locale=C --version-string=${version}
  44. .PHONY: all \
  45. doc info man html \
  46. dist distclean clean \
  47. install install-info \
  48. uninstall uninstall-info
  49. -include config.mak
  50. all : $(project) $(project)rc
  51. $(project) : src/$(project)
  52. src/$(project) : src/$(project).in
  53. @echo "Making src/$(project) ..."
  54. @echo ""
  55. sed -e "s|@VERSION@|$(version)|g" \
  56. -e "s|@PREFIX@|$(prefix)|g" \
  57. -e "s|@BINDIR@|$(bindir)|g" \
  58. -e "s|@SBINDIR@|$(sbindir)|g" \
  59. -e "s|@LIBEXECDIR@|$(libexecdir)|g" \
  60. -e "s|@SYSCONFDIR@|$(sysconfdir)|g" \
  61. -e "s|@LOCALSTATEDIR@|$(localstatedir)|g" \
  62. -e "s|@INFODIR@|$(infodir)|g" \
  63. -e "s|@MANDIR@|$(mandir)|g" \
  64. -e "s|@DOCDIR@|$(docdir)|g" \
  65. -e "s|@ARCH@|$(arch)|g" \
  66. -e "s|@PACKAGEDIR@|$(packagedir)|g" \
  67. -e "s|@TARGETDIR@|$(targetdir)|g" \
  68. -e "s|@OUTDIR@|$(outdir)|g" \
  69. $< > $@ && \
  70. chmod 755 $@
  71. $(project)rc : etc/$(project)rc
  72. etc/$(project)rc : etc/$(project)rc.in
  73. @echo "Making config: etc/$(project)rc ..."
  74. @echo ""
  75. sed -e "s|@PREFIX@|$(prefix)|g" \
  76. -e "s|@BINDIR@|$(bindir)|g" \
  77. -e "s|@SBINDIR@|$(sbindir)|g" \
  78. -e "s|@LIBEXECDIR@|$(libexecdir)|g" \
  79. -e "s|@SYSCONFDIR@|$(sysconfdir)|g" \
  80. -e "s|@LOCALSTATEDIR@|$(localstatedir)|g" \
  81. -e "s|@INFODIR@|$(infodir)|g" \
  82. -e "s|@MANDIR@|$(mandir)|g" \
  83. -e "s|@DOCDIR@|$(docdir)|g" \
  84. -e "s|@ARCH@|$(arch)|g" \
  85. -e "s|@PACKAGEDIR@|$(packagedir)|g" \
  86. -e "s|@TARGETDIR@|$(targetdir)|g" \
  87. -e "s|@OUTDIR@|$(outdir)|g" \
  88. $< > $@ && \
  89. chmod 644 $@
  90. doc : info man html
  91. info : doc/$(project).info
  92. doc/$(project).info : doc/$(project)-header.texi doc/$(project)-content.texi
  93. cd doc && env LANG=C $(MAKEINFO) $(project)-header.texi -o $(project).info
  94. man : doc/$(project).1
  95. doc/qi.1 : doc/$(project).1.in src/$(project).in
  96. env LANG=C help2man ${HELP2MAN_OPTS} \
  97. --name="a simple but well-integrated package manager" \
  98. --info-page=qi \
  99. --output=$@ doc/$(project).1.in
  100. sed -e "s#QI.1.IN#QI#g" -e "s#qi.1.in#qi#g" -i $@
  101. html : doc/$(project).html
  102. doc/$(project).html : doc/$(project)-header.texi doc/$(project)-content.texi
  103. cd doc && env LANG=C $(MAKEINFO) --html --no-split \
  104. $(project)-header.texi -o $(project).html
  105. dist : doc
  106. rm -f $(DISTNAME)
  107. ln -sf . $(DISTNAME)
  108. tarlz --solid -9 -cvf $(DISTNAME).tar.lz \
  109. $(DISTNAME)/AUTHORS \
  110. $(DISTNAME)/COPYING \
  111. $(DISTNAME)/CREDITS \
  112. $(DISTNAME)/Makefile \
  113. $(DISTNAME)/NEWS \
  114. $(DISTNAME)/README.md \
  115. $(DISTNAME)/configure \
  116. $(DISTNAME)/doc/example.order \
  117. $(DISTNAME)/doc/fdl.txt \
  118. $(DISTNAME)/doc/qi.1 \
  119. $(DISTNAME)/doc/qi.1.in \
  120. $(DISTNAME)/doc/$(project).html \
  121. $(DISTNAME)/doc/$(project).info \
  122. $(DISTNAME)/doc/$(project)-header.texi \
  123. $(DISTNAME)/doc/$(project)-content.texi \
  124. $(DISTNAME)/doc/recipe1 \
  125. $(DISTNAME)/doc/recipe2 \
  126. $(DISTNAME)/doc/recipe3 \
  127. $(DISTNAME)/etc/$(project)rc.in \
  128. $(DISTNAME)/src/qi.in
  129. rm -f $(DISTNAME)
  130. sha256sum $(DISTNAME).tar.lz > $(DISTNAME).tar.lz.sha256
  131. distclean : clean
  132. -rm -f *.tar *.tar.lz *.tar.lz.*
  133. clean :
  134. -rm -f src/$(project) etc/$(project)rc config.mak
  135. install : all install-info install-man
  136. @echo ""
  137. @echo "* Checking required directories ..."
  138. if [ ! -d "$(DESTDIR)${bindir}" ] ; then \
  139. $(INSTALL_DIR) "$(DESTDIR)${bindir}" ; \
  140. fi
  141. if [ ! -d "$(DESTDIR)${sysconfdir}" ] ; then \
  142. $(INSTALL_DIR) "$(DESTDIR)${sysconfdir}" ; \
  143. fi
  144. @echo ""
  145. @echo "* Installing on $(DESTDIR)${bindir} ..."
  146. $(INSTALL_PROGRAM) src/$(project) "$(DESTDIR)${bindir}/$(project)"
  147. @echo ""
  148. @echo "* Installing config file on $(DESTDIR)${sysconfdir} ..."
  149. $(INSTALL_DATA) etc/$(project)rc "$(DESTDIR)${sysconfdir}/$(project)rc"
  150. @echo ""
  151. @echo "* Creating package and target directory (if needed) ..."
  152. if [ ! -d "$(DESTDIR)${packagedir}" ] ; then \
  153. $(INSTALL_DIR) "$(DESTDIR)${packagedir}" ; \
  154. fi
  155. if [ ! -d "$(DESTDIR)${targetdir}" ] ; then \
  156. $(INSTALL_DIR) "$(DESTDIR)${targetdir}" ; \
  157. fi
  158. @echo ""
  159. @echo "Done."
  160. install-info :
  161. @echo ""
  162. @echo "* Installing Info document on $(DESTDIR)${infodir} ..."
  163. if [ ! -d "$(DESTDIR)${infodir}" ] ; then \
  164. $(INSTALL_DIR) "$(DESTDIR)${infodir}" ; \
  165. fi
  166. $(INSTALL_DATA) doc/$(project).info \
  167. "$(DESTDIR)${infodir}/$(project).info"
  168. -install-info --info-dir="$(DESTDIR)${infodir}" \
  169. "$(DESTDIR)${infodir}/$(project).info"
  170. install-man :
  171. @echo ""
  172. @echo "* Installing manual pages on $(DESTDIR)${mandir}/man1 ..."
  173. if [ ! -d "$(DESTDIR)${mandir}/man1" ] ; then \
  174. $(INSTALL_DIR) "$(DESTDIR)${mandir}/man1" ; \
  175. fi
  176. $(INSTALL_DATA) doc/$(project).1 "$(DESTDIR)${mandir}/man1"
  177. uninstall : uninstall-info uninstall-man
  178. @echo ""
  179. @echo "* Uninstalling from $(DESTDIR)${bindir} ..."
  180. -rm -f "$(DESTDIR)${bindir}/$(project)"
  181. -rm -f "$(DESTDIR)${sysconfdir}/$(project)rc"
  182. uninstall-info :
  183. -install-info \
  184. --info-dir="$(DESTDIR)${infodir}" \
  185. --remove "$(DESTDIR)${infodir}/$(project).info"
  186. -rm -f "$(DESTDIR)${infodir}/$(project).info"
  187. uninstall-man :
  188. -rm -f "$(DESTDIR)${mandir}/man1/$(project).1"