Skip to content

Commit 6ea2437

Browse files
committed
Makefile update
1 parent 0bf39c4 commit 6ea2437

File tree

2 files changed

+58
-52
lines changed

2 files changed

+58
-52
lines changed

Makefile

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -75,60 +75,60 @@ all: $(THESIS).pdf
7575

7676
# Force remake
7777
$(THESIS).pdf: $(THESIS).tex FORCE_MAKE
78-
@echo "Building $(THESIS).pdf with $(ENGINE)..."
79-
@latexmk $(LATEXMK_OPT) $<
78+
@echo "Building $(THESIS).pdf with $(ENGINE)..."
79+
@latexmk $(LATEXMK_OPT) $<
8080

8181
# Preview continuous mode
8282
pvc: $(THESIS).tex
83-
@echo "Starting preview continuous mode..."
84-
@latexmk $(LATEXMK_OPT_PVC) $(THESIS)
83+
@echo "Starting preview continuous mode..."
84+
@latexmk $(LATEXMK_OPT_PVC) $(THESIS)
8585

8686
# View PDF
8787
view: $(THESIS).pdf
88-
@echo "Opening $(THESIS).pdf..."
89-
$(OPEN) $<
88+
@echo "Opening $(THESIS).pdf..."
89+
$(OPEN) $<
9090

9191
# Word count
9292
wordcount: $(THESIS).tex
93-
@echo "Counting words in $(THESIS).tex..."
94-
@if grep -v ^% $< | grep -q '\\documentclass\[[^\[]*english'; then \
95-
texcount $< -inc -char-only | awk '/total/ {getline; print "英文字符数 (Latin characters)\t:",$$4}'; \
96-
else \
97-
texcount $< -inc -ch-only | awk '/total/ {getline; print "纯中文字数 (Chinese characters)\t:",$$4}'; \
98-
fi
99-
@texcount $< -inc -chinese | awk '/total/ {getline; print "总字数 (Total characters)\t:",$$4}'
93+
@echo "Counting words in $(THESIS).tex..."
94+
@if grep -v ^% $< | grep -q '\\documentclass\[[^\[]*english'; then \
95+
texcount $< -inc -char-only | awk '/total/ {getline; print "英文字符数 (Latin characters)\t:",$$4}'; \
96+
else \
97+
texcount $< -inc -ch-only | awk '/total/ {getline; print "纯中文字数 (Chinese characters)\t:",$$4}'; \
98+
fi
99+
@texcount $< -inc -chinese | awk '/total/ {getline; print "总字数 (Total characters)\t:",$$4}'
100100

101101
# Clean auxiliary files
102102
clean:
103-
@echo "Cleaning auxiliary files..."
104-
-@latexmk -c -bibtex -silent $(THESIS).tex styledef.tex 2> /dev/null
105-
@echo "Clean complete."
103+
@echo "Cleaning auxiliary files..."
104+
-@latexmk -c -bibtex -silent $(THESIS).tex styledef.tex 2> /dev/null
105+
@echo "Clean complete."
106106

107107
# Clean all generated files
108108
cleanall:
109-
@echo "Cleaning all generated files..."
110-
-@latexmk -C -bibtex -silent $(THESIS).tex styledef.tex 2> /dev/null
111-
@echo "Clean complete."
109+
@echo "Cleaning all generated files..."
110+
-@latexmk -C -bibtex -silent $(THESIS).tex styledef.tex 2> /dev/null
111+
@echo "Clean complete."
112112

113113
# Help target
114114
help:
115-
@echo "Available targets:"
116-
@echo " all - Build PDF (default)"
117-
@echo " pvc - Preview continuously"
118-
@echo " view - Open PDF"
119-
@echo " wordcount - Count words in Chinese and English"
120-
@echo " clean - Remove auxiliary files"
121-
@echo " cleanall - Remove all generated files"
122-
@echo " help - Show this help message"
123-
@echo ""
124-
@echo "Available engines (use ENGINE=<option>):"
125-
@echo " -xelatex (default)"
126-
@echo " -lualatex"
127-
@echo ""
128-
@echo "Example usage:"
129-
@echo " make"
130-
@echo " make ENGINE=-lualatex"
131-
@echo " make pvc"
115+
@echo "Available targets:"
116+
@echo " all - Build PDF (default)"
117+
@echo " pvc - Preview continuously"
118+
@echo " view - Open PDF"
119+
@echo " wordcount - Count words in Chinese and English"
120+
@echo " clean - Remove auxiliary files"
121+
@echo " cleanall - Remove all generated files"
122+
@echo " help - Show this help message"
123+
@echo ""
124+
@echo "Available engines (use ENGINE=<option>):"
125+
@echo " -xelatex (default)"
126+
@echo " -lualatex"
127+
@echo ""
128+
@echo "Example usage:"
129+
@echo " make"
130+
@echo " make ENGINE=-lualatex"
131+
@echo " make pvc"
132132

133133
# Force remake
134134
FORCE_MAKE:

make.bat

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -87,39 +87,45 @@ goto :help
8787

8888
:wordcount
8989
echo Counting words in %THESIS%.tex...
90-
set found=0
9190
setlocal enabledelayedexpansion
91+
set found=0
92+
if not exist %THESIS%.tex (
93+
echo Error: %THESIS%.tex does not exist.
94+
exit /b 1
95+
)
9296

93-
findstr "\\documentclass\[[^\[]*en" %THESIS%.tex >nul 2>&1
94-
if %ERRORLEVEL% EQU 0 (
95-
for /f "delims=" %%i in ('texcount %THESIS%.tex -inc -char-only 2^>nul') do (
97+
findstr "\\documentclass\[[^\[]*en" %THESIS%.tex > nul
98+
if %errorlevel% equ 0 (
99+
for /f "delims=" %%i in ('texcount %THESIS%.tex -inc -char-only 2^>nul') do (
96100
if !found! equ 1 (
97-
echo 英文字符数 (Latin characters) :%%i
98-
goto :count_total
101+
echo 英文字符数 Latin characters:!%%i!
102+
goto :total
99103
)
100-
echo %%i | findstr "total" >nul && set found=1
104+
echo %%i | findstr "total" > nul && set found=1
101105
)
102106
) else (
103-
for /f "delims=" %%i in ('texcount %THESIS%.tex -inc -ch-only 2^>nul') do (
107+
for /f "delims=" %%i in ('texcount %THESIS%.tex -inc -ch-only 2^>nul') do (
104108
if !found! equ 1 (
105-
echo 纯中文字数 (Chinese characters) :%%i
106-
goto :count_total
109+
echo 纯中文字数 Chinese characters:!%%i!
110+
goto :total
107111
)
108-
echo %%i | findstr "total" >nul && set found=1
112+
echo %%i | findstr "total" > nul && set found=1
109113
)
110114
)
115+
goto :total
111116

112-
:count_total
117+
:total
113118
set found=0
114119
for /f "delims=" %%i in ('texcount %THESIS%.tex -inc -chinese 2^>nul') do (
115120
if !found! equ 1 (
116-
echo 总字数 (Total characters) :%%i
117-
endlocal
121+
echo 总字数 Total characters:!%%i!
118122
goto :EOF
119123
)
120-
echo %%i | findstr "total" >nul && set found=1
124+
echo %%i | findstr "total" > nul && set found=1
125+
)
126+
if !found! neq 1 (
127+
echo Warning: Could not determine word count.
121128
)
122-
endlocal
123129
goto :EOF
124130

125131
:clean

0 commit comments

Comments
 (0)