From 560d01dfd7662137714576e3a07da99e2698de71 Mon Sep 17 00:00:00 2001 From: James Duley Date: Thu, 30 Jul 2015 23:37:38 +0100 Subject: [PATCH 1/3] LP-61 more config options: split out make helper functions Change-Id: I54b1ed3f42170c7ee0a3dbe816a5d0400881d9e2 --- Makefile | 21 ++++++--------------- make/functions.mk | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 15 deletions(-) create mode 100644 make/functions.mk diff --git a/Makefile b/Makefile index 3f447477f..62fd1aefb 100644 --- a/Makefile +++ b/Makefile @@ -26,6 +26,12 @@ # existance by each sub-make. export TOP_LEVEL_MAKEFILE := TRUE +# The root directory that this makefile resides in +export ROOT_DIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))) + +# Include some helper functions +include $(ROOT_DIR)/make/functions.mk + # It is possible to set DL_DIR and/or TOOLS_DIR environment # variables to override local tools download and installation directorys. So the # same toolchains can be used for all working copies. Particularly useful for CI @@ -35,15 +41,7 @@ export TOP_LEVEL_MAKEFILE := TRUE # will be used. They still can be overriden by the make command line parameters: # make DL_DIR=/path/to/download/directory TOOLS_DIR=/path/to/tools/directory targets... -# Function for converting Windows style slashes into Unix style -slashfix = $(subst \,/,$(1)) - -# Function for converting an absolute path to one relative -# to the top of the source tree -toprel = $(subst $(realpath $(ROOT_DIR))/,,$(abspath $(1))) - # Set up some macros for common directories within the tree -export ROOT_DIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))) export BUILD_DIR := $(ROOT_DIR)/build export PACKAGE_DIR := $(ROOT_DIR)/build/package export DIST_DIR := $(ROOT_DIR)/build/dist @@ -55,13 +53,6 @@ export TOOLS_DIR DIRS = $(DL_DIR) $(TOOLS_DIR) $(BUILD_DIR) $(PACKAGE_DIR) $(DIST_DIR) -# Function to convert to all lowercase -lc = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,$(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,$(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$1)))))))))))))))))))))))))) -# Function to make all lowercase and replace spaces with - -EMPTY := -SPACE := $(EMPTY) $(EMPTY) -smallify = $(subst $(SPACE),-,$(call lc,$1)) - # Naming for binaries and packaging etc,. ORG_BIG_NAME := LibrePilot GCS_BIG_NAME = ${ORG_BIG_NAME} GCS diff --git a/make/functions.mk b/make/functions.mk new file mode 100644 index 000000000..11a32c0e2 --- /dev/null +++ b/make/functions.mk @@ -0,0 +1,15 @@ + +# Function for converting Windows style slashes into Unix style +slashfix = $(subst \,/,$(1)) + +# Function for converting an absolute path to one relative +# to the top of the source tree +toprel = $(subst $(realpath $(ROOT_DIR))/,,$(abspath $(1))) + +# Function to convert to all lowercase +lc = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,$(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,$(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$1)))))))))))))))))))))))))) +# Function to make all lowercase and replace spaces with - +EMPTY := +SPACE := $(EMPTY) $(EMPTY) +smallify = $(subst $(SPACE),-,$(call lc,$1)) + From fa29163753a16461ec5eeb3a53de64cf4e52a64d Mon Sep 17 00:00:00 2001 From: James Duley Date: Thu, 30 Jul 2015 23:50:31 +0100 Subject: [PATCH 2/3] LP-61 more config options: tidy up some make variables Change-Id: Ibb14d07ccdb5202b1bd9087390a76e84a7282d8d --- Makefile | 53 +++++++++++++++++++++++++---------------------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/Makefile b/Makefile index 62fd1aefb..dd944fcd6 100644 --- a/Makefile +++ b/Makefile @@ -32,33 +32,33 @@ export ROOT_DIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))) # Include some helper functions include $(ROOT_DIR)/make/functions.mk +# This file can be used to override default options using the "override" keyword +CONFIG_FILE := config +-include $(CONFIG_FILE) + +############################## # It is possible to set DL_DIR and/or TOOLS_DIR environment # variables to override local tools download and installation directorys. So the # same toolchains can be used for all working copies. Particularly useful for CI # server build agents, but also for local installations. -# -# If no OPENPILOT_* variables found, makefile internal DL_DIR and TOOLS_DIR paths -# will be used. They still can be overriden by the make command line parameters: -# make DL_DIR=/path/to/download/directory TOOLS_DIR=/path/to/tools/directory targets... - -# Set up some macros for common directories within the tree -export BUILD_DIR := $(ROOT_DIR)/build -export PACKAGE_DIR := $(ROOT_DIR)/build/package -export DIST_DIR := $(ROOT_DIR)/build/dist override DL_DIR := $(if $(DL_DIR),$(call slashfix,$(DL_DIR)),$(ROOT_DIR)/downloads) override TOOLS_DIR := $(if $(TOOLS_DIR),$(call slashfix,$(TOOLS_DIR)),$(ROOT_DIR)/tools) - export DL_DIR export TOOLS_DIR -DIRS = $(DL_DIR) $(TOOLS_DIR) $(BUILD_DIR) $(PACKAGE_DIR) $(DIST_DIR) +# Set up some macros for common directories within the tree +export BUILD_DIR := $(CURDIR)/build +export PACKAGE_DIR := $(BUILD_DIR)/package +export DIST_DIR := $(BUILD_DIR)/dist + +DIRS := $(DL_DIR) $(TOOLS_DIR) $(BUILD_DIR) $(PACKAGE_DIR) $(DIST_DIR) # Naming for binaries and packaging etc,. ORG_BIG_NAME := LibrePilot -GCS_BIG_NAME = ${ORG_BIG_NAME} GCS +GCS_BIG_NAME := ${ORG_BIG_NAME} GCS # These should be lowercase with no spaces -ORG_SMALL_NAME = $(call smallify,$(ORG_BIG_NAME)) -GCS_SMALL_NAME = $(call smallify,$(GCS_BIG_NAME)) +ORG_SMALL_NAME := $(call smallify,$(ORG_BIG_NAME)) +GCS_SMALL_NAME := $(call smallify,$(GCS_BIG_NAME)) # Set up default build configurations (debug | release) GCS_BUILD_CONF := release @@ -125,20 +125,16 @@ include $(ROOT_DIR)/make/tools.mk # We almost need to consider autoconf/automake instead of this ifeq ($(UNAME), Linux) - QT_SPEC = linux-g++ - UAVOBJGENERATOR = $(BUILD_DIR)/uavobjgenerator/uavobjgenerator + QT_SPEC := linux-g++ + UAVOBJGENERATOR := $(BUILD_DIR)/uavobjgenerator/uavobjgenerator else ifeq ($(UNAME), Darwin) - QT_SPEC = macx-g++ - UAVOBJGENERATOR = $(BUILD_DIR)/uavobjgenerator/uavobjgenerator + QT_SPEC := macx-g++ + UAVOBJGENERATOR := $(BUILD_DIR)/uavobjgenerator/uavobjgenerator else ifeq ($(UNAME), Windows) - QT_SPEC = win32-g++ - UAVOBJGENERATOR = $(BUILD_DIR)/uavobjgenerator/uavobjgenerator.exe + QT_SPEC := win32-g++ + UAVOBJGENERATOR := $(BUILD_DIR)/uavobjgenerator/uavobjgenerator.exe endif -CONFIG_FILE := config --include $(CONFIG_FILE) - -############################## # # All targets # @@ -162,7 +158,7 @@ clean: all_clean # ############################## -UAVOBJGENERATOR_DIR = $(BUILD_DIR)/uavobjgenerator +UAVOBJGENERATOR_DIR := $(BUILD_DIR)/uavobjgenerator DIRS += $(UAVOBJGENERATOR_DIR) .PHONY: uavobjgenerator @@ -846,15 +842,16 @@ dist: $(DIST_NAME).gz # ############################## -CONFIG_OPTS := $(subst $(SPACE),\n,$(MAKEOVERRIDES)) +CONFIG_OPTS := $(addsuffix \n,$(MAKEOVERRIDES)) +CONFIG_OPTS := $(addprefix override$(SPACE),$(CONFIG_OPTS)) .PHONY: config_new config_new: - @printf '$(CONFIG_OPTS)\n' > $(CONFIG_FILE) + @printf '$(CONFIG_OPTS)' > $(CONFIG_FILE) .PHONY: config_append config_append: - @printf '$(CONFIG_OPTS)\n' >> $(CONFIG_FILE) + @printf '$(CONFIG_OPTS)' >> $(CONFIG_FILE) .PHONY: config_show config_show: From 50ee70f49275f38837bcc474ea10b021d25177c3 Mon Sep 17 00:00:00 2001 From: James Duley Date: Sun, 26 Jul 2015 21:30:41 +0100 Subject: [PATCH 3/3] LP-61 addtional make config options: added libbasename & GCS_LIBRARY_BASENAME Change-Id: Ied2f50b3f87d40ef7fb0bbad0fff4cd0fd9bb8a9 --- Makefile | 1 + ground/openpilotgcs/openpilotgcs.pri | 4 +++- package/Linux.mk | 8 +++++--- package/linux/librepilot.spec | 8 ++------ 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index dd944fcd6..128d1e47c 100644 --- a/Makefile +++ b/Makefile @@ -477,6 +477,7 @@ openpilotgcs_qmake $(OPENPILOTGCS_MAKEFILE): | $(OPENPILOTGCS_DIR) -spec $(QT_SPEC) -r CONFIG+=$(GCS_BUILD_CONF) CONFIG+=$(GCS_SILENT) \ 'GCS_BIG_NAME="$(GCS_BIG_NAME)"' GCS_SMALL_NAME=$(GCS_SMALL_NAME) \ 'ORG_BIG_NAME="$(ORG_BIG_NAME)"' ORG_SMALL_NAME=$(ORG_SMALL_NAME) \ + 'GCS_LIBRARY_BASENAME=$(libbasename)' \ $(GCS_QMAKE_OPTS) .PHONY: openpilotgcs diff --git a/ground/openpilotgcs/openpilotgcs.pri b/ground/openpilotgcs/openpilotgcs.pri index 0e4f71141..bbe138e0f 100644 --- a/ground/openpilotgcs/openpilotgcs.pri +++ b/ground/openpilotgcs/openpilotgcs.pri @@ -140,6 +140,8 @@ isEmpty(ORG_BIG_NAME) { ORG_BIG_NAME = "$$ORG_BIG_NAME" } +isEmpty(GCS_LIBRARY_BASENAME):GCS_LIBRARY_BASENAME = lib + macx { GCS_APP_TARGET = $$GCS_BIG_NAME GCS_PATH = $$GCS_BUILD_TREE/$${GCS_APP_TARGET}.app/Contents @@ -155,7 +157,7 @@ macx { GCS_APP_TARGET = $$GCS_SMALL_NAME GCS_PATH = $$GCS_BUILD_TREE GCS_APP_PATH = $$GCS_PATH/bin - GCS_LIBRARY_PATH = $$GCS_PATH/lib/$$GCS_SMALL_NAME + GCS_LIBRARY_PATH = $$GCS_PATH/$$GCS_LIBRARY_BASENAME/$$GCS_SMALL_NAME GCS_PLUGIN_PATH = $$GCS_LIBRARY_PATH/plugins GCS_DATA_PATH = $$GCS_PATH/share/$$GCS_SMALL_NAME GCS_DOC_PATH = $$GCS_PATH/share/doc diff --git a/package/Linux.mk b/package/Linux.mk index 40b32bb23..3d61b329e 100644 --- a/package/Linux.mk +++ b/package/Linux.mk @@ -81,10 +81,12 @@ endif # Debian based distro? # Install Linux Target # ############################## -enable-udev-rules ?= no +enable-udev-rules := no + prefix := /usr/local bindir := $(prefix)/bin -libdir := $(prefix)/lib +libbasename := lib +libdir := $(prefix)/$(libbasename) datadir := $(prefix)/share udevrulesdir := /etc/udev/rules.d @@ -101,7 +103,7 @@ install: $(V1) $(MKDIR) -p $(DESTDIR)$(datadir)/applications $(V1) $(MKDIR) -p $(DESTDIR)$(datadir)/pixmaps $(V1) $(INSTALL) $(BUILD_DIR)/$(GCS_SMALL_NAME)_$(GCS_BUILD_CONF)/bin/$(GCS_SMALL_NAME) $(DESTDIR)$(bindir) - $(V1) $(INSTALL) $(BUILD_DIR)/$(GCS_SMALL_NAME)_$(GCS_BUILD_CONF)/lib/$(GCS_SMALL_NAME) $(DESTDIR)$(libdir) + $(V1) $(INSTALL) $(BUILD_DIR)/$(GCS_SMALL_NAME)_$(GCS_BUILD_CONF)/$(libbasename)/$(GCS_SMALL_NAME) $(DESTDIR)$(libdir) $(V1) $(INSTALL) $(BUILD_DIR)/$(GCS_SMALL_NAME)_$(GCS_BUILD_CONF)/share/$(GCS_SMALL_NAME) $(DESTDIR)$(datadir) $(V1) $(INSTALL) -T $(ROOT_DIR)/package/linux/gcs.desktop $(DESTDIR)$(datadir)/applications/$(ORG_SMALL_NAME).desktop $(V1) $(INSTALL) -T $(ROOT_DIR)/ground/openpilotgcs/src/plugins/coreplugin/images/$(ORG_SMALL_NAME)_logo_128.png \ diff --git a/package/linux/librepilot.spec b/package/linux/librepilot.spec index 1330fba42..5d653644e 100644 --- a/package/linux/librepilot.spec +++ b/package/linux/librepilot.spec @@ -52,13 +52,9 @@ and ease of use. %prep %setup -q -n %{name}-%{version}-%{gitrev} -# Fix hardcoded paths -sed -i 's!lib/$$GCS_SMALL_NAME!%{_lib}/$$GCS_SMALL_NAME!g' ground/openpilotgcs/openpilotgcs.pri -sed -i 's!lib/$(GCS_SMALL_NAME!%{_lib}/$(GCS_SMALL_NAME!g' package/Linux.mk - %build -make %{?_smp_mflags} gcs QMAKE=qmake-qt5 CC=%{__cc} CXX=%{__cxx} libdir=%{_libdir} +make %{?_smp_mflags} gcs QMAKE=qmake-qt5 CC=%{__cc} CXX=%{__cxx} libbasename=%{_lib} #make -j1 opfw_resource @@ -66,7 +62,7 @@ make %{?_smp_mflags} gcs QMAKE=qmake-qt5 CC=%{__cc} CXX=%{__cxx} libdir=%{_libdi rm -rf $RPM_BUILD_ROOT make install DESTDIR=$RPM_BUILD_ROOT \ prefix=%{_prefix} \ - libdir=%{_libdir} \ + libbasename=%{_lib} \ enable-udev-rules=yes \ udevrulesdir=%{_udevrulesdir}