1# Copyright (C) 2010-2012 Free Software Foundation, Inc.
2
3# Makefile for building a staged copy of the data-directory.
4# This file is part of GDB.
5
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19srcdir = @srcdir@
20SYSCALLS_SRCDIR = $(srcdir)/../syscalls
21PYTHON_SRCDIR = $(srcdir)/../python/lib
22VPATH = $(srcdir):$(SYSCALLS_SRCDIR):$(PYTHON_SRCDIR)
23
24top_srcdir = @top_srcdir@
25top_builddir = @top_builddir@
26
27prefix = @prefix@
28exec_prefix = @exec_prefix@
29
30datarootdir = @datarootdir@
31datadir = @datadir@
32
33SHELL = @SHELL@
34
35LN_S = @LN_S@
36
37INSTALL = @INSTALL@
38INSTALL_DATA = @INSTALL_DATA@
39INSTALL_DIR = $(SHELL) $(srcdir)/../../mkinstalldirs
40
41GDB_DATADIR = @GDB_DATADIR@
42
43SYSCALLS_DIR = syscalls
44SYSCALLS_INSTALL_DIR = $(DESTDIR)$(GDB_DATADIR)/$(SYSCALLS_DIR)
45SYSCALLS_FILES = \
46	gdb-syscalls.dtd \
47	ppc-linux.xml ppc64-linux.xml \
48	i386-linux.xml amd64-linux.xml \
49	sparc-linux.xml sparc64-linux.xml \
50	mips-o32-linux.xml mips-n32-linux.xml mips-n64-linux.xml
51
52PYTHON_DIR = python
53PYTHON_INSTALL_DIR = $(DESTDIR)$(GDB_DATADIR)/$(PYTHON_DIR)
54PYTHON_FILES = \
55	gdb/__init__.py \
56	gdb/types.py \
57	gdb/printing.py \
58	gdb/prompt.py \
59	gdb/command/__init__.py \
60	gdb/command/pretty_printers.py \
61	gdb/command/prompt.py
62
63FLAGS_TO_PASS = \
64	"prefix=$(prefix)" \
65	"exec_prefix=$(exec_prefix)" \
66	"infodir=$(infodir)" \
67	"datarootdir=$(datarootdir)" \
68	"docdir=$(docdir)" \
69	"htmldir=$(htmldir)" \
70	"pdfdir=$(pdfdir)" \
71	"libdir=$(libdir)" \
72	"mandir=$(mandir)" \
73	"datadir=$(datadir)" \
74	"includedir=$(includedir)" \
75	"against=$(against)" \
76	"DESTDIR=$(DESTDIR)" \
77	"AR=$(AR)" \
78	"AR_FLAGS=$(AR_FLAGS)" \
79	"CC=$(CC)" \
80	"CFLAGS=$(CFLAGS)" \
81	"CXX=$(CXX)" \
82	"CXXFLAGS=$(CXXFLAGS)" \
83	"DLLTOOL=$(DLLTOOL)" \
84	"LDFLAGS=$(LDFLAGS)" \
85	"RANLIB=$(RANLIB)" \
86	"MAKEINFO=$(MAKEINFO)" \
87	"MAKEHTML=$(MAKEHTML)" \
88	"MAKEHTMLFLAGS=$(MAKEHTMLFLAGS)" \
89	"INSTALL=$(INSTALL)" \
90	"INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
91	"INSTALL_DATA=$(INSTALL_DATA)" \
92	"RUNTEST=$(RUNTEST)" \
93	"RUNTESTFLAGS=$(RUNTESTFLAGS)"
94
95.PHONY: all
96all: stamp-syscalls stamp-python
97
98# For portability's sake, we need to handle systems that don't have
99# symbolic links.
100stamp-syscalls: Makefile $(SYSCALLS_FILES)
101	rm -rf ./$(SYSCALLS_DIR)
102	mkdir ./$(SYSCALLS_DIR)
103	files='$(SYSCALLS_FILES)' ; \
104	for file in $$files ; do \
105	  f=$(SYSCALLS_SRCDIR)/$$file ; \
106	  if test -f $$f ; then \
107	    $(INSTALL_DATA) $$f ./$(SYSCALLS_DIR) ; \
108	  fi ; \
109	done
110	touch $@
111
112.PHONY: clean-syscalls
113clean-syscalls:
114	rm -rf $(SYSCALLS_DIR)
115	rm -f stamp-syscalls
116
117# This target is responsible for properly installing the syscalls'
118# XML files in the system.
119.PHONY: install-syscalls
120install-syscalls:
121	$(INSTALL_DIR) $(SYSCALLS_INSTALL_DIR)
122	files='$(SYSCALLS_FILES)' ; \
123	for file in $$files; do \
124	  f=$(SYSCALLS_SRCDIR)/$$file ; \
125	  if test -f $$f ; then \
126	    $(INSTALL_DATA) $$f $(SYSCALLS_INSTALL_DIR) ; \
127	  fi ; \
128	done
129
130.PHONY: uninstall-syscalls
131uninstall-syscalls:
132	files='$(SYSCALLS_FILES)' ; \
133	for file in $$files ; do \
134	  slashdir=`echo "/$$file" | sed 's,/[^/]*$$,,'` ; \
135	  rm -f $(SYSCALLS_INSTALL_DIR)/$$file ; \
136	  while test "x$$file" != "x$$slashdir" ; do \
137	    rmdir 2>/dev/null "$(SYSCALLS_INSTALL_DIR)$$slashdir" ; \
138	    file="$$slashdir" ; \
139	    slashdir=`echo "$$file" | sed 's,/[^/]*$$,,'` ; \
140	  done \
141	done
142
143stamp-python: Makefile $(PYTHON_FILES)
144	rm -rf ./$(PYTHON_DIR)
145	files='$(PYTHON_FILES)' ; \
146	for file in $$files ; do \
147	  dir=`echo "$$file" | sed 's,/[^/]*$$,,'` ; \
148	  $(INSTALL_DIR) ./$(PYTHON_DIR)/$$dir ; \
149	  $(INSTALL_DATA) $(PYTHON_SRCDIR)/$$file ./$(PYTHON_DIR)/$$dir ; \
150	done
151	touch $@
152
153.PHONY: clean-python
154clean-python:
155	rm -rf $(PYTHON_DIR)
156	rm -f stamp-python
157
158.PHONY: install-python
159install-python:
160	files='$(PYTHON_FILES)' ; \
161	for file in $$files ; do \
162	  dir=`echo "$$file" | sed 's,/[^/]*$$,,'` ; \
163	  $(INSTALL_DIR) $(PYTHON_INSTALL_DIR)/$$dir ; \
164	  $(INSTALL_DATA) ./$(PYTHON_DIR)/$$file $(PYTHON_INSTALL_DIR)/$$dir ; \
165	done
166
167.PHONY: uninstall-python
168uninstall-python:
169	files='$(PYTHON_FILES)' ; \
170	for file in $$files ; do \
171	  slashdir=`echo "/$$file" | sed 's,/[^/]*$$,,'` ; \
172	  rm -f $(PYTHON_INSTALL_DIR)/$$file ; \
173	  while test "x$$file" != "x$$slashdir" ; do \
174	    rmdir 2>/dev/null "$(PYTHON_INSTALL_DIR)$$slashdir" ; \
175	    file="$$slashdir" ; \
176	    slashdir=`echo "$$file" | sed 's,/[^/]*$$,,'` ; \
177	  done \
178	done
179
180# Traditionally "install" depends on "all".  But it may be useful
181# not to; for example, if the user has made some trivial change to a
182# source file and doesn't care about rebuilding or just wants to save the
183# time it takes for make to check that all is up to date.
184# install-only is intended to address that need.
185.PHONY: install
186install: all
187	@$(MAKE) $(FLAGS_TO_PASS) install-only
188
189.PHONY: install-only
190install-only: install-syscalls install-python
191
192.PHONY: uninstall
193uninstall: uninstall-syscalls uninstall-python
194
195.PHONY: clean
196clean: clean-syscalls clean-python
197
198.PHONY: maintainer-clean realclean distclean
199maintainer-clean realclean distclean: clean
200	rm -f Makefile
201
202.PHONY: check installcheck info dvi pdf html
203.PHONY: install-info install-pdf install-html clean-info
204check installcheck:
205info dvi pdf html:
206install-info install-pdf install-html:
207clean-info:
208
209# GNU Make has an annoying habit of putting *all* the Makefile variables
210# into the environment, unless you include this target as a circumvention.
211# Rumor is that this will be fixed (and this target can be removed)
212# in GNU Make 4.0.
213.NOEXPORT:
214
215# GNU Make 3.63 has a different problem: it keeps tacking command line
216# overrides onto the definition of $(MAKE).  This variable setting
217# will remove them.
218MAKEOVERRIDES=
219
220Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
221	cd $(top_builddir) && $(MAKE) data-directory/Makefile
222