1# 2 3# Copyright 2004 Sun Microsystems, Inc. All rights reserved. 4# Use is subject to license terms. 5# 6# Copyright (c) 2018, Joyent, Inc. 7 8# 9# Debugging targets 10# sort provides a number of debugging options to simplify failure analysis. 11# 12# debug provides symbol information and sets DEBUG; includes 13# convert, invoke 14# stats builds binaries with statistics reporting enabled 15# convert builds convert binaries (converts input to collation 16# vectors) 17# invoke builds invoke binaries (allows inspection of options 18# parser outcome) 19# 20# Debugging #defines 21# DEBUG activate assertions; allow wider range of memory 22# settings (-S) 23# DEBUG_FORCE_WIDE force all i/o through wide streams 24# DEBUG_DISALLOW_MMAP force all i/o through stdio or wide streams 25# DEBUG_NO_CACHE_TEMP do not cache last sorted portion in memory; write all 26# data to temporary files before merge 27# 28 29PROG = sort 30XPG4PROG = sort 31 32BASE_OBJS = \ 33 check.o \ 34 fields.o \ 35 initialize.o \ 36 internal.o \ 37 merge.o \ 38 options.o \ 39 streams.o \ 40 streams_array.o \ 41 streams_mmap.o \ 42 streams_stdio.o \ 43 streams_wide.o \ 44 utility.o 45 46OBJS = main.o $(BASE_OBJS) 47INVOKE_OBJS = invoke.o $(BASE_OBJS) 48CONVERT_OBJS = convert.o $(BASE_OBJS) 49STATS_OBJS = main.o statistics.o $(BASE_OBJS) 50 51XPG4OBJS = $(OBJS:%.o=xpg4_%.o) 52CLEANFILES = $(OBJS) $(XPG4OBJS) 53 54include ../Makefile.cmd 55include ../Makefile.cmd.64 56 57DCFILE = $(PROG).dc 58 59CFLAGS += $(SORT_DEBUG) 60 61CERRWARN += -_gcc=-Wno-parentheses 62CERRWARN += $(CNOWARN_UNINIT) 63CERRWARN += -_gcc=-Wno-unused-function 64 65# not linted 66SMATCH=off 67 68$(XPG4) := CFLAGS += -DXPG4 69 70debug := SORT_DEBUG = $(CCGDEBUG) -DDEBUG 71debug := COPTFLAG = 72debug := COPTFLAG64 = 73stats := SORT_DEBUG = $(CCGDEBUG) -DSTATS -DDEBUG 74stats := COPTFLAG = 75stats := COPTFLAG64 = 76 77.KEEP_STATE : 78 79.PARALLEL : $(OBJS) $(XPG4OBJS) $(LNTS) 80 81all : $(PROG) $(XPG4) 82 83debug : $(PROG) convert invoke 84 85clean : 86 $(RM) $(CLEANFILES) 87 88$(PROG) : $(OBJS) 89 $(LINK.c) -o $@ $(OBJS) $(LDLIBS) 90 $(POST_PROCESS) 91 92$(XPG4) : $(XPG4OBJS) 93 $(LINK.c) -o $@ $(XPG4OBJS) $(LDLIBS) 94 $(POST_PROCESS) 95 96invoke: $(INVOKE_OBJS) 97 $(LINK.c) -o $@ $(INVOKE_OBJS) $(LDLIBS) 98 99convert: $(CONVERT_OBJS) 100 $(LINK.c) -o $@ $(CONVERT_OBJS) $(LDLIBS) 101 102stats: $(STATS_OBJS) 103 $(LINK.c) -o $@ $(STATS_OBJS) $(LDLIBS) 104 105%.o : %.c 106 $(COMPILE.c) -o $@ $< 107 $(POST_PROCESS_O) 108 109xpg4_%.o : %.c 110 $(COMPILE.c) -o $@ $< 111 $(POST_PROCESS_O) 112 113SRCS = check.c fields.c initialize.c internal.c \ 114 main.c merge.c options.c streams.c \ 115 streams_array.c streams_mmap.c streams_stdio.c \ 116 streams_wide.c utility.c 117 118POFILES = $(SRCS:.c=.po) 119XGETFLAGS += -a -x sort.xcl 120CLOBBERFILES = $(DCFILE) $(POFILE) $(POFILES) 121 122ROOTLINK = $(PROG:%=$(ROOTBIN64)/%) 123 124.KEEP_STATE: 125 126install : $(ROOTPROG) $(ROOTXPG4PROG) $(ROOTLINK) 127 128$(ROOTLINK): 129 $(RM) $@; $(SYMLINK) ../../bin/$(@F) $@ 130 131$(POFILE) : $(POFILES) 132 echo $(SRCS) 133 echo $(POFILES) 134 -$(RM) $@ 135 $(CAT) $(POFILES) > $@ 136 137%.po : %.c 138 $(RM) messages.po 139 $(XGETTEXT) -c TRANSLATION_NOTE $< 140 $(SED) -e '/^domain/d' messages.po > $@ 141 $(RM) messages.po 142 143include ../Makefile.targ 144