wrapper/Makefile
2023-04-13 18:32:44 -04:00

51 lines
872 B
Makefile

CC = gcc
INCFLAGS = -Isrc
CCFLAGS = -std=gnu99 -Wall -Wextra -pedantic -O2
CCFLAGS += $(INCFLAGS)
LDFLAGS += $(INCFLAGS)
LDFLAGS += -lpthread
BIN = bin
APP = $(BIN)/app
SRC = $(shell find src -name "*.c")
OBJ = $(SRC:%.c=$(BIN)/%.o)
.PHONY: dirs run clean build install uninstall install-openrc uninstall-openrc
EOF: clean build
dirs:
mkdir -p ./$(BIN)
mkdir -p ./$(BIN)/src
mkdir -p ./$(BIN)/src/io
mkdir -p ./$(BIN)/src/packet
mkdir -p ./$(BIN)/src/server
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/wrapper
uninstall:
rm /usr/local/bin/wrapper
install-openrc: install
cp service/openrc /etc/init.d/wrapper
chmod +x /etc/init.d/wrapper
uninstall-openrc: uninstall
rm /etc/init.d/wrapper