Makefile.dynamic 1.12 KB
Newer Older
Achim Morschhauser's avatar
Achim Morschhauser committed
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
SRC_DIR=src/
OBJ_DIR=lib/
HDR_DIR=include/
LIB_DIR=./lib/

USR_DIR=usr/
BIN_DIR=bin/

#--------------------------------------
#--------------------------------------
SRC_FILES  = $(wildcard $(SRC_DIR)*.cpp)
OBJ_FILES  = $(patsubst $(SRC_DIR)%.cpp,$(OBJ_DIR)%.o,$(SRC_FILES))
USR_FILES  = $(wildcard $(USR_DIR)*.cpp)
USR_TARGET = $(patsubst $(USR_DIR)%.cpp,%,$(USR_FILES))
#--------------------------------------
CC=g++

CCFLAGS=-g -lrt  -std=c++11 -lpthread

EXCL=driver_serial_emulate.o
# Uncomment to use virtual serial port. Run 'make clean all' afterwards
#EXCL=driver_serial.o

.SECONDARY:

26
all: $(LIB_DIR)libLogger.so $(USR_TARGET:%=$(BIN_DIR)%)
Achim Morschhauser's avatar
Achim Morschhauser committed
27
28
29
30
31

%: $(BIN_DIR)%
	@echo ---- DONE ----


Achim Morschhauser's avatar
Achim Morschhauser committed
32
$(BIN_DIR)%: $(USR_DIR)%.cpp 
Achim Morschhauser's avatar
Achim Morschhauser committed
33
34
35
36
37
38
39
40
41
42
43
44
45
	$(CC) $(CCFLAGS) -no-pie $< -o $@ -I$(HDR_DIR) -L$(LIB_DIR) -Wl,-rpath,"\$$ORIGIN/../$(LIB_DIR)" -lLogger
#	$(CC) $(CCFLAGS)  $< -o $@ -I$(HDR_DIR) -L$(LIB_DIR) -lLogger

$(OBJ_DIR)%.o: $(SRC_DIR)%.cpp
	$(CC) $(CCFLAGS) -fPIC -c -o $@ $< -I$(HDR_DIR)

$(LIB_DIR)libLogger.so: $(filter-out $(OBJ_DIR)$(EXCL) ,$(OBJ_FILES))
	$(CC) $^  -shared -o $@

clean:
	rm -f $(BIN_DIR)*
	rm -f $(OBJ_DIR)*
	rm -f $(LIB_DIR)libLogger.so