1LOCAL_PATH:= $(call my-dir)
2
3common_src_files := \
4	src/assertion.c \
5	src/avrule_block.c \
6	src/avtab.c \
7	src/boolean_record.c \
8	src/booleans.c \
9	src/conditional.c \
10	src/constraint.c \
11	src/context.c \
12	src/context_record.c \
13	src/debug.c \
14	src/ebitmap.c \
15	src/expand.c \
16	src/genbools.c \
17	src/genusers.c \
18	src/handle.c \
19	src/hashtab.c \
20	src/hierarchy.c \
21	src/iface_record.c \
22	src/interfaces.c \
23	src/link.c \
24	src/mls.c \
25	src/module.c \
26	src/module_to_cil.c \
27	src/node_record.c \
28	src/nodes.c \
29	src/polcaps.c \
30	src/policydb.c \
31	src/policydb_convert.c \
32	src/policydb_public.c \
33	src/port_record.c \
34	src/ports.c \
35	src/roles.c \
36	src/services.c \
37	src/sidtab.c \
38	src/symtab.c \
39	src/user_record.c \
40	src/users.c \
41	src/util.c \
42	src/write.c
43
44cil_src_files := \
45	cil/src/cil_binary.c \
46	cil/src/cil_build_ast.c \
47	cil/src/cil.c \
48	cil/src/cil_copy_ast.c \
49	cil/src/cil_fqn.c \
50	cil/src/cil_lexer.l \
51	cil/src/cil_list.c \
52	cil/src/cil_log.c \
53	cil/src/cil_mem.c \
54	cil/src/cil_parser.c \
55	cil/src/cil_policy.c \
56	cil/src/cil_post.c \
57	cil/src/cil_reset_ast.c \
58	cil/src/cil_resolve_ast.c \
59	cil/src/cil_stack.c \
60	cil/src/cil_strpool.c \
61	cil/src/cil_symtab.c \
62	cil/src/cil_tree.c \
63	cil/src/cil_verify.c
64
65common_cflags := \
66	-Wall -W -Wundef \
67	-Wshadow -Wmissing-noreturn \
68	-Wmissing-format-attribute
69
70ifeq ($(HOST_OS), darwin)
71common_cflags += -DDARWIN
72endif
73
74common_includes := \
75	$(LOCAL_PATH)/include/ \
76	$(LOCAL_PATH)/src/ \
77	$(LOCAL_PATH)/cil/include/ \
78	$(LOCAL_PATH)/cil/src/ \
79
80##
81# "-x c" forces the lex/yacc files to be compiled as c the build system
82# otherwise forces them to be c++. Need to also add an explicit -std because the
83# build system will soon default C++ to -std=c++11.
84yacc_flags := -x c -std=gnu89
85
86##
87# libsepol.so
88#
89include $(CLEAR_VARS)
90
91LOCAL_MODULE := libsepol
92LOCAL_MODULE_TAGS := optional
93LOCAL_COPY_HEADERS_TO := sepol
94LOCAL_COPY_HEADERS := include/sepol/handle.h include/sepol/policydb.h cil/include/cil/cil.h
95LOCAL_C_INCLUDES := $(common_includes)
96LOCAL_CFLAGS := $(yacc_flags) $(common_cflags)
97LOCAL_SRC_FILES := $(common_src_files) $(cil_src_files)
98LOCAL_MODULE_CLASS := SHARED_LIBRARIES
99
100include $(BUILD_HOST_SHARED_LIBRARY)
101
102##
103# libsepol.a
104#
105include $(CLEAR_VARS)
106
107LOCAL_MODULE := libsepol
108LOCAL_MODULE_TAGS := optional
109LOCAL_C_INCLUDES := $(common_includes)
110LOCAL_CFLAGS := $(yacc_flags) $(common_cflags)
111LOCAL_SRC_FILES := $(common_src_files) $(cil_src_files)
112LOCAL_MODULE_CLASS := STATIC_LIBRARIES
113
114include $(BUILD_HOST_STATIC_LIBRARY)
115
116##
117# chkcon
118#
119include $(CLEAR_VARS)
120
121LOCAL_MODULE := chkcon
122LOCAL_MODULE_TAGS := optional
123LOCAL_C_INCLUDES := $(common_includes)
124LOCAL_CFLAGS := $(common_cflags)
125LOCAL_SRC_FILES := utils/chkcon.c
126LOCAL_SHARED_LIBRARIES := libsepol
127LOCAL_MODULE_CLASS := EXECUTABLES
128
129include $(BUILD_HOST_EXECUTABLE)
130
131include $(CLEAR_VARS)
132
133LOCAL_MODULE := libsepol
134LOCAL_MODULE_TAGES := optional
135LOCAL_C_INCLUDES := $(common_includes)
136LOCAL_CFLAGS := $(common_cflags)
137LOCAL_SRC_FILES := $(common_src_files)
138LOCAL_MODULE_CLASS := STATIC_LIBRARIES
139
140include $(BUILD_STATIC_LIBRARY)
141