Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
0.21
Browse files Browse the repository at this point in the history
Fixed a getVal bug that stemmed from zero removal
Added LABEL/GOTO
Added prevention for cross-program DO/LOOP, etc.
Improved logic compare with & for 'and' and | for 'or'
  • Loading branch information
PQCraft authored Aug 31, 2021
1 parent 50cb760 commit 8fa2efd
Show file tree
Hide file tree
Showing 12 changed files with 420 additions and 189 deletions.
81 changes: 67 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,43 @@
BASE_CFLAGS = -Wall -Wextra -O2 -lm -lreadline --std=c99
BASE_CFLAGS = --std=c99 -Wall -Wextra -Ofast -lm -lreadline

ifndef OS
ifdef OS
ifeq ($(findstring :/, $(PATH)), :/)
IS_LINUX = true
else
IS_LINUX = false
endif
else
IS_LINUX = true
endif

ifeq ($(IS_LINUX), true)

C = gcc
CFLAGS = $(BASE_CFLAGS)
ifeq ($(shell uname -s), Darwin)
CFLAGS += -I/usr/local/opt/readline/include -L/usr/local/opt/readline/lib
else
ifeq ($(shell uname -o), Android)
CFLAGS += -s
else
CFLAGS += -s -no-pie
endif
endif

CBITS = $(shell getconf LONG_BIT)

BUILD__ = $(C) clibasic.c $(CFLAGS) -DB$(CBITS) -o clibasic && chmod +x ./clibasic
BUILD32 = $(C) clibasic.c -m32 $(CFLAGS) -DB32 -o clibasic && chmod +x ./clibasic
BUILD_TO = "clibasic"
BUILD__ = $(C) clibasic.c $(CFLAGS) -DB$(CBITS) -o $(BUILD_TO) && chmod +x $(BUILD_TO)
BUILD32 = $(C) clibasic.c -m32 $(CFLAGS) -DB32 -o $(BUILD_TO) && chmod +x $(BUILD_TO)

INSTALL_TO = "/usr/bin/clibasic"
INSTALL = if [ "$$(id -u)" -eq 0 ]; then cp $(BUILD_TO) $(INSTALL_TO); else echo "Root privileges are needed to install."; fi

RUN = ./clibasic

CLEAN = rm -f clibasic

INSTALL = if [ "$$(id -u)" -eq 0 ]; then cp ./clibasic $(INSTALL_TO); else echo "Root privileges are needed to install."; fi
.PHONY: all all32 build build32 update install install32 run clean cross

all: clean build run

Expand All @@ -30,31 +50,56 @@ build32:
$(BUILD32)

update:
printf "\\e[0m\\e[31;1mAre you sure? [y/N]: "; read -n 1 I; [ ! "$$I" == "" ] && printf "\\e[0m\\n" &&\
printf "\\e[0m\\e[31;1mAre you sure? [y/N]:\\e[0m "; read -n 1 I; [ ! "$$I" == "" ] && printf "\\n" &&\
([[ ! "$$I" =~ ^[^Yy]$$ ]] && sh -c 'git restore . && git pull' &> /dev/null && chmod +x *.sh) || exit 0

install:
if [ ! -f ./clibasic ]; then $(BUILD__); fi
if [ ! -f $(INSTALL_TO) ]; then $(BUILD__); fi
$(INSTALL)

install32:
if [ ! -f ./clibasic ]; then $(BUILD32); fi
if [ ! -f $(INSTALL_TO) ]; then $(BUILD32); fi
$(INSTALL)

run:
./clibasic
$(RUN)

clean:
rm -f ./clibasic
$(CLEAN)

.ONESHELL:

cross:
ifeq ($(MAKECMDGOALS), cross)
@$(MAKE) cross all
else
@$(eval C = x86_64-w64-mingw32-gcc)
@$(eval C32 = i686-w64-mingw32-gcc)
@$(eval CFLAGS = $(BASE_CFLAGS) -Ilib)
@$(eval BUILD_TO = "clibasic.exe")
@$(eval BUILD__ = cp -f lib/win64/*.dll . && $(C) clibasic.c $(CFLAGS) -Llib/win64 -DB$(CBITS) -o $(BUILD_TO) && chmod -x ./clibasic.exe)
@$(eval BUILD32 = cp -f lib/win32/*.dll . && $(C32) clibasic.c -m32 $(CFLAGS) -Llib/win32 -DB32 -o $(BUILD_TO) && chmod -x ./clibasic.exe)
@$(eval INSTALL_TO = "$$HOME/.wine/drive_c/windows/system32")
@$(eval INSTALL = cp $(BUILD_TO) *.dll $(INSTALL_TO))
@$(eval RUN = wineconsole clibasic.exe)
@$(eval CLEAN = rm -f clibasic.exe *.dll)
endif
@true

else

C = gcc

CFLAGS = $(BASE_CFLAGS) -Ilib -s -D_CRT_NONSTDC_NO_WARNINGS

BUILD64 = xcopy lib\win64\*.dll . /Y && $(C) clibasic.c -m64 $(CFLAGS) -Llib\win64 -DB64 -o clibasic.exe
BUILD32 = xcopy lib\win32\*.dll . /Y && $(C) clibasic.c -m32 $(CFLAGS) -Llib\win32 -DB32 -o clibasic.exe
BUILD_TO = clibasic.exe
BUILD64 = xcopy lib\win64\*.dll . /Y && $(C) clibasic.c -m64 $(CFLAGS) -Llib\win64 -DB64 -o $(BUILD_TO)
BUILD32 = xcopy lib\win32\*.dll . /Y && $(C) clibasic.c -m32 $(CFLAGS) -Llib\win32 -DB32 -o $(BUILD_TO)

INSTALL_TO = "C:\\windows\\system32"
INSTALL = xcopy *.dll $(INSTALL_TO) /Y && xcopy $(BUILD_TO) $(INSTALL_TO) /Y

.PHONY: all all32 build build32 update run clean

all: clean build run

Expand All @@ -69,11 +114,19 @@ build32:
update:
git restore . & git pull

install:
$(BUILD64)
$(INSTALL)

install32:
$(BUILD32)
$(INSTALL)

run:
.\\clibasic.exe
.\\$(BUILD_TO)

clean:
del /q /f clibasic.exe *.dll
del /q /f $(BUILD_TO) *.dll

endif

4 changes: 3 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# tests if clibasic build on linux and windows successfully

make build clean
make -f Makefile-Cross build clean
make cross build clean

Loading

0 comments on commit 8fa2efd

Please sign in to comment.