refimpl2-config 1.14 KB
Newer Older
1 2 3 4 5 6 7
#!/usr/bin/env python

from __future__ import print_function  # compatible with python2

import sys
import os
import os.path
8 9 10
import platform

plat_sys = platform.system()
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

whereami = os.path.dirname(os.path.realpath(__file__))

args = sys.argv[1:]

if len(args) == 0 or "--help" in args or "-h" in args:
    print("""USAGE:
    
cc `refimpl2-config --istart --cflags --libs` -o the_output your-c-program-that-starts-mu.c

cc `refimpl2-config --cflags` -fPIC -shared -o theclient.so your-c-program-loaded-by-the-jvm.c

    --istart    Your C program will start the JVM and create the Mu instance.

    --cflags    If present, this script will print compiler flags.
    --libs      If present, this script will print linker flags.
""")

if '--istart' in args:
    if '--cflags' in args:
        print("-I {} ".format(whereami), end="")
    if '--libs' in args:
33 34 35
        if plat_sys == "Linux":
            print("-Wl,--no-as-needed ", end="")
        print("-L {} -l murefimpl2start -Wl,-rpath,{} ".format(
Kunshan Wang's avatar
Kunshan Wang committed
36
            whereami, whereami), end="")
37 38 39 40 41 42 43
else:
    if '--cflags' in args:
        print("-I {} ".format(whereami), end="")
    if '--libs' in args:
        pass