summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile11
1 files changed, 5 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index b339e87..e8f0229 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@ AR=ar
CFLAGS=-Wall -Wextra -std=c11 -O2 -Iinclude -Iinclude/tinyff -Iinclude/ext
SRC=$(shell find src -name "*.c")
-OBJ=$(SRC:.c=.o)
+OBJ=$(patsubst src/%.c,$(OUTDIR)/src/%.o,$(SRC))
LIB=libtinyff.a
OUTDIR=dist
@@ -12,12 +12,11 @@ all: $(OUTDIR)/$(LIB)
$(OUTDIR)/$(LIB): $(OBJ)
@mkdir -p $(OUTDIR)
- $(AR) rcs $@ $(addprefix $(OUTDIR)/,$(OBJ))
+ $(AR) rcs $@ $^
-
-%.o: %.c
- @mkdir -p $(dir $(OUTDIR)/$@)
- $(CC) $(CFLAGS) -c $< -o $(OUTDIR)/$@
+$(OUTDIR)/src/%.o: src/%.c
+ @mkdir -p $(dir $@)
+ $(CC) $(CFLAGS) -c $< -o $@
clean:
rm -rf $(OUTDIR)