summaryrefslogtreecommitdiff
blob: 85ac80de7abbc42e1e3f80b42907fdf6ba7f5c91 (plain)
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
CFLAGS ?= -O2 -g
CFLAGS += -Wall -Wextra

PN = gcc-config
PV = git
P = $(PN)-$(PV)

PREFIX = /usr
BINDIR = $(PREFIX)/bin
SUBLIBDIR = lib
LIBDIR = $(PREFIX)/$(SUBLIBDIR)
LIBEXECDIR = $(LIBDIR)/misc

MKDIR_P = mkdir -p -m 755
INSTALL_EXE = install -m 755

all: wrapper

clean:
	rm -f wrapper *.o core

install: all
	$(MKDIR_P) $(DESTDIR)$(BINDIR) $(DESTDIR)$(LIBEXECDIR)
	$(INSTALL_EXE) wrapper $(DESTDIR)$(LIBEXECDIR)/$(PN)
	sed \
		-e 's:@GENTOO_LIBDIR@:$(SUBLIBDIR):g' \
		-e 's:@PV@:$(PV):g' \
		gcc-config > $(DESTDIR)$(BINDIR)/gcc-config
	chmod a+rx $(DESTDIR)$(BINDIR)/gcc-config

test check:
	cd tests && ./run_tests

dist:
	@if [ "$(PV)" = "git" ] ; then \
		printf "please run: make dist PV=xxx\n(where xxx is a git tag)\n" ; \
		exit 1 ; \
	fi
	git archive --prefix=$(P)/ v$(PV) | xz > $(P).tar.xz

distcheck: dist
	@set -ex; \
	rm -rf $(P); \
	tar xf $(P).tar.xz; \
	pushd $(P) >/dev/null; \
	$(MAKE) install DESTDIR=`pwd`/foo; \
	rm -rf foo; \
	$(MAKE) check; \
	popd >/dev/null; \
	rm -rf $(P)

.PHONY: all clean dist install