# Makefile for callback

#### Start of system configuration section. ####

HOST = @host@
CPU = @HOST_CPU_C_ABI@

# Directories used by "make":
srcdir = @srcdir@

# Directories used by "make install":
prefix = @prefix@
local_prefix = /usr/local
exec_prefix = @exec_prefix@
libdir = @libdir@
includedir = @includedir@
mandir = @mandir@
datadir = @datadir@
datarootdir = @datarootdir@
htmldir = $(datadir)/html

# Programs used by "make":
# C compiler
CC = @CC@
CFLAGS = @CFLAGS@
CPP = @CPP@
# C++ compiler
CXX = @CXX@
CXXFLAGS = @CXXFLAGS@
# Both C and C++ compiler
CPPFLAGS = @CPPFLAGS@
INCLUDES = -I. -I$(srcdir) -I.. -I$(srcdir)/.. -I$(srcdir)/vacall_r
LDFLAGS = @LDFLAGS@
LIBTOOL = @LIBTOOL@
LIBTOOL_COMPILE = $(LIBTOOL) --mode=compile
LIBTOOL_LINK = $(LIBTOOL) --mode=link
LIBTOOL_INSTALL = $(LIBTOOL) --mode=install
LIBTOOL_UNINSTALL = $(LIBTOOL) --mode=uninstall
AR = @AR@
AR_FLAGS = rc
RANLIB = @RANLIB@
RM = rm -f
@SET_MAKE@

# Programs used by "make install":
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@

# Libtool options for linking with the thread library.
LTLIBTHREAD = @LTLIBTHREAD@

#### End of system configuration section. ####

SHELL = /bin/sh

# Needed by $(LIBTOOL).
top_builddir = ..

# Limit the set of exported symbols, on those platforms where libtool supports it.
# Currently this excludes the symbols from gnulib modules.
LIBCALLBACK_EXPORTED_SYMBOLS_REGEX = '^callback_|_callback$$|^trampoline_r_data0$$'

# Before making a release, change this according to the libtool documentation,
# section "Library interface versions".
LIBCALLBACK_VERSION_INFO = 1:4:0

all : all-subdirs libcallback.la $(srcdir)/callback.3 $(srcdir)/callback.html

all-subdirs : force
	cd @callback_subdir@ && $(MAKE) all

callback-libapi.lo : $(srcdir)/callback-libapi.c $(srcdir)/callback.h $(srcdir)/trampoline_r/trampoline_r.h ../config.h
	$(LIBTOOL_COMPILE) $(CC) $(INCLUDES) -I$(srcdir)/trampoline_r $(CPPFLAGS) $(CFLAGS) -c $(srcdir)/callback-libapi.c

callback-compat.lo : $(srcdir)/callback-compat.c ../config.h
	$(LIBTOOL_COMPILE) $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -c $(srcdir)/callback-compat.c

libcallback.la : vacall_r/libvacall.la trampoline_r/libtrampoline.la callback-libapi.lo callback-compat.lo
	$(LIBTOOL_LINK) $(CC) -o libcallback.la -rpath $(libdir) -no-undefined -export-symbols-regex $(LIBCALLBACK_EXPORTED_SYMBOLS_REGEX) -version-info $(LIBCALLBACK_VERSION_INFO) vacall_r/vacall.lo vacall_r/vacall-libapi.lo vacall_r/vacall-structcpy.lo trampoline_r/*.lo callback-libapi.lo callback-compat.lo ../gnulib-lib/libgnu.la $(LDFLAGS) $(LTLIBTHREAD)

# Installs the library and include files only. Typically called with only
# $(libdir) and $(includedir) - don't use $(prefix) and $(exec_prefix) here.
install-lib : all force
	cd vacall_r && $(MAKE) install-lib libdir='$(libdir)' includedir='$(includedir)'
	mkdir -p $(libdir)
	$(LIBTOOL_INSTALL) $(INSTALL_DATA) libcallback.la $(libdir)/libcallback.la
	mkdir -p $(includedir)
	$(INSTALL_DATA) $(srcdir)/callback.h $(includedir)/callback.h

install : force
	cd vacall_r && $(MAKE) install
	mkdir -p $(DESTDIR)$(prefix)
	mkdir -p $(DESTDIR)$(exec_prefix)
	mkdir -p $(DESTDIR)$(libdir)
	$(LIBTOOL_INSTALL) $(INSTALL_DATA) libcallback.la $(DESTDIR)$(libdir)/libcallback.la
	mkdir -p $(DESTDIR)$(includedir)
	$(INSTALL_DATA) $(srcdir)/callback.h $(DESTDIR)$(includedir)/callback.h
	mkdir -p $(DESTDIR)$(mandir)
	mkdir -p $(DESTDIR)$(mandir)/man3
	$(INSTALL_DATA) $(srcdir)/callback.3 $(DESTDIR)$(mandir)/man3/callback.3
	mkdir -p $(DESTDIR)$(datadir)
	mkdir -p $(DESTDIR)$(htmldir)
	$(INSTALL_DATA) $(srcdir)/callback.html $(DESTDIR)$(htmldir)/callback.html

installdirs : force
	cd vacall_r && $(MAKE) installdirs
	mkdir -p $(DESTDIR)$(prefix)
	mkdir -p $(DESTDIR)$(exec_prefix)
	mkdir -p $(DESTDIR)$(libdir)
	mkdir -p $(DESTDIR)$(includedir)
	mkdir -p $(DESTDIR)$(mandir)
	mkdir -p $(DESTDIR)$(mandir)/man3
	mkdir -p $(DESTDIR)$(datadir)
	mkdir -p $(DESTDIR)$(htmldir)

uninstall : force
	cd vacall_r && $(MAKE) uninstall
	$(LIBTOOL_UNINSTALL) $(RM) $(DESTDIR)$(libdir)/libcallback.la
	$(RM) $(DESTDIR)$(includedir)/callback.h
	$(RM) $(DESTDIR)$(mandir)/man3/callback.3
	$(RM) $(DESTDIR)$(htmldir)/callback.html

test1.@OBJEXT@ : $(srcdir)/test1.c $(srcdir)/callback.h $(srcdir)/vacall_r/vacall_r.h
	$(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -c $(srcdir)/test1.c

test1 : test1.@OBJEXT@ libcallback.la
	$(LIBTOOL_LINK) $(CC) $(CFLAGS) @GCC_X_NONE@ test1.@OBJEXT@ libcallback.la $(LDFLAGS) -o test1

minitests.@OBJEXT@ : $(srcdir)/minitests.c $(srcdir)/tests.c $(srcdir)/callback.h $(srcdir)/vacall_r/vacall_r.h
	$(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -c $(srcdir)/minitests.c

minitests.s : $(srcdir)/minitests.c $(srcdir)/tests.c $(srcdir)/callback.h $(srcdir)/vacall_r/vacall_r.h
	$(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -S $(srcdir)/minitests.c

minitests : minitests.@OBJEXT@ libcallback.la
	$(LIBTOOL_LINK) $(CC) $(CFLAGS) @GCC_X_NONE@ minitests.@OBJEXT@ libcallback.la $(LDFLAGS) -o minitests

minitests-c++.@OBJEXT@ : $(srcdir)/minitests-c++.cc $(srcdir)/minitests.c $(srcdir)/tests.c $(srcdir)/callback.h $(srcdir)/vacall_r/vacall_r.h
	$(CXX) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS) -c $(srcdir)/minitests-c++.cc

minitests-c++ : minitests-c++.@OBJEXT@ libcallback.la
	$(LIBTOOL_LINK) $(CXX) $(CXXFLAGS) @GCC_X_NONE@ minitests-c++.@OBJEXT@ libcallback.la $(LDFLAGS) -o minitests-c++

check-subdirs : force
	cd @callback_subdir@ && $(MAKE) check

check : all check-subdirs test1 minitests
	./test1
	./minitests > minitests.out
	LC_ALL=C uniq -u < minitests.out > minitests.output.$(HOST)
	test '!' -s minitests.output.$(HOST)
@IF_CXX@	./minitests-c++ > minitests-c++.out
@IF_CXX@	LC_ALL=C uniq -u < minitests-c++.out > minitests-c++.output.$(HOST)
@IF_CXX@	test '!' -s minitests-c++.output.$(HOST)
@IF_CXX@check : minitests-c++

tests.@OBJEXT@ : $(srcdir)/tests.c $(srcdir)/callback.h $(srcdir)/vacall_r/vacall_r.h
	$(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -c $(srcdir)/tests.c

tests.s : $(srcdir)/tests.c $(srcdir)/callback.h $(srcdir)/vacall_r/vacall_r.h
	$(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -S $(srcdir)/tests.c

tests : tests.@OBJEXT@ libcallback.la
	$(LIBTOOL_LINK) $(CC) $(CFLAGS) @GCC_X_NONE@ tests.@OBJEXT@ libcallback.la $(LDFLAGS) -o tests

extracheck-subdirs : force
	cd @callback_subdir@ && $(MAKE) extracheck

extracheck : all extracheck-subdirs tests
	./tests > tests.out
	LC_ALL=C uniq -u < tests.out > tests.output.$(HOST)
	test '!' -s tests.output.$(HOST)

MOSTLYCLEANDIRS = .libs _libs
MOSTLYCLEANFILES = \
  *.@OBJEXT@ *.lo core \
  libcallback.* \
  test1.@OBJEXT@ test1 \
  minitests.@OBJEXT@ minitests.s minitests minitests.out \
  minitests-c++.@OBJEXT@ minitests-c++ minitests-c++.out \
  tests.@OBJEXT@ tests.s tests tests.out

mostlyclean : force
	cd @callback_subdir@ && $(MAKE) mostlyclean
	$(RM) -r $(MOSTLYCLEANDIRS)
	$(RM) $(MOSTLYCLEANFILES)

clean : force
	cd @callback_subdir@ && $(MAKE) clean
	$(RM) -r $(MOSTLYCLEANDIRS)
	$(RM) $(MOSTLYCLEANFILES)

DISTCLEANFILES = \
  Makefile \
  minitests.output.* minitests-c++.output.* tests.output.*

distclean : force
	cd @callback_subdir@ && if test -f Makefile; then $(MAKE) distclean; fi
	$(RM) -r $(MOSTLYCLEANDIRS)
	$(RM) $(MOSTLYCLEANFILES)
	$(RM) $(DISTCLEANFILES)

maintainer-clean : force
	cd @callback_subdir@ && if test -f Makefile; then $(MAKE) maintainer-clean; fi
	$(RM) -r $(MOSTLYCLEANDIRS)
	$(RM) $(MOSTLYCLEANFILES)
	$(RM) $(DISTCLEANFILES)


# List of source files (committed in version control).
SOURCE_FILES = \
  COPYING MIGRATION PLATFORMS README callback.3 callback.html elf-hack.txt \
  Makefile.maint \
  Makefile.in \
  callback.h \
  callback-libapi.c \
  callback-compat.c \
  test1.c \
  minitests.c minitests-c++.cc \
  tests.c
# List of distributed files generated by Makefile.maint.
GENERATED_FILES = \
  callback.man
# List of distributed files.
DISTFILES = $(SOURCE_FILES) $(GENERATED_FILES)

distdir : $(DISTFILES)
	for file in $(DISTFILES); do \
	  if test -f $$file; then dir='.'; else dir='$(srcdir)'; fi; \
	  cp -p "$$dir/$$file" '$(distdir)'/$$file || exit 1; \
	done
	test -d '$(distdir)'/@callback_subdir@ || mkdir '$(distdir)'/@callback_subdir@; cd @callback_subdir@ && $(MAKE) distdir distdir='$(distdir)'/@callback_subdir@


force :
