xref: /illumos-gate/usr/src/tools/find_elf/Makefile (revision 16b76d3cb933ff92018a2a75594449010192eacb)
1#
2# This file and its contents are supplied under the terms of the
3# Common Development and Distribution License ("CDDL"), version 1.0.
4# You may only use this file in accordance with the terms of version
5# 1.0 of the CDDL.
6#
7# A full copy of the text of the CDDL should have accompanied this
8# source.  A copy of the CDDL is also available via the Internet at
9# http://www.illumos.org/license/CDDL.
10#
11
12#
13# Copyright 2022 Jason King
14#
15
16PROG = find_elf
17MAN1ONBLDFILES = find_elf.1onbld
18
19#
20# Since libcustr is private, we just build and link in the code directly
21# into the binary. If more build utilities require it in the future, we
22# can transition to building a tools version of the library and link
23# against it.
24CUSTRDIR = $(SRC)/lib/libcustr/common
25
26OBJS = find_elf.o custr.o
27
28include $(SRC)/tools/Makefile.tools
29include $(SRC)/cmd/Makefile.ctf
30
31$(ROOTONBLDMAN1ONBLDFILES) := FILEMODE=	644
32
33LDLIBS = -lelf -lavl
34NATIVE_LIBS += libelf.so libc.so libavl.so
35
36CPPFLAGS += -I$(CUSTRDIR)
37LDFLAGS = \
38	-L$(ROOTONBLDLIBMACH) \
39	'-R$$ORIGIN/../../lib/$(MACH)' \
40	$(BDIRECT) $(ZLAZYLOAD)
41
42CSTD = $(CSTD_GNU99)
43
44.KEEP_STATE:
45
46.PARALLEL: $(OBJS)
47
48all:	$(PROG)
49
50install: all .WAIT $(ROOTONBLDMACHPROG) $(ROOTONBLDDATAFILES) \
51	$(ROOTONBLDMAN1ONBLDFILES)
52
53clean:
54	$(RM) -f $(OBJS)
55
56$(PROG): $(OBJS)
57	$(LINK.c) $(OBJS) -o $@ $(LDLIBS)
58	$(POST_PROCESS)
59
60%.o: %.c
61	$(COMPILE.c) -o $@ $<
62	$(POST_PROCESS_O)
63
64%.o: $(CUSTRDIR)/%.c
65	$(COMPILE.c) -o $@ $<
66	$(POST_PROCESS_O)
67
68include $(SRC)/tools/Makefile.targ
69