Added a Makefile with some scons shortcuts and rules for generating a debian package.
[senf.git] / Makefile
1 #----------------------------------------------------------------------
2 # Some SCONS shortcuts
3 #----------------------------------------------------------------------
4 SCONS=scons
5
6 default: build
7
8 build:
9         $(SCONS)
10
11 clean:
12         $(SCONS) --clean
13
14 all_docs all_tests:
15         $(SCONS) $@
16
17 #----------------------------------------------------------------------
18 # Subversion stuff
19 #----------------------------------------------------------------------
20 SVN_REVISION = $(shell svn info|grep '^Revision: '|awk '{print $$2}')
21
22 svn_version:
23         @echo $(SVN_REVISION)
24
25 #----------------------------------------------------------------------
26 # Building SENF requires some debian packages
27 #----------------------------------------------------------------------
28 DEB_BASE   = scons build-essential binutils-dev
29 DEB_BOOST  = libboost-dev libboost-test-dev
30 DEB_BOOST += libboost-date-time-dev libboost-regex-dev libboost-thread-dev
31 DEB_DOC    = doxygen dia tidy xsltproc graphviz
32
33 prerequisites:
34         aptitude install $(DEB_BASE) $(DEB_BOOST) $(DEB_DOC)
35
36 #----------------------------------------------------------------------
37 # Debian package info
38 #----------------------------------------------------------------------
39 PKG_NAME=senf-dev
40 PKG_ARCH=i386
41 PKG_VERS=0.0.$(SVN_REVISION)-1
42 PKG_FILE = $(PKG_NAME)-$(PKG_VERS)_$(PKG_ARCH).deb
43
44 #----------------------------------------------------------------------
45 # Debian package structure
46 #----------------------------------------------------------------------
47 DEB_TOP = ./debian
48 DEB_CTL = $(DEB_TOP)/DEBIAN
49 DEB_LIB = $(DEB_TOP)/usr/lib/senf
50 DEB_INC = $(DEB_TOP)/usr/include/senf
51 DEB_DOC = $(DEB_TOP)/usr/share/doc/senf
52
53 #----------------------------------------------------------------------
54 # Debian package content
55 #----------------------------------------------------------------------
56 SENF_LIBS = *.a
57 SENF_HDRS = $$(find -path './XXXdebian' -prune \
58                  -o -iname \*.h \
59                  -o -iname \*.hh \
60                  -o -iname \*.ih \
61                  -o -iname \*.c \
62                  -o -iname \*.cc \
63                  -o -iname \*.ct \
64                  -o -iname \*.cci \
65                  -o -iname \*.cti \
66                  -o -iname \*.mpp \
67 )
68
69 package: $(PKG_FILE)
70 $(PKG_FILE): build
71         rm -rf $(DEB_TOP)
72         mkdir -p $(DEB_CTL) $(DEB_INC) $(DEB_LIB) $(DEB_DOC)
73         find $(DEB_TOP) -type d | xargs chmod 755
74         tar cf - $(SENF_HDRS) | (cd $(DEB_INC) && tar xf -)
75         tar cf - $(SENF_LIBS) | (cd $(DEB_LIB) && tar xf -)
76         sed -e 's,PKG_VERSION,$(PKG_VERS),' control > $(DEB_CTL)/control
77         $(MAKE) deb-doc
78         dpkg-deb --build debian $(PKG_FILE)
79
80 #----------------------------------------------------------------------
81 # Extract documentation files from source tree
82 #----------------------------------------------------------------------
83 deb-doc:
84         rsync -rz \
85                 --filter="- debian/*" \
86                 --filter="- .svn" \
87                 --filter="+ */" \
88                 --filter="+ *.html" \
89                 --filter="+ *.css" \
90                 --filter="+ *.png" \
91                 --filter="+ *.php" \
92                 --filter="+ *.idx" \
93                 --filter="+ *.log" \
94                 --filter="- *" \
95                 . $(DEB_DOC)
96