--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -1,3 +1,4 @@
+include $(TOPDIR)/rules.mk
 
 AM_CPPFLAGS = @GLIB2_CFLAGS@ -I$(top_srcdir)/include \
 	-I$(top_srcdir)/include/ccnet \
@@ -85,7 +86,7 @@ rpc_table.stamp: ${top_srcdir}/lib/rpc_t
 	@rm -f rpc_table.tmp
 	@touch rpc_table.tmp
 	@echo "[libsearpc]: generating rpc header files"
-	@PYTHON@ `which searpc-codegen.py` ${top_srcdir}/lib/rpc_table.py
+	@PYTHON@ "$(STAGING_DIR)/usr/bin/searpc-codegen.py" ${top_srcdir}/lib/rpc_table.py
 	@echo "[libsearpc]: done"
 	@mv -f rpc_table.tmp $@
 
