##############################################################################
# Copyright 2018-2024,2025 Thomas E. Dickey                                  #
# Copyright 1998-2015,2018 Free Software Foundation, Inc.                    #
#                                                                            #
# Permission is hereby granted, free of charge, to any person obtaining a    #
# copy of this software and associated documentation files (the "Software"), #
# to deal in the Software without restriction, including without limitation  #
# the rights to use, copy, modify, merge, publish, distribute, distribute    #
# with modifications, sublicense, and/or sell copies of the Software, and to #
# permit persons to whom the Software is furnished to do so, subject to the  #
# following conditions:                                                      #
#                                                                            #
# The above copyright notice and this permission notice shall be included in #
# all copies or substantial portions of the Software.                        #
#                                                                            #
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   #
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    #
# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      #
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    #
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER        #
# DEALINGS IN THE SOFTWARE.                                                  #
#                                                                            #
# Except as contained in this notice, the name(s) of the above copyright     #
# holders shall not be used in advertising or otherwise to promote the sale, #
# use or other dealings in this Software without prior written               #
# authorization.                                                             #
##############################################################################
#
#  Author:  Juergen Pfeifer, 1996
#
#  $Id: Makefile.in,v 1.67 2025/10/18 13:40:00 tom Exp $
#
.SUFFIXES:

SHELL		= @SHELL@
VPATH		= @srcdir@
THIS		= Makefile

@SET_DESTDIR@

x		= @EXEEXT@

srcdir		= @srcdir@
prefix		= @prefix@
exec_prefix	= @exec_prefix@
bindir		= @bindir@
datarootdir	= @datarootdir@
datadir		= @datadir@
libdir		= @libdir@
includedir	= @includedir@

INSTALL		= @INSTALL@ @INSTALL_OPT_O@
INSTALL_DATA	= @INSTALL_DATA@

AWK		= @AWK@
LN_S		= @LN_S@

CC		= @CC@
CFLAGS		= @CFLAGS@ @EXTRA_CFLAGS@

CPPFLAGS	= @ACPPFLAGS@ \
		  -DHAVE_CONFIG_H -I$(srcdir)

CCFLAGS		= $(CPPFLAGS) $(CFLAGS)

CFLAGS_NORMAL	= $(CCFLAGS) -DNCURSES_STATIC
CFLAGS_DEBUG	= $(CCFLAGS) -DNCURSES_STATIC @CC_G_OPT@ -DTRACE
CFLAGS_PROFILE	= $(CCFLAGS) -DNCURSES_STATIC -pg
CFLAGS_SHARED	= $(CCFLAGS) @CC_SHARED_OPTS@

CFLAGS_DEFAULT	= $(CFLAGS_@DFT_UPR_MODEL@)

REL_VERSION	= @cf_cv_rel_version@
ABI_VERSION	= @cf_cv_abi_version@
LOCAL_LIBDIR	= @top_builddir@/lib

LINK		= $(CC)
LDFLAGS		= @LDFLAGS@ @LD_MODEL@ @LIBS@

RANLIB		= @RANLIB@
################################################################################
BINDIR		= $(DESTDIR)$(bindir@MERGE_PREFIX@)
DATADIR		= $(DESTDIR)$(datadir@MERGE_PREFIX@)
LIBDIR		= $(DESTDIR)$(libdir@MERGE_PREFIX@)

MY_DATADIR	= $(DATADIR)/@ADA_LIBNAME@
THIS_DATADIR	= $(datadir)/@ADA_LIBNAME@

################################################################################
ada_srcdir	= ../src

LD_FLAGS	= @LD_MODEL@ $(LOCAL_LIBS) @LDFLAGS@ @LIBS@ @LOCAL_LDFLAGS2@ $(LDFLAGS)

ADA		= @cf_ada_compiler@
ADAPREP		= gnatprep
ADAFLAGS	= @ADAFLAGS@ -I$(srcdir)

ADAMAKE		= @cf_ada_make@
ADAMAKEFLAGS	= -a \
	-A$(srcdir) \
	-A$(ada_srcdir) \
	-A$(srcdir)/$(ada_srcdir)

ALIB		= @cf_ada_package@
ABASE		= $(ALIB)-curses
THISLIB		= sample

CARGS		= -cargs $(ADAFLAGS)
LARGS		= -largs -L../lib -l@ADA_LIBNAME@ @TEST_ARG2@ $(LD_FLAGS) @TEST_LIBS2@

PROGS		= tour$x ncurses$x @USE_GNAT_SIGINT@ rain$x

################################################################################

@MAKE_PHONY@.PHONY :	all
@MAKE_PHONY@.PHONY :	clean
@MAKE_PHONY@.PHONY :	distclean
@MAKE_PHONY@.PHONY :	install
@MAKE_PHONY@.PHONY :	install.examples
@MAKE_PHONY@.PHONY :	install.libs
@MAKE_PHONY@.PHONY :	libs
@MAKE_PHONY@.PHONY :	mostlyclean
@MAKE_PHONY@.PHONY :	realclean
@MAKE_PHONY@.PHONY :	sources
@MAKE_PHONY@.PHONY :	uninstall
@MAKE_PHONY@.PHONY :	uninstall.examples
@MAKE_PHONY@.PHONY :	uninstall.libs

all ::  $(PROGS)
	@echo made $@

sources :
	@echo made $@

libs \
install \
install.libs ::	$(PROGS)
	@echo made $@

uninstall \
uninstall.libs ::
	@echo made $@

install.examples :: $(BINDIR) $(PROGS)
	$(INSTALL) $(PROGS) $(BINDIR)

install.examples :: $(MY_DATADIR)
	$(INSTALL_DATA) explain.txt $(MY_DATADIR)

uninstall.examples ::
	-( cd $(BINDIR) && rm -f $(PROGS) )
	-rmdir $(BINDIR)
	-rm -f $(MY_DATADIR)/explain.txt
	-rmdir $(MY_DATADIR)

$(BINDIR) \
$(MY_DATADIR) :
	mkdir -p $@

AUTO_SRC = $(THISLIB)-explanation.adb

ncurses$x : $(AUTO_SRC)
	$(ADAMAKE) $(ADAMAKEFLAGS) ncurses $(CARGS) $(LARGS)

tour$x : $(AUTO_SRC)
	$(ADAMAKE) $(ADAMAKEFLAGS) tour $(CARGS) $(LARGS)

rain$x : $(AUTO_SRC)
	$(ADAMAKE) $(ADAMAKEFLAGS) rain $(CARGS) $(LARGS)

mostlyclean:
	@echo made $@

clean :: mostlyclean
	rm -f *.o *.ali b_t*.* *.s $(PROGS) a.out core b_*_test.c *.xr[bs] \
	rm -f $(AUTO_SRC)
	rm -f trace screendump b~*.ad[bs]

distclean :: clean
	rm -f Makefile

realclean :: distclean
	@echo made $@

$(THISLIB)-explanation.adb : $(srcdir)/$(THISLIB)-explanation.adb_p
	rm -f $@
	$(AWK) -v this_datadir=$(THIS_DATADIR) -f $(srcdir)/split-path.awk < $(srcdir)/$(THISLIB)-explanation.adb_p  >$@
