-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathMakefile.programs
More file actions
129 lines (102 loc) · 4.42 KB
/
Copy pathMakefile.programs
File metadata and controls
129 lines (102 loc) · 4.42 KB
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
##
## Programmer: Craig Stuart Sapp <craig@ccrma.stanford.edu>
## Creation Date: Mon Aug 10 16:06:48 PDT 2015
## Last Modified: Sat Jul 25 16:51:51 CEST 2026
## 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.programs",
## (or "gmake -f Makefile.programs" 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 "all", 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.
ENV =
ifeq ($(shell uname),Darwin)
ENV = MACOSX_DEPLOYMENT_TARGET=10.9
#ARCH = -m32 -arch i386
else
# 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 -Wsign-compare
PREFLAGS += -O3
PREFLAGS += -I$(MINDIR)
PREFLAGS += -I$(INCDIR) -I$(INCDIR)/pugixml -I$(INCDIR)/midifile
#PREFLAGS += -g
PREFLAGS += -std=c++17
ifeq ($(shell uname -s),Darwin)
PREFLAGS += -Wshorten-64-to-32
PREFLAGS += -Wsign-compare
endif
#PREFLAGS += -static
POSTFLAGS = -L$(LIBDIR) -l$(LIBFILE) -l$(PUGIXML) -l$(MIDIFILE)
COMPILER = LANG=C $(ENV) g++ $(ARCH)
#COMPILER = clang++
#PREFLAGS += -stdlib=libc++
# #
# End of user-modifiable variables. #
# #
###########################################################################
# Search paths for source and header prerequisites.
vpath %.h $(INCDIR) $(INCDIR)/midifile
vpath %.cpp $(wildcard tests/test-*) examples myprograms
vpath %.cpp $(wildcard $(TOOLDIR)) examples myprograms
# Programs compiled by the default target.
PROGS1 = $(notdir $(patsubst %.cpp,%,$(wildcard $(TOOLDIR)/*.cpp)))
PROGS = $(PROGS1) testgrid
# The actual archive file is the shared prerequisite. Unlike the old
# phony "library" prerequisite, GNU make builds this target at most once,
# then releases all program link commands to run in parallel.
LIBTARGET = $(LIBDIR)/lib$(LIBFILE).a
.PHONY: all examples info
###########################################################################
# #
# Main targets #
# #
examples: all
all: $(PROGS)
@echo Finished compiling all programs: $(PROGS).
info:
@echo "Programs to compile: $(PROGS)" | fmt
# Build the library only when the actual archive is absent.
# The leading '+' preserves GNU make's jobserver for the recursive make.
$(LIBTARGET):
+$(MAKE) library
# Create the output directory once. This is an order-only prerequisite,
# so the directory timestamp never forces programs to relink.
$(TARGDIR):
@mkdir -p $(TARGDIR)
# Every known program waits for the single completed library archive and
# the output directory. The suffix rule below performs the link.
$(PROGS): $(LIBTARGET) | $(TARGDIR)
###########################################################################
# #
# Compile/link a program from its matching .cpp source. #
# #
.cpp:
@echo [CC] $@
@$(COMPILER) $(PREFLAGS) -o $(TARGDIR)/$@ $< $(POSTFLAGS)
###########################################################################