.c.s:
$(CCCMDSRC) -S $*.c
-all: $(FIRSTMAKEFILE) make_patchnum miniperl$(EXE_EXT) extra.pods $(private) $(unidatafiles) $(public) $(dynamic_ext) $(nonxs_ext) extras.make
+all: $(FIRSTMAKEFILE) make_patchnum 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."
make_patchnum:
sh $(shellflags) make_patchnum.sh
-# make sure that we recompile perl.c if .patchnum changes
-perl$(OBJ_EXT): .patchnum unpushed.h
+git_version.h:
+ sh $(shellflags) make_patchnum.sh
+
+# make sure that we recompile perl.c if the git version changes
+perl$(OBJ_EXT): git_version.h
translators: miniperl$(EXE_EXT) $(CONFIGPM) FORCE
@echo " "; echo " Making x2p stuff"; cd x2p; $(LDLIBPTH) $(MAKE) all
-cd pod; $(LDLIBPTH) $(MAKE) clean
-cd utils; $(LDLIBPTH) $(MAKE) clean
-cd x2p; $(LDLIBPTH) $(MAKE) clean
- -rm .patchnum
-rm lib/Config_git.pl
- -rm unpushed.h
+ -rm git_version.h
-@for x in $(DYNALOADER) $(dynamic_ext) $(static_ext) $(nonxs_ext) ; do \
$(LDLIBPTH) sh ext/util/make_ext clean $$x MAKE=$(MAKE) ; \
done
# lib/Config_git.pl # holds some special configure settings related to git
# unpushed.h # header file used by patchlevel.h to store unpushed commits
-existing_patchnum=`cat .patchnum 2>/dev/null`
-existing_config=`cat lib/Config_git.pl 2>/dev/null`
-existing_unpushed=`cat unpushed.h 2>/dev/null`
+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" ] ; then
+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 [ -d ".git" ]; then
- branch=`git branch | awk 'BEGIN{ORS=""} /\*/ { print $2 }'`
+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 "$branch" ] && [ -n "$remote" ]; then
- unpushed_commit_list=`git cherry $remote/$branch | awk 'BEGIN{ORS=","} /\+/ {print $2}' | sed -e 's/,$//'`
- unpushed_commits=`git cherry $remote/$branch | awk 'BEGIN{ORS="\t\\\\\n"} /\+/ {print ",\"" $2 "\""}'`
+ 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/$branch`
+ 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
# Set up defaults for various values
-new_patchnum="describe: $describe"
if [ -n "$changed" ]; then
changed="true"
commit_title="Derived from:"
- new_patchnum="$new_patchnum
-status: uncommitted-changes"
+ status="#define PERL_GIT_UNCOMMITTED_CHANGES uncommitted-changes"
+else
+ status="/* clean working directory */"
fi
test -z "$commit_title" && commit_title='Commit id:'
-new_unpushed=`cat <<EOFTEXT
-/*********************************************************************
-* WARNING: unpushed.h is automatically generated by make_patchnum.sh *
-* DO NOT EDIT DIRECTLY - edit make_patchnum.sh instead *
-*********************************************************************/
+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: lib/Config_git.pl is generated by make_patchnum.sh #
-# DO NOT EDIT DIRECTLY - edit make_patchnum.sh instead #
-#################################################################
+#######################################################################
+# 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'
EOFDATA
`
# only update the files if necessary, other build product depends on these files
-if [ "$existing_patchnum" != "$new_patchnum" ] || [ "$new_config" != "$existing_config" ] || [ "$existing_unpushed" != "$new_unpushed" ]; then
- echo "Updating .patchnum and lib/Config_git.pl"
- echo "$new_patchnum" > .patchnum
- echo "$new_config" > lib/Config_git.pl
- echo "$new_unpushed" > unpushed.h
+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
else
- echo "Reusing .patchnum and lib/Config_git.pl"
+ echo "Reusing $header_file and $config_file"
fi