diff --git a/.gitignore b/.gitignore index 5012110..24655fb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .vscode/ -utf8 +bin/ +obj/ \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ba3b610 --- /dev/null +++ b/Makefile @@ -0,0 +1,30 @@ +CC = gcc +CFLAGS=-g -Wall -DDEBUG -Wpedantic +SRCDIR=src +OBJDIR=obj +SRCS=$(wildcard $(SRCDIR)/*.c) +# Substitute all .c with .o from SRCS +OBJS=$(patsubst $(SRCDIR)/%.c, $(OBJDIR)/%.o, $(SRCS)) +BINDIR=bin +BIN=$(BINDIR)/string-test +all: $(BIN) +release: CFLAGS=-Wall -Wpedantic -O2 +release: clean +release: $(BIN) +$(BIN): $(OBJS) $(BINDIR) + $(CC) $(CFLAGS) $(OBJS) -o $@ +$(OBJDIR)/%.o: $(SRCDIR)/%.c $(OBJDIR) + $(CC) $(CFLAGS) -c $< -o $@ +$(BINDIR): + mkdir $@ +$(OBJDIR): + mkdir $@ +.PHONY: clean +.PHONY: test +.PHONY: disass +clean: + rm -rf $(BINDIR)/* $(OBJDIR)/* +test: + $(BIN) +disass: + objdump -S --disassemble $(OBJDIR)/$(FILE).o > $(OBJDIR)/$(FILE).s \ No newline at end of file diff --git a/futil.c b/src/futil.c similarity index 100% rename from futil.c rename to src/futil.c diff --git a/futil.h b/src/futil.h similarity index 100% rename from futil.h rename to src/futil.h diff --git a/main.c b/src/main.c similarity index 100% rename from main.c rename to src/main.c diff --git a/tstring.c b/src/tstring.c similarity index 100% rename from tstring.c rename to src/tstring.c diff --git a/tstring.h b/src/tstring.h similarity index 100% rename from tstring.h rename to src/tstring.h