forked from JuliaLang/julia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
60 lines (45 loc) · 2.05 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# This file is a part of Julia. License is MIT: https://julialang.org/license
# 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
#=============================================================================
# this source directory where embedding.c is located
SRCDIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
# get the executable suffix, if any
EXE := $(suffix $(abspath $(JULIA)))
# get compiler and linker flags. (see: `contrib/julia-config.jl`)
JULIA_CONFIG := $(JULIA) -e 'include(joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "julia-config.jl"))' --
CPPFLAGS_ADD :=
CFLAGS_ADD = $(shell $(JULIA_CONFIG) --cflags)
LDFLAGS_ADD = -lm $(shell $(JULIA_CONFIG) --ldflags --ldlibs)
DEBUGFLAGS += -g
#=============================================================================
release: $(BIN)/embedding$(EXE)
debug: $(BIN)/embedding-debug$(EXE)
$(BIN)/embedding$(EXE): $(SRCDIR)/embedding.c
$(CC) $^ -o $@ $(CPPFLAGS_ADD) $(CPPFLAGS) $(CFLAGS_ADD) $(CFLAGS) $(LDFLAGS_ADD) $(LDFLAGS)
$(BIN)/embedding-debug$(EXE): $(SRCDIR)/embedding.c
$(CC) $^ -o $@ $(CPPFLAGS_ADD) $(CPPFLAGS) $(CFLAGS_ADD) $(CFLAGS) $(LDFLAGS_ADD) $(LDFLAGS) $(DEBUGFLAGS)
ifneq ($(abspath $(BIN)),$(abspath $(SRCDIR)))
# for demonstration purposes, our demo code is also installed
# in $BIN, although this would likely not be typical
$(BIN)/LocalModule.jl: $(SRCDIR)/LocalModule.jl
cp $< $@
endif
check: $(BIN)/embedding$(EXE) $(BIN)/LocalModule.jl
$(JULIA) --depwarn=error $(SRCDIR)/embedding-test.jl $<
@echo SUCCESS
clean:
-rm -f $(BIN)/embedding-debug$(EXE) $(BIN)/embedding$(EXE)
.PHONY: release debug clean check
# Makefile debugging trick:
# call print-VARIABLE to see the runtime value of any variable
print-%:
@echo '$*=$($*)'