Updated makefile, fixed error

This commit is contained in:
Dmitriy Shishkov 2021-04-17 00:14:08 +05:00
parent 7b63bd6f17
commit ecbd89c1dd
No known key found for this signature in database
GPG Key ID: 7CAE12ED13853CAC
3 changed files with 21 additions and 20 deletions

3
.gitignore vendored
View File

@ -1,3 +1,4 @@
build/
.vscode/
vgcore*
vgcore*
test.*

View File

@ -1,28 +1,28 @@
CFLAG=-Wall -ggdb3
BUILD_DIR=build
SRC_DIR=src
TARGET_EXEC ?= stack_vm
all: build_dir stack_vm
BUILD_DIR ?= ./build
SRC_DIRS ?= ./src
build_dir:
mkdir -p $(BUILD_DIR)
SRCS := $(shell find $(SRC_DIRS) -name *.c)
OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
stack_vm: main.o run.o stack.o command.o
$(CC) $(BUILD_DIR)/main.o $(BUILD_DIR)/run.o $(BUILD_DIR)/stack.o $(BUILD_DIR)/command.o -o $(BUILD_DIR)/$@
INC_DIRS := $(shell find $(SRC_DIRS) -type d)
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
main.o:
$(CC) -c $(SRC_DIR)/main.c $(CFLAG) -o $(BUILD_DIR)/$@
CPPFLAGS ?= $(INC_FLAGS) -MMD -MP
run.o:
$(CC) -c $(SRC_DIR)/run.c $(CFLAG) -o $(BUILD_DIR)/$@
$(BUILD_DIR)/$(TARGET_EXEC): $(OBJS)
$(CC) -ggdb3 $(OBJS) -o $@ $(LDFLAGS)
stack.o:
$(CC) -c $(SRC_DIR)/stack.c $(CFLAG) -o $(BUILD_DIR)/$@
$(BUILD_DIR)/%.c.o: %.c
$(MKDIR_P) $(dir $@)
$(CC) -ggdb3 $(CPPFLAGS) $(CFLAGS) -c $< -o $@
command.o:
$(CC) -c $(SRC_DIR)/command.c $(CFLAG) -o $(BUILD_DIR)/$@
.PHONY: clean all
all: $(BUILD_DIR)/$(TARGET_EXEC)
clean:
rm -rf $(BUILD_DIR)
$(RM) -r $(BUILD_DIR)
.PHONY: all clean
MKDIR_P ?= mkdir -p

View File

@ -131,7 +131,7 @@ int exec(command_t cmd, stack_t *stack)
case IN:
{
char input[512];
scanf("%s", &input);
scanf("%s", input);
int size = str_len(input);
for (int pos = size; size >= 0; size--)