blob: 9ccd75dc1a83f22365f3072e6894c2ac2994f031 [file] [log] [blame]
Todd Fiala9bb71b72014-02-26 07:39:20 +00001##===- scripts/Python/modules/readline/Makefile ------------*- Makefile -*-===##
2#
3# The LLVM Compiler Infrastructure
4#
5# This file is distributed under the University of Illinois Open Source
6# License. See LICENSE.TXT for details.
7#
8##===----------------------------------------------------------------------===##
9
10# Skip this entire Makefile if python is disabled.
11ifeq (,$(findstring -DLLDB_DISABLE_PYTHON,$(CXXFLAGS)))
12
13LEVEL := ../../../../../..
14LLDB_LEVEL := ../../../..
15
16LIBRARYNAME = readline
17
18NO_BUILD_ARCHIVE = 1
19LINK_LIBS_IN_SHARED = 1
20SHARED_LIBRARY = 1
21LOADABLE_MODULE = 1
22
Sylvestre Ledru743e2b22014-02-26 15:05:48 +000023PYTHON_INC_DIR = $(shell python-config --includes)
Todd Fiala9bb71b72014-02-26 07:39:20 +000024
25# Include all archives in the shared lib
26USEDLIBS :=
27
28include $(LLDB_LEVEL)/../../Makefile.config
29
30LINK_COMPONENTS :=
31
32include $(LEVEL)/Makefile.common
33
34# include python headers
Sylvestre Ledru743e2b22014-02-26 15:05:48 +000035CPP.Flags += $(PYTHON_INC_DIR)
Todd Fiala9bb71b72014-02-26 07:39:20 +000036
37ifeq ($(HOST_OS),Darwin)
38 LLVMLibsOptions += -Wl,-all_load
39 # set dylib internal version number to llvmCore submission number
40 ifdef LLDB_SUBMIT_VERSION
41 LLVMLibsOptions += -Wl,-current_version \
42 -Wl,$(LLDB_SUBMIT_VERSION).$(LLDB_SUBMIT_SUBVERSION) \
43 -Wl,-compatibility_version -Wl,1
44 endif
45 # extra options to override libtool defaults
46 LVMLibsOptions += -F/System/Library/Frameworks -F/System/Library/PrivateFrameworks
47 LLVMLibsOptions += -framework Foundation -framework CoreFoundation
48 LLVMLibsOptions += -framework CoreServices -framework Carbon -framework Security
49 LLVMLibsOptions += -framework DebugSymbols $(PYTHON_BUILD_FLAGS) -lobjc
50 # Mac OS X 10.4 and earlier tools do not allow a second -install_name on command line
51 DARWIN_VERS := $(shell echo $(TARGET_TRIPLE) | sed 's/.*darwin\([0-9]*\).*/\1/')
52 ifneq ($(DARWIN_VERS),8)
53 LLVMLibsOptions += -Wl,-install_name \
54 -Wl,"@executable_path/../lib/$(LIBRARYNAME)$(SHLIBEXT)"
55 endif
56endif
57
58ifeq ($(HOST_OS), $(filter $(HOST_OS), Linux GNU GNU/kFreeBSD))
59 # Include everything from the .a's into the shared library.
60 ProjLibsOptions := -Wl,--whole-archive $(ProjLibsOptions) \
61 -Wl,--no-whole-archive
62 # Link in libedit
63 # LLVMLibsOptions += -ledit
64 LLVMLibsOptions += -Wl,--soname,$(LIBRARYNAME)$(SHLIBEXT)
65endif
66
67ifeq ($(HOST_OS),FreeBSD)
68 # Include everything from the .a's into the shared library.
69 ProjLibsOptions := -Wl,--whole-archive $(ProjLibsOptions) \
70 -Wl,--no-whole-archive
71 # Allow unresolved symbols.
72 LLVMLibsOptions += -Wl,--allow-shlib-undefined
73 # Link in libedit
74 # LLVMLibsOptions += -L/usr/local/lib -ledit
75endif
76
77# FIXME: dynamically construct the version from `python -V`
78PYTHON_VERSION:=2.7
79LLDB_PYTHON_MODULE_REL_DIR:=python$(PYTHON_VERSION)/site-packages
80LLDB_PYTHON_MODULE_DIR:=$(LibDir)/$(LLDB_PYTHON_MODULE_REL_DIR)
81
82# Target to move readline module from shared lib build location to
83# local python module directory.
84all-local:: $(LLDB_PYTHON_MODULE_DIR)/$(LIBRARYNAME)$(SHLIBEXT)
85
86$(LLDB_PYTHON_MODULE_DIR)/$(LIBRARYNAME)$(SHLIBEXT): $(SharedLibDir)/$(LIBRARYNAME)$(SHLIBEXT)
87 $(Echo) Staging $(BuildMode) $(LIBRARYNAME)$(SHLIBEXT) to $(LLDB_PYTHON_MODULE_DIR)
88 $(Verb) $(MKDIR) "$(LLDB_PYTHON_MODULE_DIR)"
89 $(Verb) $(ProgInstall) $(SharedLibDir)/$(LIBRARYNAME)$(SHLIBEXT) $(LLDB_PYTHON_MODULE_DIR)
90
91# Target to move the shared library from the build python lib dir to
92# the install python lib dir.
93install-local:: $(LLDB_PYTHON_MODULE_DIR)/$(LIBRARYNAME)$(SHLIBEXT)
94 $(Echo) Installing $(BuildMode) $(LLDB_PYTHON_MODULE_DIR)/$(LIBRARYNAME)$(SHLIBEXT) to $(DESTDIR)$(prefix)/lib/$(LLDB_PYTHON_MODULE_REL_DIR)
95 $(Verb) $(MKDIR) "$(DESTDIR)$(prefix)/lib/$(LLDB_PYTHON_MODULE_REL_DIR)"
96 $(Verb) $(ProgInstall) "$(LLDB_PYTHON_MODULE_DIR)/$(LIBRARYNAME)$(SHLIBEXT)" "$(DESTDIR)$(prefix)/lib/$(LLDB_PYTHON_MODULE_REL_DIR)"
97 $(Verb) $(RM) "$(DESTDIR)$(prefix)/lib/$(LIBRARYNAME)$(SHLIBEXT)"
98
99endif # if !defined(LLDB_DISABLE_PYTHON)