- enable fortify as well
[ossec-hids.git] / debian / rules
1 #!/usr/bin/make -f
2
3 # Uncomment this to turn on verbose mode.
4 #export DH_VERBOSE=1
5
6 # Directories
7 SRCDIR = $(CURDIR)/src
8 PKGDIR = $(CURDIR)/debian/ossec-hids
9 DESTDIR = $(PKGDIR)/var/ossec
10
11 # OSSEC INSTALL SUBDIRS
12 SUBDIRS = .ssh active-response active-response/bin agentless bin etc etc/shared logs logs/alerts logs/archives logs/firewall queue queue/agent-info queue/agentless queue/alerts queue/diff queue/fts queue/ossec queue/rids queue/rootcheck queue/syscheck rules stats tmp var var/run
13
14 ###################### hardening #################
15
16 export DEB_BUILD_HARDENING=1
17 export DEB_BUILD_HARDENING_FORTIFY=1
18
19 ###################### main ######################
20
21 build: build-stamp
22 build-stamp:
23         dh_testdir
24         dh_clean
25
26         $(MAKE) -C $(SRCDIR) setlocal all build
27
28         touch build-stamp
29
30 build-arch: build
31 build-indep: build
32
33 clean:
34         dh_testdir
35         dh_testroot
36         rm -f build-stamp
37
38         # Add here commands to clean up after the build process.
39         $(MAKE) -C $(SRCDIR) clean
40
41         # additional clean
42         rm -f $(SRCDIR)/Config.OS \
43                 $(SRCDIR)/analysisd/compiled_rules/compiled_rules.h \
44                 $(SRCDIR)/analysisd/ossec-logtest \
45                 $(SRCDIR)/isbigendian \
46                 $(SRCDIR)/isbigendian.c \
47                 $(SRCDIR)/analysisd/ossec-makelists
48         rm -rf $(CURDIR)/bin
49
50         dh_clean
51
52 install: build
53         dh_testdir
54         dh_testroot
55         dh_prep
56         dh_installdirs
57
58         # ugly directory creation
59         for i in $(SUBDIRS); do \
60                 mkdir -p -m 700 $(DESTDIR)/$$i; \
61         done
62
63         # various files installation
64         install -m 644 etc/internal_options.conf $(DESTDIR)/etc
65         install -m 644 etc/decoder.xml $(DESTDIR)/etc
66         install -m 644 src/rootcheck/db/*.txt $(DESTDIR)/etc/shared
67         if [ -e ossec-debian.conf ]; then \
68                 install -m 440 ossec-debian.conf $(DESTDIR)/etc/ossec.conf; \
69         else \
70                 install -m 440 etc/ossec-local.conf $(DESTDIR)/etc/ossec.conf; \
71         fi
72         install -m 440 etc/ossec-*.conf $(DESTDIR)/etc
73         cp -r etc/rules/* $(DESTDIR)/rules
74         install -m 750 src/agentlessd/scripts/* $(DESTDIR)/agentless
75         install -s -m 755 bin/* $(DESTDIR)/bin
76         install -m 755 src/init/ossec-*.sh $(DESTDIR)/bin
77         ln -s ossec-local.sh $(DESTDIR)/bin/ossec-control
78         install -m 755 active-response/*.sh $(DESTDIR)/active-response/bin
79         install -m 755 active-response/firewalls/*.sh \
80                 $(DESTDIR)/active-response/bin
81
82         # attrs
83         chmod -R 550 $(DESTDIR)
84         chmod -R 770 $(DESTDIR)/queue/alerts
85         chmod -R 770 $(DESTDIR)/queue/ossec
86         chmod -R 750 $(DESTDIR)/queue/fts
87         chmod -R 750 $(DESTDIR)/queue/syscheck
88         chmod -R 750 $(DESTDIR)/queue/rootcheck
89         chmod -R 750 $(DESTDIR)/queue/diff
90         chmod -R 755 $(DESTDIR)/queue/agent-info
91         chmod -R 755 $(DESTDIR)/queue/rids
92         chmod -R 755 $(DESTDIR)/queue/agentless
93         chmod -R 750 $(DESTDIR)/stats
94         chmod -R 750 $(DESTDIR)/logs
95         chmod -R 550 $(DESTDIR)/rules
96         chmod 770 $(DESTDIR)/var/run
97         chmod 550 $(DESTDIR)/etc
98         chmod 440 $(DESTDIR)/etc/internal_options.conf
99         chmod -R 770 $(DESTDIR)/etc/shared
100         chmod 700 $(DESTDIR)/.ssh
101         chmod 755 $(DESTDIR)/active-response/bin/*
102         chmod 550 $(DESTDIR)/bin/*
103         chmod 440 $(DESTDIR)/etc/ossec.conf
104
105         # fixups: no need for execute bits on files there
106         find $(DESTDIR)/rules -type f -exec chmod ugo-x '{}' ';'
107         find $(DESTDIR)/etc -type f -exec chmod ugo-x '{}' ';'
108
109         # system init script
110         mkdir -p $(PKGDIR)/etc/init.d
111         if [ -e ossec-hids-debian.init ]; then \
112                 install -m 755 ossec-hids-debian.init \
113                         $(PKGDIR)/etc/init.d/ossec-hids; \
114         else \
115                 install -m 755 src/init/ossec-hids.init \
116                         $(PKGDIR)/etc/init.d/ossec-hids; \
117         fi
118
119         # system ossec-init
120         echo "DIRECTORY=\"/var/ossec\""      >  $(PKGDIR)/etc/ossec-init.conf
121         echo "VERSION=\"`cat src/VERSION`\"" >> $(PKGDIR)/etc/ossec-init.conf
122         echo "DATE=\"$(shell date --utc -d "$(shell dpkg-parsechangelog | sed -ne 's/Date: //p')")\""   >> $(PKGDIR)/etc/ossec-init.conf
123         echo "TYPE=\"local\""                >> $(PKGDIR)/etc/ossec-init.conf
124
125 # Build architecture-independent files here.
126 binary-indep: build install
127 # We have nothing to do by default.
128
129 # Build architecture-dependent files here.
130 binary-arch: build install
131         dh_testdir
132         dh_testroot
133         dh_installchangelogs
134         dh_installdocs
135 #       dh_installexamples
136 #       dh_installmenu
137 #       dh_installdebconf
138 #       dh_installlogrotate
139 #       dh_installemacsen
140 #       dh_installcatalogs
141 #       dh_installpam
142 #       dh_installmime
143 #       dh_installinit
144 #       dh_installcron
145 #       dh_installinfo
146 #       dh_undocumented
147         dh_lintian
148         dh_installman
149         dh_link
150         dh_compress
151         dh_fixperms
152 #       dh_perl
153 #       dh_python
154         dh_installdeb
155         dh_shlibdeps
156         dh_gencontrol
157         dh_md5sums
158         dh_builddeb
159
160 binary: binary-indep binary-arch
161 .PHONY: build clean binary-indep binary-arch binary install