-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
92 lines (72 loc) · 2.25 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
TARGET = networking
DIRTARGET = libgolemnetworking.a
TYPE = debug
DIRS = .
LIBS = rt pthread golemachshm
DLIBS =
ifeq ($(TYPE), debug)
LDPARAM =
CCPARAM = -Wall -g
MACROS =
endif
ifeq ($(TYPE), release)
LDPARAM = -s
CCPARAM = -Wall
MACROS = NDEBUG
endif
INCPATH = .
LIBPATH =
CXX = g++
STORE = $(TYPE)
SOURCE := $(foreach DIR,$(DIRS),$(wildcard $(DIR)/*.cpp))
HEADERS := $(foreach DIR,$(DIRS),$(wildcard $(DIR)/*.h))
OBJECTS := $(addprefix $(STORE)/, $(SOURCE:.cpp=.o))
DFILES := $(addprefix $(STORE)/,$(SOURCE:.cpp=.d))
AFILES := $(addprefix $(STORE)/,$(SOURCE:.cpp=.a))
.PHONY = clean backup dirs
all : $(DIRTARGET)
$(DIRTARGET) : dirs $(OBJECTS)
@echo Creating library
ar -rc -o $(DIRTARGET) $(OBJECTS)
$(TARGET): dirs $(OBJECTS)
@echo Linking $(TARGET)
@$(CXX) -o $(TARGET) $(OBJECTS) $(LDPARAM) $(foreach LIBRARY, $(LIBS),-l$(LIBRARY)) $(foreach LIB,$(LIBPATH),-L$(LIB))
$(STORE)/%.o: %.cpp
@echo Creating object file for $*...
@$(CC) -Wp,-MMD,$(STORE)/$*.dd $(CCPARAM) $(foreach INC,$(INCPATH),-I$(INC)) $(foreach MACRO,$(MACROS),-D$(MACRO)) $(foreach LIBRARY, $(LIBS),-l$(LIBRARY)) -c $< -o $@
@sed -e '1s/^\(.*\)$$/$(subst /,\/,$(dir $@))\1/' $(STORE)/$*.dd > $(STORE)/$*.d
@rm -f $(STORE)/$*.dd
clean:
@-rm -f $(foreach DIR,$(DIRS),$(STORE)/$(DIR)/*.d $(STORE)/$(DIR)/*.o)
@-rm -f $(TARGET)
@-rm -f $(DIRTARGET)
@echo Cleaning Done
distclean:
@-rm -f $(foreach DIR,$(DIRS),$(STORE)/$(DIR)/*.d $(STORE)/$(DIR)/*.o)
@-rm -f $(TARGET)
@-rm -f $(DIRTARGET)
@-rm -rf debug/*
@@-if [ -e debug ]; then rmdir debug; fi;
@-rm -rf man/*
@@-if [ -e man ]; then rmdir man; fi;
@echo Cleaning Done
install:
@echo Compiling...
@echo Done.
@echo Installing...
cp *.h $(DESTDIR)/usr/local/include/
cp *.a $(DESTDIR)/usr/local/lib/
@echo Done.
doc:
@doxygen doxygen.config
cp ./man/man3/* $(DESTDIR)/usr/share/man/man3
backup:
@-if [ ! -e backup ]; then mkdir backup; fi;
@zip backup/backup_`date +%d-%m-%y_%H.%M`.zip $(SOURCE) $(HEADERS) $(EXTRA_FILES)
@echo Backup created in .backup/backup_`date +%d-%m-%y_%H.%M`.zip
dirs:
@-if [ ! -e $(STORE) ]; then mkdir $(STORE); fi;
@-$(foreach DIR,$(DIRS), if [ ! -e $(STORE)/$(DIR) ]; then mkdir $(STORE)/$(DIR); fi; )
deb:
@dpkg-buildpackage -ai386 -b -us -uc
-include $(DFILES)