-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
64 lines (51 loc) · 1.58 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
########################################################################
############################# Makefile ################################
########################################################################
# Compiler settings
LANG =
CC = g++
CXXFLAGS = -Wall -shared -fPIC $$(mysql_config --cxxflags) $(LANG)
LDFLAGS =
# Makefile settings
LIBNAME = lib_mysqludf_astro.so
EXT = .cpp
SRCDIR = src
OBJDIR = obj
MYSQLPLUGINDIR = $$(mysql_config --plugindir)
############## 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) $(MYSQLPLUGINDIR)/$(LIBNAME)
.PHONY: uninstall
uninstall:
$(RM) $(LIBNAME) $(MYSQLPLUGINDIR)/$(LIBNAME)