Commit 2e9cad6e authored by Arie Peterson's avatar Arie Peterson 🐚
Browse files

Merge branch '22-makefile-does-not-track-c-file-changes' into 'master'

Resolve "Makefile does not track c file changes"

Closes #22

See merge request !16
parents 17ba154b 5d03a8da
......@@ -9,30 +9,34 @@ SRCDIR = src
OBJDIR = obj
BINDIR = bin
DEPS=$(wildcard $(SRCDIR)/*/*.c) $(wildcard $(SRCDIR)/*.c)
SOURCES := $(SRCDIR)/$(TARGET).c
INCLUDES := $(wildcard $(SRCDIR)/*.h)
OBJECTS := $(SOURCES:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
$(BINDIR)/$(TARGET): $(BINDIR)
$(BINDIR):
mkdir -p $(BINDIR)
# Make binary linking .o files and libraries
$(BINDIR)/$(TARGET): $(OBJECTS)
@$(LINKER) $(OBJECTS) $(LFLAGS) -o $@
@echo "Linking complete."
$(OBJECTS): | $(OBJDIR)
$(OBJDIR):
# Compile an object for a c file in SRCDIR
$(OBJDIR)/%.o: $(SRCDIR)/%.c $(DEPS)
mkdir -p $(OBJDIR)
$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.c
@$(CC) $(CFLAGS) -c $< -o $@
@echo "Compiled "$<" successfully."
# Remove intermediate files
.PHONY: clean
clean:
@rm -f $(OBJECTS)
@rm -rf $(OBJDIR)
@echo "Cleanup complete."
# Remove all compiled files
.PHONY: remove
remove: clean
@rm -f $(BINDIR)/$(TARGET)
@rm -rf $(BINDIR)
@echo "Executable removed."
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment