{"thread":{"id":"4798","subject":"[PATCH 1/4] configure: Add test for Perl","startedAt":"2006-07-07T16:25:13Z","lastAt":"2006-07-07T19:40:46Z","messageCount":6,"participants":["Dennis Stosberg","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"23374","messageId":"20060707162513.25746.57374.stgit@leonov.stosberg.net","threadId":"4798","inReplyTo":null,"subject":"[PATCH 0/4] More tests for hand-written configure (resend)","fromName":"Dennis Stosberg","fromEmail":"dennis@stosberg.net","sentAt":"2006-07-07T16:25:13Z","receivedAt":"2006-07-07T16:25:13Z","isPatch":true,"sender":{"key":"dennis@stosberg.net","avatar":null},"body":"Second version of the additional tests.  Changes relative to\nyesterdays's patches:\n\n  -  Calls to the \"which\" command have been replaced by a shell\n     function that Timo Hirvonen has written\n  -  Paths to Perl and Python binaries can be given in an\n     environment variable to prevent auto-detection.\n  -  NO_PYTHON is set, if no suitable python can be found\n  -  Fixes to make it run on Solaris.\n\nTested on Linux (bash, dash), Solaris 9 (sh) and NetBSD (sh/ash).\n\nI noticed that the autoconf-based solution has replaced Pasky's\nscripts in the pu branch.  Has a final decision been made?\n\nI must admit that I'm less convinced today that a hand-written\nconfiguration script is better than I was yesterday when I started\nto write the tests.\n\nRegards,\nDennis\n"},{"id":"23373","messageId":"20060707162637.25746.84757.stgit@leonov.stosberg.net","threadId":"4798","inReplyTo":"20060707162513.25746.57374.stgit@leonov.stosberg.net","subject":"[PATCH 1/4] configure: Add test for Perl","fromName":"Dennis Stosberg","fromEmail":"dennis@stosberg.net","sentAt":"2006-07-07T16:26:38Z","receivedAt":"2006-07-07T16:26:38Z","isPatch":true,"sender":{"key":"dennis@stosberg.net","avatar":null},"body":"From: Dennis Stosberg <dennis@stosberg.net>\n\nThis patch adds two tests to the configuration script. The first\none tries to find a perl binary in the path.  The second one checks\nwhether the found perl is of a sufficient version.\n\nThe user can override the auto-detection with the --perl parameter\nor with the PERL environment variable.\n\nThe path_find() function was written by Timo Hirvonen as a replacement\nfor \"which\", which cannot be used portably.\n\nSigned-off-by: Dennis Stosberg <dennis@stosberg.net>\n---\n\n config-lib.sh |   38 +++++++++++++++++++++++++++++++++++++-\n 1 files changed, 37 insertions(+), 1 deletions(-)\n\ndiff --git a/config-lib.sh b/config-lib.sh\nindex 68fecc5..34dfc05 100755\n--- a/config-lib.sh\n+++ b/config-lib.sh\n@@ -117,6 +117,22 @@ alpha() {\n \tesac\n }\n \n+# replacement for \"which\", which cannot be used portably\n+path_find()\n+{\n+        _ifs=\"$IFS\"\n+        IFS=:\n+        for i in $PATH; do\n+                if test -x \"$i/$1\"; then\n+                        IFS=\"$_ifs\"\n+                        echo \"$i/$1\"\n+                        return 0\n+                fi\n+        done\n+        IFS=\"$_ifs\"\n+        return 1\n+}\n+\n # not boolean test: implement the posix shell \"!\" operator for a\n # non-posix /bin/sh.\n #   usage:  not {command}\n@@ -240,6 +256,9 @@ process_params() {\n \t_cc=cc\n \ttest \"$CC\" && _cc=\"$CC\"\n \n+\t_perl=\n+\ttest \"$PERL\" && _perl=\"$PERL\"\n+\n \tfor ac_option do\n \t\tcase \"$ac_option\" in\n \t\t--help|-help|-h)\n@@ -262,6 +281,7 @@ Installation directories:\n \n Miscellaneous options:\n   --cc=COMPILER          use this C compiler to build MPlayer [gcc]\n+  --perl=PATH            path to perl binary [autodetect]\n   --target=PLATFORM      target platform (i386-linux, arm-linux, etc)\n   --with-install=PATH    use a custom install program (useful if your OS uses\n                          a GNU-incompatible install utility by default and\n@@ -296,6 +316,8 @@ EOF\n \n \t\t--cc=*)\n \t\t\t_cc=`echo $ac_option | cut -d '=' -f 2` ;;\n+\t\t--perl=*)\n+\t\t\t_perl=`echo $ac_option | cut -d '=' -f 2` ;;\n \t\t--target=*)\n \t\t\t_target=`echo $ac_option | cut -d '=' -f 2` ;;\n \t\t--with-install=*)\n@@ -409,8 +431,21 @@ int main(void) { return 0; }\n EOF\n \t{ cc_check && tmp_run; } || die \"unusable compiler or produced binary\"\n \techores yes\n-}\n \n+\techocheck \"for perl\"\n+\tif test -z \"$_perl\" ; then\n+\t\t_perl=`path_find perl`\n+\t\ttest \"$_perl\" || die \"cannot find path to perl\"\n+\tfi\n+\techores \"$_perl\"\n+\n+\techocheck \"perl version\"\n+\t_perl_version=`\"$_perl\" -e 'eval{require 5.6.0; printf \"%vd\", $^V}'`\n+\tif test -z \"$_perl_version\" ; then\n+\t\tdie \"your perl is too old. Perl 5.6.0 or newer is required.\"\n+\tfi\n+\techores \"$_perl_version\"\n+}\n \n write_config() {\n \techo \"Creating config.mak.autogen\"\n@@ -420,6 +455,7 @@ write_config() {\n # -------- Generated by configure -----------\n \n CC = $_cc\n+PERL_PATH = $_perl\n INSTALL = $_install\n \n EOF\n"},{"id":"23376","messageId":"20060707162640.25746.45482.stgit@leonov.stosberg.net","threadId":"4798","inReplyTo":"20060707162513.25746.57374.stgit@leonov.stosberg.net","subject":"[PATCH 2/4] configure: Add test for Python","fromName":"Dennis Stosberg","fromEmail":"dennis@stosberg.net","sentAt":"2006-07-07T16:26:40Z","receivedAt":"2006-07-07T16:26:40Z","isPatch":true,"sender":{"key":"dennis@stosberg.net","avatar":null},"body":"From: Dennis Stosberg <dennis@stosberg.net>\n\nThe test tries to find the path to a suitable Python binary.  The\nuser can override the auto-detection with the --python parameter\nor with the PYTHON environment variable.\n\nSigned-off-by: Dennis Stosberg <dennis@stosberg.net>\n---\n\n config-lib.sh |   32 ++++++++++++++++++++++++++++++++\n 1 files changed, 32 insertions(+), 0 deletions(-)\n\ndiff --git a/config-lib.sh b/config-lib.sh\nindex 34dfc05..3968245 100755\n--- a/config-lib.sh\n+++ b/config-lib.sh\n@@ -259,6 +259,9 @@ process_params() {\n \t_perl=\n \ttest \"$PERL\" && _perl=\"$PERL\"\n \n+\t_python=\n+\ttest \"$PYTHON\" && _python=\"$PYTHON\"\n+\n \tfor ac_option do\n \t\tcase \"$ac_option\" in\n \t\t--help|-help|-h)\n@@ -282,6 +285,7 @@ Installation directories:\n Miscellaneous options:\n   --cc=COMPILER          use this C compiler to build MPlayer [gcc]\n   --perl=PATH            path to perl binary [autodetect]\n+  --python=PATH          path to python binary [autodetect]\n   --target=PLATFORM      target platform (i386-linux, arm-linux, etc)\n   --with-install=PATH    use a custom install program (useful if your OS uses\n                          a GNU-incompatible install utility by default and\n@@ -318,6 +322,8 @@ EOF\n \t\t\t_cc=`echo $ac_option | cut -d '=' -f 2` ;;\n \t\t--perl=*)\n \t\t\t_perl=`echo $ac_option | cut -d '=' -f 2` ;;\n+\t\t--python=*)\n+\t\t\t_python=`echo $ac_option | cut -d '=' -f 2` ;;\n \t\t--target=*)\n \t\t\t_target=`echo $ac_option | cut -d '=' -f 2` ;;\n \t\t--with-install=*)\n@@ -445,6 +451,28 @@ EOF\n \t\tdie \"your perl is too old. Perl 5.6.0 or newer is required.\"\n \tfi\n \techores \"$_perl_version\"\n+\n+\techocheck \"for python\"\n+\tfor _py_bin in python python2.4 python2.3; do\n+\t\ttest \"$_python\" && continue\n+\n+\t\t_candidate=`path_find $_py_bin`\n+\t\ttest \"$_candidate\" || continue\n+\n+\t\t$_candidate - <<EOF || continue\n+import sys\n+v = sys.version_info\n+if v < (2, 3):\n+    sys.exit(1)\n+EOF\n+\t\t_python=$_candidate\n+\tdone\n+\tif test \"$_python\"; then\n+\t\techores \"$_python\"\n+\telse\n+\t\t_no_python=\"ConfigureYesPlease\"\n+\t\techores \"not found\"\n+\tfi\n }\n \n write_config() {\n@@ -465,6 +493,10 @@ EOF\n \t\ttest -z $_mandir || ( echo \"mandir = $_mandir\" && echo \"export mandir\" )\n \t\ttest -z $_templatedir || echo \"template_dir = $_templatedir\"\n \t\ttest -z $_gitpythondir || echo \"GIT_PYTHON_DIR = $_gitpythondir\"\n+\n+\t\ttest -z $_python || echo \"PYTHON_PATH = $_python\"\n+\t\ttest -z $_no_python || echo \"NO_PYTHON = $_no_python\"\n+\n \t\techo\n \t\teval \"$mkvars\"\n \t} > config.mak.autogen\n"},{"id":"23375","messageId":"20060707162642.25746.3676.stgit@leonov.stosberg.net","threadId":"4798","inReplyTo":"20060707162513.25746.57374.stgit@leonov.stosberg.net","subject":"[PATCH 3/4] configure: Try to figure out compiler options","fromName":"Dennis Stosberg","fromEmail":"dennis@stosberg.net","sentAt":"2006-07-07T16:26:42Z","receivedAt":"2006-07-07T16:26:42Z","isPatch":true,"sender":{"key":"dennis@stosberg.net","avatar":null},"body":"From: Dennis Stosberg <dennis@stosberg.net>\n\nThis patch adds tests to determine of what flavour the used\ncompiler is and sets CFLAGS and the PIC flag appropriately.\n\nSigned-off-by: Dennis Stosberg <dennis@stosberg.net>\n---\n\n Makefile      |    3 ++-\n config-lib.sh |   56 +++++++++++++++++++++++++++++++++++++++++++++++++++-----\n 2 files changed, 53 insertions(+), 6 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 4dc5379..23c784e 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -96,6 +96,7 @@ ALL_CFLAGS = $(CFLAGS)\n ALL_LDFLAGS = $(LDFLAGS)\n PERL_CFLAGS =\n PERL_LDFLAGS =\n+PICFLAG = -fPIC\n STRIP ?= strip\n \n prefix = $(HOME)\n@@ -483,7 +484,7 @@ endif\n endif\n endif\n ifdef USE_PIC\n-\tALL_CFLAGS += -fPIC\n+\tALL_CFLAGS += $(PICFLAG)\n endif\n ifdef NO_ACCURATE_DIFF\n \tBASIC_CFLAGS += -DNO_ACCURATE_DIFF\ndiff --git a/config-lib.sh b/config-lib.sh\nindex 3968245..0bcd4c3 100755\n--- a/config-lib.sh\n+++ b/config-lib.sh\n@@ -35,9 +35,9 @@ compile_check() {\n \techo\n \tcat \"$1\"\n \techo\n-\techo \"$_cc $CFLAGS $_inc_extra $_ld_static $_ld_extra -o $TMPO $@\"\n+\techo \"$_cc $_cflags $_inc_extra $_ld_static $_ld_extra -o $TMPO $@\"\n \trm -f \"$TMPO\"\n-\t$_cc $CFLAGS $_inc_extra $_ld_static $_ld_extra -o \"$TMPO\" \"$@\" || return $?\n+\t$_cc $_cflags $_inc_extra $_ld_static $_ld_extra -o \"$TMPO\" \"$@\" || return $?\n \techo\n \techo \"ldd $TMPO\"\n \t$_ldd \"$TMPO\" || return $?\n@@ -283,7 +283,7 @@ Installation directories:\n   --gitpythondir=DIR     use this prefix for python libraries [PREFIX/share/git-core/python]\n \n Miscellaneous options:\n-  --cc=COMPILER          use this C compiler to build MPlayer [gcc]\n+  --cc=COMPILER          use this C compiler to build Git [cc]\n   --perl=PATH            path to perl binary [autodetect]\n   --python=PATH          path to python binary [autodetect]\n   --target=PLATFORM      target platform (i386-linux, arm-linux, etc)\n@@ -373,8 +373,8 @@ EOF\n \t\t\t\ti[3-9]86*|x86|x86pc|k5|k6|k6_2|k6_3|k6-2|k6-3|pentium*|athlon*|i586_i686|i586-i686|BePC) host_arch=i386 ;;\n \t\t\t\tia64) host_arch=ia64 ;;\n \t\t\t\tx86_64|amd64)\n-\t\t\t\tif [ -n \"`$_cc -dumpmachine | sed -n '/^x86_64-/p;/^amd64-/p'`\" -a \\\n-\t\t\t\t\t-z \"`echo $CFLAGS | grep -- -m32`\"  ]; then\n+\t\t\t\tif [ -n \"`$_cc -dumpmachine 2>/dev/null | sed -n '/^x86_64-/p;/^amd64-/p'`\" -a \\\n+\t\t\t\t\t-z \"`echo $_cflags | grep -- -m32`\"  ]; then\n \t\t\t\t\thost_arch=x86_64\n \t\t\t\telse\n \t\t\t\t\thost_arch=i386\n@@ -430,7 +430,51 @@ test_setup() {\n \tTMPS=\"$I/git-conf-$RANDOM-$$.S\"\n }\n \n+cc_flavour() {\n+\n+\techocheck \"whether cc is GCC\"\n+\tcat > $TMPC <<EOF\n+#ifndef __GNUC__\n+#error Not GCC\n+#endif\n+int main(void) { return 0; }\n+EOF\n+\tif cc_check ; then\n+\t\techores \"yes\"\n+\t\t_cc_flavour=\"gcc\"\n+\t\treturn\n+\tfi\n+\techores \"no\"\n+\n+\techocheck \"whether cc is Sun CC\"\n+\tcat > $TMPC <<EOF\n+#ifndef __SUNPRO_C\n+#error Not SUN CC\n+#endif\n+int main(void) { return 0; }\n+EOF\n+\tif cc_check ; then\n+\t\techores \"yes\"\n+\t\t_cc_flavour=\"suncc\"\n+\t\treturn\n+\tfi\n+\techores \"no\"\n+}\n+\n basic_tests() {\n+\t_cc_flavour=unknown\n+\tcc_flavour\n+\n+\tif test \"$_cc_flavour\" = \"gcc\" ; then\n+\t\t_cflags=\"-g -O2 -Wall\"\n+\t\t_picflag=\"-fPIC\"\n+\telif test \"$_cc_flavour\" = \"suncc\"; then\n+\t\t_cflags=\"-g -xO3\"\n+\t\t_picflag=\"-KPIC\"\n+\tfi\n+\ttest \"$CFLAGS\" && _cflags=\"$CFLAGS\"\n+\ttest \"$PICFLAG\" && _picflag=\"$PICFLAG\"\n+\n \techocheck \"if your build environment is sane\"\n \tcat > $TMPC <<EOF\n int main(void) { return 0; }\n@@ -483,6 +527,8 @@ write_config() {\n # -------- Generated by configure -----------\n \n CC = $_cc\n+CFLAGS = $_cflags\n+PICFLAG = $_picflag\n PERL_PATH = $_perl\n INSTALL = $_install\n \n"},{"id":"23377","messageId":"20060707162644.25746.78865.stgit@leonov.stosberg.net","threadId":"4798","inReplyTo":"20060707162513.25746.57374.stgit@leonov.stosberg.net","subject":"[PATCH 4/4] configure: Fixes for Solaris","fromName":"Dennis Stosberg","fromEmail":"dennis@stosberg.net","sentAt":"2006-07-07T16:26:44Z","receivedAt":"2006-07-07T16:26:44Z","isPatch":true,"sender":{"key":"dennis@stosberg.net","avatar":null},"body":"From: Dennis Stosberg <dennis@stosberg.net>\n\n- Solaris' /bin/sh will not find a function if there is a variable \n  with the same name.\n- 'test -z $var' fails if $var is empty.  Needs to be 'test -z \"$var\"' \n\nSigned-off-by: Dennis Stosberg <dennis@stosberg.net>\n---\n\n config-lib.sh |   24 ++++++++++++------------\n 1 files changed, 12 insertions(+), 12 deletions(-)\n\ndiff --git a/config-lib.sh b/config-lib.sh\nindex 0bcd4c3..4dd4d00 100755\n--- a/config-lib.sh\n+++ b/config-lib.sh\n@@ -181,7 +181,7 @@ add_library() { # --with\n \tlib_help=\"$lib_help\n $desc [$hdefault]\"\n \tswitches=\"$switches switch_lib \\\"$name\\\" \\\"$switch\\\" \\\"\\$ac_option\\\" || \"\n-\tmkvars=\"$mkvars mkvar \\\"\\$$name\\\" \\\"$mkvar\\\";\"\n+\tmkvars=\"$mkvars print_mkvar \\\"\\$$name\\\" \\\"$mkvar\\\";\"\n \teval \"$name=$default\"\n }\n \n@@ -196,7 +196,7 @@ add_feature() { # --enable\n \tfeature_help=\"$feature_help\n $desc [$hdefault]\"\n \tswitches=\"$switches switch_feature \\\"$name\\\" \\\"$switch\\\" \\\"\\$ac_option\\\" || \"\n-\tmkvars=\"$mkvars mkvar \\\"\\$$name\\\" \\\"$mkvar\\\";\"\n+\tmkvars=\"$mkvars print_mkvar \\\"\\$$name\\\" \\\"$mkvar\\\";\"\n \teval \"$name=$default\"\n }\n \n@@ -226,7 +226,7 @@ switch_feature() {\n \treturn 0\n }\n \n-mkvar() {\n+print_mkvar() {\n \tvalue=\"$1\"; shift; mkvar=\"$1\"; shift\n \tnoval=\"\"; yesval=\"ConfigureYesPlease\"\n \tcase $mkvar in\n@@ -533,15 +533,15 @@ PERL_PATH = $_perl\n INSTALL = $_install\n \n EOF\n-\t\ttest -z $_prefix || echo \"prefix = $_prefix\"\n-\t\ttest -z $_bindir || echo \"bindir = $_bindir\"\n-\t\ttest -z $_gitexecdir || echo \"gitexecdir = $_gitexecdir\"\n-\t\ttest -z $_mandir || ( echo \"mandir = $_mandir\" && echo \"export mandir\" )\n-\t\ttest -z $_templatedir || echo \"template_dir = $_templatedir\"\n-\t\ttest -z $_gitpythondir || echo \"GIT_PYTHON_DIR = $_gitpythondir\"\n-\n-\t\ttest -z $_python || echo \"PYTHON_PATH = $_python\"\n-\t\ttest -z $_no_python || echo \"NO_PYTHON = $_no_python\"\n+\t\ttest -z \"$_prefix\" || echo \"prefix = $_prefix\"\n+\t\ttest -z \"$_bindir\" || echo \"bindir = $_bindir\"\n+\t\ttest -z \"$_gitexecdir\" || echo \"gitexecdir = $_gitexecdir\"\n+\t\ttest -z \"$_mandir\" || ( echo \"mandir = $_mandir\" && echo \"export mandir\" )\n+\t\ttest -z \"$_templatedir\" || echo \"template_dir = $_templatedir\"\n+\t\ttest -z \"$_gitpythondir\" || echo \"GIT_PYTHON_DIR = $_gitpythondir\"\n+\n+\t\ttest -z \"$_python\" || echo \"PYTHON_PATH = $_python\"\n+\t\ttest -z \"$_no_python\" || echo \"NO_PYTHON = $_no_python\"\n \n \t\techo\n \t\teval \"$mkvars\"\n"},{"id":"23391","messageId":"7vhd1tw6dd.fsf@assigned-by-dhcp.cox.net","threadId":"4798","inReplyTo":"20060707162513.25746.57374.stgit@leonov.stosberg.net","subject":"Re: [PATCH 0/4] More tests for hand-written configure (resend)","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-07-07T19:40:46Z","receivedAt":"2006-07-07T19:40:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Dennis Stosberg <dennis@stosberg.net> writes:\n\n> I noticed that the autoconf-based solution has replaced Pasky's\n> scripts in the pu branch.  Has a final decision been made?\n\nMy preference has been to see both sides battle it out without\nforcing me to decide, but...\n\n> I must admit that I'm less convinced today that a hand-written\n> configuration script is better than I was yesterday when I started\n> to write the tests.\n\n... I started to share the same feeling after Pavel Roskin made\na good point in \"git on HP-UX\" thread,\n\n    http://thread.gmane.org/gmane.comp.version-control.git/23380/focus=23393\n\nand then after seeing the messages in response to your patch\nthat used `which` from yesterday.\n\nShell scripts generated by autoconf are almost unreadable, but\nthe way how they detect features have been polished in the field\nfor portability for a long time, and there is no point for us to\nspend time reinventing the wheel.  The configure.ac files are\noften quite readable even when generated configure scripts are\nnot.\n\nSo, I would not veto the use of autoconf, as long as configure\nstays as an _optional_ mechanism to manage config.mak.gen that\nis used by the main Makefile.  The users for whom the configure\nscript breaks for whatever reason can work it around by simply\nnot using it, instead of having to debug either the unreadable\nconfigure or having to install autoconf and debug configure.ac\njust to build git.\n\nThe _optional_ is really the key word here.  So \"make clean\" to\nclean autoconf intermediate files is good, \"make realclean\" to\nremove \"configure\" script generated from \"configure.ac\" is also\ngood, but if \"make rpm\" by default runs \"configure\", then that\nis BAD and I would be very unhappy.\n\nI could probably live with \"make rpm-using-configure\", though.\n"}]}