Subject: make rules for objective-c
To: None <tech-toolchain@NetBSD.ORG>
From: Luke Mewburn <lm@cs.rmit.edu.au>
List: tech-toolchain
Date: 10/27/1997 16:46:03
Whilst investigating a PR, I noticed that we don't have standard
set of rules for compiling objective C source files (``.m'' suffix)

Apparantly '.m' is also used by modula3, mathematica, and matlab.
I don't see a problem if we add default rules for .m.o:, but others
may have further input here.

I propose that the following changes are made to the tree:

- file: share/mk/sys.mk
  add:
	OBJC?=		${CC}
	OBJCFLAGS?=	${CFLAGS}
	COMPILE.m?=	${OBJC} ${OBJCFLAGS} ${CPPFLAGS} -c
	LINK.m?=	${OBJC} ${OBJCFLAGS} ${CPPFLAGS} ${LDFLAGS}


	# Objective C
	.m:
		${LINK.m} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
	.m.o:
		${COMPILE.m} ${.IMPSRC}
	.if (${MACHINE_ARCH} != "alpha")
	.m.a:
		${COMPILE.m} ${.IMPSRC}
		${AR} ${ARFLAGS} $@ $*.o
		rm -f $*.o
	.endif
	.m.ln:
		${LINT} ${LINTFLAGS} ${CFLAGS:M-[IDU]*} -i ${.IMPSRC}


- file: share/mk/bsd.lib.mk
  add:

	.SUFFIXES:	.m
			
	.m.o:
		@echo ${COMPILE.m:Q} ${.IMPSRC}
		@${COMPILE.m} ${.IMPSRC}  -o ${.TARGET}.o
		@${LD} -x -r ${.TARGET}.o -o ${.TARGET}
		@rm -f ${.TARGET}.o

	.m.po:
		@echo ${COMPILE.m:Q} -pg ${.IMPSRC} -o ${.TARGET}
		@${COMPILE.m} -pg ${.IMPSRC} -o ${.TARGET}.o
		@${LD} -X -r ${.TARGET}.o -o ${.TARGET}
		@rm -f ${.TARGET}.o

	.m.so:
		@echo ${COMPILE.m:Q} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}
		@${COMPILE.m} ${CPICFLAGS} ${.IMPSRC} -o ${.TARGET}.o
		@${LD} -x -r ${.TARGET}.o -o ${.TARGET}
		@rm -f ${.TARGET}.o

- file: gnu/usr.bin/gcc/libobjc/Makefile
  remove: lines to do homebrew .m.o rule