scripts: refactor output formatting functions
[pacman-ng.git] / scripts / Makefile.am
blob1abf9c4c7652f8edaa377d296cc2d240e54400ed
1 # enforce that all scripts have a --help and --version option
2 AUTOMAKE_OPTIONS = std-options
4 bin_SCRIPTS = \
5         $(OURSCRIPTS) \
6         repo-remove
8 OURSCRIPTS = \
9         makepkg \
10         pacman-db-upgrade \
11         pacman-key \
12         pacman-optimize \
13         pkgdelta \
14         rankmirrors \
15         repo-add
17 EXTRA_DIST = \
18         makepkg.sh.in \
19         pacman-db-upgrade.sh.in \
20         pacman-key.sh.in \
21         pacman-optimize.sh.in \
22         pkgdelta.sh.in \
23         rankmirrors.sh.in \
24         repo-add.sh.in \
25         $(LIBRARY)
27 LIBRARY = \
28         library/output_format.sh \
29         library/parse_options.sh
31 # Files that should be removed, but which Automake does not know.
32 MOSTLYCLEANFILES = $(bin_SCRIPTS) *.tmp
34 if USE_GIT_VERSION
35 GIT_VERSION := $(shell sh -c 'git describe --abbrev=4 --dirty | sed s/^v//')
36 REAL_PACKAGE_VERSION = $(GIT_VERSION)
37 else
38 REAL_PACKAGE_VERSION = $(PACKAGE_VERSION)
39 endif
41 #### Taken from the autoconf scripts Makefile.am ####
42 edit = sed \
43         -e 's|@localedir[@]|$(localedir)|g' \
44         -e 's|@sysconfdir[@]|$(sysconfdir)|g' \
45         -e 's|@localstatedir[@]|$(localstatedir)|g' \
46         -e 's|@prefix[@]|$(prefix)|g' \
47         -e 's|@BASH_SHELL[@]|$(BASH_SHELL)|g' \
48         -e 's|@PACKAGE_VERSION[@]|$(REAL_PACKAGE_VERSION)|g' \
49         -e 's|@PACKAGE_BUGREPORT[@]|$(PACKAGE_BUGREPORT)|g' \
50         -e 's|@PACKAGE_NAME[@]|$(PACKAGE_NAME)|g' \
51         -e 's|@BUILDSCRIPT[@]|$(BUILDSCRIPT)|g' \
52         -e 's|@SIZECMD[@]|$(SIZECMD)|g' \
53         -e 's|@SEDINPLACE[@]|$(SEDINPLACE)|g' \
54         -e 's|@DUPATH[@]|$(DUPATH)|g' \
55         -e 's|@SCRIPTNAME[@]|$@|g' \
56         -e 's|@configure_input[@]|Generated from $@.sh.in; do not edit by hand.|g'
58 ## All the scripts depend on Makefile so that they are rebuilt when the
59 ## prefix etc. changes. Use chmod -w to prevent people from editing the
60 ## wrong file by accident.
61 # two 'test' lines- make sure we can handle both sh and py type scripts
62 # third 'test' line- make sure one of the two checks succeeded
63 $(OURSCRIPTS): Makefile
64         @echo '    ' GEN $@;
65         @rm -f $@ $@.tmp
66         @test -f $(srcdir)/$@.sh.in && m4 -P -I $(srcdir) $(srcdir)/$@.sh.in | $(edit) >$@.tmp || true
67         @test -f $(srcdir)/$@.py.in && m4 -P -I $(srcdir) $(srcdir)/$@.py.in | $(edit) >$@.tmp || true
68         @test -f $@.tmp || false
69         @chmod +x $@.tmp
70         @chmod a-w $@.tmp
71         @mv $@.tmp $@
73 makepkg: \
74         $(srcdir)/makepkg.sh.in \
75         $(srcdir)/library/parse_options.sh
77 pacman-db-upgrade: \
78         $(srcdir)/pacman-db-upgrade.sh.in \
79         $(srcdir)/library/output_format.sh
81 pacman-key: \
82         $(srcdir)/pacman-key.sh.in \
83         $(srcdir)/library/output_format.sh
85 pacman-optimize: $(srcdir)/pacman-optimize.sh.in
87 pkgdelta: \
88         $(srcdir)/pkgdelta.sh.in \
89         $(srcdir)/library/output_format.sh
91 rankmirrors: $(srcdir)/rankmirrors.sh.in
93 repo-add: \
94         $(srcdir)/repo-add.sh.in \
95         $(srcdir)/library/output_format.sh
97 repo-remove: $(srcdir)/repo-add.sh.in
98         rm -f repo-remove
99         $(LN_S) repo-add repo-remove
101 # vim:set ts=2 sw=2 noet: