Merge branch 'maint'
[gc-utils.git] / src / Makefile
blobf5574e9ef096df3a5ebfd23bd72af126cff2aa0d
2 # gc-utils script install program
5 PROGNAME = gc-utils
7 prefix = $(HOME)
8 export prefix DESTDIR INSTALL VERSION
10 bindir = $(prefix)/bin
11 libdir = $(prefix)/lib
13 bindir_SQ = $(subst ','\'',$(bindir))
14 libdir_SQ = $(subst ','\'',$(libdir))
15 VERSION_SQ = $(subst .,\.,$(VERSION))
16 DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
18 INSTALL = install
19 RM = rm
20 MKINSTALLDIRS = mkdir -p
22 scripts_src = gc-import.sh gc-update.sh gc-commit.sh gc-multi-commit.sh gc-utils.sh
23 scripts = $(scripts_src:%.sh=../build/%)
24 libraries_src = gc-sh-setup.sh
25 libraries = $(libraries_src:%.sh=../build/%)
27 ifndef V
28 QUIET_RM = echo ' ' RM $f;
29 QUIET_GEN = @echo ' ' GEN $(@:../build/%=%);
30 QUIET_INSTALL = echo ' ' INS $(f:../build/%=%);
31 endif
33 define generate-script
34 cp $(@:../build/%=%.sh) $@ && sed -i -e 's,\$$VERSION\$$,$(VERSION_SQ),g;s,\$$PROGNAME\$$,$(PROGNAME),g;s,\$$LIBDIR\$$,$(DESTDIR_SQ)$(libdir_SQ),g' $@
35 endef
37 .PHONY: gen install uninstall
39 gen:: $(scripts)
41 $(scripts): $(libraries)
42 $(QUIET_GEN) $(generate-script)
44 $(libraries):
45 $(QUIET_GEN) $(generate-script)
47 install: $(scripts) install-lib
48 @$(MKINSTALLDIRS) $(DESTDIR_SQ)$(bindir_SQ)
49 ifndef V
50 @$(foreach f, $(scripts), $(QUIET_INSTALL) $(INSTALL) $f "$(DESTDIR_SQ)$(bindir_SQ)/$(f:../build/%=%)" ;)
51 else
52 $(foreach f, $(scripts), $(INSTALL) $f "$(DESTDIR_SQ)$(bindir_SQ)/$(f:../build/%=%)" ;)
53 endif
55 install-lib: $(libraries)
56 @$(MKINSTALLDIRS) $(DESTDIR_SQ)$(libdir_SQ)
57 ifndef V
58 @$(foreach f, $(libraries), $(QUIET_INSTALL) $(INSTALL) $f "$(DESTDIR_SQ)$(libdir_SQ)/$(f:../build/%=%)" ;)
59 else
60 $(foreach f, $(libraries), $(INSTALL) $f "$(DESTDIR_SQ)$(libdir_SQ)/$(f:../build/%=%)" ;)
61 endif
63 uninstall:
64 @$(foreach f, $(scripts_src:%.sh=%), $(RM) '$(DESTDIR_SQ)$(bindir_SQ)/$f' && echo ' ' UNINS $f ;)
65 @$(foreach f, $(libraries_src:%.sh=%), $(RM) '$(DESTDIR_SQ)$(libdir_SQ)/$f' && echo ' ' UNINS $f ;)