-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
163 lines (124 loc) · 4.71 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
##
## Programmer: Craig Stuart Sapp <craig@ccrma.stanford.edu>
## Creation Date: Sat Nov 25 17:39:35 PST 2017
## Last Modified: Sat Nov 25 17:39:38 PST 2017
## Syntax: GNU Makefile
## Filename: pianoroll/Makefile
## vim: ts=3
##
## Description: Makefile to run tasks for library.
##
## To compile:
## make
##
# Set the environmental variable $MACOSX_DEPLOYMENT_TARGET to
# "10.9" in Apple OS X to compile for OS X 10.9 and later (for example,
# you can compile for OS X 10.9 computers even if you are using the 10.10
# version of the operating system).
ENV =
FLAG =
OS := $(shell uname -s)
ifeq ($(OS),Darwin)
OS = OSX
# Minimum OS X Version for C++14 is OS X 10.9:
ENV = MACOSX_DEPLOYMENT_TARGET=10.9
# use the following to compile for 32-bit architecture on 64-bit comps:
#ARCH = -m32 -arch i386
else
FLAG = -fext-numeric-literals
# use the following to compile for 32-bit architecture on 64-bit comps:
# (you will need 32-bit libraries in order to do this)
# ARCH = -m32
endif
###########################################################################
# #
# Beginning of user-modifiable configuration variables #
# #
BINDIR = bin
OBJDIR = obj
SRCDIR = src
TOOLDIR = tools
SRCDIR_MIN = src
INCDIR = include
EXTERNALINC = -Iexternal/midifile/include
EXTERNALSRC = external/midifile/src
LIBDIR = lib
LIBFILE = libpianoroll.a
AR = ar
RANLIB = ranlib
#DEFINES = -DDONOTUSEFFT
PREFLAGS = -c -g $(CFLAGS) $(DEFINES) -I$(INCDIR) $(EXTERNALINC)
PREFLAGS += -O3 -Wall
# using C++ 2014 standard for imaginary number literals.
PREFLAGS += -std=c++14 $(FLAG)
#PREFLAGS += -std=c++14
#PREFLAGS += -std=c++98
#PREFLAGS += -std=c++11
# Add -static flag to compile without dynamics libraries for better portability:
POSTFLAGS =
# POSTFLAGS += -static
COMPILER = LANG=C $(ENV) g++ $(ARCH)
# Or use clang++ v3.3:
#COMPILER = clang++
#PREFLAGS += -stdlib=libc++
# #
# End of user-modifiable variables. #
# #
###########################################################################
# setting up the directory paths to search for dependency files
vpath %.h $(INCDIR):$(SRCDIR):$(EXTERNALSRC)
vpath %.cpp $(SRCDIR):$(EXTERNALSRC):$(INCDIR)
vpath %.o $(OBJDIR)
# generating a list of the object files
OBJS =
OBJS += $(notdir $(patsubst %.cpp,%.o,$(wildcard $(SRCDIR)/tool-*.cpp)))
OBJS += $(notdir $(patsubst %.cpp,%.o,$(wildcard $(SRCDIR)/[A-Z]*.cpp)))
OBJS += $(notdir $(patsubst %.cpp,%.o,$(wildcard $(EXTERNALSRC)/[A-Z]*.cpp)))
# targets which don't actually refer to files
.PHONY: examples myprograms src include dynamic tools
###########################################################################
all: library tools
library: lib
lib: makedirs $(OBJS)
@-rm -f $(LIBDIR)/$(LIBFILE)
@$(AR) r $(LIBDIR)/$(LIBFILE) $(addprefix $(OBJDIR)/, $(OBJS))
@$(RANLIB) $(LIBDIR)/$(LIBFILE)
tool: tools
tools:
@$(MAKE) -f Makefile.programs
clean:
@echo Erasing object files...
@-rm -f $(OBJDIR)/*.o
@echo Erasing obj directory...
@-rmdir $(OBJDIR)
superclean: clean
-rm -rf $(LIBDIR)
-rm -f $(BINDIR)/test*
makedirs:
@-mkdir -p $(OBJDIR)
@-mkdir -p $(LIBDIR)
%:
@echo 'if [ "$<" == "" ]; then $(MAKE) -f Makefile.programs $@; fi' | bash -s
pugixml.o: pugixml.cpp
@echo [CC] $@ $<
@$(COMPILER) $(PREFLAGS) -o $(OBJDIR)/$(notdir $@) $(POSTFLAGS) $<
###########################################################################
# #
# defining an explicit rule for object file dependencies #
# #
%.o : %.cpp
@echo [CC] $@
@$(COMPILER) $(PREFLAGS) -o $(OBJDIR)/$(notdir $@) $(POSTFLAGS) $<
# #
###########################################################################
###########################################################################
# #
# Dependencies -- generated with the following command in #
# the src directory (in bash shell): #
# #
# for i in src/*.cpp
# do
# cc -std=c++14 -Iinclude -MM $i | sed 's/include\///g; s/src\///g'
# echo ""
# done
#