view mk/compile-rules.sh @ 8:ec2b657edf13

Add explicit lint-comment-style fallthrough annotations. GCC now assumes that if you don't have these you're making a mistake, which is annoying. XXX: This changeset updates the AG output files only (by hand) and is XXX: abusive - rebuilding them will erase the change. However, I need XXX: to get things to build before I can try to get AG to issue the XXX: annotations itself, so this seems like a reasonable expedient.
author David A. Holland
date Mon, 30 May 2022 23:51:43 -0400
parents 13d2b8934445
children
line wrap: on
line source

#!/bin/sh
# compile-rules.sh - generate make rules for prog.mk and lib.mk
# usage: compile-rules.sh 'srcs' 'rcfiles' > rules.mk

if [ $# != 2 ]; then
    echo "$0: usage: $0 'srcs' 'rcfiles'" 1>&2
    exit 1
fi

SRCS="$1"
RCFILES="$2"

OBJS=`echo " $SRCS " | sed 's, \./, ,g;s/\.[^\.]* /$(OBJEXT) /g'`
OBJS=`echo "$OBJS" | sed 's/^ //;s/ *$//'`
echo "OBJS=$OBJS"

RESFILES=`echo $RCFILES " " | sed 's/\.[^\.]* /.res /g;s/ *$//'`
echo "RESFILES=$RESFILES"

for S in $SRCS; do
    echo $S | awk '
	{
	    src=$1;
	    if (src ~ "^\\./") {
		sub("^\\./", "", src);
		fullsrc = src;
	    }
	    else {
		fullsrc = "$(SRCDIR)/" src;
	    }

	    obj=src;
	    sub("\\.[^\\.]*$", "$(OBJEXT)", obj);

	    printf "%s: %s\n", obj, fullsrc;
	    printf "\t@echo \"        [CC]      %s\"\n", src;
	    printf "\t@$(CC) $(CFLAGS) $(CFLAGS.$(TYPE)) $(INCFLAGS)";
	    printf " -c %s\n", fullsrc;
	}
    '
done

for R in $RCFILES; do
    echo $R | awk '
	{
	    src=$1;
	    obj=src;
	    sub("\\.[^\\.]*$", ".res", obj);
	    printf "%s: $(SRCDIR)/%s\n", obj, src;
	    printf "\t@echo \"        [WINDRES] %s\"\n", src;
	    printf "\t@$(WINDRES) $(WINDRESFLAGS) -fo$@ $(SRCDIR)/%s\n", src;
	}
    '
done