-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
67 lines (53 loc) · 1.66 KB
/
Makefile
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
57
58
59
60
61
62
63
64
65
66
67
########################################################################
############################# Makefile ################################
########################################################################
# Compiler settings
CC = gcc
CXXFLAGS = -Wall -shared -fPIC -I/usr/include/mysql
LDFLAGS = -lpaho-mqtt3cs -ljsonparser
# Makefile settings
LIBNAME = lib_mysqludf_mqtt.so
EXT = .c
SRCDIR = src
OBJDIR = obj
LIBDIR = /usr/lib
MYSQLPLUGINDIR = $(LIBDIR)/mysql/plugin
############## Do not change anything from here downwards! #############
SRC = $(wildcard $(SRCDIR)/*$(EXT))
OBJ = $(SRC:$(SRCDIR)/%$(EXT)=$(OBJDIR)/%.o)
DEP = $(OBJ:$(OBJDIR)/%.o=%.d)
RM = rm
CP = cp
LN = ln
DELOBJ = $(OBJ)
########################################################################
####################### Targets beginning here #########################
########################################################################
all: $(LIBNAME)
# Builds the app
$(LIBNAME): $(OBJ)
$(CC) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)
# Creates the dependecy rules
%.d: $(SRCDIR)/%$(EXT)
@$(CPP) $(CFLAGS) $< -MM -MT $(@:%.d=$(OBJDIR)/%.o) >$@
# Includes all .h files
-include $(DEP)
# Building rule for .o files and its .c/.cpp in combination with all .h
$(OBJDIR)/%.o: $(SRCDIR)/%$(EXT)
$(CC) $(CXXFLAGS) -o $@ -c $<
# Cleans complete project
.PHONY: clean
clean:
$(RM) $(DELOBJ) $(DEP) $(LIBNAME)
# Cleans only all files with the extension .d
.PHONY: cleandep
cleandep:
$(RM) $(DEP)
.PHONY: install
install:
$(CP) $(LIBNAME) $(LIBDIR)/$(LIBNAME)
$(LN) -fs $(LIBDIR)/$(LIBNAME) $(MYSQLPLUGINDIR)/$(LIBNAME)
.PHONY: uninstall
uninstall:
$(RM) $(MYSQLPLUGINDIR)/$(LIBNAME)
$(RM) $(LIBDIR)/$(LIBNAME)