Last active
June 15, 2017 12:50
-
-
Save dvirsky/a8407b69fc14335d8250c3b194ff85ee to your computer and use it in GitHub Desktop.
Minimal makefile for a redis module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DEBUGFLAGS = -g -ggdb -O2 | |
ifeq ($(DEBUG), 1) | |
DEBUGFLAGS = -g -ggdb -O0 | |
endif | |
# find the OS | |
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not') | |
CFLAGS = -Wall -Wno-unused-function $(DEBUGFLAGS) -fPIC -std=gnu99 -D_GNU_SOURCE | |
CC:=$(shell sh -c 'type $(CC) >/dev/null 2>/dev/null && echo $(CC) || echo gcc') | |
# Compile flags for linux / osx | |
ifeq ($(uname_S),Linux) | |
SHOBJ_CFLAGS ?= -fno-common -g -ggdb | |
SHOBJ_LDFLAGS ?= -shared -Bsymbolic -Bsymbolic-functions | |
else | |
CFLAGS += -mmacosx-version-min=10.6 | |
SHOBJ_CFLAGS ?= -dynamic -fno-common -g -ggdb | |
SHOBJ_LDFLAGS ?= -dylib -exported_symbol _RedisModule_OnLoad -macosx_version_min 10.6 | |
endif | |
SOURCEDIR=$(shell pwd -P) | |
CC_SOURCES = $(wildcard $(SOURCEDIR)/*.c) | |
CC_OBJECTS = $(patsubst $(SOURCEDIR)/%.c, $(SOURCEDIR)/%.o, $(CC_SOURCES)) | |
all: module.so | |
module.so: $(CC_OBJECTS) | |
$(LD) -o $@ $(CC_OBJECTS) $(SHOBJ_LDFLAGS) -lc | |
clean: | |
rm -rvf *.xo *.so *.o *.a | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment