projects/aports·blob v2.27.2 · refs

112 lines · 2.8 KiB

1
2PACKAGE := abuild
3VERSION := 2.27.2
4
5prefix ?= /usr
6bindir ?= $(prefix)/bin
7sysconfdir ?= /etc
8datadir ?= $(prefix)/share/$(PACKAGE)
9abuildrepo ?= ~/.cache/abuild
10
11SCRIPTS := abuild abuild-keygen abuild-sign newapkbuild \
12 abump apkgrel buildlab apkbuild-cpan checkapk \
13 apkbuild-gem-resolver
14USR_BIN_FILES := $(SCRIPTS) abuild-tar abuild-sudo abuild-fetch
15SAMPLES := sample.APKBUILD sample.initd sample.confd \
16 sample.pre-install sample.post-install
17AUTOTOOLS_TOOLCHAIN_FILES := config.sub
18
19SCRIPT_SOURCES := $(addsuffix .in,$(SCRIPTS))
20
21GIT_REV := $(shell test -d .git && git describe || echo exported)
22ifneq ($(GIT_REV), exported)
23FULL_VERSION := $(patsubst $(PACKAGE)-%,%,$(GIT_REV))
24FULL_VERSION := $(patsubst v%,%,$(FULL_VERSION))
25else
26FULL_VERSION := $(VERSION)
27endif
28
29CHMOD := chmod
30SED := sed
31TAR := tar
32LINK = $(CC) $(OBJS-$@) -o $@ $(LDFLAGS) $(LDFLAGS-$@) $(LIBS-$@)
33
34SED_REPLACE := -e 's:@VERSION@:$(FULL_VERSION):g' \
35 -e 's:@prefix@:$(prefix):g' \
36 -e 's:@sysconfdir@:$(sysconfdir):g' \
37 -e 's:@datadir@:$(datadir):g' \
38 -e 's:@abuildrepo@:$(abuildrepo):g'
39
40SSL_CFLAGS ?= $(shell pkg-config --cflags openssl)
41SSL_LDFLAGS ?= $(shell pkg-config --cflags openssl)
42SSL_LIBS ?= $(shell pkg-config --libs openssl)
43
44
45OBJS-abuild-tar = abuild-tar.o
46CFLAGS-abuild-tar.o = $(SSL_CFLAGS)
47LDFLAGS-abuild-tar = $(SSL_LDFLAGS)
48LIBS-abuild-tar = $(SSL_LIBS)
49
50OBJS-abuild-sudo = abuild-sudo.o
51OBJS-abuild-fetch = abuild-fetch.o
52
53.SUFFIXES: .sh.in .in
54%.sh: %.sh.in
55 ${SED} ${SED_REPLACE} ${SED_EXTRA} $< > $@
56 ${CHMOD} +x $@
57
58%: %.in
59 ${SED} ${SED_REPLACE} ${SED_EXTRA} $< > $@
60 ${CHMOD} +x $@
61
62P=$(PACKAGE)-$(VERSION)
63
64all: $(USR_BIN_FILES) functions.sh
65
66clean:
67 @rm -f $(USR_BIN_FILES) functions.sh
68
69%.o: %.c
70 $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS-$@) -o $@ -c $<
71
72abuild-sudo: abuild-sudo.o
73 $(LINK)
74
75abuild-tar: abuild-tar.o
76 $(LINK)
77
78abuild-fetch: abuild-fetch.o
79 $(LINK)
80
81abuild-tar.static: abuild-tar.o
82 $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS-$@) -o $@ -static $(LIBS-$@) $^
83
84help:
85 @echo "$(P) makefile"
86 @echo "usage: make install [ DESTDIR=<path> ]"
87
88install: $(USR_BIN_FILES) $(SAMPLES) abuild.conf functions.sh
89 install -d $(DESTDIR)/$(bindir) $(DESTDIR)/$(sysconfdir) \
90 $(DESTDIR)/$(datadir)
91 for i in $(USR_BIN_FILES); do\
92 install -m 755 $$i $(DESTDIR)/$(bindir)/$$i;\
93 done
94 chmod 4111 $(DESTDIR)/$(prefix)/bin/abuild-sudo
95 for i in adduser addgroup apk; do \
96 ln -fs abuild-sudo $(DESTDIR)/$(bindir)/abuild-$$i; \
97 done
98 if [ -n "$(DESTDIR)" ] || [ ! -f "/$(sysconfdir)"/abuild.conf ]; then\
99 cp abuild.conf $(DESTDIR)/$(sysconfdir)/; \
100 fi
101 cp $(SAMPLES) $(DESTDIR)/$(prefix)/share/abuild/
102 cp $(AUTOTOOLS_TOOLCHAIN_FILES) $(DESTDIR)/$(prefix)/share/abuild/
103 cp functions.sh $(DESTDIR)/$(datadir)/
104
105.gitignore: Makefile
106 echo "*.tar.bz2" > $@
107 for i in $(USR_BIN_FILES); do\
108 echo $$i >>$@;\
109 done
110
111
112.PHONY: install