diff options
author | Loïc Hoguin <[email protected]> | 2014-11-24 11:19:07 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2014-11-24 11:19:07 +0200 |
commit | 4b2f8ba5561d34532b3a268d21b268e0a9717e0d (patch) | |
tree | 9977cd5d4f5cfaadab3e93d8ece1d90eac0d44a5 /erlang.mk | |
parent | 2babb150053941bd44f32bd19655484e353738ed (diff) | |
parent | edb63def754834c1e3654a8fd2681a7ec1f97a65 (diff) | |
download | erlang.mk-4b2f8ba5561d34532b3a268d21b268e0a9717e0d.tar.gz erlang.mk-4b2f8ba5561d34532b3a268d21b268e0a9717e0d.tar.bz2 erlang.mk-4b2f8ba5561d34532b3a268d21b268e0a9717e0d.zip |
Merge branch 'C++_source' of git://github.com/nevar/erlang.mk
Diffstat (limited to 'erlang.mk')
-rw-r--r-- | erlang.mk | 40 |
1 files changed, 32 insertions, 8 deletions
@@ -585,7 +585,6 @@ list-templates: C_SRC_DIR = $(CURDIR)/c_src C_SRC_ENV ?= $(C_SRC_DIR)/env.mk -C_SRC_OPTS ?= C_SRC_OUTPUT ?= $(CURDIR)/priv/$(PROJECT).so # System type and C compiler/flags. @@ -594,23 +593,33 @@ UNAME_SYS := $(shell uname -s) ifeq ($(UNAME_SYS), Darwin) CC ?= cc CFLAGS ?= -O3 -std=c99 -arch x86_64 -flat_namespace -undefined suppress -finline-functions -Wall -Wmissing-prototypes + CXXFLAGS ?= -O3 -arch x86_64 -flat_namespace -undefined suppress -finline-functions -Wall else ifeq ($(UNAME_SYS), FreeBSD) CC ?= cc CFLAGS ?= -O3 -std=c99 -finline-functions -Wall -Wmissing-prototypes + CXXFLAGS ?= -O3 -finline-functions -Wall else ifeq ($(UNAME_SYS), Linux) CC ?= gcc CFLAGS ?= -O3 -std=c99 -finline-functions -Wall -Wmissing-prototypes + CXXFLAGS ?= -O3 -finline-functions -Wall endif CFLAGS += -fPIC -I $(ERTS_INCLUDE_DIR) -I $(ERL_INTERFACE_INCLUDE_DIR) +CXXFLAGS += -fPIC -I $(ERTS_INCLUDE_DIR) -I $(ERL_INTERFACE_INCLUDE_DIR) LDLIBS += -L $(ERL_INTERFACE_LIB_DIR) -lerl_interface -lei LDFLAGS += -shared # Verbosity. -c_src_verbose_0 = @echo " C_SRC " $(?F); -c_src_verbose = $(c_src_verbose_$(V)) +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)) # Targets. @@ -623,14 +632,29 @@ clean:: $(MAKE) -C $(C_SRC_DIR) clean else -SOURCE := $(shell find $(C_SRC_DIR) -type f -name \*.c) +SOURCES := $(shell find $(C_SRC_DIR) -type f -regex ".*\.\(C\|cc?\|cpp\)") +OBJECTS = $(addsuffix .o, $(basename $(SOURCES))) + +COMPILE_C = $(c_verbose) $(CC) $(CFLAGS) $(CPPFLAGS) -c +COMPILE_CPP = $(cpp_verbose) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c app:: $(C_SRC_ENV) $(C_SRC_OUTPUT) -$(C_SRC_OUTPUT): $(SOURCE) +$(C_SRC_OUTPUT): $(OBJECTS) @mkdir -p priv/ - $(c_src_verbose) $(CC) $(CFLAGS) $(SOURCE) \ - $(LDFLAGS) $(LDLIBS) -o $(C_SRC_OUTPUT) $(C_SRC_OPTS) + $(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) $< $(C_SRC_ENV): @erl -noshell -noinput -eval "file:write_file(\"$(C_SRC_ENV)\", \ @@ -646,7 +670,7 @@ $(C_SRC_ENV): clean:: clean-c_src clean-c_src: - $(gen_verbose) rm -f $(C_SRC_OUTPUT) + $(gen_verbose) rm -f $(C_SRC_OUTPUT) $(OBJECTS) distclean:: distclean-c_src-env |