From 5aeb3b53c067ea11b172db9b13befe86530e94f4 Mon Sep 17 00:00:00 2001 From: JesseQu Date: Wed, 21 Aug 2024 16:29:20 +0800 Subject: [PATCH] check-in the first batch of files --- .gitignore | 1 - rmutil/Makefile | 31 +++++++++++++++++++++++++++++++ source/Makefile | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 rmutil/Makefile create mode 100644 source/Makefile diff --git a/.gitignore b/.gitignore index dedab61..1ee2844 100644 --- a/.gitignore +++ b/.gitignore @@ -92,7 +92,6 @@ CMakeCache.txt CMakeFiles CMakeScripts Testing -Makefile cmake_install.cmake install_manifest.txt compile_commands.json diff --git a/rmutil/Makefile b/rmutil/Makefile new file mode 100644 index 0000000..0bb6dd9 --- /dev/null +++ b/rmutil/Makefile @@ -0,0 +1,31 @@ +# set environment variable RM_INCLUDE_DIR to the location of redismodule.h +ifndef RM_INCLUDE_DIR + RM_INCLUDE_DIR=../include/ +endif + +CFLAGS ?= -g -fPIC -O3 -std=gnu99 -Wall -Wno-unused-function +CFLAGS += -I$(RM_INCLUDE_DIR) +CC=gcc + +OBJS=util.o strings.o sds.o vector.o alloc.o periodic.o + +all: librmutil.a + +clean: + rm -rf *.o *.a + +librmutil.a: $(OBJS) + ar rcs $@ $^ + +test_vector: test_vector.o vector.o + $(CC) -Wall -o $@ $^ -lc -lpthread -O0 + @(sh -c ./$@) +.PHONY: test_vector + +test_periodic: test_periodic.o periodic.o + $(CC) -Wall -o $@ $^ -lc -lpthread -O0 + @(sh -c ./$@) +.PHONY: test_periodic + +test: test_periodic test_vector +.PHONY: test diff --git a/source/Makefile b/source/Makefile new file mode 100644 index 0000000..876bf25 --- /dev/null +++ b/source/Makefile @@ -0,0 +1,35 @@ +#set environment variable RM_INCLUDE_DIR to the location of redismodule.h +ifndef RM_INCLUDE_DIR + RM_INCLUDE_DIR=../include/ +endif + +ifndef RMUTIL_LIBDIR + RMUTIL_LIBDIR=../rmutil +endif + +# find the OS +uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not') + +# Compile flags for linux / osx +ifeq ($(uname_S),Linux) + SHOBJ_CFLAGS ?= -fno-common -g -ggdb + SHOBJ_LDFLAGS ?= -shared -Bsymbolic +else + SHOBJ_CFLAGS ?= -dynamic -fno-common -g -ggdb + SHOBJ_LDFLAGS ?= -bundle -undefined dynamic_lookup +endif +CFLAGS = -I$(RM_INCLUDE_DIR) -Wall -g -fPIC -lc -lm -std=gnu99 +CC=gcc + +all: rmutil module.so + +rmutil: FORCE + $(MAKE) -C $(RMUTIL_LIBDIR) + +module.so: module.o + $(LD) -o $@ module.o $(SHOBJ_LDFLAGS) $(LIBS) -L$(RMUTIL_LIBDIR) -lrmutil -lc + +clean: + rm -rf *.xo *.so *.o + +FORCE: