Add Makefile
This commit is contained in:
parent
f987a9608c
commit
5cf4f991cb
37
Makefile
Normal file
37
Makefile
Normal file
@ -0,0 +1,37 @@
|
||||
CC = gcc
|
||||
CCFLAGS = -Wall
|
||||
BUILDDIR = build
|
||||
SRCS = main.c
|
||||
OBJS = $(addprefix $(BUILDDIR)/, $(patsubst %.c,%.o,$(SRCS)))
|
||||
OUT = cvec
|
||||
INSTALL_PATH?=/usr/local
|
||||
INSTALL_PATH_BIN=$(INSTALL_PATH)/bin
|
||||
|
||||
.PHONY: all debug format clean
|
||||
.PRECIOUS: $(BUILDDIR)/. $(BUILDDIR)%/.
|
||||
|
||||
all: $(OUT)
|
||||
|
||||
debug: CCFLAGS += -g
|
||||
debug: all
|
||||
|
||||
$(BUILDDIR)/.:
|
||||
mkdir -p $@
|
||||
|
||||
$(BUILDDIR)%/.:
|
||||
mkdir -p $@
|
||||
|
||||
$(OUT): $(OBJS)
|
||||
$(CC) $^ -o $(OUT)
|
||||
|
||||
.SECONDEXPANSION:
|
||||
|
||||
$(BUILDDIR)/%.o: %.c | $$(@D)/.
|
||||
$(CC) $(CCFLAGS) -c $< -o $@
|
||||
|
||||
format:
|
||||
clang-format -i *.c *.h
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILDDIR)
|
||||
rm -f $(OUT)
|
Loading…
x
Reference in New Issue
Block a user