From patchwork Mon Oct 17 20:24:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Roberts, William C" X-Patchwork-Id: 9380517 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 51617600CA for ; Mon, 17 Oct 2016 20:29:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4447228F34 for ; Mon, 17 Oct 2016 20:29:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 38E6B28F41; Mon, 17 Oct 2016 20:29:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from emsm-gh1-uea11.nsa.gov (emsm-gh1-uea11.nsa.gov [8.44.101.9]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44B2628F34 for ; Mon, 17 Oct 2016 20:29:37 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.31,358,1473120000"; d="scan'208";a="20138057" IronPort-PHdr: =?us-ascii?q?9a23=3AFUbM9RwINiCxg5zXCy+O+j09IxM/srCxBDY+r6Qd?= =?us-ascii?q?0eMUIJqq85mqBkHD//Il1AaPBtSBra8ewLON4ujJYi8p2d65qncMcZhBBVcuqP?= =?us-ascii?q?49uEgeOvODElDxN/XwbiY3T4xoXV5h+GynYwAOQJ6tL2PbrnD61zMOABK3bVMz?= =?us-ascii?q?fbWvXNOIxJ3shqibwN76W01wnj2zYLd/fl2djD76kY0ou7ZkMbs70RDTo3FFKK?= =?us-ascii?q?x8zGJsIk+PzV6nvp/jtKN592xsn95pt4sZCeSpN5g/GKdVCDUgLnAd+NzgtR6F?= =?us-ascii?q?SxCGoHQbTCFeiRdBBQTf6xD2G5PwqTfSqvt22C7cO9b/C78zR3Dq9KtwYAP5gy?= =?us-ascii?q?cAcTgi+SfYjdIjorhcpUe+phh7wofRJorTLv10c7nBZvsbQ3ZMWoBaUCkSUcuH?= =?us-ascii?q?c4ITAr9Zbq5jpI7nqg5L9EOz?= X-IPAS-Result: =?us-ascii?q?A2GvBgAtNAVY/wHyM5BbGwEBAQMBAQEJAQEBFwEBBAEBCgE?= =?us-ascii?q?BgxEBAQEBAR2BU6Q6gVuUXiSHdEwBAQEBAQEBAQIBAlsngjIEAxMFghECBAECN?= =?us-ascii?q?xQgDgMJAQEXCCEICAMBLRURBwcLBRgEiDHCSgwBJYhChmkRAYV7BYg8kUqQBAK?= =?us-ascii?q?JfoV1SZAyVIVbVgGGYHiBKAEBAQ?= Received: from unknown (HELO tarius.tycho.ncsc.mil) ([144.51.242.1]) by emsm-gh1-uea11.nsa.gov with ESMTP; 17 Oct 2016 20:29:17 +0000 Received: from prometheus.infosec.tycho.ncsc.mil (prometheus [192.168.25.40]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id u9HKTFNm001275; Mon, 17 Oct 2016 16:29:16 -0400 Received: from tarius.tycho.ncsc.mil (tarius.infosec.tycho.ncsc.mil [144.51.242.1]) by prometheus.infosec.tycho.ncsc.mil (8.15.2/8.15.2) with ESMTP id u9HKOwCW165477 for ; Mon, 17 Oct 2016 16:24:58 -0400 Received: from goalie.tycho.ncsc.mil (goalie [144.51.242.250]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id u9HKOuRb032743; Mon, 17 Oct 2016 16:24:57 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A1DuBQC1MgVY/yNjr8ZbGgEBAQECAQEBAQgBAQEBgzwBAQEBAR2BU6Q6kimEF4Ixg3ECgW1MAQIBAQEBAQJehQkCBHkQIDFXBxKIUsJIAQEBAQYCJohCjHYFiDyRSpAEAo9zSZAyVIVbIjQBiQABAQE X-IPAS-Result: A1DuBQC1MgVY/yNjr8ZbGgEBAQECAQEBAQgBAQEBgzwBAQEBAR2BU6Q6kimEF4Ixg3ECgW1MAQIBAQEBAQJehQkCBHkQIDFXBxKIUsJIAQEBAQYCJohCjHYFiDyRSpAEAo9zSZAyVIVbIjQBiQABAQE X-IronPort-AV: E=Sophos;i="5.31,358,1473134400"; d="scan'208";a="5767608" Received: from emsm-gh1-uea11.corp.nsa.gov (HELO emsm-gh1-uea11.nsa.gov) ([10.208.41.37]) by goalie.tycho.ncsc.mil with ESMTP; 17 Oct 2016 16:24:56 -0400 IronPort-PHdr: =?us-ascii?q?9a23=3AznUOxRMp4NIqKjrEY3Al6mtUPXoX/o7sNwtQ0KIM?= =?us-ascii?q?zox0Kf38rarrMEGX3/hxlliBBdydsKMezbeM+Pm7CCQp2tWoiDg6aptCVhsI24?= =?us-ascii?q?09vjcLJ4q7M3D9N+PgdCcgHc5PBxdP9nC/NlVJSo6lPwWB6kO74TNaIBjjLw09?= =?us-ascii?q?fr2zQd+IyZntnLnpqtX6WEZhvHKFe7R8LRG7/036l/I9ps9cEJs30QbDuXBSeu?= =?us-ascii?q?5blitCLFOXmAvgtI/rpMYwuwwZgf8q9tZBXKPmZOx4COUAVHV1BVsy/tHmuSPO?= =?us-ascii?q?RgqXvDNcDj1XwVJ0BF3e4RX7WIrhmjfrvep6ni+BNIv5Sq5wES+v5qFnUhjphG?= =?us-ascii?q?IDNiUl2H3Ggcx3yqRAqVSuoAI7i5XYe6mJJfF+eeXbZtpcSm1fDehLUCkUHYK4?= =?us-ascii?q?a4oGCqwKe/xfpYTnu0AmrB2iCA3qD+TqmWwAvWP/waBvi7dpKgrBxgF1WoxWvQ?= =?us-ascii?q?=3D=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0G1BQAxMwVY/yNjr8ZbGgEBAQECAQEBA?= =?us-ascii?q?QgBAQEBFgEBAQMBAQEJAQEBgxEBAQEBAR2BU6Q6gVuQToQXhiICgW1MAQEBAQE?= =?us-ascii?q?BAQECAQJbJ4IyBAEVBYIRAgR5ECAxVwcSiFLCSAEBAQEGAgEliEKMdgWIPJFKk?= =?us-ascii?q?AQCj3NJkDJUhVsiNAGHP4FBAQEB?= X-IPAS-Result: =?us-ascii?q?A0G1BQAxMwVY/yNjr8ZbGgEBAQECAQEBAQgBAQEBFgEBAQM?= =?us-ascii?q?BAQEJAQEBgxEBAQEBAR2BU6Q6gVuQToQXhiICgW1MAQEBAQEBAQECAQJbJ4IyB?= =?us-ascii?q?AEVBYIRAgR5ECAxVwcSiFLCSAEBAQEGAgEliEKMdgWIPJFKkAQCj3NJkDJUhVs?= =?us-ascii?q?iNAGHP4FBAQEB?= X-IronPort-AV: E=Sophos;i="5.31,358,1473120000"; d="scan'208";a="20137876" Received: from fmsmga002-icc.fm.intel.com ([198.175.99.35]) by emsm-gh1-uea11.nsa.gov with ESMTP; 17 Oct 2016 20:24:51 +0000 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga002-icc.fm.intel.com with ESMTP; 17 Oct 2016 13:24:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.31,358,1473145200"; d="scan'208"; a="1046007570" Received: from mcohen2-mobl.amr.corp.intel.com (HELO wcrobert-MOBL1.amr.corp.intel.com) ([10.254.186.130]) by orsmga001.jf.intel.com with ESMTP; 17 Oct 2016 13:24:50 -0700 From: william.c.roberts@intel.com To: selinux@tycho.nsa.gov, seandroid-list@tycho.nsa.gov, sds@tycho.nsa.gov Subject: [PATCH 6/8] libselinux: support ANDROID_HOST=1 on Mac Date: Mon, 17 Oct 2016 16:24:08 -0400 Message-Id: <1476735850-7844-6-git-send-email-william.c.roberts@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1476735850-7844-1-git-send-email-william.c.roberts@intel.com> References: <1476735850-7844-1-git-send-email-william.c.roberts@intel.com> X-BeenThere: selinux@tycho.nsa.gov X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Security-Enhanced Linux \(SELinux\) mailing list" List-Post: List-Help: MIME-Version: 1.0 Errors-To: selinux-bounces@tycho.nsa.gov Sender: "Selinux" X-Virus-Scanned: ClamAV using ClamSMTP From: William Roberts To build on mac, first build libsepol with DISABLE_CIL=y and no DESTDIR set. Secondly, build libselinux with ANDROID_HOST=y This configuration can be used to test the Android host build on Mac. Signed-off-by: William Roberts --- libselinux/Makefile | 10 ++++++++++ libselinux/src/Makefile | 36 ++++++++++++++++++++++++++---------- libselinux/utils/Makefile | 29 +++++++++++++++++++++-------- 3 files changed, 57 insertions(+), 18 deletions(-) diff --git a/libselinux/Makefile b/libselinux/Makefile index baa0db3..ef971f4 100644 --- a/libselinux/Makefile +++ b/libselinux/Makefile @@ -27,6 +27,16 @@ else endif export PCRE_CFLAGS PCRE_LDFLAGS +OS := $(shell uname) +export OS + +ifeq ($(shell $(CC) -v 2>&1 | grep "clang"),) +COMPILER := gcc +else +COMPILER := clang +endif +export COMPILER + all install relabel clean distclean indent: @for subdir in $(SUBDIRS); do \ (cd $$subdir && $(MAKE) $@) || exit 1; \ diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile index 13501cd..7a1ae05 100644 --- a/libselinux/src/Makefile +++ b/libselinux/src/Makefile @@ -48,23 +48,39 @@ OBJS= $(patsubst %.c,%.o,$(SRCS)) LOBJS= $(patsubst %.c,%.lo,$(SRCS)) CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k -Wformat-security -Winit-self -Wmissing-include-dirs \ -Wunused -Wunknown-pragmas -Wstrict-aliasing -Wshadow -Wpointer-arith \ - -Wbad-function-cast -Wcast-align -Wwrite-strings -Wlogical-op -Waggregate-return \ + -Wbad-function-cast -Wcast-align -Wwrite-strings -Waggregate-return \ -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes \ -Wmissing-declarations -Wmissing-noreturn -Wmissing-format-attribute \ -Wredundant-decls -Wnested-externs -Winline -Winvalid-pch -Wvolatile-register-var \ - -Wdisabled-optimization -Wbuiltin-macro-redefined -Wpacked-bitfield-compat \ - -Wsync-nand -Wattributes -Wcoverage-mismatch -Wmultichar -Wcpp \ + -Wdisabled-optimization -Wbuiltin-macro-redefined \ + -Wattributes -Wmultichar \ -Wdeprecated-declarations -Wdiv-by-zero -Wdouble-promotion -Wendif-labels -Wextra \ - -Wformat-contains-nul -Wformat-extra-args -Wformat-zero-length -Wformat=2 -Wmultichar \ - -Wnormalized=nfc -Woverflow -Wpointer-to-int-cast -Wpragmas -Wsuggest-attribute=const \ - -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wtrampolines \ - -Wno-missing-field-initializers -Wno-sign-compare -Wjump-misses-init \ - -Wno-format-nonliteral -Wframe-larger-than=$(MAX_STACK_SIZE) -Wp,-D_FORTIFY_SOURCE=2 \ + -Wformat-extra-args -Wformat-zero-length -Wformat=2 -Wmultichar \ + -Woverflow -Wpointer-to-int-cast -Wpragmas \ + -Wno-missing-field-initializers -Wno-sign-compare \ + -Wno-format-nonliteral -Wframe-larger-than=$(MAX_STACK_SIZE) \ -fstack-protector-all --param=ssp-buffer-size=4 -fexceptions \ -fasynchronous-unwind-tables -fdiagnostics-show-option -funit-at-a-time \ - -fipa-pure-const -Wno-suggest-attribute=pure -Wno-suggest-attribute=const \ -Werror -Wno-aggregate-return -Wno-redundant-decls +LD_SONAME_FLAGS=-soname,$(LIBSO),-z,defs,-z,relro + +ifeq ($(COMPILER), gcc) +override CFLAGS += -fipa-pure-const -Wlogical-op -Wpacked-bitfield-compat -Wsync-nand \ + -Wcoverage-mismatch -Wcpp -Wformat-contains-nul -Wnormalized=nfc -Wsuggest-attribute=const \ + -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wtrampolines -Wjump-misses-init \ + -Wno-suggest-attribute=pure -Wno-suggest-attribute=const -Wp,-D_FORTIFY_SOURCE=2 +else +override CFLAGS += -Wunused-command-line-argument +override LDFLAGS += -L/opt/local/lib -undefined dynamic_lookup +LD_SONAME_FLAGS=-install_name,$(LIBSO) +endif + +ifeq ($(OS), Darwin) +override CFLAGS += -I/opt/local/include +override LDFLAGS += -L/opt/local/lib -undefined dynamic_lookup +endif + PCRE_LDFLAGS ?= -lpcre override CFLAGS += -I../include -I$(INCLUDEDIR) -D_GNU_SOURCE $(DISABLE_FLAGS) $(PCRE_CFLAGS) @@ -117,7 +133,7 @@ $(LIBA): $(OBJS) $(RANLIB) $@ $(LIBSO): $(LOBJS) - $(CC) $(CFLAGS) -shared -o $@ $^ $(PCRE_LDFLAGS) -ldl $(LDFLAGS) -L$(LIBDIR) -Wl,-soname,$(LIBSO),-z,defs,-z,relro + $(CC) $(CFLAGS) -shared -o $@ $^ $(PCRE_LDFLAGS) -ldl $(LDFLAGS) -L$(LIBDIR) -Wl,$(LD_SONAME_FLAGS) ln -sf $@ $(TARGET) $(LIBPC): $(LIBPC).in ../VERSION diff --git a/libselinux/utils/Makefile b/libselinux/utils/Makefile index e56a953..a4f9903 100644 --- a/libselinux/utils/Makefile +++ b/libselinux/utils/Makefile @@ -8,22 +8,35 @@ INCLUDEDIR ?= $(PREFIX)/include MAX_STACK_SIZE=8192 CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k -Wformat-security -Winit-self -Wmissing-include-dirs \ -Wunused -Wunknown-pragmas -Wstrict-aliasing -Wshadow -Wpointer-arith \ - -Wbad-function-cast -Wcast-align -Wwrite-strings -Wlogical-op -Waggregate-return \ + -Wbad-function-cast -Wcast-align -Wwrite-strings -Waggregate-return \ -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes \ -Wmissing-declarations -Wmissing-noreturn -Wmissing-format-attribute \ -Wredundant-decls -Wnested-externs -Winline -Winvalid-pch -Wvolatile-register-var \ - -Wdisabled-optimization -Wbuiltin-macro-redefined -Wpacked-bitfield-compat \ - -Wsync-nand -Wattributes -Wcoverage-mismatch -Wmultichar -Wcpp \ + -Wdisabled-optimization -Wbuiltin-macro-redefined \ + -Wattributes -Wmultichar \ -Wdeprecated-declarations -Wdiv-by-zero -Wdouble-promotion -Wendif-labels -Wextra \ - -Wformat-contains-nul -Wformat-extra-args -Wformat-zero-length -Wformat=2 -Wmultichar \ - -Wnormalized=nfc -Woverflow -Wpointer-to-int-cast -Wpragmas -Wsuggest-attribute=const \ - -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wtrampolines \ - -Wno-missing-field-initializers -Wno-sign-compare -Wjump-misses-init \ + -Wformat-extra-args -Wformat-zero-length -Wformat=2 -Wmultichar \ + -Woverflow -Wpointer-to-int-cast -Wpragmas \ + -Wno-missing-field-initializers -Wno-sign-compare \ -Wno-format-nonliteral -Wframe-larger-than=$(MAX_STACK_SIZE) -Wp,-D_FORTIFY_SOURCE=2 \ -fstack-protector-all --param=ssp-buffer-size=4 -fexceptions \ -fasynchronous-unwind-tables -fdiagnostics-show-option -funit-at-a-time \ - -fipa-pure-const -Wno-suggest-attribute=pure -Wno-suggest-attribute=const \ -Werror -Wno-aggregate-return -Wno-redundant-decls + +LD_SONAME_FLAGS=-soname,$(LIBSO),-z,defs,-z,relro + +ifeq ($(COMPILER), gcc) +override CFLAGS += -fipa-pure-const -Wpacked-bitfield-compat -Wsync-nand -Wcoverage-mismatch \ + -Wcpp -Wformat-contains-nul -Wnormalized=nfc -Wsuggest-attribute=const \ + -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wtrampolines -Wjump-misses-init \ + -Wno-suggest-attribute=pure -Wno-suggest-attribute=const +endif + +ifeq ($(OS), Darwin) +override CFLAGS += -I/opt/local/include -I../../libsepol/include +override LDFLAGS += -L../../libsepol/src -undefined dynamic_lookup +endif + override CFLAGS += -I../include -I$(INCLUDEDIR) -D_GNU_SOURCE $(DISABLE_FLAGS) $(PCRE_CFLAGS) LDLIBS += -L../src -lselinux -L$(LIBDIR) PCRE_LDFLAGS ?= -lpcre