Skip to content

Commit

Permalink
Add build.mak for creating release packages
Browse files Browse the repository at this point in the history
  • Loading branch information
ghaberek committed Jan 19, 2024
1 parent f71aa22 commit f24f721
Show file tree
Hide file tree
Showing 5 changed files with 238 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ build-*
ecp.dat
ex.err
config.gnu
config-*.gnu
Makefile
version.txt
*.swp
Expand All @@ -10,5 +11,6 @@ build
**/#*#
.*.marks
source/build
source/build-*
tests/return15
tests/warnings_issued*.txt
26 changes: 16 additions & 10 deletions source/Makefile.gnu
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
MAKEFLAGS += --no-print-directory

CONFIG_FILE = config.gnu
AR=$(CC_PREFIX)$(AR_SUFFIX)
CC=$(CC_PREFIX)$(CC_SUFFIX)
RC=$(CC_PREFIX)$(RC_SUFFIX)
ifndef CONFIG
Expand Down Expand Up @@ -105,7 +106,11 @@ ifeq "$(EBSD)" "1"
EBSDFLAG=-DEBSD -DEBSD62 -DENETBSD
endif
else
LDLFLAG=-ldl -lresolv -lnsl
ifeq "$(ARCH)" "ix86_64"
LDLFLAG=-ldl -lresolv -lnsl
else
LDLFLAG=-ldl -lresolv
endif
PREREGEX=$(FROMBSDREGEX)
SEDFLAG=-ri
endif
Expand Down Expand Up @@ -294,7 +299,8 @@ endif
ifeq "$(ARCH)" "ARM"
TARCH_FLAG=ARM
ARCH_FLAG=-DEARM
MSIZE=-mcpu=generic-armv6
# MSIZE=-march=armv6 -mfpu=vfp -mfloat-abi=hard
MSIZE=-marm
else ifeq "$(ARCH)" "ix86"
TARCH_FLAG=X86
ARCH_FLAG=-DEX86
Expand Down Expand Up @@ -517,7 +523,7 @@ ifeq "$(OBJDIR)" "libobj"
$(BUILDDIR)/$(EECUA) : $(EU_LIB_OBJECTS) | $(BUILDDIR)
$(AR) -rc $(BUILDDIR)/$(EECUA) $(EU_LIB_OBJECTS)
else
$(BUILDDIR)/$(EECUA) : $(wildcard $(TRUNKDIR)/source/*.{c,h}) $(wildcard $(TRUNKDIR)/source/pcre/*.{c,h}) | $(BUILDDIR)
$(BUILDDIR)/$(EECUA) : $(wildcard $(TRUNKDIR)/source/*.[ch]) $(wildcard $(TRUNKDIR)/source/pcre/*.[ch]) | $(BUILDDIR)
$(MAKE) $(BUILDDIR)/$(EECUA) OBJDIR=libobj ERUNTIME=1 CONFIG=$(CONFIG) EDEBUG= EPROFILE=$(EPROFILE)
endif

Expand Down Expand Up @@ -979,10 +985,10 @@ endif
$(TRUNKDIR)/source/*.h \
$(DESTDIR)$(PREFIX)/share/euphoria/source

EUDIS=eudis
EUTEST=eutest
EUCOVERAGE=eucoverage
EUDIST=eudist
EUDIS=eudis$(EXE_EXT)
EUTEST=eutest$(EXE_EXT)
EUCOVERAGE=eucoverage$(EXE_EXT)
EUDIST=eudist$(EXE_EXT)

ifeq "$(EMINGW)" "1"
MINGW_FLAGS=-gcc -con
Expand Down Expand Up @@ -1158,13 +1164,13 @@ endif
endif

ifneq "$(OBJDIR)" ""
$(BUILDDIR)/$(OBJDIR)/back/%.o : $(TRUNKDIR)/source/%.c $(CONFIG_FILE)
$(BUILDDIR)/$(OBJDIR)/back/%.o : $(TRUNKDIR)/source/%.c $(CONFIG_FILE) | $(BUILDDIR)/$(OBJDIR)/back/
$(CC) $(BE_FLAGS) $(EBSDFLAG) -I $(BUILDDIR)/$(OBJDIR)/back -I $(BUILDDIR)/include $(TRUNKDIR)/source/$*.c -o$(BUILDDIR)/$(OBJDIR)/back/$*.o

$(BUILDDIR)/$(OBJDIR)/back/be_callc.o : $(TRUNKDIR)/source/$(BE_CALLC).c $(CONFIG_FILE)
$(BUILDDIR)/$(OBJDIR)/back/be_callc.o : $(TRUNKDIR)/source/$(BE_CALLC).c $(CONFIG_FILE) | $(BUILDDIR)/$(OBJDIR)/back/
$(CC) -c -Wall $(EOSTYPE) $(ARCH_FLAG) $(FPIC) $(EOSFLAGS) $(EBSDFLAG) $(MSIZE) -DARCH=$(ARCH) -fsigned-char -O2 -fno-omit-frame-pointer -ffast-math -fno-defer-pop $(CALLC_DEBUG) $(TRUNKDIR)/source/$(BE_CALLC).c -o$(BUILDDIR)/$(OBJDIR)/back/be_callc.o

$(BUILDDIR)/$(OBJDIR)/back/be_inline.o : $(TRUNKDIR)/source/be_inline.c $(CONFIG_FILE)
$(BUILDDIR)/$(OBJDIR)/back/be_inline.o : $(TRUNKDIR)/source/be_inline.c $(CONFIG_FILE) | $(BUILDDIR)/$(OBJDIR)/back/
$(CC) -finline-functions $(BE_FLAGS) $(EBSDFLAG) $(RUNTIME_FLAGS) $(TRUNKDIR)/source/be_inline.c -o$(BUILDDIR)/$(OBJDIR)/back/be_inline.o
endif
ifdef PCRE_OBJECTS
Expand Down
147 changes: 147 additions & 0 deletions source/build.mak
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
##
## Usage:
## make -f build.mak -j$(nproc) PLATFORM=platform [USE_CCACHE=1]
##
## Options:
## PLATFORM Specify one of the platform names lited below.
## USE_CCACHE Enable ccache to speed up rebuilds. Must have ccache installed.
## -j$(nproc) Command to specify same number of build jobs as available CPUs.
##
## Platforms:
## - linux-x64 (none)
## - linux-arm (apt install {binutils,gcc}-arm-linux-gnu)
## - linux-x86 (apt install {binutils,gcc}-i686-linux-gnu)
## - windows-x64 (apt install {binutils,gcc}-mingw-w64-x86-64)
## - windows-x86 (apt install {binutils,gcc}-mingw-w64-i686)
##
## (All plaforms require the "build-essential" package in addition to the above.)
##
## This is a "meta" makefile that to create a full release of Euphoria. I assume you're on x86-64
## and using a recent distribution of Debian (11+) or Ubuntu (20.04+) or a derivative (e.g. Mint).
## See the platforms list above for the required packages. Here's how it works:
##
## 1. Runs ./configure with the options for (cross-)compiling to the target platform.
## 2. Renames config.gnu file created by ./configure to include the platform name.
## 3. Runs make, specifying the CONFIG_FILE option to the file created in steps 1-2.
## 4. Collects the artifacts from the build directory into a temporary directory in /tmp.
## 5. Creates a tarball or zip file in the source directory with the files from step 4.
##

MAKEFLAGS += --no-print-directory

MAKEFILE_NAME := $(abspath $(lastword $(MAKEFILE_LIST)))
TRUNKDIR := $(abspath $(dir $(MAKEFILE_NAME))..)

PLATFORMS := linux-arm linux-x86 linux-x64 windows-x86 windows-x64
RELEASE ?= release

ifeq ($(findstring $(PLATFORM),$(PLATFORMS)),)
$(error PLATFORM required, one of: $(PLATFORMS))
endif

GITHASH := $(shell git rev-parse --short=7 HEAD)
MAJ_VER := $(word 3,$(shell grep MAJ_VER version.h))
MIN_VER := $(word 3,$(shell grep MIN_VER version.h))
PAT_VER := $(word 3,$(shell grep PAT_VER version.h))
VERSION := $(MAJ_VER).$(MIN_VER).$(PAT_VER)

ifeq ($(PLATFORM),linux-arm)
ARCH := ARM
PLAT := LINUX
CC_PREFIX := arm-linux-gnueabihf-
else ifeq ($(PLATFORM),linux-x86)
ARCH := x86
PLAT := LINUX
CC_PREFIX := i686-linux-gnu-
else ifeq ($(PLATFORM),linux-x64)
ARCH := x86_64
PLAT := LINUX
CC_PREFIX := x86_64-linux-gnu-
else ifeq ($(PLATFORM),windows-x86)
ARCH := x86
PLAT := WINDOWS
CC_PREFIX := i686-w64-mingw32-
else ifeq ($(PLATFORM),windows-x64)
ARCH := x86_64
PLAT := WINDOWS
CC_PREFIX := x86_64-w64-mingw32-
endif

LIB_EXT := .a

ifeq ($(PLATFORM),$(filter windows-%,$(PLATFORM)))
EXE_EXT := .exe
ZIP_EXT := .zip
else
EXE_EXT :=
ZIP_EXT := .tar.gz
endif

BUILDDIR = $(TRUNKDIR)/source/build-$(PLATFORM)
CONFIG_FILE = config-$(PLATFORM).gnu
CONFIG_PARAMS = --arch=$(ARCH) --plat=$(PLAT) --build=$(BUILDDIR) --release=$(RELEASE) --use-source-translator

ifeq ($(USE_CCACHE),1)
CONFIG_PARAMS += --cc-prefix='ccache $(CC_PREFIX)'
HOSTCC = 'ccache gcc'
else
CONFIG_PARAMS += --cc-prefix=$(CC_PREFIX)
HOSTCC = gcc
endif

PACKAGE_NAME = euphoria-$(VERSION)-$(PLATFORM)
PACKAGE_FILE = $(PACKAGE_NAME)-$(GITHASH)$(ZIP_EXT)
PACKAGE_PATH = /tmp/$(PACKAGE_NAME)

BUILD_FILES := eub$(EXE_EXT) euc$(EXE_EXT) eui$(EXE_EXT) eubind$(EXE_EXT) eucoverage$(EXE_EXT) eudis$(EXE_EXT) \
eudist$(EXE_EXT) eushroud$(EXE_EXT) eutest$(EXE_EXT) eu$(LIB_EXT) eudbg$(LIB_EXT) euso$(LIB_EXT) eusodbg$(LIB_EXT)
BUILD_FILES := $(addprefix $(PACKAGE_PATH)/bin/,$(BUILD_FILES))

INCLUDE_FILES := $(wildcard $(TRUNKDIR)/include/*.e) $(wildcard $(TRUNKDIR)/include/*/*.e) \
$(wildcard $(TRUNKDIR)/include/*/*/*.e*) $(wildcard $(TRUNKDIR)/include/*.h)
INCLUDE_FILES := $(patsubst $(TRUNKDIR)/%,$(PACKAGE_PATH)/%,$(INCLUDE_FILES))

HTMLDOC_FILES := $(shell eui docs.ex ../docs/manual.af) images/next.png images/prev.png \
js/prototype.js js/scriptaculous.js js/search.js search.dat style.css
HTMLDOC_FILES := $(addprefix $(PACKAGE_PATH)/docs/html/,$(HTMLDOC_FILES))

OTHER_FILES = \
$(PACKAGE_PATH)/bin/bench.ex \
$(PACKAGE_PATH)/bin/bugreport.ex \
$(PACKAGE_PATH)/bin/buildcpdb.ex \
$(PACKAGE_PATH)/bin/ecp.dat \
$(PACKAGE_PATH)/bin/edx.bat \
$(PACKAGE_PATH)/bin/edx.ex \
$(PACKAGE_PATH)/bin/eucoverage.ex \
$(PACKAGE_PATH)/bin/euloc.ex \
$(PACKAGE_PATH)/bin/make31.exw \
$(PACKAGE_PATH)/License.txt

all : $(PACKAGE_FILE)

clean :
@rm -rf $(PACKAGE_PATH) $(BUILDDIR)
@rm -f $(CONFIG_FILE) $(PACKAGE_FILE)

$(PACKAGE_FILE) : $(BUILD_FILES) $(INCLUDE_FILES) $(HTMLDOC_FILES) $(OTHER_FILES)
ifeq ($(ZIP_EXT),.tar.gz)
@tar -C /tmp -I 'gzip -9' -vcf $(abspath $@) $(sort $(patsubst /tmp/%,%,$^))
else ifeq ($(ZIP_EXT),.zip)
@cd /tmp && zip -r9 $(abspath $@) $(sort $(patsubst /tmp/%,%,$^))
endif

$(BUILD_FILES) : $(PACKAGE_PATH)/bin/% : $(BUILDDIR)/% ; @mkdir -p $(dir $@) && cp -p $< $@ && $(CC_PREFIX)strip -g $@

$(INCLUDE_FILES) : $(PACKAGE_PATH)/include/% : $(TRUNKDIR)/include/% ; @mkdir -p $(dir $@) && cp -p $< $@

$(HTMLDOC_FILES) : $(PACKAGE_PATH)/docs/html/% : $(BUILDDIR)/html/% ; @mkdir -p $(dir $@) && cp -p $< $@

$(OTHER_FILES) : $(PACKAGE_PATH)/% : $(TRUNKDIR)/% ; @mkdir -p $(dir $@) && cp -p $< $@

$(BUILDDIR)/html/% : $(CONFIG_FILE) ; $(MAKE) CONFIG_FILE=$< htmldoc

$(BUILDDIR)/% : $(CONFIG_FILE) ; $(MAKE) CONFIG_FILE=$< HOSTCC=$(HOSTCC) $@

$(CONFIG_FILE) : ; ./configure $(CONFIG_PARAMS) && mv config.gnu $(CONFIG_FILE)

.PHONY : all clean $(PLATFORMS)
11 changes: 11 additions & 0 deletions source/configure
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ fi

XLTTARGETCC=gcc
CC=gcc
AR=ar
EDEBUG=

SCP="scp -C"
Expand Down Expand Up @@ -359,6 +360,15 @@ while [ "$1" != "" ]; do
exit
esac
;;

--ar*)
VAL=`echo $1 | cut -d = -f 2`
if [ "$VAL" = "$1" ]; then
shift ; VAL=$1
fi

AR=$VAL
;;

--wine*)
VAL=`echo $1 | cut -d = -f 2`
Expand Down Expand Up @@ -526,6 +536,7 @@ echo "TRANSLATE=$EC" >> "$PREFIX"${CONFIG_FILE}
[ -n "$TARGET" ] && echo "ETARGET=$TARGET" >> "$PREFIX"${CONFIG_FILE}
[ -n "$ARCH" ] && echo "ARCH=$ARCH" >> "$PREFIX"${CONFIG_FILE}
[ -n "$MFLAG" ] && echo "MSIZE=$MFLAG" >> "$PREFIX"${CONFIG_FILE}
[ -n "$AR" ] && echo "AR_SUFFIX=$AR" >> "$PREFIX"${CONFIG_FILE}
[ -n "$CC" ] && echo "CC_SUFFIX=$CC" >> "$PREFIX"${CONFIG_FILE}
[ -n "$CC_PREFIX" ] && echo "CC_PREFIX=$CC_PREFIX" >> "$PREFIX"${CONFIG_FILE}
[ -n "$RC" ] && echo "RC_SUFFIX=$RC" >> "$PREFIX"${CONFIG_FILE}
Expand Down
62 changes: 62 additions & 0 deletions source/docs.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
-- docs.ex
-- print a list of file names would be created by eudoc / creole

include std/io.e
include std/filesys.e
include std/search.e
include std/sequence.e
include std/text.e

sequence cmd = command_line()
sequence file_names = {}

if length( cmd ) < 3 then
puts(2, "usage: eui docs.ex path/to/manual.af\n")
abort(1)
end if

sequence manual_file = canonical_path(cmd[3])
sequence manual_path = dirname(manual_file) & SLASH
sequence manual_lines = read_lines(manual_file)

for i = 1 to length(manual_lines) do
manual_lines[i] = trim_head(manual_lines[i])

if begins(":%%output=", manual_lines[i]) then
file_names = append(file_names, manual_lines[i][11..$])

elsif begins("../", manual_lines[i]) then

if ends(" <nowiki", manual_lines[i]) != 0 then
manual_lines[i] = manual_lines[i][1..$-8]
end if

sequence parts = split(manual_lines[i], SLASH)
parts[$] = find_replace('.', filebase(parts[$]), '_')
sequence name = join(parts[3..$], '_')

if length(name) != 0 then
file_names = append(file_names, name)
end if

if equal(fileext(manual_lines[i]), "txt") then
object text_lines = read_lines(canonical_path(manual_path & manual_lines[i]))
if atom(text_lines) then
text_lines = {}
end if
for j = 1 to length(text_lines) do
text_lines[j] = trim_head(text_lines[j])
if begins("%%output=", text_lines[j]) then
file_names = append(file_names, text_lines[j][10..$])
end if
end for
end if

end if

end for

for i = 1 to length(file_names) do
printf(1, "%s.html\n", {file_names[i]})
end for

0 comments on commit f24f721

Please sign in to comment.