xref: /illumos-gate/usr/src/cmd/file/Makefile (revision 8226594fdd4479be135127f43632f1f995074654)
1#
2# CDDL HEADER START
3#
4# The contents of this file are subject to the terms of the
5# Common Development and Distribution License (the "License").
6# You may not use this file except in compliance with the License.
7#
8# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9# or http://www.opensolaris.org/os/licensing.
10# See the License for the specific language governing permissions
11# and limitations under the License.
12#
13# When distributing Covered Code, include this CDDL HEADER in each
14# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15# If applicable, add the following below this CDDL HEADER, with the
16# fields enclosed by brackets "[]" replaced with your own identifying
17# information: Portions Copyright [yyyy] [name of copyright owner]
18#
19# CDDL HEADER END
20#
21#
22# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23# Use is subject to license terms.
24#
25# Copyright (c) 2018, Joyent, Inc.
26
27PROG= file
28XPG4PROG= file
29MAGIC= magic
30
31ELFCAP=	$(SRC)/common/elfcap
32SGSRTCID=	$(SRC)/common/sgsrtcid
33
34LOBJS=	file.o elf_read32.o elf_read64.o magicutils.o
35OBJS=	$(LOBJS) elfcap.o
36XPG4OBJS= $(OBJS:%.o=xpg4_%.o)
37SRCS=	file.c elf_read.c magicutils.c $(ELFCAP)/elfcap.c
38
39include ../Makefile.cmd
40
41CSTD=	$(CSTD_GNU99)
42
43CERRWARN += $(CNOWARN_UNINIT)
44CERRWARN += -_gcc=-Wno-type-limits
45
46POFILE= file_all.po
47POFILES= $(SRCS:%.c=%.po)
48
49LDLIBS += -lelf
50CPPFLAGS += -I$(ELFCAP) -I$(SGSRTCID)
51$(XPG4) := CFLAGS += -DXPG4
52
53ROOTETCMAGIC= $(MAGIC:%=$(ROOTETC)/%)
54
55$(ROOTETCMAGIC) :=	FILEMODE =	$(LIBFILEMODE)
56
57.PARALLEL:	$(OBJS) $(XPG4OBJS) $(POFILES)
58
59.KEEP_STATE:
60
61all: $(PROG) $(XPG4) $(MAGIC)
62
63$(PROG) : $(OBJS)
64	$(LINK.c) $(OBJS) -o $@ $(LDLIBS)
65	$(POST_PROCESS)
66
67$(XPG4) : $(XPG4OBJS)
68	$(LINK.c) $(XPG4OBJS) -o $@ $(LDLIBS)
69	$(POST_PROCESS)
70
71%.o:	%.c
72	$(COMPILE.c) -o $@ $<
73
74%32.o:	%.c
75	$(COMPILE.c) -o $@ $<
76
77%64.o:	%.c
78	$(COMPILE.c) -D_ELF64 -o $@ $<
79
80xpg4_%.o:	%.c
81	$(COMPILE.c) -o $@ $<
82
83xpg4_%32.o:	%.c
84	$(COMPILE.c) -o $@ $<
85
86xpg4_%64.o:	%.c
87	$(COMPILE.c) -D_ELF64 -o $@ $<
88
89elfcap.o:	$(ELFCAP)/elfcap.c
90	$(COMPILE.c) -o $@ $(ELFCAP)/elfcap.c
91
92xpg4_elfcap.o:	$(ELFCAP)/elfcap.c
93	$(COMPILE.c) -o $@ $(ELFCAP)/elfcap.c
94
95$(POFILE):	$(POFILES)
96	$(RM) $@
97	cat $(POFILES) > $@
98
99install: all $(ROOTPROG) $(ROOTXPG4PROG) $(ROOTETCMAGIC)
100
101clean:
102	$(RM) $(OBJS) $(XPG4OBJS)
103
104include ../Makefile.targ
105