git.iko.soy/typeable/pandoc
on master help sign in
Moved more of the build process from Makefile to Setup.hs:

+ tarball target now calls 'sdist' + Added to "Extra-source-files" and "Extra-tmp-files" in pandoc.cabal, so 'sdist' and 'clean' will work properly. + Makefile no longer generates man pages or reference.odt. + Setup.hs now generates man pages in a postbuild hook. + Added dependency-checking to Setup.hs, so it only rebuilds things that need rebuilding. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1389 788f1e2b-df1e-0410-8736-df70ead52e1b

commit28828979a6df073182bf039333cb46f8ad922b19 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateSat 9 Aug 2008, 23:45 (18 years ago) parente36ff78
3 files changed+132−34
Makefile+2−12 Setup.hs+58−18 pandoc.cabal+72−4
Makefile+2−12
@@ -90,14 +90,6 @@ all: build-program
9090 sh ./markdown2pdf $< || rm -f $@
9191%.txt: %
9292 perl -p -e 's/\n/\r\n/' $< > $@ || rm -f $@ # convert to DOS line endings
93−%.1: %.1.md $(MAIN)
94− ./$(MAIN) -s -S -w man $< >$@ || rm -f $@
95−
96−cleanup_files+=$(ODTREF)
97−$(ODTREF): $(addprefix $(ODTSTYLES)/, meta.xml styles.xml content.xml mimetype \
98− settings.xml Thumbnails META-INF)
99− cd $(ODTSTYLES) ; \
100− zip -9 -q -r $(notdir $@) * -x $(notdir $@)
10193
10294.PHONY: configure
10395cleanup_files+=Setup.hi Setup.o $(BUILDCMD) $(BUILDVARS)
@@ -272,10 +264,8 @@ tarball:=$(PKGID).tar.gz
272264cleanup_files+=$(tarball)
273265tarball: $(tarball)
274266$(tarball):
275− svn export . $(PKGID)
276− $(MAKE) -C $(PKGID) wrappers
277− tar cvzf $(tarball) $(PKGID)
278− -rm -rf $(PKGID)
267+ $(BUILDCMD) sdist
268+ cp $(BUILDDIR)/$(tarball) .
279269
280270.PHONY: deb
281271deb_name:=$(shell grep ^Package debian/control | cut -d' ' -f2 | head -n 1)
Setup.hs+58−18
@@ -1,44 +1,84 @@
11import Distribution.Simple
22import Distribution.PackageDescription ( emptyHookedBuildInfo )
33import Control.Exception ( bracket_ )
4−import System.Process ( runCommand, waitForProcess )
5−import System.FilePath ( (</>) )
6−import System.Directory ( getCurrentDirectory, setCurrentDirectory, findExecutable, doesFileExist )
4+import System.Process ( runCommand, runProcess, waitForProcess )
5+import System.FilePath ( (</>), (<.>) )
6+import System.Directory
77import System.IO ( stderr )
88import System.Exit
9−import Data.Maybe ( fromJust )
9+import System.Time
10+import System.IO.Error ( isDoesNotExistError )
11+import Data.Maybe ( fromJust, isNothing, catMaybes )
1012
11−main = defaultMainWithHooks (simpleUserHooks {runTests = runTestSuite, preConf = checkReferenceODT})
13+main = defaultMainWithHooks $
14+ simpleUserHooks { runTests = runTestSuite
15+ , preConf = checkReferenceODT
16+ , postBuild = makeManPages }
1217
1318-- | Run test suite.
1419runTestSuite _ _ _ _ = do
1520 inDirectory "tests" $ runCommand "runhaskell RunTests.hs" >>= waitForProcess
1621 return ()
1722
18−-- | If reference.odt does not exist, build it.
19−checkReferenceODT _ _ = do
20− refODTexists <- doesFileExist ("odt-styles" </> "reference.odt")
21− if refODTexists
23+-- | If reference.odt needs rebuilding, build it.
24+checkReferenceODT _ _ = inDirectory "odt-styles" $ do
25+ let refodt = "reference.odt"
26+ let deps = [ "meta.xml", "content.xml", "settings.xml", "META-INF/manifest.xml",
27+ "Thumbnails/thumbnail.png", "styles.xml", "mimetype" ]
28+ modifiedDeps <- modifiedDependencies refodt deps
29+ if null modifiedDeps
2230 then return ()
23− else makeReferenceODT
31+ else makeReferenceODT modifiedDeps
2432 return emptyHookedBuildInfo
2533
2634-- | Create reference.odt by zipping up sources in odt-styles directory.
27−makeReferenceODT :: IO ()
28−makeReferenceODT = do
35+makeReferenceODT :: [FilePath] -> IO ()
36+makeReferenceODT sources = do
2937 zipPathMaybe <- findExecutable "zip"
30− if zipPathMaybe == Nothing
38+ if isNothing zipPathMaybe
3139 then error $ "The 'zip' command, which is needed to build reference.odt\n" ++
3240 "from sources in the odt-styles directory, was not found.\n" ++
3341 "Try again after installing zip (http://www.info-zip.org/Zip.html).\n" ++
3442 "Or use the pandoc source tarball, which contains a prebuilt reference.odt."
3543 else do
3644 putStrLn "Creating reference.odt:"
37− inDirectory "odt-styles" $ do
38− ec <- runCommand "zip -9 -r reference.odt *" >>= waitForProcess
39− case ec of
40− ExitSuccess -> putStrLn "Done."
41− _ -> error "Error creating ODT."
45+ ec <- runProcess (fromJust zipPathMaybe) (["-9", "-r", "reference.odt"] ++ sources)
46+ Nothing Nothing Nothing Nothing (Just stderr) >>= waitForProcess
47+ case ec of
48+ ExitSuccess -> return ()
49+ _ -> error "Error creating ODT."
50+
51+-- | Build man pages from markdown sources in man/man1/.
52+makeManPages _ _ _ _ = do
53+ mapM makeManPage ["pandoc.1", "hsmarkdown.1", "markdown2pdf.1", "html2markdown.1"]
54+ return ()
55+
56+-- | Build a man page from markdown source in man/man1.
57+makeManPage manpage = do
58+ let manDir = "man" </> "man1"
59+ let pandoc = "dist" </> "build" </> "pandoc" </> "pandoc"
60+ let page = manDir </> manpage
61+ let source = manDir </> manpage <.> "md"
62+ modifiedDeps <- modifiedDependencies page [source]
63+ if null modifiedDeps
64+ then return ()
65+ else do
66+ ec <- runProcess pandoc ["-s", "-r", "markdown", "-w", "man", "-o", page, source]
67+ Nothing Nothing Nothing Nothing (Just stderr) >>= waitForProcess
68+ case ec of
69+ ExitSuccess -> putStrLn $ "Created " ++ manDir </> manpage
70+ _ -> error $ "Error creating " ++ manDir </> manpage
71+
72+-- | Returns a list of 'dependencies' that have been modified after 'file'.
73+modifiedDependencies :: FilePath -> [FilePath] -> IO [FilePath]
74+modifiedDependencies file dependencies = do
75+ fileModTime <- catch (getModificationTime file) $
76+ \e -> if isDoesNotExistError e
77+ then return (TOD 0 0) -- the minimum ClockTime
78+ else ioError e
79+ depModTimes <- mapM getModificationTime dependencies
80+ let modified = zipWith (\dep time -> if time > fileModTime then Just dep else Nothing) dependencies depModTimes
81+ return $ catMaybes modified
4282
4383-- | Perform an IO action in a directory.
4484inDirectory :: FilePath -> IO a -> IO a
pandoc.cabal+72−4
@@ -34,15 +34,27 @@ Description: Pandoc is a Haskell library for converting from one markup
3434 which convert this native representation into a target
3535 format. Thus, adding an input or output format requires
3636 only adding a reader or writer.
37−Extra-Source-Files: README, INSTALL, COPYRIGHT, COPYING,
38− data/ASCIIMathML.js.comment,
39− data/ASCIIMathML.js.packed,
37+Extra-Source-Files:
38+ -- documentation
39+ README, INSTALL, COPYRIGHT, COPYING, changelog,
40+ -- sources for man pages
41+ man/man1/pandoc.1.md, man/man1/markdown2pdf.1.md,
42+ man/man1/html2markdown.1.md, man/man1/hsmarkdown.1.md,
43+ -- Makefile
44+ Makefile,
45+ -- wrappers
46+ markdown2pdf, html2markdown, hsmarkdown,
47+ -- data for DefaultHeaders.hs
4048 data/headers/ConTeXt.header,
4149 data/headers/Docbook.header,
4250 data/headers/LaTeX.header,
4351 data/headers/OpenDocument.header,
4452 data/headers/RTF.header,
4553 data/headers/S5.header,
54+ -- data for ASCIIMathML writer
55+ data/ASCIIMathML.js.comment,
56+ data/ASCIIMathML.js.packed,
57+ -- data for S5 writer
4658 data/ui/default/slides.js.comment,
4759 data/ui/default/slides.js.packed,
4860 data/ui/default/s5-core.css,
@@ -51,7 +63,63 @@ Extra-Source-Files: README, INSTALL, COPYRIGHT, COPYING,
5163 data/ui/default/opera.css,
5264 data/ui/default/outline.css,
5365 data/ui/default/print.css,
54− odt-styles/reference.odt
66+ -- data for ODT writer
67+ odt-styles/meta.xml,
68+ odt-styles/content.xml,
69+ odt-styles/settings.xml,
70+ odt-styles/META-INF/manifest.xml,
71+ odt-styles/Thumbnails/thumbnail.png,
72+ odt-styles/styles.xml,
73+ odt-styles/mimetype,
74+ odt-styles/reference.odt,
75+ -- tests
76+ tests/bodybg.gif,
77+ tests/writer.latex,
78+ tests/html-reader.html,
79+ tests/html-reader.native,
80+ tests/insert,
81+ tests/lalune.jpg,
82+ tests/latex-reader.latex,
83+ tests/latex-reader.native,
84+ tests/movie.jpg,
85+ tests/rst-reader.native,
86+ tests/rst-reader.rst,
87+ tests/s5.basic.html,
88+ tests/s5.fancy.html,
89+ tests/s5.fragment.html,
90+ tests/s5.inserts.html,
91+ tests/s5.native,
92+ tests/tables.context,
93+ tests/tables.docbook,
94+ tests/tables.html,
95+ tests/tables.latex,
96+ tests/tables.man,
97+ tests/tables.markdown,
98+ tests/tables.mediawiki,
99+ tests/tables.native,
100+ tests/tables.opendocument,
101+ tests/tables.texinfo,
102+ tests/tables.rst,
103+ tests/tables.rtf,
104+ tests/tables.txt,
105+ tests/testsuite.native,
106+ tests/testsuite.txt,
107+ tests/writer.context,
108+ tests/writer.docbook,
109+ tests/writer.html,
110+ tests/writer.man,
111+ tests/writer.markdown,
112+ tests/writer.mediawiki,
113+ tests/writer.native,
114+ tests/writer.opendocument,
115+ tests/writer.rst,
116+ tests/writer.rtf,
117+ tests/writer.texinfo,
118+ tests/Diff.hs,
119+ tests/RunTests.hs
120+Extra-Tmp-Files: man/man1/pandoc.1, man/man1/hsmarkdown.1,
121+ man/man1/markdown2pdf.1, man/man1/html2markdown.1
122+
55123Flag splitBase
56124 Description: Choose the new, smaller, split-up base package.
57125 Default: True