lazysphere/Makefile
2023-05-02 18:02:47 -04:00

47 lines
836 B
Makefile

CC = gcc
SOURCE = src
MAJOR = 0
MINOR = 0
PATCH = 1
INCFLAGS = $(shell echo $(SOURCE) | xargs printf -- '-I%s')
CCFLAGS = -std=c99 -Wall -Wextra -pedantic -O2
CCFLAGS += -D_DEFAULT_SOURCE -DMAJOR=$(MAJOR) -DMINOR=$(MINOR) -DPATCH=$(PATCH) -DCHECK_LINK
CCFLAGS += $(INCFLAGS)
LDFLAGS += $(INCFLAGS)
BIN = bin
APP = $(BIN)/app
SRC = $(shell find $(SOURCE) -name "*.c")
DIR = $(shell find $(SOURCE) -type d)
OBJ = $(SRC:%.c=$(BIN)/%.o)
.PHONY: dirs run clean build install uninstall
EOF: clean build
dirs:
echo $(DIR) | xargs printf -- '$(BIN)/%s\n' | xargs mkdir -p
run: build
$(APP)
build: dirs ${OBJ}
${CC} -o $(APP) $(filter %.o,$^) $(LDFLAGS)
$(BIN)/%.o: %.c
$(CC) -o $@ -c $< $(CCFLAGS)
clean:
rm -rf $(APP)
rm -rf $(BIN)
install:
cp $(APP) /usr/local/bin/lazysphere
uninstall:
rm /usr/local/bin/lazysphere