2019-09-24 08:53:00 +08:00
|
|
|
CROSS_COMPILE ?=
|
|
|
|
CC := $(CROSS_COMPILE)gcc
|
2023-01-14 18:28:39 +08:00
|
|
|
AR := $(CROSS_COMPILE)ar
|
|
|
|
RANLIB := $(CROSS_COMPILE)ranlib
|
2023-01-15 10:33:54 +08:00
|
|
|
|
2023-01-14 18:28:39 +08:00
|
|
|
OBG = rhost
|
|
|
|
CFLAGS += -Os -g -Wall -DCRON_USE_LOCAL_TIME -DCRON_TEST_MALLOC
|
2022-10-25 23:07:47 +08:00
|
|
|
|
2022-10-13 18:01:06 +08:00
|
|
|
|
2023-01-15 10:33:54 +08:00
|
|
|
CMAKE = $(shell if test -f /etc/centos-release; then echo "1"; else echo "0"; fi)
|
|
|
|
ifeq ("$(CMAKE)", "1")
|
|
|
|
CMAKE := cmake3
|
|
|
|
else
|
|
|
|
CMAKE := cmake
|
|
|
|
endif
|
|
|
|
|
2023-04-04 15:37:42 +08:00
|
|
|
ARCH := $(shell bash get_architecture.sh)
|
2023-01-28 11:37:36 +08:00
|
|
|
|
2023-01-15 10:33:54 +08:00
|
|
|
|
2022-10-13 18:01:06 +08:00
|
|
|
IPTC_CFLAGS += -DHAVE_CONFIG_H -I./libiptc -D_LARGEFILE_SOURCE=1 -D_LARGE_FILES -D_FILE_OFFSET_BITS=64 -D_REENTRANT
|
2023-01-14 18:28:39 +08:00
|
|
|
IPTC_LIB += -lip4tc
|
2022-10-22 18:41:00 +08:00
|
|
|
|
2023-01-10 12:54:53 +08:00
|
|
|
ip2region_CFLAGS += -Os -g -Wall -I/ip2region -c
|
|
|
|
ip2region_LIB += ip2region.o xdb_searcher.o
|
|
|
|
|
2023-01-14 18:28:39 +08:00
|
|
|
CLAMAV_CFLAGS += -DHAVE_CONFIG_H -I./clamav/libclamav -I./clamav/ -I./clamav/libclamunrar_iface -I./clamav/common -isystem ./clamav/ -isystem /usr/include/libxml2 -isystem /usr/include/json-c -fPIE -Wall -Wextra -Wformat-security -std=gnu90
|
2023-04-04 15:37:42 +08:00
|
|
|
CLAMAV_LIB += ./clamav/clamscan/clamscan.c.o ./clamav/clamscan/manager.c.o ./clamav/libcommon.a -Wl,-rpath,/lib /lib/libclamav.so.11.0.0 -lmspack ./clamav/libclamav_rust/$(ARCH)/debug/libclamav_rust.a -lgcc_s -lutil -lrt -lpthread -lm -ldl -lc -lbz2 -lpcre2-8 -lxml2 -ljson-c -lc -ldl -lm -lssl -lcrypto -lz -lcurl -lsystemd
|
2023-01-14 18:28:39 +08:00
|
|
|
|
|
|
|
FRESHCLAM_CFLAGS += -DHAVE_CONFIG_H -I./clamav/libfreshclam -I./clamav/common -I./clamav/libclamav -I./clamav/libclamunrar_iface -isystem ./clamav/ -isystem ./clamav/libclamav_rust -isystem /usr/include/libxml2 -isystem /usr/include/json-c -fPIE -Wall -Wextra -Wformat-security -std=gnu90
|
2023-04-04 15:37:42 +08:00
|
|
|
FRESHCLAM_LIB += ./clamav/freshclam/freshclam.c.o ./clamav/freshclam/execute.c.o ./clamav/freshclam/notify.c.o -Wl,-rpath,/lib /lib/libfreshclam.so.2.0.2 ./clamav/libcommon.a -Wl,-rpath,/lib /lib/libclamav.so.11.0.0 -lmspack ./clamav/libclamav_rust/$(ARCH)/debug/libclamav_rust.a -lgcc_s -lutil -lrt -lpthread -lm -ldl -lc -lbz2 -lpcre2-8 -lxml2 -ljson-c -lc -ldl -lm -lz -lsystemd -lcurl -lssl -lcrypto -lresolv
|
2023-01-14 18:28:39 +08:00
|
|
|
|
|
|
|
LIBCOMMON__CFLAGS += -DHAVE_CONFIG_H -I./clamav/common -I./clamav/libclamav -I./clamav/ -I./clamav/libclamunrar_iface -isystem ./clamav/ -isystem /usr/include/libxml2 -isystem /usr/include/json-c -fPIC -Wall -Wextra -Wformat-security
|
|
|
|
LIBCOMMON_LIB += ./clamav/common/cert_util.c.o ./clamav/common/actions.c.o ./clamav/common/clamdcom.c.o ./clamav/common/getopt.c.o ./clamav/common/hostid.c.o ./clamav/common/idmef_logging.c.o ./clamav/common/misc.c.o ./clamav/common/optparser.c.o ./clamav/common/output.c.o ./clamav/common/tar.c.o ./clamav/common/linux/cert_util_linux.c.o
|
|
|
|
|
2023-04-04 15:37:42 +08:00
|
|
|
|
2024-05-21 15:28:20 +08:00
|
|
|
all: libclamav_rust libclamav rhost nginx.o
|
2023-04-04 15:37:42 +08:00
|
|
|
|
2024-05-27 16:05:31 +08:00
|
|
|
rhost: conf.o common.o rhost.o libiptc.o ccronexpr.o rule.o nginx.o disk.o ip.o warning.o
|
2023-01-10 12:54:53 +08:00
|
|
|
$(CC) $(ip2region_CFLAGS) ip2region/ip2region.c
|
|
|
|
$(CC) $(ip2region_CFLAGS) ip2region/xdb_searcher.c
|
2023-01-14 18:28:39 +08:00
|
|
|
|
|
|
|
$(CC) $(CLAMAV_CFLAGS) -o ./clamav/clamscan/clamscan.c.o -c ./clamav/clamscan/clamscan.c
|
|
|
|
$(CC) $(CLAMAV_CFLAGS) -o ./clamav/clamscan/manager.c.o -c ./clamav/clamscan/manager.c
|
|
|
|
|
|
|
|
$(CC) $(FRESHCLAM_CFLAGS) -o ./clamav/freshclam/freshclam.c.o -c ./clamav/freshclam/freshclam.c
|
|
|
|
$(CC) $(FRESHCLAM_CFLAGS) -o ./clamav/freshclam/execute.c.o -c ./clamav/freshclam/execute.c
|
|
|
|
$(CC) $(FRESHCLAM_CFLAGS) -o ./clamav/freshclam/notify.c.o -c ./clamav/freshclam/notify.c
|
|
|
|
|
2024-05-27 16:05:31 +08:00
|
|
|
$(CC) $(CFLAGS) $^ -o $(OBG) $(ip2region_LIB) $(CLAMAV_LIB) $(IPTC_LIB) $(FRESHCLAM_LIB)
|
2022-10-22 18:41:00 +08:00
|
|
|
|
2022-08-09 15:25:06 +08:00
|
|
|
chmod +x $(OBG)
|
2022-10-13 18:01:06 +08:00
|
|
|
|
2023-01-14 18:28:39 +08:00
|
|
|
libclamav_rust:
|
|
|
|
cd clamav/libclamav_rust && $(CMAKE) -E env CARGO_CMD=build CARGO_TARGET_DIR=./ MAINTAINER_MODE=OFF RUSTFLAGS="" \
|
2023-04-04 15:37:42 +08:00
|
|
|
cargo build --target $(ARCH) --target-dir ./
|
2023-01-14 18:28:39 +08:00
|
|
|
cd ..
|
|
|
|
|
|
|
|
libclamav:
|
|
|
|
cd clamav/ && bash -x build-libclamav.sh
|
2023-01-15 11:02:57 +08:00
|
|
|
cp ${PWD}/clamav/libclamav.so.11.0.0 /lib/
|
|
|
|
cp ${PWD}/clamav/libfreshclam.so.2.0.2 /lib/
|
|
|
|
rm -rf /lib/libclamav.so.11 && ln -s /lib/libclamav.so.11.0.0 /lib/libclamav.so.11
|
|
|
|
rm -rf /lib/libfreshclam.so.2 && ln -s /lib/libfreshclam.so.2.0.2 /lib/libfreshclam.so.2
|
2023-01-14 18:28:39 +08:00
|
|
|
cd ..
|
|
|
|
|
|
|
|
|
|
|
|
test:
|
2024-05-21 15:28:20 +08:00
|
|
|
echo $(CMAKE) $(ARCH) $(CFLAGS)
|
2023-01-14 18:28:39 +08:00
|
|
|
|
2022-10-13 18:01:06 +08:00
|
|
|
static: conf.o rhost.o libiptc.o
|
|
|
|
$(CC) $(IPTC_CFLAGS) -c libiptc/libip4tc.c -o libiptc/libip4tc.o
|
|
|
|
ar crs libiptc/libip4tc.a libiptc/libip4tc.o
|
2022-11-23 13:15:49 +08:00
|
|
|
#$(CC) $(CFLAGS) $^ libiptc/libip4tc.o -o $(OBG) `/data/curl/bin/curl-config --cflags --static-libs` `pkg-config --libs --static libbrotlidec`
|
2022-10-13 18:01:06 +08:00
|
|
|
|
2023-01-14 18:28:39 +08:00
|
|
|
.PHONY: clean
|
2019-09-24 08:53:00 +08:00
|
|
|
clean:
|
|
|
|
rm -rf *.o
|
2023-01-14 18:28:39 +08:00
|
|
|
rm -rf $(OBG) $(cJSON_LIB) $(ip2region_LIB)
|
|
|
|
rm -rf `find ./clamav/ -name *.o`
|
|
|
|
rm -rf ./clamav/*.a
|
|
|
|
rm -rf ./clamav/libclamav.so.11.0.0
|
|
|
|
rm -rf ./clamav/libfreshclam.so.2.0.2
|
|
|
|
rm -rf ${PWD}/clamav/libclamav.so.11
|
|
|
|
rm -rf ${PWD}/clamav/libfreshclam.so.2
|
2023-01-16 14:42:14 +08:00
|
|
|
rm -rf clamav/libclamav_rust/debug
|
2023-04-04 15:37:42 +08:00
|
|
|
rm -rf clamav/libclamav_rust/$(ARCH)
|
2023-01-16 14:42:14 +08:00
|
|
|
|