Replace makefiles with a simple shell script

Build, bootstrap and test everything in one go. Put build artifacts in a
separate subdirectory which is emptied at the start of every build.
This commit is contained in:
Lassi Kortela 2019-08-09 14:56:16 +03:00
parent 82e09fa92b
commit 349a42510f
7 changed files with 57 additions and 214 deletions

8
.gitignore vendored
View File

@ -1,8 +1,2 @@
/*.o /build-*/
/*.do
/*.a
/*.da
/flisp
/llt/*.o
/llt/*.a
/flisp.boot.bak /flisp.boot.bak

View File

@ -1,58 +0,0 @@
FREEBSD-GE-10 = $(shell test `uname` = FreeBSD -a `uname -r | cut -d. -f1` -ge 10 && echo YES)
CC = $(if $(FREEBSD-GE-10),clang,gcc)
NAME = flisp
SRCS = $(NAME).c builtins.c string.c equalhash.c table.c iostream.c
OBJS = $(SRCS:%.c=%.o)
DOBJS = $(SRCS:%.c=%.do)
EXENAME = $(NAME)
LIBTARGET = lib$(NAME)
LLTDIR = llt
LLT = $(LLTDIR)/libllt.a
FLAGS = -falign-functions -Wall -Wno-strict-aliasing -I$(LLTDIR) $(CFLAGS) -DUSE_COMPUTED_GOTO
LIBFILES = $(LLT)
LIBS = $(LIBFILES) -lm
DEBUGFLAGS = -g -DDEBUG $(FLAGS)
SHIPFLAGS = -O2 -DNDEBUG $(FLAGS)
default: release test
test:
cd tests && ../flisp unittest.lsp
%.o: %.c
$(CC) $(SHIPFLAGS) -c $< -o $@
%.do: %.c
$(CC) $(DEBUGFLAGS) -c $< -o $@
flisp.o: flisp.c cvalues.c operators.c types.c flisp.h print.c read.c equal.c
flisp.do: flisp.c cvalues.c operators.c types.c flisp.h print.c read.c equal.c
flmain.o: flmain.c flisp.h
flmain.do: flmain.c flisp.h
$(LLT):
cd $(LLTDIR) && $(MAKE)
$(LIBTARGET).da: $(DOBJS)
rm -rf $@
ar rs $@ $(DOBJS)
$(LIBTARGET).a: $(OBJS)
rm -rf $@
ar rs $@ $(OBJS)
debug: $(DOBJS) $(LIBFILES) $(LIBTARGET).da flmain.do
$(CC) $(DEBUGFLAGS) $(DOBJS) flmain.do -o $(EXENAME) $(LIBS) $(LIBTARGET).da
$(MAKE) test
release: $(OBJS) $(LIBFILES) $(LIBTARGET).a flmain.o
$(CC) $(SHIPFLAGS) $(OBJS) flmain.o -o $(EXENAME) $(LIBS) $(LIBTARGET).a
clean:
rm -f *.o
rm -f *.do
rm -f $(EXENAME)
rm -f $(LIBTARGET).a
rm -f $(LIBTARGET).da

View File

@ -1,59 +0,0 @@
CC ?= gcc
CARBON_HEADERS ?= "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/Developer/Headers"
NAME = flisp
SRCS = $(NAME).c builtins.c string.c equalhash.c table.c iostream.c
OBJS = $(SRCS:%.c=%.o)
DOBJS = $(SRCS:%.c=%.do)
EXENAME = $(NAME)
LIBTARGET = lib$(NAME)
LLTDIR = llt
LLT = $(LLTDIR)/libllt.a
CONFIG = -DBITS64 -D__CPU__=686 -I$(CARBON_HEADERS)
FLAGS = -falign-functions -Wall -Wno-strict-aliasing -I$(LLTDIR) $(CFLAGS) -DUSE_COMPUTED_GOTO $(CONFIG)
LIBFILES = $(LLT)
LIBS = $(LIBFILES) -lm -framework ApplicationServices
DEBUGFLAGS = -g -DDEBUG $(FLAGS)
SHIPFLAGS = -O2 -DNDEBUG $(FLAGS)
default: release test
test:
cd tests && ../flisp unittest.lsp
%.o: %.c
$(CC) $(SHIPFLAGS) -c $< -o $@
%.do: %.c
$(CC) $(DEBUGFLAGS) -c $< -o $@
flisp.o: flisp.c cvalues.c types.c flisp.h print.c read.c equal.c
flisp.do: flisp.c cvalues.c types.c flisp.h print.c read.c equal.c
flmain.o: flmain.c flisp.h
flmain.do: flmain.c flisp.h
$(LLT):
cd $(LLTDIR) && make -f Makefile.macosx
$(LIBTARGET).da: $(DOBJS)
rm -rf $@
ar rs $@ $(DOBJS)
$(LIBTARGET).a: $(OBJS)
rm -rf $@
ar rs $@ $(OBJS)
debug: $(DOBJS) $(LIBFILES) $(LIBTARGET).da flmain.do
$(CC) $(DEBUGFLAGS) $(DOBJS) flmain.do -o $(EXENAME) $(LIBS) $(LIBTARGET).da
make test
release: $(OBJS) $(LIBFILES) $(LIBTARGET).a flmain.o
$(CC) $(SHIPFLAGS) $(OBJS) flmain.o -o $(EXENAME) $(LIBS) $(LIBTARGET).a
clean:
rm -f *.o
rm -f *.do
rm -f $(EXENAME)
rm -f $(LIBTARGET).a
rm -f $(LIBTARGET).da

View File

@ -1,14 +0,0 @@
#!/bin/sh
cp flisp.boot flisp.boot.bak
echo "Creating stage 0 boot file..."
#../../branches/interpreter/femtolisp/flisp mkboot0.lsp system.lsp compiler.lsp > flisp.boot.new
./flisp mkboot0.lsp system.lsp compiler.lsp > flisp.boot.new
mv flisp.boot.new flisp.boot
echo "Creating stage 1 boot file..."
./flisp mkboot1.lsp
echo "Testing..."
make test

View File

@ -1,37 +0,0 @@
FREEBSD-GE-10 = $(shell test `uname` = FreeBSD -a `uname -r | cut -d. -f1` -ge 10 && echo YES)
CC = $(if $(FREEBSD-GE-10),clang,gcc)
SRCS = bitvector.c hashing.c socket.c timefuncs.c ptrhash.c utf8.c ios.c \
dirpath.c htable.c bitvector-ops.c int2str.c dump.c random.c \
lltinit.c
OBJS = $(SRCS:%.c=%.o)
DOBJS = $(SRCS:%.c=%.do)
TARGET = libllt.a
FLAGS = -Wall -Wno-strict-aliasing $(CFLAGS)
LIBS =
DEBUGFLAGS = -g -DDEBUG $(FLAGS)
SHIPFLAGS = -O3 -DNDEBUG $(FLAGS)
default: release
%.o: %.c
$(CC) $(SHIPFLAGS) -c $< -o $@
%.do: %.c
$(CC) $(DEBUGFLAGS) -c $< -o $@
debug: $(DOBJS)
rm -rf $(TARGET)
ar rs $(TARGET) $(DOBJS)
release: $(OBJS)
rm -rf $(TARGET)
ar rs $(TARGET) $(OBJS)
clean:
rm -f *.o
rm -f *.do
rm -f *~
rm -f core*
rm -f $(TARGET)

View File

@ -1,39 +0,0 @@
CC = gcc
SRCS = bitvector.c hashing.c socket.c timefuncs.c ptrhash.c utf8.c ios.c \
dirpath.c htable.c bitvector-ops.c int2str.c dump.c random.c \
lltinit.c
OBJS = $(SRCS:%.c=%.o)
DOBJS = $(SRCS:%.c=%.do)
TARGET = libllt.a
# OS flags: LINUX, WIN32, MACOSX
# architecture flags: __CPU__=xxx, BITS64, ARCH_X86, ARCH_X86_64
CONFIG = -DBITS64 -D__CPU__=686
FLAGS = -Wall -Wno-strict-aliasing $(CFLAGS) $(CONFIG)
LIBS =
DEBUGFLAGS = -g -DDEBUG $(FLAGS)
SHIPFLAGS = -O3 -DNDEBUG $(FLAGS)
default: release
%.o: %.c
$(CC) $(SHIPFLAGS) -c $< -o $@
%.do: %.c
$(CC) $(DEBUGFLAGS) -c $< -o $@
debug: $(DOBJS)
rm -rf $(TARGET)
ar rs $(TARGET) $(DOBJS)
release: $(OBJS)
rm -rf $(TARGET)
ar rs $(TARGET) $(OBJS)
clean:
rm -f *.o
rm -f *.do
rm -f *~
rm -f core*
rm -f $(TARGET)

56
scripts/build.sh Executable file
View File

@ -0,0 +1,56 @@
#!/bin/sh
set -eu
CC="${CC:-clang}"
CFLAGS="-O2 -falign-functions -Wall -Wno-strict-aliasing -I ../llt -D NDEBUG -D USE_COMPUTED_GOTO"
LFLAGS="-lm"
builddir="build-$(uname | tr A-Z- a-z_)-$(uname -m | tr A-Z- a-z_)"
cd "$(dirname "$0")"/..
echo "Entering directory '$PWD'"
set -x
mkdir -p "$builddir"
find "$builddir" -mindepth 1 -delete
{ set +x; } 2>/dev/null
cd "$builddir"
echo "Entering directory '$PWD'"
set -x
$CC $CFLAGS -c ../builtins.c
$CC $CFLAGS -c ../equalhash.c
$CC $CFLAGS -c ../flisp.c
$CC $CFLAGS -c ../flmain.c
$CC $CFLAGS -c ../iostream.c
$CC $CFLAGS -c ../string.c
$CC $CFLAGS -c ../table.c
$CC $CFLAGS -c ../llt/bitvector-ops.c
$CC $CFLAGS -c ../llt/bitvector.c
$CC $CFLAGS -c ../llt/dirpath.c
$CC $CFLAGS -c ../llt/dump.c
$CC $CFLAGS -c ../llt/hashing.c
$CC $CFLAGS -c ../llt/htable.c
$CC $CFLAGS -c ../llt/int2str.c
$CC $CFLAGS -c ../llt/ios.c
$CC $CFLAGS -c ../llt/lltinit.c
$CC $CFLAGS -c ../llt/ptrhash.c
$CC $CFLAGS -c ../llt/random.c
$CC $CFLAGS -c ../llt/socket.c
$CC $CFLAGS -c ../llt/timefuncs.c
$CC $CFLAGS -c ../llt/utf8.c
$CC $LFLAGS -o flisp -lm \
builtins.o equalhash.o flisp.o flmain.o iostream.o string.o table.o \
bitvector-ops.o bitvector.o dirpath.o dump.o hashing.o htable.o \
int2str.o ios.o lltinit.o ptrhash.o random.o socket.o timefuncs.o utf8.o
ln -s ../flisp.boot flisp.boot
{ set +x; } 2>/dev/null
cd ..
echo "Entering directory '$PWD'"
echo "Creating stage 0 boot file..."
set -x
"$builddir"/flisp mkboot0.lsp system.lsp compiler.lsp >flisp.boot.new
mv flisp.boot.new flisp.boot
{ set +x; } 2>/dev/null
echo "Creating stage 1 boot file..."
set -x
"$builddir"/flisp mkboot1.lsp
{ set +x; } 2>/dev/null
cd tests
echo "Entering directory '$PWD'"
../"$builddir"/flisp unittest.lsp