cleaner Makefile, separate dir for build and target
This commit is contained in:
parent
38813b42f2
commit
d99a77f5c7
57
Makefile
Normal file
57
Makefile
Normal file
@ -0,0 +1,57 @@
|
||||
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)
|
47
src/Makefile
47
src/Makefile
@ -1,47 +0,0 @@
|
||||
LDFLAGS="-L/usr/local/opt/flex/lib"
|
||||
|
||||
|
||||
automaton: ram
|
||||
./ram < stack.asm
|
||||
echo "### machine.py ###"
|
||||
cat machine.py
|
||||
echo "### execution ###"
|
||||
python machine.py
|
||||
|
||||
bubble_sort: ram
|
||||
./ram < bubble_sort.asm
|
||||
echo "### machine.py ###"
|
||||
cat machine.py
|
||||
echo "### execution ###"
|
||||
python machine.py
|
||||
|
||||
a_pow_b: ram
|
||||
./ram < a_pow_b.asm
|
||||
echo "### machine.py ###"
|
||||
cat machine.py
|
||||
echo "### execution ###"
|
||||
python machine.py
|
||||
|
||||
test: ram
|
||||
./ram < test.asm
|
||||
echo "### machine.py ###"
|
||||
cat machine.py
|
||||
echo "### execution ###"
|
||||
python machine.py
|
||||
|
||||
ram: ram.yy.c ram.tab.c
|
||||
gcc -o $@ $^ -ly -lfl
|
||||
|
||||
ram.tab.c: ram.y
|
||||
bison -d --report=all $^
|
||||
|
||||
ram.yy.c: ram.l
|
||||
flex -o $@ $^
|
||||
|
||||
clean:
|
||||
rm -f machine.py
|
||||
rm -f ram
|
||||
rm -f *.o
|
||||
rm -f *.output
|
||||
rm -f *.tab.c *.tab.h
|
||||
rm -f *.yy.c
|
Loading…
x
Reference in New Issue
Block a user