Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
df1aaa0
old msvc
Un1q32 Jul 22, 2026
dc4fc62
a
Un1q32 Jul 22, 2026
253cd6b
fix
Un1q32 Jul 22, 2026
72fba1b
im old
Un1q32 Jul 22, 2026
ef7b02a
stdbool check
Un1q32 Jul 22, 2026
894583d
better
Un1q32 Jul 22, 2026
9678470
check function
Un1q32 Jul 22, 2026
5964290
compat stdio
Un1q32 Jul 22, 2026
58c6f95
fix
Un1q32 Jul 22, 2026
81e6ebc
fix
Un1q32 Jul 22, 2026
50efee5
fix
Un1q32 Jul 22, 2026
06a868d
build clean
Un1q32 Jul 22, 2026
ad9355f
struct syntax
Un1q32 Jul 22, 2026
d8ce68f
fix
Un1q32 Jul 22, 2026
8c4698d
fmin and fmax
Un1q32 Jul 22, 2026
e4ba28f
round
Un1q32 Jul 22, 2026
7451281
maybe fix?
Un1q32 Jul 22, 2026
13e0f7a
fix cast
Un1q32 Jul 22, 2026
cdee157
msvc
Un1q32 Jul 22, 2026
6e87533
log2
Un1q32 Jul 22, 2026
b6ff9c8
1e39
Un1q32 Jul 22, 2026
ae92a35
fix
Un1q32 Jul 22, 2026
809b3bc
msvc
Un1q32 Jul 22, 2026
eb822d9
msvc
Un1q32 Jul 22, 2026
dd0651e
fix
Un1q32 Jul 22, 2026
8fe16f3
update version
Un1q32 Jul 22, 2026
02b5145
__func__
Un1q32 Jul 22, 2026
169050c
roundf
Un1q32 Jul 22, 2026
ff8b79b
better configure
Un1q32 Jul 22, 2026
d5b9ba6
stdint
Un1q32 Jul 22, 2026
d42ae86
printf
Un1q32 Jul 22, 2026
0bbd99c
better message
Un1q32 Jul 22, 2026
cb05e54
bullshit
Un1q32 Jul 22, 2026
ed4ad00
fix
Un1q32 Jul 22, 2026
b9ba9bc
fixes
Un1q32 Jul 22, 2026
5d12875
fix
Un1q32 Jul 22, 2026
f2ce3dd
trim printf
Un1q32 Jul 22, 2026
bdff8c3
msvc
Un1q32 Jul 22, 2026
8c1342d
bullshit
Un1q32 Jul 22, 2026
f5e456d
better
Un1q32 Jul 22, 2026
1e76f7b
fix
Un1q32 Jul 22, 2026
e8b2543
msvc 9
Un1q32 Jul 22, 2026
b2c4ba8
snprintf check
Un1q32 Jul 22, 2026
041fc47
fix
Un1q32 Jul 22, 2026
1489a4c
bruh
Un1q32 Jul 22, 2026
8ddcab3
bruh
Un1q32 Jul 22, 2026
14803f1
fix
Un1q32 Jul 22, 2026
76dd75d
fix msvc
Un1q32 Jul 22, 2026
8cda09e
support old msvc in makefile
Un1q32 Jul 22, 2026
433207e
remove build.cmd and configure.cmd
Un1q32 Jul 22, 2026
44c57a7
fix
Un1q32 Jul 22, 2026
35f7ba6
fix
Un1q32 Jul 22, 2026
116cd87
isinf and isnan proper tests
Un1q32 Jul 22, 2026
0b8e284
fix
Un1q32 Jul 22, 2026
d72e09f
msvc 8 maybe
Un1q32 Jul 23, 2026
8502773
msvc 8
Un1q32 Jul 23, 2026
1d9543c
update
Un1q32 Jul 23, 2026
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
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ INCLUDES += $(INCLUDE). \
$(INCLUDE)vendor/base64 \
$(INCLUDE)vendor/bzip2

HEADERS := $(wildcard src/*.h) $(shell find vendor -name '*.h')
SRCS := $(wildcard src/*.c) $(wildcard src/image/*.c) $(wildcard vendor/bzip2/*.c) vendor/md5/md5.c vendor/sha1/sha1.c vendor/base64/base64.c
HEADERS += $(wildcard src/*.h) $(shell find vendor -name '*.h')
SRCS += $(wildcard src/*.c) $(wildcard src/image/*.c) $(wildcard vendor/bzip2/*.c) vendor/md5/md5.c vendor/sha1/sha1.c vendor/base64/base64.c

DESKTOP_BACKEND := glfw3
AUDIO_BACKEND := miniaudio
Expand Down Expand Up @@ -178,7 +178,7 @@ LIBS += -static
LIBS += -lwinmm
else
LIBS += winmm.lib
DEFINES += $(DEFINE)_CRT_SECURE_NO_WARNINGS
DEFINES += $(DEFINE)_CRT_SECURE_NO_WARNINGS $(DEFINE)_CRT_SECURE_NO_DEPRECATE
endif
DEFINES += $(DEFINE)WIN32_LEAN_AND_MEAN
else
Expand Down Expand Up @@ -208,13 +208,13 @@ endif

build/butterscotch: $(OBJS)
@{ [ -z "$(NO_COLOR)" ] && [ -t 1 ]; } && printf " \033[1;34mLD\033[0m butterscotch\n" || printf " LD butterscotch\n"
$(V)$(_CC) $(LDFLAGS) $(OBJS) $(LIBS) $(EXTRALIBS) $(OUTPUT_EXE)$@
$(V)MSYS2_ARG_CONV_EXCL='*' $(CCLINK) $(LDFLAGS) $(OBJS) $(LIBS) $(EXTRALIBS) $(OUTPUT_EXE)$@
@[ -f $@.exe ] && chmod +x $@.exe || true

build/%.c.$(OBJ_EXT): %.c compat/config.mk $(if $(DISABLE_MMD),$(HEADERS))
@mkdir -p $(dir $@)
@{ [ -z "$(NO_COLOR)" ] && [ -t 1 ]; } && printf " \033[1;32mCC\033[0m $<\n" || printf " CC $<\n"
$(V)$(_CC) $(DEFINES) $(INCLUDES) $(CFLAGS) $(DEPFLAGS) $(COMPILE_OBJ) $< $(OUTPUT_OBJ)$@
$(V)MSYS2_ARG_CONV_EXCL='*' $(_CC) $(DEFINES) $(INCLUDES) $(CFLAGS) $(DEPFLAGS) $(COMPILE_OBJ) $< $(OUTPUT_OBJ)$@

clean:
rm -rf build
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ The following compilers have been tested to successfully build butterscotch, old
* GCC 2.7 and up in C++ mode, and 3.0 and up in C99 mode
* Clang 1.1 and up
* TinyCC 0.9.27 and up
* MSVC 19.29.30159 and up
* MSVC 8.0 and up

## Community Ports

Expand Down
79 changes: 68 additions & 11 deletions compat/configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ if [ -z "$CC" ]; then
exit 1
fi

export MSYS2_ARG_CONV_EXCL='*'

# cd to the directory this script is in
[ "${0%/*}" = "$0" ] && scriptroot="." || scriptroot="${0%/*}"
cd "$scriptroot"
Expand Down Expand Up @@ -84,24 +86,29 @@ int main(void){return 0;}
return $?
}

ccname="${CC##*/}"
target="${ccname%-*}"
if [ "$ccname" = "$target" ]; then
target=
fi

printf '%s' "\
int main(void){return 0;}
" > tmp/test.c

configlog 'checking the C compiler CLI syntax'
if $CC /nologo tmp/test.c /Fe:tmp/a.out >> tmp/config.log 2>&1; then
if $CC /nologo tmp/test.c /Fetmp/a.out >> tmp/config.log 2>&1; then
printgreen 'msvc'
syntax=msvc
CC="$CC /nologo"
cflags='/Oi-' # equivalent to -fno-builtin
compile_obj='/c'
output_obj='/Fo:'
output_exe='/Fe:'
output_obj='/Fo'
output_exe='/Fe'
config "OUTPUT_OBJ := $output_obj"
config "OUTPUT_EXE := $output_exe"
config 'MSVC := 1'
config 'OBJ_EXT := obj'
config "_CC := \$(CC) /nologo"
config 'CFLAGS := /O2 /DNDEBUG'
config 'INCLUDE := /I'
config 'DEFINE := /D'
Expand All @@ -115,7 +122,6 @@ elif $CC tmp/test.c -o tmp/a.out >> tmp/config.log 2>&1; then
config "OUTPUT_OBJ := -o\$(space)"
config "OUTPUT_EXE := -o\$(space)"
config 'OBJ_EXT := o'
config "_CC := \$(CC)"
config 'CFLAGS := -O2 -DNDEBUG'
config 'INCLUDE := -I'
config 'DEFINE := -D'
Expand All @@ -136,12 +142,6 @@ else
cross_compiling=1
fi

ccname="${CC##*/}"
target="${ccname%-*}"
if [ "$ccname" = "$target" ]; then
target=
fi

if [ -n "$target" ]; then
configlog "checking for $target-pkg-config"
if command -v "$target-pkg-config"; then
Expand All @@ -152,6 +152,27 @@ if [ -n "$target" ]; then
fi
fi

printf '%s' "\
int main(void){
int a = 0;
++a;
int b = a;
return b;
}
" > tmp/test.c

config "CCLINK := $CC"
if ! nolink=1 check 'if C supports mixed declarations and code'; then
if [ "$syntax" = 'msvc' ]; then
CC="$CC /TP"
else
printf 'Support for mixed declarations and code is required, maybe try building in C++ mode.\n'
exit 1
fi
fi

config "_CC := $CC"

configlog 'checking the target OS'
if checkdefine '_WIN32' > /dev/null; then
printgreen 'windows'
Expand Down Expand Up @@ -213,6 +234,7 @@ int main(void){return 0;}
if ! nolink=1 check 'if stdbool.h works'; then
# Needed for GCC 2.95, where stdbool.h doesn't work in C++ mode
include 'compat/stdbool'
config 'HEADERS += compat/stdbool/stdbool.h'
fi

printf '%s' "\
Expand All @@ -222,6 +244,7 @@ int main(void){return 0;}

if ! nolink=1 check 'if stdint.h works'; then
include 'compat/stdint'
config 'HEADERS += compat/stdint/stdint.h'
printf '%s' "\
#include <sys/types.h>
int main(void){return 0;}
Expand Down Expand Up @@ -342,6 +365,24 @@ if ! check 'for roundf' $lm; then
define 'NO_ROUNDF'
fi

printf '%s' "\
#include <math.h>
int main(void){return isinf(0.0);}
" > tmp/test.c

if ! check 'for isinf' $lm; then
define 'NO_ISINF'
fi

printf '%s' "\
#include <math.h>
int main(void){return isnan(0.0);}
" > tmp/test.c

if ! check 'for isnan' $lm; then
define 'NO_ISNAN'
fi

printf '%s' "\
#include <string.h>
int main(void){
Expand All @@ -367,6 +408,22 @@ int main(int argc,char *argv[]){

if ! check 'for getopt_long'; then
include 'compat/getopt'
config 'HEADERS += compat/getopt/getopt.h'
fi

printf '%s' "\
#include <stdio.h>
int main(void){
char buf[8];
return snprintf(buf, sizeof(buf), \"test\");
}
" > tmp/test.c

if ! check 'for snprintf'; then
include 'compat/stdio'
define 'NO_SNPRINTF'
config 'SRCS += compat/stdio/printf.c'
config 'HEADERS += compat/stdio/printf.h'
fi

rm -f tmp/test.c tmp/a.out test.obj
13 changes: 12 additions & 1 deletion compat/stdint/stdint.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,26 @@
#define int64_t __bs_int64_t
#endif

#ifdef _MSC_VER
/* MSVC used to define intptr_t here, before it had stdint.h */
#include <crtdefs.h>
#define intptr_t __bs_intptr_t
#endif

typedef signed char int8_t;
typedef signed short int16_t;
typedef signed int int32_t;
typedef signed long long int64_t;

typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;
typedef int8_t int_fast8_t;

typedef int64_t int_fast64_t;

typedef int64_t intmax_t;

typedef long intptr_t;

#endif /* _BS_STDINT_H_ */
Loading
Loading