home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!mcsun!uknet!doc.ic.ac.uk!syma!william
- From: william@syma.sussex.ac.uk (William Craven)
- Newsgroups: comp.unix.questions
- Subject: Using C macros in Makefiles
- Keywords: C Macros Make Makefiles
- Message-ID: <1992Aug24.132028.23314@syma.sussex.ac.uk>
- Date: 24 Aug 92 13:20:28 GMT
- Organization: University of Sussex
- Lines: 54
-
- The Makefile below creates two programs server and client - and they
- both share common C source codes. However the common C source codes now have
- preCompiler defines which are based on whether the code being compiled is
- for the server or for the client. How can I set up a macro such that
- make will provide the correct define flag for the C compiler ? At present
- the defines are passed only at loading phase not during compilation.
- Will I have to rewrite the suffix macro for .o.c ?
-
- Ideas most appreciated and I will summarise if anybody has solutions.
-
- Many Thanks .......
-
- William Craven william@central.sussex.ac.uk
- UNIX Systems, Computing Service or william@syma.sussex.ac.uk
- University of Sussex
- Brighton, UK
-
-
- #
- # Makefile for rsvcRPC system
- #
-
- RSVCSRC = rsvc_common.c rsvc_xdr.c
- RSVCOBJ = rsvc_common.o rsvc_xdr.o
- RSVCINC = rsvc.h
-
- SRVRSRC = rsvc_server.c ${RSVCSRC}
- SRVROBJ = rsvc_server.o ${RSVCOBJ}
- SRVRINC = ${RSVCINC}
- SRVRFLG = -DrsvcSERVER
-
- CLNTSRC = rsvc_client.c ${RSVCSRC}
- CLNTOBJ = rsvc_client.o ${RSVCOBJ}
- CLNTINC = ${RSVCINC}
- CLNTFLG = -DrsvcCLIENT
-
- CC = cc
- CFLAGS =
-
- all: server client
-
- server: ${SRVROBJ}
- ${CC} ${CFLAGS} ${SRVRFLG} -o server ${SRVROBJ}
-
- ${SRVROBJ}: ${SRVRSRC} ${SRVRINC}
-
- client: ${CLNTOBJ}
- ${CC} ${CFLAGS} ${CLNTFLG} -o client ${CLNTOBJ}
-
- ${CLNTOBJ}: ${CLNTSRC} ${CLNTINC}
-
- clean:
- rm -f *.o server &&& reUs
-