aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-04-25 15:01:03 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-04-25 15:01:03 -0400
commit4740cc22f39f6eb1c056c07b66fec11d76340704 (patch)
tree563d98cc74e5bf8a3d017f5e2a31ce73cf893311
parentf422eccfe7d377b4e4ef6bffc4e5c9da16fca55b (diff)
Add makefile rules to check default C compiler and necessary libraries
-rw-r--r--Makefile24
1 files changed, 18 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index a2494966..75ed5ef7 100644
--- a/Makefile
+++ b/Makefile
@@ -77,7 +77,15 @@ 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 build/lib/$(LIB_FILE) build/lib/$(AR_FILE) build/bin/tomo
+all: config.mk check-c-compiler check-libs build/lib/$(LIB_FILE) build/lib/$(AR_FILE) build/bin/tomo
+
+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) $(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; }
build/bin/tomo: $(STDLIB_OBJS) $(COMPILER_OBJS)
@mkdir -p build/bin
@@ -148,10 +156,14 @@ deps:
bash ./install_dependencies.sh
check-utilities:
- @which objcopy 2>/dev/null >/dev/null || { printf '\033[31;1m%s\033[m\n' "I couldn't find 'objcopy' on your system! Try installing the package 'binutils' with your package manager."; exit 1; }
- @which patchelf 2>/dev/null >/dev/null || { printf '\033[31;1m%s\033[m\n' "I couldn't find 'patchelf' on your system! Try installing the package 'binutils' with your package manager."; exit 1; }
- @which nm 2>/dev/null >/dev/null || { printf '\033[31;1m%s\033[m\n' "I couldn't find 'nm' on your system! Try installing the package 'binutils' with your package manager."; exit 1; }
- @which awk 2>/dev/null >/dev/null || { printf '\033[31;1m%s\033[m\n' "I couldn't find 'awk' on your system! Try installing the package 'awk' with your package manager."; exit 1; }
+ @which objcopy 2>/dev/null >/dev/null \
+ || { printf '\033[31;1m%s\033[m\n' "I couldn't find 'objcopy' on your system! Try installing the package 'binutils' with your package manager."; exit 1; }
+ @which patchelf 2>/dev/null >/dev/null \
+ || { printf '\033[31;1m%s\033[m\n' "I couldn't find 'patchelf' on your system! Try installing the package 'binutils' with your package manager."; exit 1; }
+ @which nm 2>/dev/null >/dev/null \
+ || { printf '\033[31;1m%s\033[m\n' "I couldn't find 'nm' on your system! Try installing the package 'binutils' with your package manager."; exit 1; }
+ @which awk 2>/dev/null >/dev/null \
+ || { printf '\033[31;1m%s\033[m\n' "I couldn't find 'awk' on your system! Try installing the package 'awk' with your package manager."; exit 1; }
install-files: build/bin/tomo build/lib/$(LIB_FILE) build/lib/$(AR_FILE) check-utilities
@if ! echo "$$PATH" | tr ':' '\n' | grep -qx "$(PREFIX)/bin"; then \
@@ -181,4 +193,4 @@ uninstall:
endif
.SUFFIXES:
-.PHONY: all clean install install-files install-libs uninstall test tags examples deps check-utilities
+.PHONY: all clean install install-files install-libs uninstall test tags examples deps check-utilities check-c-compiler check-libs