xref: /illumos-gate/usr/src/lib/libsqlite/Makefile.targ (revision 9b9d39d2a32ff806d2431dbcc50968ef1e6d46b2)
1*9b9d39d2SRichard Lowe#
2*9b9d39d2SRichard Lowe# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
3*9b9d39d2SRichard Lowe# Use is subject to license terms.
4*9b9d39d2SRichard Lowe# Copyright 2015 Igor Kozhukhov <ikozhukhov@gmail.com>
5*9b9d39d2SRichard Lowe# Copyright 2016 Nexenta Systems, Inc.  All rights reserved.
6*9b9d39d2SRichard Lowe# Copyright (c) 2019, Joyent, Inc.
7*9b9d39d2SRichard Lowe# Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
8*9b9d39d2SRichard Lowe#
9*9b9d39d2SRichard Lowe
10*9b9d39d2SRichard Loweopcodes.h: $(SRCDIR)/vdbe.c
11*9b9d39d2SRichard Lowe	@echo "Generating $@"; \
12*9b9d39d2SRichard Lowe	$(RM) -f $@ ; \
13*9b9d39d2SRichard Lowe	echo '/* Automatically generated file.  Do not edit */' > $@ ; \
14*9b9d39d2SRichard Lowe	$(GREP) '^case OP_' $(SRCDIR)/vdbe.c | \
15*9b9d39d2SRichard Lowe	    $(SED) -e 's/://' | \
16*9b9d39d2SRichard Lowe	    $(AWK) '{printf "#define %-30s %3d\n", $$2, ++cnt}' >> $@
17*9b9d39d2SRichard Lowe
18*9b9d39d2SRichard Loweopcodes.c: $(SRCDIR)/vdbe.c
19*9b9d39d2SRichard Lowe	@echo "Generating $@"; \
20*9b9d39d2SRichard Lowe	$(RM) -f $@ ; \
21*9b9d39d2SRichard Lowe	$(ECHO) '/* Automatically generated file.  Do not edit */' > $@ ; \
22*9b9d39d2SRichard Lowe	$(ECHO) 'char *sqliteOpcodeNames[] = { "???", ' >> $@ ; \
23*9b9d39d2SRichard Lowe	$(GREP) '^case OP_' $(SRCDIR)/vdbe.c | \
24*9b9d39d2SRichard Lowe	    $(SED) -e 's/^.*OP_/  "/' -e 's/:.*$$/", /' >> $@ ; \
25*9b9d39d2SRichard Lowe	 $(ECHO) '};' >> $@
26*9b9d39d2SRichard Lowe
27*9b9d39d2SRichard Lowetestfixture: FRC
28*9b9d39d2SRichard Lowe	@if [ -f $(TCLBASE)/include/tcl.h ]; then \
29*9b9d39d2SRichard Lowe		unset SUNPRO_DEPENDENCIES; \
30*9b9d39d2SRichard Lowe		$(ECHO) $(LINK.c) -o testfixture $(TESTSRC) $(LIBRARY) $(LDLIBS) ;\
31*9b9d39d2SRichard Lowe		exec $(LINK.c) -o testfixture $(TESTSRC) $(LIBRARY) $(LDLIBS) ;\
32*9b9d39d2SRichard Lowe	else \
33*9b9d39d2SRichard Lowe		$(ECHO) "$(TCLBASE)/include/tcl.h: not found."; \
34*9b9d39d2SRichard Lowe		exit 1; \
35*9b9d39d2SRichard Lowe	fi
36*9b9d39d2SRichard Lowe
37*9b9d39d2SRichard Lowe# Prevent Makefile.lib $(PICS) := from adding PICFLAGS
38*9b9d39d2SRichard Lowe# by building lemon in a recursive make invocation.
39*9b9d39d2SRichard Lowe# Otherwise, this target causes a rebuild every time after
40*9b9d39d2SRichard Lowe# the PICS target builds this one way, then lint the other.
41*9b9d39d2SRichard Loweparse.h parse.c : $(SRCDIR)/parse.y $(TOOLDIR)/lemon.c $(TOOLDIR)/lempar.c
42*9b9d39d2SRichard Lowe	-$(RM) parse_tmp.y lempar.c
43*9b9d39d2SRichard Lowe	$(CP) $(SRCDIR)/parse.y parse_tmp.y
44*9b9d39d2SRichard Lowe	$(CP) $(TOOLDIR)/lempar.c lempar.c
45*9b9d39d2SRichard Lowe	$(MAKE) lemon
46*9b9d39d2SRichard Lowe	./lemon parse_tmp.y
47*9b9d39d2SRichard Lowe	-$(RM) parse.c parse.h
48*9b9d39d2SRichard Lowe	$(CP) parse_tmp.h parse.h
49*9b9d39d2SRichard Lowe	$(CP) parse_tmp.c parse.c
50*9b9d39d2SRichard Lowe
51*9b9d39d2SRichard Lowelemon: $(TOOLDIR)/lemon.c
52*9b9d39d2SRichard Lowe	$(NATIVECC) $(NATIVE_CFLAGS) -o $@ $(TOOLDIR)/lemon.c
53*9b9d39d2SRichard Lowe
54*9b9d39d2SRichard Loweobjs/%.o pics/%.o: $(SRCDIR)/%.c $(GENHDR)
55*9b9d39d2SRichard Lowe	$(COMPILE.c) -o $@ $<
56*9b9d39d2SRichard Lowe	$(POST_PROCESS_O)
57*9b9d39d2SRichard Lowe
58*9b9d39d2SRichard Loweobjs/%.o pics/%.o: %.c $(GENHDR)
59*9b9d39d2SRichard Lowe	$(COMPILE.c) -o $@ $<
60*9b9d39d2SRichard Lowe	$(POST_PROCESS_O)
61*9b9d39d2SRichard Lowe
62*9b9d39d2SRichard Lowe# need direct rules for generated files
63*9b9d39d2SRichard Loweobjs/opcodes.o pics/opcodes.o: opcodes.c $(GENHDR)
64*9b9d39d2SRichard Lowe	$(COMPILE.c) -o $@ opcodes.c
65*9b9d39d2SRichard Lowe	$(POST_PROCESS_O)
66*9b9d39d2SRichard Lowe
67*9b9d39d2SRichard Loweobjs/parse.o pics/parse.o: parse.c $(GENHDR)
68*9b9d39d2SRichard Lowe	$(COMPILE.c) -o $@ parse.c
69*9b9d39d2SRichard Lowe	$(POST_PROCESS_O)
70*9b9d39d2SRichard Lowe
71*9b9d39d2SRichard Loweinclude $(SRC)/lib/Makefile.targ
72