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