lav-sdl

SDL верзија програма Лавиринт
git clone https://git.sr.ht/~strahinja/lav-sdl
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

чување 3f2a3af3cae180a263d514eb96dc76b5d9a1edf4
родитељ 9e0914d07b2cba3682a180ff46096b960c2c93f2
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Wed, 17 Apr 2024 02:14:13 +0200

Migrate to POSIX make from redo

Signed-off-by: Страхиња Радић <contact@strahinja.org>

Diffstat:
MINSTALL | 32++++++++++++--------------------
AMakefile | 41+++++++++++++++++++++++++++++++++++++++++
Dall.do | 1-
Dclean.do | 1-
Aconfig.mk | 25+++++++++++++++++++++++++
Dconfig.redo | 17-----------------
Ddefault.do | 14--------------
Ddefault.o.do | 6------
Dinstall.do | 12------------
Dlav-sdl.do | 13-------------
Alib/mkpack | 14++++++++++++++
Alib/replacepat | 10++++++++++
Dpack.do | 15---------------
Drebuild.do | 1-
Duninstall.do | 10----------
измењених датотека: 15, додавања: 102(+), брисања: 110(-)

diff --git a/INSTALL b/INSTALL @@ -1,7 +1,7 @@ Prerequisites ============= -* C compiler - defaults in config.redo +* C compiler - defaults in config.mk * libSDL (SDL2, SDL2_image) @@ -11,33 +11,25 @@ Install $ git clone https://git.sr.ht/~strahinja/lav-sdl $ cd lav-sdl $ su - -If you have djb redo: - - # redo install - -if you don't: - - # ./do install + # make install Persistent build configuration file ----------------------------------- -The file config.redo will be sourced when building targets which also accept -configuration through environment variables. For example, CC and PREFIX -are specified in config.redo. +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. OpenBSD ------- -Replace gcc in CC with cc and add -D_BSD_SOURCE, eg: - - # CC='cc -g -Wall -pedantic -std=c99 -D_POSIX_C_SOURCE=200809L - -D_XOPEN_SOURCE=700 -D_BSD_SOURCE}' \ - ./do install - -and change MANDIR to +Before running make(1), comment the _CPPFLAGS definition in config.mk above the +line with the "OpenBSD" comment and uncomment the one below it: - MANDIR=$PREFIX/man/man1 + #_CPPFLAGS = -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L \ + # -D_XOPEN_SOURCE=700 + # OpenBSD + _CPPFLAGS = -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L \ + -D_XOPEN_SOURCE=700 -D_BSD_SOURCE diff --git a/Makefile b/Makefile @@ -0,0 +1,41 @@ +.POSIX: + +include config.mk + +.SUFFIXES: .c .o .h.in .h + +.h.in.h: + sh -c 'DATADIR=$(DATADIR) lib/replacepat $< $@' + +all: $(PROG) + +local.h: local.h.in + +lav-sdl.o: lav-sdl.c local.h + +$(PROG): $(OBJS) $(SRC) $(HEADERS) + $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) + +clean: + rm -f $(PROG) $(OBJS) local.h *~ + +install: all + find . \( -name '*.dat' -o -name '*.png' \) -exec sh -c 'umask 022; \ + $(INSTALL) -Dm 0644 {} $(DATADIR)/{}' shell \; + $(INSTALL) -Dm 0644 README $(DOCDIR)/README + $(INSTALL) -Dm 0644 LICENSE $(DOCDIR)/LICENSE + $(INSTALL) -Dm 0755 $(PROG) $(BINDIR)/$(PROG) + +uninstall: + find "$(DATADIR)" -type f -exec rm -f {} + + rmdir $(DATADIR) 2>/dev/null || true + rm -f $(DOCDIR)/README + rm -f $(DOCDIR)/LICENSE + rmdir $(DOCDIR) 2>/dev/null || true + rm -f $(BINDIR)/$(PROG) + rmdir $(BINDIR) 2>/dev/null || true + +pack: all + sh -x lib/mkpack + +.PHONY: all clean install pack uninstall diff --git a/all.do b/all.do @@ -1 +0,0 @@ -redo-ifchange lav-sdl diff --git a/clean.do b/clean.do @@ -1 +0,0 @@ -rm -f *.o *~ lav-sdl local.h diff --git a/config.mk b/config.mk @@ -0,0 +1,25 @@ +#CC = cc +CFLAGS = -Os -Wall -pedantic -std=c99 +_CPPFLAGS = -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L \ + -D_XOPEN_SOURCE=700 +# OpenBSD +#_CPPFLAGS = -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L \ +# -D_XOPEN_SOURCE=700 -D_BSD_SOURCE +INCLUDE = -I/usr/local/include/SDL2 +INSTALL = install +LIBS = -lSDL2_image -lSDL2 -lm +SRC = lav-sdl.c +HEADERS = local.h +OBJS = lav-sdl.o +PREFIX = /usr/local +PROG = lav-sdl + +# 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/config.redo b/config.redo @@ -1,17 +0,0 @@ -PREFIX=${PREFIX:-/usr/local} - -BINDIR=$PREFIX/bin -DATADIR=$PREFIX/share/lav-sdl -DOCDIR=$PREFIX/share/doc/lav-sdl - -PROGS="lav-sdl" -DATAFILES=$(find \( -name '*.dat' -o -name '*.png' \) -print) -DOCS="README LICENSE" - -CC=${CC:-gcc -g -Wall -pedantic -std=c99 -D_POSIX_C_SOURCE=200809L \ --D_XOPEN_SOURCE=700} -STRIP=${STRIP:-:} - -# OpenBSD -#CC=${CC:-cc -g -Wall -pedantic -std=c99 -D_POSIX_C_SOURCE=200809L \ -#-D_XOPEN_SOURCE=700 -D_BSD_SOURCE} diff --git a/default.do b/default.do @@ -1,14 +0,0 @@ -if [ -r ./config.redo ]; then - . ./config.redo -fi -PREFIX=${PREFIX:-/usr/local} -if [ -z "$DATADIR" ]; then - DATADIR=$PREFIX/share/lav-sdl -fi -if [ -r $1.in ]; then - redo-ifchange $1.in - sed -e "s,%DATADIR%,$DATADIR,g" <$1.in >$3 -else - printf "%s: don't know how to build '%s'\n" "$0" "$1" >&2 - exit 99 -fi diff --git a/default.o.do b/default.o.do @@ -1,6 +0,0 @@ -sed -n 's/^#include "\([^"]*\)"/\1/p' ${2%.o}.c | \ - xargs redo-ifchange -redo-ifchange $2.c -. ./config.redo -INCLUDES=$(pkg-config --cflags sdl2) -${CC} ${INCLUDES} -c $2.c -o $3 diff --git a/install.do b/install.do @@ -1,12 +0,0 @@ -redo-ifchange all -. ./config.redo -install -d "$DOCDIR" "$BINDIR" "$DATADIR" -for docfile in $DOCS; do - install -Dm 0644 "${docfile}" "${DOCDIR}/${docfile}" -done -for datafile in $DATAFILES; do - install -m 0644 "${datafile}" "${DATADIR}/${datafile}" -done -for binfile in $PROGS; do - install -Dm 0755 "${binfile}" "${BINDIR}/${binfile}" -done diff --git a/lav-sdl.do b/lav-sdl.do @@ -1,13 +0,0 @@ -. ./config.redo -for f in *.h.in; do - echo $f | sed -e's/\.in$//g' -done | xargs redo-ifchange -for f in *.h *.c; do - echo $f - echo $f | sed -e's/\.c$/.o/g' -done | xargs redo-ifchange -LIBS=$(pkg-config --libs sdl2) -LIBS="$LIBS $(pkg-config --libs SDL2_image)" -LIBS="$LIBS -lm" -${CC} -o $3 lav-sdl.o ${LIBS} -${STRIP} $3 diff --git a/lib/mkpack b/lib/mkpack @@ -0,0 +1,14 @@ +#!/bin/sh -x +# vim: set ft=bash: +DISTDIR=$(grep ^PROG config.mk | + sed -E 's,.*=[[:space:]]+([[:alpha:]]+),\1,') +# To be able to create the directory with the same name +rm lav-sdl +mkdir "$DISTDIR" +for f in $(git ls-files); do + d="$DISTDIR"/"$(dirname "$f")" + mkdir -p "$d" + cp "$f" "$d"/ +done +tar -cf - "$DISTDIR" | xz -9v - > "$DISTDIR".tar.xz +rm -fr "$DISTDIR" diff --git a/lib/replacepat b/lib/replacepat @@ -0,0 +1,10 @@ +#!/bin/sh +# vim: set ft=bash: +infile="$1" +outfile="$2" +DATE=$(cat date 2>/dev/null) +VERSION=$(cat version 2>/dev/null) + +sed -e 's|%VERSION%|'"$VERSION"'|g' -e 's|%DATE%|'"$DATE"'|g' \ + -e 's|%DATADIR%|'"$DATADIR"'|g' "$infile" \ + > "$outfile" diff --git a/pack.do b/pack.do @@ -1,15 +0,0 @@ -redo all -#redo-ifchange version -#read VERSION <version -#VERSION=$(echo $VERSION | sed 's/^v//') -DISTDIR=lav-sdl -# To be able to create the directory with the same name -rm lav-sdl -mkdir $DISTDIR -for f in $(git ls-files); do - d=$DISTDIR/$(dirname $f) - mkdir -p $d - cp $f $d -done -tar cvf $DISTDIR.tar.xz $DISTDIR >/dev/null -rm -fr $DISTDIR diff --git a/rebuild.do b/rebuild.do @@ -1 +0,0 @@ -redo clean all diff --git a/uninstall.do b/uninstall.do @@ -1,10 +0,0 @@ -. ./config.redo -for docfile in $DOCS; do - rm -f "${DOCDIR}/${docfile}" -done -for datafile in $DATAFILES; do - rm -f "${MANDIR}/${manfile}" -done -for binfile in $PROGS; do - rm -f "${BINDIR}/${binfile}" -done