-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
162 lines (122 loc) · 3.42 KB
/
Makefile
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#**********************************************************
#**
#** LOGRAMM
#** Interpreter
#**
#** (c) 2009-2014, Dr.Kameleon
#**
#**********************************************************
#** Makefile
#**********************************************************
##================================================
## Setup
##================================================
# Definition
APP = lgm
# Environment
OS = $(shell uname)
CC = gcc
DMD = dmd
LEX = lex
YACC = /usr/local/bin/bison
AWK = awk
CLOC = cloc
CP = cp
MV = mv
RM = rm
YES = yes
# Folders
BIN = bin
DOC = doc
EXTRAS = extras
LIB = lib
SCRIPTS = scripts
SRC = src
TESTS = tests
# Flags
CC_CFLAGS = -c -I${SRC}/parser
D_CFLAGS = -c -op -I${SRC} -J${SRC} -inline -O -release -noboundscheck
D_LFLAGS = -m64 -L-lcurl -L-lsqlite3
ifeq (${TARGET}, debug)
D_CFLAGS := $(subst -O -release,,${D_CFLAGS})
D_CFLAGS := $(subst -O -noboundscheck,,${D_CFLAGS})
D_CFLAGS += -debug -profile -g -gs -gx # -unittest
endif
ifeq (${TARGET}, profile)
D_CFLAGS += -profile
endif
CLOC_FLAGS = --exclude-dir=${BIN},${SRC}/library/yaml,${SRC}/library/warp
# Installation paths
BIN_DEST = /usr/local/bin
LIB_DEST = /usr/lib/${APP}
MAN_DEST = /usr/share/man
ifeq (${OS}, Darwin)
CGI_DEST = /Applications/XAMPP/cgi-bin
endif
ifeq (${OS}, Linux)
CGI_DEST = /usr/lib/cgi-bin
endif
# Files
BINARY = ${BIN}/${APP}
LEXER = ${SRC}/parser/logramm.l
GRAMMAR = ${SRC}/parser/logramm.y
GEN_SOURCES = lex.yy.c logramm.tab.c logramm.tab.h
CC_FILES = lex.yy logramm.tab $(basename $(wildcard ${SRC}/parser/*.c))
CC_SOURCES = $(addsuffix .c,${CC_FILES})
CC_OBJECTS = $(addsuffix .o,${CC_FILES})
D_FILES = $(basename $(wildcard ${SRC}/*.d) \
$(wildcard ${SRC}/backend/*.d) \
$(wildcard ${SRC}/components/*.d) \
$(wildcard ${SRC}/library/*.d) \
$(wildcard ${SRC}/library/yaml/*.d) \
$(wildcard ${SRC}/library/warp/*.d) \
$(wildcard ${SRC}/system/*.d) \
)
D_SOURCES = $(addsuffix .d, ${D_FILES})
D_OBJECTS = $(addsuffix .o, ${D_FILES})
TRACE_LOGS = *.log *.def
MAN_APP = ${DOC}/man/lgm.1
MAN_LIB = ${DOC}/man/lgmlib.3
UPDATEBUILD = ${SCRIPTS}/update-build.awk
BUILDNO = ${SRC}/resources/build.txt
BUILDNO_NEW = ${SRC}/resources/build.new
##================================================
## Rules
##================================================
all: update-build ${BINARY}
${RM} -f ${GEN_SOURCES}
${BINARY}: ${CC_OBJECTS} ${D_OBJECTS}
${DMD} $^ -of$@ ${D_LFLAGS}
${D_OBJECTS}: ${D_SOURCES}
${DMD} ${D_SOURCES} ${D_CFLAGS}
${CC_OBJECTS}: %.o: %.c
${CC} $< ${CC_CFLAGS} -o $@
${CC_OBJECTS}: ${CC_SOURCES}
${CC_SOURCES}:
${LEX} ${LEXER}
${YACC} -d ${GRAMMAR}
install:
${RM} -rf ${BIN_DEST}/${APP}
${CP} -rf ${BINARY} ${BIN_DEST}
${RM} -rf ${CGI_DEST}/${APP}
${CP} -rf ${BINARY} ${CGI_DEST}
${RM} -rf ${LIB_DEST}
${CP} -rf ${LIB} ${LIB_DEST}
${CP} -rf ${MAN_APP} ${MAN_DEST}/man1
${CP} -rf ${MAN_LIB} ${MAN_DEST}/man3
clean:
${RM} -f ${BINARY} ${GEN_SOURCES} ${CC_OBJECTS} ${D_OBJECTS} ${TRACE_LOGS}
count:
${CLOC} . ${CLOC_FLAGS}
countall:
${CLOC} .
update-build:
${AWK} -f ${UPDATEBUILD} < ${BUILDNO} > ${BUILDNO_NEW}
${YES} | ${RM} -rf ${BUILDNO}
${MV} ${BUILDNO_NEW} ${BUILDNO}
docs:
${APP} ${SCRIPTS}/create_doc_html.lgm ${DOC}/html
${APP} ${SCRIPTS}/create_doc_man.lgm ${DOC}/man
${APP} ${SCRIPTS}/create_sublime_completions.lgm ${EXTRAS}/highlighting/sublime
test:
${APP} ${SCRIPTS}/run_unittests.lgm