Skip to content

Commit

Permalink
feat!: Add run and dev libcmt packages
Browse files Browse the repository at this point in the history
  • Loading branch information
mpolitzer committed Jun 5, 2024
1 parent cd65bce commit 65605aa
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 41 deletions.
7 changes: 3 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
# ------------------------------------------------------------------------------
Expand Down
67 changes: 49 additions & 18 deletions sys-utils/libcmt/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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 := \
Expand Down
10 changes: 0 additions & 10 deletions sys-utils/libcmt/src/libcmt_mock.pc

This file was deleted.

8 changes: 8 additions & 0 deletions sys-utils/libcmt/tools/control.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Package: @PACKAGE@
Version: @VERSION@
Architecture: @ARCHITECTURE@
Priority: optional
Section: libs
Maintainer: Machine Reference Unit <https://discord.com/channels/600597137524391947/1107965671976992878>
Provides: @PROVIDES@
Description: @DESCRIPTION@
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
prefix=@ARG_PREFIX@
prefix=@PREFIX@
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${exec_prefix}/lib
Expand Down
8 changes: 0 additions & 8 deletions sys-utils/libcmt/tools/template/cross-control.template

This file was deleted.

0 comments on commit 65605aa

Please sign in to comment.