Jens Axboe | f93c84e | 2019-01-08 06:51:07 -0700 | [diff] [blame] | 1 | NAME=liburing |
| 2 | SPECFILE=$(NAME).spec |
| 3 | VERSION=$(shell awk '/Version:/ { print $$2 }' $(SPECFILE)) |
| 4 | TAG = $(NAME)-$(VERSION) |
| 5 | RPMBUILD=$(shell `which rpmbuild >&/dev/null` && echo "rpmbuild" || echo "rpm") |
| 6 | |
Shenghui Wang | 6cd873c | 2019-04-26 11:35:42 +0800 | [diff] [blame] | 7 | INSTALL=install |
Jens Axboe | f93c84e | 2019-01-08 06:51:07 -0700 | [diff] [blame] | 8 | |
| 9 | default: all |
| 10 | |
| 11 | all: |
| 12 | @$(MAKE) -C src |
Jens Axboe | baa8d24 | 2019-01-08 15:48:57 -0700 | [diff] [blame] | 13 | @$(MAKE) -C test |
Jens Axboe | 4916320 | 2019-04-17 17:38:14 +0000 | [diff] [blame] | 14 | @$(MAKE) -C examples |
| 15 | |
| 16 | runtests: |
| 17 | @$(MAKE) -C test runtests |
Jens Axboe | 4fb3c9e | 2019-10-24 19:19:49 -0600 | [diff] [blame] | 18 | runtests-loop: |
| 19 | @$(MAKE) -C test runtests-loop |
Jens Axboe | f93c84e | 2019-01-08 06:51:07 -0700 | [diff] [blame] | 20 | |
Jens Axboe | f16b83b | 2019-01-15 11:14:43 -0700 | [diff] [blame] | 21 | config-host.mak: configure |
| 22 | @if [ ! -e "$@" ]; then \ |
| 23 | echo "Running configure ..."; \ |
| 24 | ./configure; \ |
| 25 | else \ |
| 26 | echo "$@ is out-of-date, running configure"; \ |
| 27 | sed -n "/.*Configured with/s/[^:]*: //p" "$@" | sh; \ |
| 28 | fi |
| 29 | |
| 30 | ifneq ($(MAKECMDGOALS),clean) |
| 31 | include config-host.mak |
| 32 | endif |
| 33 | |
Stefan Hajnoczi | 3af7ea1 | 2019-07-24 09:24:47 +0100 | [diff] [blame] | 34 | %.pc: %.pc.in config-host.mak |
Stefan Hajnoczi | 1b049c1 | 2019-05-25 09:58:29 +0100 | [diff] [blame] | 35 | sed -e "s%@prefix@%$(prefix)%g" \ |
| 36 | -e "s%@libdir@%$(libdir)%g" \ |
| 37 | -e "s%@includedir@%$(includedir)%g" \ |
| 38 | -e "s%@NAME@%$(NAME)%g" \ |
| 39 | -e "s%@VERSION@%$(VERSION)%g" \ |
| 40 | $< >$@ |
| 41 | |
| 42 | install: $(NAME).pc |
Jens Axboe | f93c84e | 2019-01-08 06:51:07 -0700 | [diff] [blame] | 43 | @$(MAKE) -C src install prefix=$(DESTDIR)$(prefix) includedir=$(DESTDIR)$(includedir) libdir=$(DESTDIR)$(libdir) |
Stefan Hajnoczi | 1b049c1 | 2019-05-25 09:58:29 +0100 | [diff] [blame] | 44 | $(INSTALL) -D -m 644 $(NAME).pc $(DESTDIR)$(libdir)/pkgconfig/$(NAME).pc |
Shenghui Wang | 6cd873c | 2019-04-26 11:35:42 +0800 | [diff] [blame] | 45 | $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man2 |
| 46 | $(INSTALL) -m 644 man/*.2 $(DESTDIR)$(mandir)/man2 |
Jens Axboe | f93c84e | 2019-01-08 06:51:07 -0700 | [diff] [blame] | 47 | |
| 48 | clean: |
Stefan Hajnoczi | 1b049c1 | 2019-05-25 09:58:29 +0100 | [diff] [blame] | 49 | @rm -f config-host.mak config-host.h cscope.out $(NAME).pc |
Jens Axboe | f93c84e | 2019-01-08 06:51:07 -0700 | [diff] [blame] | 50 | @$(MAKE) -C src clean |
Jens Axboe | baa8d24 | 2019-01-08 15:48:57 -0700 | [diff] [blame] | 51 | @$(MAKE) -C test clean |
Weiping Zhang | 2e71982 | 2019-05-22 00:50:13 +0800 | [diff] [blame] | 52 | @$(MAKE) -C examples clean |
Jens Axboe | f93c84e | 2019-01-08 06:51:07 -0700 | [diff] [blame] | 53 | |
Jens Axboe | b080d06 | 2019-03-05 16:19:59 -0700 | [diff] [blame] | 54 | cscope: |
| 55 | @cscope -b -R |
| 56 | |
Jens Axboe | f93c84e | 2019-01-08 06:51:07 -0700 | [diff] [blame] | 57 | tag-archive: |
| 58 | @git tag $(TAG) |
| 59 | |
| 60 | create-archive: |
| 61 | @git archive --prefix=$(NAME)-$(VERSION)/ -o $(NAME)-$(VERSION).tar.gz $(TAG) |
| 62 | @echo "The final archive is ./$(NAME)-$(VERSION).tar.gz." |
| 63 | |
| 64 | archive: clean tag-archive create-archive |
| 65 | |
| 66 | srpm: create-archive |
| 67 | $(RPMBUILD) --define "_sourcedir `pwd`" --define "_srcrpmdir `pwd`" --nodeps -bs $(SPECFILE) |