- new target arch/os detection based on gcc

(formerly based on host, now target system)


git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@1736 8eb893ce-cfd4-0310-b710-fb5ebe64c474
sayer/1.4-spce2.6
Raphael Coeffic 17 years ago
parent 1a0aac1e16
commit ea2a6e3824

@ -5,15 +5,11 @@ NAME=sems
.PHONY: all
all: modules
COREPATH=core
include Makefile.defs
modules = core apps
# or, if you want to build all that is there:
# modules = $(filter-out $(wildcard Makefile* README doc *gz), \
# $(wildcard *) )
# imodules = $(filter-out ser-0.9.6-sems, $(modules))
.PHONY: clean
clean:
-@rm -f *.so

@ -54,7 +54,8 @@ USE_MONITORING=yes
LDFLAGS += -lm
OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")
OS := $(shell $(CC) $(EXTRA_CFLAGS) -o $(COREPATH)/../getos $(COREPATH)/../getos.c && $(COREPATH)/../getos)
ARCH := $(shell $(CC) $(EXTRA_CFLAGS) -o $(COREPATH)/../getarch $(COREPATH)/../getarch.c && $(COREPATH)/../getarch)
ifdef USE_SPANDSP
ifneq ($(spandsp_defs), 1)
@ -80,7 +81,6 @@ endif
# Additions for Solaris support.
ifeq ($(OS),solaris)
GETARCH=uname -p
CPPFLAGS += -DHAVE_SYS_SOCKIO_H -DBSD_COMP -fPIC -include compat/solaris.h
CFLAGS += -DHAVE_SYS_SOCKIO_H -DBSD_COMP -fPIC -include compat/solaris.h
# For nanosleep.
@ -91,14 +91,10 @@ ifeq ($(OS),solaris)
# I don't have libspeex installed.
# binrpcctrl does some really weird header stuff that doesn't work.
exclude_modules += binrpcctrl ilbc speex
else
GETARCH=uname -m
endif
ARCH ?= $(shell $(GETARCH) |sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
-e s/armv4l/arm/ -e "s/Power Macintosh/ppc/" \
-e "s/cobalt/mips2/" \
-e s/amd64/x86_64/ )
# fix sparc -> sparc64
ifeq ($(ARCH),sparc)
@ -144,7 +140,7 @@ else
ifeq ($(OS), netbsd)
LDFLAGS += -rdynamic -pthread
else
ifeq ($(OS), darwin)
ifeq ($(OS), macosx)
LDFLAGS += -rdynamic -pthread
LIB_LDFLAGS = -flat_namespace -undefined suppress -bundle
CXXFLAGS += -fno-common
@ -184,9 +180,6 @@ PREFIX ?= /usr/local
prefix = $(PREFIX)
BASEDIR ?=
basedir = $(BASEDIR)
# for install-ser-cfg
SERPREFIX ?= /opt/ser-sems
ser-prefix = $(SERPREFIX)
# Redhat users should use sems.redhat instead of sems
# the file will be to $(bin-prefix)/$(bin-dir)/sems copied.
@ -259,7 +252,7 @@ INSTALL-DOC = $(INSTALL) -m 644
INSTALL-AUDIO = $(INSTALL) -m 644
#export stuff to sub-makes
export REL_VERSION RELEASE OS
export REL_VERSION RELEASE OS ARCH
export CPPFLAGS CXXFLAGS LDFLAGS CFLAGS LIB_LDFLAGS
export CXX CC LD
export DESTDIR PREFIX prefix basedir ser-prefix

@ -39,6 +39,8 @@ fulldoc:
rm -Rf doxygen_output; doxygen doxygen_fulldoc ; \
rm -rf ../doc/doxygen_fulldoc ; mv doxygen_output ../doc/doxygen_fulldoc
COREPATH=.
include ../Makefile.defs
LDFLAGS += -lstdc++
@ -71,7 +73,7 @@ endif
$(CXX) -MM $< $(CPPFLAGS) $(CXXFLAGS) > $@
$(NAME): $(NAME).o $(OBJS) ../Makefile.defs
$(LD) -o $(NAME) $(NAME).o $(OBJS) $(LDFLAGS)
$(LD) -o $(NAME) $(NAME).o $(OBJS) $(LDFLAGS) $(EXTRA_LDFLAGS)
install: all mk-install-dirs \
install-audio \

@ -0,0 +1,40 @@
#include <stdio.h>
/*
* CPU detection (http://predef.sourceforge.net/prearch.html)
*/
#if defined(__i386__)
# define ARCH "x86"
#elif (defined(__x86_64__) || defined(__x86_64) || defined(__amd64__) || defined(__amd64))
# define ARCH "x86_64"
#elif defined(__arm__)
# if defined(__thumb__)
# define ARCH "arm-thumb"
# else
# define ARCH "arm"
# endif
#elif (defined(__ia64__) || defined(__IA64) || defined(__IA64__))
# define ARCH "ia64"
#elif defined(__m68k__)
# define ARCH "m68k"
#elif (defined(__mips__) || defined(mips))
# define ARCH "mips"
#elif (defined(__powerpc) || defined(__powerpc__) || defined(__POWERPC__) || defined(__ppc__))
# define ARCH "ppc"
#else
#define ARCH "unknown"
#warning "Could not detect CPU Architecture"
#endif
main()
{
printf(ARCH "\n");
}

@ -0,0 +1,38 @@
#include <stdio.h>
/*
* OS detection (see http://predef.sourceforge.net/preos.html)
*/
#if (defined(linux) || defined(__linux))
# define OS "linux"
#elif (defined(sun) || defined(__sun))
# define OS "solaris"
#elif (defined(__APPLE__) && defined(__MACH__))
# define OS "macosx"
#elif defined(__FreeBSD__)
# define OS "freebsd"
#elif defined(__NetBSD__)
# define OS "netbsd"
#elif defined(__OpenBSD__)
# define OS "openbsd"
#elif defined(__bsdi__)
# define OS "bsdi"
#elif defined(__DragonFly__)
# define OS "dragonfly"
#else
# define OS "unknown"
# warning "Could not detect the OS"
#endif
main()
{
printf(OS "\n");
}
Loading…
Cancel
Save