1
1
mirror of https://github.com/kanaka/mal.git synced 2024-11-10 12:47:45 +03:00
mal/cpp/Makefile
2016-02-24 00:33:20 -06:00

68 lines
1.3 KiB
Makefile

uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
ifeq ($(uname_S),Darwin)
# Native build on yosemite. Requires: brew install readline
CXX=g++
READLINE=/usr/local/Cellar/readline/6.3.8
INCPATHS=-I$(READLINE)/include
LIBPATHS=-L$(READLINE)/lib
else
# Ubuntu 14.10 / docker
CXX=g++-4.9
endif
LD=$(CXX)
AR=ar
DEBUG=-ggdb
CXXFLAGS=-O3 -Wall $(DEBUG) $(INCPATHS) -std=c++11
LDFLAGS=-O3 $(DEBUG) $(LIBPATHS) -L. -lreadline -lhistory
LIBSOURCES=Core.cpp Environment.cpp Reader.cpp ReadLine.cpp String.cpp \
Types.cpp Validation.cpp
LIBOBJS=$(LIBSOURCES:%.cpp=%.o)
MAINS=$(wildcard step*.cpp)
TARGETS=$(MAINS:%.cpp=%)
.PHONY: all clean
.SUFFIXES: .cpp .o
all: $(TARGETS)
dist: mal
mal: stepA_mal
cp $< $@
.deps: *.cpp *.h
$(CXX) $(CXXFLAGS) -MM *.cpp > .deps
$(TARGETS): %: %.o libmal.a
$(LD) $^ -o $@ $(LDFLAGS)
libmal.a: $(LIBOBJS)
$(AR) rcs $@ $^
.cpp.o:
$(CXX) $(CXXFLAGS) -c $< -o $@
clean:
rm -rf *.o $(TARGETS) libmal.a .deps mal
-include .deps
### Stats
.PHONY: stats stats-lisp
stats: $(LIBSOURCES) stepA_mal.cpp
@wc $^
@printf "%5s %5s %5s %s\n" `grep -E "^[[:space:]]*//|^[[:space:]]*$$" $^ | wc` "[comments/blanks]"
stats-lisp: Core.cpp Environment.cpp stepA_mal.cpp
@wc $^
@printf "%5s %5s %5s %s\n" `grep -E "^[[:space:]]*//|^[[:space:]]*$$" $^ | wc` "[comments/blanks]"