- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Make file Related
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-26-2008 04:50 AM
тАО05-26-2008 04:50 AM
Make file Related
- Tags:
- make
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-26-2008 05:07 AM - edited тАО09-11-2011 02:59 PM
тАО05-26-2008 05:07 AM - edited тАО09-11-2011 02:59 PM
Re: Makefile Related
You can create your own compile rules:
$(objdir)/foo.o: foo.c
$(CC) -o $@ -c foo.c $(CFLAGS)
And when you link, you use a macro with a list of all of the objects created as above.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-26-2008 08:46 AM
тАО05-26-2008 08:46 AM
Re: Make file Related
you can else use the VPATH macro to reference source files not residing in the current dir (see manual).
For linking it's best to build libraries out of your object files (perhaps one lib per directory?) and reference these.
In dir1/Makefile:
...
OBJS=$(SRCS:.c=.o)
$(LIBDIR)/libdir1.a: $(OBJS)
ar c $@ $(OBJS)
In exe/Makefile:
...
USERLIBS=-L$(LIBDIR) -ldir1 -ldir2 ...
...
myexe:
$(CC) -o $@ ... $(USERLIBS) ...
mfG Peter
- Tags:
- VPATH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-27-2008 12:04 AM
тАО05-27-2008 12:04 AM
Re: Make file Related
LIBDIR=${PWD}/lib
BINDIR=${PWD}/bin
SRCDIR=${PWD}/src
VPATH=${SRCDIR}
all: clean ${LIBDIR}/session.o
#${LIBDIR}/session.o: ${SRCDIR}/session.c ${SRCDIR}/session.h
# ${CC} ${CFLAGS} -o $@ -c ${SRCDIR}/session.c
${LIBDIR}/session.o: session.c session.h
${CC} ${CFLAGS} -o $@ -c session.c
clean:
rm -f ${LIBDIR}/*.o
rm -f ${BINDIR}/*
Make fails with the following error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-27-2008 12:12 AM
тАО05-27-2008 12:12 AM
Re: Make file Related
(Bundled) cc: error 1913: `session.c' does not exist or cannot be read
*** Error exit code 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-27-2008 12:42 AM - edited тАО09-11-2011 03:00 PM
тАО05-27-2008 12:42 AM - edited тАО09-11-2011 03:00 PM
Re: Makefile Related
>I tried using VPATH. But it doesn't find the source files in a different directory.
Why are you using new-fangled VPATH?
Why not the tried and true relative path that points exactly to it?
If you use VPATH, as with any new and hard to use option, you need to read the documentation:
http://www.gnu.org/software/automake/manual/make/General-Search.html#General-Search
http://www.gnu.org/software/automake/manual/make/Commands_002fSearch.html#Commands_002fSearch
The second link indicates you need to use "$^" instead of session.c.
Unfortunately, make(1) while it documents VPATH, it is almost useless since it doesn't mention "$^" nor say that "$<" works for anything except inference rules.
#${LIBDIR}/session.o: ${SRCDIR}/session.c ${SRCDIR}/session.h
# ${CC} ${CFLAGS} -o $@ -c ${SRCDIR}/session.c
I assume this works?
>(Bundled) cc: error 1913: `session.c' does not exist or cannot be read
This indicates that VPATH isn't working.
Also, why are you using cc_bundled(1)?