Skip to content

Instantly share code, notes, and snippets.

@spuriousdata
Created December 6, 2012 19:27
Show Gist options
  • Save spuriousdata/4227525 to your computer and use it in GitHub Desktop.
Save spuriousdata/4227525 to your computer and use it in GitHub Desktop.
apxs compile C++
# apxs is hardcoded to only compile *.c files so C++ files must be named foo.c or symlinked to foo.c -- What a pain in the ass.
OS=$(shell if grep -q Ubuntu /etc/*release; then echo Ubuntu; fi)
ifeq ($(OS), Ubuntu)
BUILD_BASE=/usr/share/apache2
TOPDIR=$(BUILD_BASE)
APXS=apxs2
else
BUILD_BASE=/usr/lib/httpd
TOPDIR=/etc/httpd
APXS=apxs
endif
builddir=.
top_srcdir=$(TOPDIR)
top_builddir=$(TOPDIR)
include $(BUILD_BASE)/build/special.mk
MODULE = src/mod_rtb.la
SOURCES = src/mod_rtb.c src/rtb.c src/gpb/realtime-bidding.pb.c
FILEDEPS = src/mod_rtb.h src/rtb.hh
CC_FLAGS=$(shell apxs -q CFLAGS) $(shell apr-1-config --cppflags) -I./src -I/usr/include/httpd
LD_FLAGS=-Wl$(shell pkg-config --libs protobuf) $(shell apr-1-config --libs)
all: $(MODULE)
debug:
$(APXS) -S CC=g++ -S CFLAGS="$(CC_FLAGS) -D_DEBUG -g -O0" $(LD_FLAGS) -c $(SOURCES)
$(MODULE): $(SOURCES)
$(APXS) -S CC=g++ -S CFLAGS="$(CC_FLAGS)" $(LD_FLAGS) -c $(SOURCES)
install: all
$(APXS) -i $(MODULE) /usr/local/lib/libprotobuf.a
apachectl restart
clean:
@rm $(MODULE) src/*.o src/*.lo src/*.slo *.o src/gpb/*o
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment