67 lines
1.6 KiB
Makefile
67 lines
1.6 KiB
Makefile
LDFLAGS="-L/usr/local/opt/flex/lib"
|
|
BUILD_DIR := ./build
|
|
TARGET_DIR := ./target
|
|
|
|
|
|
all: test bubble_sort automaton a_pow_b
|
|
|
|
automaton: $(BUILD_DIR)/ram $(TARGET_DIR)/ram.py
|
|
$(BUILD_DIR)/ram < src/stack.asm
|
|
mv machine.py $(TARGET_DIR)/automaton.py
|
|
echo "\n### automaton.py ###"
|
|
cat $(TARGET_DIR)/automaton.py
|
|
echo "### execution ###"
|
|
python $(TARGET_DIR)/automaton.py
|
|
|
|
bubble_sort: $(BUILD_DIR)/ram $(TARGET_DIR)/ram.py
|
|
$(BUILD_DIR)/ram < src/bubble_sort.asm
|
|
mv machine.py $(TARGET_DIR)/bubble_sort.py
|
|
echo "\n### machine.py ###"
|
|
cat $(TARGET_DIR)/bubble_sort.py
|
|
echo "### execution ###"
|
|
python $(TARGET_DIR)/bubble_sort.py
|
|
|
|
a_pow_b: $(BUILD_DIR)/ram $(TARGET_DIR)/ram.py
|
|
$(BUILD_DIR)/ram < src/a_pow_b.asm
|
|
mv machine.py $(TARGET_DIR)/a_pow_b.py
|
|
echo "\n### a_pow_b.py ###"
|
|
cat $(TARGET_DIR)/a_pow_b.py
|
|
echo "### execution ###"
|
|
python $(TARGET_DIR)/a_pow_b.py
|
|
|
|
test: $(BUILD_DIR)/ram $(TARGET_DIR)/ram.py
|
|
$(BUILD_DIR)/ram < src/test.asm
|
|
mv machine.py $(TARGET_DIR)/test.py
|
|
echo "\n### test.py ###"
|
|
cat $(TARGET_DIR)/test.py
|
|
echo "### execution ###"
|
|
python $(TARGET_DIR)/test.py
|
|
|
|
$(TARGET_DIR)/ram.py: src/ram.py
|
|
mkdir -p $(TARGET_DIR)
|
|
cp $< $@
|
|
|
|
$(BUILD_DIR)/ram: $(BUILD_DIR)/ram.yy.c $(BUILD_DIR)/ram.tab.c
|
|
gcc -o $@ $^ -ly -lfl
|
|
|
|
$(BUILD_DIR)/ram.tab.c: src/ram.y
|
|
mkdir -p $(BUILD_DIR)
|
|
bison -d --report=all -o $@ $<
|
|
|
|
$(BUILD_DIR)/ram.yy.c: src/ram.l
|
|
mkdir -p $(BUILD_DIR)
|
|
flex -o $@ $<
|
|
|
|
clean:
|
|
rm -rf $(BUILD_DIR)
|
|
rm -rf $(TARGET_DIR)
|
|
rm -f *.tar.gz
|
|
rm -f *.zip
|
|
|
|
FILES := README.md LICENSE Makefile src/
|
|
|
|
tar:
|
|
tar -czf ram.tar.gz $(FILES)
|
|
zip:
|
|
zip -r ram.zip $(FILES)
|