AM_CFLAGS = $(GTHREAD_CFLAGS)

noinst_PROGRAMS=proc_open lemon # simple-fcgi 
if CHECK_WITH_FASTCGI
sbin_PROGRAMS=lighttpd fcgi-stat-accel
else
sbin_PROGRAMS=lighttpd 
endif
bin_PROGRAMS=spawn-fcgi
LEMON=$(top_builddir)/src/lemon

lemon_SOURCES=lemon.c

#simple_fcgi_SOURCES=simple-fcgi.c
#simple_fcgi_LDADD=-lfcgi

if CROSS_COMPILING
configparser.c configparser.h: 
mod_ssi_exprparser.c mod_ssi_exprparser.h: 
else
configparser.y: lemon
mod_ssi_exprparser.y: lemon
http_resp_parser.y: lemon
http_req_parser.y: lemon
http_req_range_parser.y: lemon

configparser.c configparser.h: configparser.y
	rm -f configparser.h
	$(LEMON) -q $(srcdir)/configparser.y $(srcdir)/lempar.c

http_resp_parser.c http_resp_parser.h: http_resp_parser.y
	rm -f http_resp_parser.h
	$(LEMON) -q $(srcdir)/http_resp_parser.y $(srcdir)/lempar.c

http_req_parser.c http_req_parser.h: http_req_parser.y
	rm -f http_req_parser.h
	$(LEMON) -q $(srcdir)/http_req_parser.y $(srcdir)/lempar.c

http_req_range_parser.c http_req_range_parser.h: http_req_range_parser.y
	rm -f http_req_range_parser.h
	$(LEMON) -q $(srcdir)/http_req_range_parser.y $(srcdir)/lempar.c

mod_ssi_exprparser.c mod_ssi_exprparser.h: mod_ssi_exprparser.y 
	rm -f mod_ssi_exprparser.h
	$(LEMON) -q $(srcdir)/mod_ssi_exprparser.y $(srcdir)/lempar.c
endif

configfile.c: configparser.h
mod_ssi_expr.c: mod_ssi_exprparser.h
http_resp.c: http_resp_parser.h
http_req.c: http_req_parser.h
http_req_range.c: http_req_range_parser.h

common_src=buffer.c log.c \
      keyvalue.c chunk.c filter.c \
      stream.c fdevent.c \
      stat_cache.c plugin.c joblist.c etag.c array.c \
      data_string.c data_count.c data_array.c \
      data_integer.c md5.c \
      fdevent_select.c fdevent_linux_rtsig.c \
      fdevent_poll.c fdevent_linux_sysepoll.c \
      fdevent_solaris_devpoll.c fdevent_freebsd_kqueue.c \
      data_config.c bitset.c \
      inet_ntop_cache.c crc32.c \
      connections-glue.c iosocket.c \
      configfile-glue.c status_counter.c \
      http-header-glue.c \
      network_write.c network_linux_sendfile.c \
      network_freebsd_sendfile.c network_writev.c \
      network_solaris_sendfilev.c network_openssl.c \
      network_linux_aio.c \
      network_posix_aio.c \
      network_gthread_aio.c network_gthread_sendfile.c \
      http_resp.c http_resp_parser.c \
      http_req.c http_req_parser.c \
      http_req_range.c http_req_range_parser.c timing.c
      
src = server.c response.c connections.c network.c \
      configfile.c configparser.c request.c proc_open.c

spawn_fcgi_SOURCES=spawn-fcgi.c
spawn_fcgi_LDADD = $(GTHREAD_LIBS)

if CHECK_WITH_FASTCGI
fcgi_stat_accel_SOURCES=fcgi-stat-accel.c
fcgi_stat_accel_LDADD = -lfcgi
endif

lib_LTLIBRARIES = 

if NO_RDYNAMIC
# if the linker doesn't allow referencing symbols of the binary
# we have to put everything into a shared-lib and link it into
# everything
lib_LTLIBRARIES += liblightcomp.la
liblightcomp_la_SOURCES=$(common_src)
liblightcomp_la_CFLAGS=$(AM_CFLAGS)
liblightcomp_la_LDFLAGS = -avoid-version -no-undefined
liblightcomp_la_LIBADD = $(PCRE_LIB) $(SSL_LIB) $(GTHREAD_LIBS)
common_libadd = liblightcomp.la
else
src += $(common_src)
common_libadd = 
endif

lib_LTLIBRARIES += mod_flv_streaming.la
mod_flv_streaming_la_SOURCES = mod_flv_streaming.c 
mod_flv_streaming_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_flv_streaming_la_LIBADD = $(common_libadd)

lib_LTLIBRARIES += mod_uploadprogress.la
mod_uploadprogress_la_SOURCES = mod_uploadprogress.c 
mod_uploadprogress_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_uploadprogress_la_LIBADD = $(common_libadd)

lib_LTLIBRARIES += mod_evasive.la
mod_evasive_la_SOURCES = mod_evasive.c
mod_evasive_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_evasive_la_LIBADD = $(common_libadd)

lib_LTLIBRARIES += mod_webdav.la
mod_webdav_la_SOURCES = mod_webdav.c
mod_webdav_la_CFLAGS = $(AM_CFLAGS) $(XML_CFLAGS) $(SQLITE_CFLAGS) 
mod_webdav_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_webdav_la_LIBADD = $(common_libadd) $(XML_LIBS) $(SQLITE_LIBS) $(UUID_LIB)

lib_LTLIBRARIES += mod_magnet.la
mod_magnet_la_SOURCES = mod_magnet.c mod_magnet_cache.c
mod_magnet_la_CFLAGS = $(AM_CFLAGS) $(LUA_CFLAGS)
mod_magnet_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_magnet_la_LIBADD = $(MEMCACHE_LIB) $(common_libadd) $(LUA_LIBS) -lm

lib_LTLIBRARIES += mod_trigger_b4_dl.la
mod_trigger_b4_dl_la_SOURCES = mod_trigger_b4_dl.c
mod_trigger_b4_dl_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_trigger_b4_dl_la_LIBADD = $(GDBM_LIB) $(MEMCACHE_LIB) $(PCRE_LIB) $(common_libadd)

lib_LTLIBRARIES += mod_mysql_vhost.la
mod_mysql_vhost_la_SOURCES = mod_mysql_vhost.c
mod_mysql_vhost_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_mysql_vhost_la_LIBADD = $(MYSQL_LIBS) $(common_libadd)
mod_mysql_vhost_la_CPPFLAGS = $(MYSQL_INCLUDE)

lib_LTLIBRARIES += mod_sql_vhost_core.la
mod_sql_vhost_core_la_SOURCES = mod_sql_vhost_core.c
mod_sql_vhost_core_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_sql_vhost_core_la_LIBADD = $(common_libadd)

lib_LTLIBRARIES += mod_cgi.la
mod_cgi_la_SOURCES = mod_cgi.c
mod_cgi_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_cgi_la_LIBADD = $(common_libadd)

lib_LTLIBRARIES += mod_staticfile.la
mod_staticfile_la_SOURCES = mod_staticfile.c 
mod_staticfile_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_staticfile_la_LIBADD = $(common_libadd)

lib_LTLIBRARIES += mod_deflate.la
mod_deflate_la_SOURCES = mod_deflate.c 
mod_deflate_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_deflate_la_LIBADD = $(Z_LIB) $(BZ_LIB) $(common_libadd)

lib_LTLIBRARIES += mod_chunked.la
mod_chunked_la_SOURCES = mod_chunked.c 
mod_chunked_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_chunked_la_LIBADD = $(common_libadd)

lib_LTLIBRARIES += mod_dirlisting.la
mod_dirlisting_la_SOURCES = mod_dirlisting.c 
mod_dirlisting_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_dirlisting_la_LIBADD = $(common_libadd) $(PCRE_LIB)

lib_LTLIBRARIES += mod_indexfile.la
mod_indexfile_la_SOURCES = mod_indexfile.c 
mod_indexfile_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_indexfile_la_LIBADD = $(common_libadd)

lib_LTLIBRARIES += mod_setenv.la
mod_setenv_la_SOURCES = mod_setenv.c 
mod_setenv_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_setenv_la_LIBADD = $(common_libadd)

lib_LTLIBRARIES += mod_alias.la
mod_alias_la_SOURCES = mod_alias.c 
mod_alias_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_alias_la_LIBADD = $(common_libadd)

lib_LTLIBRARIES += mod_userdir.la
mod_userdir_la_SOURCES = mod_userdir.c 
mod_userdir_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_userdir_la_LIBADD = $(common_libadd)

lib_LTLIBRARIES += mod_rrdtool.la
mod_rrdtool_la_SOURCES = mod_rrdtool.c
mod_rrdtool_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_rrdtool_la_LIBADD = $(common_libadd)

lib_LTLIBRARIES += mod_usertrack.la
mod_usertrack_la_SOURCES = mod_usertrack.c
mod_usertrack_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_usertrack_la_LIBADD = $(common_libadd)

lib_LTLIBRARIES += mod_proxy_core.la
mod_proxy_core_la_SOURCES = mod_proxy_core.c mod_proxy_core_pool.c \
			    mod_proxy_core_backend.c mod_proxy_core_address.c \
			    mod_proxy_core_backlog.c mod_proxy_core_rewrites.c \
			    mod_proxy_core_protocol.c
mod_proxy_core_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_proxy_core_la_LIBADD = $(common_libadd) $(PCRE_LIB)

lib_LTLIBRARIES += mod_proxy_backend_http.la
mod_proxy_backend_http_la_SOURCES = mod_proxy_backend_http.c
mod_proxy_backend_http_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_proxy_backend_http_la_LIBADD = $(common_libadd) $(PCRE_LIB)

lib_LTLIBRARIES += mod_proxy_backend_fastcgi.la
mod_proxy_backend_fastcgi_la_SOURCES = mod_proxy_backend_fastcgi.c
mod_proxy_backend_fastcgi_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_proxy_backend_fastcgi_la_LIBADD = $(common_libadd) $(PCRE_LIB)

lib_LTLIBRARIES += mod_proxy_backend_scgi.la
mod_proxy_backend_scgi_la_SOURCES = mod_proxy_backend_scgi.c
mod_proxy_backend_scgi_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_proxy_backend_scgi_la_LIBADD = $(common_libadd) $(PCRE_LIB)

lib_LTLIBRARIES += mod_proxy_backend_ajp13.la
mod_proxy_backend_ajp13_la_SOURCES = mod_proxy_backend_ajp13.c
mod_proxy_backend_ajp13_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_proxy_backend_ajp13_la_LIBADD = $(common_libadd) $(PCRE_LIB)


lib_LTLIBRARIES += mod_ssi.la
mod_ssi_la_SOURCES = mod_ssi_exprparser.c mod_ssi_expr.c mod_ssi.c 
mod_ssi_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_ssi_la_LIBADD = $(common_libadd) $(PCRE_LIB)

lib_LTLIBRARIES += mod_secdownload.la
mod_secdownload_la_SOURCES = mod_secure_download.c
mod_secdownload_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_secdownload_la_LIBADD = $(common_libadd)

#lib_LTLIBRARIES += mod_httptls.la
#mod_httptls_la_SOURCES = mod_httptls.c
#mod_httptls_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
#mod_httptls_la_LIBADD = $(common_libadd)

lib_LTLIBRARIES += mod_expire.la
mod_expire_la_SOURCES = mod_expire.c
mod_expire_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_expire_la_LIBADD = $(common_libadd)

lib_LTLIBRARIES += mod_evhost.la
mod_evhost_la_SOURCES = mod_evhost.c
mod_evhost_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_evhost_la_LIBADD = $(common_libadd)

lib_LTLIBRARIES += mod_simple_vhost.la
mod_simple_vhost_la_SOURCES = mod_simple_vhost.c
mod_simple_vhost_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_simple_vhost_la_LIBADD = $(common_libadd)
		
lib_LTLIBRARIES += mod_access.la
mod_access_la_SOURCES = mod_access.c
mod_access_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_access_la_LIBADD = $(common_libadd)

lib_LTLIBRARIES += mod_compress.la
mod_compress_la_SOURCES = mod_compress.c 
mod_compress_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_compress_la_LIBADD = $(Z_LIB) $(BZ_LIB) $(common_libadd)

lib_LTLIBRARIES += mod_auth.la
mod_auth_la_SOURCES = mod_auth.c http_auth_digest.c http_auth.c
mod_auth_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_auth_la_LIBADD = $(CRYPT_LIB) $(LDAP_LIB) $(LBER_LIB) $(common_libadd)

lib_LTLIBRARIES += mod_rewrite.la
mod_rewrite_la_SOURCES = mod_rewrite.c
mod_rewrite_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_rewrite_la_LIBADD = $(PCRE_LIB) $(common_libadd)

lib_LTLIBRARIES += mod_redirect.la
mod_redirect_la_SOURCES = mod_redirect.c
mod_redirect_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_redirect_la_LIBADD = $(PCRE_LIB) $(common_libadd)

lib_LTLIBRARIES += mod_status.la
mod_status_la_SOURCES = mod_status.c
mod_status_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_status_la_LIBADD = $(common_libadd)

lib_LTLIBRARIES += mod_accesslog.la
mod_accesslog_la_SOURCES = mod_accesslog.c
mod_accesslog_la_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined
mod_accesslog_la_LIBADD = $(common_libadd)


hdr = server.h buffer.h network.h log.h keyvalue.h \
      response.h request.h fastcgi.h chunk.h filter.h \
      settings.h http_auth_digest.h \
      md5.h http_auth.h stream.h \
      fdevent.h connections.h base.h stat_cache.h \
      plugin.h mod_auth.h \
      etag.h joblist.h array.h crc32.h \
      network_backends.h configfile.h bitset.h \
      mod_ssi.h mod_ssi_expr.h inet_ntop_cache.h \
      configparser.h mod_ssi_exprparser.h \
      sys-mmap.h sys-socket.h mod_cml.h mod_cml_funcs.h \
      proc_open.h mod_sql_vhost_core.h \
      sys-files.h sys-process.h sys-strings.h  \
      iosocket.h array-static.h \
      mod_proxy_core_address.h \
      mod_proxy_core_backend.h \
      mod_proxy_core_backlog.h \
      mod_proxy_core.h  \
      mod_proxy_core_pool.h \
      mod_proxy_core_rewrites.h \
      status_counter.h \
      http_req.h \
      http_req_parser.h \
      http_req_range.h \
      http_req_range_parser.h \
      http_resp.h \
      http_resp_parser.h \
      http_parser.h \
      ajp13.h \
      mod_proxy_core_protocol.h \
      mod_magnet_cache.h \
      timing.h

DEFS= @DEFS@ -DLIBRARY_DIR="\"$(libdir)\""

lighttpd_SOURCES = $(src)
lighttpd_LDADD = $(PCRE_LIB) $(DL_LIB) $(SENDFILE_LIB) $(ATTR_LIB) $(common_libadd) $(SSL_LIB) $(AIO_LIB) $(POSIX_AIO_LIB) $(GTHREAD_LIBS)
lighttpd_LDFLAGS = -export-dynamic

proc_open_SOURCES = proc_open.c buffer.c
proc_open_CPPFLAGS= -DDEBUG_PROC_OPEN

#gen_license_SOURCES = license.c md5.c buffer.c gen_license.c

#ssl_SOURCES = ssl.c


#adserver_SOURCES = buffer.c iframe.c
#adserver_LDADD = -lfcgi -lmysqlclient

#error_test_SOURCES = error_test.c

#evalo_SOURCES = buffer.c eval.c
#bench_SOURCES = buffer.c bench.c
#ajp_SOURCES = ajp.c

noinst_HEADERS   = $(hdr)
EXTRA_DIST = mod_skeleton.c \
	     configparser.y \
	     mod_ssi_exprparser.y \
	     lempar.c  \
	     http_resp_parser.y \
	     http_req_parser.y \
	     http_req_range_parser.y 
