aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2018-03-07 05:10:02 +0100
committerTristan Gingold <tgingold@free.fr>2018-03-07 05:10:02 +0100
commitf94f726d515bcf48c50752a3487441fad629ee13 (patch)
tree8f8ddfcdc4f1aa5e825a51a26d6b63bbfcd3f2fb
parent0e9e1f63cdf19dc45804d7b8728698f879489ee9 (diff)
downloadghdl-f94f726d515bcf48c50752a3487441fad629ee13.tar.gz
ghdl-f94f726d515bcf48c50752a3487441fad629ee13.tar.bz2
ghdl-f94f726d515bcf48c50752a3487441fad629ee13.zip
configure: add --enable-python
-rw-r--r--Makefile.in6
-rwxr-xr-xconfigure18
-rw-r--r--setup.py67
-rw-r--r--setup.py.in43
4 files changed, 61 insertions, 73 deletions
diff --git a/Makefile.in b/Makefile.in
index f46115721..550998656 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -38,6 +38,7 @@ build_mode=@build_mode@
enable_werror=@enable_werror@
enable_checks=@enable_checks@
enable_openieee=@enable_openieee@
+enable_python=@enable_python@
INSTALL_PROGRAM=install -m 755
INSTALL_DATA=install -m 644
@@ -114,7 +115,7 @@ LIBVHDL_FLAGS_TO_PASS=\
enable_openieee="$(enable_openieee)" \
LN="$(LN)" CP="$(CP)" MKDIR="$(MKDIR)"
-all: Makefile all.$(backend)
+all: Makefile all.$(backend) all.libghdl.$(enable_python)
install: install.$(backend)
@@ -339,6 +340,9 @@ LIBGHDL_INCFLAGS=$(GHDL_COMMON_INCFLAGS) -aI$(srcdir)/src/vhdl/python -aI$(srcdi
libghdl$(SOEXT): $(GRT_SRC_DEPS) version.ads force
$(GNATMAKE) -I- -aI. -D pic -z libghdl -o $@ $(GNATFLAGS) $(PIC_FLAGS) -gnat05 $(LIBGHDL_INCFLAGS) -bargs -shared -Llibghdl_ -largs -shared $(SHLIB_FLAGS)
+all.libghdl.true: libghdl$(SOEXT)
+all.libghdl.false:
+
################ ghdlsynth library ######################################
GHDL_SYNTHLIB_INCFLAGS=$(GHDL_COMMON_INCFLAGS) -aI$(srcdir)/src/synth -aI$(srcdir)/src/ghdldrv -aI$(srcdir)/src/vhdl/simulate
diff --git a/configure b/configure
index e76c5c82e..fc9818201 100755
--- a/configure
+++ b/configure
@@ -22,6 +22,7 @@ build_mode=
enable_werror=true
enable_checks=true
enable_openieee=unknown
+enable_python=false
EXEEXT=
SOEXT=.so
PIC_FLAGS=-fPIC
@@ -29,7 +30,7 @@ PIC_FLAGS=-fPIC
show_help=no
progname=$0
-subst_vars="CC CXX GNATMAKE MAKE CFLAGS LDFLAGS build srcdir abs_srcdir prefix backend libdirsuffix libdirreverse gcc_src_dir llvm_config llvm_be backtrace_lib build_mode EXEEXT SOEXT PIC_FLAGS default_pie enable_werror enable_checks enable_openieee"
+subst_vars="CC CXX GNATMAKE MAKE CFLAGS LDFLAGS build srcdir abs_srcdir prefix backend libdirsuffix libdirreverse gcc_src_dir llvm_config llvm_be backtrace_lib build_mode EXEEXT SOEXT PIC_FLAGS default_pie enable_werror enable_checks enable_openieee enable_python"
# Find srcdir
srcdir=`dirname $progname`
@@ -80,6 +81,8 @@ for opt do
--disable-checks) enable_checks=false;;
--enable-openieee) enable_openieee=true;;
--disable-openieee) enable_openieee=false;;
+ --enable-python) enable_python=true;;
+ --disable-python) enable_python=false;;
--enable-coverage) build_mode="coverage";;
-h|-help|--help) show_help=yes;;
*) echo "$0: unknown option $opt; try $0 --help"
@@ -103,6 +106,7 @@ Options [defaults in brackets]:
--disable-werror warnings don't stop build
--disable-checks disable internal checks
--enable-openieee use gpl-compatible sources for ieee library
+ --enable-python build python libghdl
EOF
exit 0
fi
@@ -283,10 +287,14 @@ for v in $subst_vars; do
echo $v=\"$vval\"
done
sed_opts=`echo $subst_vars | sed -e "s/\\([a-zA-Z_]*\\)/ -e \"s%@\1@%\$\1%g\"/g"`
-echo 'echo "Creating ghdl.gpr"'
-echo sed $sed_opts '< $srcdir/ghdl.gpr.in > ghdl.gpr'
-echo 'echo "Creating Makefile"'
-echo sed $sed_opts '< $srcdir/Makefile.in > Makefile'
+subst_files="ghdl.gpr Makefile"
+if [ "$enable_python" = true ]; then
+ subst_files="$subst_files setup.py"
+fi
+echo "for f in $subst_files; do"
+echo ' echo "Creating $f"'
+echo " sed $sed_opts" '< $srcdir/${f}.in > $f'
+echo "done"
} > config.status || \
{
echo "$progname: cannot create config.status"
diff --git a/setup.py b/setup.py
deleted file mode 100644
index 65d130ea5..000000000
--- a/setup.py
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/usr/bin/env python
-
-from distutils.core import setup, Extension
-from distutils.command.build import build
-from distutils.errors import CompileError
-import distutils.dep_util
-import distutils.ccompiler
-import subprocess
-import os
-import os.path
-
-class GHDLBuild(build):
- def copy_if_changed(self, source, destname):
- dest = os.path.join(self.build_temp, destname)
- if distutils.dep_util.newer(source, dest):
- print('copying ' + source)
- self.copy_file(source, dest, preserve_times=0)
-
- def run(self):
- # Run original build code
- build.run(self)
-
- self.mkpath(self.build_temp)
-
- srcdir = os.path.dirname(os.path.abspath(__file__))
- relpath = os.path.relpath(srcdir, self.build_temp)
- self.copy_if_changed(os.path.join(srcdir, 'src', 'version.in'),
- 'version.ads')
- self.copy_if_changed(os.path.join(srcdir, 'src', 'ghdldrv',
- 'default_paths.ads.in'),
- 'default_paths.ads')
-
- comp = distutils.ccompiler.new_compiler()
- so_file = comp.shared_object_filename('libghdl')
-
- cmd = ['gnatmake',
- '-aI' + os.path.join(srcdir, 'src', 'vhdl', 'python'),
- '-aI' + os.path.join(srcdir, 'src', 'vhdl'),
- '-aI' + os.path.join(srcdir, 'src', 'psl'),
- '-aI' + os.path.join(srcdir, 'src'),
- '-aI' + os.path.join(srcdir, 'src', 'ghdldrv'),
- '-aI' + os.path.join(srcdir, 'src', 'grt'),
- '-z', 'libghdl',
- '-o', so_file, '-fPIC', '-gnat05', '-gnata', '-g',
- '-bargs', '-shared', '-Llibghdl_',
- '-largs', '-shared', '-v' ]
-
- def compile():
- print cmd
- if subprocess.call(cmd, cwd=self.build_temp) != 0:
- raise CompileError('compilation failure')
-
- self.execute(compile, [], 'Compiling ghdl')
- dstdir = os.path.join(self.build_lib, 'libghdl')
- self.copy_file(os.path.join(self.build_temp, so_file), dstdir)
- self.copy_tree(os.path.join(srcdir, "lib",), dstdir)
-
-setup (name='libghdl',
- version='1.0',
- description = 'Interface to ghdl, a VHDL analyzer',
- author = 'Tristan Gingold',
- author_email = 'tgingold@free.fr',
- url = 'github.com/tgingold/ghdl',
- package_dir = {'libghdl' : 'src/vhdl/python/libghdl'},
- packages = ['libghdl'],
- cmdclass = {
- 'build': GHDLBuild})
diff --git a/setup.py.in b/setup.py.in
new file mode 100644
index 000000000..57f997084
--- /dev/null
+++ b/setup.py.in
@@ -0,0 +1,43 @@
+#!/usr/bin/env python
+
+from distutils.core import setup, Extension
+import distutils.file_util
+import distutils.dir_util
+from distutils.command.build import build
+import os
+import os.path
+
+class GHDLBuild(build):
+ def my_copy_tree(self, src, dst):
+ """Tuned version of copy_tree: exclude .o files"""
+ distutils.dir_util.mkpath(dst, verbose=True)
+
+ for n in os.listdir(src):
+ src_name = os.path.join(src, n)
+ dst_name = os.path.join(dst, n)
+
+ if os.path.isdir(src_name):
+ self.my_copy_tree(src_name, dst_name)
+ elif not src_name.endswith(".o"):
+ distutils.file_util.copy_file(src_name, dst_name)
+
+ def run(self):
+ # Run original build code
+ build.run(self)
+
+ # Copy VHDL libraries & shared library
+ dstdir = os.path.join(self.build_lib, 'libghdl')
+ distutils.file_util.copy_file("libghdl" + "@SOEXT@", dstdir)
+ self.my_copy_tree(os.path.join("lib", "ghdl"),
+ os.path.join(dstdir, "ghdl"))
+
+setup (name='libghdl',
+ version='0.35',
+ description = 'Interface to ghdl, a VHDL analyzer',
+ author = 'Tristan Gingold',
+ author_email = 'tgingold@free.fr',
+ url = 'github.com/ghdl/ghdl',
+ package_dir = {'libghdl' : 'src/vhdl/python/libghdl'},
+ packages = ['libghdl'],
+ cmdclass = {
+ 'build': GHDLBuild})