Skip to content

Commit

Permalink
buildsys: stop using libtool
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Jan 17, 2024
1 parent e0cc1f8 commit e6b341f
Show file tree
Hide file tree
Showing 16 changed files with 132 additions and 20,660 deletions.
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
/configure
/confdefs.h
/conftest*
/libtool
/libgap.pc
/src/config.h.in
/src/config.h.in~
Expand All @@ -28,6 +27,9 @@
/gap
/sysinfo.gap
/sysinfo.gap-*
/libgap*.dylib*
/libgap*.dll*
/libgap*.so*

/bin/gap*.sh
/bin/*-*/
Expand Down Expand Up @@ -89,9 +91,6 @@ doc/gapmacrodoc.idx
/builds/
/coverage/

/libgap.la
.libs/

/tst/testlibgap/api
/tst/testlibgap/basic
/tst/testlibgap/wscreate
Expand Down
7 changes: 0 additions & 7 deletions GNUmakefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ MAINTAINER_MODE = @MAINTAINER_MODE@
GAP_VERSION = @GAP_VERSION@
GAP_RELEASEDAY = @GAP_RELEASEDAY@

# libtool library version
GAP_LIBTOOL_CURRENT = @GAP_LIBTOOL_CURRENT@
GAP_LIBTOOL_AGE = @GAP_LIBTOOL_AGE@

# GAP kernel version
GAP_KERNEL_MINOR_VERSION = @gap_kernel_minor_version@
GAP_KERNEL_MAJOR_VERSION = @gap_kernel_major_version@
Expand Down Expand Up @@ -107,9 +103,6 @@ MKDIR_P = @MKDIR_P@
SED = @SED@
SHELL = @SHELL@

# for GNU libtool
LIBTOOL = @LIBTOOL@

# misc
EXEEXT = @EXEEXT@

Expand Down
2 changes: 1 addition & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ slowing down the compilation process, or omit certain features):

On Ubuntu or Debian, you can install these with the following command:

sudo apt-get install build-essential autoconf libtool libgmp-dev libreadline-dev zlib1g-dev
sudo apt-get install build-essential autoconf libgmp-dev libreadline-dev zlib1g-dev

On macOS, please follow the instructions in section "GAP for macOS" below.

Expand Down
131 changes: 85 additions & 46 deletions Makefile.rules
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
########################################################################
# Default rule: build gap
########################################################################
all: gap$(EXEEXT) gac libgap.la CITATION doc/versiondata build/gap
all: gap$(EXEEXT) gac libgap CITATION doc/versiondata build/gap
.PHONY: all

# Backwards compatibility: add "default" target as alias for "all"
Expand Down Expand Up @@ -323,10 +323,10 @@ SYSINFO_GAC = $(abs_builddir)/gac

# OBJS shall contain the names of all object files that constitute GAP.
# So turn all FOO/bar.c and FOO/bar.cc file names in SOURCES into
# build/obj/FOO/bar.c.lo resp. build/obj/FOO/bar.cc.lo
OBJS = $(patsubst %,build/obj/%.lo,$(SOURCES))
# build/obj/FOO/bar.c.o resp. build/obj/FOO/bar.cc.o
OBJS = $(patsubst %,build/obj/%.o,$(SOURCES))

OBJS_NOCOMP = $(patsubst %,build/obj/%.lo,$(SOURCES_NOCOMP))
OBJS_NOCOMP = $(patsubst %,build/obj/%.o,$(SOURCES_NOCOMP))

########################################################################
# Quiet rules.
Expand All @@ -341,7 +341,6 @@ QUIET_CXX = @echo " CXX $< => $(OBJFILE)";
QUIET_LINK = @echo " LINK $@";
QUIET_SED = @echo " SED $< => $@";
QUIET = @
LIBTOOL += --silent
endif
endif

Expand Down Expand Up @@ -370,13 +369,13 @@ DEPFILES = $(wildcard $(patsubst %,build/deps/%.d,$(SOURCES_ALL)))
# Include the dependency tracking files
-include $(DEPFILES)

# the name of the .d and .lo file generated by one of our compiler
# the name of the .d and .o file generated by one of our compiler
# rules; you may wonder why we don't just use $@ here: this is needed
# because our compile rules have two targets, the .lo and the .d file;
# because our compile rules have two targets, the .o and the .d file;
# and the value of $@ will be whichever of the two files triggered the
# compiler rule, so we cannot use it directly
DEPFILE = build/deps/$(*D)/$(<F).d
OBJFILE = build/obj/$(*D)/$(<F).lo
OBJFILE = build/obj/$(*D)/$(<F).o

# The following flags instruct the compiler to enable advanced
# dependency tracking. Supported by GCC 3 and newer; clang; Intel C
Expand All @@ -391,14 +390,14 @@ DEPFLAGS = -MQ $(OBJFILE) -MMD -MP -MF $(DEPFILE)
########################################################################
# Compiler rules
#
# Note that these rules have two targets, the .lo and the .d file; this
# Note that these rules have two targets, the .o and the .d file; this
# models their relationship accurately and allows us to deal with some
# corner cases, e.g. when switching branches after a file got renamed;
# unfortunately it also means we can't just use $@ here (see comments on
# DEPFILE and OBJFILE above)
########################################################################

obj_deps = libtool build/config.h build/version.h $(FFDATA_H)
obj_deps = build/config.h build/version.h $(FFDATA_H)


# Build rule for C++ source files
Expand All @@ -408,26 +407,64 @@ obj_deps = libtool build/config.h build/version.h $(FFDATA_H)
# careful to not put these into GAP_CXXFLAGS, as kernel extensions may want to
# use GAP_CXXFLAGS but also may need to interface with C++ code in
# libraries that use exceptions.
build/obj/%.cc.lo: %.cc cnf/GAP-CXXFLAGS cnf/GAP-CPPFLAGS $(obj_deps)
build/obj/%.cc.o: %.cc cnf/GAP-CXXFLAGS cnf/GAP-CPPFLAGS $(obj_deps)
@$(MKDIR_P) build/obj/$(*D) build/deps/$(*D)
$(QUIET_CXX)$(LIBTOOL) --mode=compile --tag CXX $(CXX) $(DEPFLAGS) $(GAP_CXXFLAGS) -fno-exceptions -fno-rtti $(WARN_CXXFLAGS) $(GAP_CPPFLAGS) -c $< -o $(OBJFILE)
$(QUIET_CXX)$(CXX) $(DEPFLAGS) $(GAP_CXXFLAGS) -fno-exceptions -fno-rtti $(WARN_CXXFLAGS) $(GAP_CPPFLAGS) -c $< -o $(OBJFILE)
@echo "$<:" >> $(DEPFILE)

# Build rule for C source files
build/obj/%.c.lo: %.c cnf/GAP-CFLAGS cnf/GAP-CPPFLAGS $(obj_deps)
build/obj/%.c.o: %.c cnf/GAP-CFLAGS cnf/GAP-CPPFLAGS $(obj_deps)
@$(MKDIR_P) build/obj/$(*D) build/deps/$(*D)
$(QUIET_CC)$(LIBTOOL) --mode=compile --tag CC $(CC) $(DEPFLAGS) $(GAP_CFLAGS) $(WARN_CFLAGS) $(GAP_CPPFLAGS) -c $< -o $(OBJFILE)
$(QUIET_CC)$(CC) $(DEPFLAGS) $(GAP_CFLAGS) $(WARN_CFLAGS) $(GAP_CPPFLAGS) -c $< -o $(OBJFILE)
@echo "$<:" >> $(DEPFILE)

########################################################################
# Linker rules for gap executable
########################################################################

LINK=$(LIBTOOL) --mode=link $(CC) -export-dynamic
LINK=$(CC)

SHLIB_MAJOR = $(GAP_KERNEL_MAJOR_VERSION)
ifeq ($(SYS_IS_CYGWIN32),yes)
SHLIB_EXT=.dll
LIBGAP_FULL = libgap$(SHLIB_EXT)

LINK_SHLIB_FLAGS = -shared -Wl,--enable-auto-image-base -Wl,--out-implib,libgap.dll.a
else ifneq (,$(findstring darwin,$(host_os)))
SHLIB_EXT=.dylib
LIBGAP_FULL = libgap.$(SHLIB_MAJOR)$(SHLIB_EXT)
LIBGAP_COMPAT_VER = $(shell expr $(GAP_KERNEL_MAJOR_VERSION) + 1 )
LIBGAP_CURRENT_VER = $(LIBGAP_COMPAT_VER).$(GAP_KERNEL_MINOR_VERSION)
LINK_SHLIB_FLAGS = -dynamiclib
LINK_SHLIB_FLAGS += -compatibility_version $(LIBGAP_COMPAT_VER)
LINK_SHLIB_FLAGS += -current_version $(LIBGAP_CURRENT_VER)
LINK_SHLIB_FLAGS += -Wl,-single_module

# TODO: set install_name, at least for installed version of the lib?
#LINK_SHLIB_FLAGS += -install_name $(libdir)/$(LIBGAP_FULL)

GAP_CPPFLAGS += -DPIC
GAP_CFLAGS += -fno-common
GAP_CXXFLAGS += -fno-common
else
# Note: the following was tested on Linux -- patches making this work better
# on e.g. FreeBSD/OpenBSD/... are highly welcome
SHLIB_EXT=.so
LIBGAP_FULL = libgap$(SHLIB_EXT).$(SHLIB_MAJOR)
LINK_SHLIB_FLAGS = -shared -fPIC -DPIC -Wl,-soname,$(LIBGAP_FULL)

GAP_CPPFLAGS += -DPIC
GAP_CFLAGS += -fPIC
GAP_CXXFLAGS += -fPIC
GAP_LDFLAGS += -Wl,--export-dynamic
endif

libgap: libgap$(SHLIB_EXT) $(LIBGAP_FULL)
.PHONY: libgap

# Linking rule and dependencies for libgap
libgap.la: $(OBJS) cnf/GAP-LDFLAGS cnf/GAP-LIBS cnf/GAP-OBJS
$(QUIET_LINK)$(LINK) -no-undefined -version-info $(GAP_LIBTOOL_CURRENT):0:$(GAP_LIBTOOL_AGE) -rpath $(libdir) $(GAP_LDFLAGS) $(OBJS) $(GAP_LIBS) -o $@
$(LIBGAP_FULL): $(OBJS) cnf/GAP-LDFLAGS cnf/GAP-LIBS cnf/GAP-OBJS
$(QUIET_LINK)$(LINK) -o $@ $(LINK_SHLIB_FLAGS) $(GAP_LDFLAGS) $(OBJS) $(GAP_LIBS)

ifeq ($(SYS_IS_CYGWIN32),yes)

Expand All @@ -454,33 +491,39 @@ GAP_LDFLAGS += -Wl,--allow-multiple-definition
# loads that DLL and calls the renamed main function.
all: bin/$(GAPARCH)/gap.dll

bin/$(GAPARCH)/gap.dll: libgap.la
# FIXME: HACK to support kernel extensions; this is necessary
# because we don't use `libtool --mode=install` and so we have to
# work with the libtool wrappers for shared libraries meant for
# using during development, not for what we actually use them for.
# See also `LTINSTALL` and `install-libgap`.
bin/$(GAPARCH)/gap.dll: libgap.dll
@$(MKDIR_P) bin/$(GAPARCH)
cp .libs/cyggap-*.dll $@
cp $< $@

gap$(EXEEXT): libgap.la cnf/GAP-LDFLAGS cnf/GAP-LIBS cnf/GAP-OBJS build/obj/src/main.c.lo
$(QUIET_LINK)$(LINK) $(GAP_LDFLAGS) build/obj/src/main.c.lo $(GAP_LIBS) libgap.la -o $@
# build rule for the main gap executable
gap$(EXEEXT): libgap.dll cnf/GAP-LDFLAGS cnf/GAP-LIBS cnf/GAP-OBJS build/obj/src/main.c.o
$(QUIET_LINK)$(LINK) $(GAP_LDFLAGS) -Wl,--export-all-symbols build/obj/src/main.c.o $(GAP_LIBS) -L${abs_builddir} -lgap -o $@
@( if which peflags > /dev/null ; then peflags --cygwin-heap=2048 gap$(EXEEXT) ; fi )

else

# create a symlink libgap.so -> libgap.so.9 resp. libgap.dylib -> libgap.9.dylib
libgap$(SHLIB_EXT): $(LIBGAP_FULL)
@rm -f $@
ln -sf $< $@

# build rule for the main gap executable
gap$(EXEEXT): $(OBJS) cnf/GAP-LDFLAGS cnf/GAP-LIBS cnf/GAP-OBJS build/obj/src/main.c.lo
$(QUIET_LINK)$(LINK) $(GAP_LDFLAGS) build/obj/src/main.c.lo $(GAP_LIBS) $(OBJS) -o $@
gap$(EXEEXT): $(OBJS) cnf/GAP-LDFLAGS cnf/GAP-LIBS cnf/GAP-OBJS build/obj/src/main.c.o
$(QUIET_LINK)$(LINK) $(GAP_LDFLAGS) build/obj/src/main.c.o $(OBJS) $(GAP_LIBS) -o $@

# generate a modified copy of main.c for use by the `gap-install` binary
build/main.c: src/main.c
@echo "#define SYS_DEFAULT_PATHS \"$(libdir)/gap;$(datarootdir)/gap\"" > $@
@cat $< >> $@

# build rule for the gap executable used by the `install-bin` target
build/gap-install: libgap.la cnf/GAP-LDFLAGS cnf/GAP-LIBS cnf/GAP-OBJS build/obj/build/main.c.lo
$(QUIET_LINK)$(LINK) $(GAP_LDFLAGS) build/obj/build/main.c.lo $(GAP_LIBS) libgap.la -o $@
#
# we add the -Wl,-rpath,$(libdir) to make it work on Linux when installed in a
# non-system prefix (as we do for our tests), where $(libdir) is not in one of
# the default linker search directories. An alternative might be to set
# LD_LIBRARY_PATH during our tests...
build/gap-install: libgap$(SHLIB_EXT) cnf/GAP-LDFLAGS cnf/GAP-LIBS cnf/GAP-OBJS build/obj/build/main.c.o
$(QUIET_LINK)$(LINK) $(GAP_LDFLAGS) build/obj/build/main.c.o $(GAP_LIBS) -Wl,-rpath,$(libdir) -L${abs_builddir} -lgap -o $@

endif

Expand Down Expand Up @@ -525,7 +568,7 @@ etags:
########################################################################
distclean: clean
rm -rf autom4te.cache
rm -f config.log config.status libtool GNUmakefile
rm -f config.log config.status GNUmakefile
rm -f doc/make_doc
rm -f doc/*/*.aux doc/*/*.bbl doc/*/*.blg doc/*/*.brf doc/*/*.idx doc/*/*.ilg doc/*/*.ind doc/*/*.log doc/*/*.out doc/*/*.pnr doc/*/*.tex doc/*/*.toc
rm -rf dev/log
Expand All @@ -538,7 +581,7 @@ clean:
rm -rf extern/build extern/install
rm -f bin/gap.sh sysinfo.gap*
rm -f gap$(EXEEXT) gac ffgen
rm -f libgap.la
rm -f libgap$(SHLIB_EXT)
rm -f libgap.pc
rm -rf .libs
rm -f doc/wsp.g
Expand Down Expand Up @@ -566,8 +609,6 @@ clean:
#
########################################################################

LTINSTALL=$(LIBTOOL) --mode=install $(INSTALL)

install: install-bin install-doc install-gaproot install-sysinfo install-headers install-libgap
@echo "+--------------------------------------------------------------------------+"
@echo "| WARNING, 'make install' support is still experimental, and may be buggy. |"
Expand All @@ -580,10 +621,10 @@ install: install-bin install-doc install-gaproot install-sysinfo install-headers
install-bin: build/gap-install
# install a special build of gap with SYS_DEFAULT_PATHS set suitably
$(INSTALL) -d -m 0755 $(DESTDIR)$(bindir)
$(LTINSTALL) build/gap-install $(DESTDIR)$(bindir)/gap
$(INSTALL) -m 0755 build/gap-install $(DESTDIR)$(bindir)/gap
# for backwards compatibility, also install it into $(libdir)/gap
$(INSTALL) -d -m 0755 $(DESTDIR)$(libdir)/gap
$(LTINSTALL) build/gap-install $(DESTDIR)$(libdir)/gap/gap
$(INSTALL) -m 0755 build/gap-install $(DESTDIR)$(libdir)/gap/gap
# install gac
sed -e "s;@SYSINFO_GAPROOT@;$(libdir)/gap;" < $(srcdir)/cnf/gac.in > $(DESTDIR)$(bindir)/gac
chmod 0755 $(DESTDIR)$(bindir)/gac
Expand Down Expand Up @@ -649,9 +690,10 @@ install-headers: $(FFDATA_H) build/version.h
$(INSTALL) -d -m 0755 $(DESTDIR)$(includedir)/gap/hpc
$(INSTALL) -m 0644 $(srcdir)/src/hpc/*.h $(DESTDIR)$(includedir)/gap/hpc

install-libgap: libgap.la libgap.pc
install-libgap: $(LIBGAP_FULL) libgap.pc
$(INSTALL) -d -m 0755 $(DESTDIR)$(libdir)
$(LTINSTALL) libgap.la $(DESTDIR)$(libdir)
$(INSTALL) -m 0644 $(LIBGAP_FULL) $(DESTDIR)$(libdir)
ln -sf $(LIBGAP_FULL) $(DESTDIR)$(libdir)/libgap$(SHLIB_EXT)
$(INSTALL) -d -m 0755 $(DESTDIR)$(libdir)/pkgconfig
$(INSTALL) -m 0644 libgap.pc $(DESTDIR)$(libdir)/pkgconfig

Expand Down Expand Up @@ -957,8 +999,8 @@ citests: all
LIBGAPTESTS := $(addprefix tst/testlibgap/,basic api wscreate wsload trycatch)

# run a test in tst/testlibgap
tst/testlibgap/%: build/obj/tst/testlibgap/%.c.lo build/obj/tst/testlibgap/common.c.lo libgap.la
$(QUIET_LINK)$(LINK) $(GAP_LDFLAGS) $^ $(GAP_LIBS) -o $@
tst/testlibgap/%: build/obj/tst/testlibgap/%.c.o build/obj/tst/testlibgap/common.c.o libgap$(SHLIB_EXT)
$(QUIET_LINK)$(LINK) $(GAP_LDFLAGS) -Wl,-rpath,$(abs_builddir) $^ $(GAP_LIBS) -o $@

clean: clean-testlibgap
clean-testlibgap:
Expand Down Expand Up @@ -988,16 +1030,16 @@ testpkgconfigbuild: install-libgap install-headers
$(eval com := "tst/testlibgap/common")
$(CC) -c $(v).c -o $(v).o $(PKG_REPORTED_CFLAGS)
$(CC) -c $(com).c -o $(com).o $(PKG_REPORTED_CFLAGS)
$(QUIET_LINK)$(LINK) $(v).o -o $(v) $(com).o $(PKG_REPORTED_LDFLAGS)
$(QUIET_LINK)$(LINK) $(v).o -o $(v) $(com).o $(PKG_REPORTED_LDFLAGS) -Wl,-rpath,$(abs_builddir)
$(v) -A -l $(top_srcdir) -q -T --nointeract >$(v).out && \
diff $(top_srcdir)/$(v).expect $(v).out


KERNELTESTS := $(addprefix tst/testkernel/,dstruct)

# run a test in tst/testkernel
tst/testkernel/%: build/obj/tst/testkernel/%.c.lo libgap.la
$(QUIET_LINK)$(LINK) $(GAP_LDFLAGS) $^ $(GAP_LIBS) -o $@
tst/testkernel/%: build/obj/tst/testkernel/%.c.o libgap$(SHLIB_EXT)
$(QUIET_LINK)$(LINK) $(GAP_LDFLAGS) -Wl,-rpath,$(abs_builddir) $^ $(GAP_LIBS) -o $@

clean: clean-testkernel
clean-testkernel:
Expand Down Expand Up @@ -1235,9 +1277,6 @@ gac: $(srcdir)/cnf/gac.in
GNUmakefile: $(srcdir)/GNUmakefile.in config.status
$(SHELL) ./config.status $@

libtool: config.status
@$(SHELL) ./config.status $@

build/gap:
@mkdir -p $(@D) && ln -sf $(abs_srcdir)/src build/gap

Expand Down
6 changes: 1 addition & 5 deletions README.buildsys.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ can follow the standard procedure:
== Overview of the files constituting the GAP build system

* `autogen.sh`: sets up the build system; typically the first thing to run in
a fresh clone of the GAP repository. It runs `autoreconf` which in turn runs
several tools include `aclocal`, `autoheader`, `autoconf`, `libtoolize`
a fresh clone of the GAP repository. It runs `autoconf` and `autoheader`.

* `configure`: generated by `autogen.sh` from `configure.ac`.

Expand Down Expand Up @@ -69,9 +68,6 @@ can follow the standard procedure:
and which are used to track dependencies, e.g. of C source files on header
files.

- `.libs/` directories are created by libtool. Please refer to the libtool
documentation for details.


## Out-of-tree builds

Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ least these:
* a C++ compiler
* GNU Make
* GNU Autoconf
* GNU Libtool

In addition, we recommend that you install at least the following optional
dependencies (if you do not, GAP will either build its own copies of these,
Expand All @@ -66,13 +65,13 @@ slowing down the compilation process, or omit certain features):

On Ubuntu or Debian, you can install these with the following command:

sudo apt-get install build-essential autoconf libtool libgmp-dev libreadline-dev zlib1g-dev
sudo apt-get install build-essential autoconf libgmp-dev libreadline-dev zlib1g-dev

On macOS, you can install the dependencies in several ways:

* using Homebrew: `brew install autoconf libtool gmp readline`
* using Fink: `fink install autoconf2.6 libtool2 gmp5 readline7`
* using MacPorts: `port install autoconf libtool gmp readline`
* using Homebrew: `brew install autoconf gmp readline`
* using Fink: `fink install autoconf2.6 gmp5 readline7`
* using MacPorts: `port install autoconf gmp readline`

On other operating systems, you will need to figure out equivalent commands
to install the required dependencies.
Expand Down
5 changes: 0 additions & 5 deletions aclocal.m4
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,3 @@ m4_include([cnf/m4/ax_gcc_func_attribute.m4])
m4_include([cnf/m4/ax_pthread.m4])
m4_include([cnf/m4/ax_require_defined.m4])
m4_include([cnf/m4/gap.m4])
m4_include([cnf/m4/libtool.m4])
m4_include([cnf/m4/ltoptions.m4])
m4_include([cnf/m4/ltsugar.m4])
m4_include([cnf/m4/ltversion.m4])
m4_include([cnf/m4/lt~obsolete.m4])
Loading

0 comments on commit e6b341f

Please sign in to comment.