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