include libs.mk ARCH=$(shell uname -m) CFLAGS ?= -g ifeq ($(ARCH),x86_64) CFLAGS += -fPIC endif INCLUDES = -I. -Idatabase -Icommon -Ibuilddeps/scrypt-1.1.6/lib/crypto $(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 blerg_auth.a blergtool blerglatest blerg.cgi perl-lib www/build/enyo-blerg.js blerg_a_objects = database/database.o database/tags.o database/util.o database/configuration.o database/subscription.o common/stringbucket.o blerg_auth_a_objects = common/auth.o common/md5.o blergtool_objects = tools/blergtool.o blerg.a blerglatest_objects = tools/blerglatest.o blerg.a common/json.o http_blerg_objects = http/http_blerg.o http/canned_responses.o common/app.o common/json.o blerg_auth.a builddeps/scrypt.a blerg.a cgi_blerg_objects = cgi/cgi_blerg.o cgi/canned_responses.o common/app.o common/json.o blerg_auth.a builddeps/scrypt.a blerg.a all: $(targets) clean: rm -f $(targets) $(blerg_a_objects) $(blerg_auth_a_objects) $(blergtool_objects) $(blerglatest_objects) $(http_blerg_objects) $(cgi_blerg_objects) builddeps/*.a @-make -C builddeps/scrypt-1.1.6 distclean @-make -C builddeps/scrypt-1.1.6/lib/crypto clean @-make -C lib/perl/Blerg-Database clean .PHONY: perl-lib perl-lib: cd lib/perl/Blerg-Database && perl Makefile.PL make -C lib/perl/Blerg-Database blerg.a: $(blerg_a_objects) ar rcu $@ $(blerg_a_objects) blerg_auth.a: builddeps/scrypt.a $(blerg_auth_a_objects) ar rcu $@ $(blerg_auth_a_objects) blergtool: $(blergtool_objects) $(CC) $(LDFLAGS) $^ -o $@ blerglatest: $(blerglatest_objects) $(CC) $(YAJL_LIBDIR) $(LDFLAGS) $^ -lyajl_s -o $@ blerg.httpd: $(http_blerg_objects) $(CC) $(HTTP_LIBDIRS) $(LDFLAGS) $(http_blerg_objects) -lpthread -lmicrohttpd -lyajl_s -o $@ blerg.cgi: $(cgi_blerg_objects) $(CC) $(CGI_LIBDIRS) $(LDFLAGS) $(cgi_blerg_objects) -lcgi-util -lyajl_s -o $@ http/%.o: http/%.c $(CC) $(INCLUDES) $(HTTP_INCLUDES) $(CFLAGS) -c $< -o $@ cgi/%.o: cgi/%.c $(CC) $(INCLUDES) $(CGI_INCLUDES) $(CFLAGS) -c $< -o $@ %.o: %.c $(CC) $(INCLUDES) $(CFLAGS) -c $< -o $@ www/build/enyo-blerg.js: www/jssrc/blerg/* www/jssrc/package.js www/jssrc/package-min.js which node >/dev/null # Please install Node.js to re-minify the JS cd www/jssrc && enyo/tools/minify.sh -output ../build/enyo-blerg -no-alias package-min.js builddeps/scrypt-1.1.6/config.h: cd builddeps/scrypt-1.1.6 && ./configure builddeps/scrypt.a: builddeps/scrypt-1.1.6/config.h make -C builddeps/scrypt-1.1.6/lib/crypto CFLAGS="$(CFLAGS)" cp builddeps/scrypt-1.1.6/lib/crypto/scrypt.a builddeps/ .PHONY: docs docs: www/doc/perl www/doc/perl/Blerg-Database.html www/doc/perl: mkdir $@ www/doc/perl/Blerg-Database.html: lib/perl/Blerg-Database/lib/Blerg/Database.pm pod2html $< > $@ .PHONY: install install: @echo "Please use 'make install-environment' to install Blërg to an environment" .PHONY: install-environment install-environment: all docs @if [ -z "$(ENV_DIR)" ]; then \ echo "Specify the install directory in the ENV_DIR variable"; \ exit 1; \ fi install --mode 755 -d \ $(ENV_DIR)/bin \ $(ENV_DIR)/lib/cgi-bin \ $(ENV_DIR)/etc \ $(ENV_DIR)/data/data \ $(ENV_DIR)/data/hash_tags \ $(ENV_DIR)/data/ref_tags \ $(ENV_DIR)/www/build \ $(ENV_DIR)/www/css \ $(ENV_DIR)/www/doc/perl \ $(ENV_DIR)/www/images install --mode 755 blerg.cgi rss.cgi $(ENV_DIR)/lib/cgi-bin/ install --mode 755 blergtool blerglatest $(ENV_DIR)/bin/ install --mode 644 www/favicon.gif www/favicon.ico www/index.html \ www/welcome.html \ $(ENV_DIR)/www/ install --mode 644 www/build/enyo-blerg.js www/build/enyo-blerg.css \ $(ENV_DIR)/www/build/ install --mode 644 www/css/blerg.css www/css/doc.css \ $(ENV_DIR)/www/css/ install --mode 644 www/doc/changelog.html www/doc/index.html \ www/doc/post_help.html www/doc/privacy_data.html \ www/doc/contact.html \ $(ENV_DIR)/www/doc/ install --mode 644 www/doc/perl/Blerg-Database.html \ $(ENV_DIR)/www/doc/perl/ install --mode 644 www/images/blerglogo.png www/images/corner.svg \ www/images/play.png www/images/rss.png \ $(ENV_DIR)/www/images/ www/jssrc/lib/onyx/deploy.sh $(ENV_DIR)/www/jssrc/lib/onyx cd lib/perl/Blerg-Database && perl Makefile.PL INSTALL_BASE="$(ENV_DIR)" make -C lib/perl/Blerg-Database install perl scripts/write-environment-configs.pl $(ENV_DIR)