1# Copyright 2012-2020 Mitchell. See LICENSE.
2
3.SUFFIXES: .cxx .c .o .h .a
4
5AR = ar
6CC = gcc
7CXX = g++
8INCLUDEDIRS = -I ../include -I ../src -I ../lexlib
9CFLAGS = -std=c99 -pedantic -Wall
10CXXFLAGS = -std=c++17 -pedantic -DCURSES -DSCI_LEXER $(INCLUDEDIRS) -Wall
11ifdef DEBUG
12  CXXFLAGS += -DDEBUG -g
13else
14  CXXFLAGS += -DNDEBUG -Os
15endif
16CURSES_FLAGS =
17
18scintilla = ../bin/scintilla.a
19sci = AutoComplete.o CallTip.o CaseConvert.o CaseFolder.o Catalogue.o \
20      CellBuffer.o CharacterCategory.o CharClassify.o ContractionState.o \
21      DBCS.o Decoration.o Document.o EditModel.o Editor.o EditView.o \
22      ExternalLexer.o Indicator.o KeyMap.o LineMarker.o MarginView.o PerLine.o \
23      PositionCache.o RESearch.o RunStyles.o ScintillaBase.o Selection.o \
24      Style.o UniConversion.o UniqueString.o ViewStyle.o XPM.o \
25      Accessor.o CharacterSet.o DefaultLexer.o LexerBase.o LexerModule.o \
26      LexerNoExceptions.o LexerSimple.o PropSetSimple.o StyleContext.o \
27      WordList.o
28lexers = $(addsuffix .o,$(basename $(sort $(notdir $(wildcard ../lexers/Lex*.cxx)))))
29
30vpath %.h ../src ../include ../lexlib
31vpath %.cxx ../src ../lexlib ../lexers
32
33all: $(scintilla)
34$(sci) $(lexers) ScintillaCurses.o: %.o: %.cxx
35	$(CXX) $(CXXFLAGS) $(CURSES_FLAGS) -c $<
36$(scintilla): $(sci) $(lexers) ScintillaCurses.o
37	$(AR) rc $@ $^
38	touch $@
39clean: ; rm -f *.o $(scintilla)
40
41# Documentation.
42
43docs: docs/index.md docs/api.md $(wildcard docs/*.md) | \
44      docs/_layouts/default.html
45	for file in $(basename $^); do \
46		cat $| | docs/fill_layout.lua $$file.md > $$file.html; \
47	done
48docs/index.md: README.md
49	sed -e 's/^\# [[:alpha:]]\+/## Introduction/;' -e \
50		's|https://[[:alpha:]]\+\.github\.io/[[:alpha:]]\+/||;' $< > $@
51docs/api.md: docs/scinterm.luadoc ; luadoc --doclet docs/markdowndoc $^ > $@
52cleandocs: ; rm -f docs/*.html docs/index.md docs/api.md
53