File: Makefile

package info (click to toggle)
nocache 1.2-0.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 220 kB
  • sloc: ansic: 744; makefile: 54; sh: 42
file content (59 lines) | stat: -rw-r--r-- 1,523 bytes parent folder | download
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
59
#!/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 pageinfo.o wrappers.o
MANPAGES=$(wildcard man/*.1)

CC ?= gcc
CFLAGS+= -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_TIME_BITS=64
COMPILE = $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)

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

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

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

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

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

nocache.so: $(NOCACHE_BINS)
	$(COMPILE) -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 -pm 0644 nocache.so $(libdir)
	install -pm 0755 nocache.global $(bindir)/nocache
	install -pm 0755 $(CACHE_BINS) $(bindir)
	install -pm 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 .