forked from JuliaLang/julia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix embedding example and simplify Makefile
- get rid of makefile cruft - use julia-config for flags, as documented in manual - build into `libexec` also move to subdir for clarity.
- Loading branch information
1 parent
5d7c4c2
commit 8dd3123
Showing
7 changed files
with
73 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,23 @@ | ||
JULIAHOME := $(abspath ..) | ||
SRCDIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) | ||
BUILDDIR := . | ||
JULIAHOME := $(abspath $(SRCDIR)/..) | ||
include $(JULIAHOME)/Make.inc | ||
|
||
FLAGS = -Wall -Wno-strict-aliasing -fno-omit-frame-pointer \ | ||
-I$(JULIAHOME)/src -I$(JULIAHOME)/src/support -I$(build_includedir) $(CFLAGS) | ||
embedding_binary := $(abspath $(build_libexecdir)/embedding$(JULIA_LIBSUFFIX)$(EXE)) | ||
|
||
DEBUGFLAGS += $(FLAGS) | ||
SHIPFLAGS += $(FLAGS) | ||
JLDFLAGS += $(LDFLAGS) $(NO_WHOLE_ARCHIVE) $(call exec,$(LLVM_CONFIG) --ldflags) $(OSLIBS) $(RPATH) | ||
release: embedding | ||
debug: embedding-debug | ||
|
||
ifeq ($(USE_SYSTEM_LIBM),0) | ||
ifneq ($(UNTRUSTED_SYSTEM_LIBM),0) | ||
JLDFLAGS += $(WHOLE_ARCHIVE) $(build_libdir)/libopenlibm.a $(NO_WHOLE_ARCHIVE) | ||
endif | ||
endif | ||
embedding: $(embedding_binary) | ||
embedding-debug: $(embedding_binary) | ||
|
||
embedding-release: embedding | ||
$(embedding_binary): $(wildcard embedding/*) | ||
@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT)/examples/embedding $(JULIA_BUILD_MODE) \ | ||
JULIA="$(JULIA_EXECUTABLE)" BIN="$(build_libexecdir)" \ | ||
SPAWN="$(spawn)" CC="$(CC)" | ||
|
||
release debug: | ||
$(MAKE) embedding-$@ | ||
clean: | ||
-rm -f $(embedding_binary) $(embedding_binary)-debug | ||
|
||
%.o: %.c | ||
@$(call PRINT_CC, $(CC) $(CPPFLAGS) $(CFLAGS) $(SHIPFLAGS) -c $< -o $@) | ||
%.do: %.c | ||
@$(call PRINT_CC, $(CC) $(CPPFLAGS) $(CFLAGS) $(DEBUGFLAGS) -c $< -o $@) | ||
|
||
embedding: $(build_bindir)/embedding$(EXE) | ||
embedding-debug: $(build_bindir)/embedding-debug$(EXE) | ||
|
||
$(build_bindir)/embedding$(EXE): embedding.o | ||
@$(call PRINT_LINK, $(CXX) $(LINK_FLAGS) $(SHIPFLAGS) $^ -o $@ -L$(build_private_libdir) -L$(build_shlibdir) -ljulia $(JLDFLAGS)) | ||
$(build_bindir)/embedding-debug$(EXE): embedding.do | ||
@$(call PRINT_LINK, $(CXX) $(LINK_FLAGS) $(DEBUGFLAGS) $^ -o $@ -L$(build_private_libdir) -L$(build_shlibdir) -ljulia-debug $(JLDFLAGS)) | ||
|
||
|
||
clean: | $(CLEAN_TARGETS) | ||
rm -f *.o *.do | ||
rm -f $(build_bindir)/embedding-debug $(build_bindir)/embedding | ||
|
||
.PHONY: clean release debug | ||
.PHONY: all embedding clean | ||
|
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,39 @@ | ||
# This Makefile template requires the following variables to be set | ||
# in the environment or on the command-line: | ||
# JULIA: path to julia[.exe] executable | ||
# BIN: binary build directory | ||
|
||
ifndef JULIA | ||
$(error "Please pass JULIA=[path of target julia binary], or set as environment variable!") | ||
endif | ||
ifndef BIN | ||
$(error "Please pass BIN=[path of build directory], or set as environment variable!") | ||
endif | ||
|
||
#============================================================================= | ||
# get the executable suffix, if any | ||
EXE := $(suffix $(abspath $(JULIA))) | ||
|
||
# get compiler and linker flags. (see: `contrib/julia-config.jl`) | ||
CFLAGS += -lm $(shell $(SPAWN) $(JULIA) -e \ | ||
'include(joinpath(JULIA_HOME,Base.DATAROOTDIR,"julia","julia-config.jl"))' \ | ||
-- --cflags --ldflags --ldlibs) | ||
|
||
DEBUGFLAGS += -g | ||
|
||
#============================================================================= | ||
|
||
release: $(BIN)/embedding$(EXE) | ||
debug: $(BIN)/embedding-debug$(EXE) | ||
|
||
$(BIN)/embedding$(EXE): embedding.c | ||
$(CC) $^ -o $@ $(CFLAGS) | ||
|
||
$(BIN)/embedding-debug$(EXE): embedding.c | ||
$(CC) $^ -o $@ $(CFLAGS) $(DEBUGFLAGS) | ||
|
||
clean: | ||
@rm -f $(BIN)/embedding-debug$(EXE) $(BIN)/embedding$(EXE) | ||
|
||
.PHONY: release debug clean | ||
|
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
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