January 25th, 2011, 11:19 PM
I've got the following Makefile:
It compiles "swetest", and "libswe.a" but not "swemini" and "libswe.so". I don't know why.
CFLAGS = -g -O9 -Wall -pedantic # for Linux and other gcc systems
CC=cc #for Linux
# compilation rule for general cases
$(CC) $(OP) -o $@ $? -lm
$(CC) -c $(OP) $<
SWEOBJ = swedate.o swehouse.o swejpl.o swemmoon.o swemplan.o swepcalc.o sweph.o\
swepdate.o swephlib.o swecl.o swehel.o
swetest: swetest.o libswe.a
$(CC) $(OP) -o swetest swetest.o -L. -lswe -lm
swemini: swemini.o libswe.a
$(CC) $(OP) -o swemini swemini.o -L. -lswe -lm
ar r libswe.a $(SWEOBJ)
$(CC) -shared -o libswe.so $(SWEOBJ)
rm -f *.o swetest libswe*
swecl.o: swejpl.h sweodef.h swephexp.h swedll.h sweph.h swephlib.h
sweclips.o: sweodef.h swephexp.h swedll.h
swedate.o: swephexp.h sweodef.h swedll.h
swehouse.o: swephexp.h sweodef.h swedll.h swephlib.h swehouse.h
swejpl.o: swephexp.h sweodef.h swedll.h sweph.h swejpl.h
swemini.o: swephexp.h sweodef.h swedll.h
swemmoon.o: swephexp.h sweodef.h swedll.h sweph.h swephlib.h
swemplan.o: swephexp.h sweodef.h swedll.h sweph.h swephlib.h swemptab.c
swepcalc.o: swepcalc.h swephexp.h sweodef.h swedll.h
sweph.o: swejpl.h sweodef.h swephexp.h swedll.h sweph.h swephlib.h
swehel.o: sweodef.h swedll.h swephexp.h sweph.h swephlib.h
swephlib.o: swephexp.h sweodef.h swedll.h sweph.h swephlib.h
swetest.o: swephexp.h sweodef.h swedll.h
Does anyone have any ideas that can help me out or improve the Makefile?
January 26th, 2011, 05:25 AM
How are you running this?
January 26th, 2011, 06:37 AM
Originally Posted by ishnid
January 26th, 2011, 06:53 AM
If you do that, it will by default run the first target, which is swetest. It's not asked to run swemini so that's why your files are missing.
You could add another target at the top of the file that would have a dependency on both swetest and swemini if you wanted to run both by default, e.g.:
all: swetest swemini
January 26th, 2011, 08:06 AM
How would I do that? - sorry to bother. Just add the line?
And what about "libswe.so"?
January 26th, 2011, 08:27 AM
I'd suggest reading a tutorial on makefiles so that you can fully understand what's going on with this.
Yes, place the line I gave you somewhere above the "swetest: swetest.o libswe.a" line, so that it's the first target that 'make' sees.
As for libswe.so, I hadn't spotted that. If you want that target to be run too, then add it as a dependency for 'all' too.
January 26th, 2011, 09:02 AM
Thank you very much - it works fine. And it "makes" perfect sense