Populate INCLUDE_DIRS with some likely candidates.

Implement __EXPORT and such for modules, as well as symbol visibility.

Don't use UNZIP to point to unzip, as it looks there for arguments.
This commit is contained in:
px4dev 2013-04-06 00:51:59 -07:00
parent 2e5809d051
commit 8b9b41fd50
4 changed files with 103 additions and 17 deletions

View File

@ -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.
#
#
@ -98,11 +104,6 @@ $(error No module makefile specified)
endif
$(info % MODULE_MK = $(MODULE_MK))
#
# Get path and tool config
#
include $(PX4_BASE)/makefiles/setup.mk
#
# Get the board/toolchain config
#
@ -150,6 +151,19 @@ $(MODULE_COMMAND_FILES): $(GLOBAL_DEPS)
$(Q) $(TOUCH) $@
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
################################################################################

View File

@ -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) $@

View File

@ -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)/
@ -51,24 +52,33 @@ export IMAGE_DIR = $(abspath $(PX4_BASE)/Images)/
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.

62
src/include/visibility.h Normal file
View File

@ -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