in reply to Installing a group of .tar.gz format perl modules

This works for me in a linux/bsd environment:
I have a vendor directory which holds all the tar.gz's from cpan, and a makefile
Makefile:
PWD = $(shell pwd) CACHE_DIR ?= cache PERL = $(shell which perl) BUILD_INCS = -I $(PWD)/$(CACHE_DIR)/lib/perl5 INSTALL_TARGET ?= $(PWD)/$(CACHE_DIR) MAKEFILE_PL_ARGS = INSTALL_BASE=$(INSTALL_TARGET) PERL="$(PERL) $(BUIL +D_INCS)" TGZFILES = $(wildcard *.tar.gz) DEPENDS_ORDER2 = $(shell cat install_order) $(TGZFILES) # remove duplicates DEPENDS_ORDER = $(shell perl -e '@b=grep{!$$s{$$_}++} @ARGV;print "@b" +' $(DEPENDS_ORDER2)) # this gets a list of all the directories that the .tar.gz files unpac +k into UNPACK_DIRS = $(shell for t in $(DEPENDS_ORDER);do for f in `tar tzf $ +$t`;do R="$$R $$f/";break;done;done;echo $$R) BLIBS = $(patsubst %/,%/blib,$(UNPACK_DIRS)) # we want to link to gmake here, unless it is not available GMAKE = $(firstword $(shell which gmake) $(shell which $(MAKE)) ) PATH = $(PWD)/bin:$(shell echo $$PATH) .PHONY: all clean install $(TGZFILES) all: @ echo ------------------------------------------- @ echo "TGZFILES: $(TGZFILES)" @ echo ------------------------------------------- @ echo "DEPENDS_ORDER: $(DEPENDS_ORDER)" @ echo ------------------------------------------- @ echo "UNPACK_DIRS: $(UNPACK_DIRS)" @ echo ------------------------------------------- @ echo "BLIBS: $(BLIBS)" @ echo ------------------------------------------- @ echo "BUILD_INCS: $(BUILD_INCS)" @ echo ------------------------------------------- $(UNPACK_DIRS): @ echo unpacking $@ @ echo -n " " tar xfz $(@).tar.gz @ for patch_file in patches/*.$(@).tar.gz.*.patch; do \ if [ ! -e $$patch_file ]; then \ echo " No patches found for $(@).tar.gz"; \ continue; \ fi; \ echo " Running patch $$patch_file: "; \ patch -p1 < $$patch_file; \ done; @ echo " Making makefile $@ in $@"; @ cd $@ && TipTop=1 PERL_MM_USE_DEFAULT=1 perl $(BUILD_INCS) Makef +ile.PL $(MAKEFILE_PL_ARGS) >> build.log; @ echo " Making blib $@ in $@"; @ $(MAKE) -C $@ all >>build.log # ARCH=1 is to override BSDPAN (hateful software) @ echo " Installing $(@) into $(INSTALL_TARGET)" @ $(MAKE) -C $@ pure_install ARCH=1 >> build.log # force the use of gmake by putting it first in the path ENV: rm -rf bin/make ln -sf $(GMAKE) bin/make $(CACHE_DIR): ENV $(UNPACK_DIRS) install: $(CACHE_DIR) @ echo "Copying $(CACHE_DIR) to $(TARGET)"; mkdir -p $(TARGET)/ cp -Rf $(CACHE_DIR)/lib/perl5/* $(TARGET)/ @ touch $(CACHE_DIR) clean: rm -rf $(UNPACK_DIRS) rm -rf $(CACHE_DIR) rm -f ./build.log
I can pretty much just add modules to the vendor directory and it picks it up.

Some modules depend on others so there is an 'install_order' file that lists the order those modules should be installed.

I also have a patches directory in case I need to patch the cpan modules before they get built.

I call this from my main makefile like this:
$(MAKE) -C $(VENDOR_DIR) install TARGET=$(LOCAL_BUILD_TARGET)/lib/

Replies are listed 'Best First'.
Re^2: Installing a group of .tar.gz format perl modules
by duncs (Beadle) on Jun 21, 2007 at 10:05 UTC
    Thanks very much - this looks fantastic. I'll try it out and let you know how I get on.