aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: d64f0b343f67617be24dd89146d51352393f35b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
CC      = /usr/bin/g++
CFLAGS  = -Wall -std=c++11 -shared -fPIC
DEBUGFLAGS = -Wall -g -std=c++11
LDFLAGS =
SONAME = engine
BUILDDIR = build
#VERSION
VERSION = 0
PATCHLEVEL = 4
OUTPUT = lib$(SONAME).so.$(VERSION).$(PATCHLEVEL)

OBJ = cObject.o cObjectHandler.o cRender.o cInput.o cWiremesh.o

build: genversion $(OBJ)
	mkdir -p $(BUILDDIR)
	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
	@echo Building $<
	@echo ==============
	@echo
	$(CC) $(CFLAGS) -c $<



all: clean build

.PHONY: clean

clean:
	rm -df  $(OBJ) test.o version.h
	rm -R $(BUILDDIR)

run: test

genversion:
	@echo Building Version
	@echo "//Generated by MAKEFILE. DO NOT Edit." > version.h
	@echo "#pragma once" >> version.h
	@echo "#define VERSION $(VERSION)" >> version.h
	@echo "#define PATCHLEVEL $(PATCHLEVEL)" >> version.h
	@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