-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
51 lines (40 loc) · 2.06 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
OS := $(shell uname)
DLEXT := $(shell julia -e 'using Libdl; print(Libdl.dlext)')
MPI_DIR := $(shell julia --project=. -e "using MPICH_jll; print(MPICH_jll.artifact_dir)")
CC := $(MPI_DIR)/bin/mpicc
JULIA := julia
# JULIA_DIR := $(shell $(JULIA) -e 'print(dirname(Sys.BINDIR))')
JL_SHARE = $(shell julia -e 'print(joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia"))')
CFLAGS += $(shell $(JL_SHARE)/julia-config.jl --cflags)
# LDFLAGS += $(shell $(JL_SHARE)/julia-config.jl --ldflags)
# LDLIBS += $(shell $(JL_SHARE)/julia-config.jl --ldlibs)
# JL_PRIVATE_LIBDIR = $(shell julia -e 'print(joinpath(Sys.BINDIR, Base.PRIVATE_LIBDIR))')
LIBDIR := bundle/lib
LDFLAGS += -L$(LIBDIR) -L$(LIBDIR)/julia -L$(MPI_DIR)/lib
LDLIBS += -ljulia -ljulia-internal -ldiffusion
CFLAGS += -I$(MPI_DIR)/include -I$(abspath bundle/include) -I.
ifeq ($(OS), Darwin)
WLARGS := -Wl,-rpath,"$(LIBDIR)" -Wl,-rpath,"@executable_path -Wl,-rpath,"$(LIBDIR)/julia" -Wl,-rpath,"$(MPI_DIR)/lib"
else
WLARGS := -Wl,-rpath,"$(LIBDIR):$$ORIGIN" -Wl,-rpath,"$(LIBDIR)/julia:$$ORIGIN" -Wl,-rpath,"$(MPI_DIR)/lib:$$ORIGIN"
endif
MAIN := main
ifeq ($(OS), WINNT)
MAIN := $(MAIN).exe
endif
.DEFAULT_GOAL := main mpiexecjl
$(LIBDIR)/libdiffusion.$(DLEXT): build/build.jl src/Diffusion.jl build/generate_precompile.jl build/additional_precompile.jl
JULIA_CUDA_USE_BINARYBUILDER=false $(JULIA) --startup-file=no --project=. -e 'using Pkg; Pkg.instantiate()'
# JULIA_CUDA_USE_BINARYBUILDER=false $(JULIA) --startup-file=no --project=. -e 'using Pkg; Pkg.build()'
$(JULIA) --startup-file=no --project=build -e 'using Pkg; Pkg.instantiate()'
JULIA_CUDA_USE_BINARYBUILDER=false $(JULIA_MPIEXEC) $(JULIA_MPIEXEC_ARGS) $(JULIA) --startup-file=no --project=build $<
main.o: main.c
$(CC) $^ -c -o $@ $(CFLAGS) -DJULIAC_PROGRAM_LIBNAME=\"bundle/lib/libdiffusion.$(DLEXT)\"
$(MAIN): main.o $(LIBDIR)/libdiffusion.$(DLEXT)
$(CC) -o $@ $< $(LDFLAGS) $(LDLIBS) $(WLARGS)
mpiexecjl: Manifest.toml
$(JULIA) --project=. -e 'using MPI; MPI.install_mpiexecjl(destdir=".")'
.PHONY: clean
clean:
$(RM) *~ *.o *.$(DLEXT) main
$(RM) -rf bundle