1 # Makefile.am for libgpg-error.
2 # Copyright (C) 2003, 2004, 2014 g10 Code GmbH
4 # This file is part of libgpg-error.
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.
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.
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/>.
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.
25 gpg_extra_headers = gpg-extra/errno.h
26 extra_cppflags = -idirafter gpg-extra
32 localedir = $(datadir)/locale
34 bin_PROGRAMS = gpg-error
37 noinst_PROGRAMS = gen-w32-lock-obj
39 noinst_PROGRAMS = gen-posix-lock-obj
42 # Distributed lock object definitions for cross compilation.
44 syscfg/lock-obj-pub.mingw32.h \
45 syscfg/lock-obj-pub.arm-unknown-linux-androideabi.h
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
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 \
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
65 tmp_files = _mkerrcodes.h _gpg-error.def.h mkw32errmap.tab.h mkw32errmap.map.c
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
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)
81 $(LTRCCOMPILE) -i "$<" -o "$@"
83 gpg_error_res = versioninfo.lo
84 no_undefined = -no-undefined
85 export_symbols = -export-symbols gpg-error.def
87 install-def-file: gpg-error.def
88 -$(INSTALL) -d $(DESTDIR)$(libdir)
89 $(INSTALL) gpg-error.def $(DESTDIR)$(libdir)/gpg-error.def
92 -rm $(DESTDIR)$(libdir)/gpg-error.def
94 libgpg_error_la_DEPENDENCIES = $(gpg_error_res) gpg-error.def
98 arch_sources = posix-lock.c posix-lock-obj.h posix-thread.c
105 intllibs = @LTLIBINTL@
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)
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
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)
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@
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 >$@
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 >$@
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 >$@
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 >$@
149 code-to-errno.h: Makefile mkerrnos.awk errnos.in
150 $(AWK) -f $(srcdir)/mkerrnos.awk $(srcdir)/errnos.in >$@
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 >$@
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
171 echo "/*dummy*/" > $@
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 | \
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
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
194 code-from-errno.h: mkerrcodes Makefile
195 ./mkerrcodes | $(AWK) -f $(srcdir)/mkerrcodes2.awk >$@
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 >$@
203 mkheader: mkheader.c Makefile
204 $(CC_FOR_BUILD) -g -O0 -I. -I$(srcdir) -o $@ $(srcdir)/mkheader.c
206 parts_of_gpg_error_h = \
215 # If we are cross-compiling we better make sure that no stale native
216 # lock include file will be found by mkheader.
218 pre_mkheader_cmds = -rm lock-obj-pub.native.h 2>/dev/null
220 pre_mkheader_cmds = :
221 parts_of_gpg_error_h += ./lock-obj-pub.native.h
223 lock-obj-pub.native.h: Makefile gen-posix-lock-obj posix-lock-obj.h
224 ./gen-posix-lock-obj >$@
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
231 ./mkheader $(host_os) $(host_triplet) $(srcdir)/gpg-error.h.in \
232 $(PACKAGE_VERSION) $(VERSION_NUMBER) >$@
237 -$(MKDIR_P) "$(DESTDIR)$(includedir)/gpg-extra"
238 $(INSTALL_DATA) gpg-extra/errno.h \
239 "$(DESTDIR)$(includedir)/gpg-extra/errno.h"