Mercurial > ~dholland > hg > ag > index.cgi
view mk/compile-rules.sh @ 18:562c313f14f4
some minor updates for 2022
author | David A. Holland |
---|---|
date | Tue, 31 May 2022 02:03:50 -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