]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | # |
2 | # Example of how to build and install locally as a shared library | |
3 | # | |
4 | # Usage: | |
5 | # | |
6 | # $ make -f Makefile.sharedlibrary | |
7 | # $ sudo make -f Makefile.sharedlibrary install | |
8 | # $ make -f Makefile.sharedlibrary duk # --> example 'duk' linked to shared libduktape | |
9 | # | |
10 | # $ ls -l duk | |
11 | # -rwxrwxr-x 1 duktape duktape 19407 Nov 30 15:48 duk | |
12 | # | |
13 | # $ ldd ./duk | |
14 | # linux-vdso.so.1 => (0x00007ffd5ed3c000) | |
15 | # libduktape.so.104 => /usr/local/lib/libduktape.so.104 (0x00007fb2f9753000) | |
16 | # libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fb2f944d000) | |
17 | # libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb2f9088000) | |
18 | # /lib64/ld-linux-x86-64.so.2 (0x00007fb2f9991000) | |
19 | # | |
20 | # Based on: http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html | |
21 | ||
22 | # Soname version must be bumped whenever a binary compatibility change occurs | |
23 | # (and should not be bumped when the library is compatible). A simple Duktape | |
24 | # convention is to set soname version to (100*MAJOR + MINOR), e.g. 104 for | |
25 | # Duktape 1.4.x, so that it gets automatically bumped for major and minor | |
26 | # releases (potentially binary incompatible), but not for patch releases. | |
27 | DUK_VERSION=10502 | |
28 | SONAME_VERSION=105 | |
29 | REAL_VERSION=$(SONAME_VERSION).$(DUK_VERSION) | |
30 | ||
31 | # Change to actual path for actual distribution packaging. | |
32 | INSTALL_PREFIX=/usr/local | |
33 | ||
34 | # The 'noline' variant may be more appropriate for some distributions; it | |
35 | # doesn't have #line directives in the combined source. | |
36 | DUKTAPE_SRCDIR=./src | |
37 | #DUKTAPE_SRCDIR=./src-noline | |
38 | ||
39 | .PHONY: all | |
40 | all: libduktape.so.$(REAL_VERSION) libduktaped.so.$(REAL_VERSION) | |
41 | ||
42 | # If the default duk_config.h is not suitable for the distribution, modify it | |
43 | # before compiling the shared library and copy the same, edited duk_config.h | |
44 | # to $INSTALL_PREFIX/include on installation. | |
45 | ||
46 | libduktape.so.$(REAL_VERSION): | |
47 | gcc -shared -fPIC -Wall -Wextra -Os -Wl,-soname,libduktape.so.$(SONAME_VERSION) \ | |
48 | -o $@ $(DUKTAPE_SRCDIR)/duktape.c | |
49 | ||
50 | libduktaped.so.$(REAL_VERSION): | |
51 | gcc -shared -fPIC -g -Wall -Wextra -Os -Wl,-soname,libduktaped.so.$(SONAME_VERSION) \ | |
52 | -o $@ $(DUKTAPE_SRCDIR)/duktape.c | |
53 | ||
54 | # Symlinks depend on platform conventions. | |
55 | .PHONY: install | |
56 | install: libduktape.so.$(REAL_VERSION) libduktaped.so.$(REAL_VERSION) | |
57 | cp $+ $(INSTALL_PREFIX)/lib/ | |
58 | rm -f $(INSTALL_PREFIX)/lib/libduktape.so $(INSTALL_PREFIX)/lib/libduktape.so.$(SONAME_VERSION) | |
59 | ln -s libduktape.so.$(REAL_VERSION) $(INSTALL_PREFIX)/lib/libduktape.so | |
60 | ln -s libduktape.so.$(REAL_VERSION) $(INSTALL_PREFIX)/lib/libduktape.so.$(SONAME_VERSION) | |
61 | rm -f $(INSTALL_PREFIX)/lib/libduktaped.so $(INSTALL_PREFIX)/lib/libduktaped.so.$(SONAME_VERSION) | |
62 | ln -s libduktaped.so.$(REAL_VERSION) $(INSTALL_PREFIX)/lib/libduktaped.so | |
63 | ln -s libduktaped.so.$(REAL_VERSION) $(INSTALL_PREFIX)/lib/libduktaped.so.$(SONAME_VERSION) | |
64 | cp $(DUKTAPE_SRCDIR)/duktape.h $(DUKTAPE_SRCDIR)/duk_config.h $(INSTALL_PREFIX)/include/ | |
65 | ||
66 | # Note: assumes /usr/local/include/ and /usr/local/lib/ are in include/link | |
67 | # path which may not be the case for all distributions. | |
68 | #CCOPTS=-I/usr/local/include -L/usr/local/lib | |
69 | CCOPTS= | |
70 | duk: | |
71 | gcc $(CCOPTS) -Wall -Wextra -Os -o $@ ./examples/cmdline/duk_cmdline.c -lduktape -lm |