1 # Makefile for libm2min.
2 # Copyright 2013-2022 Free Software Foundation, Inc.
4 # This file is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; see the file COPYING3. If not see
16 # <http://www.gnu.org/licenses/>.
18 SUFFIXES = .c .mod .def .o .obj .lo .a .la
20 ACLOCAL_AMFLAGS = -I .. -I ../config
22 VPATH = . @srcdir@/../../gcc/m2/gm2-libs-min
27 gcc_version := $(shell @get_gcc_base_ver@ $(top_srcdir)/../gcc/BASE-VER)
29 # Directory in which the compiler finds libraries etc.
30 libsubdir = $(libdir)/gcc/$(target_alias)/$(gcc_version)
31 # Used to install the shared libgcc.
34 toolexeclibdir=@toolexeclibdir@
35 toolexecdir=@toolexecdir@
36 GM2_FOR_TARGET=@GM2_FOR_TARGET@
38 MULTIDIR := $(shell $(CC) $(CFLAGS) -print-multi-directory)
39 MULTIOSDIR := $(shell $(CC) $(CFLAGS) -print-multi-os-directory)
41 MULTIOSSUBDIR := $(shell if test x$(MULTIOSDIR) != x.; then echo /$(MULTIOSDIR); fi)
42 inst_libdir = $(libsubdir)$(MULTISUBDIR)
43 inst_slibdir = $(slibdir)$(MULTIOSSUBDIR)
46 # Work around what appears to be a GNU make bug handling MAKEFLAGS
47 # values defined in terms of make variables, as is the case for CC and
48 # friends when we are called from the top level Makefile.
50 "GCC_DIR=$(GCC_DIR)" \
51 "GM2_SRC=$(GM2_SRC)" \
52 "AR_FLAGS=$(AR_FLAGS)" \
53 "CC_FOR_BUILD=$(CC_FOR_BUILD)" \
54 "CC_FOR_TARGET=$(CC_FOR_TARGET)" \
55 "GM2_FOR_TARGET=$(GM2_FOR_TARGET)" \
57 "CXXFLAGS=$(CXXFLAGS)" \
58 "CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)" \
59 "CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)" \
60 "INSTALL=$(INSTALL)" \
61 "INSTALL_DATA=$(INSTALL_DATA)" \
62 "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
63 "INSTALL_SCRIPT=$(INSTALL_SCRIPT)" \
64 "LDFLAGS=$(LDFLAGS)" \
65 "LIBCFLAGS=$(LIBCFLAGS)" \
66 "LIBCFLAGS_FOR_TARGET=$(LIBCFLAGS_FOR_TARGET)" \
68 "MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" \
69 "MULTISUBDIR=$(MULTISUBDIR)" \
70 "MULTIOSDIR=$(MULTIOSDIR)" \
71 "MULTIBUILDTOP=$(MULTIBUILDTOP)" \
72 "MULTIFLAGS=$(MULTIFLAGS)" \
73 "PICFLAG=$(PICFLAG)" \
74 "PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)" \
76 "RUNTESTFLAGS=$(RUNTESTFLAGS)" \
77 "exec_prefix=$(exec_prefix)" \
78 "infodir=$(infodir)" \
80 "includedir=$(includedir)" \
82 "tooldir=$(tooldir)" \
88 "NM_FOR_BUILD=$(NM_FOR_BUILD)" \
89 "NM_FOR_TARGET=$(NM_FOR_TARGET)" \
90 "DESTDIR=$(DESTDIR)" \
92 "TARGET_LONGDOUBLE_ABI=$(TARGET_LONGDOUBLE_ABI)" \
93 "TARGET_LIB_PATH_libgm2=$(TARGET_LIB_PATH_libgm2)"
95 # Subdir rules rely on $(FLAGS_TO_PASS)
96 FLAGS_TO_PASS = $(AM_MAKEFLAGS)
98 M2DEFS = libc.def M2RTS.def \
101 M2MODS = M2RTS.mod SYSTEM.mod
103 libm2mindir = libm2min
104 toolexeclib_LTLIBRARIES = libm2min.la
105 libm2min_la_SOURCES = $(M2MODS) libc.c
106 libm2min_la_DEPENDENCIES = SYSTEM.def $(addsuffix .lo, $(basename $(libm2min_la_SOURCES)))
107 libm2min_la_CFLAGS = -I. -I$(GM2_SRC)/gm2-libs-min -I$(GM2_SRC)/gm2-libs $(TARGET_LONGDOUBLE_ABI)
108 libm2min_la_M2FLAGS = \
109 -fm2-pathname=m2min -I. -I$(GM2_SRC)/gm2-libs-min \
110 -fm2-pathname=m2pim -I$(GM2_SRC)/gm2-libs -fno-exceptions \
111 -fno-m2-plugin -fno-scaffold-dynamic -fno-scaffold-main -fm2-prefix=m2min \
112 $(TARGET_LONGDOUBLE_ABI)
114 libm2min_la_link_flags = -Wl,-undefined,dynamic_lookup
116 libm2min_la_link_flags =
118 if ENABLE_DARWIN_AT_RPATH
119 libm2min_la_link_flags += -nodefaultrpaths -Wl,-rpath,@loader_path/
121 libm2min_la_LINK = $(LINK) -version-info $(libtool_VERSION) $(libm2min_la_link_flags)
122 BUILT_SOURCES = SYSTEM.def
123 CLEANFILES = SYSTEM.def
125 M2LIBDIR = /m2/m2min/
128 $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile \
129 $(GM2_FOR_TARGET) -c \
130 $(CFLAGS_FOR_TARGET) $(LIBCFLAGS) $(libm2min_la_M2FLAGS) $< -o $@
132 libc.o: $(GM2_SRC)/gm2-libs-min/libc.c
136 echo "CC = $(CC_FOR_BUILD) CC_FOR_TARGET = $(CC_FOR_TARGET) GM2 = $(GM2) GM2_FOR_TARGET = $(GM2_FOR_TARGET) GM2_FOR_BUILD = $(GM2_FOR_BUILD)"
137 bash $(GM2_SRC)/tools-src/makeSystem -fpim \
138 $(GM2_SRC)/gm2-libs-min/SYSTEM.def \
139 $(GM2_SRC)/gm2-libs-min/SYSTEM.mod \
140 -I$(GM2_SRC)/gm2-libs-min -I$(GM2_SRC)/gm2-libs \
141 "$(GM2_FOR_TARGET) -fno-exceptions" $@
143 install-data-local: force
144 mkdir -p $(DESTDIR)$(inst_libdir)/$(M2LIBDIR)
145 for i in $(M2DEFS) $(M2MODS) ; do \
146 if [ -f $$i ] ; then \
147 $(INSTALL_DATA) $$i '$(DESTDIR)$(inst_libdir)/$(M2LIBDIR)'; \
148 elif [ -f @srcdir@/../../gcc/m2/gm2-libs-min/$$i ] ; then \
149 $(INSTALL_DATA) @srcdir@/../../gcc/m2/gm2-libs-min/$$i '$(DESTDIR)$(inst_libdir)/$(M2LIBDIR)'; \
151 echo "cannot find $$i" ; exit 1 ; \
153 chmod 644 $(DESTDIR)$(inst_libdir)/$(M2LIBDIR)$$i ; \