2023-01-07 21:03:35 +00:00
|
|
|
# Copyright (c) 2023 Calvin Rose
|
2018-12-08 19:17:03 +00:00
|
|
|
#
|
2018-03-18 18:03:26 +00:00
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
# of this software and associated documentation files (the "Software"), to
|
|
|
|
# deal in the Software without restriction, including without limitation the
|
|
|
|
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
# sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
# furnished to do so, subject to the following conditions:
|
2018-12-08 19:17:03 +00:00
|
|
|
#
|
2018-03-18 18:03:26 +00:00
|
|
|
# The above copyright notice and this permission notice shall be included in
|
|
|
|
# all copies or substantial portions of the Software.
|
2018-12-08 19:17:03 +00:00
|
|
|
#
|
2018-03-18 18:03:26 +00:00
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
# IN THE SOFTWARE.
|
|
|
|
|
|
|
|
################################
|
|
|
|
##### Set global variables #####
|
|
|
|
################################
|
2022-10-23 18:11:07 +00:00
|
|
|
sinclude config.mk
|
2018-09-10 18:21:08 +00:00
|
|
|
PREFIX?=/usr/local
|
2018-05-15 01:52:51 +00:00
|
|
|
|
2022-10-24 14:49:51 +00:00
|
|
|
JANETCONF_HEADER?=src/conf/janetconf.h
|
2019-10-02 04:33:15 +00:00
|
|
|
INCLUDEDIR?=$(PREFIX)/include
|
|
|
|
BINDIR?=$(PREFIX)/bin
|
|
|
|
LIBDIR?=$(PREFIX)/lib
|
2021-02-28 01:50:31 +00:00
|
|
|
JANET_BUILD?="\"$(shell git log --pretty=format:'%h' -n 1 2> /dev/null || echo local)\""
|
2019-11-27 20:52:20 +00:00
|
|
|
CLIBS=-lm -lpthread
|
2018-12-09 22:37:11 +00:00
|
|
|
JANET_TARGET=build/janet
|
2023-05-11 05:33:14 +00:00
|
|
|
JANET_BOOT=build/janet_boot
|
2023-01-21 20:31:48 +00:00
|
|
|
JANET_IMPORT_LIB=build/janet.lib
|
2023-12-09 16:11:15 +00:00
|
|
|
JANET_LIBRARY_IMPORT_LIB=build/libjanet.lib
|
2018-12-09 22:37:11 +00:00
|
|
|
JANET_LIBRARY=build/libjanet.so
|
2019-05-16 02:38:18 +00:00
|
|
|
JANET_STATIC_LIBRARY=build/libjanet.a
|
2019-10-02 04:33:15 +00:00
|
|
|
JANET_PATH?=$(LIBDIR)/janet
|
2020-07-18 18:09:53 +00:00
|
|
|
JANET_MANPATH?=$(PREFIX)/share/man/man1/
|
|
|
|
JANET_PKG_CONFIG_PATH?=$(LIBDIR)/pkgconfig
|
2021-05-30 14:14:34 +00:00
|
|
|
JANET_DIST_DIR?=janet-dist
|
2023-06-01 12:21:15 +00:00
|
|
|
JANET_BOOT_FLAGS:=. JANET_PATH '$(JANET_PATH)'
|
|
|
|
JANET_TARGET_OBJECTS=build/janet.o build/shell.o
|
2021-09-17 21:38:11 +00:00
|
|
|
JPM_TAG?=master
|
2023-11-02 13:51:42 +00:00
|
|
|
HAS_SHARED?=1
|
2018-03-18 18:03:26 +00:00
|
|
|
DEBUGGER=gdb
|
2020-04-04 18:44:21 +00:00
|
|
|
SONAME_SETTER=-Wl,-soname,
|
2018-03-18 18:03:26 +00:00
|
|
|
|
2020-06-27 17:39:16 +00:00
|
|
|
# For cross compilation
|
|
|
|
HOSTCC?=$(CC)
|
|
|
|
HOSTAR?=$(AR)
|
2023-07-28 02:37:26 +00:00
|
|
|
# Symbols are (optionally) removed later, keep -g as default!
|
|
|
|
CFLAGS?=-O2 -g
|
2023-05-17 02:10:18 +00:00
|
|
|
LDFLAGS?=-rdynamic
|
2023-12-09 16:11:15 +00:00
|
|
|
LIBJANET_LDFLAGS?=$(LD_FLAGS)
|
2023-05-11 05:33:14 +00:00
|
|
|
RUN:=$(RUN)
|
2020-06-27 17:39:16 +00:00
|
|
|
|
2023-05-17 02:10:18 +00:00
|
|
|
COMMON_CFLAGS:=-std=c99 -Wall -Wextra -Isrc/include -Isrc/conf -fvisibility=hidden -fPIC
|
2023-05-29 21:10:48 +00:00
|
|
|
BOOT_CFLAGS:=-DJANET_BOOTSTRAP -DJANET_BUILD=$(JANET_BUILD) -O0 $(COMMON_CFLAGS) -g
|
2020-06-27 17:39:16 +00:00
|
|
|
BUILD_CFLAGS:=$(CFLAGS) $(COMMON_CFLAGS)
|
2019-02-18 18:46:35 +00:00
|
|
|
|
2023-06-01 12:21:15 +00:00
|
|
|
# Disable amalgamated build
|
|
|
|
ifeq ($(JANET_NO_AMALG), 1)
|
|
|
|
JANET_TARGET_OBJECTS+=$(patsubst src/%.c,build/%.bin.o,$(JANET_CORE_SOURCES))
|
|
|
|
JANET_BOOT_FLAGS+=image-only
|
|
|
|
endif
|
|
|
|
|
2019-09-18 17:20:59 +00:00
|
|
|
# For installation
|
2020-03-04 00:03:44 +00:00
|
|
|
LDCONFIG:=ldconfig "$(LIBDIR)"
|
2019-09-18 17:20:59 +00:00
|
|
|
|
2019-03-03 23:55:10 +00:00
|
|
|
# Check OS
|
2023-05-11 05:33:14 +00:00
|
|
|
UNAME?=$(shell uname -s)
|
2018-12-08 19:17:03 +00:00
|
|
|
ifeq ($(UNAME), Darwin)
|
2019-02-16 00:02:14 +00:00
|
|
|
CLIBS:=$(CLIBS) -ldl
|
2020-04-04 18:44:21 +00:00
|
|
|
SONAME_SETTER:=-Wl,-install_name,
|
2022-03-31 05:17:59 +00:00
|
|
|
JANET_LIBRARY=build/libjanet.dylib
|
2020-03-04 00:13:25 +00:00
|
|
|
LDCONFIG:=true
|
2019-03-03 23:55:10 +00:00
|
|
|
else ifeq ($(UNAME), Linux)
|
2019-02-16 00:02:14 +00:00
|
|
|
CLIBS:=$(CLIBS) -lrt -ldl
|
2018-11-29 00:56:58 +00:00
|
|
|
endif
|
2021-10-21 04:56:40 +00:00
|
|
|
|
2019-03-04 17:16:49 +00:00
|
|
|
# For other unix likes, add flags here!
|
2019-10-02 04:33:15 +00:00
|
|
|
ifeq ($(UNAME), Haiku)
|
2020-03-04 00:13:25 +00:00
|
|
|
LDCONFIG:=true
|
2019-05-14 10:41:33 +00:00
|
|
|
LDFLAGS=-Wl,--export-dynamic
|
|
|
|
endif
|
2021-10-15 02:18:35 +00:00
|
|
|
# For Android (termux)
|
2021-10-21 05:23:23 +00:00
|
|
|
ifeq ($(UNAME), Linux) # uname on Darwin doesn't recognise -o
|
2021-10-15 02:18:35 +00:00
|
|
|
ifeq ($(shell uname -o), Android)
|
|
|
|
CLIBS:=$(CLIBS) -landroid-spawn
|
|
|
|
endif
|
2021-10-21 04:56:40 +00:00
|
|
|
endif
|
2018-05-22 02:08:16 +00:00
|
|
|
|
2023-01-21 16:37:34 +00:00
|
|
|
# Mingw
|
|
|
|
ifeq ($(findstring MINGW,$(UNAME)), MINGW)
|
|
|
|
CLIBS:=-lws2_32 -lpsapi -lwsock32
|
2023-01-21 20:31:48 +00:00
|
|
|
LDFLAGS:=-Wl,--out-implib,$(JANET_IMPORT_LIB)
|
2023-12-09 16:11:15 +00:00
|
|
|
LIBJANET_LDFLAGS:=-Wl,--out-implib,$(JANET_LIBRARY_IMPORT_LIB)
|
2023-05-11 05:33:14 +00:00
|
|
|
JANET_TARGET:=$(JANET_TARGET).exe
|
|
|
|
JANET_BOOT:=$(JANET_BOOT).exe
|
2023-01-21 16:37:34 +00:00
|
|
|
endif
|
|
|
|
|
2023-12-09 16:11:15 +00:00
|
|
|
|
2023-06-01 12:21:15 +00:00
|
|
|
$(shell mkdir -p build/core build/c build/boot build/mainclient)
|
2023-11-02 13:51:42 +00:00
|
|
|
all: $(JANET_TARGET) $(JANET_STATIC_LIBRARY) build/janet.h
|
|
|
|
ifeq ($(HAS_SHARED), 1)
|
|
|
|
all: $(JANET_LIBRARY)
|
|
|
|
endif
|
2018-12-09 22:37:11 +00:00
|
|
|
|
2019-03-23 17:50:50 +00:00
|
|
|
######################
|
|
|
|
##### Name Files #####
|
|
|
|
######################
|
2018-03-18 18:03:26 +00:00
|
|
|
|
2022-10-24 14:49:51 +00:00
|
|
|
JANET_HEADERS=src/include/janet.h $(JANETCONF_HEADER)
|
2019-03-23 17:50:50 +00:00
|
|
|
|
2019-12-31 00:06:15 +00:00
|
|
|
JANET_LOCAL_HEADERS=src/core/features.h \
|
|
|
|
src/core/util.h \
|
2019-03-23 17:50:50 +00:00
|
|
|
src/core/state.h \
|
|
|
|
src/core/gc.h \
|
|
|
|
src/core/vector.h \
|
|
|
|
src/core/fiber.h \
|
|
|
|
src/core/regalloc.h \
|
|
|
|
src/core/compile.h \
|
|
|
|
src/core/emit.h \
|
|
|
|
src/core/symcache.h
|
|
|
|
|
|
|
|
JANET_CORE_SOURCES=src/core/abstract.c \
|
|
|
|
src/core/array.c \
|
|
|
|
src/core/asm.c \
|
|
|
|
src/core/buffer.c \
|
|
|
|
src/core/bytecode.c \
|
|
|
|
src/core/capi.c \
|
|
|
|
src/core/cfuns.c \
|
|
|
|
src/core/compile.c \
|
|
|
|
src/core/corelib.c \
|
|
|
|
src/core/debug.c \
|
|
|
|
src/core/emit.c \
|
2020-05-28 15:39:40 +00:00
|
|
|
src/core/ev.c \
|
2022-06-06 23:54:17 +00:00
|
|
|
src/core/ffi.c \
|
2019-03-23 17:50:50 +00:00
|
|
|
src/core/fiber.c \
|
2024-08-11 22:50:58 +00:00
|
|
|
src/core/filewatch.c \
|
2019-03-23 17:50:50 +00:00
|
|
|
src/core/gc.c \
|
|
|
|
src/core/inttypes.c \
|
|
|
|
src/core/io.c \
|
|
|
|
src/core/marsh.c \
|
|
|
|
src/core/math.c \
|
2020-02-02 02:39:54 +00:00
|
|
|
src/core/net.c \
|
2019-03-23 17:50:50 +00:00
|
|
|
src/core/os.c \
|
|
|
|
src/core/parse.c \
|
|
|
|
src/core/peg.c \
|
|
|
|
src/core/pp.c \
|
|
|
|
src/core/regalloc.c \
|
|
|
|
src/core/run.c \
|
|
|
|
src/core/specials.c \
|
2021-07-17 01:59:03 +00:00
|
|
|
src/core/state.c \
|
2019-03-23 17:50:50 +00:00
|
|
|
src/core/string.c \
|
|
|
|
src/core/strtod.c \
|
|
|
|
src/core/struct.c \
|
|
|
|
src/core/symcache.c \
|
|
|
|
src/core/table.c \
|
|
|
|
src/core/tuple.c \
|
|
|
|
src/core/util.c \
|
|
|
|
src/core/value.c \
|
|
|
|
src/core/vector.c \
|
|
|
|
src/core/vm.c \
|
|
|
|
src/core/wrap.c
|
|
|
|
|
|
|
|
JANET_BOOT_SOURCES=src/boot/array_test.c \
|
|
|
|
src/boot/boot.c \
|
|
|
|
src/boot/buffer_test.c \
|
|
|
|
src/boot/number_test.c \
|
|
|
|
src/boot/system_test.c \
|
|
|
|
src/boot/table_test.c
|
2020-01-02 20:15:55 +00:00
|
|
|
JANET_BOOT_HEADERS=src/boot/tests.h
|
2019-03-23 17:50:50 +00:00
|
|
|
|
2020-01-29 05:38:52 +00:00
|
|
|
##########################################################
|
|
|
|
##### The bootstrap interpreter that creates janet.c #####
|
|
|
|
##########################################################
|
2019-02-08 05:44:30 +00:00
|
|
|
|
2020-01-29 05:38:52 +00:00
|
|
|
JANET_BOOT_OBJECTS=$(patsubst src/%.c,build/%.boot.o,$(JANET_CORE_SOURCES) $(JANET_BOOT_SOURCES))
|
2019-02-08 05:44:30 +00:00
|
|
|
|
2020-01-02 20:15:55 +00:00
|
|
|
$(JANET_BOOT_OBJECTS): $(JANET_BOOT_HEADERS)
|
|
|
|
|
2020-05-30 16:29:58 +00:00
|
|
|
build/%.boot.o: src/%.c $(JANET_HEADERS) $(JANET_LOCAL_HEADERS) Makefile
|
2020-02-26 02:02:03 +00:00
|
|
|
$(CC) $(BOOT_CFLAGS) -o $@ -c $<
|
2019-02-08 05:44:30 +00:00
|
|
|
|
2023-05-11 05:33:14 +00:00
|
|
|
$(JANET_BOOT): $(JANET_BOOT_OBJECTS)
|
2020-02-26 02:02:03 +00:00
|
|
|
$(CC) $(BOOT_CFLAGS) -o $@ $(JANET_BOOT_OBJECTS) $(CLIBS)
|
2019-02-08 05:44:30 +00:00
|
|
|
|
|
|
|
# Now the reason we bootstrap in the first place
|
2023-05-11 05:33:14 +00:00
|
|
|
build/c/janet.c: $(JANET_BOOT) src/boot/boot.janet
|
2023-06-01 12:21:15 +00:00
|
|
|
$(RUN) $(JANET_BOOT) $(JANET_BOOT_FLAGS) > $@
|
2020-09-06 16:04:07 +00:00
|
|
|
cksum $@
|
2018-12-06 19:30:11 +00:00
|
|
|
|
2023-06-01 12:21:15 +00:00
|
|
|
##################
|
|
|
|
##### Quicky #####
|
|
|
|
##################
|
|
|
|
|
|
|
|
build/%.bin.o: src/%.c $(JANET_HEADERS) $(JANET_LOCAL_HEADERS) Makefile
|
|
|
|
$(HOSTCC) $(BUILD_CFLAGS) -o $@ -c $<
|
|
|
|
|
2019-01-24 05:15:58 +00:00
|
|
|
########################
|
|
|
|
##### Amalgamation #####
|
|
|
|
########################
|
|
|
|
|
2022-03-31 05:17:59 +00:00
|
|
|
ifeq ($(UNAME), Darwin)
|
2024-06-15 12:11:48 +00:00
|
|
|
SONAME=libjanet.1.35.dylib
|
2022-03-31 05:17:59 +00:00
|
|
|
else
|
2024-06-15 12:11:48 +00:00
|
|
|
SONAME=libjanet.so.1.35
|
2022-03-31 05:17:59 +00:00
|
|
|
endif
|
2020-04-04 18:09:59 +00:00
|
|
|
|
2021-01-31 15:59:53 +00:00
|
|
|
build/c/shell.c: src/mainclient/shell.c
|
2020-01-29 05:38:52 +00:00
|
|
|
cp $< $@
|
2019-10-30 00:18:44 +00:00
|
|
|
|
2022-10-24 14:49:51 +00:00
|
|
|
build/janet.h: $(JANET_TARGET) src/include/janet.h $(JANETCONF_HEADER)
|
2023-05-11 05:33:14 +00:00
|
|
|
$(RUN) ./$(JANET_TARGET) tools/patch-header.janet src/include/janet.h $(JANETCONF_HEADER) $@
|
2019-01-24 05:15:58 +00:00
|
|
|
|
2022-10-24 14:49:51 +00:00
|
|
|
build/janetconf.h: $(JANETCONF_HEADER)
|
2019-11-09 02:33:26 +00:00
|
|
|
cp $< $@
|
|
|
|
|
2022-10-24 14:49:51 +00:00
|
|
|
build/janet.o: build/c/janet.c $(JANETCONF_HEADER) src/include/janet.h
|
2021-01-31 15:59:53 +00:00
|
|
|
$(HOSTCC) $(BUILD_CFLAGS) -c $< -o $@
|
2020-01-29 05:38:52 +00:00
|
|
|
|
2022-10-24 14:49:51 +00:00
|
|
|
build/shell.o: build/c/shell.c $(JANETCONF_HEADER) src/include/janet.h
|
2021-01-31 15:59:53 +00:00
|
|
|
$(HOSTCC) $(BUILD_CFLAGS) -c $< -o $@
|
2020-01-29 05:38:52 +00:00
|
|
|
|
2023-06-01 12:21:15 +00:00
|
|
|
$(JANET_TARGET): $(JANET_TARGET_OBJECTS)
|
2020-06-27 17:39:16 +00:00
|
|
|
$(HOSTCC) $(LDFLAGS) $(BUILD_CFLAGS) -o $@ $^ $(CLIBS)
|
2020-01-29 05:38:52 +00:00
|
|
|
|
2023-06-01 12:21:15 +00:00
|
|
|
$(JANET_LIBRARY): $(JANET_TARGET_OBJECTS)
|
2023-12-09 16:11:15 +00:00
|
|
|
$(HOSTCC) $(LIBJANET_LDFLAGS) $(BUILD_CFLAGS) $(SONAME_SETTER)$(SONAME) -shared -o $@ $^ $(CLIBS)
|
2020-01-29 05:38:52 +00:00
|
|
|
|
2023-06-01 12:21:15 +00:00
|
|
|
$(JANET_STATIC_LIBRARY): $(JANET_TARGET_OBJECTS)
|
2020-06-27 17:39:16 +00:00
|
|
|
$(HOSTAR) rcs $@ $^
|
2020-01-29 05:38:52 +00:00
|
|
|
|
2018-03-18 18:03:26 +00:00
|
|
|
###################
|
|
|
|
##### Testing #####
|
|
|
|
###################
|
|
|
|
|
2020-06-27 17:39:16 +00:00
|
|
|
# Testing assumes HOSTCC=CC
|
|
|
|
|
2018-12-02 20:29:21 +00:00
|
|
|
TEST_SCRIPTS=$(wildcard test/suite*.janet)
|
2018-11-18 18:56:27 +00:00
|
|
|
|
2018-09-06 02:18:42 +00:00
|
|
|
repl: $(JANET_TARGET)
|
2023-05-11 05:33:14 +00:00
|
|
|
$(RUN) ./$(JANET_TARGET)
|
2018-03-18 18:03:26 +00:00
|
|
|
|
2018-09-06 02:18:42 +00:00
|
|
|
debug: $(JANET_TARGET)
|
|
|
|
$(DEBUGGER) ./$(JANET_TARGET)
|
2018-03-18 18:03:26 +00:00
|
|
|
|
2023-05-16 17:44:31 +00:00
|
|
|
VALGRIND_COMMAND=valgrind --leak-check=full --quiet
|
2019-01-06 17:32:44 +00:00
|
|
|
|
2018-09-06 02:18:42 +00:00
|
|
|
valgrind: $(JANET_TARGET)
|
2019-01-06 17:32:44 +00:00
|
|
|
$(VALGRIND_COMMAND) ./$(JANET_TARGET)
|
2018-03-18 18:03:26 +00:00
|
|
|
|
2018-11-18 18:56:27 +00:00
|
|
|
test: $(JANET_TARGET) $(TEST_PROGRAMS)
|
2023-05-11 05:33:14 +00:00
|
|
|
for f in test/suite*.janet; do $(RUN) ./$(JANET_TARGET) "$$f" || exit; done
|
|
|
|
for f in examples/*.janet; do $(RUN) ./$(JANET_TARGET) -k "$$f"; done
|
2018-12-02 20:29:21 +00:00
|
|
|
|
2018-11-18 18:56:27 +00:00
|
|
|
valtest: $(JANET_TARGET) $(TEST_PROGRAMS)
|
2019-03-13 18:50:25 +00:00
|
|
|
for f in test/suite*.janet; do $(VALGRIND_COMMAND) ./$(JANET_TARGET) "$$f" || exit; done
|
2019-12-08 18:39:37 +00:00
|
|
|
for f in examples/*.janet; do ./$(JANET_TARGET) -k "$$f"; done
|
2018-03-18 18:03:26 +00:00
|
|
|
|
2019-01-07 02:49:24 +00:00
|
|
|
callgrind: $(JANET_TARGET)
|
2019-03-13 18:50:25 +00:00
|
|
|
for f in test/suite*.janet; do valgrind --tool=callgrind ./$(JANET_TARGET) "$$f" || exit; done
|
2019-01-07 02:49:24 +00:00
|
|
|
|
2018-12-09 22:37:11 +00:00
|
|
|
########################
|
|
|
|
##### Distribution #####
|
|
|
|
########################
|
2018-03-18 18:03:26 +00:00
|
|
|
|
2018-12-09 22:37:11 +00:00
|
|
|
dist: build/janet-dist.tar.gz
|
2018-12-08 21:17:34 +00:00
|
|
|
|
2019-03-22 18:31:20 +00:00
|
|
|
build/janet-%.tar.gz: $(JANET_TARGET) \
|
2020-11-17 15:48:31 +00:00
|
|
|
build/janet.h \
|
2023-11-02 13:51:42 +00:00
|
|
|
janet.1 LICENSE CONTRIBUTING.md $(JANET_STATIC_LIBRARY) \
|
2021-07-16 01:49:41 +00:00
|
|
|
README.md build/c/janet.c build/c/shell.c
|
2021-03-20 15:53:51 +00:00
|
|
|
mkdir -p build/$(JANET_DIST_DIR)/bin
|
|
|
|
cp $(JANET_TARGET) build/$(JANET_DIST_DIR)/bin/
|
2023-07-28 02:37:26 +00:00
|
|
|
strip -x -S 'build/$(JANET_DIST_DIR)/bin/janet'
|
2021-03-20 15:53:51 +00:00
|
|
|
mkdir -p build/$(JANET_DIST_DIR)/include
|
|
|
|
cp build/janet.h build/$(JANET_DIST_DIR)/include/
|
|
|
|
mkdir -p build/$(JANET_DIST_DIR)/lib/
|
2023-11-02 13:51:42 +00:00
|
|
|
cp $(JANET_STATIC_LIBRARY) build/$(JANET_DIST_DIR)/lib/
|
|
|
|
cp $(JANET_LIBRARY) build/$(JANET_DIST_DIR)/lib/ || true
|
2021-03-20 15:53:51 +00:00
|
|
|
mkdir -p build/$(JANET_DIST_DIR)/man/man1/
|
2022-03-21 22:47:37 +00:00
|
|
|
cp janet.1 build/$(JANET_DIST_DIR)/man/man1/janet.1
|
2021-03-20 15:53:51 +00:00
|
|
|
mkdir -p build/$(JANET_DIST_DIR)/src/
|
|
|
|
cp build/c/janet.c build/c/shell.c build/$(JANET_DIST_DIR)/src/
|
2021-05-30 14:14:34 +00:00
|
|
|
cp CONTRIBUTING.md LICENSE README.md build/$(JANET_DIST_DIR)/
|
|
|
|
cd build && tar -czvf ../$@ ./$(JANET_DIST_DIR)
|
2023-11-02 13:51:42 +00:00
|
|
|
ifeq ($(HAS_SHARED), 1)
|
|
|
|
build/janet-%.tar.gz: $(JANET_LIBRARY)
|
|
|
|
endif
|
2018-12-17 06:41:11 +00:00
|
|
|
|
2021-05-30 21:44:37 +00:00
|
|
|
#########################
|
|
|
|
##### Documentation #####
|
|
|
|
#########################
|
|
|
|
|
|
|
|
docs: build/doc.html
|
|
|
|
|
|
|
|
build/doc.html: $(JANET_TARGET) tools/gendoc.janet
|
2023-05-11 05:33:14 +00:00
|
|
|
$(RUN) $(JANET_TARGET) tools/gendoc.janet > build/doc.html
|
2021-05-30 21:44:37 +00:00
|
|
|
|
2019-05-24 23:36:07 +00:00
|
|
|
########################
|
|
|
|
##### Installation #####
|
|
|
|
########################
|
2018-03-18 18:03:26 +00:00
|
|
|
|
2020-03-03 23:44:44 +00:00
|
|
|
.INTERMEDIATE: build/janet.pc
|
2019-08-27 23:10:03 +00:00
|
|
|
build/janet.pc: $(JANET_TARGET)
|
2019-05-24 23:36:07 +00:00
|
|
|
echo 'prefix=$(PREFIX)' > $@
|
|
|
|
echo 'exec_prefix=$${prefix}' >> $@
|
|
|
|
echo 'includedir=$(INCLUDEDIR)/janet' >> $@
|
|
|
|
echo 'libdir=$(LIBDIR)' >> $@
|
|
|
|
echo "" >> $@
|
|
|
|
echo "Name: janet" >> $@
|
|
|
|
echo "Url: https://janet-lang.org" >> $@
|
|
|
|
echo "Description: Library for the Janet programming language." >> $@
|
2023-05-11 05:33:14 +00:00
|
|
|
$(RUN) $(JANET_TARGET) -e '(print "Version: " janet/version)' >> $@
|
2019-05-24 23:36:07 +00:00
|
|
|
echo 'Cflags: -I$${includedir}' >> $@
|
2020-04-04 18:09:59 +00:00
|
|
|
echo 'Libs: -L$${libdir} -ljanet' >> $@
|
2019-05-24 23:36:07 +00:00
|
|
|
echo 'Libs.private: $(CLIBS)' >> $@
|
|
|
|
|
2021-07-16 01:49:41 +00:00
|
|
|
install: $(JANET_TARGET) $(JANET_LIBRARY) $(JANET_STATIC_LIBRARY) build/janet.pc build/janet.h
|
2020-03-03 23:44:44 +00:00
|
|
|
mkdir -p '$(DESTDIR)$(BINDIR)'
|
|
|
|
cp $(JANET_TARGET) '$(DESTDIR)$(BINDIR)/janet'
|
2023-07-01 10:33:38 +00:00
|
|
|
strip -x -S '$(DESTDIR)$(BINDIR)/janet'
|
2020-03-03 23:44:44 +00:00
|
|
|
mkdir -p '$(DESTDIR)$(INCLUDEDIR)/janet'
|
2020-11-17 15:48:31 +00:00
|
|
|
cp -r build/janet.h '$(DESTDIR)$(INCLUDEDIR)/janet'
|
2023-05-27 21:22:11 +00:00
|
|
|
ln -sf ./janet/janet.h '$(DESTDIR)$(INCLUDEDIR)/janet.h'
|
2020-03-03 23:44:44 +00:00
|
|
|
mkdir -p '$(DESTDIR)$(JANET_PATH)'
|
|
|
|
mkdir -p '$(DESTDIR)$(LIBDIR)'
|
2022-03-31 05:17:59 +00:00
|
|
|
if test $(UNAME) = Darwin ; then \
|
|
|
|
cp $(JANET_LIBRARY) '$(DESTDIR)$(LIBDIR)/libjanet.$(shell $(JANET_TARGET) -e '(print janet/version)').dylib' ; \
|
|
|
|
ln -sf $(SONAME) '$(DESTDIR)$(LIBDIR)/libjanet.dylib' ; \
|
|
|
|
ln -sf libjanet.$(shell $(JANET_TARGET) -e '(print janet/version)').dylib $(DESTDIR)$(LIBDIR)/$(SONAME) ; \
|
|
|
|
else \
|
|
|
|
cp $(JANET_LIBRARY) '$(DESTDIR)$(LIBDIR)/libjanet.so.$(shell $(JANET_TARGET) -e '(print janet/version)')' ; \
|
|
|
|
ln -sf $(SONAME) '$(DESTDIR)$(LIBDIR)/libjanet.so' ; \
|
|
|
|
ln -sf libjanet.so.$(shell $(JANET_TARGET) -e '(print janet/version)') $(DESTDIR)$(LIBDIR)/$(SONAME) ; \
|
|
|
|
fi
|
2020-03-03 23:44:44 +00:00
|
|
|
cp $(JANET_STATIC_LIBRARY) '$(DESTDIR)$(LIBDIR)/libjanet.a'
|
2020-07-18 18:09:53 +00:00
|
|
|
mkdir -p '$(DESTDIR)$(JANET_MANPATH)'
|
|
|
|
cp janet.1 '$(DESTDIR)$(JANET_MANPATH)'
|
|
|
|
mkdir -p '$(DESTDIR)$(JANET_PKG_CONFIG_PATH)'
|
|
|
|
cp build/janet.pc '$(DESTDIR)$(JANET_PKG_CONFIG_PATH)/janet.pc'
|
2023-01-21 20:31:48 +00:00
|
|
|
cp '$(JANET_IMPORT_LIB)' '$(DESTDIR)$(LIBDIR)' || echo 'no import lib to install (mingw only)'
|
2023-12-09 16:11:15 +00:00
|
|
|
cp '$(JANET_LIBRARY_IMPORT_LIB)' '$(DESTDIR)$(LIBDIR)' || echo 'no import lib to install (mingw only)'
|
2022-07-20 16:19:09 +00:00
|
|
|
[ -z '$(DESTDIR)' ] && $(LDCONFIG) || echo "You can ignore this error for non-Linux systems or local installs"
|
2018-03-18 18:03:26 +00:00
|
|
|
|
2021-08-29 16:15:15 +00:00
|
|
|
install-jpm-git: $(JANET_TARGET)
|
|
|
|
mkdir -p build
|
|
|
|
rm -rf build/jpm
|
2021-09-17 21:38:11 +00:00
|
|
|
git clone --depth=1 --branch='$(JPM_TAG)' https://github.com/janet-lang/jpm.git build/jpm
|
2021-09-16 23:36:29 +00:00
|
|
|
cd build/jpm && PREFIX='$(PREFIX)' \
|
|
|
|
DESTDIR=$(DESTDIR) \
|
|
|
|
JANET_MANPATH='$(JANET_MANPATH)' \
|
|
|
|
JANET_HEADERPATH='$(INCLUDEDIR)/janet' \
|
|
|
|
JANET_BINPATH='$(BINDIR)' \
|
|
|
|
JANET_LIBPATH='$(LIBDIR)' \
|
2023-05-11 05:33:14 +00:00
|
|
|
$(RUN) ../../$(JANET_TARGET) ./bootstrap.janet
|
2021-08-29 16:15:15 +00:00
|
|
|
|
2019-06-24 12:21:07 +00:00
|
|
|
uninstall:
|
2020-03-03 23:44:44 +00:00
|
|
|
-rm '$(DESTDIR)$(BINDIR)/janet'
|
|
|
|
-rm -rf '$(DESTDIR)$(INCLUDEDIR)/janet'
|
2022-04-23 03:29:12 +00:00
|
|
|
-rm -rf '$(DESTDIR)$(INCLUDEDIR)/janet.h'
|
2020-03-03 23:44:44 +00:00
|
|
|
-rm -rf '$(DESTDIR)$(LIBDIR)'/libjanet.*
|
2020-07-18 18:09:53 +00:00
|
|
|
-rm '$(DESTDIR)$(JANET_PKG_CONFIG_PATH)/janet.pc'
|
|
|
|
-rm '$(DESTDIR)$(JANET_MANPATH)/janet.1'
|
2020-03-03 23:44:44 +00:00
|
|
|
# -rm -rf '$(DESTDIR)$(JANET_PATH)'/* - err on the side of correctness here
|
2019-06-24 12:21:07 +00:00
|
|
|
|
2019-05-24 23:36:07 +00:00
|
|
|
#################
|
|
|
|
##### Other #####
|
|
|
|
#################
|
|
|
|
|
|
|
|
format:
|
2023-06-25 22:26:36 +00:00
|
|
|
sh tools/format.sh
|
2019-05-24 23:36:07 +00:00
|
|
|
|
|
|
|
grammar: build/janet.tmLanguage
|
|
|
|
build/janet.tmLanguage: tools/tm_lang_gen.janet $(JANET_TARGET)
|
2023-05-11 05:33:14 +00:00
|
|
|
$(RUN) $(JANET_TARGET) $< > $@
|
2019-05-24 23:36:07 +00:00
|
|
|
|
2020-08-01 18:13:58 +00:00
|
|
|
compile-commands:
|
2023-07-25 22:51:07 +00:00
|
|
|
# Requires pip install compiledb
|
2020-08-01 18:13:58 +00:00
|
|
|
compiledb make
|
|
|
|
|
2019-05-24 23:36:07 +00:00
|
|
|
clean:
|
|
|
|
-rm -rf build vgcore.* callgrind.*
|
2020-05-09 15:30:09 +00:00
|
|
|
-rm -rf test/install/build test/install/modpath
|
2019-05-24 23:36:07 +00:00
|
|
|
|
2019-03-03 19:48:17 +00:00
|
|
|
test-install:
|
2021-07-16 01:49:41 +00:00
|
|
|
echo "JPM has been removed from default install."
|
2019-03-03 19:48:17 +00:00
|
|
|
|
2020-05-15 06:51:21 +00:00
|
|
|
help:
|
|
|
|
@echo
|
|
|
|
@echo 'Janet: A Dynamic Language & Bytecode VM'
|
|
|
|
@echo
|
|
|
|
@echo Usage:
|
|
|
|
@echo ' make Build Janet'
|
|
|
|
@echo ' make repl Start a REPL from a built Janet'
|
|
|
|
@echo
|
|
|
|
@echo ' make test Test a built Janet'
|
|
|
|
@echo ' make valgrind Assess Janet with Valgrind'
|
|
|
|
@echo ' make callgrind Assess Janet with Valgrind, using Callgrind'
|
2020-05-15 22:59:05 +00:00
|
|
|
@echo ' make valtest Run the test suite with Valgrind to check for memory leaks'
|
2020-05-15 06:51:21 +00:00
|
|
|
@echo ' make dist Create a distribution tarball'
|
|
|
|
@echo ' make docs Generate documentation'
|
2020-05-15 22:59:05 +00:00
|
|
|
@echo ' make debug Run janet with GDB or LLDB'
|
2020-05-15 06:51:21 +00:00
|
|
|
@echo ' make install Install into the current filesystem'
|
|
|
|
@echo ' make uninstall Uninstall from the current filesystem'
|
|
|
|
@echo ' make clean Clean intermediate build artifacts'
|
|
|
|
@echo " make format Format Janet's own source files"
|
|
|
|
@echo ' make grammar Generate a TextMate language grammar'
|
|
|
|
@echo
|
|
|
|
|
2022-06-17 22:24:52 +00:00
|
|
|
.PHONY: clean install repl debug valgrind test \
|
2020-08-01 18:13:58 +00:00
|
|
|
valtest dist uninstall docs grammar format help compile-commands
|