Commits

David McClosky committed 3c23816

Makefiles: Slight portability improvements for SWIG, add valgrind support
- Better handling of $SWIG_JAVA_PACKAGE
- $CFLAGS now passed to the linker when making SWIG extensions
- Makefile: Allow SWIG_*FLAGS to be overridden
This will presumably happen for anyone trying to build SWIG extensions
on a different distribution.
- new targets for valgrinding Python SWIG extensions and parseIt
(JVM and valgrind don't get along so no target for this)

Comments (0)

Files changed (3)

 # These paths are likely not very portable and may need to be edited
 
 # this should be the path to jni.h
-SWIG_JAVA_GCCFLAGS=-I/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/include/ \
+SWIG_JAVA_GCCFLAGS ?= -I/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/include/ \
 	-I/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/include/linux/
 # this should be the path to Python.h
-SWIG_PYTHON_GCCFLAGS=-I/usr/include/python2.6/
+SWIG_PYTHON_GCCFLAGS ?= -I/usr/include/python2.6/
 # -L should have the path to libstdc++.so
-SWIG_LINKER_FLAGS=-lstdc++ -L/usr/lib/gcc/x86_64-redhat-linux/4.4.4/
+SWIG_LINKER_FLAGS ?= -lstdc++ -L/usr/lib/gcc/x86_64-redhat-linux/4.4.4/
 export SWIG_JAVA_GCCFLAGS
 export SWIG_PYTHON_GCCFLAGS
 export SWIG_LINKER_FLAGS

first-stage/PARSE/Makefile

 evalTree: $(EVALTREE_OBJS)
 	$(CXX) $(CFLAGS) ${EVALTREE_OBJS} -o evalTree -D_REENTRANT -D_XOPEN_SOURCE=600 -lpthread
 
+.PHONY: valgrind-parseIt
+valgrind-parseIt: CFLAGS += -g -O0
+valgrind-parseIt: parseIt
+	valgrind --leak-check=full ./parseIt ../DATA/EN/ ../../sample-text/sample-data.txt
+
 #
 # SWIG wrappers for Java and Python
 #
 SWIG_PARSER_MODULE_NAME ?= SWIGParser
 # SWIG_JAVA_PACKAGE ?= your.package.name.for.the.swig.wrapper
 
+ifneq ($(strip $(SWIG_JAVA_PACKAGE)),)
+	SWIG_FLAGS += -package ${SWIG_JAVA_PACKAGE}
+endif
+
 # 
 # main SWIG targets
 #
 swig-python-test: swig-python
 	PYTHONPATH=$(PYTHONPATH):swig/python/lib python swig/python/test/test.py
 
+.PHONY: swig-python-valgrind
+swig-python-valgrind: CFLAGS += -g -O0
+swig-python-valgrind: swig-python
+	PYTHONPATH=$(PYTHONPATH):swig/python/lib valgrind --leak-check=full --suppressions=/usr/share/doc/python-devel-2.6.6/valgrind-python.supp python swig/python/test/test.py
+
 swig-clean:
 	rm -rf swig/build swig/python/lib swig/java/lib swig/java/test/*.class swig/python/test/*.py[co]
 
 swig/build/java_wrapper.cxx: swig/wrapper.i
 	mkdir -p swig/build
 	mkdir -p swig/java/lib
-ifeq ($(strip $(SWIG_JAVA_PACKAGE)),)
-	swig -module $(SWIG_PARSER_MODULE_NAME) -Wall -c++ -java -outdir swig/java/lib \
+	swig $(SWIG_FLAGS) -module $(SWIG_PARSER_MODULE_NAME) -Wall -c++ -java -outdir swig/java/lib \
 		-o swig/build/java_wrapper.cxx swig/wrapper.i
-else
-	swig -module $(SWIG_PARSER_MODULE_NAME) -Wall -c++ -java -outdir swig/java/lib \
-		-package ${SWIG_JAVA_PACKAGE} \
-		-o swig/build/java_wrapper.cxx swig/wrapper.i
-endif
 
 swig/build/java_wrapper.o: swig/build/java_wrapper.cxx
 	$(CC) -O3 $(CFLAGS) -c $(SWIG_JAVA_GCCFLAGS) -I. \
 swig/build/python_wrapper.cxx: swig/wrapper.i
 	mkdir -p swig/build
 	mkdir -p swig/python/lib
-	swig -module $(SWIG_PARSER_MODULE_NAME) -Wall -c++ -python -classic \
+	swig $(SWIG_FLAGS) -module $(SWIG_PARSER_MODULE_NAME) -Wall -c++ -python -classic \
 		-outdir swig/python/lib -o swig/build/python_wrapper.cxx swig/wrapper.i
 
 swig/build/python_wrapper.o: swig/build/python_wrapper.cxx
 		-I. swig/build/python_wrapper.cxx -o swig/build/python_wrapper.o
 
 swig/python/lib/_$(SWIG_PARSER_MODULE_NAME).so: swig/build/python_wrapper.o $(COMMON_OBJS) $(SWIG_OBJS)
-	$(CC) $(SWIG_LINKER_FLAGS) -shared \
+	$(CC) $(CFLAGS) $(SWIG_LINKER_FLAGS) -shared \
 		-o swig/python/lib/_$(SWIG_PARSER_MODULE_NAME).so \
 		$(COMMON_OBJS) $(SWIG_OBJS) swig/build/python_wrapper.o

second-stage/programs/features/Makefile

 
 # Edit these variables as needed
 SWIG_RERANKER_MODULE_NAME ?= SWIGReranker
-SWIG_JAVA_PACKAGE ?= ''
+SWIG_JAVA_PACKAGE ?= ${SWIG_RERANKER_MODULE_NAME}
+
+ifneq ($(strip $(SWIG_JAVA_PACKAGE)),)
+	SWIG_FLAGS += -package ${SWIG_JAVA_PACKAGE}
+endif
 
 SWIG_OBJS = simple-api.o heads.o read-tree.o sym.o
 
 swig/java/lib/lib$(SWIG_RERANKER_MODULE_NAME).so: $(SWIG_OBJS)
 	mkdir -p swig/build
 	mkdir -p swig/java/lib
-	swig -module $(SWIG_RERANKER_MODULE_NAME) -Wall -c++ -java -outdir swig/java/lib \
-		-package ${SWIG_JAVA_PACKAGE} \
+	swig $(SWIG_FLAGS) -module $(SWIG_RERANKER_MODULE_NAME) -Wall -c++ -java -outdir swig/java/lib \
 		-o swig/build/java_wrapper.cxx swig/wrapper.i
 	gcc -O2 $(CXXFLAGS) -c $(SWIG_JAVA_GCCFLAGS) -iquote . \
 		swig/build/java_wrapper.cxx -o swig/build/java_wrapper.o
 swig/python/lib/_$(SWIG_RERANKER_MODULE_NAME).so: $(SWIG_OBJS)
 	mkdir -p swig/build
 	mkdir -p swig/python/lib
-	swig -module $(SWIG_RERANKER_MODULE_NAME) -Wall -c++ -python -classic -outdir \
+	swig $(SWIG_FLAGS) -module $(SWIG_RERANKER_MODULE_NAME) -Wall -c++ -python -classic -outdir \
 		swig/python/lib -o swig/build/python_wrapper.cxx swig/wrapper.i
 	g++ -fno-strict-aliasing $(CXXFLAGS) -Wfatal-errors \
 		-c -iquote . $(SWIG_PYTHON_GCCFLAGS) \
 swig-python-test: swig-python
 	PYTHONPATH=swig/python/lib/ python swig/python/test/test.py
 
+.PHONY: swig-python-valgrind
+swig-python-valgrind: CXXFLAGS += -g
+swig-python-valgrind: swig-python
+	PYTHONPATH=swig/python/lib/ valgrind --leak-check=full --suppressions=/usr/share/doc/python-devel-2.6.6/valgrind-python.supp python swig/python/test/test.py
+
 swig-clean:
 	rm -rf swig/build swig/python/lib swig/java/lib swig/java/test/*.class swig/python/test/*.py[co] simple-api.o