2023-04-27 18:38:16 +00:00
|
|
|
CC = gcc
|
|
|
|
|
2023-05-06 04:39:44 +00:00
|
|
|
SOURCE = src
|
|
|
|
SOURCE += lib
|
|
|
|
SOURCE += command
|
2023-04-27 18:38:16 +00:00
|
|
|
|
2023-05-01 22:43:32 +00:00
|
|
|
MAJOR = 0
|
|
|
|
MINOR = 0
|
|
|
|
PATCH = 1
|
|
|
|
|
2023-05-06 04:39:44 +00:00
|
|
|
INCFLAGS = $(shell echo $(SOURCE) | xargs printf -- '-I%s ')
|
2023-05-01 22:43:32 +00:00
|
|
|
|
2023-05-04 20:10:37 +00:00
|
|
|
CCFLAGS = -std=c89 -Wall -Wextra -pedantic -O2
|
2023-05-01 22:43:32 +00:00
|
|
|
CCFLAGS += -D_DEFAULT_SOURCE -DMAJOR=$(MAJOR) -DMINOR=$(MINOR) -DPATCH=$(PATCH) -DCHECK_LINK
|
2023-04-27 18:38:16 +00:00
|
|
|
CCFLAGS += $(INCFLAGS)
|
|
|
|
|
2023-05-03 16:17:56 +00:00
|
|
|
LDFLAGS = -s
|
2023-04-27 18:38:16 +00:00
|
|
|
LDFLAGS += $(INCFLAGS)
|
|
|
|
|
|
|
|
BIN = bin
|
|
|
|
APP = $(BIN)/app
|
2023-05-01 22:43:32 +00:00
|
|
|
SRC = $(shell find $(SOURCE) -name "*.c")
|
|
|
|
DIR = $(shell find $(SOURCE) -type d)
|
2023-04-27 18:38:16 +00:00
|
|
|
OBJ = $(SRC:%.c=$(BIN)/%.o)
|
|
|
|
|
2023-05-06 04:39:44 +00:00
|
|
|
.PHONY: empty dirs run clean build install uninstall
|
2023-04-27 18:38:16 +00:00
|
|
|
|
2023-05-06 04:39:44 +00:00
|
|
|
empty: clean build
|
2023-04-27 18:38:16 +00:00
|
|
|
|
|
|
|
dirs:
|
2023-05-01 22:43:32 +00:00
|
|
|
echo $(DIR) | xargs printf -- '$(BIN)/%s\n' | xargs mkdir -p
|
2023-04-27 18:38:16 +00:00
|
|
|
|
|
|
|
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
|