1 #
2 # This file and its contents are supplied under the terms of the
3 # Common Development and Distribution License ("CDDL"), version 1.0.
4 # You may only use this file in accordance with the terms of version
5 # 1.0 of the CDDL.
6 #
7 # A full copy of the text of the CDDL should have accompanied this
8 # source. A copy of the CDDL is also available via the Internet at
9 # http://www.illumos.org/license/CDDL.
10 #
11 # Copyright 2019 Joyent, Inc.
12 #
13
14 #
15 # The src/ sub-directory is un-modified copy of
16 # https://github.com/illumos/smatch/tree/0.5.1-il-6
17 #
18 # This Makefile installs just enough for us to be able to run smatch
19 # locally.
20 #
21
22 PROG = smatch
23 SPARSE_VERSION = 0.5.1-il-6
24
25 include ../Makefile.tools
26
27 # We have to build smatch before we can use cw
28 i386_CC = $(GNUC_ROOT)/bin/gcc
29 sparc_CC = $(GNUC_ROOT)/bin/gcc
30 # sparc doesn't recognise -msave-args
31 i386_SMATCHFLAGS = -msave-args
32 sparc_SMATCHFLAGS =
33
34 CFLAGS = -O -m64 $($(MACH)_SMATCHFLAGS) -D__sun -Wall -Wno-unknown-pragmas -std=gnu99 -nodefaultlibs
35
36 SMATCHDATADIR = $(ROOTONBLDSHARE)/smatch
37
38 CFLAGS += -DSMATCHDATADIR='"$(SMATCHDATADIR)"'
39 CFLAGS += -DGCC_BASE='"/no/such/dir"'
40 CFLAGS += -DMULTIARCH_TRIPLET=NULL
41
42 LDLIBS += -lsqlite3 -lcrypto -lm -lgcc -lc
43 LDFLAGS = $(MAPFILE.NES:%=-Wl,-M%)
44 LDFLAGS += -L$(NATIVE_ADJUNCT)/lib -R$(NATIVE_ADJUNCT)/lib
45
46 CPPFLAGS += -nostdinc
47 CPPFLAGS += -Isrc/
48 CPPFLAGS += -I$(NATIVE_ADJUNCT)/include
49
50 # no install.bin
51 INS.file = $(RM) $@; $(CP) $< $(@D); $(CHMOD) $(FILEMODE) $@
52 INS.dir = mkdir -p $@; $(CHMOD) $(DIRMODE) $@
53
54 SMATCH_CHECK_OBJS:sh=ls src/check_*.c | sed -e 's+\.c+.o+;s+src/++;'
55
56 OBJS = smatch.o $(SMATCH_CHECK_OBJS)
57
58 OBJS += smatch_flow.o smatch_conditions.o smatch_slist.o smatch_states.o \
59 smatch_helper.o smatch_type.o smatch_hooks.o smatch_function_hooks.o \
60 smatch_modification_hooks.o smatch_extra.o smatch_estate.o smatch_math.o \
61 smatch_sval.o smatch_ranges.o smatch_implied.o smatch_ignore.o smatch_project.o \
62 smatch_var_sym.o smatch_tracker.o smatch_files.o smatch_expression_stacks.o \
63 smatch_equiv.o smatch_buf_size.o smatch_strlen.o smatch_capped.o smatch_db.o \
64 smatch_expressions.o smatch_returns.o smatch_parse_call_math.o \
65 smatch_param_limit.o smatch_param_filter.o \
66 smatch_param_set.o smatch_comparison.o smatch_param_compare_limit.o smatch_local_values.o \
67 smatch_function_ptrs.o smatch_annotate.o smatch_string_list.o \
68 smatch_param_cleared.o smatch_start_states.o \
69 smatch_recurse.o smatch_data_source.o smatch_type_val.o \
70 smatch_common_functions.o smatch_struct_assignment.o \
71 smatch_unknown_value.o smatch_stored_conditions.o avl.o \
72 smatch_function_info.o smatch_links.o smatch_auto_copy.o \
73 smatch_type_links.o smatch_untracked_param.o smatch_impossible.o \
74 smatch_strings.o smatch_param_used.o smatch_container_of.o smatch_address.o \
75 smatch_buf_comparison.o smatch_real_absolute.o smatch_scope.o \
76 smatch_imaginary_absolute.o smatch_parameter_names.o \
77 smatch_return_to_param.o smatch_passes_array_size.o \
78 smatch_constraints.o smatch_constraints_required.o \
79 smatch_fn_arg_link.o smatch_about_fn_ptr_arg.o smatch_mtag.o \
80 smatch_mtag_map.o smatch_mtag_data.o \
81 smatch_param_to_mtag_data.o smatch_mem_tracker.o smatch_array_values.o \
82 smatch_nul_terminator.o smatch_assigned_expr.o smatch_kernel_user_data.o \
83 smatch_statement_count.o smatch_bits.o smatch_integer_overflow.o
84
85 OBJS += target.o parse.o tokenize.o pre-process.o symbol.o lib.o scope.o \
86 expression.o show-parse.o evaluate.o expand.o inline.o linearize.o \
87 char.o sort.o allocate.o compat-linux.o ptrlist.o \
88 builtin.o \
89 stats.o \
90 flow.o cse.o simplify.o memops.o liveness.o storage.o unssa.o \
91 dissect.o \
92 macro_table.o token_store.o hashtable.o
93
94 SMATCH_DATA = \
95 illumos_kernel.skipped_functions \
96 illumos_user.skipped_functions
97
98 SMATCH_DB_DATA = \
99 return_states.schema \
100 call_implies.schema \
101 type_value.schema \
102 param_map.schema \
103 function_type_size.schema \
104 parameter_name.schema \
105 fn_ptr_data_link.schema \
106 constraints.schema \
107 mtag_about.schema \
108 type_info.schema \
109 function_type_info.schema \
110 caller_info.schema \
111 function_type_value.schema \
112 return_implies.schema \
113 type_size.schema \
114 constraints_required.schema \
115 fn_data_link.schema \
116 mtag_alias.schema \
117 common_caller_info.schema \
118 data_info.schema \
119 function_type.schema \
120 db.schema \
121 mtag_data.schema \
122 function_ptr.schema \
123 sink_info.schema \
124 local_values.schema \
125 mtag_map.schema
126
127 ROOTONBLDDATAFILES = $(SMATCH_DATA:%=$(SMATCHDATADIR)/smatch_data/%)
128 ROOTONBLDDATAFILES += $(SMATCH_DB_DATA:%=$(SMATCHDATADIR)/smatch_data/db/%)
129
130 BUILT_HEADERS = src/version.h src/check_list_local.h
131
132 .KEEP_STATE:
133
134 .PARALLEL: $(OBJS)
135
136 all: $(PROG)
137
138 install: all .WAIT $(ROOTONBLDMACHPROG) $(ROOTONBLDDATAFILES)
139
140 clean:
141 rm -f $(OBJS) $(BUILT_HEADERS)
142
143 $(ROOTONBLDDATAFILES): $(SMATCHDATADIR)/smatch_data/db
144
145 $(SMATCHDATADIR)/smatch_data/%: src/smatch_data/%
146 $(INS.file)
147
148 $(SMATCHDATADIR)/smatch_data/db:
149 $(INS.dir)
150
151 $(SMATCHDATADIR)/smatch_data:
152 $(INS.dir)
153
154 $(PROG): $(OBJS)
155 $(LINK.c) $(OBJS) -o $@ $(LDLIBS)
156 $(POST_PROCESS)
157
158 %.o: src/%.c $(BUILT_HEADERS)
159 $(COMPILE.c) -o $@ $<
160
161 %.o: src/cwchash/%.c
162 $(COMPILE.c) -o $@ $<
163
164 src/check_list_local.h:
165 touch src/check_list_local.h
166
167 src/version.h:
168 echo '#define SPARSE_VERSION "$(SPARSE_VERSION)"' > src/version.h
169
170 include ../Makefile.targ
|
1 #
2 # This file and its contents are supplied under the terms of the
3 # Common Development and Distribution License ("CDDL"), version 1.0.
4 # You may only use this file in accordance with the terms of version
5 # 1.0 of the CDDL.
6 #
7 # A full copy of the text of the CDDL should have accompanied this
8 # source. A copy of the CDDL is also available via the Internet at
9 # http://www.illumos.org/license/CDDL.
10 #
11 # Copyright 2019 Joyent, Inc.
12 #
13
14 #
15 # The src/ sub-directory is un-modified copy of
16 # https://github.com/illumos/smatch/tree/$SPARSE_VERSION
17 #
18 # This Makefile installs just enough for us to be able to run smatch
19 # locally.
20 #
21
22 PROG = smatch
23 SPARSE_VERSION = 0.6.1-rc1-il-1
24
25 include ../Makefile.tools
26
27 # We have to build smatch before we can use cw
28 i386_CC = $(GNUC_ROOT)/bin/gcc
29 sparc_CC = $(GNUC_ROOT)/bin/gcc
30 # sparc doesn't recognise -msave-args
31 i386_SMATCHFLAGS = -msave-args
32 sparc_SMATCHFLAGS =
33
34 CFLAGS = -O -m64 $($(MACH)_SMATCHFLAGS) -D__sun -Wall -Wno-unknown-pragmas -std=gnu99 -nodefaultlibs
35
36 SMATCHDATADIR = $(ROOTONBLDSHARE)/smatch
37
38 CFLAGS += -DSMATCHDATADIR='"$(SMATCHDATADIR)"'
39 CFLAGS += -DGCC_BASE='"/no/such/dir"'
40 CFLAGS += -DMULTIARCH_TRIPLET=NULL
41
42 LDLIBS += -lsqlite3 -lcrypto -lm -lgcc -lc
43 LDFLAGS = $(MAPFILE.NES:%=-Wl,-M%)
44 LDFLAGS += -L$(NATIVE_ADJUNCT)/lib -R$(NATIVE_ADJUNCT)/lib
45
46 CPPFLAGS += -nostdinc
47 CPPFLAGS += -Isrc/
48 CPPFLAGS += -I$(NATIVE_ADJUNCT)/include
49
50 # no install.bin
51 INS.file = $(RM) $@; $(CP) $< $(@D); $(CHMOD) $(FILEMODE) $@
52 INS.dir = mkdir -p $@; $(CHMOD) $(DIRMODE) $@
53
54 # fine for us
55 OS=linux
56
57 LIB_OBJS =
58 LIB_OBJS += allocate.o
59 LIB_OBJS += builtin.o
60 LIB_OBJS += char.o
61 LIB_OBJS += compat-$(OS).o
62 LIB_OBJS += cse.o
63 LIB_OBJS += dissect.o
64 LIB_OBJS += dominate.o
65 LIB_OBJS += evaluate.o
66 LIB_OBJS += expand.o
67 LIB_OBJS += expression.o
68 LIB_OBJS += flow.o
69 LIB_OBJS += flowgraph.o
70 LIB_OBJS += inline.o
71 LIB_OBJS += ir.o
72 LIB_OBJS += lib.o
73 LIB_OBJS += linearize.o
74 LIB_OBJS += liveness.o
75 LIB_OBJS += memops.o
76 LIB_OBJS += opcode.o
77 LIB_OBJS += optimize.o
78 LIB_OBJS += parse.o
79 LIB_OBJS += pre-process.o
80 LIB_OBJS += ptrlist.o
81 LIB_OBJS += ptrmap.o
82 LIB_OBJS += scope.o
83 LIB_OBJS += show-parse.o
84 LIB_OBJS += simplify.o
85 LIB_OBJS += sort.o
86 LIB_OBJS += ssa.o
87 LIB_OBJS += sset.o
88 LIB_OBJS += stats.o
89 LIB_OBJS += storage.o
90 LIB_OBJS += symbol.o
91 LIB_OBJS += target.o
92 LIB_OBJS += tokenize.o
93 LIB_OBJS += unssa.o
94 LIB_OBJS += utils.o
95 LIB_OBJS += macro_table.o
96 LIB_OBJS += token_store.o
97 LIB_OBJS += hashtable.o
98
99 SMATCH_OBJS =
100 SMATCH_OBJS += avl.o
101 SMATCH_OBJS += smatch_about_fn_ptr_arg.o
102 SMATCH_OBJS += smatch_address.o
103 SMATCH_OBJS += smatch_annotate.o
104 SMATCH_OBJS += smatch_array_values.o
105 SMATCH_OBJS += smatch_assigned_expr.o
106 SMATCH_OBJS += smatch_bits.o
107 SMATCH_OBJS += smatch_buf_comparison.o
108 SMATCH_OBJS += smatch_buf_size.o
109 SMATCH_OBJS += smatch_capped.o
110 SMATCH_OBJS += smatch_common_functions.o
111 SMATCH_OBJS += smatch_comparison.o
112 SMATCH_OBJS += smatch_conditions.o
113 SMATCH_OBJS += smatch_constraints.o
114 SMATCH_OBJS += smatch_constraints_required.o
115 SMATCH_OBJS += smatch_container_of.o
116 SMATCH_OBJS += smatch_data_source.o
117 SMATCH_OBJS += smatch_db.o
118 SMATCH_OBJS += smatch_equiv.o
119 SMATCH_OBJS += smatch_estate.o
120 SMATCH_OBJS += smatch_expressions.o
121 SMATCH_OBJS += smatch_expression_stacks.o
122 SMATCH_OBJS += smatch_extra.o
123 SMATCH_OBJS += smatch_files.o
124 SMATCH_OBJS += smatch_flow.o
125 SMATCH_OBJS += smatch_fn_arg_link.o
126 SMATCH_OBJS += smatch_function_hooks.o
127 SMATCH_OBJS += smatch_function_info.o
128 SMATCH_OBJS += smatch_function_ptrs.o
129 SMATCH_OBJS += smatch_helper.o
130 SMATCH_OBJS += smatch_hooks.o
131 SMATCH_OBJS += smatch_ignore.o
132 SMATCH_OBJS += smatch_imaginary_absolute.o
133 SMATCH_OBJS += smatch_implied.o
134 SMATCH_OBJS += smatch_impossible.o
135 SMATCH_OBJS += smatch_integer_overflow.o
136 SMATCH_OBJS += smatch_kernel_user_data.o
137 SMATCH_OBJS += smatch_links.o
138 SMATCH_OBJS += smatch_math.o
139 SMATCH_OBJS += smatch_mem_tracker.o
140 SMATCH_OBJS += smatch_modification_hooks.o
141 SMATCH_OBJS += smatch_mtag_data.o
142 SMATCH_OBJS += smatch_mtag_map.o
143 SMATCH_OBJS += smatch_mtag.o
144 SMATCH_OBJS += smatch_nul_terminator.o
145 SMATCH_OBJS += smatch_param_cleared.o
146 SMATCH_OBJS += smatch_param_compare_limit.o
147 SMATCH_OBJS += smatch_parameter_names.o
148 SMATCH_OBJS += smatch_param_filter.o
149 SMATCH_OBJS += smatch_param_limit.o
150 SMATCH_OBJS += smatch_param_set.o
151 SMATCH_OBJS += smatch_param_to_mtag_data.o
152 SMATCH_OBJS += smatch_param_used.o
153 SMATCH_OBJS += smatch_parse_call_math.o
154 SMATCH_OBJS += smatch_passes_array_size.o
155 SMATCH_OBJS += smatch_project.o
156 SMATCH_OBJS += smatch_ranges.o
157 SMATCH_OBJS += smatch_real_absolute.o
158 SMATCH_OBJS += smatch_recurse.o
159 SMATCH_OBJS += smatch_returns.o
160 SMATCH_OBJS += smatch_return_to_param.o
161 SMATCH_OBJS += smatch_scope.o
162 SMATCH_OBJS += smatch_slist.o
163 SMATCH_OBJS += smatch_start_states.o
164 SMATCH_OBJS += smatch_statement_count.o
165 SMATCH_OBJS += smatch_states.o
166 SMATCH_OBJS += smatch_stored_conditions.o
167 SMATCH_OBJS += smatch_string_list.o
168 SMATCH_OBJS += smatch_strings.o
169 SMATCH_OBJS += smatch_strlen.o
170 SMATCH_OBJS += smatch_struct_assignment.o
171 SMATCH_OBJS += smatch_sval.o
172 SMATCH_OBJS += smatch_tracker.o
173 SMATCH_OBJS += smatch_type_links.o
174 SMATCH_OBJS += smatch_type.o
175 SMATCH_OBJS += smatch_type_val.o
176 SMATCH_OBJS += smatch_unknown_value.o
177 SMATCH_OBJS += smatch_untracked_param.o
178 SMATCH_OBJS += smatch_var_sym.o
179
180 SMATCH_CHECK_OBJS:sh=ls src/check_*.c | sed -e 's+\.c+.o+;s+src/++;'
181
182 OBJS = smatch.o $(LIB_OBJS) $(SMATCH_OBJS) $(SMATCH_CHECK_OBJS)
183
184 SMATCH_DATA = \
185 illumos_kernel.skipped_functions \
186 illumos_user.skipped_functions
187
188 SMATCH_DB_DATA =
189 SMATCH_DB_DATA += call_implies.schema
190 SMATCH_DB_DATA += function_ptr.schema
191 SMATCH_DB_DATA += mtag_map.schema
192 SMATCH_DB_DATA += caller_info.schema
193 SMATCH_DB_DATA += function_type.schema
194 SMATCH_DB_DATA += param_map.schema
195 SMATCH_DB_DATA += common_caller_info.schema
196 SMATCH_DB_DATA += function_type_info.schema
197 SMATCH_DB_DATA += parameter_name.schema
198 SMATCH_DB_DATA += constraints.schema
199 SMATCH_DB_DATA += function_type_size.schema
200 SMATCH_DB_DATA += return_implies.schema
201 SMATCH_DB_DATA += constraints_required.schema
202 SMATCH_DB_DATA += function_type_value.schema
203 SMATCH_DB_DATA += return_states.schema
204 SMATCH_DB_DATA += data_info.schema
205 SMATCH_DB_DATA += local_values.schema
206 SMATCH_DB_DATA += sink_info.schema
207 SMATCH_DB_DATA += db.schema
208 SMATCH_DB_DATA += mtag_about.schema
209 SMATCH_DB_DATA += type_info.schema
210 SMATCH_DB_DATA += fn_data_link.schema
211 SMATCH_DB_DATA += mtag_alias.schema
212 SMATCH_DB_DATA += type_size.schema
213 SMATCH_DB_DATA += fn_ptr_data_link.schema
214 SMATCH_DB_DATA += mtag_data.schema
215 SMATCH_DB_DATA += type_value.schema
216
217 ROOTONBLDDATAFILES = $(SMATCH_DATA:%=$(SMATCHDATADIR)/smatch_data/%)
218 ROOTONBLDDATAFILES += $(SMATCH_DB_DATA:%=$(SMATCHDATADIR)/smatch_data/db/%)
219
220 BUILT_HEADERS = src/version.h src/check_list_local.h
221
222 .KEEP_STATE:
223
224 .PARALLEL: $(OBJS)
225
226 all: $(PROG)
227
228 install: all .WAIT $(ROOTONBLDMACHPROG) $(ROOTONBLDDATAFILES)
229
230 clean:
231 rm -f $(OBJS) $(BUILT_HEADERS)
232
233 $(ROOTONBLDDATAFILES): $(SMATCHDATADIR)/smatch_data/db
234
235 $(SMATCHDATADIR)/smatch_data/%: src/smatch_data/%
236 $(INS.file)
237
238 $(SMATCHDATADIR)/smatch_data/db:
239 $(INS.dir)
240
241 $(SMATCHDATADIR)/smatch_data:
242 $(INS.dir)
243
244 $(PROG): $(OBJS)
245 pwd "LEVON $(pwd)
246 $(LINK.c) $(OBJS) -o $@ $(LDLIBS)
247 $(POST_PROCESS)
248
249 %.o: src/%.c $(BUILT_HEADERS)
250 $(COMPILE.c) -o $@ $<
251
252 %.o: src/cwchash/%.c
253 $(COMPILE.c) -o $@ $<
254
255 src/check_list_local.h:
256 touch src/check_list_local.h
257
258 src/version.h:
259 echo '#define SPARSE_VERSION "$(SPARSE_VERSION)"' > src/version.h
260
261 include ../Makefile.targ
|