aboutsummaryrefslogtreecommitdiff
path: root/bootstrap
blob: 723788f35eb3e099a5e8a047793bd6eac8c22623 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/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 <<EOT;
noinst_PROGRAMS=fetchkeys
fetchkeys_SOURCES=fetchkeys.c
VPATH=\$(top_srcdir)/src
LDADD=../../gdbm/$subdir/src/.libs/libgdbm.a
AM_CPPFLAGS=-DSIZEOF_OFF_T=8 -I\$(top_srcdir)/gdbm/$subdir/src/
EOT
	;
        close $of;
    } 
    $target{$subdir} = {
	order => $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;

Return to:

Send suggestions and report system problems to the System administrator.