summaryrefslogtreecommitdiff
path: root/scripts/Makefile.am
blob: 802b8f4e75cee3a6215e19dd535418a33f1b544c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# enforce that all scripts have a --help and --version option
AUTOMAKE_OPTIONS = std-options

SUBDIRS = po

bin_SCRIPTS \
  $(OURSCRIPTS)

OURSCRIPTS \
  makepkg \
  pacman-db-upgrade \
  pacman-key \
  pacman-optimize \
  pkgdelta \
  rankmirrors \
  repo-add

EXTRA_DIST \
  makepkg.sh.in \
  pacman-db-upgrade.sh.in \
  pacman-key.sh.in \
  pacman-optimize.sh.in \
  pkgdelta.sh.in \
  rankmirrors.sh.in \
  repo-add.sh.in \
  $(LIBRARY)

LIBRARY \
  library/output_format.sh \
  library/parse_options.sh

# Files that should be removed, but which Automake does not know.
MOSTLYCLEANFILES $(bin_SCRIPTS)

if USE_GIT_VERSION
GIT_VERSION := $(shell sh -c 'git describe --abbrev=4 --dirty | sed s/^v//')
REAL_PACKAGE_VERSION $(GIT_VERSION)
else
REAL_PACKAGE_VERSION $(PACKAGE_VERSION)
endif

#### Taken from the autoconf scripts Makefile.am ####
edit = sed \
  -e 's|@localedir[@]|$(localedir)|g' \
  -e 's|@sysconfdir[@]|$(sysconfdir)|g' \
  -e 's|@localstatedir[@]|$(localstatedir)|g' \
  -e 's|@prefix[@]|$(prefix)|g' \
  -e '1s|!/bin/bash|!$(BASH_SHELL)|g' \
  -e 's|@PACKAGE_VERSION[@]|$(REAL_PACKAGE_VERSION)|g' \
  -e 's|@PACKAGE_BUGREPORT[@]|$(PACKAGE_BUGREPORT)|g' \
  -e 's|@PACKAGE_NAME[@]|$(PACKAGE_NAME)|g' \
  -e 's|@BUILDSCRIPT[@]|$(BUILDSCRIPT)|g' \
  -e 's|@SIZECMD[@]|$(SIZECMD)|g' \
  -e 's|@SEDINPLACE[@]|$(SEDINPLACE)|g' \
  -e 's|@DUPATH[@]|$(DUPATH)|g' \
  -e 's|@SCRIPTNAME[@]|$@|g' \
  -e 's|@configure_input[@]|Generated from $@.sh.in; do not edit by hand.|g'

## All the scripts depend on Makefile so that they are rebuilt when the
## prefix etc. changes. Use chmod -w to prevent people from editing the
## wrong file by accident.
# two 'test' lines- make sure we can handle both sh and py type scripts
# third 'test' line- make sure one of the two checks succeeded
$(OURSCRIPTS): Makefile
  @echo '    ' GEN $@;
  @$(RM) $@
  @test -f $(srcdir)/$@.sh.in && m4 -P -I $(srcdir) $(srcdir)/$@.sh.in | $(edit) >$@
  @chmod +x $@
  @chmod a-w $@

makepkg: \
  $(srcdir)/makepkg.sh.in \
  $(srcdir)/library/parse_options.sh

pacman-db-upgrade: \
  $(srcdir)/pacman-db-upgrade.sh.in \
  $(srcdir)/library/output_format.sh

pacman-key: \
  $(srcdir)/pacman-key.sh.in \
  $(srcdir)/library/output_format.sh \
  $(srcdir)/library/parse_options.sh

pacman-optimize: \
  $(srcdir)/pacman-optimize.sh.in \
  $(srcdir)/library/output_format.sh

pkgdelta: \
  $(srcdir)/pkgdelta.sh.in \
  $(srcdir)/library/output_format.sh

rankmirrors: $(srcdir)/rankmirrors.sh.in

repo-add: \
  $(srcdir)/repo-add.sh.in \
  $(srcdir)/library/output_format.sh

repo-remove: $(srcdir)/repo-add.sh.in
  $(RM) repo-remove
  $(LN_S) repo-add repo-remove

repo-elephant: $(srcdir)/repo-add.sh.in
  $(RM) repo-elephant
  $(LN_S) repo-add repo-elephant

install-data-hook:
  cd $(DESTDIR)$(bindir) && \
    ( $(LN_S) repo-add repo-elephant || \
    ln repo-add repo-elephant || \
    cp repo-add repo-elephant )
  cd $(DESTDIR)$(bindir) && \
    ( $(LN_S) repo-add repo-remove || \
    ln repo-add repo-remove || \
    cp repo-add repo-remove )

uninstall-hook:
  cd $(DESTDIR)$(bindir) && \
    $(RM) repo-remove repo-elephant

# vim:set ts=2 sw=2 noet: