#-*- mode: Fundamental; tab-width: 4; -*- # ex:ts=4 # Copyright (C) 2001 Nick Moffitt # # Redistribution and/or use, with or without modification, is # permitted. This software is without warranty of any kind. The # author(s) shall not be liable in the event that use of the # software causes damage. # cookies go here, so we have to be able to find them for # dependency checking. VPATH += $(COOKIEDIR) # So these targets are all loaded into bbc.port.mk at the end, # and provide actions that would be written often, such as # running configure, automake, makemaker, etc. # # The do- targets depend on these, and they can be overridden by # a port maintainer, since they'e pattern-based. Thus: # # extract-foo.tar.gz: # (special stuff to unpack non-standard tarball, such as one # accidentally named .gz when it's really bzip2 or something) # # and this will override the extract-%.tar.gz rule. # convenience variable to make the cookie. DOMAKECOOKIE = mkdir -p `dirname $(COOKIEDIR)/$@` && date >> $(COOKIEDIR)/$@ MAKECOOKIE = @$(DOMAKECOOKIE) #################### FETCH RULES #################### MASTER_SUBDIR ?= DISTFILE_SUBDIR ?= SIGFILE_SUBDIR ?= PATCHFILE_SUBDIR ?= MASTER_DIRS = $(addsuffix $(MASTER_SUBDIR),$(MASTER_SITES)) DISTFILE_DIRS = $(addsuffix $(DISTFILE_SUBDIR),$(DISTFILE_SITES)) SIGFILE_DIRS = $(addsuffix $(SIGFILE_SUBDIR),$(SIGFILE_SITES)) PATCHFILE_DIRS = $(addsuffix $(PATCHFILE_SUBDIR),$(PATCHFILE_SITES)) DISTFILE_URLS = $(foreach DIR,$(FILE_SITES) $(DISTFILE_DIRS) $(MASTER_DIRS),$(addprefix $(DIR),$(DISTFILES))) SIGFILE_URLS = $(foreach DIR,$(FILE_SITES) $(SIGFILE_DIRS) $(MASTER_DIRS),$(addprefix $(DIR),$(SIGFILES))) PATCHFILE_URLS = $(foreach DIR,$(FILE_SITES) $(PATCHFILE_DIRS) $(MASTER_DIRS),$(addprefix $(DIR),$(PATCHFILES))) # FIXME: doesn't handle colons that are actually in the URL. # Need to do some URI-encoding before we change the http:// to # http// etc. URLS = $(subst ://,//,$(DISTFILE_URLS) $(SIGFILE_URLS) $(PATCHFILE_URLS)) # Download the file if and only if it doesn't have a preexisting # checksum file. Loop through available URLs and stop when you # get one that doesn't return an error code. $(DOWNLOADDIR)/%: @if test -f $(COOKIEDIR)/checksum-$*; then : ; else \ echo " ==> Grabbing $@"; \ for i in $(filter %/$*,$(URLS)); do \ echo " ==> Trying $$i"; \ $(MAKE) -s $$i || continue; \ break; \ done; \ if test -r $@ ; then : ; else \ echo '*** GAR GAR GAR! Failed to download $@! GAR GAR GAR! ***' 1>&2; \ false; \ fi; \ fi # We specify --passive-ftp for all protocols because it's possible for # an HTTP URL to redirect to an FTP one -- download.kde.org works like # this, for instance. # We specify a custom User-Agent because some clueless host sites # block wget specifically. WGET_OPTS = -c --no-check-certificate --passive-ftp -U "GARstow/1.0" # download an http URL (colons omitted) http//%: @wget $(WGET_OPTS) -P $(DOWNLOADDIR) http://$* # download an https URL (colons omitted) # We still specify --passive-ftp because it's possible for an HTTP URL to # redirect to an FTP one -- download.kde.org works like this, for instance. # Also do --no-check-certificate since we can't check the validity https//%: @wget $(WGET_OPTS) -P $(DOWNLOADDIR) https://$* # download an ftp URL (colons omitted) ftp//%: @wget $(WGET_OPTS) -P $(DOWNLOADDIR) ftp://$* # link to a local copy of the file # (absolute path) file///%: @if test -f /$*; then \ ln -sf "/$*" $(DOWNLOADDIR)/$(notdir $*); \ else \ false; \ fi # link to a local copy of the file # (relative path) file//%: @if test -f $*; then \ ln -sf $(CURDIR)/$* $(DOWNLOADDIR)/$(notdir $*); \ else \ false; \ fi # Using Jeff Waugh's rsync rule. # DOES NOT PRESERVE SYMLINKS! rsync//%: @rsync -azvL --progress rsync://$* $(DOWNLOADDIR)/ # Download a directory tree as a tarball. RSYNC_OPTS ?= -az RSYNC_PATH ?= rsynctree//%: @mkdir -p $(DOWNLOADDIR)/rsync @rsync -v --progress $(RSYNC_OPTS) $(RSYNC_PATH) $(DOWNLOADDIR)/rsync @cd $(DOWNLOADDIR)/rsync && tar -czvf ../out * @mv $(DOWNLOADDIR)/out $(DOWNLOADDIR)/$* # Using Jeff Waugh's scp rule scp//%: @scp -C $* $(DOWNLOADDIR)/ # Check out source from CVS. CVS_CO_OPTS ?= -D$(GARVERSION) -P CVS_MODULE ?= $(GARNAME) cvs//%: @mkdir -p $(DOWNLOADDIR)/cvs @cd $(DOWNLOADDIR)/cvs && cvs -d$(CVS_ROOT) login && cvs -d$(CVS_ROOT) co $(CVS_CO_OPTS) $(CVS_MODULE) && tar --exclude=CVS -czvf ../out * @mv $(DOWNLOADDIR)/out $(DOWNLOADDIR)/$* # Check out source from Subversion. SVN_REVISION ?= "{$(GARVERSION)}" SVN_CO_OPTS ?= -r $(SVN_REVISION) svnco//%: @mkdir -p $(DOWNLOADDIR)/svn @cd $(DOWNLOADDIR)/svn && svn co $(SVN_CO_OPTS) $(SVN_PATH) && tar --exclude=.svn -czvf ../out * @mv $(DOWNLOADDIR)/out $(DOWNLOADDIR)/$* # Check out source from Darcs. DARCS_GET_OPTS ?= --partial --to-match "date $(GARVERSION)" darcs//%: @mkdir -p $(DOWNLOADDIR)/darcs @cd $(DOWNLOADDIR)/darcs && darcs get $(DARCS_GET_OPTS) $(DARCS_PATH) && tar --exclude=_darcs -czvf ../out * @mv $(DOWNLOADDIR)/out $(DOWNLOADDIR)/$* # Check out source from Git. GIT_REVISION ?= v$(GARVERSION) git//%: @mkdir -p $(DOWNLOADDIR)/git @cd $(DOWNLOADDIR)/git && \ git clone $(GIT_PATH) && \ (cd * && git checkout $(GIT_REVISION)) && \ tar --exclude=.git -czvf ../out * @mv $(DOWNLOADDIR)/out $(DOWNLOADDIR)/$* #################### CHECKSUM RULES #################### # check a given file's checksum against $(CHECKSUM_FILE) and # error out if it mentions the file without an "OK". checksum-%: $(CHECKSUM_FILE) @echo " ==> Running checksum on $*" @if grep -- '$*' $(CHECKSUM_FILE); then \ if LC_ALL="C" LANG="C" md5sum -c $(CHECKSUM_FILE) 2>&1 | grep -- '$*' | grep -v ':[ ]\+OK'; then \ echo '*** GAR GAR GAR! $* failed checksum test! GAR GAR GAR! ***' 1>&2; \ false; \ else \ echo '$(CHECKSUM_FILE) is OK'; \ $(DOMAKECOOKIE); \ fi \ else \ echo '*** GAR GAR GAR! $* not in $(CHECKSUM_FILE) file! GAR GAR GAR! ***' 1>&2; \ false; \ fi # use a signature file to check the file it refers to GPGV ?= gpgv --keyring $(GPG_KEYRING) checksig-%.sig.asc: @echo " ==> Checking PGP signature $*" @$(GPGV) $(DOWNLOADDIR)/$*.sig.asc $(DOWNLOADDIR)/$* $(MAKECOOKIE) checksig-%.asc.txt: @echo " ==> Checking PGP signature $*" @$(GPGV) $(DOWNLOADDIR)/$*.asc.txt $(DOWNLOADDIR)/$* $(MAKECOOKIE) checksig-%-asc.txt: @echo " ==> Checking PGP signature $*" @$(GPGV) $(DOWNLOADDIR)/$*-asc.txt $(DOWNLOADDIR)/$(subst -tar-,.tar.,$*) $(MAKECOOKIE) checksig-%.sig: @echo " ==> Checking PGP signature $*" @$(GPGV) $(DOWNLOADDIR)/$*.sig $(MAKECOOKIE) checksig-%.sign: @echo " ==> Checking PGP signature $*" @$(GPGV) $(DOWNLOADDIR)/$*.sign $(MAKECOOKIE) checksig-%.asc: @echo " ==> Checking PGP signature $*" @$(GPGV) $(DOWNLOADDIR)/$*.asc $(MAKECOOKIE) checksig-%.sha1: @echo " ==> Checking SHA1 checksums $*" @cd $(DOWNLOADDIR) && sha1sum -c $*.sha1 $(MAKECOOKIE) #################### GARCHIVE RULES #################### # while we're here, let's just handle how to back up our # checksummed files garchive-%: @-test -h $(DOWNLOADDIR)/$* || cp -f $(DOWNLOADDIR)/$* $(GARCHIVEDIR)/ $(MAKECOOKIE) #################### EXTRACT RULES #################### # Enable the "regular user" behaviour for tar, so that we don't extract # archives with random users or world-writable permissions. TAR_OPTS = \ --no-same-owner \ --no-same-permissions # rule to extract files with tar xzf extract-%.tar.Z extract-%.tgz extract-%.tar.gz extract-%.taz: @echo " ==> Extracting $(patsubst extract-%,$(DOWNLOADDIR)/%,$@)" @gzip -dc $(patsubst extract-%,$(DOWNLOADDIR)/%,$@) | tar xf - $(TAR_OPTS) -C $(EXTRACTDIR) $(MAKECOOKIE) # rule to extract files with tar and bzip extract-%.tar.bz extract-%.tar.bz2 extract-%.tbz: @echo " ==> Extracting $(patsubst extract-%,$(DOWNLOADDIR)/%,$@)" @bzip2 -dc $(patsubst extract-%,$(DOWNLOADDIR)/%,$@) | tar xf - $(TAR_OPTS) -C $(EXTRACTDIR) $(MAKECOOKIE) # rule to extract files with tar and lzma extract-%.tar.lzma: @echo " ==> Extracting $(patsubst extract-%,$(DOWNLOADDIR)/%,$@)" @lzma -dc $(patsubst extract-%,$(DOWNLOADDIR)/%,$@) | tar xf - $(TAR_OPTS) -C $(EXTRACTDIR) $(MAKECOOKIE) # rule to extract files with tar extract-%.tar: @echo " ==> Extracting $(patsubst extract-%,$(DOWNLOADDIR)/%,$@)" @tar xf $(patsubst extract-%,$(DOWNLOADDIR)/%,$@) $(TAR_OPTS) -C $(EXTRACTDIR) $(MAKECOOKIE) # rule to extract files with zip extract-%.zip: @echo " ==> Extracting $(patsubst extract-%,$(DOWNLOADDIR)/%,$@)" @unzip -o $(patsubst extract-%,$(DOWNLOADDIR)/%,$@) -d $(EXTRACTDIR) $(MAKECOOKIE) # rule to extract RPM files with rpm2cpio and cpio extract-%.rpm: @echo " ==> Extracting $(patsubst extract-%,$(DOWNLOADDIR)/%,$@)" @rpm2cpio $(patsubst extract-%,$(DOWNLOADDIR)/%,$@) | (cd $(EXTRACTDIR) && cpio -i -d) $(MAKECOOKIE) # Unmatched files should just be copied. # This is a bit of a kludge -- it's to allow us to have packages that are built # from a load of downloaded files (i.e. cvsweb checkouts) and a patch. extract-%: @echo " ==> Copying $(patsubst extract-%,$(DOWNLOADDIR)/%,$@)" @mkdir -p $(EXTRACTDIR)/$(DISTNAME) @cp $(patsubst extract-%,$(DOWNLOADDIR)/%,$@) $(EXTRACTDIR)/$(DISTNAME) $(MAKECOOKIE) #################### PATCH RULES #################### PATCHOPTS ?= -p2 PATCHDIR ?= $(WORKSRC) PATCH = patch $(PATCHOPTS) -d $(PATCHDIR) # apply bzipped patches patch-%.bz patch-%.bz2: @echo " ==> Applying patch $(patsubst patch-%,$(DOWNLOADDIR)/%,$@)" @bzip2 -dc $(patsubst patch-%,$(DOWNLOADDIR)/%,$@) | $(PATCH) $(MAKECOOKIE) # apply gzipped patches patch-%.gz: @echo " ==> Applying patch $(patsubst patch-%,$(DOWNLOADDIR)/%,$@)" @gzip -dc $(patsubst patch-%,$(DOWNLOADDIR)/%,$@) | $(PATCH) $(MAKECOOKIE) # apply normal patches patch-%: @echo " ==> Applying patch $(patsubst patch-%,$(DOWNLOADDIR)/%,$@)" $(PATCH) < $(patsubst patch-%,$(DOWNLOADDIR)/%,$@) $(MAKECOOKIE) # This is used by makepatch %/gar-base.diff: @echo " ==> Creating patch $@" @EXTRACTDIR=$(SCRATCHDIR) COOKIEDIR=$(SCRATCHDIR)-$(COOKIEDIR) $(MAKE) extract @if diff -x 'config.log' -x 'config.status' -ru $(SCRATCHDIR) $(WORKDIR) | grep -v '^Only in' > $@; then :; else \ rm $@; \ fi #################### CONFIGURE RULES #################### DIRPATHS = --prefix=$(prefix) --sysconfdir=$(sysconfdir) --localstatedir=$(vardir) --sharedstatedir=$(comdir) CONFIGURE_ARGS ?= $(DIRPATHS) RUBY_DIRPATHS = --prefix=$(packageprefix) RUBY_CONFIGURE_ARGS ?= $(RUBY_DIRPATHS) SCONS_ARGS ?= PREFIX=$(prefix) CMAKE_CONFIGURE_ARGS ?= -DCMAKE_INSTALL_PREFIX=$(prefix) CABAL_CONFIGURE_ARGS ?= --prefix=$(prefix) WAF_CONFIGURE_ARGS ?= --prefix=$(prefix) # configure a package that has an autoconf-style configure # script, coping correctly when WORKOBJ is set to something other than WORKDIR. configure-%/configure: @echo " ==> Running configure in $*" @mkdir -p $(WORKOBJ) @cd $(if $(WORKOBJ_CHANGED_P),$(WORKOBJ),$*) && $(CONFIGURE_ENV) $(if $(WORKOBJ_CHANGED_P),$(LEAVE_WORKOBJ)/$*,.)/configure $(CONFIGURE_ARGS) $(MAKECOOKIE) # configure a package that has a Perl-style configure script. configure-%/configure.gnu: @echo " ==> Running configure.gnu in $*" @cd $* && $(CONFIGURE_ENV) ./configure.gnu $(CONFIGURE_ARGS) $(MAKECOOKIE) # configure a package that has an openssl-style configure script. configure-%/config: @echo " ==> Running config in $*" @cd $* && $(CONFIGURE_ENV) ./config $(CONFIGURE_ARGS) $(MAKECOOKIE) # configure a package that uses imake # FIXME: untested and likely not the right way to handle the # arguments configure-%/Imakefile: @echo " ==> Running xmkmf in $*" @cd $* && $(CONFIGURE_ENV) xmkmf $(CONFIGURE_ARGS) $(MAKECOOKIE) # configure a package that uses CMake configure-%/CMakeLists.txt: @echo " ==> Running cmake in $*" @mkdir -p $(WORKOBJ) @cd $(if $(WORKOBJ_CHANGED_P),$(WORKOBJ),$*) && $(CONFIGURE_ENV) cmake $(if $(WORKOBJ_CHANGED_P),$(LEAVE_WORKOBJ)/$* ,)$(CMAKE_CONFIGURE_ARGS) $(MAKECOOKIE) # configure using Python distutils configure-%/setup.py: @echo " ==> Running setup.py config in $*" @cd $* && $(BUILD_ENV) python setup.py config $(PY_BUILD_ARGS) $(MAKECOOKIE) # configure a Ruby extension configure-%/extconf.rb: @echo " ==> Running extconf.rb in $*" @cd $* && $(CONFIGURE_ENV) ruby extconf.rb $(RUBY_CONFIGURE_ARGS) $(MAKECOOKIE) # configure the other sort of Ruby extension configure-%/setup.rb: @echo " ==> Running setup.rb config in $*" @cd $* && $(CONFIGURE_ENV) ruby setup.rb config $(RUBY_CONFIGURE_ARGS) $(MAKECOOKIE) # configure a third sort of Ruby extension configure-%/install.rb: @echo " ==> Running install.rb config in $*" @cd $* && $(CONFIGURE_ENV) ruby install.rb config $(RUBY_CONFIGURE_ARGS) $(MAKECOOKIE) # configure using SCons (which is only needed by some packages...) configure-%/SConstruct: @echo " ==> Running scons configure in $*" @cd $* && $(CONFIGURE_ENV) scons configure $(SCONS_DEBUG) $(SCONS_ARGS) $(MAKECOOKIE) # configure using Cabal configure-%/Setup.lhs configure-%/Setup.hs: @echo " ==> Running Setup configure in $*" @cd $* && $(CONFIGURE_ENV) runhaskell Setup.*hs configure $(CABAL_CONFIGURE_ARGS) $(MAKECOOKIE) # configure using waf configure-%/waf: @echo " ==> Running waf configure in $*" @cd $* && $(CONFIGURE_ENV) ./waf configure $(WAF_CONFIGURE_ARGS) $(MAKECOOKIE) #################### BUILD RULES #################### # build from a standard gnu-style makefile's default rule. build-%/Makefile build-%/makefile build-%/GNUmakefile: @echo " ==> Running make in $*" @$(BUILD_ENV) $(MAKE) -C $* $(BUILD_ARGS) $(MAKECOOKIE) build-%/Makefile-BSD: @echo " ==> Running pmake in $*" @cd $* && $(BUILD_ENV) pmake $(BUILD_ARGS) $(MAKECOOKIE) # build using Python distutils build-%/setup.py: @echo " ==> Running setup.py build in $*" @cd $* && $(BUILD_ENV) python setup.py build $(PY_BUILD_ARGS) $(MAKECOOKIE) # build using Ruby setup.rb build-%/setup.rb: @echo " ==> Running setup.rb setup in $*" @cd $* && $(BUILD_ENV) ruby setup.rb setup $(RUBY_BUILD_ARGS) $(MAKECOOKIE) # build using Ruby install.rb build-%/install.rb: @echo " ==> Running install.rb setup in $*" @cd $* && $(BUILD_ENV) ruby install.rb setup $(RUBY_BUILD_ARGS) $(MAKECOOKIE) # build using SCons (which pretends not to have a seperate configure step, # having "sticky options" instead...) build-%/SConstruct: @echo " ==> Running scons in $*" @cd $* && $(BUILD_ENV) scons $(SCONS_DEBUG) $(SCONS_ARGS) $(MAKECOOKIE) # build using Cabal build-%/Setup.lhs build-%/Setup.hs: @echo " ==> Running Setup build in $*" @cd $* && $(BUILD_ENV) runhaskell Setup.*hs build $(CABAL_BUILD_ARGS) $(MAKECOOKIE) # build using waf build-%/waf: @echo " ==> Running waf in $*" @cd $* && $(BUILD_ENV) ./waf $(WAF_BUILD_ARGS) $(MAKECOOKIE) #################### TEST RULES #################### TEST_ARGS ?= check # Test a program where "make check" (or similar) runs the test. test-%/Makefile test-%/makefile test-%/GNUmakefile: @echo " ==> Testing in $*" @$(TEST_ENV) $(MAKE) -C $* $(TEST_ARGS) $(MAKECOOKIE) #################### INSTALL RULES #################### # The format of stow package names. PACKAGENAME ?= $(GARNAME)-$(GARVERSION) packageprefix = $(packagesdir)/$(PACKAGENAME) packagedocs = $(packageprefix)/share/doc/$(GARNAME) packageexamples = $(packageprefix)/share/examples/$(GARNAME) # Set the arguments to install into the package directory. GNU_INSTALL_ARGS = prefix=$(packageprefix) exec_prefix=$(packageprefix) sysconfdir=$(sysconfdir) localstatedir=$(vardir) sharedstatedir=$(comdir) INSTALL_TARGET ?= install INSTALL_ARGS ?= $(GNU_INSTALL_ARGS) SCONS_INSTALL_ARGS ?= DESTDIR=$(packageDESTDIR) CABAL_INSTALL_ARGS ?= --copy-prefix=$(packageDESTDIR)$(prefix) # Code to handle DESTDIR installations. define prepare-DESTDIR @echo " ==> Preparing installation directory" @rm -rf $(packageprefix) @mkdir -p $(packageDESTDIR) $(sysconfdir) $(vardir) @mkdir -p `dirname $(packageDESTDIR)$(sysconfdir)` `dirname $(packageDESTDIR)$(vardir)` @ln -sf $(sysconfdir) $(packageDESTDIR)$(sysconfdir) @ln -sf $(vardir) $(packageDESTDIR)$(vardir) endef define finish-DESTDIR @echo " ==> Cleaning up installation directory" @rm $(packageDESTDIR)$(sysconfdir) $(packageDESTDIR)$(vardir) @mv $(packageDESTDIR)$(prefix)/* $(packageprefix) @rm -r $(packageDESTDIR) endef # just run make install and hope for the best. install-%/Makefile install-%/makefile install-%/GNUmakefile: @echo " ==> Running make $(INSTALL_TARGET) in $*" @$(INSTALL_ENV) $(MAKE) -C $* $(INSTALL_ARGS) $(INSTALL_TARGET) $(MAKECOOKIE) # Alternate approach: use DESTDIR. DESTDIR_INSTALL_ARGS ?= DESTDIR_PRE_COMMAND ?= true DESTDIR_POST_COMMAND ?= true packageDESTDIR = $(packageprefix)/DEST install-%/Makefile-DESTDIR: $(prepare-DESTDIR) @echo " ==> Running make $(INSTALL_TARGET) with DESTDIR in $*" @$(DESTDIR_PRE_COMMAND) @$(INSTALL_ENV) $(MAKE) -C $* $(DESTDIR_INSTALL_ARGS) $(INSTALL_TARGET) DESTDIR=$(packageDESTDIR) @$(DESTDIR_POST_COMMAND) $(finish-DESTDIR) $(MAKECOOKIE) install-%/Makefile-BSD: @echo " ==> Running pmake $(INSTALL_TARGET) in $*" @cd $* && $(INSTALL_ENV) pmake $(INSTALL_ARGS) $(INSTALL_TARGET) $(MAKECOOKIE) # install using Python distutils # We have to create the installation directory first because otherwise # setuptools (spit) will complain. install-%/setup.py: $(prepare-DESTDIR) @echo " ==> Running setup.py install in $*" @mkdir -p $(packageDESTDIR)`python -c 'from distutils.sysconfig import get_python_lib; print get_python_lib()'` @cd $* && $(INSTALL_ENV) python setup.py install --root=$(packageDESTDIR) $(PY_INSTALL_ARGS) $(finish-DESTDIR) $(MAKECOOKIE) # install using Ruby setup.rb install-%/setup.rb: @echo " ==> Running setup.rb install in $*" @cd $* && $(INSTALL_ENV) ruby setup.rb install $(RUBY_INSTALL_ARGS) $(MAKECOOKIE) # install using Ruby install.rb install-%/install.rb: @echo " ==> Running install.rb install in $*" @cd $* && $(INSTALL_ENV) ruby install.rb install $(RUBY_INSTALL_ARGS) $(MAKECOOKIE) # install using SCons install-%/SConstruct: $(prepare-DESTDIR) @echo " ==> Running scons in $*" @cd $* && $(INSTALL_ENV) scons install $(SCONS_ARGS) $(SCONS_INSTALL_ARGS) $(finish-DESTDIR) $(MAKECOOKIE) # install using Cabal install-%/Setup.lhs install-%/Setup.hs: $(prepare-DESTDIR) @echo " ==> Running Setup copy in $*" @cd $* && $(INSTALL_ENV) runhaskell Setup.*hs copy $(CABAL_INSTALL_ARGS) $(finish-DESTDIR) $(MAKECOOKIE) # install using CMake install-%/cmake_install.cmake: $(prepare-DESTDIR) @echo " ==> Running cmake in $*" @cd $* && $(INSTALL_ENV) env DESTDIR=$(packageDESTDIR) cmake -P cmake_install.cmake $(finish-DESTDIR) $(MAKECOOKIE) # install using waf install-%/waf: $(prepare-DESTDIR) @echo " ==> Running waf install in $*" @cd $* && $(INSTALL_ENV) env DESTDIR=$(packageDESTDIR) ./waf install $(WAF_INSTALL_ARGS) $(finish-DESTDIR) $(MAKECOOKIE) ###################################### # Use a manifest file of the format: # src:dest[:mode[:owner[:group]]] # as in... # ${WORKSRC}/nwall:bin/nwall:2755:root:tty # ${WORKSRC}/src/foo:share/foo # ${WORKSRC}/yoink:etc/yoink:0600 # Okay, so for the benefit of future generations, this is how it # works: # # First of all, we have this file with colon-separated lines. # The $(shell cat foo) routine turns it into a space-separated # list of words. The foreach iterates over this list, putting a # colon-separated record in $(ZORCH) on each pass through. # # Next, we have the macro $(MANIFEST_LINE), which splits a record # into a space-separated list, and $(MANIFEST_SIZE), which # determines how many elements are in such a list. These are # purely for convenience, and could be inserted inline if need # be. MANIFEST_LINE = $(subst :, ,$(ZORCH)) MANIFEST_SIZE = $(words $(MANIFEST_LINE)) # So the install command takes a variable number of parameters, # and our records have from two to five elements. Gmake can't do # any sort of arithmetic, so we can't do any really intelligent # indexing into the list of parameters. # # Since the last three elements of the $(MANIFEST_LINE) are what # we're interested in, we make a parallel list with the parameter # switch text (note the dummy elements at the beginning): MANIFEST_FLAGS = notused notused --mode= --owner= --group= # ...and then we join a slice of it with the corresponding slice # of the $(MANIFEST_LINE), starting at 3 and going to # $(MANIFEST_SIZE). That's where all the real magic happens, # right there! # # following that, we just splat elements one and two of # $(MANIFEST_LINE) on the end, since they're the ones that are # always there. Slap a semicolon on the end, and you've got a # completed iteration through the foreach! Beaujolais! # FIXME: using -D may not be the right thing to do! install-$(MANIFEST_FILE): @echo " ==> Installing from $(MANIFEST_FILE)" @WORKSRC=$(WORKSRC) ; $(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)) $(packageprefix)/$(word 2,$(MANIFEST_LINE)) ;) $(MAKECOOKIE) # Standard deps install into the standard install dir. For the # BBC, we set the includedir to the build tree and the libdir to # the install tree. Most dependencies work this way. dep-$(GARDIR)/%: @if [ "$(filter $*,$(IGNORE_DEPS))" != "" ] ; then \ echo ' ==> Ignoring dependency $*' ; \ else \ echo ' ==> Building $* as a dependency' ; \ $(MAKE) -C $(GARDIR)/$* install-p > /dev/null 2>&1 || $(MAKE) -C $(GARDIR)/$* install ; \ fi ###################################### # Commands for installing different types of files INSTALL_BIN = install_bin () { mkdir -p $(packageprefix)/bin && install -m755 $$* $(packageprefix)/bin; } && install_bin INSTALL_SBIN = install_sbin () { mkdir -p $(packageprefix)/sbin && install -m755 $$* $(packageprefix)/sbin; } && install_sbin INSTALL_INCLUDE = install_include () { mkdir -p $(packageprefix)/include && install -m644 $$* $(packageprefix)/include; } && install_include INSTALL_LIB = install_lib () { mkdir -p $(packageprefix)/lib && install -m755 $$* $(packageprefix)/lib; } && install_lib INSTALL_MAN = install_man () { for x in $$*; do v=`echo $$x | sed 's/.*\.//'`; mkdir -p $(packageprefix)/man/man$$v && install -m644 $$x $(packageprefix)/man/man$$v; done; } && install_man INSTALL_CATMAN = install_catman () { for x in $$*; do v=`echo $$x | sed 's/.*\.//'`; mkdir -p $(packageprefix)/man/cat$$v && install -m644 $$x $(packageprefix)/man/cat$$v; done; } && install_catman INSTALL_INFO = install_info () { mkdir -p $(packageprefix)/info && install -m644 $$* $(packageprefix)/info; } && install_info INSTALL_DOCS = install_docs () { mkdir -p $(packagedocs) && cp -R $$* $(packagedocs); } && install_docs INSTALL_FONTS = install_fonts () { mkdir -p $(packageprefix)/share/fonts/$(GARNAME) && cp -R "$$@" $(packageprefix)/share/fonts/$(GARNAME); } && install_fonts INSTALL_X_FONTS = install_x_fonts () { mkdir -p $(packageprefix)/lib/X11/fonts/$(GARNAME) && cp -R $$* $(packageprefix)/lib/X11/fonts/$(GARNAME); } && install_x_fonts INSTALL_SYSCONF = install_sysconf () { mkdir -p $(sysconfdir) && install -m644 $$* $(sysconfdir); } && install_sysconf INSTALL_LADSPA = install_ladspa () { mkdir -p $(packageprefix)/lib/ladspa && install -m755 $$* $(packageprefix)/lib/ladspa; } && install_ladspa SYMLINK_BIN = symlink_bin () { from=$$1; shift; mkdir -p $(packageprefix)/bin && for x in $$* ; do ln -sf $$from $(packageprefix)/bin/$$x ; done } && symlink_bin SYMLINK_SBIN = symlink_sbin () { from=$$1; shift; mkdir -p $(packageprefix)/sbin && for x in $$* ; do ln -sf $$from $(packageprefix)/sbin/$$x ; done } && symlink_sbin SYMLINK_LIB = symlink_lib () { from=$$1; shift; mkdir -p $(packageprefix)/lib && for x in $$* ; do ln -sf $$from $(packageprefix)/lib/$$x ; done } && symlink_lib SUFFIX_PROG = suffix_prog () { \ suffix=$$1; shift; \ for x in $$*; do \ case "$$x" in $$suffix*) continue ;; esac; \ n=`basename $$x`; \ maybe_mv () { \ if [ -f $$1 ] ; then \ echo " ==> Renaming $$1 to $$2"; \ mv $$1 $$2; \ fi \ }; \ maybe_mv $$x $$x-$$suffix; \ for s in 1 2 3 4 5 8; do \ maybe_mv $(packageprefix)/man/man$$s/$$n.$$s $(packageprefix)/man/man$$s/$$n-$$suffix.$$s; \ maybe_mv $(packageprefix)/share/man/man$$s/$$n.$$s $(packageprefix)/share/man/man$$s/$$n-$$suffix.$$s; \ done; \ if [ -d $(packageprefix)/info ]; then \ (cd $(packageprefix)/info && for x in $$n $$n-*; do \ maybe_mv $$x `echo $$x | sed "s,^$$n,$$n-$$suffix,"`; \ done); \ fi; \ done \ } && suffix_prog #################### DEP-CHECK RULES #################### DEPCHECK_TARGETS = users NEED_USERS ?= NEED_GROUPS ?= depcheck-users: @set -e; for user in $(NEED_USERS) -; do \ [ "$$user" = "-" ] && continue; \ echo ' ==> Checking user' $$user 'exists'; \ python -c "import pwd; pwd.getpwnam('$$user')" 2>/dev/null; \ done @set -e; for group in $(NEED_GROUPS) -; do \ [ "$$group" = "-" ] && continue; \ echo ' ==> Checking group' $$group 'exists'; \ python -c "import grp; grp.getgrnam('$$group')" 2>/dev/null; \ done $(MAKECOOKIE) #################### SYS-INSTALL RULES #################### SYSINSTALL_TARGETS = normalise collisions compatlibs link-package deconflict stow stow-compatlibs specials # Some files which multiple packages seem to contain. These get # removed before stowing. COLLISIONS ?= info/dir info/standards.info* info/configure.info* \ lib/libiberty.* \ share/mime/globs share/mime/magic share/mime/XMLnamespaces share/mime/aliases share/mime/subclasses share/mime/mime.cache \ share/applications/mimeinfo.cache \ lib/X11/fonts/*/fonts.dir lib/X11/fonts/*/fonts.scale lib/X11/fonts/*/fonts.cache* \ lib/perl5/*/*/perllocal.pod lib/perl5/site_perl/*/*/perllocal.pod sysinstall-collisions: @echo ' ==> Removing collisions' @rm -rf $(foreach FILE,$(COLLISIONS),$(packageprefix)/$(FILE)) $(MAKECOOKIE) sysinstall-normalise: @echo ' ==> Normalising directory layout' @set -e; \ normalise () { \ if [ -d $$1 ]; then \ echo " ==> Moving contents of $$1 to $$2"; \ mkdir -p $$2; \ cp -a $$1/* $$2; \ rm -fr $$1; \ fi; \ }; \ normalise $(packageprefix)/share/man $(packageprefix)/man; \ normalise $(packageprefix)/share/info $(packageprefix)/info; \ normalise $(packageprefix)/doc $(packageprefix)/share/doc; \ normalise $(packageprefix)/games $(packageprefix)/bin $(MAKECOOKIE) compatlibsdir = $(packagesdir)/compatlibs-0 oldlibdir = $(packagesdir)/$(GARNAME)/lib sysinstall-compatlibs: @if [ -d $(oldlibdir) ] ; then \ for x in "" `ls $(oldlibdir) | grep 'lib.*\.so\.[0-9]*$$'` ; do \ if [ -z "$$x" -o -f "$(packageprefix)/lib/$$x" ] ; then \ continue ; \ fi ; \ echo " ==> Copying old shared library $$x" ; \ mkdir -p $(compatlibsdir)/lib ; \ cp -L $(oldlibdir)/$$x $(compatlibsdir)/lib ; \ touch $(COOKIEDIR)/need-compatlibs; \ done ; \ fi $(MAKECOOKIE) sysinstall-link-package: @echo ' ==> Linking $(PACKAGENAME) to $(GARNAME)' @mkdir -p $(packageprefix) @rm -f $(packagesdir)/$(GARNAME) @ln -sf $(PACKAGENAME) $(packagesdir)/$(GARNAME) $(MAKECOOKIE) DECONFLICT = compatlibs sysinstall-deconflict: @if [ -n "$(DECONFLICT)" ] ; then \ echo ' ==> Removing conflicting files' ; \ $(GARSTOW_SCRIPTS)/force-deconflict $(packageprefix) $(GARNAME) $(DECONFLICT) ; \ fi $(MAKECOOKIE) # If stow fails, it was probably a missed collision; remove the cookies for the # preceding stages too. sysinstall-stow: @echo ' ==> Stowing' @stow -R -v -d $(packagesdir) -t $(prefix) $(GARNAME) || (rm -f $(packagesdir)/$(GARNAME) $(COOKIEDIR)/sysinstall-link-package $(COOKIEDIR)/sysinstall-collisions $(COOKIEDIR)/sysinstall-deconflict; false) $(MAKECOOKIE) unstow: @echo ' ==> Unstowing' @stow -v -d $(packagesdir) -t $(prefix) -D $(GARNAME) @rm -f $(packagesdir)/$(GARNAME) @rm -f $(COOKIEDIR)/sysinstall-stow $(COOKIEDIR)/sysinstall-link-package sysinstall-stow-compatlibs: @if [ -f $(COOKIEDIR)/need-compatlibs ] ; then \ echo ' ==> Stowing old shared libraries' ; \ rm -f $(packagesdir)/compatlibs ; \ ln -sf compatlibs-0 $(packagesdir)/compatlibs ; \ stow -v -d $(packagesdir) -t $(prefix) compatlibs ; \ rm -f $(COOKIEDIR)/need-compatlibs ; \ fi $(MAKECOOKIE) sysinstall-specials: @if [ -d $(packageprefix)/info ] ; then \ echo ' ==> Updating info directory' ; \ rm -f $(prefix)/info/dir ; \ (for x in $(prefix)/info/* ; do \ install-info $$x $(prefix)/info/dir ; \ done) 2>/dev/null ; \ fi || true @if [ `uname` = Linux -a -d $(packageprefix)/lib ] ; then \ echo ' ==> Updating ld.so cache' ; \ ldconfig ; \ fi @if [ -d $(packageprefix)/share/fonts ] ; then \ echo ' ==> Updating fontconfig cache' ; \ fc-cache -v $(prefix)/share/fonts ; \ fi @if [ -d $(packageprefix)/lib/X11/fonts ] ; then \ for subdir in $(packageprefix)/lib/X11/fonts/*/ ; do \ dir=$(prefix)/lib/X11/fonts/`basename $$subdir` ; \ echo ' ==> Updating font lists in '$$dir ; \ mkfontscale $$dir ; \ mkfontdir $$dir ; \ fc-cache $$dir ; \ done ; \ fi @if [ -d $(packageprefix)/share/mime ] ; then \ echo ' ==> Updating shared MIME database' ; \ update-mime-database $(prefix)/share/mime ; \ fi @if [ -d $(packageprefix)/share/applications ] ; then \ echo ' ==> Updating shared applications database' ; \ update-desktop-database ; \ fi @if [ -d $(packageprefix)/lib/gtk-2.0 ] ; then \ mkdir -p $(sysconfdir)/gtk-2.0 ; \ echo ' ==> Updating GTK loaders list' ; \ gdk-pixbuf-query-loaders >$(sysconfdir)/gtk-2.0/gdk-pixbuf.loaders ; \ echo ' ==> Updating GTK immodules list' ; \ gtk-query-immodules-2.0 >$(sysconfdir)/gtk-2.0/gtk.immodules ; \ fi @for x in $(packageprefix)/share/icons/*/ ; do \ r=`echo "$$x" | sed 's,^$(packageprefix),$(prefix),'` ; \ if [ -f "$$r/icon-theme.cache" ] ; then \ echo ' ==> Updating GTK icon cache in '$$r ; \ gtk-update-icon-cache -f $$r || true; \ fi ; \ done @if [ -d $(packageprefix)/share/texmf -o -d $(packageprefix)/share/texmf-dist -o -d $(packageprefix)/share/texmf-local ] ; then \ echo ' ==> Updating TeX paths' ; \ [ -x $(prefix)/bin/texhash ] && $(prefix)/bin/texhash || true; \ fi @if [ -d $(packageprefix)/lib ] && [ "`find $(packageprefix)/lib -maxdepth 2 -name 'ghc-*'`" != "" ] ; then \ echo " ==> Registering GHC packages" ; \ cd $(WORKSRC) && \ if [ -f Setup.hs -o -f Setup.lhs ] ; then \ $(INSTALL_ENV) runhaskell Setup.*hs register ; \ fi ; \ fi $(MAKECOOKIE) # Mmm, yesssss. cookies my preciousssss! Mmm, yes downloads it # is! We mustn't have nasty little gmakeses deleting our # precious cookieses now must we? .PRECIOUS: $(DOWNLOADDIR)/% $(COOKIEDIR)/% $(FILEDIR)/%