summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorGravatar jonas <himself@jonasgunz.de> 2019-01-29 16:49:35 +0100
committerGravatar jonas <himself@jonasgunz.de> 2019-01-29 16:49:35 +0100
commitcf5bf15232c19dda330f7ccab7737f828460f001 (patch)
tree08210c5391d78a98dfb3c9d59ad018ecd331414e /Makefile
parentda2b8fc6673076d3fc600d275f5e5c8e95b54cac (diff)
downloadtermgl-cf5bf15232c19dda330f7ccab7737f828460f001.tar.gz
Makefile now creates dynamic library Package
main.cpp is now test.cpp and contains a test routine. Build with make test
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile33
1 files changed, 24 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index a91b1d8..ae3da54 100644
--- a/Makefile
+++ b/Makefile
@@ -1,17 +1,25 @@
CC = /usr/bin/g++
-CFLAGS = -Wall -g -std=c++11
+CFLAGS = -Wall -std=c++11 -shared -fPIC
+DEBUGFLAGS = -Wall -g -std=c++11
LDFLAGS =
-OUTPUT = Engine
+SONAME = engine
BUILDDIR = build
#VERSION
VERSION = 0
PATCHLEVEL = 3
+OUTPUT = lib$(SONAME).so.$(VERSION).$(PATCHLEVEL)
-OBJ = main.o cObject.o cObjectHandler.o cRender.o cInput.o cWiremesh.o
+OBJ = cObject.o cObjectHandler.o cRender.o cInput.o cWiremesh.o
-debug: genversion $(OBJ)
+build: genversion $(OBJ)
mkdir -p $(BUILDDIR)
- $(CC) $(CFLAGS) -o $(BUILDDIR)/$(OUTPUT) $(OBJ) $(LDFLAGS)
+ mkdir -p $(BUILDDIR)/lib
+ mkdir -p $(BUILDDIR)/inc
+ $(CC) $(CFLAGS) -o $(BUILDDIR)/lib/$(OUTPUT) $(OBJ) $(LDFLAGS) -Wl,-soname=lib$(SONAME).so.$(VERSION)
+ ln -sf $(OUTPUT) $(BUILDDIR)/lib/lib$(SONAME).so.$(VERSION)
+ ln -sf $(OUTPUT) $(BUILDDIR)/lib/lib$(SONAME).so
+ cp c*.h $(BUILDDIR)/inc
+ cp version.h $(BUILDDIR)/inc
%.o: %.cpp
@echo
@@ -20,15 +28,17 @@ debug: genversion $(OBJ)
@echo
$(CC) $(CFLAGS) -c $<
-all: clean debug
+
+
+all: clean build
.PHONY: clean
clean:
- rm -df $(BUILDDIR)/$(OUTPUT) $(OBJ) version.h
+ rm -df $(OBJ) test.o version.h
+ rm -R $(BUILDDIR)
-run: debug
- ./$(BUILDDIR)/$(OUTPUT)
+run: test
genversion:
@echo Building Version
@@ -39,3 +49,8 @@ genversion:
@echo "#define BRANCH \"`git status -bs | grep '##'`\"" >> version.h
@echo "#define DATE \"`date +'%d.%m.20%y'`\"" >> version.h
@echo "#define TIME \"`date +'%H:%M:%S'`\"" >> version.h
+
+test: genversion test.o $(OBJ)
+ mkdir -p $(BUILDDIR)/test
+ $(CC) $(DEBUGFLAGS) -o $(BUILDDIR)/test/test test.o $(OBJ) $(LDFLAGS)
+ ./$(BUILDDIR)/test/test test