xref: /titanic_52/usr/src/lib/libsqlite/Makefile.com (revision f64ca10231919db05e806441ccd6186ea9c6e734)
1#
2# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
3# Use is subject to license terms.
4# Copyright 2015 Igor Kozhukhov <ikozhukhov@gmail.com>
5#
6
7# Make the SO name unlikely to conflict with any other
8# libsqlite that might also be found on the system.
9LIBRARY = libsqlite-sys.a
10
11VERS = .2.8.15
12OBJECTS = \
13	attach.o	\
14	auth.o		\
15	btree.o		\
16	btree_rb.o	\
17	build.o		\
18	copy.o		\
19	date.o		\
20	delete.o	\
21	encode.o	\
22	expr.o		\
23	func.o		\
24	hash.o		\
25	insert.o	\
26	main.o		\
27	opcodes.o	\
28	os.o		\
29	pager.o		\
30	parse.o		\
31	pragma.o	\
32	printf.o	\
33	random.o	\
34	select.o	\
35	table.o		\
36	tokenize.o	\
37	trigger.o	\
38	update.o	\
39	util.o		\
40	vacuum.o	\
41	vdbe.o		\
42	vdbeaux.o	\
43	where.o
44
45include $(SRC)/lib/Makefile.lib
46
47# install this library in the root filesystem
48include $(SRC)/lib/Makefile.rootfs
49
50SRCDIR = ../src
51TOOLDIR = ../tool
52$(DYNLIB) := LDLIBS += -lc
53LIBS = $(DYNLIB) $(LINTLIB) $(NATIVERELOC)
54
55$(LINTLIB) :=	SRCS = ../$(LINTSRC)
56
57# generated sources
58GENSRC = opcodes.c parse.c
59
60# all sources
61SRCS = \
62	$(GENSRC) \
63	$(SRCDIR)/attach.c	\
64	$(SRCDIR)/auth.c	\
65	$(SRCDIR)/btree.c	\
66	$(SRCDIR)/btree_rb.c	\
67	$(SRCDIR)/build.c	\
68	$(SRCDIR)/copy.c	\
69	$(SRCDIR)/date.c	\
70	$(SRCDIR)/delete.c	\
71	$(SRCDIR)/encode.c	\
72	$(SRCDIR)/expr.c	\
73	$(SRCDIR)/func.c	\
74	$(SRCDIR)/hash.c	\
75	$(SRCDIR)/insert.c	\
76	$(SRCDIR)/main.c	\
77	$(SRCDIR)/os.c		\
78	$(SRCDIR)/pager.c	\
79	$(SRCDIR)/pragma.c	\
80	$(SRCDIR)/printf.c	\
81	$(SRCDIR)/random.c	\
82	$(SRCDIR)/select.c	\
83	$(SRCDIR)/table.c	\
84	$(SRCDIR)/tokenize.c	\
85	$(SRCDIR)/update.c	\
86	$(SRCDIR)/util.c	\
87	$(SRCDIR)/vacuum.c	\
88	$(SRCDIR)/vdbe.c	\
89	$(SRCDIR)/vdbeaux.c	\
90	$(SRCDIR)/where.c	\
91	$(SRCDIR)/trigger.c
92
93MYCPPFLAGS = -D_REENTRANT -DTHREADSAFE=1 -DHAVE_USLEEP=1 -I. -I.. -I$(SRCDIR)
94CPPFLAGS += $(MYCPPFLAGS)
95
96CERRWARN += -_gcc=-Wno-implicit-function-declaration
97CERRWARN += -_gcc=-Wno-uninitialized
98CERRWARN += -_gcc=-Wno-unused-function
99CERRWARN += -_gcc=-Wno-unused-label
100
101MAPFILES = ../mapfile-sqlite
102
103# headers generated here
104GENHDR = opcodes.h parse.h
105
106# Header files used by all library source files.
107#
108HDR = \
109	$(GENHDR) \
110	$(SRCDIR)/btree.h	\
111	$(SRCDIR)/config.h	\
112	$(SRCDIR)/hash.h	\
113	$(SRCDIR)/os.h		\
114	../sqlite.h		\
115	$(SRCDIR)/sqliteInt.h	\
116	$(SRCDIR)/vdbe.h	\
117	$(SRCDIR)/vdbeInt.h
118
119#
120# Sources used for test harness
121#
122TESTSRC = \
123	$(SRCDIR)/tclsqlite.c	\
124	$(SRCDIR)/btree.c	\
125	$(SRCDIR)/func.c	\
126	$(SRCDIR)/os.c		\
127	$(SRCDIR)/pager.c	\
128	$(SRCDIR)/test1.c	\
129	$(SRCDIR)/test2.c	\
130	$(SRCDIR)/test3.c	\
131	$(SRCDIR)/md5.c
132
133TESTOBJS = $(TESTSRC:$(SRCDIR)/%.c=%.o)
134
135TESTCLEAN = $(TESTOBJS) test.db test.tcl test1.bt test2.db testdb
136
137#
138# Native variant (needed by cmd/configd)
139#
140NATIVERELOC = libsqlite-native.o
141NATIVEPROGS = testfixture
142NATIVEOBJS = $(OBJS:%.o=%-native.o)
143
144NATIVETARGETS = $(NATIVEPROGS) $(NATIVEOBJS) $(NATIVERELOC)
145
146$(NATIVETARGETS) :=	CC = $(NATIVECC)
147$(NATIVETARGETS) :=	LD = $(NATIVELD)
148$(NATIVETARGETS) :=	CFLAGS = $(NATIVE_CFLAGS)
149$(NATIVETARGETS) :=	CPPFLAGS = $(MYCPPFLAGS)
150$(NATIVETARGETS) :=	LDFLAGS =
151$(NATIVETARGETS) :=	LDLIBS = -lc
152
153$(OBJS) :=		CFLAGS += $(CTF_FLAGS)
154$(OBJS) :=		CTFCONVERT_POST = $(CTFCONVERT_O)
155
156TCLBASE = /usr/sfw
157TCLVERS = tcl8.3
158
159testfixture := MYCPPFLAGS += -I$(TCLBASE)/include -DTCLSH -DSQLITE_TEST=1
160#
161# work around compiler issues
162#
163testfixture := CFLAGS += \
164	-erroff=E_ARRAY_OF_INCOMPLETE \
165	-erroff=E_ARG_INCOMPATIBLE_WITH_ARG
166
167testfixture := LDLIBS += -R$(TCLBASE)/lib -L$(TCLBASE)/lib -l$(TCLVERS) -lm -ldl
168
169CLEANFILES += \
170	$(NATIVETARGETS) \
171	$(TESTCLEAN)	\
172	lemon		\
173	lemon.o		\
174	lempar.c	\
175	opcodes.c	\
176	opcodes.h	\
177	parse_tmp.c	\
178	parse_tmp.h	\
179	parse_tmp.out	\
180	parse_tmp.y	\
181	parse.c		\
182	parse.h
183
184ENCODING  = ISO8859
185
186
187.PARALLEL: $(OBJS) $(OBJS:%.o=%-native.o)
188.KEEP_STATE:
189
190# This is the default Makefile target.  The objects listed here
191# are what get build when you type just "make" with no arguments.
192#
193all:		$(LIBS)
194install:	all \
195		$(ROOTLIBDIR)/$(DYNLIB) \
196		$(ROOTLIBDIR)/$(LINTLIB) \
197		$(ROOTLIBDIR)/$(NATIVERELOC)
198
199lint:
200
201all_h: $(GENHDR)
202
203$(ROOTLIBDIR)/$(NATIVERELOC)	:= FILEMODE= 644
204$(ROOTLINTDIR)/$(LINTLIB)	:= FILEMODE= 644
205
206$(ROOTLINK): $(ROOTLIBDIR) $(ROOTLIBDIR)/$(DYNLIB)
207	$(INS.liblink)
208
209$(ROOTLINTDIR)/%: ../%
210	$(INS.file)
211
212native: $(NATIVERELOC)
213
214$(NATIVERELOC):	objs .WAIT $(OBJS:%.o=%-native.o)
215	$(LD) -r -o $(NATIVERELOC) $(OBJS:%.o=%-native.o)
216
217opcodes.h: $(SRCDIR)/vdbe.c
218	@echo "Generating $@"; \
219	 $(RM) -f $@ ; \
220	 echo '/* Automatically generated file.  Do not edit */' > $@ ; \
221	 grep '^case OP_' $(SRCDIR)/vdbe.c | \
222	    sed -e 's/://' | \
223	    $(AWK) '{printf "#define %-30s %3d\n", $$2, ++cnt}' >> $@
224
225opcodes.c: $(SRCDIR)/vdbe.c
226	@echo "Generating $@"; \
227	 $(RM) -f $@ ; \
228	 echo '/* Automatically generated file.  Do not edit */' > $@ ; \
229	 echo 'char *sqliteOpcodeNames[] = { "???", ' >> $@ ; \
230	 grep '^case OP_' $(SRCDIR)/vdbe.c | \
231	    sed -e 's/^.*OP_/  "/' -e 's/:.*$$/", /' >> $@ ; \
232	 echo '};' >> $@
233
234testfixture: FRC
235	@if [ -f $(TCLBASE)/include/tcl.h ]; then \
236		unset SUNPRO_DEPENDENCIES; \
237		echo $(LINK.c) -o testfixture $(TESTSRC) $(LIBRARY) $(LDLIBS) ;\
238		exec $(LINK.c) -o testfixture $(TESTSRC) $(LIBRARY) $(LDLIBS) ;\
239	else \
240		echo "$(TCLBASE)/include/tcl.h: not found."; \
241		exit 1; \
242	fi
243
244parse.h parse.c : $(SRCDIR)/parse.y $(TOOLDIR)/lemon.c $(TOOLDIR)/lempar.c
245	-$(RM) parse_tmp.y lempar.c
246	$(CP) $(SRCDIR)/parse.y parse_tmp.y
247	$(CP) $(TOOLDIR)/lempar.c lempar.c
248	$(NATIVECC) $(NATIVE_CFLAGS) -o lemon $(TOOLDIR)/lemon.c
249	./lemon parse_tmp.y
250	-$(RM) parse.c parse.h
251	$(CP) parse_tmp.h parse.h
252	$(CP) parse_tmp.c parse.c
253
254objs/%-native.o: $(SRCDIR)/%.c $(GENHDR)
255	$(COMPILE.c) -o $@ $<
256	$(POST_PROCESS_O)
257
258objs/%-native.o: %.c $(GENHDR)
259	$(COMPILE.c) -o $@ $<
260	$(POST_PROCESS_O)
261
262objs/parse-native.o: parse.c $(GENHDR)
263	$(COMPILE.c) -o $@ parse.c
264	$(POST_PROCESS_O)
265
266objs/%.o pics/%.o: $(SRCDIR)/%.c $(GENHDR)
267	$(COMPILE.c) -o $@ $<
268	$(POST_PROCESS_O)
269
270objs/%.o pics/%.o: %.c $(GENHDR)
271	$(COMPILE.c) -o $@ $<
272	$(POST_PROCESS_O)
273
274# need direct rules for generated files
275objs/opcodes.o pics/opcodes.o: opcodes.c $(GENHDR)
276	$(COMPILE.c) -o $@ opcodes.c
277	$(POST_PROCESS_O)
278
279objs/parse.o pics/parse.o: parse.c $(GENHDR)
280	$(COMPILE.c) -o $@ parse.c
281	$(POST_PROCESS_O)
282
283include $(SRC)/lib/Makefile.targ
284
285FRC:
286