define \n
endef
PREFIX ?= /usr
VENDOR ?= $(shell dpkg-vendor --query Vendor | tr '[:upper:]' '[:lower:]')
CPPFLAGS = $(shell dpkg-buildflags --get CPPFLAGS)
CFLAGS = $(shell dpkg-buildflags --get CFLAGS)
CFLAGS += -Wall -Wextra -g -O2 -std=gnu99
LDFLAGS = $(shell dpkg-buildflags --get LDFLAGS)
build: debian-distro-info ubuntu-distro-info
%-distro-info: %-distro-info.c distro-info-util.*
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $<
install: debian-distro-info ubuntu-distro-info
install -d $(DESTDIR)$(PREFIX)/bin
install -m 755 $^ $(DESTDIR)$(PREFIX)/bin
ln -s $(VENDOR)-distro-info $(DESTDIR)$(PREFIX)/bin/distro-info
install -d $(DESTDIR)$(PREFIX)/share/distro-info
install -m 644 shunit2-helper-functions.sh $(DESTDIR)$(PREFIX)/share/distro-info
$(foreach distro,debian ubuntu,sed -e 's@^\(COMMAND=\"\).*/\(.*-distro-info\"\)$$@\1\2@' \
test-$(distro)-distro-info > $(DESTDIR)$(PREFIX)/share/distro-info/test-$(distro)-distro-info$(\n) \
chmod 755 $(DESTDIR)$(PREFIX)/share/distro-info/test-$(distro)-distro-info$(\n))
install -d $(DESTDIR)$(PREFIX)/share/man/man1
install -m 644 $(wildcard doc/*.1) $(DESTDIR)$(PREFIX)/share/man/man1
install -d $(DESTDIR)$(PREFIX)/share/perl5/Debian
install -m 644 $(wildcard perl/Debian/*.pm) $(DESTDIR)$(PREFIX)/share/perl5/Debian
cd python && python setup.py install --root="$(DESTDIR)" --no-compile --install-layout=deb
cd python && python3 setup.py install --root="$(DESTDIR)" --no-compile --install-layout=deb
test: test-commandline test-perl test-python
test-commandline: debian-distro-info ubuntu-distro-info
./test-debian-distro-info
./test-ubuntu-distro-info
test-perl:
cd perl && ./test.pl
test-python:
$(foreach python,$(shell pyversions -r && py3versions -r),cd python && $(python) setup.py test$(\n))
clean:
rm -rf debian-distro-info ubuntu-distro-info python/build python/*.egg-info
find python -name '*.pyc' -delete
.PHONY: build clean install test test-commandline test-perl test-python