1 |
# |
2 |
# Copyright (C) 2006 Greg Kroah-Hartman <greg@kroah.com> |
3 |
# |
4 |
# This program is free software; you can redistribute it and/or modify |
5 |
# it under the terms of the GNU General Public License as published by |
6 |
# the Free Software Foundation; version 2 of the License. |
7 |
# |
8 |
# This program is distributed in the hope that it will be useful, |
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
11 |
# General Public License for more details. |
12 |
# |
13 |
# You should have received a copy of the GNU General Public License |
14 |
# along with this program; if not, write to the Free Software |
15 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
16 |
# |
17 |
# |
18 |
|
19 |
VERSION = 017 |
20 |
|
21 |
PROGRAM = bti |
22 |
SCRIPTS = bti-shrink-urls |
23 |
|
24 |
CORE_OBJS = \ |
25 |
bti.o |
26 |
|
27 |
GEN_HEADERS = \ |
28 |
bti_version.h |
29 |
|
30 |
MAN_PAGES = \ |
31 |
bti.1 |
32 |
|
33 |
CROSS_COMPILE ?= |
34 |
CC = $(CROSS_COMPILE)gcc |
35 |
LD = $(CROSS_COMPILE)gcc |
36 |
AR = $(CROSS_COMPILE)ar |
37 |
|
38 |
XML2_CFLAGS = `xml2-config --cflags` |
39 |
PCRE_CFLAGS = `pcre-config --cflags` |
40 |
override CFLAGS += -g -Wall -pipe -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -O2 $(XML2_CFLAGS) $(PCRE_CFLAGS) |
41 |
|
42 |
WARNINGS = -Wstrict-prototypes -Wsign-compare -Wshadow \ |
43 |
-Wchar-subscripts -Wmissing-declarations -Wnested-externs \ |
44 |
-Wpointer-arith -Wcast-align -Wsign-compare -Wmissing-prototypes |
45 |
CFLAGS += $(WARNINGS) |
46 |
LDFLAGS += -Wl,-warn-common,--as-needed |
47 |
|
48 |
DEST ?= |
49 |
PREFIX ?= /usr/local |
50 |
|
51 |
INSTALL = install |
52 |
INSTALL_BIN = ${INSTALL} -m 0755 -t ${DEST}${PREFIX}/bin |
53 |
INSTALL_MAN = ${INSTALL} -m 0644 -t ${DEST}${PREFIX}/share/man |
54 |
|
55 |
ifeq ($(strip $(V)),) |
56 |
E = @echo |
57 |
Q = @ |
58 |
else |
59 |
E = @\# |
60 |
Q = |
61 |
endif |
62 |
export E Q |
63 |
|
64 |
|
65 |
# We need -lcurl for the curl stuff |
66 |
# We need -lsocket and -lnsl when on Solaris |
67 |
# We need -lreadline for readline support |
68 |
# We need -lssl and -lcrypto when using libcurl with SSL support |
69 |
# We need -lpthread for the pthread example |
70 |
#LIB_OBJS = -lcurl -lnsl -lssl -lcrypto |
71 |
LIB_OBJS = -lcurl -lnsl -lreadline |
72 |
LIB_XML2 = `xml2-config --libs` |
73 |
LIB_PCRE = `pcre-config --libs` |
74 |
|
75 |
all: $(PROGRAM) $(MAN_PAGES) |
76 |
|
77 |
# "Static Pattern Rule" to build all programs |
78 |
bti: %: $(HEADERS) $(GEN_HEADERS) $(CORE_OBJS) |
79 |
$(E) " LD " $@ |
80 |
$(Q) $(LD) $(LDFLAGS) $(CORE_OBJS) -o $@ $(LIB_OBJS) $(LIB_XML2) $(LIB_PCRE) |
81 |
|
82 |
# build the objects |
83 |
%.o: %.c $(HEADERS) $(GEN_HEADERS) |
84 |
$(E) " CC " $@ |
85 |
$(Q) $(CC) -c $(CFLAGS) $< -o $@ |
86 |
|
87 |
|
88 |
bti_version.h: Makefile |
89 |
$(E) " GENHDR " $@ |
90 |
$(Q) echo "/* Generated by make. */" > $@ |
91 |
$(Q) echo \#define BTI_VERSION \"$(VERSION)\" >> $@ |
92 |
|
93 |
|
94 |
# man pages |
95 |
%.1: %.xml |
96 |
$(E) " XMLTO " $@ |
97 |
$(Q) xmlto man $? |
98 |
.PRECIOUS: %.3 |
99 |
|
100 |
clean: |
101 |
$(E) " CLEAN " |
102 |
$(Q) - find . -type f -name '*.orig' -print0 | xargs -0r rm -f |
103 |
$(Q) - find . -type f -name '*.rej' -print0 | xargs -0r rm -f |
104 |
$(Q) - find . -type f -name '*~' -print0 | xargs -0r rm -f |
105 |
$(Q) - find . -type f -name '*.[oas]' -print0 | xargs -0r rm -f |
106 |
$(Q) - find . -type f -name "*.gcno" -print0 | xargs -0r rm -f |
107 |
$(Q) - find . -type f -name "*.gcda" -print0 | xargs -0r rm -f |
108 |
$(Q) - find . -type f -name "*.gcov" -print0 | xargs -0r rm -f |
109 |
$(Q) - rm -f core $(PROGRAM) $(GEN_HEADERS) |
110 |
.PHONY: clean |
111 |
|
112 |
release: |
113 |
$(Q) - rm -f bti-$(VERSION).tar.gz |
114 |
head -1 ChangeLog | grep -q "to v$(VERSION)" |
115 |
head -1 RELEASE-NOTES | grep -q "bti $(VERSION)" |
116 |
git commit -a -m "release $(VERSION)" |
117 |
cat .git/refs/heads/master > .git/refs/tags/$(VERSION) |
118 |
@ echo |
119 |
git archive --format=tar --prefix=bti-$(VERSION)/ HEAD | gzip -9v > bti-$(VERSION).tar.gz |
120 |
.PHONY: release |
121 |
|
122 |
install: all |
123 |
$(E) " INSTALL " ${DEST}${PREFIX} |
124 |
${Q} ${INSTALL_BIN} ${PROGRAM} ${SCRIPTS} |
125 |
${Q} ${INSTALL_MAN} ${MAN_PAGES} |
126 |
.PHONY: install |