aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--makefiles/module.mk24
-rw-r--r--makefiles/nuttx.mk2
-rw-r--r--makefiles/setup.mk32
-rw-r--r--src/include/visibility.h62
4 files changed, 103 insertions, 17 deletions
diff --git a/makefiles/module.mk b/makefiles/module.mk
index 8b01d0a12..154d37cc2 100644
--- a/makefiles/module.mk
+++ b/makefiles/module.mk
@@ -75,6 +75,12 @@
# the list should be formatted as:
# <command>.<priority>.<stacksize>.<entrypoint>
#
+# DEFAULT_VISIBILITY (optional)
+#
+# If not set, global symbols defined in a module will not be visible
+# outside the module. Symbols that should be globally visible must be
+# marked __EXPORT.
+# If set, global symbols defined in a module will be globally visible.
#
#
@@ -99,11 +105,6 @@ endif
$(info % MODULE_MK = $(MODULE_MK))
#
-# Get path and tool config
-#
-include $(PX4_BASE)/makefiles/setup.mk
-
-#
# Get the board/toolchain config
#
include $(PX4_MK_DIR)/board_$(BOARD).mk
@@ -151,6 +152,19 @@ $(MODULE_COMMAND_FILES): $(GLOBAL_DEPS)
endif
################################################################################
+# Adjust compilation flags to implement EXPORT
+################################################################################
+
+ifeq ($(DEFAULT_VISIBILITY),)
+DEFAULT_VISIBILITY = hidden
+else
+DEFAULT_VISIBILITY = default
+endif
+
+CFLAGS += -fvisibility=$(DEFAULT_VISIBILITY) -include $(PX4_INCLUDE_DIR)visibility.h
+CXXFLAGS += -fvisibility=$(DEFAULT_VISIBILITY) -include $(PX4_INCLUDE_DIR)visibility.h
+
+################################################################################
# Build rules
################################################################################
diff --git a/makefiles/nuttx.mk b/makefiles/nuttx.mk
index c6e2c86d1..e86f1370b 100644
--- a/makefiles/nuttx.mk
+++ b/makefiles/nuttx.mk
@@ -71,5 +71,5 @@ LINK_DEPS += $(NUTTX_EXPORT_DIR)libs/libapps.a \
$(NUTTX_CONFIG_HEADER): $(NUTTX_ARCHIVE)
@$(ECHO) %% Unpacking $(NUTTX_ARCHIVE)
- $(Q) $(UNZIP) -q -o -d $(WORK_DIR) $(NUTTX_ARCHIVE)
+ $(Q) $(UNZIP_CMD) -q -o -d $(WORK_DIR) $(NUTTX_ARCHIVE)
$(Q) $(TOUCH) $@
diff --git a/makefiles/setup.mk b/makefiles/setup.mk
index 8e7a00ef4..7655872e5 100644
--- a/makefiles/setup.mk
+++ b/makefiles/setup.mk
@@ -41,6 +41,7 @@
# the number of duplicate slashes we have lying around in paths,
# and is consistent with joining the results of $(dir) and $(notdir).
#
+export PX4_INCLUDE_DIR = $(abspath $(PX4_BASE)/src/include)/
export PX4_MODULE_SRC = $(abspath $(PX4_BASE)/src/modules)/
export PX4_MK_DIR = $(abspath $(PX4_BASE)/makefiles)/
export NUTTX_SRC = $(abspath $(PX4_BASE)/nuttx)/
@@ -52,23 +53,32 @@ export BUILD_DIR = $(abspath $(PX4_BASE)/Build)/
export ARCHIVE_DIR = $(abspath $(PX4_BASE)/Archives)/
#
+# Default include paths
+#
+export INCLUDE_DIRS := $(PX4_MODULE_SRC) \
+ $(PX4_INCLUDE_DIR)
+
+# Include from legacy app/library path
+export INCLUDE_DIRS += $(NUTTX_APP_SRC)
+
+#
# Tools
#
-MKFW = $(PX4_BASE)/Tools/px_mkfw.py
-UPLOADER = $(PX4_BASE)/Tools/px_uploader.py
-COPY = cp
-REMOVE = rm -f
-RMDIR = rm -rf
-GENROMFS = genromfs
-TOUCH = touch
-MKDIR = mkdir
-ECHO = echo
-UNZIP = unzip
+export MKFW = $(PX4_BASE)/Tools/px_mkfw.py
+export UPLOADER = $(PX4_BASE)/Tools/px_uploader.py
+export COPY = cp
+export REMOVE = rm -f
+export RMDIR = rm -rf
+export GENROMFS = genromfs
+export TOUCH = touch
+export MKDIR = mkdir
+export ECHO = echo
+export UNZIP_CMD = unzip
#
# Host-specific paths, hacks and fixups
#
-SYSTYPE := $(shell uname -s)
+export SYSTYPE := $(shell uname -s)
ifeq ($(SYSTYPE),Darwin)
# Eclipse may not have the toolchain on its path.
diff --git a/src/include/visibility.h b/src/include/visibility.h
new file mode 100644
index 000000000..2c6adc062
--- /dev/null
+++ b/src/include/visibility.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+ *
+ * Copyright (C) 2012 PX4 Development Team. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name PX4 nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/**
+ * @file visibility.h
+ *
+ * Definitions controlling symbol naming and visibility.
+ *
+ * This file is normally included automatically by the build system.
+ */
+
+#ifndef __SYSTEMLIB_VISIBILITY_H
+#define __SYSTEMLIB_VISIBILITY_H
+
+#ifdef __EXPORT
+# undef __EXPORT
+#endif
+#define __EXPORT __attribute__ ((visibility ("default")))
+
+#ifdef __PRIVATE
+# undef __PRIVATE
+#endif
+#define __PRIVATE __attribute__ ((visibility ("hidden")))
+
+#ifdef __cplusplus
+# define __BEGIN_DECLS extern "C" {
+# define __END_DECLS }
+#else
+# define __BEGIN_DECLS
+# define __END_DECLS
+#endif
+#endif \ No newline at end of file