-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
$ ./rebar3 version rebar 3.24.0+build.5424.ref7da4837b on Erlang/OTP 26 Erts 14.2.5
- Loading branch information
Showing
6 changed files
with
93 additions
and
23 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Based on c_src.mk from erlang.mk by Loic Hoguin <[email protected]> | ||
|
||
CURDIR := $(shell pwd) | ||
BASEDIR := $(abspath $(CURDIR)/..) | ||
|
||
PROJECT ?= $(notdir $(BASEDIR)) | ||
PROJECT := $(strip $(PROJECT)) | ||
|
||
ERTS_INCLUDE_DIR ?= $(shell erl -noshell -eval "io:format(\"~ts/erts-~ts/include/\", [code:root_dir(), erlang:system_info(version)])." -s init stop) | ||
ERL_INTERFACE_INCLUDE_DIR ?= $(shell erl -noshell -eval "io:format(\"~ts\", [code:lib_dir(erl_interface, include)])." -s init stop) | ||
ERL_INTERFACE_LIB_DIR ?= $(shell erl -noshell -eval "io:format(\"~ts\", [code:lib_dir(erl_interface, lib)])." -s init stop) | ||
|
||
C_SRC_DIR = $(CURDIR) | ||
C_SRC_OUTPUT ?= $(CURDIR)/../priv/$(PROJECT).so | ||
|
||
# System type and C compiler/flags. | ||
|
||
UNAME_SYS := $(shell uname -s) | ||
ifeq ($(UNAME_SYS), Darwin) | ||
CC ?= cc | ||
CFLAGS ?= -O3 -std=c99 -finline-functions -Wall -Wmissing-prototypes | ||
CXXFLAGS ?= -O3 -finline-functions -Wall | ||
LDFLAGS ?= -flat_namespace -undefined suppress | ||
else ifeq ($(UNAME_SYS), FreeBSD) | ||
CC ?= cc | ||
CFLAGS ?= -O3 -std=c99 -finline-functions -Wall -Wmissing-prototypes | ||
CXXFLAGS ?= -O3 -finline-functions -Wall | ||
LDFLAGS ?= -lstdc++ | ||
else ifeq ($(UNAME_SYS), Linux) | ||
CC ?= gcc | ||
CFLAGS ?= -O3 -std=c99 -finline-functions -Wall -Wmissing-prototypes | ||
CXXFLAGS ?= -O3 -finline-functions -Wall | ||
LDFLAGS ?= -lstdc++ | ||
endif | ||
|
||
CFLAGS += -fPIC -I $(ERTS_INCLUDE_DIR) -I $(ERL_INTERFACE_INCLUDE_DIR) | ||
CXXFLAGS += -fPIC -I $(ERTS_INCLUDE_DIR) -I $(ERL_INTERFACE_INCLUDE_DIR) | ||
CXXFLAGS += -I isa-l/include -I jerasure/include -I gf-complete/include | ||
|
||
LDLIBS += -L $(ERL_INTERFACE_LIB_DIR) -lei | ||
LDFLAGS += gf-complete/src/.libs/*.o jerasure/src/.libs/*.o -Wl,-load_hidden,isa-l/.libs/libisal.a | ||
LDFLAGS += -shared | ||
|
||
# Verbosity. | ||
|
||
c_verbose_0 = @echo " C " $(?F); | ||
c_verbose = $(c_verbose_$(V)) | ||
|
||
cpp_verbose_0 = @echo " CPP " $(?F); | ||
cpp_verbose = $(cpp_verbose_$(V)) | ||
|
||
link_verbose_0 = @echo " LD " $(@F); | ||
link_verbose = $(link_verbose_$(V)) | ||
|
||
SOURCES := $(shell echo *.cpp) | ||
OBJECTS = $(addsuffix .o, $(basename $(SOURCES))) | ||
|
||
COMPILE_C = $(c_verbose) $(CC) $(CFLAGS) $(CPPFLAGS) -c | ||
COMPILE_CPP = $(cpp_verbose) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c | ||
|
||
$(C_SRC_OUTPUT): $(OBJECTS) | ||
@mkdir -p $(BASEDIR)/priv/ | ||
$(link_verbose) $(CC) $(OBJECTS) $(LDFLAGS) $(LDLIBS) -o $(C_SRC_OUTPUT) | ||
|
||
%.o: %.c | ||
$(COMPILE_C) $(OUTPUT_OPTION) $< | ||
|
||
%.o: %.cc | ||
$(COMPILE_CPP) $(OUTPUT_OPTION) $< | ||
|
||
%.o: %.C | ||
$(COMPILE_CPP) $(OUTPUT_OPTION) $< | ||
|
||
%.o: %.cpp | ||
$(COMPILE_CPP) $(OUTPUT_OPTION) $< | ||
|
||
clean: | ||
@rm -f $(C_SRC_OUTPUT) $(OBJECTS) |
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