Skip to content

Commit

Permalink
buildsys: add make install
Browse files Browse the repository at this point in the history
Also remove GAP_LIBTOOL_CURRENT and GAP_LIBTOOL_AGE from sysinfo.gap again.
  • Loading branch information
fingolfin committed Oct 31, 2021
1 parent 3b03258 commit 92a4aca
Showing 1 changed file with 95 additions and 40 deletions.
135 changes: 95 additions & 40 deletions Makefile.rules
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ all: gap$(EXEEXT) gac libgap.la CITATION doc/versiondata
default: all
.PHONY: default

# GAP_BIN_DIR is either the directory in which GAP is built (if GAP is
# not yet installed), or for an installed version of GAP the directory
# containing `sysinfo.gap`
GAP_BIN_DIR = $(abs_builddir)

# TODO/FIXME: document this
GAP_LIB_DIR = $(abs_srcdir)

########################################################################
# Source files
Expand Down Expand Up @@ -155,46 +162,49 @@ SOURCES_ALL += src/compstat_empty.c
# contain warning flags, and uses absolute include paths.
########################################################################

GAP_COMMON_CPPFLAGS =

GAP_CPPFLAGS =
GAP_PKG_CPPFLAGS =
GAP_INSTALL_CPPFLAGS =

# First add include paths

# The "build/" directory contains generated header files and thus is
# placed into the list of include directories.
# When GAP is installed, this is merged into the $includedir
GAP_CPPFLAGS += -I$(builddir)/build
GAP_PKG_CPPFLAGS += -I$(abs_builddir)/build

# The other source files are relative to the srcdir
GAP_CPPFLAGS += -I$(srcdir)/src
GAP_PKG_CPPFLAGS += -I$(abs_srcdir)/src
GAP_INSTALL_CPPFLAGS += -I${includedir}/gap

# For backwards compatibility with certain packages and their kernel
# extensions, also add the root of the srcdir to the package CPPFLAGS
GAP_PKG_CPPFLAGS += -I$(abs_srcdir)
# extensions, also add the root of the srcdir to the package CPPFLAGS. When
# GAP is installed, this is instead achieved by a symlink named `src` inside
# ${includedir}/gap which points pack to its parent.
GAP_PKG_CPPFLAGS += -I$(GAP_LIB_DIR)

# Add GAP_DEFINES (from autoconf, contains -D flags)
GAP_CPPFLAGS += $(GAP_DEFINES)
GAP_PKG_CPPFLAGS += $(GAP_DEFINES)
# Add GAP_DEFINES (from autoconf, contains -D flags) to common flags
GAP_COMMON_CPPFLAGS += $(GAP_DEFINES)

# Add flags for dependencies
GAP_CPPFLAGS += $(GMP_CPPFLAGS)
GAP_CPPFLAGS += $(ZLIB_CPPFLAGS)
GAP_CPPFLAGS += $(READLINE_CPPFLAGS)
GAP_CPPFLAGS += $(JULIA_CPPFLAGS)
GAP_CPPFLAGS += $(BOEHM_GC_CPPFLAGS)
GAP_CPPFLAGS += $(LIBATOMIC_OPS_CPPFLAGS)

GAP_PKG_CPPFLAGS += $(GMP_CPPFLAGS)
GAP_PKG_CPPFLAGS += $(ZLIB_CPPFLAGS)
GAP_PKG_CPPFLAGS += $(READLINE_CPPFLAGS)
GAP_PKG_CPPFLAGS += $(JULIA_CPPFLAGS)
GAP_PKG_CPPFLAGS += $(BOEHM_GC_CPPFLAGS)
GAP_PKG_CPPFLAGS += $(LIBATOMIC_OPS_CPPFLAGS)
# Add flags for dependencies to common flags
GAP_COMMON_CPPFLAGS += $(GMP_CPPFLAGS)
GAP_COMMON_CPPFLAGS += $(ZLIB_CPPFLAGS)
GAP_COMMON_CPPFLAGS += $(READLINE_CPPFLAGS)
GAP_COMMON_CPPFLAGS += $(JULIA_CPPFLAGS)
GAP_COMMON_CPPFLAGS += $(BOEHM_GC_CPPFLAGS)
GAP_COMMON_CPPFLAGS += $(LIBATOMIC_OPS_CPPFLAGS)

# Finally add user provided flags
GAP_CPPFLAGS += $(CPPFLAGS)
GAP_PKG_CPPFLAGS += $(CPPFLAGS)
# Add user provided flags to common flags
GAP_COMMON_CPPFLAGS += $(CPPFLAGS)

# Add common flags
GAP_CPPFLAGS += $(GAP_COMMON_CPPFLAGS)
GAP_PKG_CPPFLAGS += $(GAP_COMMON_CPPFLAGS)
GAP_INSTALL_CPPFLAGS += $(GAP_COMMON_CPPFLAGS)


########################################################################
Expand Down Expand Up @@ -488,42 +498,70 @@ clean:

########################################################################
# Rules for 'make install'
#
#
# WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING
#
# The following code is incomplete. Parts of it may already be useful
# for people who want to package GAP for their favorite software
# distribution. This is why install-bin etc. are exposed as separate
# targets. However, these have not yet been tested very extensively, so
# use at your own peril -- that said, if you find any issues with them
# NOT COVERED BELOW or have suggestions for improvements, please contact
# us.
#
# Among the things that are known to be missing (no need to inform us
# about it) are:
# - installing the `gac` script
# - installing packages (this one is a bit tricky, depending on what
# assumptions you are willing to make or require)
# - the install sysinfo.gap is not yet fully adapted, some FLAGS in it
# still need to be adjusted to not contain build paths
########################################################################

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

install:
@echo "Error, 'make install' has not yet been implemented"
exit 1
install: install-bin install-gaproot install-headers install-libgap
@echo "+-----------------------------------------------------------------------+"
@echo "| WARNING, 'make install' support is incomplete! Use at your own peril! |"
@echo "+-----------------------------------------------------------------------+"

# the following is wrapper script which is installed by the install-bin target
define gap_wrapper
#!/bin/sh
exec "$(bindir)/gap.real" -l "$(datarootdir)/gap" "$$@"
exec "$(libdir)/gap/gap" -l "$(libdir)/gap;$(datarootdir)/gap" "$$@"
endef
export gap_wrapper

install-bin:
install-bin: gap
@echo "Warning, 'make install-bin' is incomplete"
$(INSTALL) -d -m 0755 $(DESTDIR)$(libdir)/gap
$(INSTALL) -m 0755 gap $(DESTDIR)$(libdir)/gap

$(INSTALL) -d -m 0755 $(DESTDIR)$(bindir)
$(INSTALL) -m 0755 gap $(DESTDIR)$(bindir)/gap.real
echo "$$gap_wrapper" > gap-wrapper.sh
$(INSTALL) -m 0755 gap-wrapper.sh $(DESTDIR)$(bindir)/gap
# TODO: make gac installable; this requires adjusting path in it, and
# installing the libtool script generated by configure somewhere; and then
# putting that path to it into gac)
#$(INSTALL) gac $(DESTDIR)$(bindir)

# the following lines adjust variables for the installed sysinfo.gap
install-gaproot: GAP_BIN_DIR = $(libdir)/gap
install-gaproot: GAP_LIB_DIR = $(datarootdir)/gap
install-gaproot: GAP_PKG_CPPFLAGS = $(GAP_INSTALL_CPPFLAGS)
install-gaproot:
@echo "Warning, 'make install-gaproot' is incomplete"
$(INSTALL) -d -m 0755 $(DESTDIR)$(datarootdir)/gap
# TODO: update paths and FLAGS in sysinfo.gap
$(INSTALL) -m 0644 sysinfo.gap $(DESTDIR)$(datarootdir)/gap
$(INSTALL) -d -m 0755 $(DESTDIR)$(GAP_BIN_DIR)
$(INSTALL) -d -m 0755 $(DESTDIR)$(GAP_LIB_DIR)
$(INSTALL) -m 0644 sysinfo.gap $(DESTDIR)$(GAP_BIN_DIR)
@echo "$$sysinfo_gap" >$(DESTDIR)$(GAP_BIN_DIR)/sysinfo.gap

# the following lines should not use `cp -r`, which is not quite portable,
# and which also may not deal with file permissions correctly
cp -r $(srcdir)/doc $(DESTDIR)$(datarootdir)/gap/ # FIXME: don't use `cp -r`
cp -r $(srcdir)/grp $(DESTDIR)$(datarootdir)/gap/ # FIXME: don't use `cp -r`
cp -r $(srcdir)/lib $(DESTDIR)$(datarootdir)/gap/ # FIXME: don't use `cp -r`
cp -r $(srcdir)/doc $(DESTDIR)$(GAP_LIB_DIR)/
cp -r $(srcdir)/grp $(DESTDIR)$(GAP_LIB_DIR)/
cp -r $(srcdir)/lib $(DESTDIR)$(GAP_LIB_DIR)/
# TODO: what about CITATION, CONTRIBUTING.md, COPYRIGHT, INSTALL.md,
# LICENSE, README* ? Copy them also here? Or into some other path?
# TODO: also copy bin/BuildPackage.sh, as it is very useful?
Expand All @@ -548,10 +586,11 @@ install-headers:
@echo "Warning, 'make install-headers' is incomplete"
$(INSTALL) -d -m 0755 $(DESTDIR)$(includedir)/gap
$(INSTALL) -m 0644 $(srcdir)/src/*.h $(DESTDIR)$(includedir)/gap
# TODO: run the following only if HPC-GAP is enabled?
$(INSTALL) -m 0644 $(srcdir)/build/version.h $(DESTDIR)$(includedir)/gap
$(INSTALL) -d -m 0755 $(DESTDIR)$(includedir)/gap/hpc
$(INSTALL) -m 0644 $(srcdir)/src/hpc/*.h $(DESTDIR)$(includedir)/gap/hpc
# TODO: take care of config.h, this is difficult
# HACK to support packages which still do `#include "src/compiled.h"`
ln -sfh . $(DESTDIR)$(includedir)/gap/src

install-libgap: libgap.la
@echo "Warning, 'make install-libgap' is incomplete"
Expand Down Expand Up @@ -741,18 +780,17 @@ define sysinfo_gap
# This file has been generated by the GAP build system,
# do not edit manually!
GAParch=$(GAPARCH)
GAPARCH=$(GAPARCH)
GAP_ABI=$(ABI)
GAP_HPCGAP=$(HPCGAP)

GAP_VERSION="$(GAP_VERSION)"
GAP_BUILD_VERSION="$(GAP_BUILD_VERSION)"
GAP_LIBTOOL_CURRENT=$(GAP_LIBTOOL_CURRENT)
GAP_LIBTOOL_AGE=$(GAP_LIBTOOL_AGE)
GAP_KERNEL_MAJOR_VERSION=$(GAP_KERNEL_MAJOR_VERSION)
GAP_KERNEL_MINOR_VERSION=$(GAP_KERNEL_MINOR_VERSION)

GAP_BIN_DIR="$(abs_builddir)"
GAP_LIB_DIR="$(abs_srcdir)"
GAP_BIN_DIR="$(GAP_BIN_DIR)"
GAP_LIB_DIR="$(GAP_LIB_DIR)"

GAP="$(abs_builddir)/bin/gap.sh"
GAC="$(abs_builddir)/gac"
Expand All @@ -774,6 +812,23 @@ JULIA_LIBS="$(JULIA_LIBS)"
endef
export sysinfo_gap

# FIXME: sysinfo.gap refactoring:
# - split GAP_CPPFLAGS and move parts of them to GAP_INCLUDE_FLAGS,
# to make them easier to adjust for installation?
# - get rid of GAP_OBJS by removing the "static link" feature from gac;
# i.e., retain comp_static but don't let it go till linking
# - rename GAParch (but keep it for backwards compat)
# - because of GAParch, we can't actually install sysinfo.gap into $prefix/lib
# it seems we may need at least two root dirs for installations, too;
# one which contains "sysinfo.gap" and other arch dependent files, and
# which is where one points configure scripts at; and one which contains
# the stuff which is portable; say
# GAP_BIN_DIR=$prefix/lib/gap/ contains sysinfo.gap, gap, gac
# GAP_LIB_DIR=$prefix/share/gap/ contains doc, grp, lib, ...
# Note how "lib" means two different things above...
#
# So far, we can still "model" this quite well with sysinfo.gap; but I
# wonder if one day we might need to add provisions for more than two GAPROOTs ?
all: sysinfo.gap
sysinfo.gap: config.status $(srcdir)/Makefile.rules cnf/GAP-CFLAGS cnf/GAP-CPPFLAGS cnf/GAP-CXXFLAGS cnf/GAP-LDFLAGS cnf/GAP-LIBS
@rm -f sysinfo.gap # in case this is a symlink created by an older version of the build system
Expand Down

0 comments on commit 92a4aca

Please sign in to comment.