From 31b555ae72c37c72a27f4ffb66d38bc89420a25b Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Tue, 4 Aug 2015 13:22:49 +0200 Subject: [PATCH] Added libyosys.so build --- .gitignore | 1 + Makefile | 22 +++++++++++++++++++++- misc/example.cc | 4 ++-- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 2b6f032e4..484faf419 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ /yosys-win32-mxebin-* /yosys-win32-vcxsrc-* /yosysjs-* +/libyosys.so diff --git a/Makefile b/Makefile index efbca7194..ef8b1ed79 100644 --- a/Makefile +++ b/Makefile @@ -24,6 +24,7 @@ TARGET_BINDIR := $(DESTDIR)/bin TARGET_DATDIR := $(DESTDIR)/share/yosys EXE = +LIB = OBJS = GENFILES = EXTRA_OBJS = @@ -55,6 +56,7 @@ ifeq (Darwin,$(findstring Darwin,$(shell uname))) else LDFLAGS += -rdynamic LDLIBS += -lrt + LIB = .so endif YOSYS_VER := 0.5+$(shell test -d .git && { git log --author=clifford@clifford.at --oneline c3c9fbfb8c678.. | wc -l; }) @@ -105,6 +107,7 @@ CXXFLAGS += $(EMCCFLAGS) LDFLAGS += $(EMCCFLAGS) LDLIBS = EXE = .js +LIB = TARGETS := $(filter-out yosys-config,$(TARGETS)) EXTRA_TARGETS += yosysjs-$(YOSYS_VER).zip @@ -131,11 +134,16 @@ LDLIBS := $(filter-out -lrt,$(LDLIBS)) ABCMKARGS += ARCHFLAGS="-DSIZEOF_VOID_P=4 -DSIZEOF_LONG=4 -DSIZEOF_INT=4 -DWIN32_NO_DLL -x c++ -fpermissive -w" ABCMKARGS += LIBS="lib/x86/pthreadVC2.lib -s" READLINE=0 CC="$(CXX)" CXX="$(CXX)" EXE = .exe +LIB = else ifneq ($(CONFIG),none) $(error Invalid CONFIG setting '$(CONFIG)'. Valid values: clang, gcc, gcc-4.6, emcc, none) endif +ifneq ($(LIB),) +TARGETS += libyosys$(LIB) +endif + ifeq ($(ENABLE_READLINE),1) CXXFLAGS += -DYOSYS_ENABLE_READLINE LDLIBS += -lreadline @@ -286,7 +294,12 @@ yosys.js: $(filter-out yosysjs-$(YOSYS_VER).zip,$(EXTRA_TARGETS)) endif yosys$(EXE): $(OBJS) - $(P) $(CXX) -o yosys$(EXE) $(LDFLAGS) $(OBJS) $(LDLIBS) + $(P) $(CXX) -o yosys$(EXE) $(LDFLAGS) $^ $(LDLIBS) + +ifneq ($(LIB),) +libyosys$(LIB): $(filter-out kernel/driver.o,$(OBJS)) + $(P) $(CXX) -o libyosys$(LIB) -shared -Wl,-soname,libyosys$(LIB) $(LDFLAGS) $^ $(LDLIBS) +endif %.o: %.cc $(P) $(CXX) -o $@ -c $(CXXFLAGS) $< @@ -363,10 +376,17 @@ install: $(TARGETS) $(EXTRA_TARGETS) $(INSTALL_SUDO) install $(TARGETS) $(DESTDIR)/bin/ $(INSTALL_SUDO) mkdir -p $(DESTDIR)/share/yosys $(INSTALL_SUDO) cp -r share/. $(DESTDIR)/share/yosys/. +ifneq ($(LIB),) + $(INSTALL_SUDO) cp libyosys$(LIB) $(DESTDIR)/lib/ + $(INSTALL_SUDO) ldconfig +endif uninstall: $(INSTALL_SUDO) rm -vf $(addprefix $(DESTDIR)/bin/,$(notdir $(TARGETS))) $(INSTALL_SUDO) rm -rvf $(DESTDIR)/share/yosys/ +ifneq ($(LIB),) + $(INSTALL_SUDO) rm -vf $(DESTDIR)/lib/libyosys$(LIB) +endif update-manual: $(TARGETS) $(EXTRA_TARGETS) cd manual && ../yosys -p 'help -write-tex-command-reference-manual' diff --git a/misc/example.cc b/misc/example.cc index a8244ac4e..67d0d7be5 100644 --- a/misc/example.cc +++ b/misc/example.cc @@ -1,6 +1,6 @@ -// clang -o example -std=c++11 -I/usr/include/tcl8.5 -I include/ example.cc objs/*.o -lstdc++ -lm -lrt -lreadline -lffi -ldl -ltcl8.5 +// yosys-config --exec --cxx -o example --cxxflags --ldflags example.cc -lyosys -lstdc++ -#include +#include int main() {