ref: de08c21e7a9f359e65463e60a1ae5af023ecdbf8
parent: c058c12afdb43db5a63a464dc6ba42e1050af0df
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Fri Mar 10 10:30:08 EST 2023
gnu/bsd portable makefiles, remove macosx-specific one
--- a/Makefile
+++ b/Makefile
@@ -1,58 +1,45 @@
-FREEBSD-GE-10 = $(shell test `uname` = FreeBSD -a `uname -r | cut -d. -f1` -ge 10 && echo YES)
-CC = $(if $(FREEBSD-GE-10),clang,gcc)
+DESTDIR?=
+PREFIX?=/usr/local
+BIN=${DESTDIR}${PREFIX}/bin
-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
+TARG=flisp
+LLT=llt/libllt.a
+CFLAGS?=-O2 -pipe -g -Wall
+CFLAGS+=-falign-functions -Wno-strict-aliasing
+LDFLAGS?=
+LDFLAGS+=${LLT} -lm
-FLAGS = -falign-functions -Wall -Wno-strict-aliasing -I$(LLTDIR) $(CFLAGS) -DUSE_COMPUTED_GOTO
-LIBFILES = $(LLT)
-LIBS = $(LIBFILES) -lm
+OBJS=\
+ flmain.o\
+ flisp.o\
+ builtins.o\
+ string.o\
+ equalhash.o\
+ table.o\
+ iostream.o\
-DEBUGFLAGS = -g -DDEBUG $(FLAGS)
-SHIPFLAGS = -O2 -DNDEBUG $(FLAGS)
+.PHONY: all default test clean
-default: release test
+all: default
-test:
- cd test && ../flisp unittest.lsp
+default: ${TARG}
-%.o: %.c
- $(CC) $(SHIPFLAGS) -c $< -o $@
-%.do: %.c
- $(CC) $(DEBUGFLAGS) -c $< -o $@
+test: ${TARG}
+ cd test && ../$(TARG) unittest.lsp
+${TARG}: ${OBJS} ${LLT}
+ ${CC} -o $@ ${OBJS} ${LDFLAGS}
+
+.SUFFIXES: .c .o
+.c.o:
+ ${CC} -o $@ -c $< ${CFLAGS} -Illt -DUSE_COMPUTED_GOTO
+
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)
+${LLT}:
+ ${MAKE} -C llt CFLAGS="${CFLAGS}" CC="${CC}"
-$(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
+ rm -f *.o ${TARG}
+ ${MAKE} -C llt clean
--- a/Makefile.macosx
+++ /dev/null
@@ -1,59 +1,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
--- a/llt/Makefile
+++ b/llt/Makefile
@@ -1,37 +1,30 @@
-FREEBSD-GE-10 = $(shell test `uname` = FreeBSD -a `uname -r | cut -d. -f1` -ge 10 && echo YES)
-CC = $(if $(FREEBSD-GE-10),clang,gcc)
+CFLAGS?=-O2 -pipe -g -Wall -falign-functions -Wno-strict-aliasing
+TARG=libllt.a
-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
+OBJS=\
+ bitvector.o\
+ hashing.o\
+ socket.o\
+ timefuncs.o\
+ ptrhash.o\
+ utf8.o\
+ ios.o\
+ dirpath.o\
+ htable.o\
+ bitvector-ops.o\
+ int2str.o\
+ dump.o\
+ random.o\
+ lltinit.o\
-FLAGS = -Wall -Wno-strict-aliasing $(CFLAGS)
-LIBS =
+.PHONY: all default clean
-DEBUGFLAGS = -g -DDEBUG $(FLAGS)
-SHIPFLAGS = -O3 -DNDEBUG $(FLAGS)
+all: default
-default: release
+default: ${TARG}
-%.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)
+ rm -f *.o ${TARG}
+
+${TARG}: ${OBJS}
+ ${AR} crs ${TARG} ${OBJS}
--- a/llt/Makefile.macosx
+++ /dev/null
@@ -1,39 +1,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)