aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-12-24 12:01:26 -0500
committerBruce Hill <bruce@bruce-hill.com>2025-12-24 12:01:26 -0500
commitf41b836b772ca8a4d3a5c824e2d5a6c90bb5e5ff (patch)
tree512cd6eeb21763ecb8d9bb67b2d22540e13129a7
parent7d09323e379c3ce1ac5c476a09b4409f90d3a33d (diff)
Add rules for building depdendencies in static builds
-rw-r--r--Makefile22
-rw-r--r--vendor/Makefile70
-rw-r--r--vendor/gmp-configure-fix.patch11
3 files changed, 89 insertions, 14 deletions
diff --git a/Makefile b/Makefile
index bd4bc1dc..be131bfb 100644
--- a/Makefile
+++ b/Makefile
@@ -87,13 +87,7 @@ CFLAGS+=$(CCONFIG) $(INCLUDE_DIRS) $(EXTRA) $(CWARN) $(G) $(O) $(OSFLAGS) $(LTO)
-DSUDO='"$(SUDO)"' -DDEFAULT_C_COMPILER='"$(DEFAULT_C_COMPILER)"' \
-DGIT_VERSION='"$(GIT_VERSION)"' -ffunction-sections -fdata-sections
CFLAGS_PLACEHOLDER="$$(printf '\033[2m<flags...>\033[m\n')"
-LDLIBS=-lgc -lm -lunistring -lgmp
-
-ifeq ($(OS),OpenBSD)
- LDLIBS += -lexecinfo
-else
- LDLIBS += -ldl
-endif
+LDLIBS=-lm ./vendor/build/lib/libgc.a ./vendor/build/lib/libgmp.a ./vendor/build/lib/libunistring.a
AR_FILE=libtomo@$(TOMO_VERSION).a
ifeq ($(OS),Darwin)
@@ -108,7 +102,7 @@ TESTS=$(patsubst test/%.tm,test/results/%.tm.testresult,$(wildcard test/[!_]*.tm
API_YAML=$(wildcard api/*.yaml)
API_MD=$(patsubst %.yaml,%.md,$(API_YAML))
-all: config.mk check-c-compiler check-libs build
+all: config.mk check-c-compiler build
@$(ECHO) "All done!"
BUILD_DIR=build/tomo@$(TOMO_VERSION)
@@ -141,7 +135,7 @@ $(BUILD_DIR)/man/%.gz: man/% | $(BUILD_DIR)/man/man1 $(BUILD_DIR)/man/man3
$(BUILD_DIR)/bin/tomo: $(BUILD_DIR)/bin/tomo@$(TOMO_VERSION) | $(BUILD_DIR)/bin
ln -sf tomo@$(TOMO_VERSION) $@
-$(BUILD_DIR)/bin/$(EXE_FILE): $(STDLIB_OBJS) $(COMPILER_OBJS) | $(BUILD_DIR)/bin
+$(BUILD_DIR)/bin/$(EXE_FILE): $(STDLIB_OBJS) $(COMPILER_OBJS) | $(BUILD_DIR)/bin deps
@$(ECHO) $(CC) $(CFLAGS_PLACEHOLDER) $(LDFLAGS) $^ $(LDLIBS) -o $@
@$(CC) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@
@@ -165,9 +159,9 @@ check-c-compiler:
@$(DEFAULT_C_COMPILER) -v 2>/dev/null >/dev/null \
|| { printf '\033[31;1m%s\033[m\n' "You have set your DEFAULT_C_COMPILER to $(DEFAULT_C_COMPILER) in your config.mk, but I can't run it!"; exit 1; }
-check-libs: check-c-compiler
- @echo 'int main() { return 0; }' | $(DEFAULT_C_COMPILER) $(LDFLAGS) $(LDLIBS) -x c - -o /dev/null 2>/dev/null >/dev/null \
- || { printf '\033[31;1m%s\033[m\n' "I expected to find the following libraries on your system, but I can't find them: $(LDLIBS)"; exit 1; }
+# check-libs: check-c-compiler | deps
+# @echo 'int main() { return 0; }' | $(DEFAULT_C_COMPILER) $(LDFLAGS) -x c - $(LDLIBS) -o /dev/null 2>/dev/null >/dev/null \
+# || { printf '\033[31;1m%s\033[m\n' "I expected to find the following libraries on your system, but I can't find them: $(LDLIBS)"; exit 1; }
tags:
ctags src/*.{c,h} src/stdlib/*.{c,h} src/compile/*.{c,h} src/parse/*.{c,h} src/formatter/*.{c,h}
@@ -229,7 +223,7 @@ core-libs:
./local-tomo -L modules/core.ini
deps:
- bash ./install_dependencies.sh
+ $(MAKE) -C vendor
check-utilities: check-c-compiler
@which debugedit 2>/dev/null >/dev/null \
@@ -263,4 +257,4 @@ uninstall:
endif
.SUFFIXES:
-.PHONY: all build clean install install-files uninstall test tags core-libs examples deps check-utilities check-c-compiler check-libs version
+.PHONY: all build clean install install-files uninstall test tags core-libs examples deps check-utilities check-c-compiler version
diff --git a/vendor/Makefile b/vendor/Makefile
new file mode 100644
index 00000000..19f5d5ae
--- /dev/null
+++ b/vendor/Makefile
@@ -0,0 +1,70 @@
+GMP_VERSION=6.3.0
+UNISTRING_VERSION=1.4.1
+GC_VERSION=8.2.8
+
+all: build-gc/include/gc.h build-gc/lib/libgc.a build-gmp/lib/libgmp.a build-unistring/lib/libunistring.a
+
+# Boehm-Demers-Weiser Garbage collector
+gc-$(GC_VERSION).tar.gz:
+ curl -LOJ 'https://hboehm.info/gc/gc_source/gc-$(GC_VERSION).tar.gz'
+
+gc-$(GC_VERSION)/configure: gc-$(GC_VERSION).tar.gz
+ tar xzfm $<
+
+gc-$(GC_VERSION)/Makefile: gc-$(GC_VERSION)/configure
+ prefix=$$(realpath ./build-gc); \
+ cd gc-$(GC_VERSION); \
+ ./configure \
+ --enable-static \
+ --disable-shared \
+ --prefix="$$prefix"; \
+
+build-gc/include/gc.h build-gc/lib/libgc.a: gc-$(GC_VERSION)/Makefile
+ cd gc-$(GC_VERSION); \
+ $(MAKE) -j install
+
+# GNU Multiple Precision Arithmetic Library
+gmp-$(GMP_VERSION).tar.xz:
+ curl -LOJ 'https://gmplib.org/download/gmp/gmp-$(GMP_VERSION).tar.xz'
+
+gmp-$(GMP_VERSION)/configure: gmp-$(GMP_VERSION).tar.xz
+ tar xJfm $<
+ cd gmp-$(GMP_VERSION) && patch -p0 -N < ../gmp-configure-fix.patch
+
+gmp-$(GMP_VERSION)/Makefile: gmp-$(GMP_VERSION)/configure
+ prefix=$$(realpath ./build-gmp); \
+ cd gmp-$(GMP_VERSION); \
+ ./configure \
+ --enable-static \
+ --disable-shared \
+ --prefix="$$prefix"
+
+build-gmp/lib/libgmp.a: gmp-$(GMP_VERSION)/Makefile
+ $(MAKE) -C gmp-$(GMP_VERSION) -j
+ $(MAKE) -C gmp-$(GMP_VERSION) check
+ $(MAKE) -C gmp-$(GMP_VERSION) install
+
+# Lib Unistring
+libunistring-$(UNISTRING_VERSION).tar.gz:
+ curl -LOJ 'https://ftp.gnu.org/gnu/libunistring/libunistring-$(UNISTRING_VERSION).tar.gz'
+
+libunistring-$(UNISTRING_VERSION)/configure: libunistring-$(UNISTRING_VERSION).tar.gz
+ tar xzfm $<
+
+libunistring-$(UNISTRING_VERSION)/Makefile: libunistring-$(UNISTRING_VERSION)/configure
+ prefix=$$(realpath ./build-unistring); \
+ cd libunistring-$(UNISTRING_VERSION); \
+ ./configure \
+ --enable-static \
+ --disable-shared \
+ --prefix="$$prefix"
+
+build-unistring/lib/libunistring.a: libunistring-$(UNISTRING_VERSION)/Makefile
+ $(MAKE) -C libunistring-$(UNISTRING_VERSION) -j
+ $(MAKE) -C libunistring-$(UNISTRING_VERSION) check
+ $(MAKE) -C libunistring-$(UNISTRING_VERSION) install
+
+clean:
+ rm -rf build-gc build-gmp build-unistring
+
+.PHONY: all clean
diff --git a/vendor/gmp-configure-fix.patch b/vendor/gmp-configure-fix.patch
new file mode 100644
index 00000000..4810d138
--- /dev/null
+++ b/vendor/gmp-configure-fix.patch
@@ -0,0 +1,11 @@
+--- configure 2025-12-23 23:16:03.232370246 -0500
++++ configure.fixed 2025-12-23 23:16:36.361925323 -0500
+@@ -6568,7 +6568,7 @@
+
+ #if defined (__GNUC__) && ! defined (__cplusplus)
+ typedef unsigned long long t1;typedef t1*t2;
+-void g(){}
++void g(...){}
+ void h(){}
+ static __inline__ t1 e(t2 rp,t2 up,int n,t1 v0)
+ {t1 c,x,r;int i;if(v0){c=1;for(i=1;i<n;i++){x=up[i];r=x+1;rp[i]=r;}}return c;}