First build system #1

Merged
wesley merged 1 commits from first-build into main 2024-02-04 13:24:27 -05:00
7 changed files with 82 additions and 0 deletions

2
.gitignore vendored
View File

@@ -52,3 +52,5 @@ Module.symvers
Mkfile.old Mkfile.old
dkms.conf dkms.conf
# Ignore /bin directory
/bin

29
build-all.sh Executable file
View File

@@ -0,0 +1,29 @@
#!/bin/bash
#
# Build script to build everything
set echo on
mkdir -p bin/
echo "Building all.."
pushd quantum
source build.sh
popd
ERRORLEVEL=$?
if [ $ERRORLEVEL -ne 0 ]; then
echo "Error:"$ERRORLEVEL && exit
fi
pushd test_stuff
source build.sh
popd
ERRORLEVEL=$?
if [ $ERRORLEVEL -ne 0 ]; then
echo "Error:"$ERRORLEVEL && exit
fi
echo "All assemblies built successfully!!!!"

23
quantum/build.sh Executable file
View File

@@ -0,0 +1,23 @@
#!/bin/bash
#
# Build script for quantum
set echo on
mkdir -p build/
# Get a list of all the .c files.
cFilenames=$(find . -type f -name "*.c")
assembly="quantum"
objLocation="build/libquantum.o"
compilerFlags="-g -c -fpic"
includeFlags="-Isrc"
echo "Building $assembly..."
# First we need to compile down to .o files
gcc $cFilenames $compilerFlags -o $objLocation $includeFlags
compilerFlags="-g -shared"
gcc $objLocation $compilerFlags -o ../bin/libquantum.so $includeFlags

5
quantum/src/test.c Normal file
View File

@@ -0,0 +1,5 @@
#include <stdio.h>
#include "test.h"
void hello_quantum() { printf("Hello from Quantum!\n"); }

1
quantum/src/test.h Normal file
View File

@@ -0,0 +1 @@
void hello_quantum();

15
test_stuff/build.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
#Build script for test_stuff
set echo on
# Get a list of all the .c files.
cFilenames=$(find . -type f -name "*.c")
assembly="test_stuff"
compilerFlags="-g -fpic"
includeFlags="-Isrc -I../quantum/src/"
linkerFlags="-L../bin/ -lquantum -Wl,-rpath,."
echo "Building $assembly..."
gcc $cFilenames $compilerFlags -o ../bin/$assembly $includeFlags $linkerFlags

7
test_stuff/src/main.c Normal file
View File

@@ -0,0 +1,7 @@
#include <test.h>
int main() {
hello_quantum();
return 0;
}