diff --git a/Makefile.flags b/Makefile.flags index 3cb14b7..bb7952a 100644 --- a/Makefile.flags +++ b/Makefile.flags @@ -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 ################################################### 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..368c096 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,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 # @@ -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) @@ -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++") @@ -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) diff --git a/Makefile.macros b/Makefile.macros index 7f6bf31..4909117 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) @@ -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 @@ -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. @@ -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 "" > $(INSTALL_BINDIR)/$(1) + @echo "" >> $(INSTALL_BINDIR)/$(1) + @echo "" >> $(INSTALL_BINDIR)/$(1) + @echo " " >> $(INSTALL_BINDIR)/$(1) + @echo " " >> $(INSTALL_BINDIR)/$(1) + @echo " Emscripten-Generated Code" >> $(INSTALL_BINDIR)/$(1) + @echo " " >> $(INSTALL_BINDIR)/$(1) + @echo "" >> $(INSTALL_BINDIR)/$(1) + @echo "" >> $(INSTALL_BINDIR)/$(1) + @echo " " >> $(INSTALL_BINDIR)/$(1) + @echo "" >> $(INSTALL_BINDIR)/$(1) + @echo "" >> $(INSTALL_BINDIR)/$(1) +endef + ################################################### # Install the pkg-config file (if the project is a library) # @@ -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