how to pass -Dxxx compile option

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

how to pass -Dxxx compile option

Xingwei Lin
Hi,

How can I pass -Dxxx compile option when I build sqlite? Such as, -
DSQLITE_ENABLE_INTERNAL_FUNCTIONS.

--
Best regards,
Xingwei Lin
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: how to pass -Dxxx compile option

Simon Slavin-3
On 9 Jan 2020, at 6:47am, Xingwei Lin <[hidden email]> wrote:

> How can I pass -Dxxx compile option when I build sqlite? Such as, -
> DSQLITE_ENABLE_INTERNAL_FUNCTIONS.

Depends on which compiler you're using.  See examples for gcc on this page:

<https://www.sqlite.org/howtocompile.html>
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: how to pass -Dxxx compile option

Xingwei Lin
Thanks for reply.

I always use ./configure && make to compile sqlite.

./configure can add some compile options, but I don't know how to add -Dxxx
option in this compilation process.

On Thu, Jan 9, 2020 at 5:29 PM Simon Slavin <[hidden email]> wrote:

> On 9 Jan 2020, at 6:47am, Xingwei Lin <[hidden email]> wrote:
>
> > How can I pass -Dxxx compile option when I build sqlite? Such as, -
> > DSQLITE_ENABLE_INTERNAL_FUNCTIONS.
>
> Depends on which compiler you're using.  See examples for gcc on this page:
>
> <https://www.sqlite.org/howtocompile.html>
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>


--
Best regards,
Xingwei Lin
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: how to pass -Dxxx compile option

Niall O'Reilly
On 9 Jan 2020, at 9:41, Xingwei Lin wrote:

> I always use ./configure && make to compile sqlite.
>
> ./configure can add some compile options, but I don't know how to add -Dxxx
> option in this compilation process.

I don't know (since I've never needed to build SQLite),
but can offer a hint which may help you discover for yourself
while waiting for real expert advice.

Just before sending, I did check my incoming mail, and didn't see
anything from a real expert yet.

After running ./configure (without && make), inspect the Makefile
and try to find how it runs the compiler, and how it passes options
to the compiler.  The man page for make is worth reading, but can
be confusing.

The Makefiles for other software packages that I have to build
from time to time are written following the convention that the
compiler is invoked using a macro CC, and that options are passed
to it using a macro CFLAGS.

If you find lines like
  $(CC) ... $(CFLAGS) ...
then you can set a value for CFLAGS by giving an argument to make:
  make CFLAGS=-Dxxx
If you see lines like
  CFLAGS = $(SOMEFLAGS) $(MOREFLAGS) $(EXTRAFLAGS)
then you'll need to be more careful, and work out which of the
macros on the right-hand side should be over-ridden by the
argument to make.

I hope this helps.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: how to pass -Dxxx compile option

Gary R. Schmidt
In reply to this post by Xingwei Lin
On 09/01/2020 17:47, Xingwei Lin wrote:
> Hi,
>
> How can I pass -Dxxx compile option when I build sqlite? Such as, -
> DSQLITE_ENABLE_INTERNAL_FUNCTIONS.
>
./configure --help will tell you that CFLAGS is how you do that, so:

     ./configure CFLAGS=-Dwhatever

If you have many options:

     ./configure CFLAGS="-Dwhatever -Dthis -Dthat -mwhoops"

        Cheers,
                Gary B-)
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: how to pass -Dxxx compile option

Kees Nuyt
In reply to this post by Xingwei Lin
On Thu, 9 Jan 2020 14:47:44 +0800, you wrote:

> Hi,
>
> How can I pass -Dxxx compile option when I build sqlite? Such as, -
> DSQLITE_ENABLE_INTERNAL_FUNCTIONS.

I don't consider myself an expoert, but the script
below works for me on a Raspberry Pi, Raspbian Jessie.
Note: instead of readline I use the linenoise lib
that is shipped with fossil. Also, I built a few
of the tools at the same time.
You may have to tweak this a little for your preferences and your platform.

        cd ~/src/sqlite
        test ! -z "$opt_p" && fossil pull --verbose
        test ! -z "$opt_u" && fossil update trunk

        OPTS=-DHAVE_LINENOISE
        export CPPFLAGS="-DSQLITE_ENABLE_API_ARMOR \
-DSQLITE_ENABLE_COLUMN_METADATA \
-DSQLITE_ENABLE_DBPAGE_VTAB \
-DSQLITE_ENABLE_DBSTAT_VTAB \
-DSQLITE_ENABLE_DESERIALIZE \
-DSQLITE_ENABLE_EXPLAIN_COMMENTS \
-DSQLITE_ENABLE_FTS5 \
-DSQLITE_ENABLE_HIDDEN_COLUMNS \
-DSQLITE_ENABLE_JSON1 \
-DSQLITE_ENABLE_MEMSYS5 \
-DSQLITE_ENABLE_NORMALIZE \
-DSQLITE_ENABLE_OFFSET_SQL_FUNC \
-DSQLITE_ENABLE_PREUPDATE_HOOK \
-DSQLITE_ENABLE_RBU \
-DSQLITE_ENABLE_RTREE \
-DSQLITE_ENABLE_GEOPOLY \
-DSQLITE_ENABLE_STMT_SCANSTATUS \
-DSQLITE_ENABLE_STMTVTAB \
-DSQLITE_ENABLE_UNKNOWN_SQL_FUNCTION \
-DSQLITE_ENABLE_UNLOCK_NOTIFY \
-DSQLITE_ENABLE_UPDATE_DELETE_LIMIT \
-DSQLITE_INTROSPECTION_PRAGMAS \
-DSQLITE_SOUNDEX \
-DSQLITE_USE_URI \
-DSQLITE_SECURE_DELETE \
-DSQLITE_DQS=0 \
-DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1"
        ./configure \
--prefix=/usr/local \
--libdir=/usr/lib/arm-linux-gnueabihf \
--enable-load-extension \
--enable-threadsafe \
--with-readline-lib=auto \
--with-pic \
--with-gnu-ld \
--enable-json1 \
--enable-fts5 \
--enable-rtree \
--enable-session \
--enable-update-limit \
--enable-geopoly \
--enable-tcl \
--disable-debug \
--disable-static \
        && make clean
        && make sqlite3.c \
        && make shell.c \
        && gcc $OPTS $CPPFLAGS \
        -I ../fossil/src \
        -L /usr/lib/arm-linux-gnueabihf -ltcl8.6 -lm -ldl -lz -lpthread \
        shell.c ../fossil/src/linenoise.c sqlite3.c -o sqlite3 \
        && make sqlite3_analyzer \
        && make sqldiff \
        && make scrub \
        && make showdb \
        && make showwal \
        && make showshm \
        && make wordcount


--
Regards,
Kees Nuyt
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: how to pass -Dxxx compile option

Richard Hipp-3
In reply to this post by Xingwei Lin
On 1/9/20, Xingwei Lin <[hidden email]> wrote:
> Hi,
>
> How can I pass -Dxxx compile option when I build sqlite? Such as, -
> DSQLITE_ENABLE_INTERNAL_FUNCTIONS.
>

Option 1:

CFLAGS='-O2 -DSQLITE_ENABLE_INTERNAL_FUNCTIONS' ./configure && make

Option 2:

./configure && OPTS='-DSQLITE_ENABLE_INTERNAL_FUNCTIONS' make -e

Option 3:

./configure && make OPTS='-DSQLITE_ENABLE_INTERNAL_FUNCTIONS'

--
D. Richard Hipp
[hidden email]
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: how to pass -Dxxx compile option

Warren Young
On Jan 9, 2020, at 6:37 AM, Richard Hipp <[hidden email]> wrote:

>
> On 1/9/20, Xingwei Lin <[hidden email]> wrote:
>>
>> How can I pass -Dxxx compile option when I build sqlite? Such as, -
>> DSQLITE_ENABLE_INTERNAL_FUNCTIONS.
>
> Option 1:
>
> CFLAGS='-O2 -DSQLITE_ENABLE_INTERNAL_FUNCTIONS' ./configure && make
>
> Option 2:
>
> ./configure && OPTS='-DSQLITE_ENABLE_INTERNAL_FUNCTIONS' make -e
>
> Option 3:
>
> ./configure && make OPTS='-DSQLITE_ENABLE_INTERNAL_FUNCTIONS’

…or the one actually recommended by the Autoconf developers:

    ./configure CFLAGS='-DSQLITE_ENABLE_INTERNAL_FUNCTIONS'

The reasons for the recommendation have to do with complications that result from multiple variables, nested Makefile.am, etc.:

    https://www.gnu.org/software/automake/manual/html_node/Flag-Variables-Ordering.html

I assume SQLite’s Autoconf usage isn’t complicated enough that all of that applies, but you want to get into the habit of doing it the way that works across the broadest set of use cases.

Incidentally, this method of overriding CFLAGS and such also works with Autosetup.  See the second example here:

    https://msteveb.github.io/autosetup/user/
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: how to pass -Dxxx compile option

Stephan Buchert-2
In reply to this post by Xingwei Lin
I have an executable file myconfigure with

./configure CFLAGS="-O2 -DSQLITE_MAX_COLUMN=4096 -DHAVE_FDATASYNC
-DHAVE_STRCHRNUL -DHAVE_LOCALTIME_R -DHAVE_GMTIME_R -DHAVE_NAN
-DHAVE_USLEEP -DSQLITE_DEFAULT_WORKER_THREADS=4 -DSQLITE_TEMP_STORE=2
-DSQLITE_USE_URI -DSQLITE_ENABLE_API_ARMOR
-DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_DBSTAT_VTAB
-DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS5
-DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_PREUPDATE_HOOK
-DSQLITE_ENABLE_PREUPDATE_HOOK -DSQLITE_ENABLE_MEMORY_MANAGEMENT
-DSQLITE_MAX_MMAP_SIZE=4393751543808
-DSQLITE_DEFAULT_MMAP_SIZE=2194728288256
-DSQLITE_DEFAULT_CACHE_SIZE=-8000 -DSQLITE_DEFAULT_WORKER_THREADS=4
-DSQLITE_ENABLE_MEMSYS5 -DSQLITE_ENABLE_STMTVTAB -DSQLITE_ENABLE_RTREE
-DSQLITE_ENABLE_GEOPOLY -DSQLITE_ENABLE_STAT4
-DSQLITE_ENABLE_UNLOCK_NOTIFY -DSQLITE_ENABLE_NULL_TRIM
-DSQLITE_ENABLE_OFFSET_SQL_FUNC" LIBS="-lm"

(everything on one line) and execute it instead of "configure" whenever
there is an update of Sqlite. Then "make" and "sudo make install".
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: how to pass -Dxxx compile option

Warren Young
In reply to this post by Warren Young
On Jan 9, 2020, at 6:51 AM, Warren Young <[hidden email]> wrote:
>
>    ./configure CFLAGS='-DSQLITE_ENABLE_INTERNAL_FUNCTIONS'
>
> The reasons for the recommendation have to do with complications that result from multiple variables, nested Makefile.am, etc.

It also allows autoreconf to work properly in the case of Autoconf and @AUTOREMAKE@ in the case of Autosetup.

To see it, try this in the Fossil source tree to produce a debuggable build:

    ./configure CFLAGS='-O0 -g'

Then look at the rule generated at the end for re-generating the Makefile:

Makefile: ./Makefile.in …noise noise noise…
    /path/to/configure CFLAGS=-O0
    touch /path/to/Makefile

You don’t get that by exporting CFLAGS as an environment variable, for example.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: how to pass -Dxxx compile option

Xingwei Lin
In reply to this post by Gary R. Schmidt
Thanks all the nice guys' reply!!

On Thu, Jan 9, 2020 at 10:59 PM Gary R. Schmidt <[hidden email]> wrote:

> On 09/01/2020 17:47, Xingwei Lin wrote:
> > Hi,
> >
> > How can I pass -Dxxx compile option when I build sqlite? Such as, -
> > DSQLITE_ENABLE_INTERNAL_FUNCTIONS.
> >
> ./configure --help will tell you that CFLAGS is how you do that, so:
>
>      ./configure CFLAGS=-Dwhatever
>
> If you have many options:
>
>      ./configure CFLAGS="-Dwhatever -Dthis -Dthat -mwhoops"
>
>         Cheers,
>                 Gary    B-)
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>


--
Best regards,
Xingwei Lin
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users