Commit 4e6174d4 authored by Vivien Kraus's avatar Vivien Kraus
Browse files

First commit!

parents
((nil
(compile-command . "cd @abs_top_builddir@ && make -j 4")
(eval
. (setq company-clang-arguments
(split-string
"-I@abs_top_srcdir@ -I@abs_top_builddir@ -I@abs_top_srcdir@/lib -I@abs_top_builddir@/lib -I@abs_top_srcdir@/src -I@abs_top_builddir@/src @CFLAGS@ @CPPFLAGS@ @OPENMP_CFLAGS@ @ASAN_CFLAGS@"
)
)
)
)
)
.deps
.dir-locals.el
**/*~
Makefile.in
aclocal.m4
ar-lib
autom4te.cache
compile
config.guess
config.h.in
config.sub
configure
depcomp
devel-build
indent.stamp
install-sh
libtarot-*.tar.gz
ltmain.sh
missing
m4/libtool.m4
m4/ltoptions.m4
m4/ltversion.m4
m4/ltsugar.m4
m4/lt~obsolete.m4
test-driver
Vivien Kraus <vivien@planete-kraus.eu>
\ No newline at end of file
/usr/share/automake-1.15/COPYING
\ No newline at end of file
/usr/share/automake-1.15/INSTALL
\ No newline at end of file
bin_PROGRAMS =
lib_LTLIBRARIES = libtarot.la
libtarot_la_SOURCES = \
src/_tarot_count_cards.c \
src/_tarot_count_handful.c \
src/_tarot_has_lead_suit.c \
src/_tarot_n_cards_in_trick.c \
src/_tarot_n_players_between.c \
src/_tarot_strongest_trump.c \
src/tarot_decompose.c \
src/tarot_game_bids.c \
src/tarot_game_call.c \
src/tarot_game_cards.c \
src/tarot_game_decl.c \
src/tarot_game_discard.c \
src/tarot_game_dog.c \
src/tarot_game_handful.c \
src/tarot_game_init.c \
src/tarot_game_options.c \
src/tarot_game_state.c \
src/tarot_game_trick.c \
src/tarot_game_trick_card.c \
src/tarot_libtarot_version.c \
src/tarot_of.c \
src/tarot_private.h \
src/tarot_strerror.c
libtarot_la_CFLAGS = $(OPENMP_CFLAGS) $(ASAN_CFLAGS)
libtarot_la_LDFLAGS = -no-undefined -version-info $(LIBTAROT_VERSION_INFO)
libtarot_la_LIBADD = $(ASAN_LIBS)
include_HEADERS = src/tarot.h
TESTS = \
check_composition \
check_game_init
check_PROGRAMS = \
check_composition \
check_game_init
check_composition_SOURCES = src/check_composition.c
check_composition_CFLAGS = $(ASAN_CFLAGS)
check_composition_LDADD = libtarot.la
check_composition_LIBS = $(ASAN_LIBS)
check_game_init_SOURCES = src/check_game_init.c
check_game_init_CFLAGS = $(ASAN_CFLAGS)
check_game_init_LDADD = libtarot.la
check_game_init_LIBS = $(ASAN_LIBS)
INDENTED_FILES = \
$(include_HEADERS) \
$(libtarot_la_SOURCES) \
$(check_composition_SOURCES) \
$(check_game_init_SOURCES)
ACLOCAL_AMFLAGS = -I m4
dist_noinst_SCRIPTS = bootstrap.sh
EXTRA_DIST = $(srcdir)/indent.stamp .gitignore
$(srcdir)/indent.stamp: $(INDENTED_FILES)
if HAVE_INDENT
(cd $(srcdir) && $(INDENT) -gnu $(INDENTED_FILES))
echo "Done!" > $(srcdir)/indent.stamp
else
@ >&2 echo "ERROR: you have changed the source code, \
but you don't have indent installed."
endif
No release yet.
\ No newline at end of file
This is a standard autotools-based project.
\ No newline at end of file
#!/bin/sh
autoreconf --warnings=all --warnings=error --install || exit 1
mkdir -p devel-build || exit 1
cd devel-build || exit 1
# Please also check out hooks/pre-commit.sh
../configure \
--enable-indent \
CPPFLAGS="-Wall -Wextra -Werror -g -O0" || exit 1
rm -f ../.dir-locals.el || exit 1
ln -s devel-build/.dir-locals.el ../.dir-locals.el || exit 1
make -j 16 distcheck || exit 1
rm -f ../.git/hooks/pre-commit.sh || exit 1
ln -s ../../hooks/pre-commit.sh ../.git/hooks/pre-commit || exit 1
chmod ugo+x ../.git/hooks/pre-commit || exit 1
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT([libtarot], [devel], [vivien@planete-kraus.eu])
AC_SUBST([LIBTAROT_VERSION_INFO], [[0:0:0]])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIRS([m4])
AC_ARG_ENABLE([indent],
AS_HELP_STRING([--enable-indent],
[use the indent program (for contributors) (default: if available)]))
AC_ARG_VAR([INDENT],
AS_HELP_STRING([indent program (optional, but strongly recommanded
for contributors)]))
# Checks for programs.
AC_PROG_CC
AM_INIT_AUTOMAKE([subdir-objects])
AM_PROG_AR
LT_INIT
AX_INDENT
# Checks for libraries.
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
AC_OPENMP
AX_ASAN
# Checks for library functions.
AC_CONFIG_FILES([Makefile .dir-locals.el])
AC_OUTPUT
#!/bin/sh
# https://stackoverflow.com/questions/12320220/testing-what-is-about-to-be-committed-in-a-pre-commit-hook
tmpdir=$(mktemp -d) # Or put it wherever you like
git archive HEAD | tar -xf - -C "$tmpdir"
git diff --staged | patch -p1 -d "$tmpdir"
cd "$tmpdir"
autoreconf --warnings=all --warnings=error --install || exit 1
./configure \
--enable-indent\
CPPFLAGS="-Wall -Wextra -Werror -g -O0" || exit 1
make -j 16 distcheck
AC_DEFUN([AX_ASAN], [
AC_ARG_ENABLE([asan],
AS_HELP_STRING([--disable-asan], [Disable AddressSanitizer support])
)
AS_IF([test "x$enable_asan" != "xno"], [
NORMAL_CFLAGS="$CFLAGS"
NORMAL_LIBS="$LIBS"
dnl Check if -fsanitize=address with -lasan works
CFLAGS="$NORMAL_CFLAGS -fsanitize=address"
CXXFLAGS="$NORMAL_CXXFLAGS -fsanitize=address"
LIBS="$NORMAL_LIBS -lasan"
AC_LANG_PUSH([C])
AC_MSG_CHECKING([for $CC option to support AddressSanitizer])
AC_LINK_IFELSE([
AC_LANG_PROGRAM([[#include <stdlib.h>]], [[
free (malloc (5));
return 0;
]])
], [
AC_SUBST([ASAN_CFLAGS], [-fsanitize=address])
AC_SUBST([ASAN_LIBS], [-lasan])
AC_MSG_RESULT([-fsanitize=address with -lasan])
])
AC_LANG_POP([C])
CFLAGS="$NORMAL_CFLAGS"
LIBS="$NORMAL_LIBS"
])
])
AC_DEFUN([AX_INDENT], [
AC_ARG_ENABLE([indent],
[AS_HELP_STRING([--enable-indent],
[use the indent program (required for contributors,
default: if available)])])
AC_ARG_VAR([INDENT],
[indent program (optional, but strongly
recommended for contributors, default: search for 'indent',
pass 'no' to disable the check)])
AS_IF([test "x$INDENT" != "xno"], [
AC_PATH_PROG([INDENT], [indent], [no])
])
AM_CONDITIONAL([HAVE_INDENT], [test "x$INDENT" != "xno"])
AS_IF([test "x$enable_indent" = "xyes" && test "x$INDENT" = "xno"],
AC_MSG_FAILURE([Requested indent program not found.]))
])
#include "tarot_private.h"
int
_tarot_count_cards (unsigned int n_players,
unsigned int *n_cards, unsigned int *n_dog)
{
switch (n_players)
{
case 3:
*n_cards = 24;
*n_dog = 6;
break;
case 4:
*n_cards = 18;
*n_dog = 6;
break;
case 5:
*n_cards = 15;
*n_dog = 3;
break;
default:
return 1;
}
return 0;
}
#include "tarot_private.h"
int
_tarot_count_handful (unsigned int n_players,
unsigned int *s, unsigned int *d, unsigned int *t)
{
switch (n_players)
{
case 3:
*s = 13;
*d = 15;
*t = 18;
break;
case 4:
*s = 10;
*d = 13;
*t = 15;
break;
case 5:
*s = 8;
*d = 10;
*t = 13;
break;
default:
return 1;
}
return 0;
}
#include "tarot_private.h"
int
_tarot_has_lead_suit (const TarotCard * cards, unsigned int n,
TarotSuit * suit)
{
unsigned int j = 0;
for (j = 0; j < n; ++j)
{
if (cards[j] != TAROT_EXCUSE)
{
TarotNumber n;
tarot_decompose (cards[j], &n, suit);
return 1;
}
}
return 0;
}
#include "tarot_private.h"
unsigned int
_tarot_n_cards_in_trick (const TarotGame * game, unsigned int i_trick)
{
if (i_trick < game->i_trick)
return game->n_players;
else if (i_trick == game->i_trick)
return game->n_cards_in_trick;
return 0;
}
#include "tarot_private.h"
unsigned int
_tarot_n_players_between (unsigned int n_players, TarotPlayer start,
TarotPlayer end)
{
if (end >= start)
return (end - start);
return end + n_players - start;
}
#include "tarot_private.h"
TarotNumber
_tarot_strongest_trump (const TarotCard * cards, unsigned int n)
{
unsigned int j = 0;
TarotNumber ret;
TarotSuit s;
for (j = 0; j < n; ++j)
{
if (tarot_decompose (cards[j], &ret, &s) == TAROT_OK)
{
if (s == TAROT_TRUMPS)
{
return ret;
}
}
}
return 0;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment