linije

Клон игре Color lines
git clone https://git.sr.ht/~strahinja/linije
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

чување 66d911adc541ddb9914eb1160c93dd1537f6a692
родитељ 5d62a1e1a90136e85282d7d1e8b3b6a5052e245b
Аутор: Страхиња Радић <sr@strahinja.org>
Датум:   Thu,  7 May 2026 07:47:36 +0000

Synchronize build files with the rest of my projects; update copyright year

Diffstat:
MINSTALL | 33+++++++++++++++++----------------
MMakefile | 7++++---
MREADME | 2+-
Aconfig.Haiku | 21+++++++++++++++++++++
Aconfig.Linux | 17+++++++++++++++++
Aconfig.OpenBSD | 18++++++++++++++++++
Dconfig.mk | 28----------------------------
Mlib/makedate | 42++++++++++++++++++++++++++++++++++++++----
Mlib/makeversion | 46++++++++++++++++++++++++++++++++++++++++------
Mlib/mkpack | 4++--
Mlinije.c | 11++++++++---
Mlocal.h.in | 2+-
Mversion.h.in | 2+-
измењених датотека: 13, додавања: 168(+), брисања: 65(-)

diff --git a/INSTALL b/INSTALL @@ -1,11 +1,13 @@ Prerequisites ============= -* C compiler - defaults in config.mk +* C compiler - defaults in config.mk (HaikuOS needs Clang/LLVM) * libSDL v3 (SDL3, SDL3_image - as of 2025-07, build from source: https://github.com/libsdl-org/SDL https://github.com/libsdl-org/SDL_image - Confirmed as needed in OpenBSD and Alpine) + Confirmed as still needed in OpenBSD and Alpine; specifically needs + SDL_SCALEMODE_PIXELART from newer versions of SDL3, absent in current SDL3 + port in OpenBSD) Install @@ -13,6 +15,16 @@ Install $ git clone https://git.sr.ht/~strahinja/linije $ cd linije + $ cp config.$(uname -s) config.mk + $ su + # make install + +With got[1]: + + $ got clone https://git.sr.ht/~strahinja/linije + $ got checkout linije.git + $ cd sled + $ cp config.$(uname -s) config.mk $ su # make install @@ -24,18 +36,7 @@ The file config.mk will be sourced when building targets which also accept configuration through environment variables. For example, CPPFLAGS and PREFIX are specified in config.mk. +Initially, there will be no config.mk, you will need to copy one of the +customized config.* files or write your own: -OpenBSD -------- - -Before running make(1), comment the _CPPFLAGS and INCLUDE definitions in -config.mk above the line with the "OpenBSD" comment and uncomment the ones below -it: - - #_CPPFLAGS = -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L \ - # -D_XOPEN_SOURCE=700 - #INCLUDE = -I/usr/include - # OpenBSD - _CPPFLAGS = -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L \ - -D_XOPEN_SOURCE=700 -D_BSD_SOURCE - INCLUDE = -I/usr/local/include + $ cp config.$(uname -s) config.mk || echo Write config.mk from scratch diff --git a/Makefile b/Makefile @@ -2,6 +2,7 @@ include config.mk +.SUFFIXES: .SUFFIXES: .c .o .h.in .h .h.in.h: @@ -24,9 +25,9 @@ makedate: makeversion: sh lib/makeversion -l -hiscore.o: hiscore.c +hiscore.o: hiscore.c hiscore.h -linije.o: linije.c local.h version.h +linije.o: linije.c hiscore.h local.h version.h version.h: version.h.in date version @@ -57,4 +58,4 @@ uninstall: pack: all sh -x lib/mkpack -.PHONY: all clean install pack uninstall +.PHONY: all clean install makedate makeversion pack uninstall diff --git a/README b/README @@ -14,7 +14,7 @@ License ------- linije - Color lines clone -Copyright (C) 2025 Strahinya Radich +Copyright (C) 2025-2026 Strahinya Radich This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/config.Haiku b/config.Haiku @@ -0,0 +1,21 @@ +# TODO: Testing +CC = clang +CFLAGS = -I. -Os -Wextra -Wall -pedantic -std=c99 +CPPFLAGS = -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L \ + -D_XOPEN_SOURCE=700 -DNDEBUG #-I/usr/local/include +DESTDIR = /boot/home/config/non-packaged +INSTALL = install +LIBS = -lSDL3_image -lSDL3 -lm +SRC = hiscore.c linije.c +HEADERS = hiscore.h local.h +OBJS = hiscore.o linije.o +PREFIX = +PROG = linije + +# Derived macros +BINDIR = $(DESTDIR)$(PREFIX)/bin +# TODO: Test +DATADIR = $(DESTDIR)$(PREFIX)/share/$(PROG) +DOCDIR = $(DESTDIR)$(PREFIX)/documentation/$(PROG) +MANPREFIX = $(DESTDIR)$(PREFIX)/documentation/man +#MANPAGE = $(PROG).1 diff --git a/config.Linux b/config.Linux @@ -0,0 +1,17 @@ +CFLAGS = -Os -Wextra -Wall -pedantic -std=c99 +CPPFLAGS = -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L \ + -D_XOPEN_SOURCE=700 -DNDEBUG -I/usr/local/include +INSTALL = install +LIBS = -lSDL3_image -lSDL3 -lm +SRC = hiscore.c linije.c +HEADERS = hiscore.h local.h +OBJS = hiscore.o linije.o +PREFIX = /usr/local +PROG = linije + +# Derived macros +BINDIR = $(DESTDIR)$(PREFIX)/bin +DATADIR = $(DESTDIR)$(PREFIX)/share/$(PROG) +DOCDIR = $(DESTDIR)$(PREFIX)/share/doc/$(PROG) +MANPREFIX = $(DESTDIR)$(PREFIX)/share/man +#MANPAGE = $(PROG).1 diff --git a/config.OpenBSD b/config.OpenBSD @@ -0,0 +1,18 @@ +CFLAGS = -Os -Wextra -Wall -pedantic -std=c99 +CPPFLAGS = -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L \ + -D_XOPEN_SOURCE=700 -D_BSD_SOURCE -DNDEBUG \ + -I/usr/local/include +INSTALL = install +LIBS = -lSDL3_image -lSDL3 -lm +SRC = hiscore.c linije.c +HEADERS = hiscore.h local.h +OBJS = hiscore.o linije.o +PREFIX = /usr/local +PROG = linije + +# Derived macros +BINDIR = $(DESTDIR)$(PREFIX)/bin +DATADIR = $(DESTDIR)$(PREFIX)/share/$(PROG) +DOCDIR = $(DESTDIR)$(PREFIX)/share/doc/$(PROG) +MANPREFIX = $(DESTDIR)$(PREFIX)/man +#MANPAGE = $(PROG).1 diff --git a/config.mk b/config.mk @@ -1,28 +0,0 @@ -#CC = cc -CFLAGS = -Os -Wall -pedantic -std=c99 -#CFLAGS = -O2 -Wall -pedantic -std=c99 -#CFLAGS = -Og -ggdb -Wall -pedantic -std=c99 -_CPPFLAGS = -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L \ - -D_XOPEN_SOURCE=700 -INCLUDE = -I/usr/include -# OpenBSD -#_CPPFLAGS = -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L \ -# -D_XOPEN_SOURCE=700 -D_BSD_SOURCE -#INCLUDE = -I/usr/local/include -INSTALL = install -LIBS = -lSDL3_image -lSDL3 -lm -SRC = hiscore.c linije.c -HEADERS = local.h -OBJS = hiscore.o linije.o -PREFIX = /usr/local -PROG = linije - -# Derived macros -BINDIR = $(PREFIX)/bin -CPPFLAGS = $(_CPPFLAGS) $(INCLUDE) -DATADIR = $(PREFIX)/share/$(PROG) -DOCDIR = $(PREFIX)/share/doc/$(PROG) -MANPREFIX = $(PREFIX)/share/man -# OpenBSD -#MANPREFIX = $(PREFIX)/man -#MANPAGE = $(PROG).1 diff --git a/lib/makedate b/lib/makedate @@ -4,7 +4,38 @@ FALLBACKDATE=${FALLBACKDATE:-unknown} LC_ALL=C export LC_ALL -if [ -d .got ] && command -v got >/dev/null 2>&1; then +die() +{ + printf "%s\n" "$@" >&2 + exit 1 +} + +exists() +{ + command -v $* >/dev/null 2>&1 +} + +_getent() +{ + if exists getent; then + command getent "$@" 2>/dev/null + return + fi + case "$1" in + passwd|group) + if [ -z "$2" ]; then + cat /etc/"$1" + else + awk -F: -vu="$2" '{ if ($3 == u) print }' /etc/"$1" + fi + ;; + *) ;; + esac +} + +exists diff || die "The build script $0 requires diff(1), none found" + +if [ -d .got ] && exists got; then got log | awk ' /^date: / { @@ -25,9 +56,12 @@ if [ -d .got ] && command -v got >/dev/null 2>&1; then print month_names[$2] " " $3 ", " $5 exit }' >date.new -elif [ -d .git ] && command -v git >/dev/null 2>&1; then - user=$(getent passwd "$(unalias ls >/dev/null 2>&1 || true; \ - command ls -lnd . | awk '{print $3}')" | awk -F: '{print $1}') +elif [ -d .git ] && exists git; then + + user=$(printf "%s\n" "$(_getent passwd \ + "$(unalias ls >/dev/null 2>&1 || true; \ + command ls -nd . | awk '{print $3}')")" | + awk -F: '{print $1}') if [ -z "$user" ]; then printf "$0: error: Cannot determine owner of %s" "$(pwd)" >&2 exit 1 diff --git a/lib/makeversion b/lib/makeversion @@ -1,8 +1,41 @@ #!/bin/sh -x # vim: set ft=bash: FALLBACKVER=${FALLBACKVER:-unknown} +LC_ALL=C +export LC_ALL -if [ -d .got ] && command -v got >/dev/null 2>&1; then +die() +{ + printf "%s\n" "$@" >&2 + exit 1 +} + +exists() +{ + command -v $* >/dev/null 2>&1 +} + +_getent() +{ + if exists getent; then + command getent "$@" 2>/dev/null + return + fi + case "$1" in + passwd|group) + if [ -z "$2" ]; then + cat /etc/"$1" + else + awk -F: -vu="$2" '{ if ($3 == u) print }' /etc/"$1" + fi + ;; + *) ;; + esac +} + +exists diff || die "The build script $0 requires diff(1), none found" + +if [ -d .got ] && exists got; then lastcommit=$(got log | awk '/^commit/ {print substr($2,1,7); exit}') got tag -l | @@ -30,11 +63,12 @@ if [ -d .got ] && command -v got >/dev/null 2>&1; then } printf "\n" }' >version.new -elif [ -d .git ] && command -v git >/dev/null 2>&1; then - LC_ALL=C - export LC_ALL - user=$(getent passwd "$(unalias ls >/dev/null 2>&1 || true; \ - command ls -lnd . | awk '{print $3}')" | awk -F: '{print $1}') +elif [ -d .git ] && exists git; then + + user=$(printf "%s\n" "$(_getent passwd \ + "$(unalias ls >/dev/null 2>&1 || true; \ + command ls -nd . | awk '{print $3}')")" | + awk -F: '{print $1}') if [ -z "$user" ]; then printf "$0: error: Cannot determine owner of %s" "$(pwd)" >&2 exit 1 diff --git a/lib/mkpack b/lib/mkpack @@ -4,7 +4,7 @@ DISTDIR=$(grep '^PROG[[:space:]]\{1,\}=' config.mk | sed -E 's,.*=[[:space:]]+([[:alpha:]]+),\1,')-$(cat version) mkdir "$DISTDIR" if [ -d .got ] && command -v got >/dev/null 2>&1; then - files=$(got tree | sed -e 's,[@/*$]$,,g') + files=$(got tree -R | sed -e 's,[@/*$]$,,g') elif [ -d .git ] && command -v git >/dev/null 2>&1; then files=$(git ls-files) else @@ -14,7 +14,7 @@ fi for f in $files; do d="$DISTDIR"/"$(dirname "$f")" mkdir -p "$d" - cp "$f" "$d"/ + [ -f "$f" ] && cp "$f" "$d"/ done tar -cf - "$DISTDIR" | xz -9v - > "$DISTDIR".tar.xz rm -fr "$DISTDIR" diff --git a/linije.c b/linije.c @@ -1,5 +1,5 @@ /* This program is licensed under the terms of GNU GPL v3 or (at your option) - * any later version. Copyright (C) 2025 Страхиња Радић. + * any later version. Copyright (C) 2025-2026 Страхиња Радић. * See the file LICENSE for exact copyright and license details. */ #include <SDL3/SDL.h> @@ -55,6 +55,7 @@ #define MAX(a, b) (((a) > (b)) ? (a) : (b)) #define INDEX(x, y) ((y) * GRID_WIDTH + (x)) #define INDEXFI(x, y) (((int)floor(y)) * GRID_WIDTH + ((int)floor(x))) +#define UNUSED(x) ((void)(x)) #define VALNAME(n) [n] = #n /* clang-format off */ @@ -119,7 +120,7 @@ const char* help_text[] = { "\1---\2", "", "This program is licensed under the terms of GNU GPL v3 or (at your", - "option) any later version. Copyright (C) 2025 Strahinya Radich.", + "option) any later version. Copyright (C) 2025-2026 Strahinya Radich.", "See the file LICENSE for exact copyright and license details.", NULL }; @@ -410,7 +411,8 @@ check_five_loop: "check_five: len = %d, not popping", len); } i++; - if (i < sizeof(check_five_deltas) / sizeof(check_five_deltas[0])) + if (i < (ssize_t)(sizeof(check_five_deltas) + / sizeof(check_five_deltas[0]))) goto check_five_loop; SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, @@ -1744,6 +1746,9 @@ main(int argc, char** argv) unsigned int last_time, current_time; int x, y; + UNUSED(argc); + UNUSED(argv); + init_state(&state); hs_init(&hof); diff --git a/local.h.in b/local.h.in @@ -1,5 +1,5 @@ /* This program is licensed under the terms of GNU GPL v3 or (at your option) - * any later version. Copyright (C) 2025 Страхиња Радић. + * any later version. Copyright (C) 2025-2026 Страхиња Радић. * See the file LICENSE for exact copyright and license details. */ #define DATADIR "%DATADIR%" diff --git a/version.h.in b/version.h.in @@ -1,5 +1,5 @@ /* This program is licensed under the terms of GNU GPL v3 or (at your option) - * any later version. Copyright (C) 2025 Страхиња Радић. + * any later version. Copyright (C) 2025-2026 Страхиња Радић. * See the file LICENSE for exact copyright and license details. */ #define PROGRAM_NAME "linije"