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/ build/
.vscode/ .vscode/
vgcore* vgcore*
test.*

View File

@ -1,28 +1,28 @@
CFLAG=-Wall -ggdb3 TARGET_EXEC ?= stack_vm
BUILD_DIR=build
SRC_DIR=src
all: build_dir stack_vm BUILD_DIR ?= ./build
SRC_DIRS ?= ./src
build_dir: SRCS := $(shell find $(SRC_DIRS) -name *.c)
mkdir -p $(BUILD_DIR) OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
stack_vm: main.o run.o stack.o command.o INC_DIRS := $(shell find $(SRC_DIRS) -type d)
$(CC) $(BUILD_DIR)/main.o $(BUILD_DIR)/run.o $(BUILD_DIR)/stack.o $(BUILD_DIR)/command.o -o $(BUILD_DIR)/$@ INC_FLAGS := $(addprefix -I,$(INC_DIRS))
main.o: CPPFLAGS ?= $(INC_FLAGS) -MMD -MP
$(CC) -c $(SRC_DIR)/main.c $(CFLAG) -o $(BUILD_DIR)/$@
run.o: $(BUILD_DIR)/$(TARGET_EXEC): $(OBJS)
$(CC) -c $(SRC_DIR)/run.c $(CFLAG) -o $(BUILD_DIR)/$@ $(CC) -ggdb3 $(OBJS) -o $@ $(LDFLAGS)
stack.o: $(BUILD_DIR)/%.c.o: %.c
$(CC) -c $(SRC_DIR)/stack.c $(CFLAG) -o $(BUILD_DIR)/$@ $(MKDIR_P) $(dir $@)
$(CC) -ggdb3 $(CPPFLAGS) $(CFLAGS) -c $< -o $@
command.o: .PHONY: clean all
$(CC) -c $(SRC_DIR)/command.c $(CFLAG) -o $(BUILD_DIR)/$@
all: $(BUILD_DIR)/$(TARGET_EXEC)
clean: 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: case IN:
{ {
char input[512]; char input[512];
scanf("%s", &input); scanf("%s", input);
int size = str_len(input); int size = str_len(input);
for (int pos = size; size >= 0; size--) for (int pos = size; size >= 0; size--)