61 lines
1.1 KiB
Makefile
61 lines
1.1 KiB
Makefile
CC = gcc
|
|
|
|
SOURCE = src
|
|
SOURCE += lib
|
|
SOURCE += command
|
|
|
|
MAJOR = 0
|
|
MINOR = 0
|
|
PATCH = 1
|
|
|
|
INCFLAGS = $(shell echo $(SOURCE) | xargs printf -- '-I%s ')
|
|
|
|
CCFLAGS = -std=c89 -Wall -Wextra -pedantic -O2
|
|
CCFLAGS += -DMAJOR=$(MAJOR) -DMINOR=$(MINOR) -DPATCH=$(PATCH) -DCHECK_LINK
|
|
CCFLAGS += $(INCFLAGS)
|
|
|
|
LDFLAGS = -s
|
|
LDFLAGS = -lcrypt
|
|
LDFLAGS += $(INCFLAGS)
|
|
|
|
UNAME := $(shell uname)
|
|
|
|
ifeq ($(UNAME), Linux)
|
|
CCFLAGS += -D_GNU_SOURCE
|
|
else
|
|
CCFLAGS += -D_DEFAULT_SOURCE
|
|
endif
|
|
|
|
BIN = bin
|
|
APP = $(BIN)/app
|
|
SRC = $(shell find $(SOURCE) -name "*.c")
|
|
DIR = $(shell find $(SOURCE) -type d)
|
|
OBJ = $(SRC:%.c=$(BIN)/%.o)
|
|
|
|
.PHONY: empty dirs run clean build install uninstall
|
|
|
|
empty: 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
|
|
chown root:root /usr/local/bin/lazysphere
|
|
chmod 6711 /usr/local/bin/lazysphere
|
|
|
|
uninstall:
|
|
rm /usr/local/bin/lazysphere
|