sophuwu.site > termcalc
uwu man
sophuwu sophie@skisiel.com
Sun, 23 Jun 2024 16:00:12 +0200
commit

3757ef1ce3188ba16b560e38c4251259d5c04853

parent

60d2e780edd34affdfcf4b553a5abd0473af0831

9 files changed, 39 insertions(+), 10 deletions(-)

jump to
M MakefileMakefile

@@ -1,14 +1,12 @@

NAME := termcalc - -CXX := g++ -std=c++17 -SRC := src/*.cpp -TARGET := $(NAME) +CCFLAGS := -O3 +SRC := src/*.c -all: $(TARGET) +all: $(SRC) + @./zig-cc/zigcomp -$(TARGET): $(SRC) - $(CXX) -o $(TARGET) $(SRC) +zig: $(SRC) + $(CC) $(CCFLAGS) -o build/$(NAME).$(ZIGTARGET) $(SRC) clean: - rm $(TARGET) - + @echo "clean target is for compatibility with autotools"
M src/calc.csrc/calc.c

@@ -3,7 +3,6 @@ // This program is a simple calculator that takes in two numbers and an operator and returns the result of the operation.

#include "calc.h" - int checkInput(int argc) { if (argc != 4) print ("Usage: calc <num1> <op> <num2>\n\n\tOperators: + - x / %\n\tExample: calc 10 / 5\n"); return argc != 4;
A zig-cc/.gitignore

@@ -0,0 +1,2 @@

+!* +!./*
A zig-cc/ar

@@ -0,0 +1,2 @@

+#!/bin/bash +zig ar -target $ZIGTARGET $@
A zig-cc/cc

@@ -0,0 +1,2 @@

+#!/bin/bash +zig cc -target $ZIGTARGET $@
A zig-cc/cxx

@@ -0,0 +1,2 @@

+#!/bin/bash +zig c++ -target $ZIGTARGET $@
A zig-cc/ld

@@ -0,0 +1,2 @@

+#!/bin/bash +zig ld -target $ZIGTARGET $@
A zig-cc/ranlib

@@ -0,0 +1,2 @@

+#!/bin/bash +zig ranlib -target $ZIGTARGET $@
A zig-cc/zigcomp

@@ -0,0 +1,20 @@

+#!/bin/bash +declare -a ZIGTARGETS=( + 'x86_64-linux-musl' + 'aarch64-linux-musl' +) +#arm-linux-musleabihf ## 32 bit arm +ZIGBIN="$PWD/zig-cc" +export CC="$ZIGBIN/cc" +export CXX="$ZIGBIN/cxx" +export AR="$ZIGBIN/ar" +export LD="$ZIGBIN/ld" +export RANLIB="$ZIGBIN/ranlib" + +for Target in "${ZIGTARGETS[@]}"; +do + export ZIGTARGET=$Target + echo "============ $ZIGTARGET ============" + make zig +done +