Blame Makefile

rpm-build b051e4
PYTHON ?= python3
rpm-build b051e4
PYTHONSITEPACKAGES := $(shell $(PYTHON) -c 'import site; print(site.getsitepackages()[0])')
rpm-build b051e4
PYTHONINCLUDE := $(shell $(PYTHON)-config --includes)
rpm-build b051e4
rpm-build b051e4
VERSION=1.2.3
rpm-build b051e4
rpm-build b051e4
ifneq (,$(filter sparc64 ppc64 ppc64le x86_64 s390x aarch64,$(shell uname -m)))
rpm-build b051e4
LIBDIR = lib64
rpm-build b051e4
else
rpm-build b051e4
LIBDIR = lib
rpm-build b051e4
endif
rpm-build b051e4
rpm-build b051e4
CFLAGS += -std=gnu11 -Wall -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -fPIC $(PYTHONINCLUDE)
rpm-build b051e4
rpm-build b051e4
OBJECTS = md5.o libimplantisomd5.o checkisomd5.o implantisomd5
rpm-build b051e4
SOURCES = $(patsubst %.o,%.c,$(OBJECTS))
rpm-build b051e4
LDFLAGS += -fPIC
rpm-build b051e4
rpm-build b051e4
PYOBJS = pyisomd5sum.o libcheckisomd5.a libimplantisomd5.a
rpm-build b051e4
rpm-build b051e4
all: implantisomd5 checkisomd5 pyisomd5sum.so libimplantisomd5.a libcheckisomd5.a
rpm-build b051e4
rpm-build b051e4
%.o: %.c
rpm-build b051e4
	$(CC) $(CPPFLAGS) $(CFLAGS) -c -O3 -o $@ $<
rpm-build b051e4
rpm-build b051e4
implantisomd5: implantisomd5.o libimplantisomd5.a
rpm-build b051e4
	$(CC) $(CPPFLAGS) $(CFLAGS) implantisomd5.o libimplantisomd5.a -lpopt $(LDFLAGS) -o implantisomd5
rpm-build b051e4
rpm-build b051e4
checkisomd5: checkisomd5.o libcheckisomd5.a
rpm-build b051e4
	$(CC) $(CPPFLAGS) $(CFLAGS) checkisomd5.o libcheckisomd5.a -lpopt $(LDFLAGS) -o checkisomd5
rpm-build b051e4
rpm-build b051e4
libimplantisomd5.a: libimplantisomd5.a(libimplantisomd5.o md5.o utilities.o)
rpm-build b051e4
rpm-build b051e4
libcheckisomd5.a: libcheckisomd5.a(libcheckisomd5.o md5.o utilities.o)
rpm-build b051e4
rpm-build b051e4
pyisomd5sum.so: $(PYOBJS)
rpm-build b051e4
	$(CC) $(CPPFLAGS) $(CFLAGS) -shared -g -fpic $(PYOBJS) $(LDFLAGS) -o pyisomd5sum.so
rpm-build b051e4
rpm-build b051e4
install: all install-bin install-python install-devel
rpm-build b051e4
rpm-build b051e4
install-bin:
rpm-build b051e4
	install -d -m 0755 $(DESTDIR)/usr/bin
rpm-build b051e4
	install -d -m 0755 $(DESTDIR)/usr/share/man/man1
rpm-build b051e4
	install -m 0755 implantisomd5 $(DESTDIR)/usr/bin
rpm-build b051e4
	install -m 0755 checkisomd5 $(DESTDIR)/usr/bin
rpm-build b051e4
	install -m 0644 implantisomd5.1 $(DESTDIR)/usr/share/man/man1
rpm-build b051e4
	install -m 0644 checkisomd5.1 $(DESTDIR)/usr/share/man/man1
rpm-build b051e4
rpm-build b051e4
install-python:
rpm-build b051e4
	install -d -m 0755 $(DESTDIR)$(PYTHONSITEPACKAGES)
rpm-build b051e4
	install -m 0755 pyisomd5sum.so $(DESTDIR)$(PYTHONSITEPACKAGES)
rpm-build b051e4
rpm-build b051e4
install-devel:
rpm-build b051e4
	install -d -m 0755 $(DESTDIR)/usr/include
rpm-build b051e4
	install -d -m 0755 $(DESTDIR)/usr/$(LIBDIR)
rpm-build b051e4
	install -d -m 0755 $(DESTDIR)/usr/share/pkgconfig
rpm-build b051e4
	install -m 0644 libimplantisomd5.h $(DESTDIR)/usr/include/
rpm-build b051e4
	install -m 0644 libcheckisomd5.h $(DESTDIR)/usr/include/
rpm-build b051e4
	install -m 0644 libimplantisomd5.a $(DESTDIR)/usr/$(LIBDIR)
rpm-build b051e4
	install -m 0644 libcheckisomd5.a $(DESTDIR)/usr/$(LIBDIR)
rpm-build b051e4
	sed "s#@VERSION@#${VERSION}#g; s#@includedir@#/usr/include#g; s#@libdir@#/usr/${LIBDIR}#g" isomd5sum.pc.in > ${DESTDIR}/usr/share/pkgconfig/isomd5sum.pc
rpm-build b051e4
rpm-build b051e4
clean:
rpm-build b051e4
	rm -f *.o *.so *.pyc *.a .depend *~
rpm-build b051e4
	rm -f implantisomd5 checkisomd5 
rpm-build b051e4
rpm-build b051e4
tag:
rpm-build b051e4
	@git tag -a -m "Tag as $(VERSION)" -f $(VERSION)
rpm-build b051e4
	@echo "Tagged as $(VERSION)"
rpm-build b051e4
rpm-build b051e4
archive:
rpm-build b051e4
	@git archive --format=tar --prefix=isomd5sum-$(VERSION)/ HEAD |bzip2 > isomd5sum-$(VERSION).tar.bz2
rpm-build b051e4
	@echo "The final archive is in isomd5sum-$(VERSION).tar.bz2"
rpm-build b051e4
rpm-build b051e4
test:
rpm-build b051e4
	./testpyisomd5sum.py