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, Version 1.0 only 6 # (the "License"). You may not use this file except in compliance 7 # with the License. 8 # 9 # You can obtain a copy of the license at COPYING 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 COPYING. 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 # Copyright (c) 2012 Joyent Inc. 22 # 23 24 include ../Makefile.defs 25 26 PROG = cpp$(STRAP) 27 PROGDIR = /usr/lib 28 29 OBJS = \ 30 cpp.o$(STRAP) \ 31 y.tab.o$(STRAP) 32 33 CLEANFILES += \ 34 y.tab.c$(STRAP) 35 36 CFLAGS += -O2 37 LD = $(GCC) 38 39 COMPILE.c = $(GCC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ 40 LINK.prog = $(LD) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) 41 PROTOFILES = $(DESTDIR)$(PROGDIR)/$(PROG) 42 43 all: $(PROG) 44 45 install: $(PROTOFILES) 46 47 clean: 48 -rm -f $(OBJS) $(CLEANFILES) $(PROG) *strap 49 50 $(PROG): $(OBJS) 51 $(LINK.prog) 52 53 %.o$(STRAP): %.c 54 $(COMPILE.c) 55 56 # 57 # We need to distinguish between the cpp build in the bootstrap and the cpp 58 # built normally. However, when we install it, they need to have the same name. 59 # To handle this we add a small bit of shell logic. Note that the mv bit is 60 # explicitly ignored and instead we do a final check to make sure we have 61 # something called cpp at the very end which will either be because of install 62 # or because of the later mv. 63 # 64 $(DESTDIR)$(PROGDIR)/%: % 65 mkdir -p $(DESTDIR)$(PROGDIR) 66 /usr/sbin/install -m 0755 -f $(DESTDIR)$(PROGDIR) $(PROG) 67 -[ "$(PROG)" == "cppstrap" ] && mv -f $(DESTDIR)$(PROGDIR)/$(PROG) \ 68 $(DESTDIR)$(PROGDIR)/cpp 69 [ -f "$(DESTDIR)$(PROGDIR)/cpp" ] 70 71 y.tab.c: cpy.y 72 $(YACC) cpy.y