From ac6004730fa54a756d1627a4e8450cd32df86f75 Mon Sep 17 00:00:00 2001 From: Preston Pan Date: Tue, 9 Jan 2024 18:39:49 -0800 Subject: reorganize directory structure --- Makefile | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index b5991f6..3faaa20 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,26 @@ -## -# Project Title -# -# @file -# @version 0.1 +CC := gcc +SRCDIR := src +BUILDDIR := build +TARGET := bin/stem +SRCEXT := c +SOURCES := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT)) +OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.o)) +CFLAGS := +LIB := -L lib -lm +INC := -I include -all: - cc *.c -o stem -lm +$(TARGET): $(OBJECTS) + @echo " Linking..." + @echo " $(CC) $^ -o $(TARGET) $(LIB)"; $(CC) $^ -o $(TARGET) $(LIB) -O3 + +$(BUILDDIR)/%.o: $(SRCDIR)/%.$(SRCEXT) + @echo " Building..." + @mkdir -p $(BUILDDIR) + @echo " $(CC) $(CFLAGS) $(INC) -c -o $@ $<"; $(CC) $(CFLAGS) $(INC) -c -o $@ $< -save-temps -O3 clean: - rm stem + @echo " Cleaning..."; + @echo " $(RM) -r $(BUILDDIR) $(TARGET)"; $(RM) -r $(BUILDDIR) $(TARGET) install: - cp stem /usr/local/bin/ -# end + cp $(TARGET) /usr/local/bin/ -- cgit