Skip to content

Instantly share code, notes, and snippets.

@dvirsky
Last active June 15, 2017 12:50
Show Gist options
  • Select an option

  • Save dvirsky/a8407b69fc14335d8250c3b194ff85ee to your computer and use it in GitHub Desktop.

Select an option

Save dvirsky/a8407b69fc14335d8250c3b194ff85ee to your computer and use it in GitHub Desktop.

Revisions

  1. dvirsky revised this gist Jun 15, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Makefile
    Original file line number Diff line number Diff line change
    @@ -19,7 +19,7 @@ else
    endif

    SOURCEDIR=$(shell pwd -P)
    CC_SOURCES = $(wildcard $(SOURCEDIR)/*.c) $(wildcard $(SOURCEDIR)/dep/*.c)
    CC_SOURCES = $(wildcard $(SOURCEDIR)/*.c)
    CC_OBJECTS = $(patsubst $(SOURCEDIR)/%.c, $(SOURCEDIR)/%.o, $(CC_SOURCES))

    all: module.so
  2. dvirsky revised this gist May 10, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Makefile
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,7 @@ CC_OBJECTS = $(patsubst $(SOURCEDIR)/%.c, $(SOURCEDIR)/%.o, $(CC_SOURCES))
    all: module.so

    module.so: $(CC_OBJECTS)
    $(LD) -o $@ $(CC_OBJECTS) -lc
    $(LD) -o $@ $(CC_OBJECTS) $(SHOBJ_LDFLAGS) -lc

    clean:
    rm -rvf *.xo *.so *.o *.a
  3. dvirsky renamed this gist May 10, 2017. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. dvirsky created this gist May 10, 2017.
    32 changes: 32 additions & 0 deletions Make.module
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    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) $(wildcard $(SOURCEDIR)/dep/*.c)
    CC_OBJECTS = $(patsubst $(SOURCEDIR)/%.c, $(SOURCEDIR)/%.o, $(CC_SOURCES))

    all: module.so

    module.so: $(CC_OBJECTS)
    $(LD) -o $@ $(CC_OBJECTS) -lc

    clean:
    rm -rvf *.xo *.so *.o *.a