Use a configuration file for paths to programs

This commit is contained in:
Pierre Pronchery 2017-11-09 04:42:43 +01:00
parent 666bcc29c0
commit ad6257b5c4
4 changed files with 22 additions and 1 deletions

6
data/configure.conf Normal file
View File

@ -0,0 +1,6 @@
[programs]
ccshared=$(CC) -shared
cxx=c++
ln=ln -f
mkdir=mkdir -m 0755 -p
rm=rm -f

4
data/project.conf Normal file
View File

@ -0,0 +1,4 @@
dist=Makefile,configure.conf
[configure.conf]
install=$(PREFIX)/share/configure

View File

@ -2,7 +2,7 @@ package=configure
version=0.2.3 version=0.2.3
config=h,sh config=h,sh
subdirs=doc,src,tests,tools subdirs=data,doc,src,tests,tools
dist=Makefile,AUTHORS,BUGS,CHANGES,COPYING,config.h,config.sh,INSTALL.md,README.md dist=Makefile,AUTHORS,BUGS,CHANGES,COPYING,config.h,config.sh,INSTALL.md,README.md
[AUTHORS] [AUTHORS]

View File

@ -45,6 +45,13 @@
# define PROGNAME PACKAGE # define PROGNAME PACKAGE
#endif #endif
#ifndef PREFIX
# define PREFIX "/usr/local"
#endif
#ifndef DATADIR
# define DATADIR PREFIX "/share"
#endif
/* Configure */ /* Configure */
/* private */ /* private */
@ -323,6 +330,7 @@ static int _configure_detect_programs(Configure * configure)
{ {
int ret = 0; int ret = 0;
String const section[] = "programs"; String const section[] = "programs";
String const filename[] = DATADIR "/" PACKAGE "/" PACKAGE ".conf";
struct struct
{ {
String const * name; String const * name;
@ -343,6 +351,9 @@ static int _configure_detect_programs(Configure * configure)
if(config_set(configure->programs, section, programs[i].name, if(config_set(configure->programs, section, programs[i].name,
programs[i].program) != 0) programs[i].program) != 0)
return -1; return -1;
if(config_load(configure->programs, filename) != 0)
configure_error(DATADIR "/" PACKAGE "/" PACKAGE ".conf: "
"Could not load program definitions", 0);
/* platform-specific */ /* platform-specific */
switch(configure->os) switch(configure->os)
{ {