summaryrefslogtreecommitdiffstats
path: root/libfdisk/src/Makemodule.am
blob: 073d57158dd3a73ae5db9f9ed3740a991abd38a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# libfdisk.h is generated, so it's stored in builddir!
fdiskincdir = $(includedir)/libfdisk
nodist_fdiskinc_HEADERS = libfdisk/src/libfdisk.h

usrlib_exec_LTLIBRARIES += libfdisk.la
libfdisk_la_SOURCES = \
	include/list.h \
	\
	libfdisk/src/fdiskP.h \
	libfdisk/src/init.c \
	libfdisk/src/field.c \
	libfdisk/src/item.c \
	libfdisk/src/test.c \
	libfdisk/src/ask.c \
	libfdisk/src/alignment.c \
	libfdisk/src/label.c \
	libfdisk/src/utils.c \
	libfdisk/src/context.c \
	libfdisk/src/parttype.c \
	libfdisk/src/partition.c \
	libfdisk/src/table.c \
	libfdisk/src/iter.c \
	libfdisk/src/script.c \
	libfdisk/src/version.c \
	libfdisk/src/wipe.c \
	\
	libfdisk/src/sun.c \
	libfdisk/src/sgi.c \
	libfdisk/src/dos.c \
	libfdisk/src/bsd.c \
	libfdisk/src/gpt.c

libfdisk_la_LIBADD = libcommon.la libuuid.la

libfdisk_la_CFLAGS = \
	$(AM_CFLAGS) \
	$(SOLIB_CFLAGS) \
	-I$(ul_libuuid_incdir) \
	-I$(ul_libfdisk_incdir) \
	-I$(top_srcdir)/libfdisk/src

EXTRA_libfdisk_la_DEPENDENCIES = \
	libfdisk/src/libfdisk.sym

libfdisk_la_LDFLAGS = $(SOLIB_LDFLAGS)
if HAVE_VSCRIPT
libfdisk_la_LDFLAGS += $(VSCRIPT_LDFLAGS),$(top_srcdir)/libfdisk/src/libfdisk.sym
endif
libfdisk_la_LDFLAGS += -version-info $(LIBFDISK_VERSION_INFO)


if BUILD_LIBBLKID
libfdisk_la_LIBADD += libblkid.la
libfdisk_la_CFLAGS += -I$(ul_libblkid_incdir)
endif

EXTRA_DIST += \
	libfdisk/src/libfdisk.sym

if BUILD_LIBFDISK_TESTS
check_PROGRAMS += \
	test_fdisk_ask \
	test_fdisk_gpt \
	test_fdisk_script \
	test_fdisk_utils \
	test_fdisk_version \
	test_fdisk_item

libfdisk_tests_cflags  = -DTEST_PROGRAM $(libfdisk_la_CFLAGS)
libfdisk_tests_ldflags = libuuid.la -static
libfdisk_tests_ldadd   = libfdisk.la $(LDADD)

if BUILD_LIBBLKID
libfdisk_tests_ldflags += libblkid.la
endif

test_fdisk_ask_SOURCES = libfdisk/src/ask.c
test_fdisk_ask_CFLAGS = $(libfdisk_tests_cflags)
test_fdisk_ask_LDFLAGS = $(libfdisk_tests_ldflags)
test_fdisk_ask_LDADD = $(libfdisk_tests_ldadd)

test_fdisk_gpt_SOURCES = libfdisk/src/gpt.c
test_fdisk_gpt_CFLAGS = $(libfdisk_tests_cflags)
test_fdisk_gpt_LDFLAGS = $(libfdisk_tests_ldflags)
test_fdisk_gpt_LDADD = $(libfdisk_tests_ldadd)

test_fdisk_utils_SOURCES = libfdisk/src/utils.c
test_fdisk_utils_CFLAGS = $(libfdisk_tests_cflags)
test_fdisk_utils_LDFLAGS = $(libfdisk_tests_ldflags)
test_fdisk_utils_LDADD = $(libfdisk_tests_ldadd)

test_fdisk_script_SOURCES = libfdisk/src/script.c
test_fdisk_script_CFLAGS = $(libfdisk_tests_cflags)
test_fdisk_script_LDFLAGS = $(libfdisk_tests_ldflags)
test_fdisk_script_LDADD = $(libfdisk_tests_ldadd)

if FUZZING_ENGINE
check_PROGRAMS += test_fdisk_script_fuzz

# https://google.github.io/oss-fuzz/getting-started/new-project-guide/#Requirements
nodist_EXTRA_test_fdisk_script_fuzz_SOURCES = dummy.cxx

test_fdisk_script_fuzz_SOURCES = libfdisk/src/script.c
test_fdisk_script_fuzz_CFLAGS = -DFUZZ_TARGET $(libfdisk_la_CFLAGS)
test_fdisk_script_fuzz_LDFLAGS = $(libfdisk_tests_ldflags) -lpthread
test_fdisk_script_fuzz_LDADD = $(libfdisk_tests_ldadd) $(LIB_FUZZING_ENGINE)
endif

test_fdisk_version_SOURCES = libfdisk/src/version.c
test_fdisk_version_CFLAGS = $(libfdisk_tests_cflags)
test_fdisk_version_LDFLAGS = $(libfdisk_tests_ldflags)
test_fdisk_version_LDADD = $(libfdisk_tests_ldadd)

test_fdisk_item_SOURCES = libfdisk/src/item.c
test_fdisk_item_CFLAGS = $(libfdisk_tests_cflags)
test_fdisk_item_LDFLAGS = $(libfdisk_tests_ldflags)
test_fdisk_item_LDADD = $(libfdisk_tests_ldadd)

endif # BUILD_LIBFDISK_TESTS


# move lib from $(usrlib_execdir) to $(libdir) if needed
install-exec-hook-libfdisk:
	if test "$(usrlib_execdir)" != "$(libdir)" -a -f "$(DESTDIR)$(usrlib_execdir)/libfdisk.so"; then \
		$(MKDIR_P) $(DESTDIR)$(libdir); \
		mv $(DESTDIR)$(usrlib_execdir)/libfdisk.so.* $(DESTDIR)$(libdir); \
		so_img_name=$$(readlink $(DESTDIR)$(usrlib_execdir)/libfdisk.so); \
		so_img_rel_target=$$(echo $(usrlib_execdir) | sed 's,\(^/\|\)[^/][^/]*,..,g'); \
		(cd $(DESTDIR)$(usrlib_execdir) && \
			rm -f libfdisk.so && \
			$(LN_S) $$so_img_rel_target$(libdir)/$$so_img_name libfdisk.so); \
	fi

uninstall-hook-libfdisk:
	rm -f $(DESTDIR)$(libdir)/libfdisk.so*

INSTALL_EXEC_HOOKS += install-exec-hook-libfdisk
UNINSTALL_HOOKS += uninstall-hook-libfdisk