From cc4e2b3ad0a6ad65d63d4e6b69b6947f74828744 Mon Sep 17 00:00:00 2001 From: Garritt McCune Date: Fri, 8 Jul 2022 13:26:04 +0000 Subject: [PATCH] Added Makefile. --- .gitignore | 3 ++- Makefile | 30 ++++++++++++++++++++++++++++++ futil.c => src/futil.c | 0 futil.h => src/futil.h | 0 main.c => src/main.c | 0 tstring.c => src/tstring.c | 0 tstring.h => src/tstring.h | 0 7 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 Makefile rename futil.c => src/futil.c (100%) rename futil.h => src/futil.h (100%) rename main.c => src/main.c (100%) rename tstring.c => src/tstring.c (100%) rename tstring.h => src/tstring.h (100%) 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