xref: /illumos-gate/usr/src/cmd/file/Makefile (revision d17be682)
17c478bd9Sstevel@tonic-gate#
27c478bd9Sstevel@tonic-gate# CDDL HEADER START
37c478bd9Sstevel@tonic-gate#
47c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the
5c13de8f6Sab# Common Development and Distribution License (the "License").
6c13de8f6Sab# You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate#
87c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate# and limitations under the License.
127c478bd9Sstevel@tonic-gate#
137c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate#
197c478bd9Sstevel@tonic-gate# CDDL HEADER END
207c478bd9Sstevel@tonic-gate#
217c478bd9Sstevel@tonic-gate#
229a411307Srie# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate# Use is subject to license terms.
247c478bd9Sstevel@tonic-gate#
255661bb76SJohn Levon# Copyright (c) 2018, Joyent, Inc.
267c478bd9Sstevel@tonic-gate
277c478bd9Sstevel@tonic-gatePROG= file
287c478bd9Sstevel@tonic-gateXPG4PROG= file
297c478bd9Sstevel@tonic-gateMAGIC= magic
307c478bd9Sstevel@tonic-gate
317c478bd9Sstevel@tonic-gateELFCAP=	$(SRC)/common/elfcap
32c13de8f6SabSGSRTCID=	$(SRC)/common/sgsrtcid
337c478bd9Sstevel@tonic-gate
34c2c65e21SnyLOBJS=	file.o elf_read32.o elf_read64.o magicutils.o
357c478bd9Sstevel@tonic-gateOBJS=	$(LOBJS) elfcap.o
367c478bd9Sstevel@tonic-gateXPG4OBJS= $(OBJS:%.o=xpg4_%.o)
37c2c65e21SnySRCS=	file.c elf_read.c magicutils.c $(ELFCAP)/elfcap.c
387c478bd9Sstevel@tonic-gate
397c478bd9Sstevel@tonic-gateinclude ../Makefile.cmd
407c478bd9Sstevel@tonic-gate
41856f620eSRobert MustacchiCSTD=	$(CSTD_GNU99)
42856f620eSRobert Mustacchi
43*d3b5f563SJohn LevonCERRWARN += $(CNOWARN_UNINIT)
447014882cSRichard LoweCERRWARN += -_gcc=-Wno-type-limits
457014882cSRichard Lowe
467c478bd9Sstevel@tonic-gatePOFILE= file_all.po
47c2c65e21SnyPOFILES= $(SRCS:%.c=%.po)
48c2c65e21Sny
497c478bd9Sstevel@tonic-gateLDLIBS += -lelf
5099f63845SabCPPFLAGS += -I$(ELFCAP) -I$(SGSRTCID)
517c478bd9Sstevel@tonic-gate$(XPG4) := CFLAGS += -DXPG4
527c478bd9Sstevel@tonic-gate
537c478bd9Sstevel@tonic-gateROOTETCMAGIC= $(MAGIC:%=$(ROOTETC)/%)
547c478bd9Sstevel@tonic-gate
557c478bd9Sstevel@tonic-gate$(ROOTETCMAGIC) :=	FILEMODE =	$(LIBFILEMODE)
567c478bd9Sstevel@tonic-gate
577c478bd9Sstevel@tonic-gate.PARALLEL:	$(OBJS) $(XPG4OBJS) $(POFILES)
587c478bd9Sstevel@tonic-gate
597c478bd9Sstevel@tonic-gate.KEEP_STATE:
607c478bd9Sstevel@tonic-gate
617c478bd9Sstevel@tonic-gateall: $(PROG) $(XPG4) $(MAGIC)
627c478bd9Sstevel@tonic-gate
637c478bd9Sstevel@tonic-gate$(PROG) : $(OBJS)
647c478bd9Sstevel@tonic-gate	$(LINK.c) $(OBJS) -o $@ $(LDLIBS)
657c478bd9Sstevel@tonic-gate	$(POST_PROCESS)
667c478bd9Sstevel@tonic-gate
677c478bd9Sstevel@tonic-gate$(XPG4) : $(XPG4OBJS)
687c478bd9Sstevel@tonic-gate	$(LINK.c) $(XPG4OBJS) -o $@ $(LDLIBS)
697c478bd9Sstevel@tonic-gate	$(POST_PROCESS)
707c478bd9Sstevel@tonic-gate
719a411307Srie%.o:	%.c
729a411307Srie	$(COMPILE.c) -o $@ $<
739a411307Srie
74c2c65e21Sny%32.o:	%.c
75c2c65e21Sny	$(COMPILE.c) -o $@ $<
76c2c65e21Sny
77c2c65e21Sny%64.o:	%.c
78c2c65e21Sny	$(COMPILE.c) -D_ELF64 -o $@ $<
79c2c65e21Sny
807c478bd9Sstevel@tonic-gatexpg4_%.o:	%.c
817c478bd9Sstevel@tonic-gate	$(COMPILE.c) -o $@ $<
827c478bd9Sstevel@tonic-gate
83c2c65e21Snyxpg4_%32.o:	%.c
84c2c65e21Sny	$(COMPILE.c) -o $@ $<
85c2c65e21Sny
86c2c65e21Snyxpg4_%64.o:	%.c
87c2c65e21Sny	$(COMPILE.c) -D_ELF64 -o $@ $<
88c2c65e21Sny
897c478bd9Sstevel@tonic-gateelfcap.o:	$(ELFCAP)/elfcap.c
907c478bd9Sstevel@tonic-gate	$(COMPILE.c) -o $@ $(ELFCAP)/elfcap.c
917c478bd9Sstevel@tonic-gate
927c478bd9Sstevel@tonic-gatexpg4_elfcap.o:	$(ELFCAP)/elfcap.c
937c478bd9Sstevel@tonic-gate	$(COMPILE.c) -o $@ $(ELFCAP)/elfcap.c
947c478bd9Sstevel@tonic-gate
957c478bd9Sstevel@tonic-gate$(POFILE):	$(POFILES)
967c478bd9Sstevel@tonic-gate	$(RM) $@
977c478bd9Sstevel@tonic-gate	cat $(POFILES) > $@
987c478bd9Sstevel@tonic-gate
997c478bd9Sstevel@tonic-gateinstall: all $(ROOTPROG) $(ROOTXPG4PROG) $(ROOTETCMAGIC)
1007c478bd9Sstevel@tonic-gate
1017c478bd9Sstevel@tonic-gateclean:
1027c478bd9Sstevel@tonic-gate	$(RM) $(OBJS) $(XPG4OBJS)
1037c478bd9Sstevel@tonic-gate
1047c478bd9Sstevel@tonic-gateinclude ../Makefile.targ
105