home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.unix.shell:3802 comp.unix.questions:10685
- Newsgroups: comp.unix.shell,comp.unix.questions
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!sdd.hp.com!cs.utexas.edu!convex!news.utdallas.edu!corpgate!bnrgate!bcars267!bmdhh243!agc
- From: agc@bmdhh298.bnr.ca (Alan Carter)
- Subject: Re: Need help from a make guru
- Message-ID: <1992Sep03.105554.10887@bnr.uk>
- Sender: news@bnr.uk (News Administrator)
- Nntp-Posting-Host: bmdhh298
- Organization: BNR-Europe-Limited, Maidenhead, England
- References: <Btytp9.BKs@news.larc.nasa.gov> <1992Sep3.071821.3803@ericsson.se>
- Date: Thu, 03 Sep 1992 10:55:54 GMT
- Lines: 48
-
- In article <Btytp9.BKs@news.larc.nasa.gov>, alan@hal.larc.nasa.gov (alan dare) writes:
- |>
- |> 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?
-
- Your problem is that you are trying to nest the stuff in `` command line
- substitution braces. This is not allowed. Do it in two steps:
-
- TEMP=`ls *.c |sed 's/\.c/.o/g'\`
- OBJECTS=`for i in $TEMP; do echo "../obj/$i"; done`
-
- Alan
-
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Maidenhead itself is too snobby to be pleasant. It is the haunt of the
- river swell and his overdressed female companion. It is the town of showy
- hotels, patronized chiefly by dudes and ballet girls.
-
- Three Men In A Boat, Jerome K. Jerome, 1889
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-