forked from pclewis/lslint
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Makefile
90 lines (64 loc) · 1.98 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
PROGRAM = lslint
VERSION_NUMBER = $(BUILD_VERSION_NUMBER)
BUILD_DATE = $(shell date +"%Y-%m-%d")
# See if we're running on mac
UNAME = $(shell uname -a | grep Darwin)
ifneq "$(UNAME)" ""
MAC = 1
endif
LEX = flex
YACC = bison
DEBUG ?= -DDEBUG_LEVEL=LOG_DEBUG_MINOR -ggdb
LINKDEBUG =
ifneq "$(DEBUG)" ""
LINKDEBUG = -DEBUG
endif
OPTIMIZE ?=
LDOUTPUT = -o
UPX = true
CXXOUTPUT = -o
ifdef MAC
CXX = g++ -g -Wall -std=c++98 -pedantic-errors -fno-omit-frame-pointer
LD = g++ -g
else # linux
CXX = g++ -g -Wall -std=c++98 -pedantic-errors -fno-omit-frame-pointer -ffloat-store $(BUILD_ADDITIONAL_ARG)
LD = g++ -g -static $(BUILD_ADDITIONAL_ARG)
endif
CXX += $(DEBUG) $(OPTIMIZE) -DVERSION='"$(VERSION)"' -DBUILD_DATE='"$(BUILD_DATE)"'
CC = $(CXX)
ifneq "$(DEBUG)" ""
VERSION = $(VERSION_NUMBER)debug
else
VERSION = $(VERSION_NUMBER)
endif
OBJS = lslmini.tab.o lex.yy.o lslmini.o symtab.o builtins.o builtins_txt.o types.o values.o final_walk.o operators.o logger.o
all: $(PROGRAM)
$(PROGRAM): $(OBJS)
$(LD) $(LDFLAGS) $(LDOUTPUT)"$@" $^
$(UPX) "$@"
clean:
rm -f $(OBJS) lex.yy.c lslint lslmini.tab.c lslmini.tab.h
check: all
sh test.sh
$(OBJS): lslmini.hh
builtins_txt.cc: builtins.txt
echo "#ifdef _MSC_VER" > builtins_txt.cc
echo "#pragma execution_character_set(\"utf-8\")" >> builtins_txt.cc
echo "#endif" >> builtins_txt.cc
echo "const char *builtins_txt[] = {" >> builtins_txt.cc
sed -e '/^\/\//d; s/"/\\\"/g; s/^/"/; s/$$/",/' \
builtins.txt >> builtins_txt.cc || \
{ rm -f builtins_txt.cc ; false ; }
echo "(char*)0 };" >> builtins_txt.cc
lex.yy.o: lex.yy.c lslmini.tab.h
lex.yy.o lslmini.tab.o lslmini.o symtab.o builtins.o: lslmini.hh symtab.hh ast.hh types.hh lslmini.tab.h
logger.o: lslmini.tab.h logger.hh
types.o: types.hh lslmini.hh lslmini.tab.h
values.o final_walk.o operators.o: lslmini.tab.h
lslmini.tab.c lslmini.tab.h: lslmini.y
$(YACC) -d lslmini.y
lex.yy.c: lslmini.l
$(LEX) lslmini.l
.c.o .cc.o:
$(CXX) $(CXXFLAGS) $(CXXOUTPUT)"$@" -c $<
.PHONY: all clean check