shithub: scc

Download patch

ref: 5e4090d4e5e80779e9dd893a0d05b3113b595956
parent: 5d1501e35338badd9a2958f1c1c68ad52ea2b020
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Tue Aug 14 05:51:52 EDT 2018

[cc2] Remove gendep.sh

This generation of dependencies was too complex, and it doesn't
make sense anymore. If you don't want all the targets you only
has to modify the Makefiles.

--- a/cc2/Makefile
+++ b/cc2/Makefile
@@ -1,8 +1,5 @@
 .POSIX:
 
-# Makefile is only used as a template for makefile.
-# If you modify Makefile remember to run make dep
-
 PROJECTDIR = ..
 include $(PROJECTDIR)/rules.mk
 include $(LIBDIR)/libdep.mk
@@ -10,13 +7,12 @@
 MOREFLAGS = -I$(PROJECTDIR)/inc/$(STD) $(CC2_CFLAGS)
 
 OBJ = main.o parser.o peep.o symbol.o node.o code.o optm.o
-HDR = cc2.h $(PROJECTDIR)/inc/$(STD)/cstd.h $(PROJECTDIR)/inc/scc.h
 
 all:
 	cp cc2-* $(PROJECTDIR)/rootdir/libexec/scc/
 
 dep:
-	MKQBE=${MKQBE} ./gendep.sh $(TARGETS)
+	$(PROJECTDIR)/mkdep.sh
 
 main.o: error.h
 
@@ -30,4 +26,67 @@
 	rm -f cc2-* error.h
 
 distclean: clean
-	rm -f makefile
+
+include target/amd64-sysv/target.mk
+include target/i386-sysv/target.mk
+include target/qbe_amd64-sysv/target.mk
+include target/qbe_arm64-sysv/target.mk
+include target/z80-scc/target.mk
+
+parser.c: $(PROJECTDIR)/inc/$(STD)/cstd.h
+
+#deps
+code.o: ./../inc/scc.h
+code.o: ./cc2.h
+main.o: ./../inc/arg.h
+main.o: ./../inc/scc.h
+main.o: ./cc2.h
+main.o: ./error.h
+node.o: ./../inc/scc.h
+node.o: ./cc2.h
+optm.o: ./../inc/scc.h
+optm.o: ./cc2.h
+parser.o: ./../inc/scc.h
+parser.o: ./cc2.h
+peep.o: ./../inc/scc.h
+peep.o: ./cc2.h
+symbol.o: ./../inc/scc.h
+symbol.o: ./cc2.h
+target/amd64-sysv/cgen.o: ./target/amd64-sysv/../../../inc/scc.h
+target/amd64-sysv/cgen.o: ./target/amd64-sysv/../../cc2.h
+target/amd64-sysv/cgen.o: ./target/amd64-sysv/arch.h
+target/amd64-sysv/code.o: ./target/amd64-sysv/../../../inc/scc.h
+target/amd64-sysv/code.o: ./target/amd64-sysv/../../cc2.h
+target/amd64-sysv/code.o: ./target/amd64-sysv/arch.h
+target/amd64-sysv/optm.o: ./target/amd64-sysv/../../../inc/scc.h
+target/amd64-sysv/optm.o: ./target/amd64-sysv/../../cc2.h
+target/amd64-sysv/types.o: ./target/amd64-sysv/../../../inc/scc.h
+target/amd64-sysv/types.o: ./target/amd64-sysv/../../cc2.h
+target/i386-sysv/cgen.o: ./target/i386-sysv/../../../inc/scc.h
+target/i386-sysv/cgen.o: ./target/i386-sysv/../../cc2.h
+target/i386-sysv/cgen.o: ./target/i386-sysv/arch.h
+target/i386-sysv/code.o: ./target/i386-sysv/../../../inc/scc.h
+target/i386-sysv/code.o: ./target/i386-sysv/../../cc2.h
+target/i386-sysv/code.o: ./target/i386-sysv/arch.h
+target/i386-sysv/optm.o: ./target/i386-sysv/../../../inc/scc.h
+target/i386-sysv/optm.o: ./target/i386-sysv/../../cc2.h
+target/i386-sysv/types.o: ./target/i386-sysv/../../../inc/scc.h
+target/i386-sysv/types.o: ./target/i386-sysv/../../cc2.h
+target/qbe/cgen.o: ./target/qbe/../../../inc/scc.h
+target/qbe/cgen.o: ./target/qbe/../../cc2.h
+target/qbe/cgen.o: ./target/qbe/arch.h
+target/qbe/code.o: ./target/qbe/../../../inc/scc.h
+target/qbe/code.o: ./target/qbe/../../cc2.h
+target/qbe/code.o: ./target/qbe/arch.h
+target/qbe/optm.o: ./target/qbe/../../../inc/scc.h
+target/qbe/optm.o: ./target/qbe/../../cc2.h
+target/z80-scc/cgen.o: ./target/z80-scc/../../../inc/scc.h
+target/z80-scc/cgen.o: ./target/z80-scc/../../cc2.h
+target/z80-scc/cgen.o: ./target/z80-scc/arch.h
+target/z80-scc/code.o: ./target/z80-scc/../../../inc/scc.h
+target/z80-scc/code.o: ./target/z80-scc/../../cc2.h
+target/z80-scc/code.o: ./target/z80-scc/arch.h
+target/z80-scc/optm.o: ./target/z80-scc/../../../inc/scc.h
+target/z80-scc/optm.o: ./target/z80-scc/../../cc2.h
+target/z80-scc/types.o: ./target/z80-scc/../../../inc/scc.h
+target/z80-scc/types.o: ./target/z80-scc/../../cc2.h
--- a/cc2/gendep.sh
+++ /dev/null
@@ -1,39 +1,0 @@
-#!/bin/sh
-
-gentarget()
-{
-
-	cat <<EOF
-include target/$1/target.mk
-\$(OBJ-$1): \$(HDR)
-all: cc2-$1
-cc2-$1: \$(OBJ-$1) \$(LIBDIR)/libscc.a
-	\$(CC) \$(SCC_LDFLAGS) \$(OBJ-$1) -lscc -o \$@
-
-EOF
-}
-
-set -e
-
-rm -f makefile
-trap "rm -f $$.mk" 0 2 3
-
-re='\([^-]*\)-\([^-]*\)-\([^-]*\)-\([^-]*\)'
-
-echo $@ |
-tr ' ' '\n' |
-sed "s/$re/\1-\2/" |
-sort -u |
-(cat Makefile
-while read i
-do
-	if test ${MKQBE:-0} -eq 1
-	then
-		case $i in
-		amd64-sysv)
-			gentarget qbe_$i
-			;;
-		esac
-	fi
-	gentarget $i
-done) > $$.mk && mv $$.mk makefile
--- a/cc2/target/amd64-sysv/target.mk
+++ b/cc2/target/amd64-sysv/target.mk
@@ -1,5 +1,12 @@
+all: cc2-amd64-sysv
+
+target/amd64-sysv/code.o: $(PROJECTDIR)/inc/$(STD)/cstd.h
+
 OBJ-amd64-sysv = $(OBJ)  \
         target/amd64-sysv/cgen.o \
         target/amd64-sysv/optm.o \
         target/amd64-sysv/code.o \
         target/amd64-sysv/types.o
+
+cc2-amd64-sysv: $(OBJ-amd64-sysv) $(LIBDIR)/libscc.a
+	$(CC) $(SCC_LDFLAGS) $(OBJ-amd64-sysv) -lscc -o $@
--- a/cc2/target/i386-sysv/target.mk
+++ b/cc2/target/i386-sysv/target.mk
@@ -1,5 +1,12 @@
+all: cc2-i386-sysv
+
+target/i386-sysv/code.o: $(PROJECTDIR)/inc/$(STD)/cstd.h
+
 OBJ-i386-sysv = $(OBJ)  \
         target/i386-sysv/cgen.o \
         target/i386-sysv/optm.o \
         target/i386-sysv/code.o \
         target/i386-sysv/types.o
+
+cc2-i386-sysv: $(OBJ-i386-sysv) $(LIBDIR)/libscc.a
+	$(CC) $(SCC_LDFLAGS) $(OBJ-i386-sysv) -lscc -o $@
--- a/cc2/target/qbe_amd64-sysv/target.mk
+++ b/cc2/target/qbe_amd64-sysv/target.mk
@@ -1,5 +1,12 @@
+all: cc2-qbe_amd64-sysv
+
+target/qbe/cgen.o: $(PROJECTDIR)/inc/$(STD)/cstd.h
+
 OBJ-qbe_amd64-sysv = $(OBJ)  \
         target/qbe/cgen.o \
         target/qbe/optm.o \
         target/qbe/code.o \
         target/amd64-sysv/types.o
+
+cc2-qbe_amd64-sysv: $(OBJ-qbe_amd64-sysv) $(LIBDIR)/libscc.a
+	$(CC) $(SCC_LDFLAGS) $(OBJ-qbe_amd64-sysv) -lscc -o $@
--- a/cc2/target/qbe_arm64-sysv/target.mk
+++ b/cc2/target/qbe_arm64-sysv/target.mk
@@ -1,4 +1,4 @@
-OBJ-qbe_amd64-sysv = $(OBJ)  \
+OBJ-qbe_arm64-sysv = $(OBJ)  \
         target/qbe/cgen.o \
         target/qbe/optm.o \
         target/qbe/code.o \
--- a/cc2/target/z80-scc/target.mk
+++ b/cc2/target/z80-scc/target.mk
@@ -1,3 +1,7 @@
+all: cc2-z80-scc
+
+target/z80-scc/code.o: $(PROJECTDIR)/inc/$(STD)/cstd.h
+
 OBJ-z80-scc = $(OBJ)  \
         target/z80-scc/cgen.o \
         target/z80-scc/optm.o \
@@ -4,3 +8,5 @@
         target/z80-scc/code.o \
         target/z80-scc/types.o
 
+cc2-z80-scc: $(OBJ-z80-scc) $(LIBDIR)/libscc.a
+	$(CC) $(SCC_LDFLAGS) $(OBJ-z80-scc) -lscc -o $@