Skip to content
This repository was archived by the owner on Feb 10, 2026. It is now read-only.

Commit 1f702c0

Browse files
committed
Improvements to the build system
1 parent 5e85b81 commit 1f702c0

File tree

4 files changed

+38
-52
lines changed

4 files changed

+38
-52
lines changed

.github/workflows/linux.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,16 @@ jobs:
6868
6969
- name: Tests
7070
run: |
71-
make compile_tests CC=gcc MODE=DEBUG USE_C2X_FLAG=1
71+
make compile_tests CC=gcc LANGUAGE=c2x MODE=DEBUG
7272
7373
- name: Examples
7474
run: |
75-
make compile_examples CC=gcc MODE=DEBUG USE_C2X_FLAG=1
75+
make compile_examples CC=gcc LANGUAGE=c2x MODE=DEBUG
7676
7777
- name: Build Library
7878
run: |
79-
make static CC=gcc MODE=RELEASE USE_C2X_FLAG=1
80-
make dynamic CC=gcc MODE=RELEASE USE_C2X_FLAG=1
79+
make static CC=gcc LANGUAGE=c2x MODE=RELEASE
80+
make dynamic CC=gcc LANGUAGE=c2x MODE=RELEASE
8181
if: matrix.bits == 64
8282

8383
- name: Generate Artifacts

.github/workflows/macos.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ jobs:
5151
5252
- name: Tests
5353
run: |
54-
make compile_tests CC=clang MODE=DEBUG
54+
make compile_tests CC=clang LANGUAGE=c2x MODE=DEBUG
5555
5656
- name: Examples
5757
run: |
58-
make compile_examples CC=clang MODE=DEBUG
58+
make compile_examples CC=clang LANGUAGE=c2x MODE=DEBUG
5959
6060
- name: Build Library
6161
run: |
@@ -65,12 +65,12 @@ jobs:
6565
brew install grep
6666
6767
# Build sili x86_64 & arm64 static
68-
make static CC=clang EXTRA_FLAGS="-target x86_64-apple-macos10.12" LIB_NAME="sili_x86_64"
69-
make static CC=clang EXTRA_FLAGS="-target arm64-apple-macos11" LIB_NAME="sili_arm64"
68+
make static CC=clang MODE=RELEASE LANGUAGE=c2x EXTRA_FLAGS="-target x86_64-apple-macos10.12" LIB_NAME="sili_x86_64"
69+
make static CC=clang MODE=RELEASE LANGUAGE=c2x EXTRA_FLAGS="-target arm64-apple-macos11" LIB_NAME="sili_arm64"
7070
7171
# Build sili x86_64 & arm64 dynamic
72-
make dynamic CC=clang EXTRA_FLAGS="-target x86_64-apple-macos10.12" LIB_NAME="sili_x86_64"
73-
make dynamic CC=clang EXTRA_FLAGS="-target arm64-apple-macos11" LIB_NAME="sili_arm64"
72+
make dynamic CC=clang MODE=RELEASE LANGUAGE=c2x EXTRA_FLAGS="-target x86_64-apple-macos10.12" LIB_NAME="sili_x86_64"
73+
make dynamic CC=clang MODE=RELEASE LANGUAGE=c2x EXTRA_FLAGS="-target arm64-apple-macos11" LIB_NAME="sili_arm64"
7474
7575
- name: Generate Artifacts
7676
run: |

.github/workflows/windows.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,15 @@ jobs:
8181
# MinGW
8282
- name: Tests (MinGW-w64 64-bit)
8383
run: |
84-
make compile_tests CC=${{ matrix.ARCH }}-w64-mingw32-gcc USE_C2X_FLAG=1
84+
make compile_tests CC=${{ matrix.ARCH }}-w64-mingw32-gcc LANGUAGE=c17 MODE=DEBUG
8585
shell: cmd
8686
if: |
8787
matrix.compiler == 'mingw-w64' &&
8888
matrix.bits == 64
8989
9090
- name: Examples (MinGW-w64 64-bit)
9191
run: |
92-
make compile_examples CC=${{ matrix.ARCH }}-w64-mingw32-gcc USE_C2X_FLAG=1
92+
make compile_examples CC=${{ matrix.ARCH }}-w64-mingw32-gcc LANGUAGE=c17 MODE=DEBUG
9393
shell: cmd
9494
if: |
9595
matrix.compiler == 'mingw-w64' &&
@@ -100,8 +100,8 @@ jobs:
100100
${{ matrix.ARCH }}-w64-mingw32-gcc.exe --version
101101
windres.exe --version
102102
dir C:\msys64\mingw64\bin
103-
make static CC=${{ matrix.ARCH }}-w64-mingw32-gcc USE_C2X_FLAG=1
104-
make dynamic CC=${{ matrix.ARCH }}-w64-mingw32-gcc USE_C2X_FLAG=1
103+
make static CC=${{ matrix.ARCH }}-w64-mingw32-gcc LANGUAGE=c17 MODE=RELEASE
104+
make dynamic CC=${{ matrix.ARCH }}-w64-mingw32-gcc LANGUAGE=c17 MODE=RELEASE
105105
copy /Y .\build\libsili.dll .\build\${{ env.RELEASE_NAME }}\lib
106106
shell: cmd
107107
if: |
@@ -112,24 +112,27 @@ jobs:
112112
# MSVC
113113
- name: Tests (MSVC16 64-bit)
114114
run: |
115-
make compile_tests CC=cl.exe
115+
make compile_tests LANGUAGE=c17 MODE=DEBUG CC=cl.exe
116+
shell: powershell
116117
if: |
117118
matrix.compiler == 'msvc16' &&
118119
matrix.bits == 64
119120
120121
- name: Examples (MSVC16 64-bit)
121122
run: |
122-
make compile_examples CC=cl.exe
123+
make compile_examples LANGUAGE=c17 MODE=DEBUG CC=cl.exe
124+
shell: powershell
123125
if: |
124126
matrix.compiler == 'msvc16' &&
125127
matrix.bits == 64
126128
127129
- name: Build Library (MSVC16 64-bit)
128130
run: |
129131
windres.exe --version
130-
make static CC=cl.exe AR=lib
131-
make dynamic CC=cl.exe
132+
make static CC=cl.exe LANGUAGE=c17 MODE=RELEASE
133+
make dynamic CC=cl.exe LANGUAGE=c17 MODE=RELEASE
132134
copy /Y .\build\libsili.dll .\build\${{ env.RELEASE_NAME }}\lib
135+
shell: powershell
133136
if: |
134137
matrix.compiler == 'msvc16' &&
135138
matrix.bits == 64

Makefile

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
# 'DEBUG' turns on all warnings as well as flags to help with debugging/finding
1111
# problematic code. 'RELEASE' turns on all optimisations as well as warnings.
1212
#
13-
# LANGUAGE - selects which programming language to target. Currently C and C++
14-
# are the only valid options.
13+
# LANGUAGE - selects which programming language (and standard) to use. Available
14+
# values: c99, c11, c17, c18, c2x/c23, c++11, c++14, c++17, c++20, etc.
1515

1616
CC = clang
1717
PLATFORM = DEFAULT
1818
MODE = FAST
19-
LANGUAGE = C
19+
LANGUAGE = c23
2020

2121

2222
# General building options:
@@ -75,14 +75,15 @@ ifeq ($(PLATFORM),DEFAULT)
7575
endif
7676

7777

78-
ifeq ($(LANGUAGE),C)
79-
ifeq ($(or $(filter OS_X,$(PLATFORM)),$(USE_C2X_FLAG)),)
80-
GNU_FLAGS = -std=c23 -x c -Wvla
81-
else
82-
GNU_FLAGS = -std=c2x -x c -Wvla
83-
endif
84-
else ifeq ($(LANGUAGE),CPP)
85-
GNU_FLAGS = -std=c++11 -x c++ -fno-exceptions
78+
#
79+
# GNU compiler configurations
80+
#
81+
ifneq ($(PLATFORM),WIN32_MSVC)
82+
83+
ifneq (,$(filter cpp%,$(LANGUAGE)))
84+
GNU_FLAGS = -std=$(LANGUAGE) -x c++ -fno-exceptions
85+
else
86+
GNU_FLAGS = -std=$(LANGUAGE) -x c -Wvla
8687
endif
8788

8889

@@ -150,30 +151,8 @@ endif
150151

151152
GNU_INCLUDES = -I"." -I"include"
152153

153-
154-
ifeq ($(PLATFORM),DEFAULT)
155-
ifneq (,$(filter $(CC),mingw32-gcc x86_64-w64-mingw32-g++ w64gcc w32gcc))
156-
PLATFORM = WIN32_GNU
157-
else ifneq (,$(filter $(CC),cl))
158-
PLATFORM = WIN32_MSVC
159-
else ifneq (,$(filter $(CC), wasi))
160-
PLATFORM = WASM_WASI
161-
else ifneq (,$(filter $(CC), emcc))
162-
PLATFORM = WASM_EMCC
163-
else
164-
DETECTED_OS := $(shell uname 2>/dev/null || echo Unknown)
165-
166-
ifeq ($(DETECTED_OS),Darwin)
167-
PLATFORM = OS_X
168-
else ifeq ($(DETECTED_OS),Linux)
169-
PLATFORM = LINUX
170-
else
171-
$(error Unsupported platform. Please refer to the Makefile for supported platofmrs.)
172-
endif
173-
endif
174154
endif
175155

176-
177156
ifeq ($(PLATFORM),WIN32_GNU)
178157
FLAGS = $(GNU_FLAGS)
179158
INCLUDES = $(GNU_INCLUDES)
@@ -280,7 +259,11 @@ clean:
280259

281260

282261
$(EXE): $(SRC) sili.h Makefile examples/*
283-
$(CC) $(FLAGS) $(EXTRA_FLAGS) $(SRC) $(INCLUDES) $(LIBS) -o "$@"
262+
ifneq (,$(filter $(PLATFORM),WIN32_GNU OS_X LINUX WASM_WASI WASM_EMCC))
263+
$(CC) $(FLAGS) $(EXTRA_FLAGS) $(SRC) $(INCLUDES) $(LIBS) -o "$@"
264+
else ifneq (,$(filter $(PLATFORM),WIN32_MSVC))
265+
$(CC) $(FLAGS) $(EXTRA_FLAGS) $(SRC) $(INCLUDES) $(LIBS) /Fe"$@"
266+
endif
284267

285268
static:
286269
ifneq (,$(filter $(PLATFORM),WIN32_GNU OS_X LINUX WASM_WASI WASM_EMCC))

0 commit comments

Comments
 (0)