Skip to content

Commit

Permalink
Fixing ExaequOS architecture
Browse files Browse the repository at this point in the history
  • Loading branch information
Lecrapouille committed May 20, 2024
1 parent 6b78f99 commit 44ed73c
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 23 deletions.
4 changes: 2 additions & 2 deletions Makefile.flags
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@ endif
# Use ifdef because pkg-config does not like empty argument
#
ifdef PKG_LIBS
PKGCFG_LIBS := `pkg-config --libs $(PKG_LIBS)`
PKGCFG_CFLAGS := `pkg-config --cflags $(PKG_LIBS)`
PKGCFG_LIBS := `PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --libs $(PKG_LIBS)`
PKGCFG_CFLAGS := `PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --cflags $(PKG_LIBS)`
endif

###################################################
Expand Down
12 changes: 12 additions & 0 deletions Makefile.footer
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@

include $(M)/Makefile.flags

###################################################
# Disable shared lib for ExaequOS for the moment
#
ifneq ($(EXAEQUOS),)
ifdef SHARED_LIB_TARGET
$(warning Sorry for the moment no shared lib can be created for ExaequOS)
SHARED_LIB_TARGET :=
endif
endif

###################################################
# Internal librairies
#
Expand Down Expand Up @@ -97,6 +107,7 @@ endif
###################################################
# Shared library
#
ifeq ($(EXAEQUOS),)
$(SHARED_LIB_TARGET): LDFLAGS += $(DLL_LDFLAGS)
$(SHARED_LIB_TARGET): $(LIB_OBJS) $(THIRDPART_OBJS) $(THIRDPART_LIBS)
ifeq ($(LIB_OBJS),)
Expand All @@ -105,6 +116,7 @@ endif
@$(call print-to,"Shared lib","$(TARGET)","$(BUILD)/$@","$(VERSION)")
$(Q)cd $(BUILD) && $(COMPILER) $(LDFLAGS) -o $@ $(LIB_OBJS) $(THIRDPART_OBJS) $(LINK_ALL_LOAD) $(THIRDPART_LIBS) $(NOT_PKG_LIBS) $(PKGCFG_LIBS) $(LINK_NO_ALL_LOAD) $(LINKER_FLAGS)
$(Q)cd $(BUILD) && cp $@ $(SHARED_LIB_TARGET_NOVERSION)
endif

###################################################
# Generate the pkg-config file
Expand Down
49 changes: 32 additions & 17 deletions Makefile.header
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,6 @@ WIN_ENV := $(patsubst MINGW%,MINGW,$(WIN_ENV))
ARCHI := Windows
endif

###################################################
# Emscripten
#
ifneq ($(EMSCRIPTEN),)
$(warning Compiling with emscripten)
ARCHI := Emscripten
endif

###################################################
# Exaequos https://github.com/exaequos
#
ifneq ($(EXAEQUOS),)
$(warning Compiling with emscripten-exa for ExaequOS)
ARCHI := ExaequOS
endif

###################################################
# Macros to override through Makefile command lines
#
Expand Down Expand Up @@ -132,6 +116,27 @@ PROJECT_INFO ?= project_info.hpp
# MacOS X path to the application bundle icon
MACOS_BUNDLE_ICON ?= .makefile/macos.icns

PKG_CONFIG_PATH ?=

###################################################
# Emscripten
#
ifneq ($(EXAEQUOS),)
$(warning Compiling with exaequOS-emscripten)
ARCHI := Emscripten
CXX := em++.py
CC := emcc.py
AR := emar.py
ARFLAGS := crsv
DEFINES += -DEXAEQUOS
STRIP :=
DESTDIR :=
PKG_CONFIG_PATH := $(abspath $(P)/exapkgs/pkgconfigs)
else ifneq ($(EMSCRIPTEN),)
$(warning Compiling with emscripten)
ARCHI := Emscripten
endif

###################################################
# Check if some variables have been defined
#
Expand Down Expand Up @@ -177,7 +182,11 @@ TMPDIR ?= /tmp
# Application extension
#
ifeq ($(ARCHI),Emscripten)
ifneq ($(EXAEQUOS),)
EXT := .js
else
EXT := .html
endif
else ifeq ($(ARCHI),Darwin)
EXT := .app
else ifeq ($(ARCHI),Linux)
Expand Down Expand Up @@ -216,13 +225,18 @@ $(error Supported SUFFIX are $(CC_SUFFIX) or $(CXX_SUFFIX))
endif

###################################################
# Determine compiler name
# Determine compiler name. Exaequos em++.py does not work
#
ifeq ($(EXAEQUOS),)
COMPILER_NAME := $(shell $(COMPILER) --version | head -1 | cut -d" " -f1 | cut -d"-" -f1)
else
COMPILER_NAME := em++.py
endif

###################################################
# Determine compiler version
#
ifeq ($(EXAEQUOS),)
ifeq ("$(COMPILER_NAME)","clang")
COMPILER_VERSION := $(shell $(COMPILER) --version | head -1 | grep -o -E '[0-9]+\.[0-9]+\.[0-9]+' | head -1)
else ifeq ("$(COMPILER_NAME)","g++")
Expand All @@ -232,6 +246,7 @@ COMPILER_VERSION := $(shell $(COMPILER) --version | head -1 | grep -o -E '[0-9]+
else
COMPILER_VERSION := 0
endif
endif

###################################################
# Convert version number into a integer (ie g++-4.9.2 will return 40902)
Expand Down
71 changes: 67 additions & 4 deletions Makefile.macros
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ TARGET_LOWER_CASE := $(shell echo $(TARGET) | tr A-Z a-z)
#
SHORT_LIB_TARGET := -l$(TARGET_LOWER_CASE)
LIB_TARGET := lib$(TARGET_LOWER_CASE)
ifeq ($(EXAEQUOS),)
SHARED_LIB_TARGET_NOVERSION := $(LIB_TARGET).$(SO)
SHARED_LIB_TARGET := $(SHARED_LIB_TARGET_NOVERSION).$(TARGET_VERSION)
SHARED_LIB_TARGET_MAJOR := $(SHARED_LIB_TARGET_NOVERSION).$(TARGET_MAJOR_VERSION)
endif
STATIC_LIB_TARGET_NOVERSION := $(LIB_TARGET).a
STATIC_LIB_TARGET := $(STATIC_LIB_TARGET_NOVERSION).$(TARGET_VERSION)
STATIC_LIB_TARGET_MAJOR := $(STATIC_LIB_TARGET_NOVERSION).$(TARGET_MAJOR_VERSION)
Expand All @@ -58,8 +60,12 @@ STATIC_LIB_TARGET_MAJOR := $(STATIC_LIB_TARGET_NOVERSION).$(TARGET_MAJOR_VERSION
#
INSTALL_INCLUDEDIR = $(DESTDIR)$(INCLUDEDIR)/$(PROJECT_LOWER_CASE)/$(TARGET_VERSION)
INSTALL_LIBDIR = $(DESTDIR)$(LIBDIR)
INSTALL_BINDIR = $(DESTDIR)$(BINDIR)
INSTALL_DATADIR = $(DESTDIR)$(DATADIR)
ifneq ($(EXAEQUOS),)
INSTALL_BINDIR := /media/localhost/$(TARGET)/exa
else
INSTALL_BINDIR = $(DESTDIR)$(BINDIR)
endif

###################################################
# Define where to install pkg-config file
Expand Down Expand Up @@ -170,12 +176,22 @@ endef
###################################################
# Install the project binary
#
ifeq ($(EXAEQUOS),)
define INSTALL_BINARY
@$(call print-to,"Installing","$(BUILD)/$(TARGET)","$(PROJECT_EXE)","")
@mkdir -p $(INSTALL_BINDIR)
@cp $(BUILD)/$(TARGET) $(PROJECT_EXE)
@ln -sf $(PROJECT_EXE) $(PROJECT_EXE_NO_VERSION)
endef
else
define INSTALL_BINARY
@$(call print-to,"Installing exaequOS","$(BUILD)/$(TARGET)","$(PROJECT_EXE)","")
@mkdir -p $(INSTALL_BINDIR)
cp $(BUILD)/$(TARGET).js $(INSTALL_BINDIR)/$(TARGET).js
cp $(BUILD)/$(TARGET).wasm $(INSTALL_BINDIR)/$(TARGET).wasm
$(call CREATE_EXAEQUOS_HTML,exa.html)
endef
endif

###################################################
# Install the project documentation.
Expand Down Expand Up @@ -242,6 +258,33 @@ define CREATE_PKG_CONFIG
@echo "Cflags: -I$$""{includedir}" >> $(BUILD)/$(1)
endef

###################################################
# Create the exa.html file
#
define CREATE_EXAEQUOS_HTML
@$(call print-to,"Generating","$(TARGET)","$(1)","")
@echo "<!doctype html>" > $(INSTALL_BINDIR)/$(1)
@echo "<html lang=\"en-us\">" >> $(INSTALL_BINDIR)/$(1)
@echo "<head>" >> $(INSTALL_BINDIR)/$(1)
@echo " <meta charset=\"utf-8\">" >> $(INSTALL_BINDIR)/$(1)
@echo " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">" >> $(INSTALL_BINDIR)/$(1)
@echo " <title>Emscripten-Generated Code</title>" >> $(INSTALL_BINDIR)/$(1)
@echo " <style>" >> $(INSTALL_BINDIR)/$(1)
@echo " html, body {" >> $(INSTALL_BINDIR)/$(1)
@echo " margin : 0;" >> $(INSTALL_BINDIR)/$(1)
@echo " padding: 0;" >> $(INSTALL_BINDIR)/$(1)
@echo " border: none;" >> $(INSTALL_BINDIR)/$(1)
@echo " width: 100%;" >> $(INSTALL_BINDIR)/$(1)
@echo " height: 100%;" >> $(INSTALL_BINDIR)/$(1)
@echo " }" >> $(INSTALL_BINDIR)/$(1)
@echo " </style>" >> $(INSTALL_BINDIR)/$(1)
@echo "</head>" >> $(INSTALL_BINDIR)/$(1)
@echo "<body>" >> $(INSTALL_BINDIR)/$(1)
@echo " <script async type=\"text/javascript\" src=\"$(TARGET).js\"></script>" >> $(INSTALL_BINDIR)/$(1)
@echo "</body>" >> $(INSTALL_BINDIR)/$(1)
@echo "</html>" >> $(INSTALL_BINDIR)/$(1)
endef

###################################################
# Install the pkg-config file (if the project is a library)
#
Expand All @@ -256,18 +299,38 @@ endef
# Install static and dynamic libraries (if the project
# is not an application)
#
define INSTALL_PROJECT_LIBRARIES
@$(call print-to,"Installing","libs","$(INSTALL_LIBDIR)","")
@mkdir -p $(INSTALL_LIBDIR)
define INSTALL_PROJECT_STATIC_LIBRARIES
@install -m 644 $(BUILD)/$(STATIC_LIB_TARGET) $(INSTALL_LIBDIR)
@ln -snf $(INSTALL_LIBDIR)/$(STATIC_LIB_TARGET) $(INSTALL_LIBDIR)/$(STATIC_LIB_TARGET_NOVERSION)
@ln -snf $(INSTALL_LIBDIR)/$(STATIC_LIB_TARGET) $(INSTALL_LIBDIR)/$(STATIC_LIB_TARGET_MAJOR)
endef

define INSTALL_PROJECT_SHARED_LIBRARIES
@install -m 644 $(BUILD)/$(SHARED_LIB_TARGET) $(INSTALL_LIBDIR)
@ln -snf $(INSTALL_LIBDIR)/$(SHARED_LIB_TARGET) $(INSTALL_LIBDIR)/$(SHARED_LIB_TARGET_NOVERSION)
@ln -snf $(INSTALL_LIBDIR)/$(SHARED_LIB_TARGET) $(INSTALL_LIBDIR)/$(SHARED_LIB_TARGET_MAJOR)
@$(call INSTALL_PKG_CONFIG)
endef

###################################################
# Install static and dynamic libraries (if the project
# is not an application)
#
ifeq ($(EXAEQUOS),)
define INSTALL_PROJECT_LIBRARIES
@$(call print-to,"Installing","libs","$(INSTALL_LIBDIR)","")
@mkdir -p $(INSTALL_LIBDIR)
@$(call INSTALL_PROJECT_SHARED_LIBRARIES)
@$(call INSTALL_PROJECT_STATIC_LIBRARIES)
endef
else
define INSTALL_PROJECT_LIBRARIES
@$(call print-to,"Installing","libs","$(INSTALL_LIBDIR)","")
@mkdir -p $(INSTALL_LIBDIR)
@$(call INSTALL_PROJECT_STATIC_LIBRARIES)
endef
endif

###################################################
# Install all .hpp files to the $(INSTALL_INCLUDEDIR) folder
# TODO need glob regex
Expand Down

0 comments on commit 44ed73c

Please sign in to comment.