home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.unix.shell:3777 comp.unix.questions:10656
- Newsgroups: comp.unix.shell,comp.unix.questions
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!news.larc.nasa.gov!hal.larc.nasa.gov!alan
- From: alan@hal.larc.nasa.gov (alan dare)
- Subject: Need help from a make guru
- Message-ID: <Btytp9.BKs@news.larc.nasa.gov>
- Originator: alan@hal.larc.nasa.gov
- Sender: news@news.larc.nasa.gov (USENET Network News)
- Organization: NASA Langley Research Center, Hampton, VA USA
- Date: Wed, 2 Sep 1992 19:19:56 GMT
- Lines: 38
-
-
- In our application we wanted to keep the object and source separate from
- each other in a directory structure as shown below:
-
- <topdir>
- |
- / \
- obj src
-
- My current makefile does this quite well. It also doesn't require a separate
- condition for each source. Problem: Several users add modules to a
- executive then compile it. It would would be nice if they didn't have to
- modify the makefile. The makefile would just compile any source file in the
- current directory. I have taken several stabs at it, but I am not having
- any luck. All I need for it to work is a variable containing a list of
- the source and a variable containing the objects with the directory path
- "../obj/" prefixed to it. Below is a makefile that would compile all *.c and
- create a a.out file. However, I can't get make to execute the shell command
- correctly on the OBJECTS line correctly (the line is a valid shell command).
-
- OBJDIR = ../obj
-
- SOURCE=*.c
- OBJECTS=`for i in \`ls *.c |sed 's/\.c/.o/g'\`; do echo "../obj/$i"; done`
- $(OBJDIR)/a.out: $(OBJECTS)
- cc -o $@ $(OBJECTS)
-
- $(OBJECTS) : $SOURCE
- cc -c $(OPT) $(@F:o=c) -o $@
-
- Can anybody tell me how I can get the OBJECT variable set correctly?
-
- Thanks to any and all.
- --
-
- *********************************************************************
- Alan Dare | Internet : alan@hal.larc.nasa.gov
- NASA Langley Research Center |
-