-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
100 lines (85 loc) · 2.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
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
92
93
94
95
96
97
98
99
100
#############################################################
# #
# Generic Makefile for C++ projects #
# Author: Gabriel <software@kanedo.net> #
# Date: 2014-04-18 #
# Version: 1.0 #
# #
#############################################################
# the C++ Compiler
CPP=g++
# the C Compiler
CC=gcc
# Compiler flags for C++
CPPFLAGS=-g -c -std=c++11
# Compiler flags for C
CFLAGS=-g -c
# Linker Flags
#-lz use with zlib for gzstream.o
LDFLAGS=-g -lz
# define an asset dir (optional)
ASSETSDIR=assets
# set to 1 if ASSETSDIR should be copied to BUILDIR
# set to 0 if not
WITH_COPY_ASSETS=1
# CONFIGURATION_BUILD_DIR is usually defined by Xcode
# use it.
# otherwise (e.g. invoked from commandline) use build/ as buildir
ifdef CONFIGURATION_BUILD_DIR
BUILDIR=$(CONFIGURATION_BUILD_DIR)
else
BUILDIR=build
endif
# list dependencies
# DEPS=gzstream.c
DEPS=
# replace .c file ending and replace it with .o. change dir to $(BUILDIR)
DEPS_OBJECTS=$(patsubst %.c,$(BUILDIR)/%.o,$(DEPS))
# list sources
SOURCES=$(wildcard *.cpp)
# replace .cpp file ending and replace it with .o. change dir to $(BUILDIR)
OBJECTS=$(patsubst %.cpp,$(BUILDIR)/%.o,$(SOURCES))
# PRODUCT_NAME is usually defined by Xcode.
# use it as executable name
# otherwise define your own
ifdef PRODUCT_NAME
EXECUTABLE=$(PRODUCT_NAME)
else
EXECUTABLE=apobec
endif
.PHONY: all run clean COPY_ASSETS
all: $(BUILDIR)/$(EXECUTABLE)
# PRODUCT_NAME is usually defined by xcode in which case only make all is invoked
# to run the project. we need to copy some asset-files in the build folder in order to run the executable properly
ifdef PRODUCT_NAME
ifeq ($(WITH_COPY_ASSETS),1)
$(MAKE) COPY_ASSETS
endif
endif
# build executable
$(BUILDIR)/$(EXECUTABLE): $(BUILDIR) $(DEPS_OBJECTS) $(OBJECTS)
$(CPP) $(LDFLAGS) $(DEPS_OBJECTS) $(OBJECTS) -o $@
# compile dependencies
$(DEPS_OBJECTS): $(DEPS)
${CPP} -I. -O -c $< -o $@
# compile cpp files
$(BUILDIR)/%.o: %.cpp
$(CPP) $(CPPFLAGS) $< -o $@
# target to create the builddir
$(BUILDIR):
mkdir -p $@
# phony target to copy asset files into the builddir
COPY_ASSETS:
mkdir -p $(BUILDIR)/$(ASSETSDIR)
cp -rf $(ASSETSDIR)/ $(BUILDIR)/$(ASSETSDIR)
# phony target which calls the executable
# copies optional asset files and
# invokes the exec with arguments
run: all
ifeq ($(WITH_COPY_ASSETS),1)
$(MAKE) COPY_ASSETS
endif
./$(BUILDIR)/$(EXECUTABLE) -e $(BUILDIR)/$(ASSETSDIR)/e.train.gz -f $(BUILDIR)/$(ASSETSDIR)/f.train.gz -a $(BUILDIR)/$(ASSETSDIR)/Alignment.gz
# remove generated files
clean:
rm -rf $(BUILDIR) $(DEPS_OBJECTS) $(OBJECTS) $(EXECUTABLE)