2024-07-21 14:44:46 +00:00
|
|
|
CC := gcc
|
|
|
|
CC_FLAGS:=-Wall -Wpedantic -Wno-unused-variable
|
|
|
|
|
|
|
|
LD_FLAGS:=-lmnl -lnetfilter_queue
|
|
|
|
BUILD_DIR:=build
|
|
|
|
APP:=$(BUILD_DIR)/youtubeUnblock
|
|
|
|
|
|
|
|
SRCS := youtubeUnblock.c
|
|
|
|
OBJS := $(SRCS:%.c=$(BUILD_DIR)/%.o)
|
|
|
|
|
2024-07-22 07:55:05 +00:00
|
|
|
# PREFIX is environment variable, if not set default to /usr/local
|
|
|
|
ifeq ($(PREFIX),)
|
|
|
|
PREFIX := /usr/local
|
|
|
|
else
|
|
|
|
PREFIX := $(DESTDIR)
|
|
|
|
endif
|
|
|
|
|
2024-07-21 14:44:46 +00:00
|
|
|
.PHONY: default all dev dev_attrs prepare_dirs
|
|
|
|
default: all
|
|
|
|
|
|
|
|
|
|
|
|
run_dev: dev
|
2024-07-22 07:55:05 +00:00
|
|
|
bash -c "sudo ./$(APP) 537"
|
2024-07-21 14:44:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
dev: dev_attrs all
|
|
|
|
|
|
|
|
dev_attrs:
|
|
|
|
$(eval CC_FLAGS := $(CC_FLAGS) -DDEBUG -ggdb -g3)
|
|
|
|
|
|
|
|
all: prepare_dirs $(APP)
|
|
|
|
|
|
|
|
|
|
|
|
prepare_dirs:
|
|
|
|
mkdir -p $(BUILD_DIR)
|
|
|
|
|
|
|
|
$(APP): $(OBJS)
|
|
|
|
@echo 'LD $(APP)'
|
|
|
|
@$(CC) $(OBJS) -o $(APP) $(LD_FLAGS)
|
|
|
|
|
|
|
|
$(BUILD_DIR)/%.o: %.c
|
|
|
|
@echo 'CC $@'
|
|
|
|
@$(CC) -c $(CC_FLAGS) $^ -o $@
|
|
|
|
|
2024-07-22 07:55:05 +00:00
|
|
|
install: all
|
|
|
|
install -d $(PREFIX)/bin/
|
|
|
|
install -m 755 $(APP) $(PREFIX)/bin/
|
|
|
|
install -d $(PREFIX)/lib/systemd/system/
|
|
|
|
|
|
|
|
@cp youtubeUnblock.service $(BUILD_DIR)
|
|
|
|
@sed -i 's/$$(PREFIX)/$(subst /,\/,$(PREFIX))/g' $(BUILD_DIR)/youtubeUnblock.service
|
|
|
|
install -m 644 $(BUILD_DIR)/youtubeUnblock.service $(PREFIX)/lib/systemd/system/
|
|
|
|
|
|
|
|
uninstall:
|
|
|
|
rm $(PREFIX)/bin/youtubeUnblock
|
|
|
|
systemctl disable youtubeUnblock.service
|
|
|
|
rm $(PREFIX)/lib/systemd/system/youtubeUnblock.service
|
|
|
|
|
2024-07-21 14:44:46 +00:00
|
|
|
clean:
|
|
|
|
rm -rf $(BUILD_DIR)
|