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