1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-28 11:09:54 +00:00
janet/Makefile

105 lines
3.1 KiB
Makefile
Raw Normal View History

# Copyright (c) 2017 Calvin Rose
#
# 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:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# 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.
2017-02-09 20:02:59 +00:00
################################
##### Set global variables #####
################################
PREFIX?=/usr/local
BINDIR=$(PREFIX)/bin
CFLAGS=-std=c99 -Wall -Wextra -I./src/include -g
CLIBS=-lm -ldl
2017-02-09 20:02:59 +00:00
PREFIX=/usr/local
DST_TARGET=dst
2017-11-01 21:53:43 +00:00
DEBUGGER=lldb
DST_C_LIBS=$(addprefix libs/,testlib.so)
DST_HEADERS=$(sort $(wildcard src/include/dst/*.h))
DST_LIBHEADERS=$(sort $(wildcard src/include/headerlibs/*.h))
DST_ALL_HEADERS=$(DST_HEADERS) $(DST_LIB_HEADERS)
DST_ASM_SOURCES=$(sort $(wildcard src/assembler/*.c))
DST_COMPILER_SOURCES=$(sort $(wildcard src/compiler/*.c))
DST_CONTEXT_SOURCES=$(sort $(wildcard src/context/*.c))
DST_CORE_SOURCES=$(sort $(wildcard src/core/*.c))
DST_MAINCLIENT_SOURCES=$(sort $(wildcard src/mainclient/*.c))
DST_PARSER_SOURCES=$(sort $(wildcard src/parser/*.c))
2017-07-15 16:21:06 +00:00
all: $(DST_TARGET)
########################################
##### The main interpreter program #####
########################################
DST_ALL_SOURCES=$(DST_ASM_SOURCES) \
$(DST_COMPILER_SOURCES) \
$(DST_CONTEXT_SOURCES) \
$(DST_CORE_SOURCES) \
$(DST_MAINCLIENT_SOURCES) \
$(DST_PARSER_SOURCES)
$(DST_TARGET): $(DST_ALL_SOURCES) $(DST_ALL_HEADERS)
$(CC) $(CFLAGS) -o $(DST_TARGET) $(DST_ALL_SOURCES) $(CLIBS)
2017-02-09 20:02:59 +00:00
#######################
##### C Libraries #####
#######################
%.so: %.c $(DST_HEADERS)
$(CC) $(CFLAGS) -DDST_LIB -shared -undefined dynamic_lookup -o $@ $<
###################
##### Testing #####
###################
2018-01-16 04:31:39 +00:00
repl: $(DST_TARGET)
@ ./$(DST_TARGET)
2017-02-09 20:02:59 +00:00
debug: $(DST_TARGET)
@ $(DEBUGGER) ./$(DST_TARGET)
2017-02-09 20:02:59 +00:00
valgrind: $(DST_TARGET)
@ valgrind --leak-check=full -v ./$(DST_TARGET)
2017-02-09 20:02:59 +00:00
test: $(DST_TARGET)
@ ./$(DST_TARGET) --gcinterval=0x10000 test/suite0.dst
valtest: $(DST_TARGET)
valgrind --leak-check=full -v ./$(DST_TARGET) dsttests/basic.dst
#################
##### Other #####
#################
clean:
rm $(DST_TARGET) || true
rm src/**/*.o || true
2017-03-22 04:27:18 +00:00
rm vgcore.* || true
install: $(DST_TARGET)
cp $(DST_TARGET) $(BINDIR)/dst
uninstall:
rm $(BINDIR)/dst
2018-01-16 04:31:39 +00:00
.PHONY: clean install repl debug valgrind test valtest install uninstall