2024-07-22 19:46:16 +00:00
|
|
|
BUILD_DIR := $(CURDIR)/build
|
|
|
|
DEPSDIR := $(BUILD_DIR)/deps
|
2024-07-21 14:44:46 +00:00
|
|
|
|
2024-07-22 19:46:16 +00:00
|
|
|
CC := gcc
|
2024-08-01 06:58:34 +00:00
|
|
|
CCLD := $(CC)
|
|
|
|
LD := ld
|
2024-08-02 07:19:04 +00:00
|
|
|
CFLAGS:=-Wall -Wpedantic -Wno-unused-variable -I$(DEPSDIR)/include -Os
|
2024-07-22 19:46:16 +00:00
|
|
|
LDFLAGS:=-L$(DEPSDIR)/lib -static
|
2024-07-21 14:44:46 +00:00
|
|
|
|
2024-07-25 06:51:23 +00:00
|
|
|
LIBNFNETLINK_CFLAGS := -I$(DEPSDIR)/include
|
|
|
|
LIBNFNETLINK_LIBS := -L$(DEPSDIR)/lib
|
|
|
|
LIBMNL_CFLAGS := -I$(DEPSDIR)/include
|
|
|
|
LIBMNL_LIBS := -L$(DEPSDIR)/lib
|
|
|
|
|
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-31 11:09:01 +00:00
|
|
|
export CC CCLD LD CFLAGS LDFLAGS LIBNFNETLINK_CFLAGS LIBNFNETLINK_LIBS LIBMNL_CFLAGS LIBMNL_LIBS
|
2024-07-22 19:46:16 +00:00
|
|
|
|
|
|
|
APP:=$(BUILD_DIR)/youtubeUnblock
|
|
|
|
|
|
|
|
SRCS := youtubeUnblock.c
|
|
|
|
OBJS := $(SRCS:%.c=$(BUILD_DIR)/%.o)
|
|
|
|
|
|
|
|
LIBNFNETLINK := $(DEPSDIR)/lib/libnfnetlink.a
|
|
|
|
LIBMNL := $(DEPSDIR)/lib/libmnl.a
|
|
|
|
LIBNETFILTER_QUEUE := $(DEPSDIR)/lib/libnetfilter_queue.a
|
|
|
|
|
|
|
|
|
2024-07-21 14:44:46 +00:00
|
|
|
.PHONY: default all dev dev_attrs prepare_dirs
|
|
|
|
default: all
|
|
|
|
|
|
|
|
run_dev: dev
|
2024-07-23 12:55:55 +00:00
|
|
|
bash -c "sudo $(APP) 537"
|
2024-07-21 14:44:46 +00:00
|
|
|
|
|
|
|
dev: dev_attrs all
|
|
|
|
|
|
|
|
dev_attrs:
|
2024-07-22 19:46:16 +00:00
|
|
|
$(eval CFLAGS := $(CFLAGS) -DDEBUG -ggdb -g3)
|
2024-07-21 14:44:46 +00:00
|
|
|
|
|
|
|
all: prepare_dirs $(APP)
|
|
|
|
|
|
|
|
prepare_dirs:
|
|
|
|
mkdir -p $(BUILD_DIR)
|
2024-07-22 19:46:16 +00:00
|
|
|
mkdir -p $(DEPSDIR)
|
2024-07-21 14:44:46 +00:00
|
|
|
|
2024-07-22 19:46:16 +00:00
|
|
|
$(LIBNFNETLINK):
|
2024-07-25 06:51:23 +00:00
|
|
|
cd deps/libnfnetlink && ./autogen.sh && ./configure --prefix=$(DEPSDIR) $(if $(CROSS_COMPILE_PLATFORM),--host=$(CROSS_COMPILE_PLATFORM),) --enable-static --disable-shared
|
2024-07-22 19:46:16 +00:00
|
|
|
$(MAKE) -C deps/libnfnetlink
|
|
|
|
$(MAKE) install -C deps/libnfnetlink
|
|
|
|
|
|
|
|
$(LIBMNL):
|
2024-07-25 06:51:23 +00:00
|
|
|
cd deps/libmnl && ./autogen.sh && ./configure --prefix=$(DEPSDIR) $(if $(CROSS_COMPILE_PLATFORM),--host=$(CROSS_COMPILE_PLATFORM),) --enable-static --disable-shared
|
2024-07-22 19:46:16 +00:00
|
|
|
$(MAKE) -C deps/libmnl
|
|
|
|
$(MAKE) install -C deps/libmnl
|
|
|
|
|
|
|
|
$(LIBNETFILTER_QUEUE): $(LIBNFNETLINK) $(LIBMNL)
|
2024-07-25 06:51:23 +00:00
|
|
|
cd deps/libnetfilter_queue && ./autogen.sh && ./configure --prefix=$(DEPSDIR) $(if $(CROSS_COMPILE_PLATFORM),--host=$(CROSS_COMPILE_PLATFORM),) --enable-static --disable-shared
|
2024-07-22 19:46:16 +00:00
|
|
|
$(MAKE) -C deps/libnetfilter_queue
|
|
|
|
$(MAKE) install -C deps/libnetfilter_queue
|
|
|
|
|
|
|
|
$(APP): $(OBJS) $(LIBNETFILTER_QUEUE) $(LIBMNL)
|
2024-07-31 11:09:01 +00:00
|
|
|
@echo 'CCLD $(APP)'
|
|
|
|
@$(CCLD) $(OBJS) -o $(APP) -L$(DEPSDIR)/lib -lmnl -lnetfilter_queue
|
2024-07-21 14:44:46 +00:00
|
|
|
|
2024-07-22 19:46:16 +00:00
|
|
|
$(BUILD_DIR)/%.o: %.c $(LIBNETFILTER_QUEUE) $(LIBMNL)
|
2024-07-21 14:44:46 +00:00
|
|
|
@echo 'CC $@'
|
2024-07-22 19:46:16 +00:00
|
|
|
@$(CC) -c $(CFLAGS) $^ -o $@
|
2024-07-21 14:44:46 +00:00
|
|
|
|
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
|
|
|
|
rm $(PREFIX)/lib/systemd/system/youtubeUnblock.service
|
2024-07-31 10:51:51 +00:00
|
|
|
-systemctl disable youtubeUnblock.service
|
2024-07-22 07:55:05 +00:00
|
|
|
|
2024-07-21 14:44:46 +00:00
|
|
|
clean:
|
|
|
|
rm -rf $(BUILD_DIR)
|
2024-07-22 19:46:16 +00:00
|
|
|
$(MAKE) distclean -C deps/libnetfilter_queue || true
|
|
|
|
$(MAKE) distclean -C deps/libmnl || true
|
|
|
|
$(MAKE) distclean -C deps/libnfnetlink || true
|