-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile.programs
135 lines (103 loc) · 4.27 KB
/
Makefile.programs
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
##
## Programmer: Craig Stuart Sapp <[email protected]>
## Creation Date: Mon Aug 10 16:06:48 PDT 2015
## Last Modified: Sun Apr 16 10:01:31 PDT 2023
## Syntax: GNU Makefile
## Filename: Makefile.programs
## vim: ts=3
##
## Description: Makefile to compile programs using the humlib library.
##
## To run this makefile, type (without quotes) "make -f Makefile.examples",
## (or "gmake -f Makefile.examples" on FreeBSD computers). However this makefile
## is intended to be used with the file "Makefile" which runs this makefile with
## the command "make programs". The program executables will be placed
## in the "bin" directory.
##
## Without arguments or with the argument "programs", this makefile will
## compile all programs. If you give a program name as an argument, it
## will compile just that program. E.g.: "make -f Makefile.programs flipper"
## or used in conjunction with "Makefile", type "make flipper", which will
## compile the cli/flipper.cpp program and place it in the ./bin directory.
# 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 =
ifeq ($(shell uname),Darwin)
ENV = MACOSX_DEPLOYMENT_TARGET=10.9
# use the following to compile for 32-bit architecture on 64-bit comps:
#ARCH = -m32 -arch i386
else
# 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 #
# #
INCDIR = include
MINDIR = min
LIBDIR = lib
LIBFILE = humlib
TARGDIR = bin
TOOLDIR = cli
PUGIXML = pugixml
MIDIFILE = midifile
PREFLAGS = -Wall
PREFLAGS += -O3
PREFLAGS += -I$(MINDIR)
PREFLAGS += -I$(INCDIR) -I$(INCDIR)/pugixml -I$(INCDIR)/midifile
# include debugging information:
#PREFLAGS += -g
# using C++ 2011/2017 standard:
PREFLAGS += -std=c++17
# Add -static flag to compile without dynamics libraries for better portability:
#PREFLAGS += -static
POSTFLAGS = -L$(LIBDIR) -l$(LIBFILE) -l$(PUGIXML) -l$(MIDIFILE)
COMPILER = LANG=C $(ENV) g++ $(ARCH)
# Alternatly, 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) $(INCDIR)/midifile
vpath %.cpp $(wildcard tests/test-*) examples myprograms
vpath %.cpp $(wildcard $(TOOLDIR)) examples myprograms
# generating a list of the programs to compile with "make all"
PROGS1=$(notdir $(patsubst %.cpp,%,$(wildcard $(TOOLDIR)/*.cpp)))
PROGS=$(PROGS1) testgrid
# targets which don't actually refer to files
.PHONY: examples
###########################################################################
# #
# #
examples: all
all: library bin $(PROGS)
@echo Finished compiling all programs: $(PROGS).
library:
@make library
info:
@echo "Programs to compile: $(PROGS)" | fmt
bin:
ifeq ($(wildcard $(TARGDIR)),)
@-mkdir -p $(TARGDIR)
endif
###########################################################################
#
# Defining explicit rules for program sourcefile dependencies:
#
.cpp: library
ifeq ($(wildcard $(TARGDIR)),)
@-mkdir -p $(TARGDIR)
endif
@echo [CC] $@
@$(COMPILER) $(PREFLAGS) -o $(TARGDIR)/$@ $< $(POSTFLAGS)
# && strip $(TARGDIR)/$@$(EXTEN)
# #
# #
###########################################################################