[Asterisk-Dev] Makefile changes for more platforms

Thorsten Lockert tholo at sigmasoft.com
Sun Apr 27 08:07:47 MST 2003


This patch changes the Makefiles to specify position-indendependant
code (PIC) for things that will be in shared modules.  This appears
to be the default on Linux, but is not on most other systems.  Thus
the -fPIC flag is a no-op on Linux, but makes things work on other
platforms.

In addition it tries to be a bit better about passing debug flags
to the linker and link against apropriate libraries on non-Linux
platforms.

Index: Makefile
===================================================================
RCS file: /usr/cvsroot/asterisk/Makefile,v
retrieving revision 1.2
diff -u -r1.2 Makefile
--- Makefile	23 Apr 2003 16:23:12 -0000	1.2
+++ Makefile	27 Apr 2003 15:13:22 -0000
@@ -13,13 +13,17 @@
 
 .EXPORT_ALL_VARIABLES:
 
+OSARCH=$(shell uname -s)
+
 # Pentium Pro Optimize
-#PROC=i686
+PROC=i686
 # Pentium Optimize
 #PROC=i586
 #PROC=k6
 #PROC=ppc
+ifeq (${OSARCH},Linux)
 PROC=$(shell uname -m)
+endif
 
 ######### More GSM codec optimization
 ######### Uncomment to enable MMXTM optimizations for x86 architecture CPU's
@@ -63,6 +67,9 @@
 CFLAGS+=$(OPTIMIZE)
 CFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
 CFLAGS+=$(shell if uname -m | grep -q ppc; then echo "-fsigned-char"; fi)
+ifeq (${OSARCH},OpenBSD)
+CFLAGS+=-pthread
+endif
 
 LIBEDIT=editline/libedit.a
 
@@ -85,7 +92,10 @@
 CFLAGS+= $(TRACE_FRAMES)
 CFLAGS+=# -fomit-frame-pointer 
 SUBDIRS=res channels pbx apps codecs formats agi cdr astman
-LIBS=-ldl -lpthread -lncurses -lm  #-lnjamd
+ifeq (${OSARCH},Linux)
+LIBS=-ldl
+endif
+LIBS+=-lpthread -lncurses -lm  #-lnjamd
 OBJS=io.o sched.o logger.o frame.o loader.o config.o channel.o \
 	translate.o file.o say.o pbx.o cli.o md5.o term.o \
 	ulaw.o alaw.o callerid.o fskmodem.o image.o app.o \
@@ -147,7 +157,7 @@
 endif
 
 asterisk: .version build.h editline/libedit.a db1-ast/libdb1.a $(OBJS)
-	gcc -o asterisk -rdynamic $(OBJS) $(LIBS) $(LIBEDIT) db1-ast/libdb1.a
+	gcc $(DEBUG) -o asterisk -rdynamic $(OBJS) $(LIBS) $(LIBEDIT) db1-ast/libdb1.a
 
 subdirs: 
 	for x in $(SUBDIRS); do $(MAKE) -C $$x || exit 1 ; done
Index: apps/Makefile
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/Makefile,v
retrieving revision 1.1.1.8
diff -u -r1.1.1.8 Makefile
--- apps/Makefile	16 Mar 2003 06:00:09 -0000	1.1.1.8
+++ apps/Makefile	27 Apr 2003 15:13:22 -0000
@@ -27,7 +27,7 @@
 APPS+=$(shell if [ -f /usr/include/linux/zaptel.h ]; then echo "app_zapras.so app_meetme.so app_flash.so app_zapbarge.so" ; fi)
 #APPS+=$(shell if [ -f /usr/include/zap.h ]; then echo "app_rpt.so" ; fi)
 
-CFLAGS+=
+CFLAGS+=-fPIC
 
 all: $(APPS)
 
Index: cdr/Makefile
===================================================================
RCS file: /usr/cvsroot/asterisk/cdr/Makefile,v
retrieving revision 1.3
diff -u -r1.3 Makefile
--- cdr/Makefile	24 Apr 2003 01:19:33 -0000	1.3
+++ cdr/Makefile	27 Apr 2003 15:13:22 -0000
@@ -13,7 +13,7 @@
 
 MODS=cdr_csv.so
 
-CFLAGS+=
+CFLAGS+=-fPIC
 
 #
 # MySQL stuff...  Autoconf anyone??
Index: channels/Makefile
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/Makefile,v
retrieving revision 1.4
diff -u -r1.4 Makefile
--- channels/Makefile	18 Apr 2003 14:34:46 -0000	1.4
+++ channels/Makefile	27 Apr 2003 15:13:22 -0000
@@ -11,6 +11,8 @@
 # the GNU General Public License
 #
 
+OSARCH=$(shell uname -s)
+
 CHANNEL_LIBS=chan_modem.so chan_iax.so chan_sip.so \
 	     chan_modem_aopen.so chan_oss.so \
              chan_modem_bestdata.so chan_modem_i4l.so \
@@ -41,6 +43,7 @@
 ALSA_SRC+=$(shell [ -f alsa-monitor.h ] && echo "alsa-monitor.h")
 
 CFLAGS+=-DCRYPTO
+CFLAGS+=-fPIC
 
 CFLAGS+=#-DVOFRDUMPER
 
@@ -76,7 +79,11 @@
 chan_oss.o: chan_oss.c  busy.h ringtone.h
 
 chan_iax2.so: chan_iax2.o iax2-parser.o
+ifeq (${OSARCH},Linux)
 	$(CC) -shared -Xlinker -x -o $@ chan_iax2.o iax2-parser.o
+else
+	$(CC) -shared -Xlinker -x -o $@ chan_iax2.o iax2-parser.o -lossaudio
+endif
 
 chan_zap.o: $(CHANZAP)
 	$(CC) -c $(CFLAGS) -o chan_zap.o $(CHANZAP)
Index: codecs/gsm/Makefile
===================================================================
RCS file: /usr/cvsroot/asterisk/codecs/gsm/Makefile,v
retrieving revision 1.2
diff -u -r1.2 Makefile
--- codecs/gsm/Makefile	23 Apr 2003 16:23:12 -0000	1.2
+++ codecs/gsm/Makefile	27 Apr 2003 15:13:23 -0000
@@ -55,7 +55,7 @@
 # CCFLAGS 	= -c -O
 
 CC		= gcc -ansi -pedantic $(OPTIMIZE) -march=$(PROC) -fschedule-insns2  -fomit-frame-pointer 
-CCFLAGS 	+= -c -DNeedFunctionPrototypes=1 -finline-functions -funroll-loops
+CCFLAGS 	+= -c -DNeedFunctionPrototypes=1 -finline-functions -funroll-loops -fPIC
 
 LD 		= $(CC)
 
@@ -175,7 +175,6 @@
 		$(SRC)/code.c		\
 		$(SRC)/debug.c		\
 		$(SRC)/decode.c		\
-		$(SRC)/k6opt.s	\
 		$(SRC)/long_term.c	\
 		$(SRC)/lpc.c		\
 		$(SRC)/preprocess.c	\
@@ -190,6 +189,9 @@
 		$(SRC)/gsm_option.c	\
 		$(SRC)/short_term.c	\
 		$(SRC)/table.c
+ifneq (${OSARCH},OpenBSD)
+GSM_SOURCES+=	$(SRC)/k6opt.s
+endif
 
 TOAST_SOURCES = $(SRC)/toast.c 		\
 		$(SRC)/toast_lin.c	\
@@ -220,7 +222,6 @@
 		$(SRC)/code.o		\
 		$(SRC)/debug.o		\
 		$(SRC)/decode.o		\
-		$(SRC)/k6opt.o	\
 		$(SRC)/long_term.o	\
 		$(SRC)/lpc.o		\
 		$(SRC)/preprocess.o	\
@@ -235,6 +236,9 @@
 		$(SRC)/gsm_option.o	\
 		$(SRC)/short_term.o	\
 		$(SRC)/table.o
+ifneq (${OSARCH},OpenBSD)
+GSM_OBJECTS+=	$(SRC)/k6opt.o
+endif
 
 TOAST_OBJECTS =	$(SRC)/toast.o 		\
 		$(SRC)/toast_lin.o	\
Index: codecs/mp3/Makefile
===================================================================
RCS file: /usr/cvsroot/asterisk/codecs/mp3/Makefile,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 Makefile
--- codecs/mp3/Makefile	12 Feb 2003 13:59:14 -0000	1.1.1.1
+++ codecs/mp3/Makefile	27 Apr 2003 15:13:23 -0000
@@ -1,7 +1,7 @@
 #
 # LMC section
 
-CFLAGS+= -I../include -Iinclude -O6 -funroll-loops -finline-functions -Wall -Wno-missing-prototypes -Wno-missing-declarations -g
+CFLAGS+= -I../include -Iinclude -O6 -funroll-loops -finline-functions -Wall -Wno-missing-prototypes -Wno-missing-declarations -g -fPIC
 RANLIB=ranlib
 
 # the XING decoder objs and dependencies:
Index: codecs/Makefile
===================================================================
RCS file: /usr/cvsroot/asterisk/codecs/Makefile,v
retrieving revision 1.3
diff -u -r1.3 Makefile
--- codecs/Makefile	23 Apr 2003 16:23:12 -0000	1.3
+++ codecs/Makefile	27 Apr 2003 15:13:23 -0000
@@ -21,7 +21,7 @@
 MODG723+=$(shell [ -f g723.1b/coder2.c ] && echo "codec_g723_1b.so")
 MODSPEEX=$(shell [ -f /usr/include/speex.h ] || [ -f /usr/local/include/speex.h ] && echo "codec_speex.so")
 MODILBC=$(shell [ -f ilbc/iLBC_decode.h ] && echo "codec_ilbc.so")
-CFLAGS+=
+CFLAGS+=-fPIC
 
 LIBG723=g723.1/libg723.a
 LIBG723B=g723.1b/libg723b.a
Index: codecs/lpc10/Makefile
===================================================================
RCS file: /usr/cvsroot/asterisk/codecs/lpc10/Makefile,v
retrieving revision 1.2
diff -u -r1.2 Makefile
--- codecs/lpc10/Makefile	28 Mar 2003 21:36:52 -0000	1.2
+++ codecs/lpc10/Makefile	27 Apr 2003 15:13:23 -0000
@@ -22,7 +22,7 @@
 # 
 
 WARNINGS = -Wall -Wno-comment -Wno-error
-CFLAGS = $(OPTIMIZE) -I$(LIB_TARGET_DIR) $(WARNINGS)
+CFLAGS = $(OPTIMIZE) -I$(LIB_TARGET_DIR) $(WARNINGS) -fPIC
 #CFLAGS+= $(shell if uname -m | grep -q 86; then echo "-mpentium" ; fi)
 
 #fix for PPC processors
Index: codecs/ilbc/Makefile
===================================================================
RCS file: /usr/cvsroot/asterisk/codecs/ilbc/Makefile,v
retrieving revision 1.2
diff -u -r1.2 Makefile
--- codecs/ilbc/Makefile	23 Apr 2003 19:13:35 -0000	1.2
+++ codecs/ilbc/Makefile	27 Apr 2003 15:13:23 -0000
@@ -1,3 +1,4 @@
+CFLAGS+= -fPIC -O3
 LIB=libilbc.a
 
 OBJS= anaFilter.o iCBSearch.o packing.o \
Index: formats/Makefile
===================================================================
RCS file: /usr/cvsroot/asterisk/formats/Makefile,v
retrieving revision 1.2
diff -u -r1.2 Makefile
--- formats/Makefile	21 Mar 2003 04:25:13 -0000	1.2
+++ formats/Makefile	27 Apr 2003 15:13:23 -0000
@@ -17,7 +17,7 @@
 
 GSMLIB=../codecs/gsm/lib/libgsm.a
 
-CFLAGS+=
+CFLAGS+=-fPIC
 
 all: $(FORMAT_LIBS)
 
Index: pbx/Makefile
===================================================================
RCS file: /usr/cvsroot/asterisk/pbx/Makefile,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 Makefile
--- pbx/Makefile	12 Feb 2003 13:59:15 -0000	1.1.1.1
+++ pbx/Makefile	27 Apr 2003 15:13:23 -0000
@@ -27,7 +27,7 @@
 MOC=$(QTDIR)/bin/moc
 KDE_FLAGS=-I$(KDEDIR)/include -I$(KDEDIR)/include/kde -I$(QTDIR)/include
 KDE_LIBS=-L$(KDEDIR)/lib -L$(QTDIR)/lib -lqt -lkdecore -lkdeui
-CFLAGS+=
+CFLAGS+=-fPIC
 
 KDE_CONSOLE_OBJS=pbx_kdeconsole_main.o pbx_kdeconsole.o 
 
Index: res/Makefile
===================================================================
RCS file: /usr/cvsroot/asterisk/res/Makefile,v
retrieving revision 1.4
diff -u -r1.4 Makefile
--- res/Makefile	8 Apr 2003 04:28:09 -0000	1.4
+++ res/Makefile	27 Apr 2003 15:13:23 -0000
@@ -20,7 +20,7 @@
 #
 # Work around buggy RedHat 9.0
 #
-CFLAGS+=-DOPENSSL_NO_KRB5
+CFLAGS+=-DOPENSSL_NO_KRB5 -fPIC
 
 all: $(MODS)
 
--
Thorsten Lockert      | tholo at sigmasoft.com | Universe, n.:
2121 N. Lakeshore Dr. | tholo at openbsd.org   |         The problem.
Chapel Hill, NC 27514 |                     |



More information about the asterisk-dev mailing list