view mk/compile-rules.sh @ 6:607e3be6bad8

Adjust to the moving target called the C++ standard. Apparently nowadays it's not allowed to define an explicit copy constructor but not an assignment operator. Consequently, defining the explicit copy constructor in terms of the implicit/automatic assignment operator for general convenience no longer works. Add assignment operators. Caution: not tested with the IBM compiler, but there's no particular reason it shouldn't work.
author David A. Holland
date Mon, 30 May 2022 23:46:22 -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