Custom compilation flag for an nginx module

erankor2 nginx-forum at
Wed Dec 3 15:47:01 UTC 2014

Hi all,

Is it possible for an nginx module to define custom compilation switches
that add external libs / preprocessor macros ? Is there some example of a
module that does it ?
Specifically, what I'm trying to do is measure time accurately in my module
for benchmarking purposes. Since I use Linux, I was planning to use
clock_gettime(CLOCK_MONOTONIC) for that. This function is Linux-specific,
and so I would like to make it optional at compilation time:
 * if nginx is compile with --with-clock-gettime (or something like that) I
will use clock_gettime and link against the required library (librt)
 * otherwise, I will fall back to using gettimeofday or drop the feature



Posted at Nginx Forum:,255292,255292#msg-255292

More information about the nginx mailing list