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) 42C99LMODE= -Xc99=%all 43 44CERRWARN += -_gcc=-Wno-uninitialized 45CERRWARN += -_gcc=-Wno-type-limits 46 47# not linted 48SMATCH=off 49 50POFILE= file_all.po 51POFILES= $(SRCS:%.c=%.po) 52 53# The debug binary can be built using the flags 54# SOURCEDEBUG=yes CGLOBALSTATIC= 55# This will avoid the multiple symbols definition error 56# for static global variables in elf_read32.o and elf_read64.o 57 58LDLIBS += -lelf 59CPPFLAGS += -I$(ELFCAP) -I$(SGSRTCID) 60$(XPG4) := CFLAGS += -DXPG4 61 62ROOTETCMAGIC= $(MAGIC:%=$(ROOTETC)/%) 63 64$(ROOTETCMAGIC) := FILEMODE = $(LIBFILEMODE) 65 66.PARALLEL: $(OBJS) $(XPG4OBJS) $(POFILES) 67 68.KEEP_STATE: 69 70all: $(PROG) $(XPG4) $(MAGIC) 71 72$(PROG) : $(OBJS) 73 $(LINK.c) $(OBJS) -o $@ $(LDLIBS) 74 $(POST_PROCESS) 75 76$(XPG4) : $(XPG4OBJS) 77 $(LINK.c) $(XPG4OBJS) -o $@ $(LDLIBS) 78 $(POST_PROCESS) 79 80%.o: %.c 81 $(COMPILE.c) -o $@ $< 82 83%32.o: %.c 84 $(COMPILE.c) -o $@ $< 85 86%64.o: %.c 87 $(COMPILE.c) -D_ELF64 -o $@ $< 88 89xpg4_%.o: %.c 90 $(COMPILE.c) -o $@ $< 91 92xpg4_%32.o: %.c 93 $(COMPILE.c) -o $@ $< 94 95xpg4_%64.o: %.c 96 $(COMPILE.c) -D_ELF64 -o $@ $< 97 98elfcap.o: $(ELFCAP)/elfcap.c 99 $(COMPILE.c) -o $@ $(ELFCAP)/elfcap.c 100 101xpg4_elfcap.o: $(ELFCAP)/elfcap.c 102 $(COMPILE.c) -o $@ $(ELFCAP)/elfcap.c 103 104$(POFILE): $(POFILES) 105 $(RM) $@ 106 cat $(POFILES) > $@ 107 108install: all $(ROOTPROG) $(ROOTXPG4PROG) $(ROOTETCMAGIC) 109 110clean: 111 $(RM) $(OBJS) $(XPG4OBJS) 112 113lint: lint_SRCS 114 115include ../Makefile.targ 116