From 280a1313b009fcd5c0cb1b399ed4de35a2e91c8f Mon Sep 17 00:00:00 2001 From: "lperron@google.com" Date: Sun, 4 Dec 2011 20:05:48 +0000 Subject: [PATCH] regroup system detection in Makefile.port --- Makefile | 14 +++----------- Makefile.def | 12 +----------- Makefile.port | 34 ++++++++++++++++++++++++++++++++++ Makefile.third_party.unix | 13 ++++++------- Makefile.unix | 8 +++----- 5 files changed, 47 insertions(+), 34 deletions(-) create mode 100644 Makefile.port diff --git a/Makefile b/Makefile index 623cf3f4dd..c917b1aac0 100644 --- a/Makefile +++ b/Makefile @@ -9,18 +9,10 @@ help: all: cplibs cpexe pycp javacp algorithmslibs pyalgorithms javaalgorithms graphlibs pygraph javagraph lplibs lpexe pylp javalp -# Let's discover something about where we run -ifeq "$(SHELL)" "cmd.exe" - SYSTEM=win -else - ifeq "$(SHELL)" "sh.exe" - SYSTEM=win - else - SYSTEM=unix - endif -endif +# First, we try to detect the platform. +include Makefile.port -# First, we include predefined variables +# We include predefined variables include Makefile.def # Then we overwrite the local ones if the Makefile.local file exists. diff --git a/Makefile.def b/Makefile.def index d4f79abe36..1f9187ed6a 100644 --- a/Makefile.def +++ b/Makefile.def @@ -23,17 +23,7 @@ UNIX_PROTOBUF_DIR=../protobuf-2.4.1 #UNIX_SCIP_DIR=../ziboptsuite-2.1.0/scip-2.1.0 # Linux jdk root -# first, determine 32 or 64 bits. -ifeq "$(SYSTEM)" "unix" - LBITS := $(shell getconf LONG_BIT) - ifeq ($(LBITS),64) - JDK_EXT=64 - else - JDK_EXT=32 - endif -endif - -LINUX_JDK_ROOT=/usr/local/buildtools/java/jdk-$(JDK_EXT) +LINUX_JDK_ROOT=/usr/local/buildtools/java/jdk-$(PTRLENGTH) # Include files path for java on mac os X MAC_JDK_HEADERS=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/include #MAC_JDK_HEADERS=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bundle/Headers diff --git a/Makefile.port b/Makefile.port new file mode 100644 index 0000000000..9d687e176a --- /dev/null +++ b/Makefile.port @@ -0,0 +1,34 @@ +# Useful variable. +TOP ?= $(shell pwd) +OS = $(shell uname -s) + +# Let's discover something about where we run +ifeq "$(SHELL)" "cmd.exe" + SYSTEM=win +else + ifeq "$(SHELL)" "sh.exe" + SYSTEM=win + PLATFORM=WINDOWS + else + SYSTEM=unix + ifeq ($(OS),Linux) + PLATFORM=LINUX + LBITS : = $(shell getconf LONG_BIT) + ifeq ($(LBITS),64) + PTRLENGTH=64 + else + PTRLENGTH=32 + endif + endif + ifeq ($(OS),Darwin) # Assume Mac Os X + PLATFORM=MACOSX + PTRLENGTH=64 + endif + endif +endif + +printport: + @echo SHELL=$(SHELL) + @echo SYSTEM=$(SYSTEM) + @echo PLATFORM=$(PLATFORM) + @echo PTRLENGTH=$(PTRLENGTH) \ No newline at end of file diff --git a/Makefile.third_party.unix b/Makefile.third_party.unix index d780c8d193..3f3a943da6 100644 --- a/Makefile.third_party.unix +++ b/Makefile.third_party.unix @@ -5,22 +5,21 @@ GOOGLE_APPUTILS_TAG=11 # trunk CBC_TAG=2.7.5 SWIG_TAG=rel-2.0.4 -# Useful variable. -TOP ?= $(shell pwd) - # Build extra dependencies (GLPK, SCIP) from archive only if the archive is present. -GLPK_TAG=4.47 # The archive should be glpk-4.47.tar.gz -SCIP_TAG=2.1.0 # The archive should be ziboptsuite-2.1.0.tgz +# The archive should be glpk-4.47.tar.gz +GLPK_TAG=4.47 +# The archive should be ziboptsuite-2.1.0.tgz +SCIP_TAG=2.1.0 # Detect if scip archive is there. ifeq ($(wildcard dependencies/archives/ziboptsuite-$(SCIP_TAG).tgz),) SCIP_TARGET= else SCIP_TARGET=dependencies/install/ziboptsuite-$(SCIP_TAG)/scip-$(SCIP_TAG)/bin/scip - ifeq ($(OS),Linux) + ifeq ($(PLATFORM), LINUX) BUILD_SCIP=make ZIMPL=false READLINE=false USRCXXFLAGS=-fPIC CFLAGS=-fPIC endif - ifeq ($(OS),Darwin) # Assume Mac Os X + ifeq ($(PLATFORM), MACOSX) BUILD_SCIP=make ZIMPL=false READLINE=false ARCH=x86_64 endif endif diff --git a/Makefile.unix b/Makefile.unix index 36ce46b720..c19fc873f5 100644 --- a/Makefile.unix +++ b/Makefile.unix @@ -59,7 +59,7 @@ UNIX_CLP_COIN = /coin endif endif -ifeq ($(OS),Linux) +ifeq ($(PLATFORM),LINUX) LD = gcc -shared # This is needed to find libgflags.a GFLAGS_LNK = -Wl,-rpath $(UNIX_GFLAGS_DIR)/lib -L$(UNIX_GFLAGS_DIR)/lib -lgflags @@ -79,9 +79,7 @@ endif ifdef UNIX_SCIP_DIR SCIP_LNK = -Wl,-rpath $(UNIX_SCIP_DIR)/lib -L$(UNIX_SCIP_DIR)/lib -lscip.$(SCIP_ARCH) -lnlpi.$(SCIP_ARCH) -llpispx.$(SCIP_ARCH) -lsoplex.$(SCIP_ARCH) -lreadline endif -# Detect 32 bit or 64 bit OS and define ARCH and SCIP_ARCH flags correctly. -LBITS : = $(shell getconf LONG_BIT) -ifeq ($(LBITS),64) +ifeq ($(PTRLENGTH),64) ARCH = -DARCH_K8 SCIP_ARCH = linux.x86_64.gnu.opt else @@ -95,7 +93,7 @@ JAVA_BIN = $(LINUX_JDK_ROOT)/bin/java JAR_BIN = $(LINUX_JDK_ROOT)/bin/jar JNILIBEXT = so endif -ifeq ($(OS),Darwin) # Assume Mac Os X +ifeq ($(PLATFORM),MACOSX) LD = ld -arch x86_64 -bundle -flat_namespace -undefined suppress GFLAGS_LNK = -L$(UNIX_GFLAGS_DIR)/lib -lgflags ZLIB_LNK = -lz