diff --git a/Dockerfile b/Dockerfile index 0bf25de0..eb620e8b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -86,10 +86,9 @@ FROM c-builder as libcmt-debian-packager ARG CMT_BASE=${BUILD_BASE}/tools/sys-utils/libcmt ARG TOOLS_LIBCMT=libcmt.deb USER root -RUN make -C ${CMT_BASE} debian-package \ - TARGET_DESTDIR=${BUILD_BASE}/_install \ - TARGET_PREFIX=/usr/riscv64-linux-gnu \ - LIBCMT_DEB_FILENAME=${BUILD_BASE}/${TOOLS_LIBCMT} +RUN make -C ${CMT_BASE} TARGET_DESTDIR=${BUILD_BASE}/install/run install-run libcmt.deb && \ + make -C ${CMT_BASE} TARGET_DESTDIR=${BUILD_BASE}/install/dev install-run install libcmt-dev.deb && \ + make -C ${CMT_BASE} TARGET_DESTDIR=${BUILD_BASE}/install/cross install-run install libcmt-dev-riscv64-cross.deb # build rust tools # ------------------------------------------------------------------------------ diff --git a/sys-utils/libcmt/Makefile b/sys-utils/libcmt/Makefile index b45a9c95..1fc743b0 100644 --- a/sys-utils/libcmt/Makefile +++ b/sys-utils/libcmt/Makefile @@ -13,16 +13,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - -LIBCMT_VERSION ?=0.0.0 - -INSTALL_FILE= install -m0644 -INSTALL_EXEC= install -m0755 - -# paths -PREFIX = /usr -TARGET_PREFIX ?= $(PREFIX) - TOOLCHAIN_PREFIX ?= riscv64-linux-gnu- TARGET_CC := $(TOOLCHAIN_PREFIX)gcc TARGET_AR := $(TOOLCHAIN_PREFIX)ar @@ -65,7 +55,7 @@ libcmt_SRC := \ src/util.c \ src/io.c -libcmt_OBJDIR := build/lib +libcmt_OBJDIR := build/riscv64 libcmt_OBJ := $(patsubst %.c,$(libcmt_OBJDIR)/%.o,$(libcmt_SRC)) libcmt_LIB := $(libcmt_OBJDIR)/libcmt.a libcmt_SO := $(libcmt_OBJDIR)/libcmt.so @@ -81,19 +71,60 @@ $(libcmt_SO): $(libcmt_OBJ) $(TARGET_CC) -shared -o $@ $^ libcmt: $(libcmt_LIB) $(libcmt_SO) +install-run: $(libcmt_SO) + mkdir -p $(DESTDIR)$(TARGET_PREFIX)/lib + cp -f $(libcmt_SO) $(TARGET_DESTDIR)$(TARGET_PREFIX)/lib + install: $(libcmt_LIB) $(libcmt_SO) build/ffi.h mkdir -p $(TARGET_DESTDIR)$(TARGET_PREFIX)/lib - cp -f $(libcmt_LIB) $(libcmt_SO) $(TARGET_DESTDIR)$(TARGET_PREFIX)/lib + cp -f $(libcmt_LIB) $(TARGET_DESTDIR)$(TARGET_PREFIX)/lib mkdir -p $(TARGET_DESTDIR)$(TARGET_PREFIX)/include/libcmt/ cp -f include/libcmt/*.h $(TARGET_DESTDIR)$(TARGET_PREFIX)/include/libcmt/ cp -f build/ffi.h $(TARGET_DESTDIR)$(TARGET_PREFIX)/include/libcmt/ mkdir -p $(TARGET_DESTDIR)$(TARGET_PREFIX)/lib/pkgconfig - sed -e 's|@ARG_PREFIX@|$(TARGET_PREFIX)|g' src/libcmt.pc > $(TARGET_DESTDIR)$(TARGET_PREFIX)/lib/pkgconfig/libcmt.pc - -debian-package: install - mkdir -p $(TARGET_DESTDIR)/DEBIAN - sed 's|ARG_VERSION|$(LIBCMT_VERSION)|g;' tools/template/cross-control.template > $(TARGET_DESTDIR)/DEBIAN/control - dpkg-deb -Zxz --root-owner-group --build $(TARGET_DESTDIR) $(LIBCMT_DEB_FILENAME) + sed -e 's|@PREFIX@|$(TARGET_PREFIX)|g' \ + tools/libcmt.pc.in > $(TARGET_DESTDIR)$(TARGET_PREFIX)/lib/pkgconfig/libcmt.pc + +# requires either install-run or install +debian-package: + dpkg-deb -Zxz --root-owner-group --build $(TARGET_DESTDIR) $(DEB_FILENAME) + +$(DESTDIR)/DEBIAN/control: tools/control.in + mkdir -p $(@D) + sed -e 's|@PACKAGE@|$(ARG_PACKAGE)|' \ + -e 's|@VERSION@|$(ARG_VERSION)|' \ + -e 's|@ARCHITECTURE@|$(ARG_ARCHITECTURE)|' \ + -e 's|@PROVIDES@|$(ARG_PROVIDES)|' \ + -e 's|@DESCRIPTION@|$(ARG_DESCRIPTION)|' \ + $< > $@ + +# debian package variants +libcmt.deb: + $(MAKE) $(DESTDIR)/DEBIAN/control \ + ARG_PACKAGE=libcmt \ + ARG_VERSION=0.0.1 \ + ARG_ARCHITECTURE=riscv64 \ + ARG_PROVIDES=libcmt \ + ARG_DESCRIPTION="Libcmt runtime" + $(MAKE) TARGET_PREFIX=/usr debian-package DEB_FILENAME=$@ + +libcmt-dev.deb: + $(MAKE) $(DESTDIR)/DEBIAN/control \ + ARG_PACKAGE=libcmt-dev \ + ARG_VERSION=0.0.1 \ + ARG_ARCHITECTURE=any \ + ARG_PROVIDES=libcmt-dev \ + ARG_DESCRIPTION="Libcmt native libraries and header files" + $(MAKE) TARGET_PREFIX=/usr debian-package DEB_FILENAME=$@ + +libcmt-dev-riscv64-cross.deb: + $(MAKE) $(DESTDIR)/DEBIAN/control \ + ARG_PACKAGE=libcmt \ + ARG_VERSION=0.0.1 \ + ARG_ARCHITECTURE=riscv64 \ + ARG_PROVIDES=libcmt \ + ARG_DESCRIPTION="Libcmt cross libraries and header files" + $(MAKE) TARGET_PREFIX=/usr/riscv64-linux-gnu debian-package DEB_FILENAME=$@ #------------------------------------------------------------------------------- mock_SRC := \ diff --git a/sys-utils/libcmt/src/libcmt_mock.pc b/sys-utils/libcmt/src/libcmt_mock.pc deleted file mode 100644 index c1b4a7bc..00000000 --- a/sys-utils/libcmt/src/libcmt_mock.pc +++ /dev/null @@ -1,10 +0,0 @@ -prefix=@ARG_PREFIX@ -exec_prefix=${prefix} -includedir=${prefix}/include -libdir=${exec_prefix}/lib - -Name: libcmt -Description: The Cartesi Machine Tools library -Version: 0.0.1 -Cflags: -I${includedir} -Libs: -L${libdir} -lcmt diff --git a/sys-utils/libcmt/tools/control.in b/sys-utils/libcmt/tools/control.in new file mode 100644 index 00000000..9168b837 --- /dev/null +++ b/sys-utils/libcmt/tools/control.in @@ -0,0 +1,8 @@ +Package: @PACKAGE@ +Version: @VERSION@ +Architecture: @ARCHITECTURE@ +Priority: optional +Section: libs +Maintainer: Machine Reference Unit +Provides: @PROVIDES@ +Description: @DESCRIPTION@ diff --git a/sys-utils/libcmt/src/libcmt.pc b/sys-utils/libcmt/tools/libcmt.pc.in similarity index 90% rename from sys-utils/libcmt/src/libcmt.pc rename to sys-utils/libcmt/tools/libcmt.pc.in index c1b4a7bc..a5fcbfb4 100644 --- a/sys-utils/libcmt/src/libcmt.pc +++ b/sys-utils/libcmt/tools/libcmt.pc.in @@ -1,4 +1,4 @@ -prefix=@ARG_PREFIX@ +prefix=@PREFIX@ exec_prefix=${prefix} includedir=${prefix}/include libdir=${exec_prefix}/lib diff --git a/sys-utils/libcmt/tools/template/cross-control.template b/sys-utils/libcmt/tools/template/cross-control.template deleted file mode 100644 index 25193a4f..00000000 --- a/sys-utils/libcmt/tools/template/cross-control.template +++ /dev/null @@ -1,8 +0,0 @@ -Package: libcmt-dev-riscv64-cross -Version: ARG_VERSION -Architecture: all -Priority: optional -Section: devel -Maintainer: Machine Reference Unit -Provides: libcmt-dev-riscv64-cross -Description: Libcmt Library and Headers