1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
CABAL = cabal
HAPPY = happy
HAPPY_OPTS = -agc
HAPPY_VER = `awk '/^version:/ { print $$2 }' happy.cabal`
ALEX = alex
ALEX_OPTS = -g
SDIST_DIR=dist-newstyle/sdist
TARBALL="${SDIST_DIR}/happy-$(HAPPY_VER).tar.gz"
GEN = src/gen/Parser.hs src/gen/AttrGrammarParser.hs
all : $(GEN)
src/gen/%.hs : src/boot/%.ly
$(HAPPY) $(HAPPYFLAGS) $< -o $@
sdist ::
@case "`$(CABAL) --numeric-version`" in \
2.[2-9].* | [3-9].* ) ;; \
* ) echo "Error: needs cabal 2.2.0.0 or later (but got : `$(CABAL) --numeric-version`)" ; exit 1 ;; \
esac
@if [ "`git status -s`" != '' ]; then \
echo Tree is not clean; \
exit 1; \
fi
$(HAPPY) $(HAPPY_OPTS) src/Parser.ly -o src/Parser.hs
$(HAPPY) $(HAPPY_OPTS) src/AttrGrammarParser.ly -o src/AttrGrammarParser.hs
mv src/Parser.ly src/Parser.ly.boot
mv src/AttrGrammarParser.ly src/AttrGrammarParser.ly.boot
$(CABAL) v2-run gen-happy-sdist
cabal v2-sdist
@if [ ! -f "${TARBALL}" ]; then \
echo "Error: source tarball not found: ${TARBALL}"; \
exit 1; \
fi
git checkout .
git clean -f
sdist-test :: sdist sdist-test-only
@rm -rf "${SDIST_DIR}/happy-${HAPPY_VER}/"
sdist-test-only ::
@if [ ! -f "${TARBALL}" ]; then \
echo "Error: source tarball not found: ${TARBALL}"; \
exit 1; \
fi
rm -rf "${SDIST_DIR}/happy-$(HAPPY_VER)/"
tar -xf "${TARBALL}" -C ${SDIST_DIR}/
echo "packages: ." > "${SDIST_DIR}/happy-$(HAPPY_VER)/cabal.project"
cd "${SDIST_DIR}/happy-$(HAPPY_VER)/" && cabal v2-test --enable-tests all
@echo ""
@echo "Success! ${TARBALL} is ready for distribution!"
@echo ""
# Export name of generated tarball for e.g. use in CI.
print-tarball:
@echo ${TARBALL}
|