Old KDE building system – not used for TDE
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

317 lines
11 KiB

  1. #-*- mode: Fundamental; tab-width: 4; -*-
  2. # ex:ts=4
  3. # $Id$
  4. # Copyright (C) 2001 Nick Moffitt
  5. #
  6. # Redistribution and/or use, with or without modification, is
  7. # permitted. This software is without warranty of any kind. The
  8. # author(s) shall not be liable in the event that use of the
  9. # software causes damage.
  10. # Comment this out to make much verbosity
  11. #.SILENT:
  12. #ifeq ($(origin GARDIR), undefined)
  13. #GARDIR := $(CURDIR)/../..
  14. #endif
  15. GARDIR ?= ../..
  16. FILEDIR ?= files
  17. DOWNLOADDIR ?= download
  18. COOKIEDIR ?= cookies
  19. WORKDIR ?= work
  20. WORKSRC ?= $(WORKDIR)/$(DISTNAME)
  21. EXTRACTDIR ?= $(WORKDIR)
  22. SCRATCHDIR ?= tmp
  23. CHECKSUM_FILE ?= checksums
  24. MANIFEST_FILE ?= manifest
  25. DIRSTODOTS = $(subst . /,./,$(patsubst %,/..,$(subst /, ,/$(1))))
  26. ROOTFROMDEST = $(call DIRSTODOTS,$(DESTDIR))
  27. DISTNAME ?= $(GARNAME)-$(GARVERSION)
  28. ALLFILES ?= $(DISTFILES) $(PATCHFILES)
  29. INSTALL_DIRS = $(addprefix $(DESTDIR),$(BUILD_PREFIX) $(prefix) $(exec_prefix) $(bindir) $(sbindir) $(libexecdir) $(datadir) $(sysconfdir) $(sharedstatedir) $(localstatedir) $(libdir) $(infodir) $(lispdir) $(includedir) $(mandir) $(foreach NUM,1 2 3 4 5 6 7 8, $(mandir)/man$(NUM)) $(sourcedir))
  30. # These are bad, since exporting them mucks up the dep rules!
  31. # WORKSRC is added in manually for the manifest rule.
  32. #export GARDIR FILEDIR DOWNLOADDIR COOKIEDIR WORKDIR WORKSRC EXTRACTDIR
  33. #export SCRATCHDIR CHECKSUM_FILE MANIFEST_FILE
  34. # For rules that do nothing, display what dependencies they
  35. # successfully completed
  36. DONADA = @echo " [$(call TMSG_ACTION,$@)] complete for $(call TMSG_ID,$(GARNAME))."
  37. # TODO: write a stub rule to print out the name of a rule when it
  38. # *does* do something, and handle indentation intelligently.
  39. # Default sequence for "all" is: fetch checksum extract patch configure build
  40. all: build
  41. $(DONADA)
  42. # include the configuration file to override any of these variables
  43. include $(GARDIR)/kde.conf.mk
  44. include $(GARDIR)/gar.conf.mk
  45. include $(GARDIR)/gar.lib.mk
  46. include $(GARDIR)/color.mk
  47. ifdef BUILD_CLEAN
  48. DO_BUILD_CLEAN = buildclean
  49. else
  50. DO_BUILD_CLEAN =
  51. endif
  52. # some packages use DESTDIR, but some use other methods. For the
  53. # rules that *we* write, the DESTDIR will be transparently added.
  54. # These need to happen after gar.conf.mk, as they use the := to
  55. # set the vars.
  56. # NOTE: removed due to
  57. # http://gar.lnx-bbc.org/wiki/ImplicitDestdirConsideredHarmful
  58. #%-install: prefix := $(DESTDIR)$(prefix)
  59. #install-none: prefix := $(DESTDIR)$(prefix)
  60. #################### DIRECTORY MAKERS ####################
  61. # This is to make dirs as needed by the base rules
  62. $(sort $(DOWNLOADDIR) $(COOKIEDIR) $(WORKSRC) $(WORKDIR) $(EXTRACTDIR) $(FILEDIR) $(SCRATCHDIR) $(INSTALL_DIRS)) $(COOKIEDIR)/%:
  63. @if test -d $@; then : ; else \
  64. install -d $@; \
  65. echo "install -d $@"; \
  66. fi
  67. # These stubs are wildcarded, so that the port maintainer can
  68. # define something like "pre-configure" and it won't conflict,
  69. # while the configure target can call "pre-configure" safely even
  70. # if the port maintainer hasn't defined it.
  71. #
  72. # in addition to the pre-<target> rules, the maintainer may wish
  73. # to set a "pre-everything" rule, which runs before the first
  74. # actual target.
  75. pre-%:
  76. @true
  77. post-%:
  78. @true
  79. # Call any arbitrary rule recursively
  80. deep-%: %
  81. @for i in $(LIBDEPS) $(DEPENDS) $(BUILDDEPS); do \
  82. $(MAKE) -C $(GARDIR)/$$i $@; \
  83. done
  84. # ========================= MAIN RULES =========================
  85. # The main rules are the ones that the user can specify as a
  86. # target on the "make" command-line. Currently, they are:
  87. # fetch-list fetch checksum makesum extract checkpatch patch
  88. # build install reinstall uninstall package
  89. # (some may not be complete yet).
  90. #
  91. # Each of these rules has dependencies that run in the following
  92. # order:
  93. # - run the previous main rule in the chain (e.g., install
  94. # depends on build)
  95. # - run the pre- rule for the target (e.g., configure would
  96. # then run pre-configure)
  97. # - generate a set of files to depend on. These are typically
  98. # cookie files in $(COOKIEDIR), but in the case of fetch are
  99. # actual downloaded files in $(DOWNLOADDIR)
  100. # - run the post- rule for the target
  101. #
  102. # The main rules also run the $(DONADA) code, which prints out
  103. # what just happened when all the dependencies are finished.
  104. announce:
  105. @echo "[$(call TMSG_BRIGHT,=====) $(call TMSG_ACTION,NOW BUILDING): $(call TMSG_ID,$(DISTNAME)) $(call TMSG_BRIGHT,=====)]"
  106. # fetch-list - Show list of files that would be retrieved by fetch.
  107. # NOTE: DOES NOT RUN pre-everything!
  108. fetch-list:
  109. @echo "Distribution files: "
  110. @for i in $(DISTFILES); do echo " $$i"; done
  111. @echo "Patch files: "
  112. @for i in $(PATCHFILES); do echo " $$i"; done
  113. # showdeps - Show dependencies in a tree-structure
  114. showdeps:
  115. @for i in $(LIBDEPS) $(BUILDDEPS); do \
  116. echo -e "$(TABLEVEL)$$i";\
  117. $(MAKE) -s -C $(GARDIR)/$$i TABLEVEL="$(TABLEVEL)\t" showdeps;\
  118. done
  119. # fetch - Retrieves $(DISTFILES) (and $(PATCHFILES) if defined)
  120. # into $(DOWNLOADDIR) as necessary.
  121. FETCH_TARGETS = $(addprefix $(DOWNLOADDIR)/,$(ALLFILES))
  122. fetch: announce pre-everything $(DOWNLOADDIR) $(addprefix dep-$(GARDIR)/,$(FETCHDEPS)) pre-fetch $(FETCH_TARGETS) post-fetch
  123. $(DONADA)
  124. # returns true if fetch has completed successfully, false
  125. # otherwise
  126. fetch-p:
  127. @$(foreach COOKIEFILE,$(FETCH_TARGETS), test -e $(COOKIEFILE) ;)
  128. # checksum - Use $(CHECKSUMFILE) to ensure that your
  129. # distfiles are valid.
  130. CHECKSUM_TARGETS = $(addprefix checksum-,$(filter-out $(NOCHECKSUM),$(ALLFILES)))
  131. checksum: fetch $(COOKIEDIR) pre-checksum $(CHECKSUM_TARGETS) post-checksum
  132. $(DONADA)
  133. # returns true if checksum has completed successfully, false
  134. # otherwise
  135. checksum-p:
  136. @$(foreach COOKIEFILE,$(CHECKSUM_TARGETS), test -e $(COOKIEDIR)/$(COOKIEFILE) ;)
  137. # makesum - Generate distinfo (only do this for your own ports!).
  138. MAKESUM_TARGETS = $(addprefix $(DOWNLOADDIR)/,$(filter-out $(NOCHECKSUM),$(ALLFILES)))
  139. makesum: fetch $(MAKESUM_TARGETS)
  140. @if test "x$(MAKESUM_TARGETS)" != "x "; then \
  141. $(MD5) $(MAKESUM_TARGETS) > $(CHECKSUM_FILE) ; \
  142. echo "Checksums complete for $(call TMSG_ID,$(MAKESUM_TARGETS))" ; \
  143. fi
  144. # I am always typing this by mistake
  145. makesums: makesum
  146. garchive: checksum
  147. mkdir -p $(GARCHIVEDIR)
  148. cp -Lr $(DOWNLOADDIR)/* $(GARCHIVEDIR) || true
  149. # extract - Unpacks $(DISTFILES) into $(EXTRACTDIR) (patches are "zcatted" into the patch program)
  150. EXTRACT_TARGETS = $(addprefix extract-,$(filter-out $(NOEXTRACT),$(DISTFILES)))
  151. extract: checksum $(EXTRACTDIR) $(COOKIEDIR) $(addprefix dep-$(GARDIR)/,$(EXTRACTDEPS)) pre-extract $(EXTRACT_TARGETS) post-extract
  152. $(DONADA)
  153. # returns true if extract has completed successfully, false
  154. # otherwise
  155. extract-p:
  156. @$(foreach COOKIEFILE,$(EXTRACT_TARGETS), test -e $(COOKIEDIR)/$(COOKIEFILE) ;)
  157. # checkpatch - Do a "patch -C" instead of a "patch". Note
  158. # that it may give incorrect results if multiple
  159. # patches deal with the same file.
  160. # TODO: actually write it!
  161. checkpatch: extract
  162. @echo "$(call TMSG_FAIL,$@) NOT IMPLEMENTED YET"
  163. # patch - Apply any provided patches to the source.
  164. PATCH_TARGETS = $(addprefix patch-,$(PATCHFILES))
  165. patch: extract $(WORKSRC) pre-patch $(PATCH_TARGETS) post-patch
  166. $(DONADA)
  167. # returns true if patch has completed successfully, false
  168. # otherwise
  169. patch-p:
  170. @$(foreach COOKIEFILE,$(PATCH_TARGETS), test -e $(COOKIEDIR)/$(COOKIEFILE) ;)
  171. # makepatch - Grab the upstream source and diff against $(WORKSRC). Since
  172. # diff returns 1 if there are differences, we remove the patch
  173. # file on "success". Goofy diff.
  174. makepatch: $(SCRATCHDIR) $(FILEDIR) $(FILEDIR)/gar-base.diff
  175. $(DONADA)
  176. # this takes the changes you've made to a working directory,
  177. # distills them to a patch, updates the checksum file, and tries
  178. # out the build (assuming you've listed the gar-base.diff in your
  179. # PATCHFILES). This is way undocumented. -NickM
  180. beaujolais: makepatch makesum clean build
  181. $(DONADA)
  182. # configure - Runs either GNU configure, one or more local
  183. # configure scripts or nothing, depending on
  184. # what's available.
  185. CONFIGURE_TARGETS = $(addprefix configure-,$(CONFIGURE_SCRIPTS))
  186. LIBDEPS += $(DEPENDS)
  187. configure: patch $(addprefix builddep-$(GARDIR)/,$(BUILDDEPS)) $(addprefix dep-$(GARDIR)/,$(LIBDEPS)) $(addprefix srcdep-$(GARDIR)/,$(SOURCEDEPS)) pre-configure $(CONFIGURE_TARGETS) post-configure
  188. $(DONADA)
  189. # returns true if configure has completed successfully, false
  190. # otherwise
  191. configure-p:
  192. @$(foreach COOKIEFILE,$(CONFIGURE_TARGETS), test -e $(COOKIEDIR)/$(COOKIEFILE) ;)
  193. # build - Actually compile the sources.
  194. BUILD_TARGETS = $(addprefix build-,$(BUILD_SCRIPTS))
  195. build: configure pre-build $(BUILD_TARGETS) post-build
  196. $(DONADA)
  197. # returns true if build has completed successfully, false
  198. # otherwise
  199. build-p:
  200. @$(foreach COOKIEFILE,$(BUILD_TARGETS), test -e $(COOKIEDIR)/$(COOKIEFILE) ;)
  201. # strip - Strip binaries
  202. strip: build pre-strip $(addprefix strip-,$(STRIP_SCRIPTS)) post-strip
  203. @echo "$(call TMSG_FAIL,$@) NOT IMPLEMENTED YET"
  204. # install - Install the results of a build.
  205. INSTALL_TARGETS = $(addprefix install-,$(INSTALL_SCRIPTS))
  206. install: build $(addprefix dep-$(GARDIR)/,$(INSTALLDEPS)) $(INSTALL_DIRS) pre-install $(INSTALL_TARGETS) post-install $(DO_BUILD_CLEAN)
  207. $(DONADA)
  208. # returns true if install has completed successfully, false
  209. # otherwise
  210. install-p:
  211. @$(foreach COOKIEFILE,$(INSTALL_TARGETS), test -e $(COOKIEDIR)/$(COOKIEFILE) ;)
  212. # installstrip - Install the results of a build, stripping first.
  213. installstrip: strip pre-install $(INSTALL_TARGETS) post-install
  214. $(DONADA)
  215. # reinstall - Install the results of a build, ignoring
  216. # "already installed" flag.
  217. # TODO: actually write it!
  218. reinstall: build
  219. rm -rf $(COOKIEDIR)/install*
  220. $(MAKE) install
  221. # uninstall - Remove the installation.
  222. # TODO: actually write it!
  223. uninstall: build
  224. @echo "$(call TMSG_FAIL,$@) NOT IMPLEMENTED YET"
  225. # package - Create a package from an _installed_ port.
  226. # TODO: actually write it!
  227. package: build
  228. @echo "$(call TMSG_FAIL,$@) NOT IMPLEMENTED YET"
  229. # tarball - Make a tarball from an install of the package into a scratch dir
  230. tarball: build
  231. rm -rf $(COOKIEDIR)/install*
  232. $(MAKE) DESTDIR=$(CURDIR)/$(SCRATCHDIR) BUILD_PREFIX=$(call DIRSTODOTS,$(CURDIR)/$(SCRATCHDIR))/$(BUILD_PREFIX) install
  233. find $(SCRATCHDIR) -depth -type d | while read i; do rmdir $$i > /dev/null 2>&1 || true; done
  234. $(TAR) czvf $(CURDIR)/$(WORKDIR)/$(DISTNAME)-install.tar.gz -C $(SCRATCHDIR) .
  235. $(MAKECOOKIE)
  236. # The clean rule. It must be run if you want to re-download a
  237. # file after a successful checksum (or just remove the checksum
  238. # cookie, but that would be lame and unportable).
  239. clean:
  240. @rm -rf $(DOWNLOADDIR) $(COOKIEDIR) $(COOKIEDIR)-* $(WORKSRC) $(WORKDIR) $(EXTRACTDIR) $(SCRATCHDIR) $(SCRATCHDIR)-$(COOKIEDIR) $(SCRATCHDIR)-build *~
  241. buildclean:
  242. @rm -rf $(WORKSRC) $(WORKDIR) $(EXTRACTDIR) $(SCRATCHDIR) $(SCRATCHDIR)-$(COOKIEDIR) $(SCRATCHDIR)-build *~
  243. # these targets do not have actual corresponding files
  244. .PHONY: all fetch-list fetch checksum makesum extract checkpatch patch makepatch configure build install clean buildclean beaujolais strip fetch-p checksum-p extract-p patch-p configure-p build-p install-p
  245. # apparently this makes all previous rules non-parallelizable,
  246. # but the actual builds of the packages will be, according to
  247. # jdub.
  248. .NOTPARALLEL: