sys-devel/lcc: new package, add 2021.01.11

Signed-off-by: Benoît Dufour <benoit.dufour@mail.com>
This commit is contained in:
Benoît Dufour
2023-11-05 22:55:48 -05:00
parent 5276f0bf01
commit e2e38fbb37
3 changed files with 193 additions and 0 deletions

1
sys-devel/lcc/Manifest Normal file
View File

@@ -0,0 +1 @@
DIST 3fd0acc0c3087411c0966d725a56be29038c05a9.tar.gz 636724 BLAKE2B 9fffbda4e888d79c672d2da25cec4132848ce5f8cadd99f128645389377230b491ef3d2f3c550774df6ae82fd6304addcd1f00d6d0da79440ea510b0d97d5600 SHA512 f954509307136632408a219ccefa3e85a05538553c17aec72556979370fa795076a574033c6f7d2b51ca30218665fddd3b576b00fdb6327ae09f0e0c041d428a

View File

@@ -0,0 +1,156 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..6c3b77c
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,11 @@
+cmake_minimum_required(VERSION 3.13)
+
+# TODO: test, triple
+
+project(lcc C)
+
+add_subdirectory(lburg)
+add_subdirectory(src)
+add_subdirectory(cpp)
+add_subdirectory(etc)
+add_subdirectory(lib)
diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
new file mode 100644
index 0000000..accff2e
--- /dev/null
+++ b/cpp/CMakeLists.txt
@@ -0,0 +1,12 @@
+add_executable(cpp
+ cpp.c
+ lex.c
+ nlist.c
+ tokens.c
+ macro.c
+ eval.c
+ include.c
+ hideset.c
+ getopt.c
+ unix.c
+ )
\ No newline at end of file
diff --git a/etc/CMakeLists.txt b/etc/CMakeLists.txt
new file mode 100644
index 0000000..aa4d4aa
--- /dev/null
+++ b/etc/CMakeLists.txt
@@ -0,0 +1,18 @@
+add_executable(lcc
+ lcc.c)
+
+if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+ target_sources(lcc PRIVATE win32.c)
+elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ target_sources(lcc PRIVATE linux.c)
+endif()
+
+add_executable(bprint
+ bprint.c)
+
+target_link_libraries(bprint PRIVATE profio)
+
+add_executable(ops EXCLUDE_FROM_ALL
+ ops.c)
+
+target_link_libraries(ops PRIVATE c)
\ No newline at end of file
diff --git a/lburg/CMakeLists.txt b/lburg/CMakeLists.txt
new file mode 100644
index 0000000..25b0ae1
--- /dev/null
+++ b/lburg/CMakeLists.txt
@@ -0,0 +1,14 @@
+
+add_executable(lburg
+ lburg.c
+ gram.c)
+
+target_include_directories(lburg PRIVATE lburg)
+
+# lburg function for generation of c files from md files
+function(lburg md_file c_file)
+ add_custom_command(OUTPUT ${c_file}
+ DEPENDS ${md_file}
+ COMMAND lburg ${md_file} ${c_file}
+ VERBATIM)
+endfunction()
\ No newline at end of file
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
new file mode 100644
index 0000000..3c31289
--- /dev/null
+++ b/lib/CMakeLists.txt
@@ -0,0 +1,4 @@
+add_library(liblcc STATIC
+ assert.c
+ yynull.c
+ bbexit.c)
\ No newline at end of file
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644
index 0000000..21efef9
--- /dev/null
+++ b/src/CMakeLists.txt
@@ -0,0 +1,56 @@
+add_executable(rcc
+ main.c)
+
+target_link_libraries(rcc PRIVATE librcc)
+
+lburg(${CMAKE_CURRENT_SOURCE_DIR}/dagcheck.md dagcheck.c)
+lburg(${CMAKE_CURRENT_SOURCE_DIR}/alpha.md alpha.c )
+lburg(${CMAKE_CURRENT_SOURCE_DIR}/mips.md mips.c )
+lburg(${CMAKE_CURRENT_SOURCE_DIR}/sparc.md sparc.c )
+lburg(${CMAKE_CURRENT_SOURCE_DIR}/x86.md x86.c )
+lburg(${CMAKE_CURRENT_SOURCE_DIR}/x86linux.md x86linux.c)
+
+add_library(librcc STATIC
+ alloc.c
+ bind.c
+ dag.c
+ dagcheck.c
+ decl.c
+ enode.c
+ error.c
+ expr.c
+ event.c
+ init.c
+ inits.c
+ input.c
+ lex.c
+ list.c
+ main.c
+ output.c
+ prof.c
+ profio.c
+ simp.c
+ stmt.c
+ string.c
+ sym.c
+ trace.c
+ tree.c
+ types.c
+ null.c
+ symbolic.c
+ gen.c
+ bytecode.c
+ alpha.c
+ mips.c
+ sparc.c
+ stab.c
+ x86.c
+ x86linux.c)
+
+target_include_directories(librcc PUBLIC .)
+
+add_library(c INTERFACE)
+target_include_directories(c INTERFACE .)
+
+add_library(profio INTERFACE)
+target_include_directories(profio INTERFACE .)
\ No newline at end of file

View File

@@ -0,0 +1,36 @@
# Copyright 2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
inherit cmake
# Would allow installing gentoo on any arch.
DESCRIPTION="The lcc retargetable ANSI C compiler"
HOMEPAGE="https://drh.github.io/lcc/"
SHA='3fd0acc0c3087411c0966d725a56be29038c05a9'
SRC_URI="https://github.com/drh/lcc/archive/${SHA}.tar.gz"
# Build using CMake, still missing some features.
PATCHES=( "${FILESDIR}/add_cmake_support.patch" )
LICENSE="lcc"
SLOT="0"
KEYWORDS="~amd64"
# What are the dependencies if any?
#DEPEND=""
#RDEPEND="${DEPEND}"
#BDEPEND=""
S="${WORKDIR}/${PN}-${SHA}"
src_install() {
doman "doc/bprint.1"
doman "doc/lcc.1"
#into "/usr/lib/lcc"
dobin "${WORKDIR}/${PN}-${SHA}_build/cpp/cpp"
dobin "${WORKDIR}/${PN}-${SHA}_build/etc/bprint"
dobin "${WORKDIR}/${PN}-${SHA}_build/etc/lcc"
dobin "${WORKDIR}/${PN}-${SHA}_build/lburg/lburg"
dobin "${WORKDIR}/${PN}-${SHA}_build/src/rcc"
}