File: Makefile

package info (click to toggle)
nocache 0.9-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 164 kB
  • ctags: 70
  • sloc: ansic: 512; makefile: 74; sh: 26
file content (58 lines) | stat: -rw-r--r-- 1,366 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/make -f
# -*- makefile -*-

PREFIX ?= /usr/local
MANDIR ?= /share/man/man1
BINDIR ?= /bin
LIBDIR ?= /lib
mandir  = $(DESTDIR)$(PREFIX)$(MANDIR)
bindir  = $(DESTDIR)$(PREFIX)$(BINDIR)
libdir  = $(DESTDIR)$(PREFIX)$(LIBDIR)

CACHE_BINS=cachedel cachestats
NOCACHE_BINS=nocache.o fcntl_helpers.o
MANPAGES=$(wildcard man/*.1)

CFLAGS+= -Wall
GCC = gcc $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)

.PHONY: all
all: $(CACHE_BINS) nocache.so nocache

$(CACHE_BINS):
	$(GCC) -o $@ $@.c

$(NOCACHE_BINS):
	$(GCC) -fPIC -c -o $@ $(@:.o=.c)

nocache.global:
	sed 's!##libdir##!$(subst $(DESTDIR),,$(libdir))!' <nocache.in >$@

nocache:
	sed 's!##libdir##!$$(dirname "$$0")!' <nocache.in >$@
	chmod a+x $@

nocache.so: $(NOCACHE_BINS)
	$(GCC) -pthread -shared -Wl,-soname,nocache.so -o nocache.so $(NOCACHE_BINS) -ldl

$(mandir) $(libdir) $(bindir):
	mkdir -v -p $@

install: all $(mandir) $(libdir) $(bindir) nocache.global
	install -m 0644 nocache.so $(libdir)
	install -m 0755 nocache.global $(bindir)/nocache
	install -m 0755 $(CACHE_BINS) $(bindir)
	install -m 0644 $(MANPAGES) $(mandir)

.PHONY: uninstall
uninstall:
	cd $(mandir) && $(RM) -v $(notdir $(MANPAGES))
	$(RM) -v $(bindir)/nocache $(libdir)/nocache.so

.PHONY: clean distclean
clean distclean:
	$(RM) -v $(CACHE_BINS) $(NOCACHE_BINS) nocache.so nocache nocache.global

.PHONY: test
test: all
	cd t; prove -v .