feat(build): add Makefile for libraries

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2014-06-28 18:32:44 -07:00
parent 65c63e146f
commit 5a7e198583
4 changed files with 43 additions and 0 deletions

25
library/Makefile.common Normal file
View file

@ -0,0 +1,25 @@
TOP := $(dir $(lastword $(MAKEFILE_LIST)))
EXTRACT_DEPS = $(TOP)/extract_deps
LEAN_FILES = $(wildcard *.lean)
OLEAN_FILES = $(LEAN_FILES:.lean=.olean)
DEPS = make.deps
all: $(OLEAN_FILES) $(DEPS)
%.olean: %.lean
$(LEAN) $< -o $@
%.olean: %.lua
$(LEAN) $< -o $@
.PHONY: all clean
clean:
-rm -f *.olean $(DEPS)
$(DEPS): $(LEAN_FILES)
LEAN=$(LEAN) $(EXTRACT_DEPS) $(LEAN_FILES) > make.deps
ifneq ($(MAKECMDGOALS),clean)
-include $(DEPS)
endif

10
library/extract_deps Executable file
View file

@ -0,0 +1,10 @@
#!/usr/bin/env bash
for LEANFILE in $@; do
OLEANFILE=${LEANFILE//.lean/.olean}
DEPS=`$LEAN --deps $LEANFILE | cut -d ' ' -f 2- | tr "\n" " "`
echo -n "$OLEANFILE:"
for DEP in $DEPS; do
echo -n " ${DEP}"
done
echo ""
done

View file

@ -0,0 +1 @@
include ../Makefile.common

View file

@ -270,3 +270,10 @@ file(GLOB_RECURSE LEAN_SOURCES
${LEAN_SOURCE_DIR}/[A-Za-z]*.h)
add_style_check_target(style "${LEAN_SOURCES}")
add_test(NAME style_check COMMAND ${LEAN_SOURCE_DIR}/cmake/Modules/cpplint.py ${LEAN_SOURCES})
add_custom_target(
standard_lib ALL
COMMAND make LEAN=${CMAKE_BINARY_DIR}/shell/lean
DEPENDS ${CMAKE_BINARY_DIR}/shell/lean
WORKING_DIRECTORY ${LEAN_SOURCE_DIR}/../library/standard
)