aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile44
1 files changed, 19 insertions, 25 deletions
diff --git a/Makefile b/Makefile
index bd4bc1dc..4d618928 100644
--- a/Makefile
+++ b/Makefile
@@ -83,17 +83,11 @@ O=-O3
# Note: older versions of Make have buggy behavior with hash marks inside strings, so this ugly code is necessary:
TOMO_VERSION=$(shell awk 'BEGIN{hashes=sprintf("%c%c",35,35)} $$1==hashes {print $$2; exit}' CHANGES.md)
GIT_VERSION=$(shell git log -1 --pretty=format:"%as_%h" 2>/dev/null || echo "unknown")
-CFLAGS+=$(CCONFIG) $(INCLUDE_DIRS) $(EXTRA) $(CWARN) $(G) $(O) $(OSFLAGS) $(LTO) \
+CFLAGS+=$(CCONFIG) $(INCLUDE_DIRS) $(EXTRA) $(CWARN) $(G) $(O) $(OSFLAGS) \
-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
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,12 +135,14 @@ $(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
- @$(ECHO) $(CC) $(CFLAGS_PLACEHOLDER) $(LDFLAGS) $^ $(LDLIBS) -o $@
- @$(CC) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@
+$(BUILD_DIR)/bin/$(EXE_FILE): $(STDLIB_OBJS) $(COMPILER_OBJS) build/gc/lib/libgc.a build/gmp/lib/libgmp.a build/unistring/lib/libunistring.a | $(BUILD_DIR)/bin deps
+ @$(ECHO) $(CC) $(CFLAGS_PLACEHOLDER) $(LDFLAGS) $(LDLIBS) $^ -o $@
+ @$(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) $^ -o $@
-$(BUILD_DIR)/lib/$(AR_FILE): $(STDLIB_OBJS) | $(BUILD_DIR)/lib
- ar -rcs $@ $^
+$(BUILD_DIR)/lib/$(AR_FILE): $(STDLIB_OBJS) build/gc/lib/libgc.a build/unistring/lib/libunistring.a build/gmp/lib/libgmp.a | $(BUILD_DIR)/lib
+ $(CC) -no-pie -r -nostdlib $^ -o libtomo.o
+ ar rcs $@ libtomo.o
+ rm -f libtomo.o
$(BUILD_DIR)/lib/tomo@$(TOMO_VERSION)/modules.ini: modules/core.ini modules/examples.ini | $(BUILD_DIR)/lib/tomo@$(TOMO_VERSION)
@cat $^ > $@
@@ -165,9 +161,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}
@@ -200,7 +196,7 @@ test: $(TESTS)
@printf '\033[32;7m ALL TESTS PASSED! \033[m\n'
clean:
- rm -rf build/* $(COMPILER_OBJS) $(STDLIB_OBJS) test/*.tm.testresult test/.build lib/*/.build examples/.build examples/*/.build
+ rm -rf build/tomo*/{bin,lib} $(COMPILER_OBJS) $(STDLIB_OBJS) test/*.tm.testresult test/.build lib/*/.build examples/.build examples/*/.build
%: %.md
pandoc --lua-filter=docs/.pandoc/bold-code.lua -s $< -t man -o $@
@@ -228,14 +224,12 @@ examples:
core-libs:
./local-tomo -L modules/core.ini
-deps:
- bash ./install_dependencies.sh
+deps: build/gc/lib/libgc.a build/unistring/lib/libgc.a build/gmp/lib/libgmp.a
-check-utilities: check-c-compiler
- @which debugedit 2>/dev/null >/dev/null \
- || printf '\033[33;1m%s\033[m\n' "I couldn't find 'debugedit' on your system! Try installing the package 'debugedit' with your package manager. (It's not required though)"
+build/gc/lib/libgc.a build/unistring/lib/libgc.a build/gmp/lib/libgmp.a:
+ $(MAKE) -C vendor
-install-files: build check-utilities
+install-files: build check-c-compiler
@if ! echo "$$PATH" | tr ':' '\n' | grep -qx "$(PREFIX)/bin"; then \
echo $$PATH; \
printf "\033[31;1mError: '$(PREFIX)/bin' is not in your \$$PATH variable!\033[m\n" >&2; \
@@ -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-c-compiler version