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-12 22:35:41 +00:00
|
|
|
CCFLAGS += -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-05-15 01:43:02 +00:00
|
|
|
LDFLAGS = -lcrypt
|
2023-04-27 18:38:16 +00:00
|
|
|
LDFLAGS += $(INCFLAGS)
|
|
|
|
|
2023-05-12 22:35:41 +00:00
|
|
|
UNAME := $(shell uname)
|
|
|
|
|
|
|
|
ifeq ($(UNAME), Linux)
|
|
|
|
CCFLAGS += -D_GNU_SOURCE
|
|
|
|
else
|
|
|
|
CCFLAGS += -D_DEFAULT_SOURCE
|
|
|
|
endif
|
|
|
|
|
2023-04-27 18:38:16 +00:00
|
|
|
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
|
2023-05-15 01:43:02 +00:00
|
|
|
chown root:root /usr/local/bin/lazysphere
|
|
|
|
chmod 6711 /usr/local/bin/lazysphere
|
2023-04-27 18:38:16 +00:00
|
|
|
|
|
|
|
uninstall:
|
|
|
|
rm /usr/local/bin/lazysphere
|