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.
 
 
 

470 lines
15 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. # cookies go here, so we have to be able to find them for
  11. # dependency checking.
  12. VPATH += $(COOKIEDIR)
  13. # So these targets are all loaded into bbc.port.mk at the end,
  14. # and provide actions that would be written often, such as
  15. # running configure, automake, makemaker, etc.
  16. #
  17. # The do- targets depend on these, and they can be overridden by
  18. # a port maintainer, since they'e pattern-based. Thus:
  19. #
  20. # extract-foo.tar.gz:
  21. # (special stuff to unpack non-standard tarball, such as one
  22. # accidentally named .gz when it's really bzip2 or something)
  23. #
  24. # and this will override the extract-%.tar.gz rule.
  25. # convenience variable to make the cookie.
  26. MAKECOOKIE = mkdir -p $(COOKIEDIR)/$(@D) && date >> $(COOKIEDIR)/$@
  27. #################### FETCH RULES ####################
  28. URLS = $(subst ://,//,$(foreach SITE,$(FILE_SITES) $(MASTER_SITES),$(addprefix $(SITE),$(DISTFILES))) $(foreach SITE,$(FILE_SITES) $(PATCH_SITES) $(MASTER_SITES),$(addprefix $(SITE),$(PATCHFILES))))
  29. # Download the file if and only if it doesn't have a preexisting
  30. # checksum file. Loop through available URLs and stop when you
  31. # get one that doesn't return an error code.
  32. $(DOWNLOADDIR)/%:
  33. @if test -f $(COOKIEDIR)/checksum-$*; then : ; else \
  34. echo " ==> Grabbing $(call TMSG_ID,$@)"; \
  35. for i in $(filter %/$*,$(URLS)); do \
  36. echo " ==> Trying $(call TMSG_ID,$$i)"; \
  37. $(MAKE) -s $$i || continue; \
  38. break; \
  39. done; \
  40. if test -r $@ ; then : ; else \
  41. echo '*** GAR GAR GAR! Failed to download $(call TMSG_ID,$@)! GAR GAR GAR! ***' 1>&2; \
  42. false; \
  43. fi; \
  44. fi
  45. # download an http URL
  46. http//%:
  47. @wget -c -nd --passive-ftp -P $(DOWNLOADDIR) http://$*
  48. # download an ftp URL
  49. ftp//%:
  50. @wget -c -nd --passive-ftp -P $(DOWNLOADDIR) ftp://$*
  51. # link to a local copy of the file
  52. # (absolute path)
  53. file///%:
  54. @if test -f /$*; then \
  55. ln -f -s /$* $(DOWNLOADDIR)/$(notdir $*); \
  56. else \
  57. false; \
  58. fi
  59. # link to a local copy of the file
  60. # (relative path)
  61. file//%:
  62. @if test -f $*; then \
  63. ln -f -s "$(CURDIR)/$*" $(DOWNLOADDIR)/$(notdir $*); \
  64. else \
  65. false; \
  66. fi
  67. # Using Jeff Waugh's rsync rule.
  68. # DOES NOT PRESERVE SYMLINKS!
  69. rsync//%:
  70. @rsync -azvLP rsync://$* $(DOWNLOADDIR)/
  71. # Using Jeff Waugh's scp rule
  72. scp//%:
  73. @scp -C $* $(DOWNLOADDIR)/
  74. #################### CHECKSUM RULES ####################
  75. # check a given file's checksum against $(CHECKSUM_FILE) and
  76. # error out if it mentions the file without an "OK".
  77. checksum-%: $(CHECKSUM_FILE)
  78. @echo " ==> Running checksum on $(call TMSG_ID,$*)"
  79. @if grep -- '$*' $(CHECKSUM_FILE); then \
  80. if LC_ALL="C" LANG="C" $(MD5) -c $(CHECKSUM_FILE) 2>&1 | grep -- '$*' | grep -v ':[ ]\+OK'; then \
  81. echo '*** GAR GAR GAR! $(call TMSG_ID,$*) failed checksum test! GAR GAR GAR! ***' 1>&2; \
  82. false; \
  83. else \
  84. echo 'file $(call TMSG_ID,$*) passes checksum test!'; \
  85. $(MAKECOOKIE); \
  86. fi \
  87. else \
  88. echo '*** GAR GAR GAR! $(call TMSG_ID,$*) not in $(CHECKSUM_FILE) file! GAR GAR GAR! ***' 1>&2; \
  89. false; \
  90. fi
  91. #################### EXTRACT RULES ####################
  92. # rule to extract uncompressed tarballs
  93. tar-extract-%:
  94. @echo ' $(call TMSG_LIB,Extracting,$(DOWNLOADDIR)/$*)'
  95. @$(TAR) -xf $(DOWNLOADDIR)/$* -C $(EXTRACTDIR)
  96. @$(MAKECOOKIE)
  97. # rule to extract files with tar xzf
  98. tar-gz-extract-%:
  99. @echo ' $(call TMSG_LIB,Extracting,$(DOWNLOADDIR)/$*)'
  100. @gzip -dc $(DOWNLOADDIR)/$* | $(TAR) -xf - -C $(EXTRACTDIR)
  101. @$(MAKECOOKIE)
  102. # rule to extract files with tar and bzip
  103. tar-bz-extract-%:
  104. @echo ' $(call TMSG_LIB,Extracting,$(DOWNLOADDIR)/$*)'
  105. @bzip2 -dc $(DOWNLOADDIR)/$* | $(TAR) -xf - -C $(EXTRACTDIR)
  106. @$(MAKECOOKIE)
  107. # rule to extract files with unzip
  108. zip-extract-%:
  109. @echo ' $(call TMSG_LIB,Extracting,$(DOWNLOADDIR)/$*)'
  110. @unzip $(DOWNLOADDIR)/$* -d $(EXTRACTDIR)
  111. @$(MAKECOOKIE)
  112. # this is a null extract rule for files which are constant and
  113. # unchanged (not archives)
  114. cp-extract-%:
  115. @echo ' $(call TMSG_LIB,Copying,$(DOWNLOADDIR)/$*)'
  116. @cp $(DOWNLOADDIR)/$* $(WORKDIR)/
  117. @$(MAKECOOKIE)
  118. ### EXTRACT FILE TYPE MAPPINGS ###
  119. # These rules specify which of the above extract action rules to use for a
  120. # given file extension. Often support for a given extract type can be handled
  121. # by simply adding a rule here.
  122. extract-%.tar: tar-extract-%.tar
  123. @$(MAKECOOKIE)
  124. extract-%.tar.gz: tar-gz-extract-%.tar.gz
  125. @$(MAKECOOKIE)
  126. extract-%.tar.Z: tar-gz-extract-%.tar.Z
  127. @$(MAKECOOKIE)
  128. extract-%.tgz: tar-gz-extract-%.tgz
  129. @$(MAKECOOKIE)
  130. extract-%.taz: tar-gz-extract-%.taz
  131. @$(MAKECOOKIE)
  132. extract-%.tar.bz: tar-bz-extract-%.tar.bz
  133. @$(MAKECOOKIE)
  134. extract-%.tar.bz2: tar-bz-extract-%.tar.bz2
  135. @$(MAKECOOKIE)
  136. extract-%.tbz: tar-bz-extract-%.tbz
  137. @$(MAKECOOKIE)
  138. extract-%.zip: zip-extract-%.zip
  139. @$(MAKECOOKIE)
  140. extract-%.ZIP: zip-extract-%.ZIP
  141. @$(MAKECOOKIE)
  142. extract-%.jpeg: cp-extract-%.jpeg
  143. @$(MAKECOOKIE)
  144. extract-%.png: cp-extract-%.png
  145. @$(MAKECOOKIE)
  146. extract-%.html: cp-extract-%.html
  147. @$(MAKECOOKIE)
  148. extract-%.spl: cp-extract-%.spl
  149. @$(MAKECOOKIE)
  150. extract-%.txt: cp-extract-%.txt
  151. @$(MAKECOOKIE)
  152. extract-%.cfg: cp-extract-%.cfg
  153. @$(MAKECOOKIE)
  154. extract-%.c: cp-extract-%.c
  155. @$(MAKECOOKIE)
  156. extract-%.sh: cp-extract-%.sh
  157. @$(MAKECOOKIE)
  158. extract-%.cmd: cp-extract-%.cmd
  159. @$(MAKECOOKIE)
  160. extract-%: cp-extract-%
  161. @$(MAKECOOKIE)
  162. #################### PATCH RULES ####################
  163. # apply bzipped patches
  164. bz-patch-%:
  165. @echo ' $(call TMSG_LIB,Applying patch,$(DOWNLOADDIR)/$*)'
  166. @bzip2 -dc $(DOWNLOADDIR)/$* | patch -p0
  167. @$(MAKECOOKIE)
  168. # apply gzipped patches
  169. gz-patch-%:
  170. @echo ' $(call TMSG_LIB,Applying patch,$(DOWNLOADDIR)/$*)'
  171. @gzip -dc $(DOWNLOADDIR)/$* | patch -p0
  172. @$(MAKECOOKIE)
  173. # apply normal patches
  174. normal-patch-%:
  175. @echo ' $(call TMSG_LIB,Applying patch,$(DOWNLOADDIR)/$*)'
  176. @patch -p0 < $(DOWNLOADDIR)/$*
  177. @$(MAKECOOKIE)
  178. # This is used by makepatch
  179. %/gar-base.diff:
  180. @echo ' $(call TMSG_LIB,Creating patch,$@)'
  181. @EXTRACTDIR=$(SCRATCHDIR) COOKIEDIR=$(SCRATCHDIR)-$(COOKIEDIR) $(MAKE) extract
  182. @if diff --speed-large-files --minimal -Nru $(SCRATCHDIR) $(WORKDIR) > $@; then \
  183. rm $@; \
  184. fi
  185. ### PATCH FILE TYPE MAPPINGS ###
  186. # These rules specify which of the above patch action rules to use for a given
  187. # file extension. Often support for a given patch format can be handled by
  188. # simply adding a rule here.
  189. patch-%.diff.bz: bz-patch-%.diff.bz
  190. @$(MAKECOOKIE)
  191. patch-%.patch.bz: bz-patch-%.patch.bz
  192. @$(MAKECOOKIE)
  193. patch-%.diff.bz2: bz-patch-%.diff.bz2
  194. @$(MAKECOOKIE)
  195. patch-%.patch.bz2: bz-patch-%.patch.bz2
  196. @$(MAKECOOKIE)
  197. patch-%.diff.gz: gz-patch-%.diff.gz
  198. @$(MAKECOOKIE)
  199. patch-%.patch.gz: gz-patch-%.patch.gz
  200. @$(MAKECOOKIE)
  201. patch-%.diff.Z: gz-patch-%.diff.Z
  202. @$(MAKECOOKIE)
  203. patch-%.patch.Z: gz-patch-%.patch.Z
  204. @$(MAKECOOKIE)
  205. patch-%.diff: normal-patch-%.diff
  206. @$(MAKECOOKIE)
  207. patch-%.patch: normal-patch-%.patch
  208. @$(MAKECOOKIE)
  209. #################### CONFIGURE RULES ####################
  210. ifdef HAVE_QT_3_3_INSTALLED
  211. TMP_DIRPATHS = --prefix=$(prefix) --exec_prefix=$(exec_prefix) --bindir=$(bindir) --sbindir=$(sbindir) --libexecdir=$(libexecdir) --datadir=$(datadir) --sysconfdir=$(sysconfdir) --sharedstatedir=$(sharedstatedir) --localstatedir=$(localstatedir) --libdir=$(libdir) --infodir=$(infodir) --lispdir=$(lispdir) --includedir=$(includedir) --mandir=$(mandir) --with-qt-dir=$(QTDIR)
  212. else
  213. TMP_DIRPATHS = --prefix=$(prefix) --exec_prefix=$(exec_prefix) --bindir=$(bindir) --sbindir=$(sbindir) --libexecdir=$(libexecdir) --datadir=$(datadir) --sysconfdir=$(sysconfdir) --sharedstatedir=$(sharedstatedir) --localstatedir=$(localstatedir) --libdir=$(libdir) --infodir=$(infodir) --lispdir=$(lispdir) --includedir=$(includedir) --mandir=$(mandir) --with-qt-dir=$(prefix)
  214. QTDIR = $(prefix)
  215. endif
  216. TDEDIR = $(prefix)
  217. TDEDIRS = $(prefix)
  218. ARTSCCONFIG = $(prefix)/bin/artsc-config
  219. KDECONFIG = $(prefix)/bin/tde-config
  220. LIBART_CONFIG = $(prefix)/bin/libart2-config
  221. XML_CONFIG = $(prefix)/bin/xml2-config
  222. XSLT_CONFIG = $(prefix)/bin/xslt-config
  223. export QTDIR TDEDIR TDEDIRS ARTSCCONFIG KDECONFIG LIBART_CONFIG XML_CONFIG XSLT_CONFIG
  224. NODIRPATHS += --lispdir
  225. DIRPATHS = $(filter-out $(addsuffix %,$(NODIRPATHS)), $(TMP_DIRPATHS))
  226. # configure a package that has an autoconf-style configure
  227. # script.
  228. configure-%/configure:
  229. @echo ' $(call TMSG_LIB,Running configure in,$*)'
  230. @cd $* && $(CONFIGURE_ENV) ./configure $(CONFIGURE_ARGS)
  231. @$(MAKECOOKIE)
  232. # configure a package that uses imake
  233. # FIXME: untested and likely not the right way to handle the
  234. # arguments
  235. configure-%/Imakefile:
  236. @echo ' $(call TMSG_LIB,Running xmkmf in,$*)'
  237. @cd $* && $(CONFIGURE_ENV) xmkmf $(CONFIGURE_ARGS)
  238. @$(MAKECOOKIE)
  239. #################### BUILD RULES ####################
  240. # build from a standard gnu-style makefile's default rule.
  241. build-%/Makefile:
  242. @echo ' $(call TMSG_LIB,Running make in,$*)'
  243. @$(BUILD_ENV) $(MAKE) $(foreach TTT,$(BUILD_OVERRIDE_DIRS),$(TTT)="$($(TTT))") -C $* $(BUILD_ARGS)
  244. @$(MAKECOOKIE)
  245. build-%/makefile:
  246. @echo ' $(call TMSG_LIB,Running make in,$*)'
  247. @$(BUILD_ENV) $(MAKE) $(foreach TTT,$(BUILD_OVERRIDE_DIRS),$(TTT)="$($(TTT))") -C $* $(BUILD_ARGS)
  248. @$(MAKECOOKIE)
  249. build-%/GNUmakefile:
  250. @echo ' $(call TMSG_LIB,Running make in,$*)'
  251. @$(BUILD_ENV) $(MAKE) $(foreach TTT,$(BUILD_OVERRIDE_DIRS),$(TTT)="$($(TTT))") -C $* $(BUILD_ARGS)
  252. @$(MAKECOOKIE)
  253. #################### STRIP RULES ####################
  254. # The strip rule should probably strip uninstalled binaries.
  255. # TODO: Seth, what was the exact parameter set to strip that you
  256. # used to gain maximal space on the LNX-BBC?
  257. # Strip all binaries listed in the manifest file
  258. # TODO: actually write it!
  259. # This will likely become almost as hairy as the actual
  260. # installation code.
  261. strip-$(MANIFEST_FILE):
  262. @echo "$(call TMSG_FAIL,Not finished)"
  263. # The Makefile must have a "make strip" rule for this to work.
  264. strip-%/Makefile:
  265. @echo ' $(call TMSG_LIB,Running make strip in,$*)'
  266. @$(BUILD_ENV) $(MAKE) -C $* $(BUILD_ARGS) strip
  267. @$(MAKECOOKIE)
  268. #################### INSTALL RULES ####################
  269. # just run make install and hope for the best.
  270. install-%/Makefile:
  271. @echo ' $(call TMSG_LIB,Running make install in,$*)'
  272. @$(INSTALL_ENV) $(MAKE) DESTDIR=$(DESTDIR) $(foreach TTT,$(INSTALL_OVERRIDE_DIRS),$(TTT)="$(DESTDIR)$($(TTT))") -C $* $(INSTALL_ARGS) install
  273. @$(MAKECOOKIE)
  274. install-%/makefile:
  275. @echo ' $(call TMSG_LIB,Running make install in,$*)'
  276. @$(INSTALL_ENV) $(MAKE) DESTDIR=$(DESTDIR) $(foreach TTT,$(INSTALL_OVERRIDE_DIRS),$(TTT)="$(DESTDIR)$($(TTT))") -C $* $(INSTALL_ARGS) install
  277. @$(MAKECOOKIE)
  278. install-%/GNUmakefile:
  279. @echo ' $(call TMSG_LIB,Running make install in,$*)'
  280. @$(INSTALL_ENV) $(MAKE) DESTDIR=$(DESTDIR) $(foreach TTT,$(INSTALL_OVERRIDE_DIRS),$(TTT)="$(DESTDIR)$($(TTT))") -C $* $(INSTALL_ARGS) install
  281. @$(MAKECOOKIE)
  282. ######################################
  283. # Use a manifest file of the format:
  284. # src:dest[:mode[:owner[:group]]]
  285. # as in...
  286. # ${WORKSRC}/nwall:${bindir}/nwall:2755:root:tty
  287. # ${WORKSRC}/src/foo:${sharedstatedir}/foo
  288. # ${WORKSRC}/yoink:${sysconfdir}/yoink:0600
  289. # Okay, so for the benefit of future generations, this is how it
  290. # works:
  291. #
  292. # First of all, we have this file with colon-separated lines.
  293. # The $(shell cat foo) routine turns it into a space-separated
  294. # list of words. The foreach iterates over this list, putting a
  295. # colon-separated record in $(ZORCH) on each pass through.
  296. #
  297. # Next, we have the macro $(MANIFEST_LINE), which splits a record
  298. # into a space-separated list, and $(MANIFEST_SIZE), which
  299. # determines how many elements are in such a list. These are
  300. # purely for convenience, and could be inserted inline if need
  301. # be.
  302. MANIFEST_LINE = $(subst :, ,$(ZORCH))
  303. MANIFEST_SIZE = $(words $(MANIFEST_LINE))
  304. # So the install command takes a variable number of parameters,
  305. # and our records have from two to five elements. Gmake can't do
  306. # any sort of arithmetic, so we can't do any really intelligent
  307. # indexing into the list of parameters.
  308. #
  309. # Since the last three elements of the $(MANIFEST_LINE) are what
  310. # we're interested in, we make a parallel list with the parameter
  311. # switch text (note the dummy elements at the beginning):
  312. MANIFEST_FLAGS = notused notused --mode= --owner= --group=
  313. # The following environment variables are set before the
  314. # installation boogaloo begins. This ensures that WORKSRC is
  315. # available to the manifest and that all of the location
  316. # variables are suitable for *installation* (that is, using
  317. # DESTDIR)
  318. MANIFEST_ENV += WORKSRC=$(WORKSRC)
  319. # This was part of the "implicit DESTDIR" regime. However:
  320. # http://gar.lnx-bbc.org/wiki/ImplicitDestdirConsideredHarmful
  321. #MANIFEST_ENV += $(foreach TTT,prefix exec_prefix bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir infodir lispdir includedir mandir,$(TTT)=$(DESTDIR)$($(TTT)))
  322. # ...and then we join a slice of it with the corresponding slice
  323. # of the $(MANIFEST_LINE), starting at 3 and going to
  324. # $(MANIFEST_SIZE). That's where all the real magic happens,
  325. # right there!
  326. #
  327. # following that, we just splat elements one and two of
  328. # $(MANIFEST_LINE) on the end, since they're the ones that are
  329. # always there. Slap a semicolon on the end, and you've got a
  330. # completed iteration through the foreach! Beaujolais!
  331. # FIXME: using -D may not be the right thing to do!
  332. install-$(MANIFEST_FILE):
  333. @echo ' $(call TMSG_LIB,Installing from,$(MANIFEST_FILE))'
  334. $(MANIFEST_ENV) ; $(foreach ZORCH,$(shell cat $(MANIFEST_FILE)), install -Dc $(join $(wordlist 3,$(MANIFEST_SIZE),$(MANIFEST_FLAGS)),$(wordlist 3,$(MANIFEST_SIZE),$(MANIFEST_LINE))) $(word 1,$(MANIFEST_LINE)) $(word 2,$(MANIFEST_LINE)) ;)
  335. @$(MAKECOOKIE)
  336. #################### DEPENDENCY RULES ####################
  337. # builddeps need to have everything put in $(BUILD_PREFIX)
  338. # (unless they've been installed already, in which case they're
  339. # already in the install dir)
  340. # it checks the standard cookie dir first, then a special
  341. # -builddep cookie dir, then if those fail, it does the builddep
  342. # build with the -builddep cookie dir. This should do The Right
  343. # Thing.
  344. builddep-$(GARDIR)/%:
  345. @echo ' $(call TMSG_LIB,Building,$*,as a build dep)'
  346. @COOKIEDIR=cookies $(MAKE) -C $(GARDIR)/$* install-p > /dev/null 2>&1 || \
  347. COOKIEDIR=$(COOKIEDIR)-builddep $(MAKE) -C $(GARDIR)/$* install-p > /dev/null 2>&1 || \
  348. COOKIEDIR=$(COOKIEDIR)-builddep prefix=$(BUILD_PREFIX) exec_prefix=$(BUILD_PREFIX) $(MAKE) -C $(GARDIR)/$* install
  349. # Standard deps install into the standard install dir. For the
  350. # BBC, we set the includedir to the build tree and the libdir to
  351. # the install tree. Most dependencies work this way.
  352. # XXX: use a secondary variable to store the canonical cookiedir
  353. # somehow.
  354. dep-$(GARDIR)/%:
  355. @echo ' $(call TMSG_LIB,Building,$*,as a dependency)'
  356. @COOKIEDIR=cookies $(MAKE) -C $(GARDIR)/$* install-p > /dev/null 2>&1 || \
  357. $(MAKE) -C $(GARDIR)/$* install
  358. # Source Deps grab the source code for another package
  359. srcdep-$(GARDIR)/%:
  360. @echo ' $(call TMSG_LIB,Grabbing source for,$*,as a dependency)'
  361. @$(MAKE) -C $(GARDIR)/$* patch-p extract-p > /dev/null 2>&1 || \
  362. $(MAKE) -C $(GARDIR)/$* patch
  363. # Igor's info and man gzipper rule
  364. gzip-info-man: gzip-info gzip-man
  365. gzip-info:
  366. find $(DESTDIR) -type f -iname *.info* -not -iname *.gz | \
  367. xargs -r gzip --force
  368. gzip-man:
  369. find $(DESTDIR) -type f -iname *.[1-8] -size +2 -print | \
  370. xargs -r gzip --force
  371. # Mmm, yesssss. cookies my preciousssss! Mmm, yes downloads it
  372. # is! We mustn't have nasty little gmakeses deleting our
  373. # precious cookieses now must we?
  374. .PRECIOUS: $(DOWNLOADDIR)/% $(COOKIEDIR)/% $(FILEDIR)/%