Commits

Stephen Smalley committed 3fab9cd

Support for building on MacOS X as part of Android.

Comments (0)

Files changed (5)

+LOCAL_PATH:= $(call my-dir)
+
+common_src_files := \
+	policy_parse.y \
+	policy_scan.l \
+	queue.c \
+	module_compiler.c \
+	parse_util.c \
+	policy_define.c
+
+common_cflags := \
+	-Wall -Wshadow -O2 \
+	-pipe -fno-strict-aliasing \
+	-Wno-return-type
+
+ifeq ($(HOST_OS),darwin)
+common_cflags += -DDARWIN
+endif
+
+common_includes := \
+	$(LOCAL_PATH)/ \
+	$(LOCAL_PATH)/../libsepol/include/ \
+	$(LOCAL_PATH)/../libsepol/src/ \
+
+##
+# "-x c" forces the lex/yacc files to be compiled as c
+# the build system otherwise forces them to be c++
+yacc_flags := -x c
+
+
+##
+# checkpolicy
+#
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := checkpolicy
+LOCAL_MODULE_TAGS := optional
+LOCAL_C_INCLUDES := $(common_includes) 
+LOCAL_CFLAGS := $(yacc_flags) $(common_cflags)
+LOCAL_SRC_FILES := $(common_src_files) checkpolicy.c
+LOCAL_STATIC_LIBRARIES := libsepol
+LOCAL_YACCFLAGS := -v
+LOCAL_MODULE_CLASS := EXECUTABLES
+
+include $(BUILD_HOST_EXECUTABLE)
+
+
+##
+# checkmodule
+#
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := checkmodule
+LOCAL_MODULE_TAGS := optional
+LOCAL_C_INCLUDES := $(common_includes) 
+LOCAL_CFLAGS := $(yacc_flags) $(common_cflags)
+LOCAL_SRC_FILES := $(common_src_files) checkmodule.c
+LOCAL_STATIC_LIBRARIES := libsepol
+LOCAL_YACCFLAGS := -v
+LOCAL_MODULE_CLASS := EXECUTABLES
+
+include $(BUILD_HOST_EXECUTABLE)
 #include <errno.h>
 #include <sys/mman.h>
 
+#ifdef DARWIN
+#include <ctype.h>
+#endif
+
 #include <sepol/policydb/policydb.h>
 #include <sepol/policydb/services.h>
 #include <sepol/policydb/conditional.h>
 	}
 
 	memset(newc, 0, sizeof(ocontext_t));
+
+#ifdef DARWIN
+	memcpy(&newc->u.node6.addr[0], &addr.s6_addr[0], 16);
+	memcpy(&newc->u.node6.mask[0], &mask.s6_addr[0], 16);
+#else
 	memcpy(&newc->u.node6.addr[0], &addr.s6_addr32[0], 16);
 	memcpy(&newc->u.node6.mask[0], &mask.s6_addr32[0], 16);
+#endif
 
 	if (parse_security_context(&newc->context[0])) {
 		free(newc);
 
 typedef int (* require_func_t)();
 
+#ifdef ANDROID
+#include "policy_parse.h"
+#else
 #include "y.tab.h"
+#endif
 
 static char linebuf[2][255];
 static unsigned int lno = 0;
 unsigned int policydb_errors = 0;
 %}
 
-%option noinput nounput
+%option noinput nounput noyywrap
 
 %array
 letter  [A-Za-z]