Let invididual scripted targets have a separate prefix

This commit is contained in:
Pierre Pronchery 2014-12-01 00:29:24 +01:00
parent ac8c7a11b9
commit 6a625dc18e
7 changed files with 53 additions and 6 deletions

View File

@ -72,6 +72,7 @@ dist:
$(PACKAGE)-$(VERSION)/tests/plugin/project.conf \ $(PACKAGE)-$(VERSION)/tests/plugin/project.conf \
$(PACKAGE)-$(VERSION)/tests/plugin/Makefile.Darwin \ $(PACKAGE)-$(VERSION)/tests/plugin/Makefile.Darwin \
$(PACKAGE)-$(VERSION)/tests/plugin/Makefile.NetBSD \ $(PACKAGE)-$(VERSION)/tests/plugin/Makefile.NetBSD \
$(PACKAGE)-$(VERSION)/tests/script/Makefile.NetBSD \
$(PACKAGE)-$(VERSION)/tests/project.conf \ $(PACKAGE)-$(VERSION)/tests/project.conf \
$(PACKAGE)-$(VERSION)/tools/pkg-config.c \ $(PACKAGE)-$(VERSION)/tools/pkg-config.c \
$(PACKAGE)-$(VERSION)/tools/Makefile \ $(PACKAGE)-$(VERSION)/tools/Makefile \

View File

@ -1410,6 +1410,7 @@ static int _script_depends(Config * config, FILE * fp, String const * target);
static int _target_script(Configure * configure, FILE * fp, static int _target_script(Configure * configure, FILE * fp,
String const * target) String const * target)
{ {
String const * prefix;
String const * script; String const * script;
if((script = config_get(configure->config, target, "script")) == NULL) if((script = config_get(configure->config, target, "script")) == NULL)
@ -1427,7 +1428,9 @@ static int _target_script(Configure * configure, FILE * fp,
fprintf(fp, "\n$(OBJDIR)%s:", target); fprintf(fp, "\n$(OBJDIR)%s:", target);
_script_depends(configure->config, fp, target); _script_depends(configure->config, fp, target);
fputc('\n', fp); fputc('\n', fp);
fprintf(fp, "\t%s -P \"$(PREFIX)\" -- \"$(OBJDIR)%s\"\n", script, if((prefix = config_get(configure->config, target, "prefix")) == NULL)
prefix = "$(PREFIX)";
fprintf(fp, "\t%s -P \"%s\" -- \"$(OBJDIR)%s\"\n", script, prefix,
target); target);
return 0; return 0;
} }
@ -1657,6 +1660,7 @@ static int _write_clean(Configure * configure, FILE * fp)
static int _clean_targets(Config * config, FILE * fp) static int _clean_targets(Config * config, FILE * fp)
{ {
String const * prefix;
String const * p; String const * p;
String * targets; String * targets;
String * q; String * q;
@ -1696,8 +1700,12 @@ static int _clean_targets(Config * config, FILE * fp)
&& strcmp(p, "script") == 0 && strcmp(p, "script") == 0
&& (p = config_get(config, targets, "script")) && (p = config_get(config, targets, "script"))
!= NULL) != NULL)
fprintf(fp, "\t%s%s%s%s\n", p, " -c -P \"$(PREFIX)\"" {
" -- \"", targets, "\""); if((prefix = config_get(config, targets, "prefix")) == NULL)
prefix = "$(PREFIX)";
fprintf(fp, "\t%s%s%s%s%s%s\n", p, " -c -P \"", prefix,
"\" -- \"", targets, "\"");
}
if(c == '\0') if(c == '\0')
break; break;
targets[i] = c; targets[i] = c;

View File

@ -10,7 +10,7 @@ INSTALL = install
all: $(TARGETS) all: $(TARGETS)
$(OBJDIR)tests.log: binary/project.conf binary/Makefile.Darwin binary/Makefile.NetBSD binary/Makefile.Windows library/project.conf library/Makefile.Darwin library/Makefile.NetBSD library/Makefile.Windows plugin/Makefile.Darwin plugin/Makefile.NetBSD tests.sh $(OBJDIR)tests.log: binary/project.conf binary/Makefile.Darwin binary/Makefile.NetBSD binary/Makefile.Windows library/project.conf library/Makefile.Darwin library/Makefile.NetBSD library/Makefile.Windows plugin/Makefile.Darwin plugin/Makefile.NetBSD script/Makefile.NetBSD tests.sh
./tests.sh -P "$(PREFIX)" -- "$(OBJDIR)tests.log" ./tests.sh -P "$(PREFIX)" -- "$(OBJDIR)tests.log"
clean: clean:

View File

@ -1,7 +1,7 @@
targets=tests.log targets=tests.log
dist=Makefile,tests.sh,binary/project.conf,binary/Makefile.Darwin,binary/Makefile.NetBSD,binary/Makefile.Windows,library/project.conf,library/Makefile.Darwin,library/Makefile.NetBSD,library/Makefile.Windows,plugin/project.conf,plugin/Makefile.Darwin,plugin/Makefile.NetBSD dist=Makefile,tests.sh,binary/project.conf,binary/Makefile.Darwin,binary/Makefile.NetBSD,binary/Makefile.Windows,library/project.conf,library/Makefile.Darwin,library/Makefile.NetBSD,library/Makefile.Windows,plugin/project.conf,plugin/Makefile.Darwin,plugin/Makefile.NetBSD,script/Makefile.NetBSD
[tests.log] [tests.log]
type=script type=script
script=./tests.sh script=./tests.sh
depends=binary/project.conf,binary/Makefile.Darwin,binary/Makefile.NetBSD,binary/Makefile.Windows,library/project.conf,library/Makefile.Darwin,library/Makefile.NetBSD,library/Makefile.Windows,plugin/Makefile.Darwin,plugin/Makefile.NetBSD,tests.sh depends=binary/project.conf,binary/Makefile.Darwin,binary/Makefile.NetBSD,binary/Makefile.Windows,library/project.conf,library/Makefile.Darwin,library/Makefile.NetBSD,library/Makefile.Windows,plugin/Makefile.Darwin,plugin/Makefile.NetBSD,script/Makefile.NetBSD,tests.sh

View File

@ -0,0 +1,29 @@
TARGETS = $(OBJDIR)test
OBJDIR =
PREFIX = /usr/local
DESTDIR =
RM = rm -f
LN = ln -f
MKDIR = mkdir -m 0755 -p
INSTALL = install
all: $(TARGETS)
$(OBJDIR)test:
./script.sh -P "/somewhere/else" -- "$(OBJDIR)test"
clean:
$(RM) -- $(test_OBJS)
./script.sh -c -P "/somewhere/else" -- "test"
distclean: clean
$(RM) -- $(TARGETS)
install: $(TARGETS)
./script.sh -P "$(DESTDIR)/somewhere/else/again" -i -- "$(OBJDIR)test"
uninstall:
./script.sh -P "$(DESTDIR)/somewhere/else/again" -u -- "test"
.PHONY: all clean distclean install uninstall

View File

@ -0,0 +1,8 @@
targets=test
dist=Makefile
[test]
type=script
script=./script.sh
prefix=/somewhere/else
install=/somewhere/else/again

View File

@ -102,5 +102,6 @@ _test "Darwin" "plugin"
_test "NetBSD" "binary" _test "NetBSD" "binary"
_test "NetBSD" "library" _test "NetBSD" "library"
_test "NetBSD" "plugin" _test "NetBSD" "plugin"
_test "NetBSD" "script"
_test "Windows" "binary" _test "Windows" "binary"
_test "Windows" "library") > "$target" _test "Windows" "library") > "$target"