File: Makefile

package info (click to toggle)
lammps 0~20161109.git9806da6-7
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 248,460 kB
  • ctags: 80,635
  • sloc: cpp: 701,185; python: 33,420; fortran: 26,434; ansic: 11,340; sh: 6,108; perl: 4,104; makefile: 2,891; xml: 2,590; f90: 1,690; objc: 238; lisp: 169; tcl: 61; csh: 16; awk: 14
file content (145 lines) | stat: -rw-r--r-- 4,114 bytes parent folder | download | duplicates (2)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# Makefile for LAMMPS documentation

SHELL 	      = /bin/bash
SHA1          = $(shell echo $USER-$PWD | python utils/sha1sum.py)
BUILDDIR      = /tmp/lammps-docs-$(SHA1)
RSTDIR        = $(BUILDDIR)/rst
VENV          = $(BUILDDIR)/docenv
TXT2RST       = $(VENV)/bin/txt2rst

PYTHON        = $(shell which python3)
HAS_PYTHON3    = NO
HAS_VIRTUALENV = NO

ifeq ($(shell which python3 >/dev/null 2>&1; echo $$?), 0)
HAS_PYTHON3 = YES
endif

ifeq ($(shell which virtualenv >/dev/null 2>&1; echo $$?), 0)
HAS_VIRTUALENV = YES
endif

SOURCES=$(wildcard src/*.txt)
OBJECTS=$(SOURCES:src/%.txt=$(RSTDIR)/%.rst)

.PHONY: help clean-all clean epub html pdf old venv

# ------------------------------------------

help:
	@echo "Please use \`make <target>' where <target> is one of"
	@echo "  html       create HTML doc pages in html dir"
	@echo "  pdf        create Manual.pdf and Developer.pdf in this dir"
	@echo "  old        create old-style HTML doc pages in old dir"
	@echo "  fetch      fetch HTML and PDF files from LAMMPS web site"
	@echo "  epub       create ePUB format manual for e-book readers"
	@echo "  clean      remove all intermediate RST files"
	@echo "  clean-all  reset the entire build environment"
	@echo "  txt2html   build txt2html tool"

# ------------------------------------------

clean-all:
	rm -rf $(BUILDDIR)/* utils/txt2html/txt2html.exe

clean:
	rm -rf $(RSTDIR)

html: $(OBJECTS)
	@(\
		. $(VENV)/bin/activate ;\
		cp -r src/* $(RSTDIR)/ ;\
		sphinx-build -j 8 -b html -c utils/sphinx-config -d $(BUILDDIR)/doctrees $(RSTDIR) html ;\
		deactivate ;\
	)
	-rm html/searchindex.js
	@rm -rf html/_sources
	@rm -rf html/PDF
	@rm -rf html/USER
	@cp -r src/PDF html/PDF
	@cp -r src/USER html/USER
	@rm -rf html/PDF/.[sg]*
	@rm -rf html/USER/.[sg]*
	@rm -rf html/USER/*/.[sg]*
	@rm -rf html/USER/*/*.[sg]*
	@echo "Build finished. The HTML pages are in doc/html."

epub: $(OBJECTS)
	@mkdir -p epub
	@rm -f LAMMPS.epub
	@cp src/JPG/lammps-logo.png epub/
	@(\
		. $(VENV)/bin/activate ;\
		cp -r src/* $(RSTDIR)/ ;\
		sphinx-build -j 8 -b epub -c utils/sphinx-config -d $(BUILDDIR)/doctrees $(RSTDIR) epub ;\
		deactivate ;\
	)
	@mv  epub/LAMMPS.epub .
	@rm -rf epub
	@echo "Build finished. The ePUB manual file is created."

pdf: utils/txt2html/txt2html.exe
	@(\
		cd src; \
		../utils/txt2html/txt2html.exe -b *.txt; \
		htmldoc --batch lammps.book;          \
		for s in `echo *.txt | sed -e 's,\.txt,\.html,g'` ; \
			do grep -q $$s lammps.book || \
			echo doc file $$s missing in src/lammps.book; done; \
		rm *.html; \
		cd Developer; \
		pdflatex developer; \
		pdflatex developer; \
		mv developer.pdf ../../Developer.pdf; \
	)

old: utils/txt2html/txt2html.exe
	@rm -rf old
	@mkdir old; mkdir old/Eqs; mkdir old/JPG; mkdir old/PDF
	@cd src; ../utils/txt2html/txt2html.exe -b *.txt; \
	  mv *.html ../old; \
	  cp Eqs/*.jpg ../old/Eqs; \
	  cp JPG/* ../old/JPG; \
	  cp PDF/* ../old/PDF;

fetch:
	@rm -rf html_www Manual_www.pdf Developer_www.pdf
	@curl -s -o Manual_www.pdf http://lammps.sandia.gov/doc/Manual.pdf
	@curl -s -o Developer_www.pdf http://lammps.sandia.gov/doc/Developer.pdf
	@curl -s -o lammps-doc.tar.gz http://lammps.sandia.gov/tars/lammps-doc.tar.gz
	@tar xzf lammps-doc.tar.gz
	@rm -f lammps-doc.tar.gz

txt2html: utils/txt2html/txt2html.exe

# ------------------------------------------

utils/txt2html/txt2html.exe: utils/txt2html/txt2html.cpp
	g++ -O -Wall -o $@ $<

$(RSTDIR)/%.rst : src/%.txt $(TXT2RST)
	@(\
		mkdir -p $(RSTDIR) ; \
		. $(VENV)/bin/activate ;\
		txt2rst $< > $@ ;\
		deactivate ;\
	)

$(VENV):
	@if [ "$(HAS_PYTHON3)" == "NO" ] ; then echo "Python3 was not found! Please check README.md for further instructions" 1>&2; exit 1; fi
	@if [ "$(HAS_VIRTUALENV)" == "NO" ] ; then echo "virtualenv was not found! Please check README.md for further instructions" 1>&2; exit 1; fi
	@( \
		virtualenv -p $(PYTHON) $(VENV); \
		. $(VENV)/bin/activate; \
		pip install Sphinx; \
		pip install sphinxcontrib-images; \
		deactivate;\
	)

$(TXT2RST): $(VENV)
	@( \
		. $(VENV)/bin/activate; \
		(cd utils/converters;\
		python setup.py develop);\
		deactivate;\
	)