view make/Makefile @ 1:8ff6e91a0455 default tip

Support building BDB on ppc Reviewed-by: chegar
author dholmes
date Tue, 26 Jun 2012 14:32:07 +0100
parents a1985f14b030
children
line wrap: on
line source

#
# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.  Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

# Makefile for building Berkeley DB-RDS ( Restricted Data Store ),
# a.k.a Ultrasmall build
#
# This library is currently used by org.openjdk.pmap.PersistentTreeMap.

# For now dependency on JDK shared makefiles
BUILDDIR = .
PACKAGE = bdb

ifndef BDB_TOPDIR
  BDB_TOPDIR = $(BUILDDIR)/..
endif
ifndef JDK_TOPDIR
  JDK_TOPDIR=$(BDB_TOPDIR)/../jdk
endif
ifndef JDK_MAKE_SHARED_DIR
  JDK_MAKE_SHARED_DIR=$(JDK_TOPDIR)/make/common/shared
endif
ifndef ALT_EXPORT_PATH
  ALT_EXPORT_PATH = $(BDB_TOPDIR)/import
endif

include $(JDK_MAKE_SHARED_DIR)/../Defs.gmk

SRCDIR = $(BUILDDIR)/../src
DISTDIR = $(BUILDDIR)/../dist
EXPORTDIR = $(ALT_EXPORT_PATH)

# Careful not to conflict with LIBRARY definition for Library.gmk
_LIBRARY = $(LIB_PREFIX)db-rds.$(LIBRARY_SUFFIX)

GEN_HEADERS_DIR=$(GENNATIVESRCDIR)/bdb

all: build

ifeq ($(PLATFORM), windows)
  LIBRARY = db-rds
  VERSIONINFO_RESOURCE = libdb.rc

  include FILES_c.gmk
  include $(JDK_MAKE_SHARED_DIR)/../Library.gmk

  # Find C source files
  vpath %.c $(SRCDIR)
  vpath %.c $(SRCDIR)/btree
  vpath %.c $(SRCDIR)/db
  vpath %.c $(SRCDIR)/dbreg
  vpath %.c $(SRCDIR)/common
  vpath %.c $(SRCDIR)/fileops
  vpath %.c $(SRCDIR)/clib
  vpath %.c $(SRCDIR)/hash
  vpath %.c $(SRCDIR)/heap
  vpath %.c $(SRCDIR)/log
  vpath %.c $(SRCDIR)/mutex
  vpath %.c $(SRCDIR)/qam
  vpath %.c $(SRCDIR)/rep
  vpath %.c $(SRCDIR)/repmgr
  vpath %.c $(SRCDIR)/env
  vpath %.c $(SRCDIR)/lock
  vpath %.c $(SRCDIR)/mp
  vpath %.c $(SRCDIR)/txn
  vpath %.c $(SRCDIR)/hmac
  vpath %.c $(SRCDIR)/os_windows
  # search os after os_windows so any commonly named files
  # will be found in os_windows first
  vpath %.c $(SRCDIR)/os

  CFLAGS += -D_WINDOWS -DDB_CREATE_DLL -DHAVE_RDS_BUILD \
            -D_USRDLL -D_WINDLL -D_UNICODE -DUNICODE -D_MBCS
  EXTRA_LFLAGS += /DEF:"libdb.def"
  OTHER_LDLIBS += kernel32.lib user32.lib ws2_32.lib

  # do not link against libjava
  JAVALIB =

  OTHER_INCLUDES += -I$(SRCDIR)
  OTHER_INCLUDES += -I$(SRCDIR)/windows_incl

  $(EXPORTDIR)/header/db.h: $(SRCDIR)/windows_incl/db.h
	$(install-file)

else # NOT WINDOWS
  SRCDIR_ABS:=$(call FullPath,$(SRCDIR))
  DISTDIR_ABS:=$(call FullPath,$(DISTDIR))
  BDB_OUTPUT_LIB=$(TEMPDIR)/.libs/libdb-5.4.$(LIBRARY_SUFFIX)
  BDB_OUTPUT_HEADER=$(TEMPDIR)/db.h
  BDB_CONFIG_OPTIONS=--disable-static CC=$(CC) LD=$(LD)

  # 64-bit Solaris compile needs to specify appropriate addressing model
  ifeq ($(PLATFORM), solaris)
    ifeq ($(ARCH_DATA_MODEL), 64)
      BDB_CONFIG_OPTIONS+=CFLAGS=-m64
    endif
  endif

  # This is a crude hack and needs to be handled correctly
  ifneq ($(CROSS_COMPILE_ARCH), )
    BDB_CONFIG_OPTIONS+=--build=i686-pc-linux-gnu --host=$(CROSS_COMPILE_ARCH)-none-linux-gnueabi \
                        cross_compiling=yes
  endif

  define configure-bdb
    $(CD) $(TEMPDIR) && \
    $(SH) $(DISTDIR_ABS)/configure $(BDB_CONFIG_OPTIONS)
  endef

  define make-bdb
    $(CD) $(TEMPDIR) && \
    $(MAKE)
  endef

  $(BDB_OUTPUT_HEADER):
	$(configure-bdb)
	$(MKDIR) -p $(GEN_HEADERS_DIR)
	$(CP) $(BDB_OUTPUT_HEADER) $(GEN_HEADERS_DIR)

  $(BDB_OUTPUT_LIB): $(BDB_OUTPUT_HEADER)
	$(make-bdb)

  $(LIB_LOCATION)/$(_LIBRARY): $(BDB_OUTPUT_LIB)
	$(install-file)

  $(EXPORTDIR)/header/db.h: $(GEN_HEADERS_DIR)/db.h
	$(install-file)

endif  # NOT WINDOWS

EXPORT_LIST = $(EXPORTDIR)/lib/$(LIBARCH)/$(_LIBRARY)
EXPORT_LIST += $(EXPORTDIR)/header/db.h

build: $(LIB_LOCATION)/$(_LIBRARY) export

export: $(EXPORT_LIST)

$(EXPORTDIR)/lib/$(LIBARCH)/$(_LIBRARY): $(LIB_LOCATION)/$(_LIBRARY)
	$(install-file)

clobber::
	$(RM) -rf $(TEMPDIR) $(EXPORTDIR)

.PHONY: clobber clean build all export $(EXPORTDIR)/lib/$(LIBARCH)/$(_LIBRARY)