-
Notifications
You must be signed in to change notification settings - Fork 85
/
Makefile
65 lines (53 loc) · 1.65 KB
/
Makefile
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
60
61
62
63
64
65
export VERSION = 1.2.11
RELEASE ?= .tl3
export RELEASE
man-target := script/zh_CN/nettrace.8
ROOT := $(abspath .)
export ROOT
PREFIX ?= ./output
PREFIX := $(abspath $(PREFIX))
MAN_DIR := $(PREFIX)/usr/share/man
BCOMP := ${PREFIX}/usr/share/bash-completion/completions/
export PREFIX
SCRIPT = $(ROOT)/script
export SCRIPT
ARCH ?= $(shell uname -m)
SOURCE_DIR := ~/rpmbuild/SOURCES/nettrace-${VERSION}
PACK_TARGET := nettrace-$(VERSION)-1$(RELEASE).$(ARCH)
PACK_PATH := $(abspath $(PREFIX)/$(PACK_TARGET))
PACK_NAME := $(PACK_TARGET).tar.bz2
all clean:
make -C src $@
%.8: %.md
md2man-roff $< > $@
man: $(man-target)
install:
@mkdir -p $(PREFIX)
make -C src install
@mkdir -p ${MAN_DIR}/zh_CN/man8/; gzip -k $(SCRIPT)/zh_CN/*.8; \
mv $(SCRIPT)/zh_CN/*.8.gz ${MAN_DIR}/zh_CN/man8
@mkdir -p ${MAN_DIR}/man8/; gzip -k $(SCRIPT)/*.8; mv \
$(SCRIPT)/*.8.gz ${MAN_DIR}/man8/; \
cd ${MAN_DIR}/man8/; for i in `ls ../zh_CN/man8/`; \
do \
if [ ! -f $$i ];then \
ln -s ../zh_CN/man8/$$i ./; \
fi; \
done
@mkdir -p $(BCOMP); cd $(BCOMP); cp $(SCRIPT)/bash-completion.sh \
./nettrace
pack:
@make clean
@rm -rf $(PACK_PATH) && mkdir -p $(PACK_PATH)
make PREFIX=$(PACK_PATH) -C src pack
@cd $(PREFIX) && tar -cjf $(PACK_NAME) $(PACK_TARGET) && \
echo "$(PREFIX)/$(PACK_NAME) is generated"
rpm:
@make clean
@rm -rf ${SOURCE_DIR} && mkdir -p ${SOURCE_DIR}
@cp -r * ${SOURCE_DIR}/
@sed -i 's/%{VERSION}/$(VERSION)/' ${SOURCE_DIR}/script/nettrace.spec
@cd ~/rpmbuild/SOURCES/ && tar -czf nettrace-${VERSION}.tar.gz \
nettrace-${VERSION}
@rpmbuild -D 'dist $(RELEASE)' --target ${ARCH} \
-ba ${SOURCE_DIR}/script/nettrace.spec