01f864101bc714aeb50041ea2853aa5e45f9ccc6
[debian/amanda] / server-src / Makefile.am
1 # Makefile for Amanda server programs.
2
3 INCLUDES =      -I$(top_builddir)/common-src \
4                 -I$(top_srcdir)/common-src   \
5                 -I$(top_srcdir)/restore-src  \
6                 -I$(top_srcdir)/tape-src     \
7                 -I$(top_srcdir)/amandad-src
8
9 LINT=@AMLINT@
10 LINTFLAGS=@AMLINTFLAGS@
11
12 lib_LTLIBRARIES =       libamserver.la
13 LIB_EXTENSION = la
14
15 sbin_PROGRAMS =         amadmin         amcheck         amflush         \
16                         amgetconf       amlabel         amtape          \
17                         amreport
18
19 libexec_PROGRAMS =      amindexd        amlogroll       amtrmidx        \
20                         amtrmlog        driver          dumper          \
21                         planner         taper           amcleanupdisk   \
22                         chunker
23
24 sbin_SCRIPTS =          amcheckdb       amcleanup       amdump          \
25                         amoverview      amrmtape        amtoc           \
26                         amverify        amverifyrun     amstatus        \
27                         amcrypt         amaespipe       amcrypt-ossl    \
28                         amcrypt-ossl-asym
29
30 libamserver_la_SOURCES= amindex.c       changer.c                       \
31                         conffile.c      diskfile.c      driverio.c      \
32                         holding.c       infofile.c      logfile.c       \
33                         tapefile.c      find.c          server_util.c   \
34                         taperscan.c
35
36 libamserver_la_LDFLAGS= -release $(VERSION)
37
38 ###
39 # Because libamanda includes routines (e.g. regex) provided by some system
40 # libraries, and because of the way libtool sets up the command line, we
41 # need to list libamanda twice here, first to override the system library
42 # routines, and second to pick up any references in the other libraries.
43 ###
44
45 LDADD = ../common-src/libamanda.$(LIB_EXTENSION) \
46         libamserver.$(LIB_EXTENSION)             \
47         ../tape-src/libamtape.$(LIB_EXTENSION)   \
48         ../common-src/libamanda.$(LIB_EXTENSION) \
49         ../tape-src/libamtape.$(LIB_EXTENSION)   \
50         ../common-src/libamanda.$(LIB_EXTENSION) \
51         $(READLINE_LIBS)
52
53 amindexd_LDADD = ../common-src/libamanda.$(LIB_EXTENSION) \
54         libamserver.$(LIB_EXTENSION) \
55         ../amandad-src/libamandad.$(LIB_EXTENSION) \
56         ../tape-src/libamtape.$(LIB_EXTENSION) \
57         ../common-src/libamanda.$(LIB_EXTENSION) \
58         ../tape-src/libamtape.$(LIB_EXTENSION) \
59         ../common-src/libamanda.$(LIB_EXTENSION)
60
61 SUFFIXES =              .sh .pl
62
63 .pl:
64                         cat $< > $@
65                         chmod a+x $@
66                         -test -z "$(PERL)" || $(PERL) -c $@
67
68 .sh:
69                         cat $< > $@
70                         chmod a+x $@
71
72 # there are used for testing only:
73 TEST_PROGS = diskfile conffile infofile
74
75 EXTRA_PROGRAMS =        $(TEST_PROGS)
76
77 CLEANFILES = *.test.c $(sbin_SCRIPTS)
78
79 amindexd_CSRC =         amindexd.c      disk_history.c  list_dir.c
80 amindexd_SOURCES =      disk_history.h  list_dir.h      $(amindexd_CSRC)
81
82 amreport_SOURCES =      reporter.c
83
84 amgetconf_SOURCES =     getconf.c
85
86 noinst_HEADERS =        amindex.h       changer.h                       \
87                         conffile.h      diskfile.h      driverio.h      \
88                         holding.h       infofile.h      logfile.h       \
89                         tapefile.h      find.h          server_util.h   \
90                         taperscan.h
91
92 install-exec-hook:
93         @list="$(sbin_PROGRAMS) $(sbin_SCRIPTS)"; \
94         for p in $$list; do \
95                 pa=$(DESTDIR)$(sbindir)/`echo $$p|sed '$(transform)'`; \
96                 echo chown $(BINARY_OWNER) $$pa; \
97                 chown $(BINARY_OWNER) $$pa; \
98                 echo chgrp $(SETUID_GROUP) $$pa; \
99                 chgrp $(SETUID_GROUP) $$pa; \
100         done
101         @list="$(libexec_PROGRAMS) $(libexec_SCRIPTS)"; \
102         for p in $$list; do \
103                 pa=$(DESTDIR)$(libexecdir)/`echo $$p|sed '$(transform)'`; \
104                 echo chown $(BINARY_OWNER) $$pa; \
105                 chown $(BINARY_OWNER) $$pa; \
106                 echo chgrp $(SETUID_GROUP) $$pa; \
107                 chgrp $(SETUID_GROUP) $$pa; \
108         done
109         @list="amcheck"; \
110         for p in $$list; do \
111                 if echo "$(sbin_PROGRAMS)" | grep $$p >/dev/null 2>&1; then \
112                         pa=$(DESTDIR)$(sbindir)/`echo $$p|sed '$(transform)'`; \
113                         echo chown root $$pa; \
114                         chown root $$pa; \
115                         echo chmod u+s,o-rwx $$pa; \
116                         chmod u+s,o-rwx $$pa; \
117                 else true; \
118                 fi; \
119         done
120 ##                                                     ##
121 ## enterprise version will install dumper/planner suid ##
122 ##                                                     ##
123
124         @list="dumper planner"; \
125         for p in $$list; do \
126                 if echo "$(libexec_PROGRAMS)" | grep $$p >/dev/null 2>&1; then \
127                         pa=$(DESTDIR)$(libexecdir)/`echo $$p|sed '$(transform)'`; \
128                         echo chown root $$pa; \
129                         chown root $$pa; \
130                         echo chmod u+s,o-rwx $$pa; \
131                         chmod u+s,o-rwx $$pa; \
132                 else true; \
133                 fi; \
134         done
135
136 lint:
137         @ for p in $(libexec_PROGRAMS) $(sbin_PROGRAMS); do                     \
138                 if [ $$p = "amindexd" ]; then                                   \
139                         s="$(amindexd_CSRC)";                                   \
140                 elif [ $$p = "amreport" ]; then                                 \
141                         s="$(amreport_SOURCES)";                                \
142                 elif [ $$p = "amgetconf" ]; then                                \
143                         s="$(getconf_SOURCES)";                                 \
144                 else                                                            \
145                         s=$$p.c;                                                \
146                 fi;                                                             \
147                 f="$$s $(libamserver_la_SOURCES)";                              \
148                 (cd ../common-src; make listlibsrc);                            \
149                 f="$$f "`cat ../common-src/listlibsrc.output`;                  \
150                 (cd ../tape-src; make listlibsrc);                              \
151                 f="$$f "`cat ../tape-src/listlibsrc.output`;                    \
152                 echo $(LINT) $$f;                                               \
153                 $(LINT) $(LINTFLAGS) $(CPPFLAGS) $(DEFS) -I. -I../config        \
154                     $(INCLUDES) $$f;                                            \
155                 if [ $$? -ne 0 ]; then                                          \
156                     exit 1;                                                     \
157                 fi;                                                             \
158         done;                                                                   \
159         exit 0
160
161 listlibsrc:
162         @ for p in $(libamserver_la_SOURCES); do                \
163                 listlibsrcs="$$listlibsrcs `pwd`/$$p";          \
164         done;                                                   \
165         echo $$listlibsrcs >listlibsrc.output
166
167
168 diskfile_SOURCES = diskfile.test.c
169 conffile_SOURCES = conffile.test.c
170 infofile_SOURCES = infofile.test.c
171
172 %.test.c: $(srcdir)/%.c
173         echo '#define TEST' >$@
174         echo '#include "$<"' >>$@