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