makedir.SH Precursor to makedir
Makefile.micro microperl Makefile
Makefile.SH A script that generates Makefile
-make_patchnum.com DCL script to generate .patchnum file on VMS (should be rewritten to create git_version.h)
-make_patchnum.sh Script to generate git_version.h and lib/Config_git.pl files
-make_patchnum.pl Script to generate git_Version.h and lib/Config_git.pl files for all OS'es (experimental)
+make_patchnum.com DCL script to generate .patchnum file on VMS (should be replaced by make_patchnum.pl)
+make_patchnum.pl Script to generate git_Version.h and lib/Config_git.pl files for all OS'es
malloc.c A version of malloc you might not want
malloc_ctl.h A version of malloc you might not want
MANIFEST This list of files
## In the following dollars and backticks do not need the extra backslash.
$spitshell >>$Makefile <<'!NO!SUBS!'
-private = preplibrary $(CONFIGPM) $(CONFIGPOD) lib/ExtUtils/Miniperl.pm
+private = preplibrary $(CONFIGPM) $(CONFIGPOD) make_patchnum lib/ExtUtils/Miniperl.pm
# Files to be built with variable substitution before miniperl
# is available.
.c.s:
$(CCCMDSRC) -S $*.c
-all: $(FIRSTMAKEFILE) miniperl$(EXE_EXT) miniperl make_patchnum extra.pods $(private) $(unidatafiles) $(public) $(dynamic_ext) $(nonxs_ext) extras.make
+all: $(FIRSTMAKEFILE) miniperl$(EXE_EXT) miniperl extra.pods $(private) $(unidatafiles) $(public) $(dynamic_ext) $(nonxs_ext) extras.make
@echo " ";
@echo " Everything is up to date. Type '$(MAKE) test' to run test suite."
.PHONY: all translators utilities make_patchnum
make_patchnum:
- sh $(shellflags) make_patchnum.sh || $(MAKE) miniperl
-
+ $(LDLIBPTH) $(RUN) ./miniperl -Ilib make_patchnum.pl || $(MAKE) miniperl
git_version.h: stock_git_version.h
cp stock_git_version.h git_version.h
test_prep_pre: preplibrary utilities $(nonxs_ext)
-test_prep: make_patchnum test_prep_pre miniperl$(EXE_EXT) $(unidatafiles) perl$(EXE_EXT) $(dynamic_ext) $(TEST_PERL_DLL)
+test_prep: test_prep_pre miniperl$(EXE_EXT) $(unidatafiles) perl$(EXE_EXT) $(dynamic_ext) $(TEST_PERL_DLL)
PERL=./perl $(MAKE) _test_prep
_test_tty:
sub backtick {
my $command = shift;
- my $result = `$command`;
- chomp $result;
- return $result;
+ if (wantarray) {
+ my @result= `$command`;
+ chomp @result;
+ return @result;
+ } else {
+ my $result= `$command`;
+ $result="" if ! defined $result;
+ chomp $result;
+ return $result;
+ }
}
-my $existing_patchnum = read_file('.patchnum');
-my $existing_config = read_file('lib/Config_git.pl');
-my $existing_unpushed = read_file('unpushed.h');
+sub write_files {
+ my %content= map { /WARNING: '([^']+)'/ || die "Bad mojo!"; $1 => $_ } @_;
+ my @files= sort keys %content;
+ my $files= join " and ", map { "'$_'" } @files;
+ foreach my $file (@files) {
+ if (read_file($file) ne $content{$file}) {
+ print "Updating $files\n";
+ write_file($_,$content{$_}) for @files;
+ return 1;
+ }
+ }
+ print "Reusing $files\n";
+ return 0;
+}
my $unpushed_commits = '/*no-op*/';
-my ($read, $branch, $snapshot_created, $commit_id, $describe);
-my ($changed, $extra_info, $commit_title, $new_patchnum);
-if (my $patch_file= read_file('.patch')) {
- ($branch, $snapshot_created, $commit_id, $describe) = split /\s+/, $patchfile;
+my ($read, $branch, $snapshot_created, $commit_id, $describe)= ("") x 5;
+my ($changed, $extra_info, $commit_title, $new_patchnum, $status)= ("") x 5;
+if (my $patch_file= read_file(".patch")) {
+ ($branch, $snapshot_created, $commit_id, $describe) = split /\s+/, $patch_file;
$extra_info = "git_snapshot_date='$snapshot_created'";
$commit_title = "Snapshot of:";
}
elsif (-d path_to('.git')) {
# git branch | awk 'BEGIN{ORS=""} /\*/ { print $2 }'
- $branch = join "", map { (split /\s/, $_)[1] }
- grep {/\*/} split /\n/, backtick('git branch');
- my $remote;
+ ($branch) = map { /\* ([^(]\S*)/ ? $1 : () } backtick('git branch');
+ my ($remote,$merge);
if (length $branch) {
- $remote = backtick("git config branch.$branch.remote");
+ $merge= backtick("git config branch.$branch.merge");
+ $merge =~ s!^refs/heads/!!;
+ $remote= backtick("git config branch.$branch.remote");
}
$commit_id = backtick("git rev-parse HEAD");
$describe = backtick("git describe");
# git cherry $remote/$branch | awk 'BEGIN{ORS=","} /\+/ {print $2}' | sed -e 's/,$//'
my $unpushed_commit_list =
join ",", map { (split /\s/, $_)[1] }
- grep {/\+/} split /\n/, backtick("git cherry $remote/$branch");
+ grep {/\+/} backtick("git cherry $remote/$merge");
# git cherry $remote/$branch | awk 'BEGIN{ORS="\t\\\\\n"} /\+/ {print ",\"" $2 "\""}'
$unpushed_commits =
- join "", map { ',"'.(split /\s/, $_)[1].'"'."\t\\\n" }
- grep {/\+/} split /\n/, backtick("git cherry $remote/$branch");
+ join "", map { ',"'.(split /\s/, $_)[1]."\"\t\\\n" }
+ grep {/\+/} backtick("git cherry $remote/$merge");
if (length $unpushed_commits) {
$commit_title = "Local Commit:";
- my $ancestor = backtick("git rev-parse $remote/$branch");
+ my $ancestor = backtick("git rev-parse $remote/$merge");
$extra_info = "$extra_info
git_ancestor='$ancestor'
+git_remote_branch='$remote/$merge'
git_unpushed='$unpushed_commit_list'";
}
}
- if (length $changed) {
+ if ($changed) {
$changed = 'true';
$commit_title = "Derived from:";
- $new_patchnum = "$new_patchnum
-status: uncommitted-changes";
- }
- if (not length $commit_title) {
- $commit_title = "Commit id:";
+ $status='"uncommitted-changes"'
+ } else {
+ $status='/*clean-working-directory*/'
}
+ $commit_title ||= "Commit id:";
}
-my $new_unpushed =<<"EOFTEXT";
-/*********************************************************************
-* WARNING: unpushed.h is automatically generated by make_patchnum.pl *
-* DO NOT EDIT DIRECTLY - edit make_patchnum.pl instead *
-*********************************************************************/
-#define PERL_GIT_UNPUSHED_COMMITS $unpushed_commits
-/*leave-this-comment*/
-EOFTEXT
-
-my $new_config =<<"EOFDATA";
-#################################################################
-# WARNING: lib/Config_git.pl is generated by make_patchnum.pl #
-# DO NOT EDIT DIRECTLY - edit make_patchnum.pl instead #
-#################################################################
+# we extract the filename out of the warning header, so dont mess with that
+exit(write_files(<<"EOF_HEADER", <<"EOF_CONFIG"));
+/**************************************************************************
+* WARNING: 'git_version.h' is automatically generated by make_patchnum.pl
+* DO NOT EDIT DIRECTLY - edit make_patchnum.pl instead
+***************************************************************************/
+#define PERL_GIT_UNCOMMITTED_CHANGES $status
+#define PERL_PATCHNUM "$describe"
+#define PERL_GIT_UNPUSHED_COMMITS\t\t\\
+$unpushed_commits/*leave-this-comment*/
+EOF_HEADER
+######################################################################
+# WARNING: 'lib/Config_git.pl' is generated by make_patchnum.pl
+# DO NOT EDIT DIRECTLY - edit make_patchnum.pl instead
+######################################################################
\$Config::Git_Data=<<'ENDOFGIT';
git_commit_id='$commit_id'
git_describe='$describe'
git_commit_id_title='$commit_title'
$extra_info
ENDOFGIT
-EOFDATA
-
-# only update the files if necessary, other build product depends on these files
-if (( $existing_patchnum ne $new_patchnum ) || ( $existing_config ne $new_config ) || ( $existing_unpushed ne $new_unpushed )) {
- print "Updating .patchnum and lib/Config_git.pl\n";
- write_file('.patchnum', $new_patchnum);
- write_file('lib/Config_git.pl', $new_config);
- write_file('unpushed.h', $new_unpushed);
-}
-else {
- print "Reusing .patchnum and lib/Config_git.pl\n"
-}
-
+EOF_CONFIG
# ex: set ts=4 sts=4 et ft=perl:
+++ /dev/null
-#!/bin/sh
-
-# this script is used to regenerate a number of special build files
-# based on either information contained in a file called .patch or
-# directly from git.
-# The files involved are:
-# .patchnum # information about the current checkout
-# lib/Config_git.pl # holds some special configure settings related to git
-# unpushed.h # header file used by patchlevel.h to store unpushed commits
-
-config_file="lib/Config_git.pl"
-header_file="git_version.h"
-patch_file=".patch"
-
-git_dir=`git rev-parse --git-dir 2>/dev/null`
-existing_config=`cat $config_file 2>/dev/null`
-existing_header=`cat $header_file 2>/dev/null`
-
-unpushed_commits='/*no-op*/'
-if [ -s $patch_file ] ; then
- # this is the minimal expectation for the
- read branch snapshot_created commit_id describe < .patch
- changed=""
- extra_info="git_snapshot_date='$snapshot_created'"
- commit_title='Snapshot of:'
-elif [ -n "$git_dir" ]; then
- branch=`git branch | awk 'BEGIN{ORS=""} /^\* [^(]/ { print $2 }'`
- test -n "$branch" && remote=`git config branch.$branch.remote`
- test -n "$branch" && merge=`git config branch.$branch.merge | sed s,refs/heads/,,`
- commit_id=`git rev-parse HEAD`
- changed=`git diff-index --name-only HEAD`
- describe=`git describe --tags`
- commit_created=`git log -1 --pretty='format:%ci'`
- extra_info="git_commit_date='$commit_created'"
- if [ -n "$merge" ] && [ -n "$remote" ]; then
- unpushed_commit_list=`git cherry $remote/$merge | awk 'BEGIN{ORS=","} /\+/ {print $2}' | sed -e 's/,$//'`
- unpushed_commits=`git cherry $remote/$merge | awk 'BEGIN{ORS="\t\\\\\n"} /\+/ {print ",\"" $2 "\""}'`
-
- if [ -n "$unpushed_commits" ]; then
- commit_title="Local Commit:"
- ancestor=`git rev-parse $remote/$merge`
- extra_info="$extra_info
-git_ancestor='$ancestor'
-git_remote_branch='$remote/$merge'
-git_unpushed='$unpushed_commit_list'"
- fi
-
- fi
-else
- cat <<SNDOGS
-Something is wrong with your source tree. You should
-either have a .git directory and a functional git toolset
-OR should have a .patch file in the source tree. Please
-report the particulars of this situation to
-perl5-porters@perl.org.
-SNDOGS
- exit 2
-fi
-
-# Set up defaults for various values
-if [ -n "$changed" ]; then
- changed="true"
- commit_title="Derived from:"
- status="#define PERL_GIT_UNCOMMITTED_CHANGES uncommitted-changes"
-else
- status="/* clean working directory */"
-fi
-test -z "$commit_title" && commit_title='Commit id:'
-
-new_header=`cat <<EOFTEXT
-/***************************************************************************
-* WARNING: $header_file is automatically generated by make_patchnum.sh
-* DO NOT EDIT DIRECTLY - edit make_patchnum.sh instead
-****************************************************************************/
-#define PERL_PATCHNUM $describe
-$status
-#define PERL_GIT_UNPUSHED_COMMITS $unpushed_commits
-/*leave-this-comment*/
-EOFTEXT
-`
-new_config=`cat <<EOFDATA
-#######################################################################
-# WARNING: $config_file is generated by make_patchnum.sh
-# DO NOT EDIT DIRECTLY - edit make_patchnum.sh instead
-#######################################################################
-\\$Config::Git_Data=<<'ENDOFGIT';
-git_commit_id='$commit_id'
-git_describe='$describe'
-git_branch='$branch'
-git_uncommitted_changes='$changed'
-git_commit_id_title='$commit_title'
-$extra_info
-ENDOFGIT
-EOFDATA
-`
-# only update the files if necessary, other build product depends on these files
-if [ "$new_config" != "$existing_config" ] || [ "$existing_header" != "$new_header" ]; then
- echo "Updating $header_file and $config_file"
- echo "$new_config" > $config_file
- echo "$new_header" > $header_file
- exit 1
-else
- echo "Reusing $header_file and $config_file"
-fi
-
#if !defined(PERL_PATCHLEVEL_H_IMPLICIT) && !defined(LOCAL_PATCH_COUNT)
#include "git_version.h"
-#if !defined(PERL_GIT_UNPUSHED_COMMITS)
-#define PERL_GIT_UNPUSHED_COMMITS_PATCH /* no-op */
-#else
-#define PERL_GIT_UNPUSHED_COMMITS_PATCH PERL_GIT_UNPUSHED_COMMITS
-#endif
-#if !defined(PERL_GIT_UNCOMMITTED_CHANGES)
-#define PERL_GIT_UNCOMMITTED_CHANGES_PATCH /*no op*/
-#else
-#define PERL_GIT_UNCOMMITTED_CHANGES_PATCH , STRINGIFY(PERL_GIT_UNCOMMITTED_CHANGES)
-#endif
static const char * const local_patches[] = {
NULL
- PERL_GIT_UNPUSHED_COMMITS_PATCH /* do not remove this line */
- PERL_GIT_UNCOMMITTED_CHANGES_PATCH /* do not remove this line */
+ PERL_GIT_UNPUSHED_COMMITS /* do not remove this line */
+ PERL_GIT_UNCOMMITTED_CHANGES /* do not remove this line */
,NULL
};
* DO NOT EDIT DIRECTLY - edit make_patchnum.sh instead
****************************************************************************/
#define PERL_PATCHNUM UNKOWN
-#define PERL_GIT_UNCOMMITTED_CHANGES UNKNOWN
+#define PERL_GIT_UNCOMMITTED_CHANGES ,"UNKNOWN"
#define PERL_GIT_UNPUSHED_COMMITS /*leave-this-comment*/