0960b7 | 2002-09-09 | Marcus Comstedt | |
|
0d0331 | 2003-08-24 | Martin Nilsson | | #pike __REAL_VERSION__
|
7aaaf1 | 2008-06-20 | Stephen R. van den Berg | | constant version =
sprintf("%d.%d.%d",(int)__REAL_VERSION__,__REAL_MINOR__,__REAL_BUILD__);
|
614816 | 2002-12-14 | Martin Nilsson | | constant description = "Pike module installer.";
|
0960b7 | 2002-09-09 | Marcus Comstedt | |
string srcdir;
|
a1a48e | 2003-03-20 | Dan Nelson | | string make=getenv("MAKE")||"make";
|
0960b7 | 2002-09-09 | Marcus Comstedt | | string make_flags="";
string include_path=master()->include_prefix;
|
ad1d63 | 2003-02-22 | Marcus Comstedt | | string config_args="";
|
a98cf8 | 2002-09-13 | Marcus Comstedt | | #ifdef NOT_INSTALLED
string src_path=combine_path(__FILE__,"../../../../../src");
string bin_path=combine_path(src_path,"../bin");
#else
string src_path=include_path;
string bin_path=include_path;
|
265463 | 2003-11-06 | Martin Nilsson | | #endif
|
041825 | 2003-10-30 | H. William Welliver III | |
|
c2b063 | 2003-10-30 | H. William Welliver III | |
|
356035 | 2008-07-08 | Henrik Grubbström (Grubba) | | string local_module_path=combine_path(getenv("HOME")||"","lib/pike/modules");
|
1be98f | 2008-06-29 | Per Hedbor | | bool old_style_module = false;
|
041825 | 2003-10-30 | H. William Welliver III | |
string system_module_path=master()->system_module_path[-1];
|
0df63c | 2003-11-04 | H. William Welliver III | |
|
9443dd | 2006-04-22 | Henrik Grubbström (Grubba) | | string system_doc_path = master()->doc_prefix;
|
0df63c | 2003-11-04 | H. William Welliver III | |
|
a98cf8 | 2002-09-13 | Marcus Comstedt | | string run_pike;
|
0960b7 | 2002-09-09 | Marcus Comstedt | |
#define NOT 0
#define AUTO 1
#define ALWAYS 2
mapping(string:int) run=
([
"automake":AUTO,
"autoheader":AUTO,
"autoconf":AUTO,
"configure":AUTO,
"depend":AUTO,
"make":AUTO,
|
9443dd | 2006-04-22 | Henrik Grubbström (Grubba) | | ]);
|
0960b7 | 2002-09-09 | Marcus Comstedt | |
mapping(string:string) specs = ([]);
void load_specs(string fn)
{
string name, val;
foreach(Stdio.read_file(fn)/"\n", string line)
if(2==sscanf(line, "%s=%s", name, val) && !specs[name])
specs[name] = val;
|
9443dd | 2006-04-22 | Henrik Grubbström (Grubba) | |
if (!system_doc_path) {
if(file_stat(combine_path(system_module_path,
"../../doc/src/core_autodoc.xml")))
system_doc_path=combine_path(system_module_path, "../../doc");
else if(file_stat(combine_path(system_module_path,
"../../../doc/pike/src/core_autodoc.xml")))
system_doc_path=combine_path(system_module_path, "../../../doc/pike");
else if(file_stat(combine_path(system_module_path, "../../doc")))
system_doc_path=combine_path(system_module_path, "../../doc");
else if(file_stat(combine_path(system_module_path, "../../../doc/pike")))
system_doc_path=combine_path(system_module_path, "../../../doc/pike");
else {
system_doc_path = combine_path(system_module_path, "../../doc");
}
}
|
0960b7 | 2002-09-09 | Marcus Comstedt | | }
array(string) do_split_quoted_string(string s)
{
array(string) res = Process.split_quoted_string(s);
if(sizeof(res) == 1 && res[0] == "" &&
search(s, "'")<0 && search(s, "\"")<0)
return ({});
else
return res;
}
string fix(string path)
{
|
7c056d | 2003-06-06 | Johan Sundström | | if(!has_value(path, "$src")) return path;
|
0960b7 | 2002-09-09 | Marcus Comstedt | | if(!srcdir)
{
string s=Stdio.read_file("Makefile");
if(s)
{
sscanf(s,"%*s\nSRCDIR=%s\n",srcdir);
}
|
1be98f | 2008-06-29 | Per Hedbor | | if(!srcdir)
|
0960b7 | 2002-09-09 | Marcus Comstedt | | {
srcdir=".";
}
|
352471 | 2015-05-26 | Martin Nilsson | |
|
0960b7 | 2002-09-09 | Marcus Comstedt | | if(!srcdir)
{
werror("You must provide --source=<source dir>\n");
exit(1);
}
}
return replace(path,"$src",srcdir);
}
void do_zero()
{
foreach(indices(run), string x) if(run[x]==AUTO) m_delete(run,x);
}
int max_time_of_files(string ... a)
{
int t=0;
|
7c056d | 2003-06-06 | Johan Sundström | | foreach(a, string file)
{
Stdio.Stat s = file_stat(fix(file));
if(!s) return 0;
t = max(t, s->mtime);
}
|
0960b7 | 2002-09-09 | Marcus Comstedt | | return t;
}
int just_run(mapping options, string ... cmd)
{
werror(" %s\n",cmd*" ");
|
f6883f | 2003-02-14 | Marcus Comstedt | | return Process.create_process(cmd,(["env":getenv()])|options)->wait();
|
0960b7 | 2002-09-09 | Marcus Comstedt | | }
void run_or_fail(mapping options,string ... cmd)
{
werror(" %s\n",cmd*" ");
|
f6883f | 2003-02-14 | Marcus Comstedt | | int ret=Process.create_process(cmd,(["env":getenv()])|options)->wait();
|
0960b7 | 2002-09-09 | Marcus Comstedt | | if(ret)
exit(ret);
}
void do_make(array(string) cmd)
{
int tmp1;
|
c2b063 | 2003-10-30 | H. William Welliver III | | string lmp;
|
e9bce7 | 2003-11-07 | H. William Welliver III | | string full_srcdir;
|
c2b063 | 2003-10-30 | H. William Welliver III | |
if(search(cmd, "testsuite")!=-1)
lmp="./plib/modules";
|
265463 | 2003-11-06 | Martin Nilsson | | else
lmp = local_module_path;
|
352471 | 2015-05-26 | Martin Nilsson | |
|
e9bce7 | 2003-11-07 | H. William Welliver III | | if(srcdir !=".") full_srcdir=srcdir + "/";
else full_srcdir=getcwd() + "/";
|
c2b063 | 2003-10-30 | H. William Welliver III | |
|
1be98f | 2008-06-29 | Per Hedbor | | array extra_args = ({});
|
352471 | 2015-05-26 | Martin Nilsson | |
|
1be98f | 2008-06-29 | Per Hedbor | | if( old_style_module )
{
extra_args =
({"PIKE_INCLUDES=-I"+include_path,
"PIKE_SRC_DIR="+src_path,
"BUILD_BASE="+include_path,
|
e0cb60 | 2008-06-29 | Marcus Agehall | | "MODULE_BASE="+combine_path(include_path, "modules"),
|
1be98f | 2008-06-29 | Per Hedbor | | "TMP_BINDIR="+bin_path,
"SRCDIR="+fix("$src"),
"FULL_SRCDIR=" + full_srcdir,
"TMP_MODULE_BASE=.",
"PIKE_EXTERNAL_MODULE=pike_external_module",
"CORE_AUTODOC_PATH=" + combine_path(system_doc_path, "src/core_autodoc.xml"),
"SYSTEM_DOC_PATH=" + system_doc_path + "/",
"SYSTEM_MODULE_PATH=" + system_module_path,
"LOCAL_MODULE_PATH=" + lmp,
"RUNPIKE="+run_pike,
|
51a330 | 2012-08-06 | Bill Welliver | | "FINAL_PIKE="+run_pike,
|
1be98f | 2008-06-29 | Per Hedbor | | });
}
else
{
|
3647eb | 2008-06-29 | Per Hedbor | | extra_args = ({
"PIKE="+run_pike,
"SRCDIR="+fix("$src"),
"MODULE_INSTALL_DIR="+combine_path(__FILE__,"../../.."),
"LOCAL_MODULE_PATH=" + lmp,
});
|
1be98f | 2008-06-29 | Per Hedbor | | }
|
352471 | 2015-05-26 | Martin Nilsson | |
|
1be98f | 2008-06-29 | Per Hedbor | | array(string) makecmd=({make})+do_split_quoted_string(make_flags)+extra_args+cmd;
|
0960b7 | 2002-09-09 | Marcus Comstedt | |
if(tmp1=max_time_of_files("Makefile"))
{
rm("remake");
tmp1=just_run(([]),@makecmd);
if(tmp1)
{
if(max_time_of_files("remake"))
{
run_or_fail(([]),@makecmd);
}else{
exit(tmp1);
}
}
}else{
werror("No Makefile.\n");
}
}
int main(int argc, array(string) argv)
{
|
e0cb60 | 2008-06-29 | Marcus Agehall | | string specspath=combine_path(include_path, "specs");
|
d0c621 | 2008-03-28 | Bertrand Lupart | |
if(!Stdio.is_file(specspath))
{
werror("Missing specs file at %s\n",specspath);
return 1;
}
|
a98cf8 | 2002-09-13 | Marcus Comstedt | | run_pike = master()->_pike_file_name;
#ifdef NOT_INSTALLED
run_pike += " -DNOT_INSTALLED";
#endif
#ifdef PRECOMPILED_SEARCH_MORE
run_pike += " -DPRECOMPILED_SEARCH_MORE";
#endif
if(master()->_master_file_name)
run_pike += " -m"+master()->_master_file_name;
|
e46bb6 | 2002-09-14 | Marcus Comstedt | | putenv("RUNPIKE", run_pike);
|
a98cf8 | 2002-09-13 | Marcus Comstedt | |
|
d0c621 | 2008-03-28 | Bertrand Lupart | | load_specs(specspath);
|
352471 | 2015-05-26 | Martin Nilsson | |
|
0960b7 | 2002-09-09 | Marcus Comstedt | | foreach(Getopt.find_all_options(argv,aggregate(
({"autoconf",Getopt.NO_ARG,({"--autoconf"}) }),
({"configure",Getopt.NO_ARG,({"--configure"}) }),
({"autoheader",Getopt.NO_ARG,({"--autoheader"}) }),
({"automake",Getopt.NO_ARG,({"--automake"}) }),
({"depend",Getopt.NO_ARG,({"--depend"}) }),
({"all",Getopt.NO_ARG,({"--all"}) }),
({"make",Getopt.NO_ARG,({"--make"}) }),
({"auto",Getopt.NO_ARG,({"--auto"}) }),
({"source",Getopt.HAS_ARG,({"--source"}) }),
({"query",Getopt.HAS_ARG,({"--query"}) }),
|
ec9d4c | 2003-04-07 | Martin Nilsson | | ({"config_args",Getopt.HAS_ARG,({"--configure-args"}) }),
({"help",Getopt.NO_ARG,({"--help"}) }),
|
0960b7 | 2002-09-09 | Marcus Comstedt | | )),array opt)
{
switch(opt[0])
{
case "query":
|
d22f9c | 2003-04-04 | Martin Nilsson | | if(opt[1]=="specs")
write("%O\n", specs);
else if(stringp(this[opt[1]]))
write("%s\n", this[opt[1]]);
else
write("Unknown variable %s.\n", opt[1]);
|
0960b7 | 2002-09-09 | Marcus Comstedt | | exit(0);
|
ec9d4c | 2003-04-07 | Martin Nilsson | | case "help":
|
4ceddc | 2003-04-07 | Martin Nilsson | | write(help, version);
|
ec9d4c | 2003-04-07 | Martin Nilsson | | exit(0);
|
0960b7 | 2002-09-09 | Marcus Comstedt | |
|
ad1d63 | 2003-02-22 | Marcus Comstedt | | case "config_args": config_args=opt[1]; break;
|
0960b7 | 2002-09-09 | Marcus Comstedt | | case "source": srcdir=opt[1]; break;
case "automake": run->automake=ALWAYS; do_zero(); break;
case "autoheader": run->autoheader=ALWAYS; do_zero(); break;
case "autoconf": run->autoconf=ALWAYS; do_zero(); break;
case "configure": run->configure=ALWAYS; do_zero(); break;
case "make": run->make=ALWAYS; do_zero(); break;
case "depend": run->depend=ALWAYS; do_zero(); break;
|
352471 | 2015-05-26 | Martin Nilsson | |
case "all":
|
0960b7 | 2002-09-09 | Marcus Comstedt | | run->depend=run->autoheader=run->autoconf=run->configure=run->make=ALWAYS;
break;
|
352471 | 2015-05-26 | Martin Nilsson | |
|
0960b7 | 2002-09-09 | Marcus Comstedt | | case "auto":
run->depend=run->autoheader=run->autoconf=run->configure=run->make=AUTO;
break;
}
}
argv=Getopt.get_args(argv);
|
1be98f | 2008-06-29 | Per Hedbor | | string configure_args="";
|
352471 | 2015-05-26 | Martin Nilsson | |
|
1be98f | 2008-06-29 | Per Hedbor | | foreach( argv, string arg )
if( sscanf( arg, "CONFIGUREARGS=%s", configure_args ) )
argv-=({arg});
|
0960b7 | 2002-09-09 | Marcus Comstedt | |
|
1be98f | 2008-06-29 | Per Hedbor | | string configure_in = "$src/configure.in";
if( max_time_of_files( configure_in ) < max_time_of_files( "$src/configure.ac" ) )
configure_in = "$src/configure.ac" ;
|
0960b7 | 2002-09-09 | Marcus Comstedt | | int tmp1;
|
1be98f | 2008-06-29 | Per Hedbor | |
|
0960b7 | 2002-09-09 | Marcus Comstedt | | if(run->automake)
{
|
1be98f | 2008-06-29 | Per Hedbor | | if(tmp1=max_time_of_files("$src/Makefile.am",configure_in))
|
0960b7 | 2002-09-09 | Marcus Comstedt | | {
|
352471 | 2015-05-26 | Martin Nilsson | | write("** Running automake\n");
|
0960b7 | 2002-09-09 | Marcus Comstedt | | if(run->automake == ALWAYS ||
max_time_of_files("$src/Makefile.in") < tmp1)
{
|
594b9e | 2009-10-24 | H. William Welliver III | | run_or_fail((["cwd":srcdir]),"aclocal");
run_or_fail((["cwd":srcdir]),"automake");
|
0960b7 | 2002-09-09 | Marcus Comstedt | | rm(fix("$src/stamp-h.in"));
}
}
}
|
352471 | 2015-05-26 | Martin Nilsson | |
|
1be98f | 2008-06-29 | Per Hedbor | | if( max_time_of_files( configure_in ) < max_time_of_files( "$src/configure.ac" ) )
configure_in = "$src/configure.ac" ;
string configure_content = Stdio.read_file(fix(configure_in))||"";
old_style_module = has_value(configure_content, "AC_MODULE_INIT" );
if( old_style_module )
{
write("** Old style module\n");
}
|
0960b7 | 2002-09-09 | Marcus Comstedt | |
|
1be98f | 2008-06-29 | Per Hedbor | | string stamp_file = "$src/stamp-h.in";
if( sscanf( configure_content, "%*sAC_CONFIG_HEADER(%[^)])", stamp_file ) == 2 )
stamp_file="$src/"+stamp_file+".in";
|
352471 | 2015-05-26 | Martin Nilsson | |
|
0960b7 | 2002-09-09 | Marcus Comstedt | | if(run->autoheader)
{
|
1be98f | 2008-06-29 | Per Hedbor | | if(tmp1=max_time_of_files("$src/acconfig.h",configure_in))
|
0960b7 | 2002-09-09 | Marcus Comstedt | | {
|
1be98f | 2008-06-29 | Per Hedbor | | if(run->autoheader==ALWAYS || max_time_of_files(stamp_file) <= tmp1)
|
0960b7 | 2002-09-09 | Marcus Comstedt | | {
|
594b9e | 2009-10-24 | H. William Welliver III | | run_or_fail((["cwd":srcdir]),"autoheader");
|
1be98f | 2008-06-29 | Per Hedbor | | if( stamp_file == "$src/stamp-h.in" )
Stdio.write_file(fix(stamp_file),"foo\n");
|
0960b7 | 2002-09-09 | Marcus Comstedt | | }
}
}
|
b0b552 | 2011-11-19 | Marcus Comstedt | | if(run->configure && run->autoconf != ALWAYS && old_style_module)
{
string cfscript = Stdio.read_file(fix("$src/configure"));
if(cfscript && !has_value(cfscript, "propagated_variables"))
{
write("** WARNING: Incompatible configure script detected, deleting it\n");
rm(fix("$src/configure"));
}
}
|
0960b7 | 2002-09-09 | Marcus Comstedt | | if(run->autoconf)
{
|
1be98f | 2008-06-29 | Per Hedbor | | if(tmp1=max_time_of_files(configure_in))
|
0960b7 | 2002-09-09 | Marcus Comstedt | | {
|
1be98f | 2008-06-29 | Per Hedbor | | if(run->autoconf==ALWAYS || max_time_of_files("$src/configure") <= tmp1)
|
0960b7 | 2002-09-09 | Marcus Comstedt | | {
|
1be98f | 2008-06-29 | Per Hedbor | | if( old_style_module )
{
|
b0b552 | 2011-11-19 | Marcus Comstedt | | if(file_stat(fix("$src/aclocal.m4")))
{
write("** WARNING: aclocal.m4 detected in src tree, deleting it\n");
rm(fix("$src/aclocal.m4"));
}
|
1be98f | 2008-06-29 | Per Hedbor | | write("** Running autoconf (with extra compat macros)\n");
string data = Process.popen("autoconf --version");
data = (data/"\n")[0];
float v;
sscanf(data, "%*s%f", v);
if(!v || v>2.52)
|
594b9e | 2009-10-24 | H. William Welliver III | | run_or_fail((["cwd":srcdir]),"autoconf","--include="+src_path);
|
1be98f | 2008-06-29 | Per Hedbor | | else
|
594b9e | 2009-10-24 | H. William Welliver III | | run_or_fail((["cwd":srcdir]),"autoconf","--localdir="+src_path);
|
1be98f | 2008-06-29 | Per Hedbor | | }
|
ec9d4c | 2003-04-07 | Martin Nilsson | | else
|
1be98f | 2008-06-29 | Per Hedbor | | {
write("** Running autoconf\n");
|
594b9e | 2009-10-24 | H. William Welliver III | | run_or_fail( (["cwd":srcdir]), "autoconf" );
|
1be98f | 2008-06-29 | Per Hedbor | | }
|
0960b7 | 2002-09-09 | Marcus Comstedt | | }
}
}
if(run->configure)
{
|
1be98f | 2008-06-29 | Per Hedbor | | if( tmp1=max_time_of_files("$src/configure") )
|
0960b7 | 2002-09-09 | Marcus Comstedt | | {
|
1be98f | 2008-06-29 | Per Hedbor | | if(run->configure == ALWAYS || (max_time_of_files("Makefile") <= tmp1))
|
0960b7 | 2002-09-09 | Marcus Comstedt | | {
|
1be98f | 2008-06-29 | Per Hedbor | | if( old_style_module )
{
|
f543d2 | 2008-06-29 | Marcus Comstedt | | if(!max_time_of_files("propagated_variables")) {
write("** Copying propagated_variables\n");
Stdio.write_file("propagated_variables", Stdio.read_file(combine_path(include_path, "propagated_variables")));
}
|
1be98f | 2008-06-29 | Per Hedbor | | write("** Running configure (with extra compat args)\n");
array(string) cfa = do_split_quoted_string(specs->configure_args||"");
mapping(string:string) cfa_env = ([]);
foreach(cfa; int i; string arg)
|
f6883f | 2003-02-14 | Marcus Comstedt | | {
|
1be98f | 2008-06-29 | Per Hedbor | | string key, val;
if(2==sscanf(arg, "%[a-zA-Z0-9_]=%s", key, val))
{
cfa_env[key] = val;
cfa[i] = 0;
}
|
3e97e2 | 2003-02-20 | Marcus Comstedt | | }
|
1be98f | 2008-06-29 | Per Hedbor | | run_or_fail((["env":getenv()|cfa_env|
(specs & ({"CC","CFLAGS","CPPFLAGS","CPP",
"LDFLAGS","LDSHARED"}))|
(["PIKE_SRC_DIR":src_path,
"BUILD_BASE":include_path])]),
fix("$src/configure"),
"--cache-file=./config.cache",
@(cfa-({0})), @do_split_quoted_string(config_args));
}
else
{
write("** Running configure\n");
|
3647eb | 2008-06-29 | Per Hedbor | | run_or_fail( ([ "env":getenv()|
([
"PIKE":run_pike,
"MODULE_INSTALL_DIR":combine_path(__FILE__,"../../.."),
"LOCAL_MODULE_PATH":local_module_path,
])
]),
fix("$src/configure"),
@do_split_quoted_string(configure_args));
|
3e97e2 | 2003-02-20 | Marcus Comstedt | | }
|
0960b7 | 2002-09-09 | Marcus Comstedt | | }
}
}
|
1be98f | 2008-06-29 | Per Hedbor | | if( old_style_module && run->depend )
|
0960b7 | 2002-09-09 | Marcus Comstedt | | {
|
bbf9a3 | 2002-09-12 | Marcus Comstedt | | if(!max_time_of_files("$src/dependencies") || run->depend == ALWAYS)
|
0960b7 | 2002-09-09 | Marcus Comstedt | | {
|
1be98f | 2008-06-29 | Per Hedbor | | write("** Running make depend\n");
|
0960b7 | 2002-09-09 | Marcus Comstedt | |
Stdio.write_file(srcdir+"/dependencies","");
do_make( ({"depend"}) );
do_make( ({"Makefile"}) );
}
}
if(run->make)
{
|
1be98f | 2008-06-29 | Per Hedbor | | write("** Running "+argv[1..]*" ");
|
0960b7 | 2002-09-09 | Marcus Comstedt | | do_make(argv[1..]);
}
}
|
ec9d4c | 2003-04-07 | Martin Nilsson | |
|
4ceddc | 2003-04-07 | Martin Nilsson | | constant help=#"Pike module installer %s.
|
ec9d4c | 2003-04-07 | Martin Nilsson | | module <options> <arguments passed to make>
Information options:
--help Prints this text
--query=X Shows the value of setting X. Possible settings are
include_path, configure_command, src_path, bin_path,
|
041825 | 2003-10-30 | H. William Welliver III | | system_module_path, make and specs.
|
ec9d4c | 2003-04-07 | Martin Nilsson | |
Stage selection:
If none of these stages are selected, all of them will
be run, given that the timestamps of the dependncies
indicates that it is needed. If one or more stage is
selected, these stages will always run, but none of
the unselected ones.
--automake Runs aclocal and automake.
--autoheader Runs autoheader.
--autoconf Runs autoconf.
--configure Runs configure.
--depend Runs make depend and make Makefile.
--make Runs make.
--all Runs all of the above.
--auto Sets all stages to auto (default).
Environment:
--source=X Path to the source directory.
--configure-args
Additional arguments to configure.
";
|