Deprecate blerg.httpd since it's become a hassle
[blerg.git] / Makefile
index 761b2bb..144d942 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,30 +1,49 @@
-libmicrohttpd_a = libmicrohttpd-0.9.3/src/daemon/.libs/libmicrohttpd.a
-
-CFLAGS = -g -Ilibmicrohttpd-0.9.3/src/include
-LIBS =
-
-targets = blerg.a blergtool http_blerg
-blerg_a_objects = database.o tags.o
-blergtool_objects = blergtool.o blerg.a
-http_blerg_objects = http_blerg.o auth.o blerg.a
+include libs.mk
+
+CFLAGS ?= -g
+INCLUDES = -I. -Idatabase -Icommon $(YAJL_INCLUDES)
+HTTP_INCLUDES = -Ihttp $(MHD_INCLUDES)
+CGI_INCLUDES = -Icgi $(CGI_UTIL_INCLUDES)
+LDFLAGS ?=
+HTTP_LIBDIRS = $(MHD_LIBDIR) $(YAJL_LIBDIR)
+CGI_LIBDIRS = $(CGI_UTIL_LIBDIR) $(YAJL_LIBDIR)
+
+targets = blerg.a blergtool blerglatest blerg.cgi rss.cgi
+blerg_a_objects = database/database.o database/tags.o database/util.o database/subscription.o common/stringbucket.o
+blergtool_objects = tools/blergtool.o blerg.a
+blerglatest_objects = tools/blerglatest.o blerg.a common/json.o
+rss_objects = cgi/rss.o cgi/canned_responses.o common/app.o common/escapery.o blerg.a
+http_blerg_objects = http/http_blerg.o http/canned_responses.o common/app.o common/json.o common/auth.o common/md5.o blerg.a
+cgi_blerg_objects = cgi/cgi_blerg.o cgi/canned_responses.o common/app.o common/json.o common/auth.o common/md5.o blerg.a
 
 all: $(targets)
 
 clean:
-       rm -f $(targets) $(blerg_a_objects) $(blergtool_objects) $(http_blerg_objects)
-       -cd libmicrohttpd-0.9.3 && make distclean
+       rm -f $(targets) $(blerg_a_objects) $(blergtool_objects) $(blerglatest_objects) $(http_blerg_objects) $(cgi_blerg_objects) $(rss_objects)
 
 blerg.a: $(blerg_a_objects)
        ar rcu $@ $(blerg_a_objects)
 
-$(libmicrohttpd_a):
-       cd libmicrohttpd-0.9.3 && ./configure --disable-https --disable-shared && make
-
 blergtool: $(blergtool_objects)
-       gcc $^ -o $@
+       gcc $(LDFLAGS) $^ -o $@
+
+blerglatest: $(blerglatest_objects)
+       gcc $(YAJL_LIBDIR) $(LDFLAGS) $^ -lyajl_s -o $@
+
+blerg.httpd: $(http_blerg_objects)
+       gcc $(HTTP_LIBDIRS) $(LDFLAGS) $(http_blerg_objects) -lpthread -lmicrohttpd -lyajl_s -o $@
+
+blerg.cgi: $(cgi_blerg_objects)
+       gcc $(CGI_LIBDIRS) $(LDFLAGS) $(cgi_blerg_objects) -lcgi-util -lyajl_s -o $@
+
+rss.cgi: $(rss_objects)
+       gcc $(CGI_LIBDIRS) $(LDFLAGS) $(rss_objects) -lcgi-util -o $@
+
+http/%.o: http/%.c
+       gcc $(INCLUDES) $(HTTP_INCLUDES) $(CFLAGS) -c $< -o $@
 
-http_blerg: $(http_blerg_objects) $(libmicrohttpd_a)
-       gcc $(http_blerg_objects) -lpthread $(libmicrohttpd_a) -o $@
+cgi/%.o: cgi/%.c
+       gcc $(INCLUDES) $(CGI_INCLUDES) $(CFLAGS) -c $< -o $@
 
 %.o: %.c
-       gcc $(CFLAGS) $(LIBS) -c $< -o $@
+       gcc $(INCLUDES) $(CFLAGS) -c $< -o $@