From 838b3406a86631437461fe6080d6b1002b6c7fa5 Mon Sep 17 00:00:00 2001 From: Quentin Quadrat Date: Mon, 20 May 2024 21:18:34 +0200 Subject: [PATCH] Fixing ExaequOS architecture --- Makefile.footer | 12 ++++++++++++ Makefile.header | 48 +++++++++++++++++++++++++++++++----------------- Makefile.macros | 28 +++++++++++++++++++++++++--- 3 files changed, 68 insertions(+), 20 deletions(-) diff --git a/Makefile.footer b/Makefile.footer index b315771..457c7fd 100644 --- a/Makefile.footer +++ b/Makefile.footer @@ -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 # @@ -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),) @@ -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 diff --git a/Makefile.header b/Makefile.header index 1846b2f..3383dcd 100644 --- a/Makefile.header +++ b/Makefile.header @@ -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 # @@ -132,6 +116,26 @@ PROJECT_INFO ?= project_info.hpp # MacOS X path to the application bundle icon MACOS_BUNDLE_ICON ?= .makefile/macos.icns +################################################### +# Emscripten +# +ifneq ($(EXAEQUOS),) +#ifeq ($(EMSCRIPTEN),) +#$(error You are inside a docker but you did not call emmake) +#endif +ARCHI := Emscripten +CXX := em++.py +CC := emcc.py +AR := emar.py +ARFLAGS := crs +DEFINES += -DEXAEQUOS +endif + +ifneq ($(EMSCRIPTEN),) +$(warning Compiling with emscripten) +ARCHI := Emscripten +endif + ################################################### # Check if some variables have been defined # @@ -177,7 +181,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) @@ -216,13 +224,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++") @@ -232,6 +245,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) diff --git a/Makefile.macros b/Makefile.macros index 7f6bf31..84f0cf7 100644 --- a/Makefile.macros +++ b/Makefile.macros @@ -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) @@ -256,18 +258,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) +endif +endif + ################################################### # Install all .hpp files to the $(INSTALL_INCLUDEDIR) folder # TODO need glob regex