
$FreeBSD: ports/net/asterisk-oh323/files/patch-asterisk-driver::Makefile,v 1.6 2009/01/26 09:04:20 sobomax Exp $

--- asterisk-driver/Makefile.orig
+++ asterisk-driver/Makefile
@@ -34,23 +34,23 @@
 ifndef SKIP_SUFFIX
 	ifeq ($(OH323STAT),1)
 		ifeq ($(OH323BUILDTYPE),debug) # Static, debug
-			LIBPTPATH=$(word 1,$(shell ls $(PWLIBDIR)/lib/libpt*_d_s.a))
+			LIBPTPATH=$(word 1,$(shell ls $(SYSLIBDIR)/libpt*_d_s.a))
 		else                           # Static, opt
-			LIBPTPATH=$(word 1,$(shell ls $(PWLIBDIR)/lib/libpt*_r_s.a))
+			LIBPTPATH=$(word 1,$(shell ls $(SYSLIBDIR)/libpt*_r_s.a))
 		endif
 	else
 		ifeq ($(OH323BUILDTYPE),debug) # Shared, debug
-			LIBPTPATH=$(word 1,$(shell ls $(PWLIBDIR)/lib/libpt*d.so))
+			LIBPTPATH=$(word 1,$(shell ls $(SYSLIBDIR)/libpt*d.so))
 		else                           # Shared, opt
-			LIBPTPATH=$(word 1,$(shell ls $(PWLIBDIR)/lib/libpt*r.so))
+			LIBPTPATH=$(word 1,$(shell ls $(SYSLIBDIR)/libpt*r.so))
 		endif
 	endif
 	LIBPTNAME=$(subst lib,,$(basename $(notdir $(LIBPTPATH))))
 else
 	ifeq ($(OH323STAT),1)
-		LIBPTPATH=$(word 1,$(shell ls $(PWLIBDIR)/lib/$(LIBPT_BASE).a))
+		LIBPTPATH=$(word 1,$(shell ls $(SYSLIBDIR)/$(LIBPT_BASE).a))
 	else
-		LIBPTPATH=$(word 1,$(shell ls $(PWLIBDIR)/lib/$(LIBPT_BASE).so))
+		LIBPTPATH=$(word 1,$(shell ls $(SYSLIBDIR)/$(LIBPT_BASE).so))
 	endif
 	LIBPTNAME=$(subst lib,,$(basename $(notdir $(LIBPTPATH))))
 endif
@@ -59,42 +59,42 @@
 ifndef SKIP_SUFFIX
 	ifeq ($(OH323STAT),1)
 		ifeq ($(OH323BUILDTYPE),debug)   # Static, debug
-			LIBH323PATH=$(word 1,$(shell ls $(OPENH323DIR)/lib/libh323*_d_s.a))
+			LIBH323PATH=$(word 1,$(shell ls $(SYSLIBDIR)/libh323*_d_s.a))
 		else
 			ifeq ($(OH323BUILDTYPE),opt) # Static, opt
-				LIBH323PATH=$(word 1,$(shell ls $(OPENH323DIR)/lib/libh323*_r_s.a))
+				LIBH323PATH=$(word 1,$(shell ls $(SYSLIBDIR)/libh323*_r_s.a))
 			else                         # Static, opt, no trace
-				LIBH323PATH=$(word 1,$(shell ls $(OPENH323DIR)/lib/libh323*_n_s.a))
+				LIBH323PATH=$(word 1,$(shell ls $(SYSLIBDIR)/libh323*_n_s.a))
 			endif
 		endif
 	else
 		ifeq ($(OH323BUILDTYPE),debug)   # Shared, debug
-			LIBH323PATH=$(word 1,$(shell ls $(OPENH323DIR)/lib/libh323*d.so))
+			LIBH323PATH=$(word 1,$(shell ls $(SYSLIBDIR)/libh323*d.so))
 		else
 			ifeq ($(OH323BUILDTYPE),opt) # Shared, opt
-				LIBH323PATH=$(word 1,$(shell ls $(OPENH323DIR)/lib/libh323*r.so))
+				LIBH323PATH=$(word 1,$(shell ls $(SYSLIBDIR)/libh323*r.so))
 			else                         # Shared, opt, no trace
-				LIBH323PATH=$(word 1,$(shell ls $(OPENH323DIR)/lib/libh323*n.so))
+				LIBH323PATH=$(word 1,$(shell ls $(SYSLIBDIR)/libh323*n.so))
 			endif
 		endif
 	endif
 	LIBH323NAME=$(subst lib,,$(basename $(notdir $(LIBH323PATH))))
 else
 	ifeq ($(OH323STAT),1)
-		LIBH323PATH=$(word 1,$(shell ls $(OPENH323DIR)/lib/$(LIBH323_BASE).a))
+		LIBH323PATH=$(word 1,$(shell ls $(SYSLIBDIR)/$(LIBH323_BASE).a))
 	else
-		LIBH323PATH=$(word 1,$(shell ls $(OPENH323DIR)/lib/$(LIBH323_BASE).so))
+		LIBH323PATH=$(word 1,$(shell ls $(SYSLIBDIR)/$(LIBH323_BASE).so))
 	endif
 	LIBH323NAME=$(subst lib,,$(basename $(notdir $(LIBH323PATH))))
 endif
 LIBH323=$(LIBH323NAME)
 
 ifndef SKIP_EXTLIBS
-	EXTLIBS=$(shell $(PWLIBDIR)/make/ptlib-config --libs)
+	EXTLIBS=$(shell $(PWLIBDIR)/make/ptlib-config --ldflags --libs)
 endif
 
 CFLAGS += -pipe -Wstrict-prototypes -Wmissing-prototypes \
-		-Wmissing-declarations -D_REENTRANT -D_GNU_SOURCE -fPIC -g -O6 \
+		-Wmissing-declarations -D_REENTRANT -D_GNU_SOURCE -fPIC -g \
 		-fomit-frame-pointer -DAST_MODULE=\"chan_oh323.so\"
 
 DRVDEPS=$(shell ls *.h)
@@ -116,6 +116,7 @@
 	if [ ! -d $(DESTDIR)$(ASTERISKETCDIR) ]; then \
 		$(INSTALL) -d $(DESTDIR)$(ASTERISKETCDIR); \
 	fi
+	$(INSTALL) -m 0644 oh323.conf.sample $(DESTDIR)$(ASTERISKETCDIR)/
 	if [ ! -f $(DESTDIR)$(ASTERISKETCDIR)/oh323.conf ]; then \
 		$(INSTALL) -m 0644 oh323.conf.sample $(DESTDIR)$(ASTERISKETCDIR)/oh323.conf; \
 	fi
@@ -151,19 +152,27 @@
 	@if [ ! -f "$(LIBH323PATH)" ]; then \
 		echo "ERROR: No OPENH323 library found!"; exit 1; \
 	fi
+ifeq ($(OH323NOWRAP),1)
+	$(CC) -shared -Xlinker -x -g -o $@ $(TARGET_OBJ) \
+	../wrapper/*.o \
+	-L$(SYSLIBDIR) -l$(LIBH323) \
+	-L$(SYSLIBDIR) -l$(LIBPT) \
+	-lstdc++ $(EXTLIBS)
+else
 ifeq ($(OH323STAT),1)
 	$(CC) -shared -Xlinker -x -g -o $@ $(TARGET_OBJ) \
 	-L../wrapper -loh323wrap_s \
-	-L$(OPENH323DIR)/lib -l$(LIBH323) \
-	-L$(PWLIBDIR)/lib -l$(LIBPT) \
+	-L$(SYSLIBDIR) -l$(LIBH323) \
+	-L$(SYSLIBDIR) -l$(LIBPT) \
 	-lstdc++ $(EXTLIBS)
 else
 	$(CC) -shared -Xlinker -x -g -o $@ $(TARGET_OBJ) \
 	-L../wrapper -loh323wrap \
-	-L$(OPENH323DIR)/lib -l$(LIBH323) \
-	-L$(PWLIBDIR)/lib -l$(LIBPT) \
+	-L$(SYSLIBDIR) -l$(LIBH323) \
+	-L$(SYSLIBDIR) -l$(LIBPT) \
 	-lstdc++ $(EXTLIBS)
 endif
+endif
 
 %.o: %.c $(DRVDEPS)
 	$(CC) $(CFLAGS) $(ASTERISKINCLUDE) -c -o $@ $<
