# HG changeset patch # User Shinji KONO # Date 1666166993 -32400 # Node ID 7412ef4ef78901b29b2a711e70bc3194d0868575 # Parent 06763fed18e4d01d6e451b4d32fe99ae46953801 use cmake diff -r 06763fed18e4 -r 7412ef4ef789 CMakeLists.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CMakeLists.txt Wed Oct 19 17:09:53 2022 +0900 @@ -0,0 +1,32 @@ +cmake_minimum_required(VERSION 3.24) +add_definitions("-Wall -g") +enable_testing() +set(CMAKE_C_FLAGS_DEBUG "-O") + +set(COMPILER s-compile.c s-token.c) +# set(COMPILER s-tree-compile.c s-token.c) +# set(COMPILER s-yacc.y s-token.c) + +add_executable(token token.c s-token.c) +add_executable(calc calc.c) +add_executable(s-calc s-calc-r.c s-token.c) +add_executable(s-calc-left s-calc.c s-token.c) +add_executable(s-tree s-tree.c s-token.c) +add_executable(s-prefix s-prefix.c s-code-print.c s-token.c) +add_executable(s-rpn ${COMPILER} s-code-print.c ) +add_executable(s-aarch ${COMPILER} s-code-arm-mac.c ) + +# add_executable(s-ppc ${COMPILER} s-code-ppc.c ) +# add_executable(s-09 ${COMPILER} s-code-09.c ) +# add_executable(s-intel ${COMPILER} s-code-intel.c ) +# add_executable(s-intel-r ${COMPILER} s-code-intel-r.c ) +# add_executable(s-imac ${COMPILER} s-code-intel-mac.c ) +add_executable(s-imac64 ${COMPILER} s-code-intel64-mac.c ) +add_executable(s-imac64-r ${COMPILER} s-code-intel64-mac-r.c ) +add_executable(s-llvm ${COMPILER} s-code-llvm.c) +# add_executable(s-sparc ${COMPILER} s-code-sparc.c ) +# add_executable(s-rs6k ${COMPILER} s-code-rs6k.c ) +# add_executable(s-rs6k-r ${COMPILER} s-code-rs6k-r.c ) +# add_executable(s-m68k ${COMPILER} s-code-m68k.c ) + +add_test( NAME test-aarch COMMAND sh test.sh ${CMAKE_C_COMPILER} s-aarch ) diff -r 06763fed18e4 -r 7412ef4ef789 Makefile --- a/Makefile Wed Oct 12 16:37:44 2022 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,112 +0,0 @@ -TEST = s-imac64-r - -CC = clang -# CFLAGS = -g -O -Wall -CFLAGS = -g -O0 -Wall -YYFLAGS = -v -YACC = bison -# COMPILER = s-compile.o s-token.o -# COMPILER = s-tree-compile.o s-token.o -COMPILER = s-yacc.o s-token.o - -# TARGET = token calc s-calc s-prefix s-rpn s-09 s-intel s-intel-r s-sparc s-rs6k s-m68k s-ppc s-imac -TARGET = token calc s-calc s-calc-left s-prefix s-rpn s-intel s-intel-r s-sparc s-ppc s-imac s-imac64 s-imac64-r s-llvm -# TARGET = s-imac64-r - -all: $(TARGET) - -token: token.o s-token.o - $(CC) $(CFLAGS) -o $@ $^ - -calc: calc.c - $(CC) $(CFLAGS) -o $@ $^ - -s-calc: s-calc-r.c s-token.o - $(CC) $(CFLAGS) -o $@ $^ - -s-calc-left: s-calc.c s-token.o - $(CC) $(CFLAGS) -o $@ $^ - -s-tree: s-tree.c s-token.o - $(CC) $(CFLAGS) -o $@ $^ - -s-prefix: s-prefix.o s-code-print.o s-token.o - $(CC) $(CFLAGS) -o $@ $^ -s-rpn: $(COMPILER) s-code-print.o - $(CC) $(CFLAGS) -o $@ $^ -s-ppc: $(COMPILER) s-code-ppc.o - $(CC) $(CFLAGS) -o $@ $^ -s-09: $(COMPILER) s-code-09.o - $(CC) $(CFLAGS) -o $@ $^ -s-intel: $(COMPILER) s-code-intel.o - $(CC) $(CFLAGS) -o $@ $^ -s-intel-r: $(COMPILER) s-code-intel-r.o - $(CC) $(CFLAGS) -o $@ $^ -s-imac: $(COMPILER) s-code-intel-mac.o - $(CC) $(CFLAGS) -o $@ $^ -s-imac64: $(COMPILER) s-code-intel64-mac.o - $(CC) $(CFLAGS) -o $@ $^ -s-imac64-r: $(COMPILER) s-code-intel64-mac-r.o - $(CC) $(CFLAGS) -o $@ $^ -s-llvm: $(COMPILER) s-code-llvm.o - $(CC) $(CFLAGS) -o $@ $^ -s-sparc: $(COMPILER) s-code-sparc.o - $(CC) $(CFLAGS) -o $@ $^ -s-rs6k: $(COMPILER) s-code-rs6k.o - $(CC) $(CFLAGS) -o $@ $^ -s-rs6k-r: $(COMPILER) s-code-rs6k-r.o - $(CC) $(CFLAGS) -o $@ $^ -s-m68k: $(COMPILER) s-code-m68k.o - $(CC) $(CFLAGS) -o $@ $^ -s-yacc.o: s-yacc.y - $(YACC) $(YYFLAGS) s-yacc.y - # mv y.tab.c s-yacc.c - mv s-yacc.tab.c s-yacc.c - $(CC) -c s-yacc.c - -test: $(TEST) - ./$(TEST) < s-input.txt > s-output.s - $(CC) s-output.s - ./a.out - -testll: $(TEST) - ./$(TEST) < s-input.txt > s-output.ll - $(CC) s-output.ll - ./a.out - -MC09EMU = ../emulator/util09/v09 -MC09ASM = ../emulator/util09/a09 -test-09: s-09 - ./s-09 < s-input.txt > s-output.a09 - $(MC09ASM) s-output.a09 - $(MC09EMU) s-output - -tar: - ( cd ..; tar zcf compiler-examples.tgz --exclude CVS compiler-examples ) - -clean: - rm -rf *.o $(TARGET) a.out s-output.s s-output.a09 s-output *.dSYM *.s - rm -f s-yacc.c y.tab.c y.tab.h - -# DO NOT DELETE - -s-calc.o: s-compile.h -s-code-09.o: s-compile.h -s-code-intel-mac.o: s-compile.h -s-code-intel-r.o: s-compile.h -s-code-intel.o: s-compile.h -s-code-intel64-mac-r.o: s-compile.h -s-code-intel64-mac.o: s-compile.h -s-code-llvm.o: s-compile.h -s-code-m68k.o: s-compile.h -s-code-ppc.o: s-compile.h -s-code-print.o: s-compile.h -s-code-rs6k-r.o: s-compile.h -s-code-rs6k.o: s-compile.h -s-code-sparc.o: s-compile.h -s-compile.o: s-compile.h -s-prefix.o: s-compile.h -s-token.o: s-compile.h -s-tree-compile.o: s-compile.h -s-yacc.o: s-compile.h -token.o: s-compile.h diff -r 06763fed18e4 -r 7412ef4ef789 test.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test.sh Wed Oct 19 17:09:53 2022 +0900 @@ -0,0 +1,11 @@ +#!/bin/sh +# usage s-calc /usr/bin/clang + +# pwd +# echo $1 $2 +# ls . + +./$2 < s-input.txt > s-output.s +$1 s-output.s +./a.out +