Merge remote-tracking branch 'origin/master'
[unleashed/lotheac.git] / usr / src / lib / libsqlite / Makefile.com
blob030bb6021a38afdf9d862f321287a8ce0a42efdd
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 # Copyright 2016 Nexenta Systems, Inc.  All rights reserved.
6 # Copyright (c) 2018, Joyent, Inc.
9 # Make the SO name unlikely to conflict with any other
10 # libsqlite that might also be found on the system.
11 LIBRARY = libsqlite-sys.a
13 VERS = .2.8.15
14 OBJECTS = \
15         attach.o        \
16         auth.o          \
17         btree.o         \
18         btree_rb.o      \
19         build.o         \
20         copy.o          \
21         date.o          \
22         delete.o        \
23         encode.o        \
24         expr.o          \
25         func.o          \
26         hash.o          \
27         insert.o        \
28         main.o          \
29         opcodes.o       \
30         os.o            \
31         pager.o         \
32         parse.o         \
33         pragma.o        \
34         printf.o        \
35         random.o        \
36         select.o        \
37         table.o         \
38         tokenize.o      \
39         trigger.o       \
40         update.o        \
41         util.o          \
42         vacuum.o        \
43         vdbe.o          \
44         vdbeaux.o       \
45         where.o
47 include $(SRC)/lib/Makefile.lib
49 # install this library in the root filesystem
50 include $(SRC)/lib/Makefile.rootfs
52 SRCDIR = ../src
53 TOOLDIR = ../tool
54 $(DYNLIB) := LDLIBS += -lc
55 LIBS = $(DYNLIB) $(NATIVERELOC)
57 # generated sources
58 GENSRC = opcodes.c parse.c
60 # all sources
61 SRCS = \
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
93 MYCPPFLAGS = -DTHREADSAFE=1 -DHAVE_USLEEP=1 -I. -I.. -I$(SRCDIR)
94 CPPFLAGS += $(MYCPPFLAGS)
96 CERRWARN += -Wno-implicit-function-declaration
97 CERRWARN += -Wno-uninitialized
98 CERRWARN += -Wno-unused-function
99 CERRWARN += -Wno-unused-label
101 # not linted
102 SMATCH=off
104 MAPFILES = ../mapfile-sqlite
106 # headers generated here
107 GENHDR = opcodes.h parse.h
109 # Header files used by all library source files.
111 HDR = \
112         $(GENHDR) \
113         $(SRCDIR)/btree.h       \
114         $(SRCDIR)/config.h      \
115         $(SRCDIR)/hash.h        \
116         $(SRCDIR)/os.h          \
117         ../sqlite.h             \
118         $(SRCDIR)/sqliteInt.h   \
119         $(SRCDIR)/vdbe.h        \
120         $(SRCDIR)/vdbeInt.h
123 # Sources used for test harness
125 TESTSRC = \
126         $(SRCDIR)/tclsqlite.c   \
127         $(SRCDIR)/btree.c       \
128         $(SRCDIR)/func.c        \
129         $(SRCDIR)/os.c          \
130         $(SRCDIR)/pager.c       \
131         $(SRCDIR)/test1.c       \
132         $(SRCDIR)/test2.c       \
133         $(SRCDIR)/test3.c       \
134         $(SRCDIR)/md5.c 
136 TESTOBJS = $(TESTSRC:$(SRCDIR)/%.c=%.o)
138 TESTCLEAN = $(TESTOBJS) test.db test.tcl test1.bt test2.db testdb
141 # Native variant (needed by cmd/configd)
143 NATIVERELOC = libsqlite-native.o
144 NATIVEPROGS = testfixture
145 NATIVEOBJS = $(OBJS:%.o=%-native.o)
147 NATIVETARGETS = $(NATIVEPROGS) $(NATIVEOBJS) $(NATIVERELOC)
149 $(NATIVETARGETS) :=     CC = $(NATIVECC)
150 $(NATIVETARGETS) :=     LD = $(NATIVELD)
151 $(NATIVETARGETS) :=     CFLAGS = $(NATIVE_CFLAGS)
152 $(NATIVETARGETS) :=     CPPFLAGS = $(MYCPPFLAGS)
153 $(NATIVETARGETS) :=     LDFLAGS =
154 $(NATIVETARGETS) :=     LDLIBS = -lc
156 $(OBJS) :=              CFLAGS += $(CTF_FLAGS)
157 $(OBJS) :=              CTFCONVERT_POST = $(CTFCONVERT_O)
159 TCLBASE = /usr/sfw
160 TCLVERS = tcl8.3
162 testfixture := MYCPPFLAGS += -I$(TCLBASE)/include -DTCLSH -DSQLITE_TEST=1
163 testfixture := LDLIBS += -R$(TCLBASE)/lib -L$(TCLBASE)/lib -l$(TCLVERS) -lm -ldl
165 CLEANFILES += \
166         $(NATIVETARGETS) \
167         $(TESTCLEAN)    \
168         lemon           \
169         lemon.o         \
170         lempar.c        \
171         opcodes.c       \
172         opcodes.h       \
173         parse_tmp.c     \
174         parse_tmp.h     \
175         parse_tmp.out   \
176         parse_tmp.y     \
177         parse.c         \
178         parse.h
180 ENCODING  = ISO8859
183 .PARALLEL: $(OBJS) $(OBJS:%.o=%-native.o)
184 .KEEP_STATE:
186 # This is the default Makefile target.  The objects listed here
187 # are what get build when you type just "make" with no arguments.
189 all:            $(LIBS)
190 install:        all \
191                 $(ROOTLIBDIR)/$(DYNLIB) \
192                 $(ROOTLIBDIR)/$(NATIVERELOC)
194 all_h: $(GENHDR)
196 $(ROOTLIBDIR)/$(NATIVERELOC)    := FILEMODE= 644
198 $(ROOTLINK): $(ROOTLIBDIR) $(ROOTLIBDIR)/$(DYNLIB)
199         $(INS.liblink)
201 native: $(NATIVERELOC)
203 $(NATIVERELOC): objs .WAIT $(OBJS:%.o=%-native.o)
204         $(LD) -r -o $(NATIVERELOC) $(OBJS:%.o=%-native.o)
206 opcodes.h: $(SRCDIR)/vdbe.c
207         @echo "Generating $@"; \
208          $(RM) -f $@ ; \
209          echo '/* Automatically generated file.  Do not edit */' > $@ ; \
210          grep '^case OP_' $(SRCDIR)/vdbe.c | \
211             sed -e 's/://' | \
212             $(AWK) '{printf "#define %-30s %3d\n", $$2, ++cnt}' >> $@
214 opcodes.c: $(SRCDIR)/vdbe.c
215         @echo "Generating $@"; \
216          $(RM) -f $@ ; \
217          echo '/* Automatically generated file.  Do not edit */' > $@ ; \
218          echo 'char *sqliteOpcodeNames[] = { "???", ' >> $@ ; \
219          grep '^case OP_' $(SRCDIR)/vdbe.c | \
220             sed -e 's/^.*OP_/  "/' -e 's/:.*$$/", /' >> $@ ; \
221          echo '};' >> $@
223 testfixture: FRC
224         @if [ -f $(TCLBASE)/include/tcl.h ]; then \
225                 unset SUNPRO_DEPENDENCIES; \
226                 echo $(LINK.c) -o testfixture $(TESTSRC) $(LIBRARY) $(LDLIBS) ;\
227                 exec $(LINK.c) -o testfixture $(TESTSRC) $(LIBRARY) $(LDLIBS) ;\
228         else \
229                 echo "$(TCLBASE)/include/tcl.h: not found."; \
230                 exit 1; \
231         fi
233 # Prevent Makefile.lib $(PICS) := from adding PICFLAGS
234 # by building lemon in a recursive make invocation.
235 # Otherwise, this target causes a rebuild every time after
236 # the PICS target builds this one way, then lint the other.
237 parse.h parse.c : $(SRCDIR)/parse.y $(TOOLDIR)/lemon.c $(TOOLDIR)/lempar.c
238         -$(RM) parse_tmp.y lempar.c
239         $(CP) $(SRCDIR)/parse.y parse_tmp.y
240         $(CP) $(TOOLDIR)/lempar.c lempar.c
241         $(MAKE) lemon
242         ./lemon parse_tmp.y
243         -$(RM) parse.c parse.h
244         $(CP) parse_tmp.h parse.h
245         $(CP) parse_tmp.c parse.c
247 lemon: $(TOOLDIR)/lemon.c
248         $(NATIVECC) $(NATIVE_CFLAGS) -o $@ $(TOOLDIR)/lemon.c
250 objs/%-native.o: $(SRCDIR)/%.c $(GENHDR)
251         $(COMPILE.c) -o $@ $<
252         $(POST_PROCESS_O)
254 objs/%-native.o: %.c $(GENHDR)
255         $(COMPILE.c) -o $@ $<
256         $(POST_PROCESS_O)
258 objs/parse-native.o: parse.c $(GENHDR)
259         $(COMPILE.c) -o $@ parse.c
260         $(POST_PROCESS_O)
262 objs/%.o pics/%.o: $(SRCDIR)/%.c $(GENHDR)
263         $(COMPILE.c) -o $@ $<
264         $(POST_PROCESS_O)
266 objs/%.o pics/%.o: %.c $(GENHDR)
267         $(COMPILE.c) -o $@ $<
268         $(POST_PROCESS_O)
270 # need direct rules for generated files
271 objs/opcodes.o pics/opcodes.o: opcodes.c $(GENHDR)
272         $(COMPILE.c) -o $@ opcodes.c
273         $(POST_PROCESS_O)
275 objs/parse.o pics/parse.o: parse.c $(GENHDR)
276         $(COMPILE.c) -o $@ parse.c
277         $(POST_PROCESS_O)
279 include $(SRC)/lib/Makefile.targ
281 FRC: