Skip to content

Commit 0fd31e7

Browse files
authored
More stuff
1 parent b98bd7f commit 0fd31e7

File tree

1 file changed

+36
-12
lines changed

1 file changed

+36
-12
lines changed

examples/MyLib/Makefile

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,67 @@
11
# Makefile
22

3+
# This is the default target:
34
.DEFAULT_GOAL := all
4-
55
.PHONY: all
66
all: build-library build-executable
77

8+
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
9+
10+
# The user can override these to use custom locations for Julia and/or GCC:
811
JULIA ?= julia
912
GCC ?= gcc
1013

14+
# We automatically compute DLEXT:
1115
DLEXT := $(shell $(JULIA) --startup-file=no -e 'import Libdl; print(Libdl.dlext)')
1216

17+
# Define TARGET in one place, so that we don't need to keep retyping it.
1318
TARGET="MyLibCompiled"
1419

20+
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
21+
22+
# build-library and build-executable are just for convenience:
23+
24+
.PHONY: build-library
25+
build-library: $(TARGET)/lib/libmylib.$(DLEXT)
26+
27+
.PHONY: build-executable
28+
build-executable: my_application.out
29+
30+
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
31+
32+
.PHONY: clean
33+
clean:
34+
$(RM) *.o
35+
$(RM) *.out
36+
$(RM) *.$(DLEXT)
37+
$(RM) -rf $(TARGET)
38+
39+
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
40+
41+
# Library:
42+
1543
MYLIB_INCLUDES = $(TARGET)/include/julia_init.h $(TARGET)/include/mylib.h
1644
MYLIB_PATH := $(TARGET)/lib/libmylib.$(DLEXT)
1745

46+
# We split this up into multiple lines, just so that we don't end up with a single really long line.
1847
DEPS_build_library := src/MyLib.jl
1948
DEPS_build_library += build/build.jl
2049
DEPS_build_library += build/generate_precompile.jl build/additional_precompile.jl
2150
DEPS_build_library += build/mylib.h
2251
DEPS_build_library += build/Project.toml build/Manifest.toml
2352

24-
.PHONY: build-library
25-
build-library: MyLibCompiled/lib/libmylib.dylib
26-
27-
MyLibCompiled/lib/libmylib.dylib: $(DEPS_build_library)
53+
$(TARGET)/lib/libmylib.$(DLEXT): $(DEPS_build_library)
2854
$(JULIA) --startup-file=no --project=. -e 'import Pkg; Pkg.instantiate(); Pkg.precompile()'
2955
$(JULIA) --startup-file=no --project=build -e 'import Pkg; Pkg.instantiate(); Pkg.precompile()'
3056
$(JULIA) --startup-file=no --project=build -e 'include("build/build.jl")'
3157

3258
INCLUDE_DIR = $(TARGET)/include
3359

34-
.PHONY: build-executable
35-
build-executable: my_application.out
60+
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
61+
62+
# Application (my_application.out):
3663

37-
my_application.out: MyLibCompiled/lib/libmylib.dylib
64+
my_application.out: $(TARGET)/lib/libmylib.$(DLEXT)
3865
$(GCC) my_application.c -o my_application.out -I$(INCLUDE_DIR) -L$(TARGET)/lib -ljulia -lmylib
3966

40-
.PHONY: clean
41-
clean:
42-
$(RM) *~ *.o *.$(DLEXT)
43-
$(RM) -Rf $(TARGET)
67+
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

0 commit comments

Comments
 (0)