aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2017-02-07 06:31:03 +0100
committerTristan Gingold <tgingold@free.fr>2017-02-07 06:31:03 +0100
commit7873da82231e872021311ece34644c323e5e99d8 (patch)
treef3856c93f32ac710ef7b8ce00416f06d80a11529
parentdb4b46e5c5c5f98ccba37fc18a9ac48a0cba0ff5 (diff)
downloadghdl-7873da82231e872021311ece34644c323e5e99d8.tar.gz
ghdl-7873da82231e872021311ece34644c323e5e99d8.tar.bz2
ghdl-7873da82231e872021311ece34644c323e5e99d8.zip
libghdlsynth: can generate so/dll file.
-rw-r--r--Makefile.in36
-rwxr-xr-xconfigure9
-rw-r--r--src/grt/Makefile.inc49
3 files changed, 69 insertions, 25 deletions
diff --git a/Makefile.in b/Makefile.in
index b2d84f53a..06d8d86b6 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -70,7 +70,7 @@ ifeq "$(build_mode)" "coverage"
OPT_FLAGS+=-fprofile-arcs -ftest-coverage
endif
-GNATFLAGS=-gnaty3befhkmr -gnatwae -aO. -gnatf -gnat05 $(OPT_FLAGS) $(ADA_FLAGS)
+GNATFLAGS=-gnaty3befhkmr -gnatwae -gnatf -gnat05 $(OPT_FLAGS) $(ADA_FLAGS)
GRT_FLAGS=$(OPT_FLAGS)
WARN_CFLAGS=-Wall
@@ -84,6 +84,15 @@ target=$(build)
#target=x86_64-apple-darwin
#target=i386-pc-mingw32
+ifeq ($(SOEXT),.so)
+SHLIB_FLAGS=-Wl,-soname,$@
+else ifeq ($(SOEXT),.dll)
+SHLIB_FLAGS=
+else ifeq ($(SOEXT),.dylib)
+# Allow the use of -rpath in executable
+SHLIB_FLAGS=-Wl,-install_name,@rpath/$@
+endif
+
all: Makefile all.$(backend)
install: install.$(backend)
@@ -291,7 +300,7 @@ libmhdlsimvhdl.a: $(GRT_ADD_OBJS) $(GRT_SRC_DEPS) version.ads force
GHDL_SYNTHLIB_INCFLAGS=$(GHDL_COMMON_INCFLAGS) -aI$(srcdir)/src/synth -aI$(srcdir)/src/ghdldrv -aI$(srcdir)/src/vhdl/simulate -aI$(srcdir)/src/grt
-libghdlsynth.a: $(GRT_ADD_OBJS) $(GRT_SRC_DEPS) version.ads force
+libghdlsynth.a: $(GRT_ADD_OBJS) $(GRT_SRC_DEPS) version.ads force
$(GNATMAKE) -c libghdlsynth $(GNATFLAGS) -gnat12 $(GHDL_SYNTHLIB_INCFLAGS)
gnatbind -Llibghdlsynth_ libghdlsynth.ali -O > ghdlsynth.files
# Extract link options, be sure to link statically with libgnat
@@ -300,12 +309,20 @@ libghdlsynth.a: $(GRT_ADD_OBJS) $(GRT_SRC_DEPS) version.ads force
$(RM) -f $@
ar rc $@ b~libghdlsynth.o `cat ghdlsynth.files` $(GRT_ADD_OBJS)
-install.libghdlsynth: libghdlsynth.a install.dirs
- $(INSTALL_DATA) -p libghdlsynth.a $(DESTDIR)$(libdir)/
+libghdlsynth$(SOEXT): $(GRT_ADD_SHOBJS) $(GRT_SRC_DEPS) version.ads force
+ $(GNATMAKE) -I- -aI. -D pic -z libghdlsynth -o $@ $(GNATFLAGS) $(PIC_FLAGS) -gnat12 $(GHDL_SYNTHLIB_INCFLAGS) -bargs -shared -Llibghdlsynth_ -largs -shared $(GRT_ADD_SHOBJS) $(SHLIB_FLAGS)
+
+install.libghdlsynth.include: install.dirs
$(INSTALL_DATA) -p $(srcdir)/src/synth/ghdlsynth.h $(DESTDIR)$(incdir)/
$(INSTALL_DATA) -p $(srcdir)/src/synth/ghdlsynth_gates.h $(DESTDIR)$(incdir)/
+
+install.libghdlsynth.static: libghdlsynth.a install.libghdlsynth.include
+ $(INSTALL_DATA) -p libghdlsynth.a $(DESTDIR)$(libdir)/
$(INSTALL_DATA) -p ghdlsynth.link $(DESTDIR)$(libdir)/
+install.libghdlsynth.shared: libghdlsynth$(SOEXT) install.libghdlsynth.include
+ $(INSTALL_DATA) -p libghdlsynth$(SOEXT) $(DESTDIR)$(libdir)/
+
################ ghwdump #################################################
GHWDUMP_OBJS=ghwdump.o ghwlib.o
@@ -332,15 +349,8 @@ vpi_thunk.o: $(GRTSRCDIR)/vpi_thunk.c $(GRTSRCDIR)/vpi_thunk.h
# Do not use OPT_FLAGS (do not enable coverage)
$(CC) -c -o $@ $< $(PIC_FLAGS) -O $(WARN_CFLAGS)
-libghdlvpi.so: vpi_thunk.o
- $(CC) -o $@ $< -shared -Wl,-soname,libghdlvpi.so
-
-libghdlvpi.dll: vpi_thunk.o
- $(CC) -o $@ $< -shared
-
-libghdlvpi.dylib: vpi_thunk.o
-# Allow the use of -rpath in executable
- $(CC) -o $@ $< -shared -Wl,-install_name,@rpath/libghdlvpi.dylib
+libghdlvpi$(SOEXT): vpi_thunk.o
+ $(CC) -o $@ $< -shared $(SHLIB_FLAGS)
all.vpi: libghdlvpi$(SOEXT)
diff --git a/configure b/configure
index 56d95c51e..01a2cbf1e 100755
--- a/configure
+++ b/configure
@@ -204,6 +204,15 @@ else
default_pie="no"
fi
+# Create subdirectories
+if [ ! -d pic ]; then
+ echo "create pic/ subdirectory"
+ if ! mkdir pic; then
+ echo "failed to create pic/"
+ exit 1;
+ fi
+fi
+
# Generate config.status
rm -f config.status
{
diff --git a/src/grt/Makefile.inc b/src/grt/Makefile.inc
index b87cb966f..7edea4960 100644
--- a/src/grt/Makefile.inc
+++ b/src/grt/Makefile.inc
@@ -71,6 +71,7 @@ GRT_FST_OBJS := fstapi.o lz4.o fastlz.o
# Additionnal object files (C or asm files).
GRT_ADD_OBJS:=$(GRT_TARGET_OBJS) grt-cbinding.o grt-cvpi.o $(GRT_FST_OBJS)
+GRT_ADD_SHOBJS:=$(patsubst %, pic/%, $(GRT_ADD_OBJS))
# Source files create by grt.
GRT_SRC_DEPS:=grt-backtraces-impl.ads
@@ -116,41 +117,65 @@ run-bind.o: run-bind.adb
main.o: $(GRTSRCDIR)/main.adb
$(GRT_ADACOMPILE) -o $@ $<
+GRT_C_COMPILE = $(CC) -c $(GRT_FLAGS) -o $@ $<
+GRT_C_COMPILE_PIC = $(CC) -c $(GRT_FLAGS) $(PIC_FLAGS) -o $@ $<
+
jumps.o: $(GRTSRCDIR)/config/jumps.c
- $(CC) -c $(GRT_FLAGS) $(GRT_CFLAGS) -o $@ $<
+ $(GRT_C_COMPILE)
+
+pic/jumps.o: $(GRTSRCDIR)/config/jumps.c
+ $(GRT_C_COMPILE_PIC)
win32.o: $(GRTSRCDIR)/config/win32.c
- $(CC) -c $(GRT_FLAGS) -o $@ $<
+ $(GRT_C_COMPILE)
math.o: $(GRTSRCDIR)/config/math.c
- $(CC) -c $(GRT_FLAGS) -o $@ $<
+ $(GRT_C_COMPILE)
times.o : $(GRTSRCDIR)/config/times.c
- $(CC) -c $(GRT_FLAGS) -o $@ $<
+ $(GRT_C_COMPILE)
+
+pic/times.o : $(GRTSRCDIR)/config/times.c
+ $(GRT_C_COMPILE_PIC)
clock.o : $(GRTSRCDIR)/config/clock.c
- $(CC) -c $(GRT_FLAGS) -o $@ $<
+ $(GRT_C_COMPILE)
grt-cbinding.o: $(GRTSRCDIR)/grt-cbinding.c
- $(CC) -c $(GRT_FLAGS) -o $@ $<
+ $(GRT_C_COMPILE)
+
+pic/grt-cbinding.o: $(GRTSRCDIR)/grt-cbinding.c
+ $(GRT_C_COMPILE_PIC)
grt-cvpi.o: $(GRTSRCDIR)/grt-cvpi.c
- $(CC) -c $(GRT_FLAGS) -o $@ $<
+ $(GRT_C_COMPILE)
+
+pic/grt-cvpi.o: $(GRTSRCDIR)/grt-cvpi.c
+ $(GRT_C_COMPILE_PIC)
grt-cthreads.o: $(GRTSRCDIR)/grt-cthreads.c
- $(CC) -c $(GRT_FLAGS) -o $@ $<
+ $(GRT_C_COMPILE)
fstapi.o: $(GRTSRCDIR)/fst/fstapi.c
- $(CC) -c $(GRT_FLAGS) -o $@ -I$(GRTSRCDIR)/fst $<
+ $(GRT_C_COMPILE) -I$(GRTSRCDIR)/fst
+
+pic/fstapi.o: $(GRTSRCDIR)/fst/fstapi.c
+ $(GRT_C_COMPILE_PIC) -I$(GRTSRCDIR)/fst
lz4.o: $(GRTSRCDIR)/fst/lz4.c
- $(CC) -c $(GRT_FLAGS) -o $@ $<
+ $(GRT_C_COMPILE)
+
+pic/lz4.o: $(GRTSRCDIR)/fst/lz4.c
+ $(GRT_C_COMPILE_PIC)
fastlz.o: $(GRTSRCDIR)/fst/fastlz.c
- $(CC) -c $(GRT_FLAGS) -o $@ $<
+ $(GRT_C_COMPILE)
+
+pic/fastlz.o: $(GRTSRCDIR)/fst/fastlz.c
+ $(GRT_C_COMPILE_PIC)
chkstk.o: $(GRTSRCDIR)/config/chkstk.S
- $(CC) -c $(GRT_FLAGS) -o $@ $<
+ $(GRT_C_COMPILE)
grt-backtraces-impl.ads:
ifneq ($(GRT_LIBBACKTRACE),)