Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add shared library build #12

Merged
merged 4 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
*.o
*.d
*.lo
*.la
riscv-fesvr
riscv-isa-sim-32
riscv-isa-sim-64
Expand All @@ -26,6 +28,8 @@ Makefile.in
/ylwrap
.deps/
.dirstamp
.libs
libtool

autom4te.cache
/autoscan.log
Expand Down
20 changes: 17 additions & 3 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,43 @@ TRDB_LINKER_INCLUDES = -Ilib/riscv-binutils-gdb/include -Ilib/riscv-binutils-gdb
TRDB_ALL_LINKER_FLAGS = -Llib/riscv-binutils-gdb/opcodes -Llib/riscv-binutils-gdb/bfd -Llib/riscv-binutils-gdb/libiberty -Llib/riscv-binutils-gdb/zlib
TRDB_ALL_LINKER_LIBS= -lbfd -lopcodes -liberty -lz -ldl -lc

# TRDB CLI tool
trdb_SOURCES = src/trace_debugger.c src/utils.c src/serialize.c \
src/error.c src/disassembly.c src/trdb.c

trdb_LDFLAGS = $(TRDB_ALL_LINKER_FLAGS)
trdb_LDADD = $(TRDB_ALL_LINKER_LIBS)

# Tests
tests_SOURCES = src/trace_debugger.c src/utils.c src/serialize.c \
src/error.c src/disassembly.c test/tests.c
tests_LDFLAGS = $(TRDB_ALL_LINKER_FLAGS)
tests_LDADD = $(TRDB_ALL_LINKER_LIBS)

# Benchmarks
benchmarks_SOURCES = src/trace_debugger.c src/utils.c src/serialize.c \
src/error.c src/disassembly.c benchmark/benchmarks.c
benchmarks_LDFLAGS = $(TRDB_ALL_LINKER_FLAGS)
benchmarks_LDADD = $(TRDB_ALL_LINKER_LIBS)

noinst_LIBRARIES = libtrdb.a
libtrdb_a_SOURCES = src/trace_debugger.c src/utils.c src/serialize.c \
src/error.c src/disassembly.c
# Dynamic library
lib_LTLIBRARIES = libtrdb.la
libtrdb_la_SOURCES = src/trace_debugger.c src/utils.c src/serialize.c \
src/error.c src/disassembly.c dpi/trdb_sv.c
libtrdb_la_LDFLAGS = $(TRDB_ALL_LINKER_FLAGS)
libtrdb_la_LIBADD = $(TRDB_ALL_LINKER_LIBS)

include_HEADERS = include/disassembly.h include/serialize.h include/trace_debugger.h

AM_CFLAGS = -std=gnu11 -Wall -Wextra -Wno-missing-field-initializers -Wno-unused-function -Wno-missing-braces -fdiagnostics-color
AM_CPPFLAGS = -D_GNU_SOURCE -I. -Iinclude -Iinternal $(TRDB_LINKER_INCLUDES)

# workaround for shared source files
# https://www.gnu.org/software/automake/manual/html_node/Objects-created-both-with-libtool-and-without.html
trdb_CFLAGS = $(AM_CFLAGS)
tests_CFLAGS = $(AM_CFLAGS)
benchmarks_CFLAGS = $(AM_CFLAGS)

doxygen-doc: doxyfile
doxygen doxyfile

Expand Down
5 changes: 3 additions & 2 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
+ decompress trace packets
+ disassemble traces
+ model a trace encoding source (processor interface to trace packets)
+ used as part of a RTL testbench through DPI

The =trdb= command line tool is used to provide a command line interface to
=libtrdb= functionalities.
Expand Down Expand Up @@ -40,8 +41,8 @@

instead of =./configure=.

=libtrdb.a= is a library for using the C-model, the decompression and
disassembly functionality.
=libtrdb.so= is a library for providing the C-model, decompression,
disassembly functionality and a simple interface using the SystemVerilog DPI.

Run

Expand Down
9 changes: 5 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ AM_INIT_AUTOMAKE([-Wall foreign subdir-objects])
AC_PROG_CC
AC_PROG_RANLIB
AM_PROG_AR
LT_INIT
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([
Makefile
])
AX_SUBDIRS_CONFIGURE([lib/riscv-binutils-gdb/bfd], [--enable-targets=riscv32])
AX_SUBDIRS_CONFIGURE([lib/riscv-binutils-gdb/opcodes], [--enable-targets=riscv32])
AX_SUBDIRS_CONFIGURE([lib/riscv-binutils-gdb/libiberty])
AX_SUBDIRS_CONFIGURE([lib/riscv-binutils-gdb/zlib])
AX_SUBDIRS_CONFIGURE([lib/riscv-binutils-gdb/bfd], [--enable-targets=riscv32, --with-pic])
AX_SUBDIRS_CONFIGURE([lib/riscv-binutils-gdb/opcodes], [--enable-targets=riscv32, --with-pic])
AX_SUBDIRS_CONFIGURE([lib/riscv-binutils-gdb/libiberty], [], [[CFLAGS=-O2 -g -fpic]])
AX_SUBDIRS_CONFIGURE([lib/riscv-binutils-gdb/zlib], [], [[CFLAGS=-O2 -g -fpic]])
AC_OUTPUT
Loading
Loading