Blob Blame History Raw
#  GnuTLS --- Guile bindings for GnuTLS.
#  Copyright (C) 2007-2014, 2016 Free Software Foundation, Inc.
#
#  GnuTLS is free software; you can redistribute it and/or
#  modify it under the terms of the GNU Lesser General Public
#  License as published by the Free Software Foundation; either
#  version 2.1 of the License, or (at your option) any later version.
#
#  GnuTLS is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#  Lesser General Public License for more details.
#
#  You should have received a copy of the GNU Lesser General Public
#  License along with GnuTLS; if not, write to the Free Software
#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

GUILE_FOR_BUILD =						\
  GUILE_AUTO_COMPILE=0 $(GUILE) -L $(top_srcdir)/guile/modules

noinst_HEADERS = errors.h utils.h

EXTRA_DIST =					\
  make-enum-map.scm make-smob-types.scm		\
  make-enum-header.scm make-smob-header.scm

# Files generated by the (gnutls build ...) modules.
GENERATED_BINDINGS =				\
  enum-map.i.c smob-types.i.c enums.h smobs.h

BUILT_SOURCES =					\
  $(GENERATED_BINDINGS)				\
  core.x errors.x

CLEANFILES = $(BUILT_SOURCES)

guileextension_LTLIBRARIES  = guile-gnutls-v-2.la

# Use '-module' to build a "dlopenable module", in Libtool terms.
# Use '-undefined' to placate Libtool on Windows; see
# <https://lists.gnutls.org/pipermail/gnutls-devel/2014-December/007294.html>.
guile_gnutls_v_2_la_LDFLAGS = -module -no-undefined

# Linking against GnuTLS.
GNUTLS_CORE_LIBS  = $(top_builddir)/lib/libgnutls.la

# Linking against Gnulib modules.
GNULIB_LIBS    = $(top_builddir)/gl/libgnu.la
GNULIB_CFLAGS  = -I$(top_builddir)/gl -I$(top_srcdir)/gl


guile_gnutls_v_2_la_SOURCES = core.c errors.c utils.c
guile_gnutls_v_2_la_CFLAGS =			\
  $(AM_CFLAGS) $(GNULIB_CFLAGS) $(GUILE_CFLAGS)
guile_gnutls_v_2_la_LIBADD = \
	$(GNUTLS_CORE_LIBS) $(GNULIB_LIBS) \
	$(GUILE_LDFLAGS)

AM_CPPFLAGS = \
	-I$(top_srcdir)/lib/includes \
	-I$(top_builddir)/lib/includes	\
	-I$(top_srcdir)/extra/includes \
	-I$(top_builddir) \
	-I$(builddir)

if HAVE_GCC

AM_CFLAGS = -Wall -Wextra

# Generated `.x' files and Guile's `scm_c_define_gsubr ()' require
# `-Wno-strict-prototypes'.  This trick makes sure `-Wno-s-p' appears
# after `-Ws-p'.
AM_CFLAGS += -Wno-strict-prototypes

# Functions generated from 'SCM_SMOB_PRINT' & co. typically have
# unused parameters.
AM_CFLAGS += -Wno-unused-parameter

# The `-fgnu89-inline' option appeared in GCC 4.1.3.
if HAVE_GCC_GNU89_INLINE_OPTION

# Guile and GMP currently rely on GNU inline semantics, not C99 inline.
AM_CFLAGS += -fgnu89-inline

endif HAVE_GCC_GNU89_INLINE_OPTION

endif HAVE_GCC


enums.h: $(srcdir)/make-enum-header.scm
	$(AM_V_GEN)$(GUILE_FOR_BUILD) "$^" > "$@.tmp"
	$(AM_V_at)mv "$@.tmp" "$@"

enum-map.i.c: $(srcdir)/make-enum-map.scm
	$(AM_V_GEN)$(GUILE_FOR_BUILD) "$^" > "$@.tmp"
	$(AM_V_at)mv "$@.tmp" "$@"

smobs.h: $(srcdir)/make-smob-header.scm
	$(AM_V_GEN)$(GUILE_FOR_BUILD) "$^" > "$@.tmp"
	$(AM_V_at)mv "$@.tmp" "$@"

smob-types.i.c: $(srcdir)/make-smob-types.scm
	$(AM_V_GEN)$(GUILE_FOR_BUILD) "$^" > "$@.tmp"
	$(AM_V_at)mv "$@.tmp" "$@"


# C file snarfing.

# `$(GUILE_CFLAGS)' may contain a series of `-I' switches so it must be
# included here, even though we'd really want `$(GUILE_CPPFLAGS)'.
snarfcppopts = $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
	       $(CFLAGS) $(guile_gnutls_v_2_la_CFLAGS)

# Note: we cannot use the portable ".c.x" form, since that leads
# prerequisites to be ignored:
# <https://lists.gnutls.org/pipermail/gnutls-devel/2013-September/006453.html>.
%.x: %.c $(GENERATED_BINDINGS)
	$(AM_V_GEN)$(guile_snarf) -o $@ $< $(snarfcppopts)

# Target used by doc/Makefile, to create all built sources necessary
# for generating the manual.

.PHONY: built-sources
built-sources: $(BUILT_SOURCES)