Allow machines to use cg if they wish.
authorDavid Given <dg@cowlark.com>
Sun, 22 Mar 2015 23:08:51 +0000 (00:08 +0100)
committerDavid Given <dg@cowlark.com>
Sun, 22 Mar 2015 23:08:51 +0000 (00:08 +0100)
--HG--
rename : mach/proto/ncg/build.mk => mach/proto/cg/build.mk
rename : util/ncgg/build.mk => util/cgg/build.mk

mach/proto/cg/build.mk [new file with mode: 0644]
plat/build.mk
util/cgg/build.mk [new file with mode: 0644]
util/cgg/main.c

diff --git a/mach/proto/cg/build.mk b/mach/proto/cg/build.mk
new file mode 100644 (file)
index 0000000..2327009
--- /dev/null
@@ -0,0 +1,46 @@
+define build-cg-impl
+
+$(call reset)
+
+$(eval cflags += -Imach/$(ARCH)/cg -I$(OBJDIR)/$D -Imach/proto/cg)
+$(eval objdir := $(ARCH))
+
+$(call cfile, mach/proto/cg/codegen.c)
+$(call cfile, mach/proto/cg/compute.c)
+$(call cfile, mach/proto/cg/equiv.c)
+$(call cfile, mach/proto/cg/fillem.c)
+$(call cfile, mach/proto/cg/gencode.c)
+$(call cfile, mach/proto/cg/glosym.c)
+$(call cfile, mach/proto/cg/main.c)
+$(call cfile, mach/proto/cg/move.c)
+$(call cfile, mach/proto/cg/nextem.c)
+$(call cfile, mach/proto/cg/reg.c)
+$(call cfile, mach/proto/cg/regvar.c)
+$(call cfile, mach/proto/cg/salloc.c)
+$(call cfile, mach/proto/cg/state.c)
+$(call cfile, mach/proto/cg/subr.c)
+$(call cfile, mach/proto/cg/var.c)
+
+$(eval $q: $(OBJDIR)/$D/tables.h)
+$(eval CLEANABLES += $(OBJDIR)/$D/tables.h $(OBJDIR)/$D/tables.c)
+$(OBJDIR)/$D/tables.c: $(OBJDIR)/$D/tables.h
+$(OBJDIR)/$D/tables.h: $(CGG) $(CPPANSI) mach/$(ARCH)/cg/table
+       @echo CGG $$@
+       @mkdir -p $$(dir $$@)
+       $(hide) cd $$(dir $$@) && \
+               $(abspath $(CPPANSI)) -I$(abspath mach/$(ARCH)/cg) $(abspath mach/$(ARCH)/cg/table) | $(abspath $(CGG))
+
+$(call cfile, $(OBJDIR)/$D/tables.c)
+
+$(eval $q: $(INCDIR)/flt_arith.h)
+
+$(call rawfile, $(LIBEM_DATA))
+$(call rawfile, $(LIBFLT_ARITH))
+
+$(call cprogram, $(BINDIR)/$(PLATFORM)/cg)
+$(call installto, $(PLATDEP)/$(PLATFORM)/cg)
+
+endef
+
+build-cg = $(eval $(build-cg-impl))
+
index aff84c0..623658b 100644 (file)
@@ -17,7 +17,7 @@ define build-platform-impl
                        $(PLATIND)/descr/$(PLATFORM) \
                        $(PLATFORM_HEADERS_$(PLATFORM)) \
                        $(PLATDEP)/$(PLATFORM)/as \
-                       $(PLATDEP)/$(PLATFORM)/ncg \
+                       $(if $(arch-cg-$(ARCH)), $(PLATDEP)/$(PLATFORM)/cg, $(PLATDEP)/$(PLATFORM)/ncg) \
                        $(ARCHITECTURE_$(ARCH)))
 
        # libsys
@@ -48,7 +48,7 @@ define build-platform-impl
     # The tools themselves
 
     $(call build-as)
-    $(call build-ncg)
+    $(if $(arch-cg-$(ARCH)), $(call build-cg), $(call build-ncg))
 
        # Build top only if the architecture asks for it.
 
diff --git a/util/cgg/build.mk b/util/cgg/build.mk
new file mode 100644 (file)
index 0000000..4fc8532
--- /dev/null
@@ -0,0 +1,25 @@
+D := util/cgg
+
+define build-cgg-impl
+
+$(call reset)
+$(eval cflags += -I$D)
+
+$(call yacc, $(OBJDIR)/$D, $D/bootgram.y)
+
+$(call flex, $(OBJDIR)/$D, $D/bootlex.l)
+$(call dependson, $(OBJDIR)/$D/y.tab.h)
+
+$(call cfile, $D/main.c)
+
+$(eval $q: $(INCDIR)/em_spec.h)
+
+$(call rawfile, $(LIBEM_DATA))
+$(call rawfile, $(LIBASSERT))
+$(call rawfile, $(LIBSYSTEM))
+$(call cprogram, $(BINDIR)/cgg)
+$(eval CGG := $o)
+
+endef
+
+$(eval $(build-cgg-impl))
index fba8e31..86375b7 100644 (file)
@@ -1009,3 +1009,8 @@ max(a,b) {
                return(a);
        return(b);
 }
+
+int yywrap(void) {
+       return 1;
+}
+