diff --git a/Makefile b/Makefile index 8d458e8..babb41e 100644 --- a/Makefile +++ b/Makefile @@ -72,6 +72,7 @@ dist: $(PACKAGE)-$(VERSION)/tests/plugin/project.conf \ $(PACKAGE)-$(VERSION)/tests/plugin/Makefile.Darwin \ $(PACKAGE)-$(VERSION)/tests/plugin/Makefile.NetBSD \ + $(PACKAGE)-$(VERSION)/tests/script/Makefile.NetBSD \ $(PACKAGE)-$(VERSION)/tests/project.conf \ $(PACKAGE)-$(VERSION)/tools/pkg-config.c \ $(PACKAGE)-$(VERSION)/tools/Makefile \ diff --git a/src/makefile.c b/src/makefile.c index c6a2555..ce0ad74 100644 --- a/src/makefile.c +++ b/src/makefile.c @@ -1410,6 +1410,7 @@ static int _script_depends(Config * config, FILE * fp, String const * target); static int _target_script(Configure * configure, FILE * fp, String const * target) { + String const * prefix; String const * script; 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); _script_depends(configure->config, fp, target); 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); return 0; } @@ -1657,6 +1660,7 @@ static int _write_clean(Configure * configure, FILE * fp) static int _clean_targets(Config * config, FILE * fp) { + String const * prefix; String const * p; String * targets; String * q; @@ -1696,8 +1700,12 @@ static int _clean_targets(Config * config, FILE * fp) && strcmp(p, "script") == 0 && (p = config_get(config, targets, "script")) != 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') break; targets[i] = c; diff --git a/tests/Makefile b/tests/Makefile index 2e11ceb..75d298e 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -10,7 +10,7 @@ INSTALL = install 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" clean: diff --git a/tests/project.conf b/tests/project.conf index 879b177..26a70a2 100644 --- a/tests/project.conf +++ b/tests/project.conf @@ -1,7 +1,7 @@ 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] type=script 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 diff --git a/tests/script/Makefile.NetBSD b/tests/script/Makefile.NetBSD new file mode 100644 index 0000000..4f510fa --- /dev/null +++ b/tests/script/Makefile.NetBSD @@ -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 diff --git a/tests/script/project.conf b/tests/script/project.conf new file mode 100644 index 0000000..2c3effa --- /dev/null +++ b/tests/script/project.conf @@ -0,0 +1,8 @@ +targets=test +dist=Makefile + +[test] +type=script +script=./script.sh +prefix=/somewhere/else +install=/somewhere/else/again diff --git a/tests/tests.sh b/tests/tests.sh index f3790c6..8fe2b02 100755 --- a/tests/tests.sh +++ b/tests/tests.sh @@ -102,5 +102,6 @@ _test "Darwin" "plugin" _test "NetBSD" "binary" _test "NetBSD" "library" _test "NetBSD" "plugin" +_test "NetBSD" "script" _test "Windows" "binary" _test "Windows" "library") > "$target"