|
|
1.1 ! root 1: # ! 2: # Makefile include file for simple commands ! 3: # Copyright NeXT, Inc. 1992. All rights reserved. ! 4: # ! 5: ! 6: # ! 7: # TOOLS ! 8: # ! 9: MD= md ! 10: ifneq "" "$(wildcard /bin/mkdirs)" ! 11: MKDIRS = /bin/mkdirs ! 12: else ! 13: MKDIRS = /bin/mkdir -p ! 14: endif ! 15: ! 16: # ! 17: # Default type(s) to build ! 18: # ! 19: TYPES= STD ! 20: ! 21: # ! 22: # Sources for tags ! 23: # ! 24: SRCS= $(HFILES) $(YFILES) $(CFILES) $(MFILES) $(SFILES) $(EXTRA_SRCS) ! 25: ! 26: # ! 27: # Build list of object modules from source files ! 28: # Trick is to strip off any path prefix ! 29: # ! 30: XCOBJS= $(CFILES:.c=.o) ! 31: COBJS= $(XCOBJS:t) ! 32: ! 33: XMOBJS= $(MFILES:.m=.o) ! 34: MOBJS= $(XMOBJS:t) ! 35: ! 36: XYOBJS= $(YFILES:.y=.o) ! 37: YOBJS= $(XYOBJS:t) ! 38: ! 39: XSOBJS= $(SFILES:.s=.o) ! 40: SOBJS= $(XSOBJS:t) ! 41: ! 42: # ! 43: # Make the first SOBJ be the first module loaded. Simplifies ! 44: # getting crt0.s in the right place for programs that need it first. ! 45: # ! 46: OBJS= $(SOBJS) $(YOBJS) $(COBJS) $(MOBJS) $(EXTRA_OBJS) ! 47: ! 48: # ! 49: # PROGRAM_PATH is the directory underneath OBJROOT and SYMROOT where ! 50: # we do our actual building. ! 51: # ! 52: PROGRAM_PATH=$(PROGRAM) ! 53: ! 54: # ! 55: # This makefile actually does builds in $(OBJROOT). Set-up vpath so ! 56: # sources may be found. ! 57: # ! 58: STD_VPATH=$(SRCDIR) ! 59: PROF_VPATH=$(SRCDIR) ! 60: DBG_VPATH=$(SRCDIR) ! 61: ! 62: # ! 63: # *_NAME's are used by vers_string so that it's apparent which ! 64: # binary type you have (debug, prof, etc) by looking at the vers_string ! 65: # ! 66: STD_NAME= ! 67: PROF_NAME=_PROF ! 68: DBG_NAME=_DBG ! 69: ! 70: # ! 71: # These commands are executed whenever make exits, they clean-up ! 72: # any crud left about. ! 73: # ! 74: STD_EXIT= $(RM) $(RMFLAGS) $(DERIVED) *.d ! 75: PROF_EXIT= $(RM) $(RMFLAGS) $(DERIVED) *.d ! 76: DBG_EXIT= $(RM) $(RMFLAGS) $(DERIVED) *.d ! 77: ! 78: # ! 79: # Indirection used to get appropriate options for the TYPE of build ! 80: # being done. ! 81: # ! 82: COPTS= ${$(TYPE)_COPTS} ! 83: LDOPTS= ${$(TYPE)_LDOPTS} ! 84: XLIBS= ${$(TYPE)_LIBS} ! 85: ! 86: NAME=${$(TYPE)_NAME} ! 87: VPATH=${$(TYPE)_VPATH} ! 88: EXIT=${$(TYPE)_EXIT} ! 89: ! 90: # ! 91: # This is completely untested! ! 92: # ! 93: CMD_FLAGS= "RC_FLAGS=$(RC_FLAGS)" "RC_ARCH=$(RC_ARCH)" ! 94: ! 95: # ! 96: # Cause .c file to be built from yacc file ! 97: # ! 98: XYFILES= $(YFILES:t) ! 99: $(XYFILES:.y=.c): $$(@:.c=.y) ! 100: ! 101: # ! 102: # CCFLAGS are for command line use ! 103: # e.g. make CCFLAGS="-I/foo/bar/include" ! 104: # ! 105: # RC_CFLAGS are for Release Control use. ! 106: # ! 107: .c.o: ! 108: $(CC) -MD $(CFLAGS) $(COPTS) $(RC_CFLAGS) $(CCFLAGS) -c -o $@ $< ! 109: $(MD) -d -u Makedep $(*F).d ! 110: ! 111: .m.o: ! 112: $(CC) -MD $(CFLAGS) $(COPTS) $(RC_CFLAGS) $(CCFLAGS) -c -o $@ $< ! 113: $(MD) -d -u Makedep $(*F).d ! 114: ! 115: .s.o: ! 116: $(CC) -MD $(SFLAGS) $(CFLAGS) $(COPTS) $(RC_CFLAGS) $(CCFLAGS) \ ! 117: -c -o $@ $< ! 118: $(MD) -d -u Makedep $(*F).d ! 119: ! 120: .l.o: ! 121: $(LEX) $(LFLAGS) $< ! 122: $(CC) $(CFLAGS) $(COPTS) $(RC_CFLAGS) $(CCFLAGS) -c lex.yy.c ! 123: $(RM) $(RMFLAGS) lex.yy.c ! 124: $(MV) $(MVFLAGS) lex.yy.o $@ ! 125: ! 126: .y.o: ! 127: $(YACC) $(YFLAGS) $< ! 128: $(CC) $(CFLAGS) $(COPTS) $(RC_CFLAGS) $(CCFLAGS) -c y.tab.c ! 129: $(RM) $(RMFLAGS) y.tab.c ! 130: $(MV) $(MVFLAGS) y.tab.o $@ ! 131: ! 132: # ! 133: # Standard clean-up on exit ! 134: # ! 135: .EXIT: ! 136: -$(EXIT) ! 137: ! 138: # ! 139: # Standard targets ! 140: # All executed in "source" directory ! 141: # ! 142: .DEFTARGET: all ! 143: ! 144: all: $(TYPES) ! 145: ! 146: remake: clean all ! 147: ! 148: ! 149: STD_GARBAGE= errs [Mm]ake.out *~ *.o *.d TAGS tags vers.c Makedep ! 150: ! 151: # ! 152: # Initial rule for handling: ! 153: # STD (release) ! 154: # PROF (profiling) ! 155: # DBG (debugging) ! 156: # builds. ! 157: # ! 158: # "make DBG" builds a debugging version. Objects are placed ! 159: # DBG_OBJS. ! 160: # ! 161: # Main trick here is to convert (possibly relative) pathnames to ! 162: # absolute paths via pwd. Then reinvoke make with appropriate ! 163: # macros defined. ! 164: # ! 165: STD PROF DBG: $(SYMROOT)/$(PROGRAM_PATH)/$$@_OBJS \ ! 166: $(OBJROOT)/$(PROGRAM_PATH)/$$@_OBJS ALWAYS ! 167: @echo cd $(OBJROOT)/$(PROGRAM_PATH)/$@_OBJS ! 168: @SRCDIR=`pwd`; cd $(SYMROOT); SYMDIR=`pwd`; cd $$SRCDIR; \ ! 169: cd $(OBJROOT)/$(PROGRAM_PATH)/$@_OBJS; \ ! 170: SRCDIR=`relpath -d $$SRCDIR . $$SRCDIR`; \ ! 171: SYMDIR=`relpath -d $$SRCDIR . $$SYMDIR`; \ ! 172: $(MAKE) -f $$SRCDIR/Makefile TYPE="$@" \ ! 173: SRCDIR=$$SRCDIR SYMROOT=$$SYMDIR $(CMD_FLAGS) \ ! 174: $$SYMDIR/$(PROGRAM_PATH)/$@_OBJS/$(PROGRAM) ! 175: ! 176: install:: DSTROOT $(DSTDIRS) STD installhdrs ! 177: install $(IFLAGS) \ ! 178: $(SYMROOT)/$(PROGRAM_PATH)/STD_OBJS/$(PROGRAM) \ ! 179: $(DSTROOT)$(BINDIR)/$(PROGRAM) ! 180: ! 181: install:: install_extra ALWAYS ! 182: ! 183: reinstall: clean install ! 184: ! 185: clean:: ALWAYS ! 186: -$(RM) $(RMFLAGS) $(STD_GARBAGE) $(GARBAGE) ! 187: -$(RM) -rf $(OBJROOT)/$(PROGRAM_PATH) ! 188: # -$(RM) -rf $(OBJROOT)/$(PROGRAM_PATH)/*_OBJS ! 189: @-if [ $(SYMROOT) != $(OBJROOT) ]; \ ! 190: then \ ! 191: echo $(RM) -rf $(SYMROOT)/$(PROGRAM_PATH)/*_OBJS; \ ! 192: $(RM) -rf $(SYMROOT)/$(PROGRAM_PATH)/*_OBJS; \ ! 193: fi ! 194: ! 195: tags: ALWAYS tags_link ! 196: $(RM) -f TAGS tags ! 197: etags -et $(SRCS) ! 198: ctags -w $(SRCS) ! 199: ! 200: # ! 201: # Internal targets ! 202: # All targets below are executed in "source" directory ! 203: # ! 204: ! 205: DSTROOT:ALWAYS ! 206: @if [ -n "$($@)" ]; \ ! 207: then \ ! 208: exit 0; \ ! 209: else \ ! 210: echo Must define $@; \ ! 211: exit 1; \ ! 212: fi ! 213: ! 214: $(DSTDIRS): ! 215: $(MKDIRS) $@ ! 216: ! 217: $(OBJROOT)/$(PROGRAM_PATH)/DBG_OBJS \ ! 218: $(OBJROOT)/$(PROGRAM_PATH)/PROF_OBJS \ ! 219: $(OBJROOT)/$(PROGRAM_PATH)/STD_OBJS \ ! 220: $(SYMROOT)/$(PROGRAM_PATH)/DBG_OBJS \ ! 221: $(SYMROOT)/$(PROGRAM_PATH)/PROF_OBJS \ ! 222: $(SYMROOT)/$(PROGRAM_PATH)/STD_OBJS: ! 223: $(MKDIRS) $@ ! 224: ! 225: # ! 226: # "Internal" target to building the command ! 227: # Executed in $(OBJROOT)/$(PROGRAM_PATH)/$(TYPE)_OBJS ! 228: # ! 229: # This makefile when invoked in the OBJROOT will have the following ! 230: # macros defined: ! 231: # SRCDIR -- path to the directory containing this Makefile ! 232: # SYMROOT -- path to the directory that is to contain the result ! 233: # of this build ! 234: # ! 235: ! 236: $(SYMROOT)/$(PROGRAM_PATH)/$(TYPE)_OBJS/$(PROGRAM): \ ! 237: $(OBJS) vers.o $(SRCDIR)/Makefile ! 238: $(CC) $(LDFLAGS) $(LDOPTS) $(RC_CFLAGS) \ ! 239: -o $@ $(OBJS) vers.o $(XLIBS) $(LIBS) ! 240: ! 241: vers.c: $(OBJS) ! 242: @$(RM) -f $@ ! 243: @CWD=`pwd`; \ ! 244: cd $(SRCDIR); \ ! 245: echo vers_string -c $(PROGRAM)$(NAME) \> $$CWD/$@; \ ! 246: vers_string -c $(PROGRAM)$(NAME) > $$CWD/$@ ! 247: ! 248: ALWAYS: ! 249: ! 250: # ! 251: # This must be designed to work in the context of ! 252: # $(OBJROOT)/$(PROGRAM_PATH)/$(TYPE)_OBJS. Since include ! 253: # files are found relative to the Makefile, this should ! 254: # do the trick. ! 255: # ! 256: -include $(OBJROOT)/$(PROGRAM_PATH)/$(TYPE)_OBJS/Makedep ! 257: ! 258: # ! 259: # Added 26-Jun-92 dmitch for driverkit project... ! 260: # ! 261: installsrc: SRCROOT $(SRCROOT) ! 262: gnutar cf - $(SRCS) Makefile | (cd $(SRCROOT); gnutar xpf -) ! 263: ! 264: $(SRCROOT): ! 265: $(MKDIRS) $@ ! 266: ! 267: SRCROOT: ! 268: @if [ -n "${$@}" ]; \ ! 269: then \ ! 270: exit 0; \ ! 271: else \ ! 272: echo Must define $@; \ ! 273: exit 1; \ ! 274: fi
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.