xref: /titanic_50/usr/src/cmd/file/Makefile (revision 62a24de03df1f2399ceda704cb3874dabc98bbbd)
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# ident	"%Z%%M%	%I%	%E% SMI"
26#
27
28PROG= file
29XPG4PROG= file
30MAGIC= magic
31
32ELFCAP=	$(SRC)/common/elfcap
33SGSRTCID=	$(SRC)/common/sgsrtcid
34
35LOBJS=	file.o elf_read32.o elf_read64.o magicutils.o
36OBJS=	$(LOBJS) elfcap.o
37XPG4OBJS= $(OBJS:%.o=xpg4_%.o)
38SRCS=	file.c elf_read.c magicutils.c $(ELFCAP)/elfcap.c
39
40include ../Makefile.cmd
41
42POFILE= file_all.po
43POFILES= $(SRCS:%.c=%.po)
44
45# The debug binary can be built using the flag
46# -D COPTFLAG=-g CGLOBALSTATIC=
47# This will avoid the multiple symbols definition error
48# for static global variables in elf_read32.o and elf_read64.o
49
50LDLIBS += -lelf
51CPPFLAGS += -I$(ELFCAP) -I$(SGSRTCID)
52$(XPG4) := CFLAGS += -DXPG4
53
54ROOTETCMAGIC= $(MAGIC:%=$(ROOTETC)/%)
55
56$(ROOTETCMAGIC) :=	FILEMODE =	$(LIBFILEMODE)
57
58.PARALLEL:	$(OBJS) $(XPG4OBJS) $(POFILES)
59
60.KEEP_STATE:
61
62all: $(PROG) $(XPG4) $(MAGIC)
63
64$(PROG) : $(OBJS)
65	$(LINK.c) $(OBJS) -o $@ $(LDLIBS)
66	$(POST_PROCESS)
67
68$(XPG4) : $(XPG4OBJS)
69	$(LINK.c) $(XPG4OBJS) -o $@ $(LDLIBS)
70	$(POST_PROCESS)
71
72%.o:	%.c
73	$(COMPILE.c) -o $@ $<
74
75%32.o:	%.c
76	$(COMPILE.c) -o $@ $<
77
78%64.o:	%.c
79	$(COMPILE.c) -D_ELF64 -o $@ $<
80
81xpg4_%.o:	%.c
82	$(COMPILE.c) -o $@ $<
83
84xpg4_%32.o:	%.c
85	$(COMPILE.c) -o $@ $<
86
87xpg4_%64.o:	%.c
88	$(COMPILE.c) -D_ELF64 -o $@ $<
89
90elfcap.o:	$(ELFCAP)/elfcap.c
91	$(COMPILE.c) -o $@ $(ELFCAP)/elfcap.c
92
93xpg4_elfcap.o:	$(ELFCAP)/elfcap.c
94	$(COMPILE.c) -o $@ $(ELFCAP)/elfcap.c
95
96$(POFILE):	$(POFILES)
97	$(RM) $@
98	cat $(POFILES) > $@
99
100install: all $(ROOTPROG) $(ROOTXPG4PROG) $(ROOTETCMAGIC)
101
102clean:
103	$(RM) $(OBJS) $(XPG4OBJS)
104
105lint: lint_SRCS
106
107include ../Makefile.targ
108