File: gar.lib.mk
base-0 patch-1
Line 37Line 37
# get one that doesn't return an error code.
$(DOWNLOADDIR)/%:
        @if test -f $(COOKIEDIR)/checksum-$*; then : ; else \
# get one that doesn't return an error code.
$(DOWNLOADDIR)/%:
        @if test -f $(COOKIEDIR)/checksum-$*; then : ; else \
                echo " ==> Grabbing $@"; \
                echo -e " $(WORKCOLOR)==> Grabbing $(BOLD)$@$(NORMALCOLOR)"; \
                for i in $(filter %/$*,$(URLS)); do \
                for i in $(filter %/$*,$(URLS)); do \
                        echo "         ==> Trying $$i"; \
                        echo -e "         $(WORKCOLOR)==> Trying $(BOLD)$$i$(NORMALCOLOR)"; \
                        $(MAKE) -s $$i || continue; \
                        mv $(PARTIALDIR)/$* $@; \
                        break; \
                done; \
                if test -r $@ ; then : ; else \
                        $(MAKE) -s $$i || continue; \
                        mv $(PARTIALDIR)/$* $@; \
                        break; \
                done; \
                if test -r $@ ; then : ; else \
                        echo '*** GAR GAR GAR! Failed to download $@! GAR GAR GAR! ***' 1>&2; \
                        echo -e "$(ERRORCOLOR)*** GAR GAR GAR! Failed to download $@! GAR GAR GAR! ***$(NORMALCOLOR)" 1>&2; \
                        false; \
                fi; \
        fi

# download an http URL (colons omitted)
http//%:
                        false; \
                fi; \
        fi

# download an http URL (colons omitted)
http//%:
        @wget -c -P $(PARTIALDIR) http://$*
        @wget -c -P $(PARTIALDIR) -T 120 -t 3 http://$*
# download an ftp URL (colons omitted)
ftp//%:
# download an ftp URL (colons omitted)
ftp//%:
        @wget -c --passive-ftp -P $(PARTIALDIR) ftp://$*
        @wget -c --passive-ftp -P $(PARTIALDIR) -T 120 -t 3 ftp://$*
# link to a local copy of the file
# (absolute path)
# link to a local copy of the file
# (absolute path)
Line 85Line 85
scp//%:
        @scp -C $* $(PARTIALDIR)/

scp//%:
        @scp -C $* $(PARTIALDIR)/


cvs//%:
        @cvs -d :pserver:$(shell dirname $* | sed 's,/,:/,') login; \
        cd $(PARTIALDIR); \
        cvs -z3 -d :pserver:$(shell dirname $* | sed 's,/,:/,') co $(shell basename $*)


#################### 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)
#################### 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; \
        @echo -e " $(WORKCOLOR)==> Running checksum on $(BOLD)$*$(NORMALCOLOR)"
        @rm -f $(CHECKSUM_FILE).tmp
        @cat $(CHECKSUM_FILE) | sed -e 's~ download/~ $(DOWNLOADDIR)/~' > $(CHECKSUM_FILE).tmp
        @if grep -- '$*' $(CHECKSUM_FILE).tmp; then \
                if LC_ALL="C" LANG="C" md5sum -c $(CHECKSUM_FILE).tmp 2>&1 | grep -- '$*' | grep -v ':[ ]\+OK'; then \
                        echo -e "$(ERRORCOLOR)*** GAR GAR GAR! $* failed checksum test! GAR GAR GAR! ***$(NORMALCOLOR)" 1>&2; \
                        rm -f $(CHECKSUM_FILE).tmp ;\
                        false; \
                else \
                        false; \
                else \
                        echo 'file $* passes checksum test!'; \
                        echo -e "$(SUCCESSCOLOR)file $(BOLD)$* $(SUCCESSCOLOR)passes checksum test!$(NORMALCOLOR)"; \
                        rm -f $(CHECKSUM_FILE).tmp ;\
                        $(MAKECOOKIE); \
                fi \
        else \
                        $(MAKECOOKIE); \
                fi \
        else \
                echo '*** GAR GAR GAR! $* not in $(CHECKSUM_FILE) file! GAR GAR GAR! ***' 1>&2; \
                echo -e "$(ERRORCOLOR)*** GAR GAR GAR! $* not in $(CHECKSUM_FILE) file! GAR GAR GAR! ***$(NORMALCOLOR)" 1>&2; \
                rm -f $(CHECKSUM_FILE).tmp ;\
                false; \
        fi
               
                false; \
        fi
               
Line 111Line 122
# checksummed files

$(GARCHIVEDIR)/%: $(GARCHIVEDIR)
# checksummed files

$(GARCHIVEDIR)/%: $(GARCHIVEDIR)
        cp -Lr $(DOWNLOADDIR)/$* $@
        -cp -Lr $(DOWNLOADDIR)/$* $@
#################### EXTRACT RULES ####################

# rule to extract uncompressed tarballs
tar-extract-%:
#################### EXTRACT RULES ####################

# rule to extract uncompressed tarballs
tar-extract-%:
        @echo " ==> Extracting $(DOWNLOADDIR)/$*"
        @echo -e " $(WORKCOLOR)==> Extracting $(BOLD)$(DOWNLOADDIR)/$*$(NORMALCOLOR)"
        @tar -xf $(DOWNLOADDIR)/$* -C $(EXTRACTDIR)
        @$(MAKECOOKIE)

# rule to extract files with tar xzf
tar-gz-extract-%:
        @tar -xf $(DOWNLOADDIR)/$* -C $(EXTRACTDIR)
        @$(MAKECOOKIE)

# rule to extract files with tar xzf
tar-gz-extract-%:
        @echo " ==> Extracting $(DOWNLOADDIR)/$*"
        @echo -e " $(WORKCOLOR)==> Extracting $(BOLD)$(DOWNLOADDIR)/$*$(NORMALCOLOR)"
        @gzip -dc $(DOWNLOADDIR)/$* | tar -xf - -C $(EXTRACTDIR)
        @$(MAKECOOKIE)

# rule to extract files with tar and bzip
tar-bz-extract-%:
        @gzip -dc $(DOWNLOADDIR)/$* | tar -xf - -C $(EXTRACTDIR)
        @$(MAKECOOKIE)

# rule to extract files with tar and bzip
tar-bz-extract-%:
        @echo " ==> Extracting $(DOWNLOADDIR)/$*"
        @echo -e " $(WORKCOLOR)==> Extracting $(BOLD)$(DOWNLOADDIR)/$*$(NORMALCOLOR)"
        @bzip2 -dc $(DOWNLOADDIR)/$* | tar -xf - -C $(EXTRACTDIR)
        @$(MAKECOOKIE)

# rule to extract files with unzip
zip-extract-%:
        @bzip2 -dc $(DOWNLOADDIR)/$* | tar -xf - -C $(EXTRACTDIR)
        @$(MAKECOOKIE)

# rule to extract files with unzip
zip-extract-%:
        @echo " ==> Extracting $(DOWNLOADDIR)/$*"
        @echo -e " $(WORKCOLOR)==> Extracting $(BOLD)$(DOWNLOADDIR)/$*$(NORMALCOLOR)"
        @unzip $(DOWNLOADDIR)/$* -d $(EXTRACTDIR)
        @$(MAKECOOKIE)

# this is a null extract rule for files which are constant and
# unchanged (not archives)
cp-extract-%:
        @unzip $(DOWNLOADDIR)/$* -d $(EXTRACTDIR)
        @$(MAKECOOKIE)

# this is a null extract rule for files which are constant and
# unchanged (not archives)
cp-extract-%:
        @echo " ==> Copying $(DOWNLOADDIR)/$*"
        @cp $(DOWNLOADDIR)/$* $(WORKDIR)/
        @echo -e " $(WORKCOLOR)==> Copying $(BOLD)$(DOWNLOADDIR)/$*$(NORMALCOLOR)"
        @cp -a $(DOWNLOADDIR)/$* $(WORKDIR)/
        @$(MAKECOOKIE)

#gets the meat of a .deb into $(WORKSRC)
deb-bin-extract-%:
        @$(MAKECOOKIE)

#gets the meat of a .deb into $(WORKSRC)
deb-bin-extract-%:
        @echo " ==> Extracting $(DOWNLOADDIR)/$*"
        @echo -e " $(WORKCOLOR)==> Extracting $(BOLD)$(DOWNLOADDIR)/$*$(NORMALCOLOR)"
        @ar x $(DOWNLOADDIR)/$*
        @rm debian-binary && mv *.tar.gz $(DOWNLOADDIR) && mkdir $(WORKSRC) && tar -xvz -C $(WORKSRC) -f $(DOWNLOADDIR)/data.tar.gz
        @$(MAKECOOKIE)
        @ar x $(DOWNLOADDIR)/$*
        @rm debian-binary && mv *.tar.gz $(DOWNLOADDIR) && mkdir $(WORKSRC) && tar -xvz -C $(WORKSRC) -f $(DOWNLOADDIR)/data.tar.gz
        @$(MAKECOOKIE)
Line 208Line 219
# apply bzipped patches
bz-patch-%:
# apply bzipped patches
bz-patch-%:
        @echo " ==> Applying patch $(DOWNLOADDIR)/$*"
        @echo -e " $(WORKCOLOR)==> Applying patch $(BOLD)$(DOWNLOADDIR)/$*$(NORMALCOLOR)"
        @bzip2 -dc $(DOWNLOADDIR)/$* |$(GARPATCH)
        @$(MAKECOOKIE)

# apply gzipped patches
gz-patch-%:
        @bzip2 -dc $(DOWNLOADDIR)/$* |$(GARPATCH)
        @$(MAKECOOKIE)

# apply gzipped patches
gz-patch-%:
        @echo " ==> Applying patch $(DOWNLOADDIR)/$*"
        @echo -e " $(WORKCOLOR)==> Applying patch $(BOLD)$(DOWNLOADDIR)/$*$(NORMALCOLOR)"
        @gzip -dc $(DOWNLOADDIR)/$* |$(GARPATCH)
        @$(MAKECOOKIE)

# apply normal patches
normal-patch-%:
        @gzip -dc $(DOWNLOADDIR)/$* |$(GARPATCH)
        @$(MAKECOOKIE)

# apply normal patches
normal-patch-%:
        @echo " ==> Applying patch $(DOWNLOADDIR)/$*"
        @echo -e " $(WORKCOLOR)==> Applying patch $(BOLD)$(DOWNLOADDIR)/$*$(NORMALCOLOR)"
        @$(GARPATCH) <$(DOWNLOADDIR)/$*
        @$(MAKECOOKIE)

# This is used by makepatch
%/gar-base.diff:
        @$(GARPATCH) <$(DOWNLOADDIR)/$*
        @$(MAKECOOKIE)

# This is used by makepatch
%/gar-base.diff:
        @echo " ==> Creating patch $@"
        @EXTRACTDIR=$(SCRATCHDIR) COOKIEDIR=$(SCRATCHDIR)-$(COOKIEDIR) $(MAKE) extract
        @echo -e " $(WORKCOLOR)==> Creating patch $(BOLD)$@$(NORMALCOLOR)"
        @$(MAKE) EXTRACTDIR=$(SCRATCHDIR) COOKIEDIR=$(SCRATCHDIR)-$(COOKIEDIR) extract
        @if diff --speed-large-files --minimal -Nru $(SCRATCHDIR) $(WORKDIR) > $@; then \
                rm $@; \
        fi
        @if diff --speed-large-files --minimal -Nru $(SCRATCHDIR) $(WORKDIR) > $@; then \
                rm $@; \
        fi
Line 266Line 277
# configure a package that has an autoconf-style configure
# script.
configure-%/configure:
# configure a package that has an autoconf-style configure
# script.
configure-%/configure:
        @echo " ==> Running configure in $*"
        @echo -e " $(WORKCOLOR)==> Running configure in $(BOLD)$*$(NORMALCOLOR)"
        @cd $* && $(CONFIGURE_ENV) ./configure $(CONFIGURE_ARGS)
        @$(MAKECOOKIE)

        @cd $* && $(CONFIGURE_ENV) ./configure $(CONFIGURE_ARGS)
        @$(MAKECOOKIE)

Line 274Line 285
# FIXME: untested and likely not the right way to handle the
# arguments
configure-%/Imakefile:
# FIXME: untested and likely not the right way to handle the
# arguments
configure-%/Imakefile:
        @echo " ==> Running imake in $*"
        @echo -e " $(WORKCOLOR)==> Running imake in $(BOLD)$*$(NORMALCOLOR)"
        @cd $* && $(CONFIGURE_ENV) imake -DUseInstalled -DBOOTSTRAPCFLAGS="$(CFLAGS)" -I$(DESTDIR)$(includedir)/X11/config $(CONFIGURE_ARGS)
        @$(MAKECOOKIE)

        @cd $* && $(CONFIGURE_ENV) imake -DUseInstalled -DBOOTSTRAPCFLAGS="$(CFLAGS)" -I$(DESTDIR)$(includedir)/X11/config $(CONFIGURE_ARGS)
        @$(MAKECOOKIE)


# configure a package that uses a "config" or "oldconfig" make
# target
configure-%/Makefile:
        @echo -e " $(WORKCOLOR)==> Running make in $(BOLD)$*$(NORMALCOLOR)"
        @$(CONFIGURE_ENV) $(firstword $(MAKE)) $(PARALLELMFLAGS) -C $* $(CONFIGURE_ARGS)
        @$(MAKECOOKIE)

#################### BUILD RULES ####################

# build from a standard gnu-style makefile's default rule.
build-%/Makefile:
#################### BUILD RULES ####################

# build from a standard gnu-style makefile's default rule.
build-%/Makefile:
        @echo " ==> Running make in $*"
        @$(BUILD_ENV) $(MAKE) $(PARALLELMFLAGS) $(foreach TTT,$(BUILD_OVERRIDE_DIRS),$(TTT)="$($(TTT))") -C $* $(BUILD_ARGS)
        @echo -e " $(WORKCOLOR)==> Running make in $(BOLD)$*$(NORMALCOLOR)"
        @$(BUILD_ENV) $(firstword $(MAKE)) $(PARALLELMFLAGS) $(foreach TTT,$(BUILD_OVERRIDE_DIRS),$(TTT)="$($(TTT))") -C $* $(BUILD_ARGS)
        @$(MAKECOOKIE)

build-%/makefile:
        @$(MAKECOOKIE)

build-%/makefile:
        @echo " ==> Running make in $*"
        @$(BUILD_ENV) $(MAKE) $(PARALLELMFLAGS) $(foreach TTT,$(BUILD_OVERRIDE_DIRS),$(TTT)="$($(TTT))") -C $* $(BUILD_ARGS)
        @echo -e " $(WORKCOLOR)==> Running make in $(BOLD)$*$(NORMALCOLOR)"
        @$(BUILD_ENV) $(firstword $(MAKE)) $(PARALLELMFLAGS) $(foreach TTT,$(BUILD_OVERRIDE_DIRS),$(TTT)="$($(TTT))") -C $* $(BUILD_ARGS)
        @$(MAKECOOKIE)

build-%/GNUmakefile:
        @$(MAKECOOKIE)

build-%/GNUmakefile:
        @echo " ==> Running make in $*"
        @$(BUILD_ENV) $(MAKE) $(PARALLELMFLAGS) $(foreach TTT,$(BUILD_OVERRIDE_DIRS),$(TTT)="$($(TTT))") -C $* $(BUILD_ARGS)
        @echo -e " $(WORKCOLOR)==> Running make in $(BOLD)$*$(NORMALCOLOR)"
        @$(BUILD_ENV) $(firstword $(MAKE)) $(PARALLELMFLAGS) $(foreach TTT,$(BUILD_OVERRIDE_DIRS),$(TTT)="$($(TTT))") -C $* $(BUILD_ARGS)
        @$(MAKECOOKIE)

#################### STRIP RULES ####################
        @$(MAKECOOKIE)

#################### STRIP RULES ####################
Line 306Line 324
# This will likely become almost as hairy as the actual
# installation code.
strip-$(MANIFEST_FILE):
# This will likely become almost as hairy as the actual
# installation code.
strip-$(MANIFEST_FILE):
        @echo "Not finished"
        @echo -e "$(ERRORCOLOR)Not finished$(NORMALCOLOR)"
# The Makefile must have a "make strip" rule for this to work.
strip-%/Makefile:
# The Makefile must have a "make strip" rule for this to work.
strip-%/Makefile:
        @echo " ==> Running make strip in $*"
        @$(BUILD_ENV) $(MAKE) -C $* $(BUILD_ARGS) strip
        @echo -e " $(WORKCOLOR)==> Running make strip in $(BOLD)$*$(NORMALCOLOR)"
        @$(BUILD_ENV) $(firstword $(MAKE)) -C $* $(BUILD_ARGS) strip
        @$(MAKECOOKIE)

#################### INSTALL RULES ####################

        @$(MAKECOOKIE)

#################### INSTALL RULES ####################


INSTALL_TARGET ?= install

# just run make install and hope for the best.
install-%/Makefile:
# just run make install and hope for the best.
install-%/Makefile:
        @echo " ==> Running make install in $*"
        @$(INSTALL_ENV) $(MAKE) DESTDIR=$(DESTDIR) $(foreach TTT,$(INSTALL_OVERRIDE_DIRS),$(TTT)="$(DESTDIR)$($(TTT))") -C $* $(INSTALL_ARGS) install
        @echo -e " $(WORKCOLOR)==> Running make install in $(BOLD)$*$(NORMALCOLOR)"
        @$(INSTALL_ENV) $(firstword $(MAKE)) DESTDIR=$(DESTDIR) $(foreach TTT,$(INSTALL_OVERRIDE_DIRS),$(TTT)="$(DESTDIR)$($(TTT))") -C $* $(INSTALL_ARGS) $(INSTALL_TARGET)
        @$(MAKECOOKIE)

install-%/makefile:
        @$(MAKECOOKIE)

install-%/makefile:
        @echo " ==> Running make install in $*"
        @$(INSTALL_ENV) $(MAKE) DESTDIR=$(DESTDIR) $(foreach TTT,$(INSTALL_OVERRIDE_DIRS),$(TTT)="$(DESTDIR)$($(TTT))") -C $* $(INSTALL_ARGS) install
        @echo -e " $(WORKCOLOR)==> Running make install in $(BOLD)$*$(NORMALCOLOR)"
        @$(INSTALL_ENV) $(firstword $(MAKE)) DESTDIR=$(DESTDIR) $(foreach TTT,$(INSTALL_OVERRIDE_DIRS),$(TTT)="$(DESTDIR)$($(TTT))") -C $* $(INSTALL_ARGS) $(INSTALL_TARGET)
        @$(MAKECOOKIE)

install-%/GNUmakefile:
        @$(MAKECOOKIE)

install-%/GNUmakefile:
        @echo " ==> Running make install in $*"
        @$(INSTALL_ENV) $(MAKE) DESTDIR=$(DESTDIR) $(foreach TTT,$(INSTALL_OVERRIDE_DIRS),$(TTT)="$(DESTDIR)$($(TTT))") -C $* $(INSTALL_ARGS) install
        @echo -e " $(WORKCOLOR)==> Running make install in $(BOLD)$*$(NORMALCOLOR)"
        @$(INSTALL_ENV) $(firstword $(MAKE)) DESTDIR=$(DESTDIR) $(foreach TTT,$(INSTALL_OVERRIDE_DIRS),$(TTT)="$(DESTDIR)$($(TTT))") -C $* $(INSTALL_ARGS) $(INSTALL_TARGET)
        @$(MAKECOOKIE)

# LICENSE INSTALLATION
        @$(MAKECOOKIE)

# LICENSE INSTALLATION
Line 353Line 373
Public_Domain_LICENSE_TEXT = $(LICENSEDIR)/public-domain.txt

install-license-%: $($*_LICENSE_TEXT)
Public_Domain_LICENSE_TEXT = $(LICENSEDIR)/public-domain.txt

install-license-%: $($*_LICENSE_TEXT)
        echo " ==> Installing $* license text"
        install -d $(DESTDIR)$(licensedir)/$(GARNAME)/
        install -m 644 $($*_LICENSE_TEXT) $(DESTDIR)$(licensedir)/$(GARNAME)/
        $(MAKECOOKIE)
        @echo -e " $(WORKCOLOR)==> Installing $(BOLD)$* $(WORKCOLOR)license text$(NORMALCOLOR)"
        @install -d $(DESTDIR)$(licensedir)/$(GARNAME)/
        @install -m 644 $($*_LICENSE_TEXT) $(DESTDIR)$(licensedir)/$(GARNAME)/
        @$(MAKECOOKIE)
# pkg-config scripts

install-%-config:
# pkg-config scripts

install-%-config:
        mkdir -p $(STAGINGDIR)/$(GARNAME)
        cp -f $(DESTDIR)$(bindir)/$*-config $(STAGINGDIR)/$(GARNAME)/
        $(MAKECOOKIE)
        @mkdir -p $(STAGINGDIR)/$(GARNAME)
        @cp -f $(DESTDIR)$(bindir)/$*-config $(STAGINGDIR)/$(GARNAME)/
        @$(MAKECOOKIE)
######################################
# Use a manifest file of the format:
######################################
# Use a manifest file of the format:
Line 422Line 442
# FIXME: using -D may not be the right thing to do!
install-$(MANIFEST_FILE):
# FIXME: using -D may not be the right thing to do!
install-$(MANIFEST_FILE):
        @echo " ==> Installing from $(MANIFEST_FILE)"
        @echo -e " $(WORKCOLOR)==> Installing from $(BOLD)$(MANIFEST_FILE)$(NORMALCOLOR)"
        $(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)) ;)
        @$(MAKECOOKIE)

# stanard steps for installing a minit script
install-%.init:
        $(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)) ;)
        @$(MAKECOOKIE)

# stanard steps for installing a minit script
install-%.init:
        @echo " ==> Installing minit script $*"
        @echo -e " $(WORKCOLOR)==> Installing minit script $(BOLD)$*$(NORMALCOLOR)"
        @install -D -m 755 $(WORKDIR)/$*.init $(DESTDIR)$(sysconfdir)/init.d/$*
        @if ! grep "^NOSTOP[ ]=" $(WORKDIR)/$*.init > /dev/null; then \
                install -d $(DESTDIR)$(sysconfdir)/rchalt.d $(DESTDIR)$(sysconfdir)/rcreboot.d ;\
        @install -D -m 755 $(WORKDIR)/$*.init $(DESTDIR)$(sysconfdir)/init.d/$*
        @if ! grep "^NOSTOP[ ]=" $(WORKDIR)/$*.init > /dev/null; then \
                install -d $(DESTDIR)$(sysconfdir)/rchalt.d $(DESTDIR)$(sysconfdir)/rcreboot.d ;\
Line 442Line 462
# These three lines are here to grandfather in all the packages that use
# BUILDDEPS, LIBDEPS and DEPENDS. BUILDDEPS, LIBDEPS, and DEPENDS are not
# obsolete... merely integrated into a more general mechanism
# These three lines are here to grandfather in all the packages that use
# BUILDDEPS, LIBDEPS and DEPENDS. BUILDDEPS, LIBDEPS, and DEPENDS are not
# obsolete... merely integrated into a more general mechanism
IMGDEPS += $(sort $(if $(BUILDDEPS),build,) $(if $(strip $(DEPENDS) $(LIBDEPS)),$(DESTIMG),))
$(DESTIMG)_DEPENDS += $(LIBDEPS) $(DEPENDS)
$(DESTIMG)_DEPENDS += $(addprefix lang/,$(filter-out none,$(SOURCE_LANGUAGES))) $(LIBDEPS) $(DEPENDS)
IMGDEPS += $(sort $(if $(BUILDDEPS),build,) $(if $(strip $($(DESTIMG)_DEPENDS)),$(DESTIMG),))
build_DEPENDS += $(BUILDDEPS)

# 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.

build_DEPENDS += $(BUILDDEPS)

# 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.

$(GARDIR)/%/$(COOKIEROOTDIR)/$(DESTIMG).d/install:
        @echo ' ==> Building $* as a dependency'
        @$(MAKE) -C $(GARDIR)/$* install DESTIMG=$(DESTIMG)
$(GARDIR)/%/$(COOKIEROOTDIR)/$(__DESTIMG).d/install:
        @echo -e " $(WORKCOLOR)==> Building $(BOLD)$* $(WORKCOLOR)as a dependency$(NORMALCOLOR)"
        @$(MAKE) -C $(GARDIR)/$* install DESTIMG=$(__DESTIMG)
# builddeps need to have everything put in the build DESTIMG
#$(GARDIR)/%/$(COOKIEROOTDIR)/build.d/install:
# builddeps need to have everything put in the build DESTIMG
#$(GARDIR)/%/$(COOKIEROOTDIR)/build.d/install:
Line 463Line 483
# XXX: nobody uses this, but it should really be more like
# $(GARDIR)/%/cookies/patch:
srcdep-$(GARDIR)/%:
# XXX: nobody uses this, but it should really be more like
# $(GARDIR)/%/cookies/patch:
srcdep-$(GARDIR)/%:
        @echo ' ==> Grabbing source for $* as a dependency'
        @echo -e " $(WORKCOLOR)==> Grabbing source for $(BOLD)$* $(WORKCOLOR)as a dependency$(NORMALCOLOR)"
        @$(MAKE) -C $(GARDIR)/$* patch-p extract-p > /dev/null 2>&1 || \
        $(MAKE) -C $(GARDIR)/$* patch

        @$(MAKE) -C $(GARDIR)/$* patch-p extract-p > /dev/null 2>&1 || \
        $(MAKE) -C $(GARDIR)/$* patch

Line 471Line 491
# images other than the current package's DESTIMG.
IMGDEP_TARGETS = $(foreach TTT,$(filter-out $($*_NODEPEND),$($*_DEPENDS)),$(subst xyzzy,$(TTT),$(GARDIR)/xyzzy/$(COOKIEROOTDIR)/$*.d/install))
imgdep-%:
# images other than the current package's DESTIMG.
IMGDEP_TARGETS = $(foreach TTT,$(filter-out $($*_NODEPEND),$($*_DEPENDS)),$(subst xyzzy,$(TTT),$(GARDIR)/xyzzy/$(COOKIEROOTDIR)/$*.d/install))
imgdep-%:
        @$(if $(IMGDEP_TARGETS),$(MAKE) DESTIMG="$*" $(IMGDEP_TARGETS),true)
        @$(if $(IMGDEP_TARGETS),$(MAKE) __DESTIMG="$*" $(IMGDEP_TARGETS),true)
        @$(MAKECOOKIE)

# SOURCEPKG
        @$(MAKECOOKIE)

# SOURCEPKG
Line 479Line 499
# source for the specified package into the current packages $(WORKDIR)

$(COOKIEDIR)/sourcepkg-%/patch:
# source for the specified package into the current packages $(WORKDIR)

$(COOKIEDIR)/sourcepkg-%/patch:
        $(MAKE) -C $(GARDIR)/$* DESTIMG="$(DESTIMG)" EXTRACTDIR="$(CURDIR)/$(EXTRACTDIR)" WORKDIR="$(CURDIR)/$(WORKDIR)" COOKIEDIR="$(CURDIR)/$(COOKIEDIR)/sourcepkg-$*" patch
        @$(MAKE) -C $(GARDIR)/$* DESTIMG="$(DESTIMG)" DOWNLOADDIR="$(GARDIR)/$(CATEGORIES)/$(GARNAME)/$(DOWNLOADDIR)" EXTRACTDIR="$(GARDIR)/$(CATEGORIES)/$(GARNAME)/$(EXTRACTDIR)" WORKDIR="$(GARDIR)/$(CATEGORIES)/$(GARNAME)/$(WORKDIR)" COOKIEDIR="$(GARDIR)/$(CATEGORIES)/$(GARNAME)/$(COOKIEDIR)/sourcepkg-$*" patch
# Igor's info and man gzipper rule
gzip-info-man: gzip-info gzip-man
# Igor's info and man gzipper rule
gzip-info-man: gzip-info gzip-man
Line 531Line 551
prune-language-modules:
        # XXX: TODO for Perl and Ruby
        # XXX: also remove some modules which users are unlikely to need
prune-language-modules:
        # XXX: TODO for Perl and Ruby
        # XXX: also remove some modules which users are unlikely to need
        echo Deleting compiled Python modules...
        @echo -e "$(WORKCOLOR)Deleting compiled Python modules...$(NORMALCOLOR)"
        [ ! -d $(WORKSRC)/lib/python2.2 ] || find $(WORKSRC)/lib/python2.2 -name '*.py[co]' -exec rm -f '{}' ';'
        [ ! -d $(WORKSRC)/lib/python2.2 ] || find $(WORKSRC)/lib/python2.2 -name '*.py[co]' -exec rm -f '{}' ';'
        echo Removing Python config directory...
        @echo -e "$(WORKCOLOR)Removing Python config directory...$(NORMALCOLOR)"
        rm -rf $(WORKSRC)/lib/python2.2/config
        rm -rf $(WORKSRC)/lib/python2.2/config
        echo Deleting Perl documentation...
        @echo -e "$(WORKCOLOR)Deleting Perl documentation...$(NORMALCOLOR)"
        [ ! -d $(WORKSRC)/lib/perl5 ] || find $(WORKSRC)/lib/perl5 -name '*.pod' -exec rm -f '{}' ';'
        [ ! -d $(WORKSRC)/lib/perl5 ] || find $(WORKSRC)/lib/perl5 -name '*.pod' -exec rm -f '{}' ';'
        echo Deleting Perl unicore...
        @echo -e "$(WORKCOLOR)Deleting Perl unicore...$(NORMALCOLOR)"
#        [ ! -d $(WORKSRC)/lib/perl5 ] || find $(WORKSRC)/lib/perl5 -type d -name unicore -exec rm -rf '{}' ';'
        [ ! -d $(WORKSRC)/lib/perl5/5.8.0/unicore ] || rm -rf $(WORKSRC)/lib/perl5/5.8.0/unicore
        $(MAKECOOKIE)

prune-xemacs:
#        [ ! -d $(WORKSRC)/lib/perl5 ] || find $(WORKSRC)/lib/perl5 -type d -name unicore -exec rm -rf '{}' ';'
        [ ! -d $(WORKSRC)/lib/perl5/5.8.0/unicore ] || rm -rf $(WORKSRC)/lib/perl5/5.8.0/unicore
        $(MAKECOOKIE)

prune-xemacs:
        echo Pruning XEmacs distribution...
        @echo -e "$(WORKCOLOR)Pruning XEmacs distribution...$(NORMALCOLOR)"
        [ ! -d $(WORKSRC)$(libdir)/xemacs-21.4.9/etc/photos ] || rm -rf $(WORKSRC)$(libdir)/xemacs-21.4.9/etc/photos
        [ ! -d $(WORKSRC)$(libdir)/xemacs-21.4.9/info ] || rm -rf $(WORKSRC)$(libdir)/xemacs-21.4.9/info
        [ ! -d $(WORKSRC)$(libdir)/xemacs-21.4.9/lisp ] || (for f in $$(find $(WORKSRC)$(libdir)/xemacs-21.4.9/lisp -name "*.el" -or -name "*.elc" | sed "s/elc/el/g" | sort | uniq -d); do rm -rf $$f; done)
        [ ! -d $(WORKSRC)$(libdir)/xemacs-21.4.9/etc/photos ] || rm -rf $(WORKSRC)$(libdir)/xemacs-21.4.9/etc/photos
        [ ! -d $(WORKSRC)$(libdir)/xemacs-21.4.9/info ] || rm -rf $(WORKSRC)$(libdir)/xemacs-21.4.9/info
        [ ! -d $(WORKSRC)$(libdir)/xemacs-21.4.9/lisp ] || (for f in $$(find $(WORKSRC)$(libdir)/xemacs-21.4.9/lisp -name "*.el" -or -name "*.elc" | sed "s/elc/el/g" | sort | uniq -d); do rm -rf $$f; done)
Line 553Line 573
        $(MAKECOOKIE)

prune-xemacs-packages: prune-xemacs
        $(MAKECOOKIE)

prune-xemacs-packages: prune-xemacs
        echo Pruning XEmacs packages...
        @echo -e "$(WORKCOLOR)Pruning XEmacs packages...$(NORMALCOLOR)"
        [ ! -d $(WORKSRC)$(libdir)/xemacs/xemacs-packages/lisp ] || (for f in $$(find $(WORKSRC)$(libdir)/xemacs/xemacs-packages/lisp -name "*.el" -or -name "*.elc" | sed "s/elc/el/g" | sort | uniq -d); do rm -rf $$f; done)
        [ ! -d $(WORKSRC)$(libdir)/xemacs/xemacs-packages/info ] || rm -rf $(WORKSRC)$(libdir)/xemacs/xemacs-packages/info
        [ ! -d $(WORKSRC)$(libdir)/xemacs/xemacs-packages/man ] || rm -rf $(WORKSRC)$(libdir)/xemacs/xemacs-packages/man
        [ ! -d $(WORKSRC)$(libdir)/xemacs/xemacs-packages/lisp ] || (for f in $$(find $(WORKSRC)$(libdir)/xemacs/xemacs-packages/lisp -name "*.el" -or -name "*.elc" | sed "s/elc/el/g" | sort | uniq -d); do rm -rf $$f; done)
        [ ! -d $(WORKSRC)$(libdir)/xemacs/xemacs-packages/info ] || rm -rf $(WORKSRC)$(libdir)/xemacs/xemacs-packages/info
        [ ! -d $(WORKSRC)$(libdir)/xemacs/xemacs-packages/man ] || rm -rf $(WORKSRC)$(libdir)/xemacs/xemacs-packages/man
Line 629Line 649
        # some hard links didn't seem to survive
        cd $(WORKSRC)$(bindir) && ln -sf python2.2 python
        cd $(WORKSRC)$(bindir) && ln -sf perl5.8.0 perl
        # some hard links didn't seem to survive
        cd $(WORKSRC)$(bindir) && ln -sf python2.2 python
        cd $(WORKSRC)$(bindir) && ln -sf perl5.8.0 perl
        cd $(WORKSRC)$(bindir) && ln -sf gawk-3.1.0 gawk

        cd $(WORKSRC)$(bindir) && ln -sf mkisofs mkhybrid
        $(MAKECOOKIE)

        cd $(WORKSRC)$(bindir) && ln -sf mkisofs mkhybrid
        $(MAKECOOKIE)

Line 637Line 656
# Wholesale deletion of various include directories
# XXX: Is there any reason to list /usr/*?
# Wholesale deletion of various include directories
# XXX: Is there any reason to list /usr/*?
prune-headers: $(addprefix prune-delete-$(WORKSRC),$(includedir) /usr/X11R6/include /usr/share/keymaps/include/usr/share/keymaps/i386/include /usr/share/keymaps/mac/include $(libdir)/glib)
prune-headers: $(addprefix prune-delete-$(WORKSRC),$(includedir) /usr/X11R6/include /usr/share/keymaps/include /usr/share/keymaps/i386/include /usr/share/keymaps/mac/include $(libdir)/glib)
        $(MAKECOOKIE)

# Wholesale deletion of $(sourcedir)
        $(MAKECOOKIE)

# Wholesale deletion of $(sourcedir)
Line 656Line 675
        rm -f $(WORKSRC)/usr/lib/*.a
        rm -f $(WORKSRC)/usr/X11R6/lib/*.a
        rm -f $(WORKSRC)/usr/local/lib/*.a
        rm -f $(WORKSRC)/usr/lib/*.a
        rm -f $(WORKSRC)/usr/X11R6/lib/*.a
        rm -f $(WORKSRC)/usr/local/lib/*.a
        echo NOT deleting all other static library archives.
        echo Remaining static libraries in DESTDIR are currently
        @echo "$(WORKCOLOR)NOT deleting all other static library archives."
        @echo "Remaining static libraries in DESTDIR are currently$(BOLD)"
        find $(WORKSRC) -name '*.a' -print
        find $(WORKSRC) -name '*.a' -print

        @echo -e "$(NORMALCOLOR)"
        $(MAKECOOKIE)

prune-superfluous-binaries:
        $(MAKECOOKIE)

prune-superfluous-binaries: