Skip to content
Closed
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: 3 additions & 1 deletion .github/workflows/Dockerfile_builder
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ FROM ubuntu:22.04
SHELL ["/bin/bash", "-c"]
USER root:root
# Install build tools
RUN apt-get update && apt-get install -y make clang libx11-dev gcc
RUN apt-get update \
&& apt-get install -y build-essential gcc pkgconf make clang cmake \
&& apt-get install -y libx11-dev libbsd-dev libpcap-dev
USER root
WORKDIR /root
ENTRYPOINT /bin/bash
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
matrix:
os: [macos-11, macos-12, ubuntu-22.04, ubuntu-20.04]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v6
- name: Install X11 dependencies on MacOS
if: ${{ runner.os == 'macOS'}}
run: brew install --cask xquartz
Expand All @@ -28,7 +28,7 @@ jobs:
# runs-on: [self-hosted, linux, ARM]
# if: ${{ github.repository == 'Interlisp/maiko' }}
# steps:
# - uses: actions/checkout@v3
# - uses: actions/checkout@v6
# - name: Build
# working-directory: bin
# run: ./makeright x
Expand All @@ -41,7 +41,7 @@ jobs:
env:
BUILD_TYPE: Release
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v6
- name: Show CMake version
run: cmake --version
- name: Install X11 dependencies on MacOS
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/buildBuilderImage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
steps:
# Checkout maiko
- name: Checkout maiko
uses: actions/checkout@v3
uses: actions/checkout@v6

# Setup docker environment variables
- name: Setup Docker Environment Variables
Expand All @@ -49,18 +49,18 @@ jobs:

# Setup the Docker Machine Emulation environment.
- name: Set up QEMU
uses: docker/setup-qemu-action@master
uses: docker/setup-qemu-action@v4
with:
platforms: linux/amd64,linux/arm64,linux/arm/v7

# Setup the Docker Buildx funtion
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master
uses: docker/setup-buildx-action@v4

# Login to ghcr.io
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
Expand All @@ -71,7 +71,7 @@ jobs:
#
- name: Build Docker Images for Push to GHCR
if: ${{ true }}
uses: docker/build-push-action@v4
uses: docker/build-push-action@v7
with:
builder: ${{ steps.buildx.outputs.name }}
build-args: |
Expand Down
34 changes: 17 additions & 17 deletions .github/workflows/buildRelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ jobs:
steps:
# Checkout the actions for this repo owner
- name: Checkout Actions
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
repository: ${{ github.repository_owner }}/.github
path: ./Actions_${{ github.sha }}
Expand Down Expand Up @@ -157,15 +157,15 @@ jobs:
steps:
# Checkout the actions for this repo owner
- name: Checkout Actions
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
repository: ${{ github.repository_owner }}/.github
path: ./Actions_${{ github.sha }}
- run: mv ./Actions_${{ github.sha }}/actions ../actions && rm -rf ./Actions_${{ github.sha }}

# Checkout the branch
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6

# Setup release tag
- name: Setup Release Tag
Expand All @@ -185,14 +185,14 @@ jobs:

# Setup the Docker Machine Emulation environment.
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v4
with:
platforms: linux/amd64,linux/arm64,linux/arm/v7

# Setup the Docker Buildx funtion
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v4

# Do the Docker Build using the Dockerfile in the repository we
# checked out. Save the results in a directory under /tmp to be used
Expand All @@ -204,7 +204,7 @@ jobs:
# Dockerfile, NOT HERE IN THE WORKFLOW.
#
- name: Build Docker Image and Save It Locally
uses: docker/build-push-action@v4
uses: docker/build-push-action@v7
with:
builder: ${{ steps.buildx.outputs.name }}
build-args: |
Expand Down Expand Up @@ -246,7 +246,7 @@ jobs:

# Push Release to github
- name: Push the release
uses: ncipollo/release-action@v1
uses: ncipollo/release-action@v1.21.0
with:
allowUpdates: true
artifacts:
Expand Down Expand Up @@ -280,11 +280,11 @@ jobs:

# Checkout the branch
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6

# Checkout the actions for this repo owner
- name: Checkout Actions
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
repository: ${{ github.repository_owner }}/.github
path: ./Actions_${{ github.sha }}
Expand Down Expand Up @@ -376,7 +376,7 @@ jobs:

# Push Release
- name: Push the release
uses: ncipollo/release-action@v1
uses: ncipollo/release-action@v1.21.0
with:
allowUpdates: true
artifacts:
Expand Down Expand Up @@ -434,13 +434,13 @@ jobs:

# Checkout the branch
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
path: cygwin\maiko

# Checkout the actions for this repo owner
- name: Checkout Actions
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
repository: ${{ github.repository_owner }}/.github
path: ./Actions_${{ github.sha }}
Expand Down Expand Up @@ -470,7 +470,7 @@ jobs:

# Push Release to github
- name: Push the release
uses: ncipollo/release-action@v1
uses: ncipollo/release-action@v1.21.0
with:
allowUpdates: true
artifacts:
Expand Down Expand Up @@ -501,7 +501,7 @@ jobs:

# Checkout the actions for this repo owner
- name: Checkout Actions
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
repository: ${{ github.repository_owner }}/.github
path: ./Actions_${{ github.sha }}
Expand Down Expand Up @@ -530,7 +530,7 @@ jobs:

# Checkout the maiko branch
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6

# Setup release tag
- name: Setup Release Tag
Expand All @@ -547,7 +547,7 @@ jobs:

# Push Release to github
- name: Push the release
uses: ncipollo/release-action@v1
uses: ncipollo/release-action@v1.21.0
with:
allowUpdates: true
artifacts: ${{ steps.tag.outputs.release_tag }}-emscripten.tgz
Expand All @@ -573,7 +573,7 @@ jobs:
steps:
# Checkout the actions for this repo owner
- name: Checkout Actions
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
repository: ${{ github.repository_owner }}/.github
path: ./Actions_${{ github.sha }}
Expand Down
41 changes: 40 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.15)
PROJECT(maiko C)

SET(CMAKE_EXPORT_COMPILE_COMMANDS ON)

SET(CMAKE_C_STANDARD 99)
Expand Down Expand Up @@ -37,6 +36,12 @@ IF(NEED_LIB_M)
SET(MAIKO_LIBRARIES m)
ENDIF()

IF (CMAKE_SYSTEM_NAME STREQUAL "Linux")
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBBSD-OVERLAY REQUIRED IMPORTED_TARGET "libbsd-overlay")
SET(MAIKO_LIBRARIES ${MAIKO_LIBRARIES} PkgConfig::LIBBSD-OVERLAY)
ENDIF()

SET (MAIKO_RELEASE 351 CACHE STRING "Release version to build. Release: 115, 200, 201, 210, 300, 350, 351")
SET_PROPERTY(CACHE MAIKO_RELEASE PROPERTY STRINGS 115 200 201 210 300 350 351)

Expand Down Expand Up @@ -448,6 +453,7 @@ ADD_CUSTOM_COMMAND(OUTPUT vdate.c
ADD_EXECUTABLE(lde src/ldeboot.c src/unixfork.c)
TARGET_COMPILE_DEFINITIONS(lde PRIVATE ${MAIKO_DEFINITIONS})
TARGET_INCLUDE_DIRECTORIES(lde PRIVATE inc)
TARGET_LINK_LIBRARIES(lde ${MAIKO_LIBRARIES})
IF(MAIKO_DISPLAY_X11)
# Tell it that the X11 launcher is available.
TARGET_COMPILE_DEFINITIONS(lde PRIVATE ${MAIKO_DISPLAY_X11_DEFINITIONS})
Expand Down Expand Up @@ -528,3 +534,36 @@ TARGET_INCLUDE_DIRECTORIES(setsout PRIVATE inc)
ADD_EXECUTABLE(tstsout src/tstsout.c src/byteswap.c)
TARGET_COMPILE_DEFINITIONS(tstsout PRIVATE ${MAIKO_DEFINITIONS})
TARGET_INCLUDE_DIRECTORIES(tstsout PRIVATE inc)

# Installation Targets
IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/../" CACHE PATH "Installation prefix" FORCE)
ENDIF()
execute_process(
COMMAND sh "${CMAKE_SOURCE_DIR}/bin/osversion"
OUTPUT_VARIABLE os_ver
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE res
)
Comment on lines +542 to +547
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The execute_process command uses relative paths like ../bin/osversion. This approach is not robust for out-of-source builds, where the build directory is not a direct subdirectory of the source root, and will cause the build to fail in such standard setups. You should use absolute paths constructed with CMAKE_SOURCE_DIR to make the command reliable regardless of the build directory location.

execute_process(
  COMMAND sh -c "echo $(${CMAKE_SOURCE_DIR}/bin/osversion).$(${CMAKE_SOURCE_DIR}/bin/machinetype)"
  OUTPUT_VARIABLE release_dir
  OUTPUT_STRIP_TRAILING_WHITESPACE
)

if(NOT res EQUAL 0)
message(FATAL_ERROR "osversion script failed")
endif()

execute_process(
COMMAND sh "${CMAKE_SOURCE_DIR}/bin/machinetype"
OUTPUT_VARIABLE machine_type
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE res
)
if(NOT res EQUAL 0)
message(FATAL_ERROR "machinetype script failed")
endif()

set(release_dir "${os_ver}.${machine_type}")INSTALL(TARGETS lde DESTINATION ${release_dir})

IF(MAIKO_DISPLAY_X11)
INSTALL(TARGETS ldex ldeinit DESTINATION ${release_dir})
ENDIF()
IF(MAIKO_DISPLAY_SDL)
INSTALL(TARGETS ldesdl DESTINATION ${release_dir})
ENDIF()
44 changes: 44 additions & 0 deletions bin/linux-common.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Common Options for All Linuxes

include linux-compiler.mk

BSD_CFLAGS :=
BSD_LDFLAGS :=
ifeq ($(USE_LIBBSD),T)
# Use LIBBSD - but only if glibc < 2.38
# Because we only need strlcat, strlcpy and friends from libbsd
# and they are included in glibc from 2.38 on.
GLIBC_VERSION := $(shell ldd --version | head -1 | sed -e "s/^.*\([0-9]\.[0-9][0-9]\)/\\1/")
GLIBC_CHECK := $(shell echo "$(GLIBC_VERSION) >= 2.38" | bc)
ifneq ($(GLIBC_CHECK),1)
include linux-libbsd.mk
endif
endif

ifeq ($(USE_DISPLAY),x)
include linux-x.mk
DEFAULT_TARGET := ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldex
endif
ifeq ($(USE_DISPLAY),sdl)
include linux-sdl.mk
DEFAULT_TARGET := ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldesdl
endif
ifeq ($(USE_DISPLAY),init)
include linux-x.mk
DEFAULT_TARGET := ../$(OSARCHNAME)/ldeinit
endif

OPTFLAGS ?= -O2 -g3
DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) $(BSD_CFLAGS) $(ADDITIONAL_DFLAGS)

LDFLAGS = $(XLDFLAGS) -lc -lm $(BSD_LDFLAGS)

ifeq ($(USE_DISPLAY),x)
LDELDFLAGS = $(XLDFLAGS) -lc -lm $(BSD_LDFLAGS)
else
LDELDFLAGS = -lc -lm $(BSD_LDFLAGS)
endif

OBJECTDIR = ../$(RELEASENAME)/

default: $(DEFAULT_TARGET)
40 changes: 40 additions & 0 deletions bin/linux-compiler.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Select whether to use clang or gcc
# Priority
# 1. If -DUSE_GCC or -DUSE_CLANG on command line (but not both) use the requested compiler.
# 2. If one compiler is installed but not the other, use the installed compiler.
# 3. Use clang

EXISTS_GCC := $(shell command -v gcc)
EXISTS_CLANG := $(shell command -v clang)
ifeq ($(or $(EXISTS_GCC),$(EXISTS_CLANG)),)
$(error "Cannot find compiler: neither gcc nor clang. Exiting.")
endif
ifneq ($(and $(USE_CLANG),$(USE_GCC)),)
$(error "Cannot use both USE_CLANG=T and USE_GCC=T. Exiting.")
endif
COMPILER :=
ifdef USE_CLANG
ifeq ($(EXISTS_CLANG),)
$(error "USE_CLANG=T given, but cannot find the clang compiler. Exiting")
endif
COMPILER := clang
endif
ifdef USE_GCC
ifeq ($(EXISTS_GCC),)
$(error "USE_GCC=T given, but cannot find the gcc compiler. Exiting")
endif
COMPILER := gcc
endif
ifeq ($(COMPILER),)
ifneq ($(EXISTS_CLANG),)
COMPILER := clang
else
COMPILER := gcc
endif
endif

ifeq ($(COMPILER),gcc)
CC := gcc $(GCC_CFLAGS)
else
CC := clang $(CLANG_CFLAGS)
endif
Loading