2 # gc-utils script install program
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))
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/%)
28 QUIET_RM = echo ' ' RM $f;
29 QUIET_GEN = @echo ' ' GEN $(@:../build/%=%);
30 QUIET_INSTALL = echo ' ' INS $(f:../build/%=%);
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
' $@
37 .PHONY: gen install uninstall
41 $(scripts): $(libraries)
42 $(QUIET_GEN) $(generate-script)
45 $(QUIET_GEN) $(generate-script)
47 install: $(scripts) install-lib
48 @$(MKINSTALLDIRS) $(DESTDIR_SQ)$(bindir_SQ)
50 @$(foreach f, $(scripts), $(QUIET_INSTALL) $(INSTALL) $f "$(DESTDIR_SQ)$(bindir_SQ)/$(f:../build/%=%)" ;)
52 $(foreach f, $(scripts), $(INSTALL) $f "$(DESTDIR_SQ)$(bindir_SQ)/$(f:../build/%=%)" ;)
55 install-lib: $(libraries)
56 @$(MKINSTALLDIRS) $(DESTDIR_SQ)$(libdir_SQ)
58 @$(foreach f, $(libraries), $(QUIET_INSTALL) $(INSTALL) $f "$(DESTDIR_SQ)$(libdir_SQ)/$(f:../build/%=%)" ;)
60 $(foreach f, $(libraries), $(INSTALL) $f "$(DESTDIR_SQ)$(libdir_SQ)/$(f:../build/%=%)" ;)
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 ;)