tests: Locate resources and scripts relative to top source dir.
[gnupg.git] / g10 / Makefile.am
1 # Copyright (C) 1998, 1999, 2000, 2001, 2002,
2 #               2003, 2006, 2010  Free Software Foundation, Inc.
3 #
4 # This file is part of GnuPG.
5 #
6 # GnuPG is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # GnuPG is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, see <https://www.gnu.org/licenses/>.
18
19 ## Process this file with automake to produce Makefile.in
20
21 EXTRA_DIST = options.skel dirmngr-conf.skel distsigkey.gpg \
22              ChangeLog-2011 gpg-w32info.rc \
23              gpg.w32-manifest.in test.c t-keydb-keyring.kbx \
24              t-keydb-get-keyblock.gpg t-stutter-data.asc
25
26 AM_CPPFLAGS =
27
28 include $(top_srcdir)/am/cmacros.am
29
30 AM_CFLAGS = $(SQLITE3_CFLAGS) $(LIBGCRYPT_CFLAGS) \
31             $(LIBASSUAN_CFLAGS) $(GPG_ERROR_CFLAGS)
32
33 needed_libs = ../kbx/libkeybox.a $(libcommon)
34
35 # Because there are no program specific transform macros we need to
36 # work around that to allow installing gpg as gpg2.
37 gpg2_hack_list = gpg gpgv
38 if USE_GPG2_HACK
39 gpg2_hack_uninst = gpg2 gpgv2
40 use_gpg2_hack = yes
41 else
42 gpg2_hack_uninst = $(gpg2_hack_list)
43 use_gpg2_hack = no
44 endif
45
46 # NB: We use noinst_ for gpg and gpgv so that we can install them with
47 # the install-hook target under the name gpg2/gpgv2.
48 noinst_PROGRAMS = gpg
49 if !HAVE_W32CE_SYSTEM
50 noinst_PROGRAMS += gpgv
51 endif
52 if MAINTAINER_MODE
53 noinst_PROGRAMS += gpgcompose
54 endif
55 noinst_PROGRAMS += $(module_tests)
56 TESTS = $(module_tests)
57 TESTS_ENVIRONMENT = \
58         abs_top_srcdir=$(abs_top_srcdir)
59
60 if ENABLE_BZIP2_SUPPORT
61 bzip2_source = compress-bz2.c
62 else
63 bzip2_source =
64 endif
65
66 if ENABLE_CARD_SUPPORT
67 card_source = card-util.c
68 else
69 card_source =
70 endif
71
72 if NO_TRUST_MODELS
73 trust_source =
74 else
75 trust_source = trustdb.c trustdb.h tdbdump.c tdbio.c tdbio.h
76 endif
77
78 if USE_TOFU
79 tofu_source = tofu.h tofu.c gpgsql.c gpgsql.h sqrtu32.c sqrtu32.h
80 else
81 tofu_source =
82 endif
83
84
85 if HAVE_W32_SYSTEM
86 resource_objs += gpg-w32info.o
87
88 gpg-w32info.o : gpg.w32-manifest
89
90 endif
91
92 common_source =  \
93               gpg.h             \
94               dek.h             \
95               build-packet.c    \
96               compress.c        \
97               $(bzip2_source)   \
98               filter.h          \
99               free-packet.c     \
100               getkey.c          \
101               keydb.c keydb.h    \
102               keyring.c keyring.h \
103               seskey.c          \
104               kbnode.c          \
105               main.h            \
106               mainproc.c        \
107               armor.c           \
108               mdfilter.c        \
109               textfilter.c      \
110               progress.c        \
111               misc.c            \
112               rmd160.c rmd160.h \
113               options.h         \
114               openfile.c        \
115               keyid.c           \
116               packet.h          \
117               parse-packet.c    \
118               cpr.c             \
119               plaintext.c       \
120               sig-check.c       \
121               keylist.c         \
122               pkglue.c pkglue.h \
123               ecdh.c
124
125 gpg_sources = server.c          \
126               $(common_source)  \
127               pkclist.c         \
128               skclist.c         \
129               pubkey-enc.c      \
130               passphrase.c      \
131               decrypt.c         \
132               decrypt-data.c    \
133               cipher.c          \
134               encrypt.c         \
135               sign.c            \
136               verify.c          \
137               revoke.c          \
138               dearmor.c         \
139               import.c          \
140               export.c          \
141               migrate.c         \
142               delkey.c          \
143               keygen.c          \
144               helptext.c        \
145               keyserver.c       \
146               keyserver-internal.h \
147               call-dirmngr.c call-dirmngr.h \
148               photoid.c photoid.h \
149               call-agent.c call-agent.h \
150               trust.c $(trust_source) $(tofu_source) \
151               $(card_source) \
152               exec.c exec.h
153
154 gpg_SOURCES  = gpg.c \
155         keyedit.c       \
156         $(gpg_sources)
157
158 gpgcompose_SOURCES  = gpgcompose.c  $(gpg_sources)
159 gpgv_SOURCES = gpgv.c           \
160               $(common_source)  \
161               verify.c
162
163 #gpgd_SOURCES = gpgd.c \
164 #              ks-proto.h \
165 #              ks-proto.c \
166 #              ks-db.c \
167 #              ks-db.h \
168 #              $(common_source)
169
170 LDADD =  $(needed_libs) ../common/libgpgrl.a \
171          $(ZLIBS) $(LIBINTL) $(CAPLIBS) $(NETLIBS)
172 gpg_LDADD = $(LDADD) $(SQLITE3_LIBS) $(LIBGCRYPT_LIBS) $(LIBREADLINE) \
173              $(LIBASSUAN_LIBS) $(GPG_ERROR_LIBS) \
174              $(LIBICONV) $(resource_objs) $(extra_sys_libs)
175 gpg_LDFLAGS = $(extra_bin_ldflags)
176 gpgv_LDADD = $(LDADD) $(LIBGCRYPT_LIBS) \
177               $(GPG_ERROR_LIBS) \
178               $(LIBICONV) $(resource_objs) $(extra_sys_libs)
179 gpgv_LDFLAGS = $(extra_bin_ldflags)
180
181 gpgcompose_LDADD = $(LDADD) $(SQLITE3_LIBS) $(LIBGCRYPT_LIBS) $(LIBREADLINE) \
182              $(LIBASSUAN_LIBS) $(GPG_ERROR_LIBS) \
183              $(LIBICONV) $(resource_objs) $(extra_sys_libs)
184 gpgcompose_LDFLAGS = $(extra_bin_ldflags)
185
186 t_common_ldadd =
187 module_tests = t-rmd160 t-keydb t-keydb-get-keyblock t-stutter
188 t_rmd160_SOURCES = t-rmd160.c rmd160.c
189 t_rmd160_LDADD = $(t_common_ldadd)
190 t_keydb_SOURCES = t-keydb.c test-stubs.c $(common_source)
191 t_keydb_LDADD = $(LDADD) $(LIBGCRYPT_LIBS) $(GPG_ERROR_LIBS) \
192               $(LIBICONV) $(t_common_ldadd)
193 t_keydb_get_keyblock_SOURCES = t-keydb-get-keyblock.c test-stubs.c \
194               $(common_source)
195 t_keydb_get_keyblock_LDADD = $(LDADD) $(LIBGCRYPT_LIBS) $(GPG_ERROR_LIBS) \
196               $(LIBICONV) $(t_common_ldadd)
197 t_stutter_SOURCES = t-stutter.c test-stubs.c \
198               $(common_source)
199 t_stutter_LDADD = $(LDADD) $(LIBGCRYPT_LIBS) $(GPG_ERROR_LIBS) \
200               $(LIBICONV) $(t_common_ldadd)
201
202
203 $(PROGRAMS): $(needed_libs) ../common/libgpgrl.a
204
205 # NB: To install gpg and gpgv we use this -hook.  This code has to
206 # duplicate most of the automake generated install-binPROGRAMS target
207 # so that directories are created and the transform feature works.
208 install-exec-hook:
209         @echo "running install-exec-hook"; \
210         echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \
211         $(MKDIR_P) "$(DESTDIR)$(bindir)"; \
212         for p in $(gpg2_hack_list); do \
213           echo "$$p$(EXEEXT) $$p$(EXEEXT)"; done | \
214         sed 's/$(EXEEXT)$$//' | \
215         while read p p1; do if test -f $$p \
216           ; then echo "$$p"; echo "$$p"; else :; fi; \
217         done | \
218         sed -e 'p;s,.*/,,;n;h' \
219             -e 's|.*|.|' \
220             -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
221         sed 'N;N;N;s,\n, ,g' | \
222         $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
223           { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
224             if ($$2 == $$4) files[d] = files[d] " " $$1; \
225             else { print "f", $$3 "/" $$4, $$1; } } \
226           END { for (d in files) print "f", d, files[d] }' | \
227         while read type dir files; do \
228             for f in $$files; do \
229                if test $(use_gpg2_hack) = yes ; \
230                  then f2=`echo "$${f}" | sed 's/$(EXEEXT)$$//'`2$(EXEEXT); \
231                  else f2="$${f}" ;\
232                fi ; \
233                echo "$(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) \
234                      $${f} '$(DESTDIR)$(bindir)/$${f2}'"; \
235                $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) \
236                      $${f} "$(DESTDIR)$(bindir)/$${f2}"; \
237             done; \
238         done
239
240
241 install-data-local:
242         $(mkinstalldirs) $(DESTDIR)$(pkgdatadir)
243         $(INSTALL_DATA) $(srcdir)/options.skel \
244                                 $(DESTDIR)$(pkgdatadir)/gpg-conf.skel
245         $(INSTALL_DATA) $(srcdir)/dirmngr-conf.skel \
246                                 $(DESTDIR)$(pkgdatadir)/dirmngr-conf.skel
247         $(INSTALL_DATA) $(srcdir)/distsigkey.gpg \
248                                 $(DESTDIR)$(pkgdatadir)/distsigkey.gpg
249
250 # NB: For uninstalling gpg and gpgv we use -local because there is
251 # no need for a specific order the targets need to be run.
252 uninstall-local:
253         -@rm $(DESTDIR)$(pkgdatadir)/gpg-conf.skel
254         -@rm $(DESTDIR)$(pkgdatadir)/dirmngr-conf.skel
255         -@rm $(DESTDIR)$(pkgdatadir)/distsigkey.gpg
256         -@files=`for p in $(gpg2_hack_uninst); do echo "$$p"; done | \
257           sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
258               -e 's/$$/$(EXEEXT)/' \
259         `; \
260         echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
261         cd "$(DESTDIR)$(bindir)" && rm -f $$files