updatified makefile. to infinity and maybe a little further? can't hardly be verbose...
[tinyjs-rewrite.git] / Makefile
blob826508345e113cb10de9c51055e5c3f986b1be19
2 libname = tinyjs
3 exename_main = tjs
4 exename_testbin = run_tests
6 # sources for tinyjs
7 sources = \
8 src/util.cpp \
9 src/scriptvar.cpp \
10 src/varlink.cpp \
11 src/exception.cpp \
12 src/lexer.cpp \
13 src/tinyjs.cpp \
14 src/functions.cpp \
15 src/mathfuncs.cpp
17 # sources for the tinyjs frontend
18 sources_main = \
19 src/main.cpp
21 # sources for the unittest program
22 sources_testbin = \
23 src/run_tests.cpp
25 # names for intermediate files
26 objects = $(sources:.cpp=.o)
27 objects_main = $(sources_main:.cpp=.o)
28 objects_testbin = $(sources_testbin:.cpp=.o)
30 #############################################
31 ### warning: edit below at your own risk! ###
32 #############################################
34 # construct the physical library file from the library name
35 libfile = lib$(libname).a
37 # need C++11 support (not going to change, sorry folks)
38 CXX = clang++ -std=c++11
40 # flags for header file paths
41 INCFLAGS = -Iinclude
43 # remove underscore for heavy-duty checks.
44 # WARNING: VERBOSE
45 _WFLAGS = \
46 -pedantic -Wall -Wextra \
47 -Wcast-align \
48 -Wcast-qual \
49 -Wctor-dtor-privacy \
50 -Wdisabled-optimization \
51 -Wformat=2 \
52 -Winit-self \
53 -Wmissing-declarations \
54 -Wold-style-cast \
55 -Woverloaded-virtual \
56 -Wredundant-decls \
57 -Wshadow \
58 -Wsign-conversion \
59 -Wsign-promo \
60 -Wstrict-overflow=5 \
61 -Wswitch-default \
62 -Wundef \
63 -Wno-unused
65 # compiler flags
66 CFLAGS = $(INCFLAGS) $(WFLAGS) -c -g -rdynamic -D_DEBUG
68 # linker flags
69 LDFLAGS = -g -rdynamic -L. -Wl,-rpath=.
70 BINFLAGS = -l$(libname) $(LDFLAGS)
72 ##########################
73 #### tasks begin here ####
74 ##########################
76 # 'default' task
77 all: $(objects) $(libfile) $(exename_testbin) $(exename_main)
79 # task for building the libfile (static or dynamic -- modify accordingly!)
80 $(libfile): $(objects)
81 ar rcs $(libfile) $(objects)
83 # task for building our frontend executable
84 $(exename_main): $(libfile) $(objects_main)
85 $(CXX) -o $(exename_main) $(objects_main) $(BINFLAGS)
87 # task for building our unittesting application
88 $(exename_testbin): $(libfile) $(objects_testbin)
89 $(CXX) -o $(exename_testbin) $(objects_testbin) $(BINFLAGS)
91 # task for cleaning up intermediate files
92 clean:
93 rm -f $(objects)
94 rm -f $(objects_main)
95 rm -f $(objects_testbin)
97 # task for cleaning up everything else as well, leaving
98 # us with the sources only (hence **dist**clean)
99 distclean: clean
100 rm -f $(libfile)
101 rm -f $(exename_main)
102 rm -f $(exename_testbin)
104 # invoke distclean, and rebuild every binary
105 rebuild: distclean all
107 # the 'sed' part here is to strip color codes from the diagnostic
108 # output -- specifically from clang. only reason being that NppExec
109 # (yes, the Notepad++ plugin) can't handle it. sorry :-)
110 .cpp.o:
111 $(CXX) $(CFLAGS) $< -o $@ 2>&1 | sed 's/\o33\[30m/\o33[37m/g'