P
Peter Smithson
Hi,
I did a search for this and other than GNU specific replies, I couldn't
find the answer. I know it's not really a C++ question but I don't
know of a group for makefiles for C++ and people on this list must have
come across the problem.
It's really simple - how do I write a makefile which will work on
Solaris, HPUX and Linux using the "make" that comes with the OS. It'd
be nice if it worked on AIX, SCO OS, Unixware etc. too.
One nice looking solution I found was this -
%.o: %.cpp
g++ -I$(INCLUDES) -c $<
But I think that requires the GNU make as it didn't work on Solaris.
I've currently got this. It works on all platforms but it's a pain -
clist.o: clist.cpp
$(CXX) $(CFLAGS) -c -o $@ clist.cpp
$(LIB)(clist.o):clist.o
$(AR) -rv $(LIB) clist.o
$(LIB): \
$(LIB)(clist.o)\
etc.
I know one answer is to always use gmake but it's just one more step
when you do a port (get gmake built) so I'd rather avoid it.
Thanks.
Peter
I did a search for this and other than GNU specific replies, I couldn't
find the answer. I know it's not really a C++ question but I don't
know of a group for makefiles for C++ and people on this list must have
come across the problem.
It's really simple - how do I write a makefile which will work on
Solaris, HPUX and Linux using the "make" that comes with the OS. It'd
be nice if it worked on AIX, SCO OS, Unixware etc. too.
One nice looking solution I found was this -
%.o: %.cpp
g++ -I$(INCLUDES) -c $<
But I think that requires the GNU make as it didn't work on Solaris.
I've currently got this. It works on all platforms but it's a pain -
clist.o: clist.cpp
$(CXX) $(CFLAGS) -c -o $@ clist.cpp
$(LIB)(clist.o):clist.o
$(AR) -rv $(LIB) clist.o
$(LIB): \
$(LIB)(clist.o)\
etc.
I know one answer is to always use gmake but it's just one more step
when you do a port (get gmake built) so I'd rather avoid it.
Thanks.
Peter