mirror of https://github.com/YosysHQ/yosys.git
- Makefile, kernel/posix_compatibility.h/.cc: provide POSIX.2008 fake implementation of open_memstream()/fmemopen() for pre-POSIX.2008 systems.
- Makefile: OSX build rules (Apple's gcc and clang have no -rdynamic option and no librt). - Makefile: Generate debugger symbols and don't optimize for size in debug target (otherwise the debugger pretty hard to use). - Makefile: Reorder target concatenation in order to avoid use-before-built problems for source-include and linker dependencies. - Makefile: On OSX/macports, qmake-qt4 is named 'qmake' (the default Qt4 installation name, unless the distribution changes it). - Makefile: For OSX/Macports, we need to pass -I/opt/local/include and -L/opt/local/lib to give GNU libraries precedence over Apple's. - Makefile: Build a local minisat copy just like abc (to avoid dependency on broken/unmaintained distribution header files). - .gitignore: Ignore minisat directory.
This commit is contained in:
parent
9327d434d5
commit
0fb044a58f
|
@ -9,6 +9,7 @@
|
|||
/qtcreator.creator
|
||||
/qtcreator.creator.user
|
||||
/Makefile.conf
|
||||
/minisat
|
||||
/abc
|
||||
/yosys
|
||||
/yosys-abc
|
||||
|
|
46
Makefile
46
Makefile
|
@ -19,14 +19,24 @@ INSTALL_SUDO :=
|
|||
OBJS =
|
||||
GENFILES =
|
||||
EXTRA_TARGETS =
|
||||
TARGETS = yosys yosys-config
|
||||
TARGETS =
|
||||
|
||||
all: top-all
|
||||
|
||||
CXXFLAGS = -Wall -Wextra -ggdb -I"$(shell pwd)" -MD -D_YOSYS_ -fPIC
|
||||
LDFLAGS = -rdynamic
|
||||
LDLIBS = -lstdc++ -lreadline -lm -ldl -lrt
|
||||
QMAKE = qmake-qt4
|
||||
CXXFLAGS = -Wall -Wextra -ggdb -I"$(shell pwd)" -I${DESTDIR}/include -MD -D_YOSYS_ -fPIC -include kernel/posix_compatibility.h
|
||||
LDFLAGS = -I${DESTDIR}/lib
|
||||
LDLIBS = -lstdc++ -lreadline -lm -ldl
|
||||
|
||||
ifeq (Darwin,$(findstring Darwin,$(shell uname)))
|
||||
# add macports include and library path to search directories, don't use '-rdynamic' and '-lrt':
|
||||
CXXFLAGS += -I/opt/local/include
|
||||
LDFLAGS += -L/opt/local/lib
|
||||
QMAKE = qmake
|
||||
else
|
||||
LDFLAGS += -rdynamic
|
||||
LDLIBS += -lrt
|
||||
QMAKE = qmake-qt4
|
||||
endif
|
||||
|
||||
YOSYS_VER := 0.2.0+
|
||||
GIT_REV := $(shell git rev-parse --short HEAD || echo UNKOWN)
|
||||
|
@ -41,16 +51,18 @@ OBJS = kernel/version_$(GIT_REV).o
|
|||
ABCREV = 2058c8ccea68
|
||||
ABCPULL = 1
|
||||
|
||||
MINISATREV = HEAD
|
||||
|
||||
-include Makefile.conf
|
||||
|
||||
ifeq ($(CONFIG),clang-debug)
|
||||
CXX = clang
|
||||
CXXFLAGS += -std=c++11 -Os
|
||||
CXXFLAGS += -std=c++11 -g -O0 -Wall
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG),gcc-debug)
|
||||
CXX = gcc
|
||||
CXXFLAGS += -std=gnu++0x -Os
|
||||
CXXFLAGS += -std=gnu++0x -g -O0 -Wall
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG),release)
|
||||
|
@ -70,8 +82,8 @@ CXXFLAGS += -pg -fno-inline
|
|||
LDFLAGS += -pg
|
||||
endif
|
||||
|
||||
ifeq ($(ENABLE_QT4),1)
|
||||
TARGETS += yosys-svgviewer
|
||||
ifeq ($(ENABLE_MINISAT),1)
|
||||
TARGETS += yosys-minisat
|
||||
endif
|
||||
|
||||
ifeq ($(ENABLE_ABC),1)
|
||||
|
@ -85,7 +97,14 @@ CXXFLAGS += $(patsubst %,-I$(VERIFIC_DIR)/%,$(VERIFIC_COMPONENTS)) -D'VERIFIC_DI
|
|||
LDLIBS += $(patsubst %,$(VERIFIC_DIR)/%/*-linux.a,$(VERIFIC_COMPONENTS))
|
||||
endif
|
||||
|
||||
OBJS += kernel/driver.o kernel/register.o kernel/rtlil.o kernel/log.o kernel/calc.o
|
||||
# Build yosys after minisat and abc (we need to access the local copies of the downloaded/installed header files).
|
||||
TARGETS += yosys yosys-config
|
||||
|
||||
ifeq ($(ENABLE_QT4),1)
|
||||
TARGETS += yosys-svgviewer
|
||||
endif
|
||||
|
||||
OBJS += kernel/driver.o kernel/register.o kernel/rtlil.o kernel/log.o kernel/calc.o kernel/posix_compatibility.o
|
||||
|
||||
OBJS += libs/bigint/BigIntegerAlgorithms.o libs/bigint/BigInteger.o libs/bigint/BigIntegerUtils.o
|
||||
OBJS += libs/bigint/BigUnsigned.o libs/bigint/BigUnsignedInABase.o
|
||||
|
@ -123,6 +142,13 @@ yosys-svgviewer: libs/svgviewer/*.h libs/svgviewer/*.cpp
|
|||
cd libs/svgviewer && $(QMAKE) && make
|
||||
cp libs/svgviewer/svgviewer yosys-svgviewer
|
||||
|
||||
yosys-minisat: $(DESTDIR)/bin/minisat
|
||||
$(DESTDIR)/bin/minisat:
|
||||
test -d minisat || ( git clone https://github.com/niklasso/minisat.git minisat && sed -i -e 's/PRIi64/ & /' minisat/minisat/utils/Options.h )
|
||||
( cd minisat && git checkout $(MINISATREV) )
|
||||
( cd minisat && $(MAKE) prefix=$(DESTDIR) DESTDIR="" config install )
|
||||
@( cd minisat && echo "Installed minisat version `git describe --always --dirty` into $(DESTDIR)." )
|
||||
|
||||
abc/abc-$(ABCREV):
|
||||
ifneq ($(ABCREV),default)
|
||||
if ( cd abc && hg identify; ) | grep -q +; then \
|
||||
|
|
|
@ -0,0 +1,134 @@
|
|||
/*
|
||||
* yosys -- Yosys Open SYnthesis Suite
|
||||
*
|
||||
* Copyright (C) 2012 Clifford Wolf <clifford@clifford.at>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* POSIX.2008 fake implementation for pre-POSIX.2008 systems. (OSX, BSD, MINGW, CYGWIN, older Linux &c.)
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if !(_XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L)
|
||||
typedef struct memstream {
|
||||
off_t pos;
|
||||
off_t size;
|
||||
char * buffer;
|
||||
char ** bufp;
|
||||
size_t * sizep;
|
||||
bool realloc;
|
||||
} memstream_t;
|
||||
|
||||
static int memstream_read (void * cookie, char * buf, int size)
|
||||
{
|
||||
memstream_t * mem = (memstream_t *) cookie;
|
||||
off_t available = mem->size - mem->pos;
|
||||
if (available < 0)
|
||||
available = 0;
|
||||
if (size > available)
|
||||
size = available;
|
||||
memcpy(buf, mem->buffer + mem->pos, size);
|
||||
mem->pos += size;
|
||||
return size;
|
||||
}
|
||||
|
||||
static int memstream_write (void * cookie, const char * buf, int size)
|
||||
{
|
||||
memstream_t * mem = (memstream_t *) cookie;
|
||||
off_t available = mem->size - mem->pos;
|
||||
if (size > available) {
|
||||
if (mem->realloc) {
|
||||
mem->buffer = (char *) realloc(mem->buffer, mem->pos + size + 1);
|
||||
memset(mem->buffer + mem->size, 0, mem->pos + size + 1 - mem->size);
|
||||
mem->size = mem->pos + size;
|
||||
if (mem->bufp)
|
||||
*(mem->bufp) = mem->buffer;
|
||||
if (mem->sizep)
|
||||
*(mem->sizep) = mem->size;
|
||||
} else {
|
||||
size = available;
|
||||
}
|
||||
}
|
||||
memcpy(mem->buffer + mem->pos, buf, sizeof(char) * size);
|
||||
mem->pos += size;
|
||||
return size;
|
||||
}
|
||||
|
||||
static fpos_t memstream_seek (void * cookie, fpos_t offset, int whence)
|
||||
{
|
||||
memstream_t * mem = (memstream_t *) cookie;
|
||||
switch (whence) {
|
||||
case SEEK_SET:
|
||||
if (offset < 0)
|
||||
goto error_inval;
|
||||
mem->pos = offset;
|
||||
return 0;
|
||||
case SEEK_CUR:
|
||||
if (mem->pos + offset < 0)
|
||||
goto error_inval;
|
||||
mem->pos += offset;
|
||||
return 0;
|
||||
case SEEK_END:
|
||||
if (mem->size + offset < 0)
|
||||
goto error_inval;
|
||||
mem->pos = mem->size + offset;
|
||||
break;
|
||||
default:
|
||||
goto error_inval;
|
||||
}
|
||||
return mem->pos;
|
||||
error_inval:
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int memstream_close (void * cookie)
|
||||
{
|
||||
memstream_t * mem = (memstream_t *) cookie;
|
||||
if (mem->bufp)
|
||||
*(mem->bufp) = mem->buffer;
|
||||
if (mem->sizep)
|
||||
*(mem->sizep) = mem->size;
|
||||
free(cookie);
|
||||
return 0;
|
||||
}
|
||||
|
||||
FILE * fmemopen (void * buf, size_t size, const char * mode)
|
||||
{
|
||||
memstream_t * mem = (memstream_t *) malloc(sizeof(memstream_t));
|
||||
memset(mem, 0, sizeof(memstream_t));
|
||||
mem->size = size;
|
||||
mem->buffer = (char *) buf;
|
||||
(void) mode;
|
||||
return funopen(mem, memstream_read, memstream_write, memstream_seek, memstream_close);
|
||||
}
|
||||
|
||||
FILE * open_memstream (char ** bufp, size_t * sizep)
|
||||
{
|
||||
memstream_t * mem = (memstream_t *) malloc(sizeof(memstream_t));
|
||||
memset(mem, 0, sizeof(memstream_t));
|
||||
mem->bufp = bufp;
|
||||
mem->sizep = sizep;
|
||||
mem->realloc = true;
|
||||
return funopen(mem, memstream_read, memstream_write, memstream_seek, memstream_close);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* yosys -- Yosys Open SYnthesis Suite
|
||||
*
|
||||
* Copyright (C) 2012 Clifford Wolf <clifford@clifford.at>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef POSIX_COMPATIBILITY_H
|
||||
#define POSIX_COMPATIBILITY_H
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if !(_XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L)
|
||||
FILE * open_memstream (char ** bufp, size_t * sizep);
|
||||
FILE * fmemopen (void * buf, size_t size, const char * mode);
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue