From 13d5e5f8f40cd3c14d47406a12dbf46fae87b653 Mon Sep 17 00:00:00 2001 From: Daniel Warner Date: Sat, 23 Apr 2011 12:13:06 +0000 Subject: [PATCH] Create static library in Makefile --- .hgignore | 3 ++- Makefile | 26 ++++++++++++++++++-------- RunTest.cpp | 1 + 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/.hgignore b/.hgignore index 7d7abee..cd3cbf1 100644 --- a/.hgignore +++ b/.hgignore @@ -2,6 +2,7 @@ syntax: glob Release\* Debug\* *.o -sat +RunTest *.txt *.orig +*.a diff --git a/Makefile b/Makefile index 7c79088..b6c8322 100644 --- a/Makefile +++ b/Makefile @@ -1,26 +1,36 @@ CC=g++ +AR=ar CFLAGS=-c -Wall -O2 LDFLAGS= -SOURCES=Coord.cpp \ + +SOURCES=CoordGeodetic.cpp \ + CoordTopographic.cpp \ Eci.cpp \ Globals.cpp \ Julian.cpp \ Observer.cpp \ SGP4.cpp \ + SatelliteOrbit.cpp \ Timespan.cpp \ Tle.cpp \ - Vector.cpp \ - main.cpp + Vector.cpp OBJECTS=$(SOURCES:.cpp=.o) -EXECUTABLE=sat +SGP4LIB=libsgp4.a -all: $(SOURCES) $(EXECUTABLE) +TESTPROG=RunTest +TESTSOURCES=RunTest.cpp +TESTOBJECTS=$(TESTSOURCES:.cpp=.o) -$(EXECUTABLE): $(OBJECTS) - $(CC) $(LDFLAGS) $(OBJECTS) -o $@ +all: $(SGP4LIB) ${TESTPROG} + +${SGP4LIB}: ${OBJECTS} + ${AR} -rcs -o $@ ${OBJECTS} + +${TESTPROG}: ${SGP4LIB} ${TESTOBJECTS} + $(CC) ${TESTOBJECTS} $(LDFLAGS) -static -L. -lsgp4 -o $@ .cpp.o: $(CC) $(CFLAGS) $< -o $@ clean: - rm -rf *.o $(EXECUTABLE) + rm -rf *.o ${SGP4LIB} ${TESTPROG} diff --git a/RunTest.cpp b/RunTest.cpp index 3f74fc0..623e737 100644 --- a/RunTest.cpp +++ b/RunTest.cpp @@ -12,6 +12,7 @@ #include #include #include +#include void RunTle(Tle tle, double start, double end, double inc) { double current = start;