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
580ab886dSwesolows# Common Development and Distribution License (the "License").
680ab886dSwesolows# 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#
2124da5b34Srie# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
227c478bd9Sstevel@tonic-gate# Use is subject to license terms.
237c478bd9Sstevel@tonic-gate#
241f5207b7SJohn Levon# Copyright (c) 2019, Joyent, Inc.
251f5207b7SJohn Levon#
267c478bd9Sstevel@tonic-gate
27b8767451SRichard LoweLIB	= geniconvtbl.so
287c478bd9Sstevel@tonic-gatePROG	= geniconvtbl
297c478bd9Sstevel@tonic-gate
30b8767451SRichard LoweSRCDIR  = $(SRC)/cmd/geniconvtbl
317c478bd9Sstevel@tonic-gate
32b8767451SRichard LoweMAPFILE	= $(SRCDIR)/mapfile
337c478bd9Sstevel@tonic-gate
34b8767451SRichard LoweOBJS    = itmcomp.o assemble.o disassemble.o itm_util.o y.tab.o lex.yy.o
35b8767451SRichard LoweMSGFILES = itmcomp.i assemble.i disassemble.i itm_util.i y.tab.i lex.yy.i geniconvtbl.i
367c478bd9Sstevel@tonic-gate
37b8767451SRichard Loweinclude $(SRC)/cmd/Makefile.cmd
387c478bd9Sstevel@tonic-gate
39b8767451SRichard LowePOFILE	= geniconvtbl_.po
407c478bd9Sstevel@tonic-gate
417c478bd9Sstevel@tonic-gateROOTDIRS32=	$(ROOTLIB)/iconv
427c478bd9Sstevel@tonic-gateROOTDIRS64=	$(ROOTLIB)/iconv/$(MACH64)
43b8767451SRichard LoweROOTLIB32 =	$(ROOTDIRS32)/$(LIB)
44b8767451SRichard LoweROOTLIB64 =	$(ROOTDIRS64)/$(LIB)
457c478bd9Sstevel@tonic-gate
46b8767451SRichard LoweCLOBBERFILES=	$(LIB)
47b8767451SRichard LoweCLEANFILES =	$(OBJS) y.tab.c y.tab.h lex.yy.c \
48b8767451SRichard Lowe		$(POFILE)
497c478bd9Sstevel@tonic-gate
50b8767451SRichard LoweCPPFLAGS	+= -I. -I$(SRCDIR)
51d3b5f563SJohn LevonCERRWARN	+= $(CNOWARN_UNINIT)
527014882cSRichard LoweCERRWARN	+= -_gcc=-Wno-unused-label
537014882cSRichard LoweCERRWARN	+= -_gcc=-Wno-switch
547014882cSRichard LoweCERRWARN	+= -_gcc=-Wno-unused-variable
557014882cSRichard LoweCERRWARN	+= -_gcc=-Wno-implicit-function-declaration
56b8767451SRichard LoweYFLAGS		+= -d
57299e09deSRichard LoweCFLAGS		+= -D_FILE_OFFSET_BITS=64
587c478bd9Sstevel@tonic-gate
591f5207b7SJohn Levon# dump_expr() is too hairy
601f5207b7SJohn LevonSMATCH=off
611f5207b7SJohn Levon
62*73a801acSToomas Soome$(LIB) :=	LDFLAGS += $(GSHARED) -Wl,-h$@ $(ZTEXT) $(ZDEFS) $(BDIRECT) \
63b8767451SRichard Lowe		$(C_PICFLAGS) $(MAPFILE:%=-Wl,-M%)			\
64b8767451SRichard Lowe		$(MAPFILE.PGA:%=-Wl,-M%) $(MAPFILE.NED:%=-Wl,-M%)
65b8767451SRichard Lowe$(LIB) :=	CPPFLAGS += -D_REENTRANT
66b8767451SRichard Lowe$(LIB) :=	LDLIBS += -lc
677c478bd9Sstevel@tonic-gate
68b8767451SRichard Lowe$(PROG) :=	LDLIBS += -lgen
697c478bd9Sstevel@tonic-gate
707c478bd9Sstevel@tonic-gate.KEEP_STATE:
717c478bd9Sstevel@tonic-gate
72b8767451SRichard Lowe.PARALLEL: $(LIB) $(OBJS)
737c478bd9Sstevel@tonic-gate
747c478bd9Sstevel@tonic-gate$(PROG): $(OBJS)
757c478bd9Sstevel@tonic-gate	$(LINK.c) $(OBJS) -o $@ $(LDLIBS)
767c478bd9Sstevel@tonic-gate	$(POST_PROCESS)
777c478bd9Sstevel@tonic-gate
78b8767451SRichard Lowe$(LIB): $(SRCDIR)/geniconvtbl.c
79b8767451SRichard Lowe	$(LINK.c) -o $@ $(SRCDIR)/geniconvtbl.c $(LDLIBS)
807c478bd9Sstevel@tonic-gate	$(POST_PROCESS_SO)
817c478bd9Sstevel@tonic-gate
82b8767451SRichard Lowey.tab.c + y.tab.h: $(SRCDIR)/itm_comp.y
83b8767451SRichard Lowe	$(YACC) $(YFLAGS) $(SRCDIR)/itm_comp.y
84b8767451SRichard Lowe	@ $(MV) y.tab.c y.tab.c~
85b8767451SRichard Lowe	@ $(SED) -f  $(SRCDIR)/yacc.sed y.tab.c~ > y.tab.c
86b8767451SRichard Lowe	@ $(RM) y.tab.c~
877c478bd9Sstevel@tonic-gate
88b8767451SRichard Lowelex.yy.c: $(SRCDIR)/itm_comp.l y.tab.h
89b8767451SRichard Lowe	$(LEX) -t $(SRCDIR)/itm_comp.l | $(SED) -f $(SRCDIR)/lex.sed > $(@)
907c478bd9Sstevel@tonic-gate
917c478bd9Sstevel@tonic-gateclean:
927c478bd9Sstevel@tonic-gate	$(RM) $(CLEANFILES)
937c478bd9Sstevel@tonic-gate
94b8767451SRichard Lowe$(POFILE): $(MSGFILES)
95b8767451SRichard Lowe	$(BUILDPO.msgfiles)
96b8767451SRichard Lowe
97299e09deSRichard Lowe%.o:	%.c
987c478bd9Sstevel@tonic-gate	$(COMPILE.c) $<
997c478bd9Sstevel@tonic-gate
100b8767451SRichard Lowe%.o:	$(SRCDIR)/%.c
1017c478bd9Sstevel@tonic-gate	$(COMPILE.c) $<
1027c478bd9Sstevel@tonic-gate
103b8767451SRichard Lowe%.i:	$(SRCDIR)/%.c
104b8767451SRichard Lowe	$(CPPFORPO) $< > $@
105b8767451SRichard Lowe
1067c478bd9Sstevel@tonic-gate# install rule
1077c478bd9Sstevel@tonic-gate$(ROOTDIRS32)/%: $(ROOTDIRS32) %
108b8767451SRichard Lowe	$(INS.file)
1097c478bd9Sstevel@tonic-gate
1107c478bd9Sstevel@tonic-gate$(ROOTDIRS64)/%: $(ROOTDIRS64) %
111b8767451SRichard Lowe	$(INS.file)
1127c478bd9Sstevel@tonic-gate
1137c478bd9Sstevel@tonic-gate$(ROOTDIRS32): $(ROOTLIB)
114b8767451SRichard Lowe	$(INS.dir)
1157c478bd9Sstevel@tonic-gate
1167c478bd9Sstevel@tonic-gate$(ROOTDIRS64): $(ROOTDIRS32)
117b8767451SRichard Lowe	$(INS.dir)
1187c478bd9Sstevel@tonic-gate
119b8767451SRichard Loweinclude $(SRC)/cmd/Makefile.targ
120b8767451SRichard Loweinclude $(SRC)/Makefile.msg.targ
121