Updating to version 1.13. Libgcrypt depends on libgpg-error
[platform/upstream/libgpg-error.git] / src / Makefile.am
1 # Makefile.am for libgpg-error.
2 # Copyright (C) 2003, 2004, 2014 g10 Code GmbH
3 #
4 # This file is part of libgpg-error.
5 #
6 # libgpg-error is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU Lesser General Public License as
8 # published by the Free Software Foundation; either version 2.1 of the
9 # License, or (at your option) any later version.
10 #
11 # libgpg-error 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 Lesser General Public License for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this program; if not, see <http://www.gnu.org/licenses/>.
18
19 # We distribute the generated sources err-sources.h and err-codes.h,
20 # because they are needed to build the po directory, and they don't
21 # depend on the configuration anyway.
22
23
24 if HAVE_W32CE_SYSTEM
25 gpg_extra_headers = gpg-extra/errno.h
26 extra_cppflags = -idirafter gpg-extra
27 else
28 gpg_extra_headers =
29 extra_cppflags =
30 endif
31
32 localedir = $(datadir)/locale
33
34 bin_PROGRAMS = gpg-error
35
36 if HAVE_W32_SYSTEM
37 noinst_PROGRAMS = gen-w32-lock-obj
38 else
39 noinst_PROGRAMS = gen-posix-lock-obj
40 endif
41
42 # Distributed lock object definitions for cross compilation.
43 lock_obj_pub = \
44         syscfg/lock-obj-pub.mingw32.h \
45         syscfg/lock-obj-pub.arm-unknown-linux-androideabi.h
46
47 lib_LTLIBRARIES = libgpg-error.la
48 include_HEADERS = gpg-error.h
49 bin_SCRIPTS = gpg-error-config
50 m4datadir = $(datadir)/aclocal
51 m4data_DATA = gpg-error.m4
52
53 EXTRA_DIST = mkstrtable.awk err-sources.h.in err-codes.h.in \
54         mkerrnos.awk errnos.in README \
55         mkerrcodes.awk mkerrcodes1.awk mkerrcodes2.awk mkerrcodes.c \
56         mkheader.c gpg-error.h.in mkw32errmap.c w32-add.h w32ce-add.h \
57         err-sources.h err-codes.h gpg-error-config.in gpg-error.m4 \
58         gpg-error.def.in versioninfo.rc.in \
59         $(lock_obj_pub)
60
61 BUILT_SOURCES = err-sources.h err-codes.h code-to-errno.h code-from-errno.h \
62         err-sources-sym.h err-codes-sym.h errnos-sym.h gpg-error.h \
63         gpg-error.def mkw32errmap.map.c
64
65 tmp_files = _mkerrcodes.h _gpg-error.def.h mkw32errmap.tab.h mkw32errmap.map.c
66
67 CLEANFILES = err-sources.h err-codes.h code-to-errno.h code-from-errno.h \
68         gpg-error.h mkerrcodes mkerrcodes.h gpg-error.def mkw32errmap.tab.h \
69         mkw32errmap.map.c err-sources-sym.h err-codes-sym.h errnos-sym.h \
70         gpg-extra/errno.h mkheader $(tmp_files) lock-obj-pub.native.h
71
72 if HAVE_W32_SYSTEM
73 arch_sources = w32-gettext.c w32-lock.c w32-lock-obj.h w32-thread.c
74 RCCOMPILE = $(RC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
75             -DLOCALEDIR=\"$(localedir)\" $(AM_CPPFLAGS) $(CPPFLAGS)
76 LTRCCOMPILE = $(LIBTOOL) --mode=compile --tag=RC $(RCCOMPILE)
77
78 SUFFIXES = .rc .lo
79
80 .rc.lo:
81         $(LTRCCOMPILE) -i "$<" -o "$@"
82
83 gpg_error_res = versioninfo.lo
84 no_undefined = -no-undefined
85 export_symbols = -export-symbols gpg-error.def
86
87 install-def-file: gpg-error.def
88         -$(INSTALL) -d $(DESTDIR)$(libdir)
89         $(INSTALL) gpg-error.def $(DESTDIR)$(libdir)/gpg-error.def
90
91 uninstall-def-file:
92         -rm $(DESTDIR)$(libdir)/gpg-error.def
93
94 libgpg_error_la_DEPENDENCIES = $(gpg_error_res) gpg-error.def
95 intllibs =
96
97 else
98 arch_sources = posix-lock.c posix-lock-obj.h posix-thread.c
99 gpg_error_res =
100 no_undefined =
101 export_symbols =
102 install-def-file:
103 uninstall-def-file:
104
105 intllibs = @LTLIBINTL@
106
107 endif
108
109
110 libgpg_error_la_LDFLAGS = -version-info \
111   @LIBGPG_ERROR_LT_CURRENT@:@LIBGPG_ERROR_LT_REVISION@:@LIBGPG_ERROR_LT_AGE@ \
112   $(no_undefined) $(export_symbols)
113
114 libgpg_error_la_SOURCES = gpg-error.h gettext.h $(arch_sources) \
115         init.c init.h version.c lock.h thread.h \
116         strsource.c strerror.c code-to-errno.c code-from-errno.c
117
118 # Note that RCCOMPILE needs the same defines as ..._la_CPPFLAGS but
119 # without the extra_cppflags because they may include am -idirafter
120 # which is not supported by the RC compiler.
121 libgpg_error_la_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" $(extra_cppflags)
122 libgpg_error_la_LIBADD = $(gpg_error_res) $(intllibs) $(LIBTHREAD)
123
124 gpg_error_SOURCES = strsource-sym.c strerror-sym.c gpg-error.c
125 gpg_error_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" $(extra_cppflags)
126 gpg_error_LDADD = ./libgpg-error.la @LTLIBINTL@
127
128 # We build err-sources.h and err-codes.h in the source directory.
129 # This is needed because gettext does only look into the source
130 # directory to find the files listed in po/POTFILE.in.  To make these
131 # rules work we also need to depend on Makefile.am and not on the
132 # generated files Makefile.in or Makefile.
133 $(srcdir)/err-sources.h: Makefile.am mkstrtable.awk err-sources.h.in
134         $(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=3 \
135                 $(srcdir)/err-sources.h.in >$@
136
137 err-sources-sym.h: Makefile mkstrtable.awk err-sources.h.in
138         $(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=2 -v nogettext=1 \
139                 $(srcdir)/err-sources.h.in >$@
140
141 $(srcdir)/err-codes.h: Makefile.am mkstrtable.awk err-codes.h.in
142         $(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=3 \
143                 $(srcdir)/err-codes.h.in >$@
144
145 err-codes-sym.h: Makefile mkstrtable.awk err-codes.h.in
146         $(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=2 -v nogettext=1 \
147                 $(srcdir)/err-codes.h.in >$@
148
149 code-to-errno.h: Makefile mkerrnos.awk errnos.in
150         $(AWK) -f $(srcdir)/mkerrnos.awk $(srcdir)/errnos.in >$@
151
152 # It is correct to use $(CPP).  We want the host's idea of the error codes.
153 mkerrcodes.h: Makefile mkerrcodes.awk $(gpg_extra_headers)
154         $(AWK) -f $(srcdir)/mkerrcodes1.awk $(srcdir)/errnos.in >_$@
155         $(CPP) $(CPPFLAGS) $(extra_cppflags) _$@ | grep GPG_ERR_ | \
156                $(AWK) -f $(srcdir)/mkerrcodes.awk >$@
157         -rm _$@
158
159 if HAVE_W32CE_SYSTEM
160 # It is correct to use $(CPP).  We want the host's idea of the error codes.
161 mkw32errmap.tab.h: Makefile mkw32errmap.c
162         $(CPP) -DRESOLVE_MACROS $(srcdir)/mkw32errmap.c | \
163               grep '{&mkw32errmap_marker' >$@
164 mkw32errmap.map.c: mkw32errmap
165         ./mkw32errmap --map > $@
166 gpg-extra/errno.h: mkw32errmap
167         -$(MKDIR_P) gpg-extra
168         ./mkw32errmap > $@
169 else
170 mkw32errmap.map.c:
171         echo "/*dummy*/" > $@
172 endif
173
174 # We use CC proper for preprocessing thus we have to convince it that
175 # the data is really to be preprocessed.
176 gpg-error.def: Makefile gpg-error.def.in
177         cat $(srcdir)/gpg-error.def.in >_$@.h
178         $(CPP) $(DEFAULT_INCLUDES) $(INCLUDES) $(extra_cppflags) _$@.h | \
179           grep -v '^#' >$@
180         -rm _$@.h
181
182 # It is correct to use $(CC_FOR_BUILD) here.  We want to run the
183 # program at build time.
184 mkerrcodes: mkerrcodes.c mkerrcodes.h Makefile
185         $(CC_FOR_BUILD) -I. -I$(srcdir) -o $@ $(srcdir)/mkerrcodes.c
186
187 if HAVE_W32CE_SYSTEM
188 # It is correct to use $(CC_FOR_BUILD) here.  We want to run the
189 # program at build time.
190 mkw32errmap: mkw32errmap.c mkw32errmap.tab.h Makefile
191         $(CC_FOR_BUILD) -I. -I$(srcdir) -o $@ $(srcdir)/mkw32errmap.c
192 endif
193
194 code-from-errno.h: mkerrcodes Makefile
195         ./mkerrcodes | $(AWK) -f $(srcdir)/mkerrcodes2.awk >$@
196
197 errnos-sym.h: Makefile mkstrtable.awk errnos.in
198         $(AWK) -f $(srcdir)/mkstrtable.awk -v textidx=2 -v nogettext=1 \
199                 -v prefix=GPG_ERR_ -v namespace=errnos_ \
200                 $(srcdir)/errnos.in >$@
201
202
203 mkheader: mkheader.c Makefile
204         $(CC_FOR_BUILD) -g -O0 -I. -I$(srcdir) -o $@ $(srcdir)/mkheader.c
205
206 parts_of_gpg_error_h =          \
207         gpg-error.h.in          \
208         err-sources.h.in        \
209         err-codes.h.in          \
210         errnos.in               \
211         w32-add.h               \
212         w32ce-add.h             \
213         $(lock_obj_pub)
214
215 # If we are cross-compiling we better make sure that no stale native
216 # lock include file will be found by mkheader.
217 if CROSS_COMPILING
218 pre_mkheader_cmds = -rm lock-obj-pub.native.h 2>/dev/null
219 else
220 pre_mkheader_cmds = :
221 parts_of_gpg_error_h += ./lock-obj-pub.native.h
222
223 lock-obj-pub.native.h: Makefile gen-posix-lock-obj posix-lock-obj.h
224         ./gen-posix-lock-obj >$@
225 endif
226
227 # We also depend on versioninfo.rc because that is build by
228 # config.status and thus has up-to-date version numbers.
229 gpg-error.h: Makefile mkheader $(parts_of_gpg_error_h) versioninfo.rc
230         $(pre_mkheader_cmds)
231         ./mkheader $(host_os) $(host_triplet)  $(srcdir)/gpg-error.h.in \
232                    $(PACKAGE_VERSION) $(VERSION_NUMBER) >$@
233
234
235 install-data-local:
236 if HAVE_W32CE_SYSTEM
237         -$(MKDIR_P) "$(DESTDIR)$(includedir)/gpg-extra"
238         $(INSTALL_DATA) gpg-extra/errno.h \
239                          "$(DESTDIR)$(includedir)/gpg-extra/errno.h"
240 else
241         :
242 endif