#!/bin/sh #! -*- perl -*- eval 'exec perl -x -S $0 ${1+"$@"}' if 0; use strict; use warnings; use File::Basename; my %target; die "no bootstrap.conf in current working directory\n" unless -f "bootstrap.conf"; # Read configuration open(my $fh, '<', 'bootstrap.conf') or die "can't open bootstrap.conf: $!\n"; my $i = 0; while (<$fh>) { chomp; s/^\s+//; s/#.*$//; next if /^$/ ; my ($treeish, $subdir) = split /\s+/; if (!$subdir) { $subdir = basename($treeish); } if ($subdir ne "master") { unless (-d "gdbm/$subdir") { system("git -C gdbm clone -b $treeish ./master $subdir"); } } system("(cd gdbm/$subdir; ./bootstrap)"); unless (-d "src/$subdir") { mkdir "src/$subdir" } my $makefile = "src/$subdir/Makefile.am"; unless (-f $makefile) { open(my $of, '>', $makefile) or die "can't open $makefile for writing: $!\n"; print $of < $i, treeish => $treeish }; ++$i; } close($fh); # # Creating directories # unless (-d 'm4') { mkdir 'm4' } unless (-d 'gdbm') { mkdir 'gdbm' } system("git submodule init"); system("git submodule update"); # # Creating bootstrap.mk # my @k = sort { $target{$a}{order} <=> $target{$b}{order}} keys %target; my $gdbm_subdirs = join(' ', map { "gdbm/$_" } @k); open($fh, '>', 'bootstrap.mk') or die "can't open bootstrap.mk: $!\n"; print $fh "AC_SUBST([USER_SUBDIRS],['$gdbm_subdirs'])\n"; print $fh "AC_SUBST([USER_TARGETS],['" . join(' ', @k) . "'])\n"; print $fh "AC_CONFIG_SUBDIRS([$gdbm_subdirs])\n"; print $fh "AC_CONFIG_FILES([" . join(' ', map { "src/$_/Makefile" } @k) . "])\n"; close $fh;