aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorPreston Pan <preston@nullring.xyz>2024-01-09 18:39:49 -0800
committerPreston Pan <preston@nullring.xyz>2024-01-09 18:39:49 -0800
commitac6004730fa54a756d1627a4e8450cd32df86f75 (patch)
tree8cb4d59438a1252fa069788b2ffb78b2a1bbad3e /Makefile
parent6ccf0572469dfc8cd8fa7b8537b2ac6c265d2df6 (diff)
reorganize directory structure
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile31
1 files changed, 21 insertions, 10 deletions
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/