-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
161 lines (135 loc) · 3.46 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
# Copyright (C) 2012 John J. Glynn
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Source file root directory
SRC ?= src
# Header file root directory
INCLUDE ?= include
# Default build directory
BIN ?= bin
# Project name.
PROJECT = simpleCanvas
# Executable to build
EXECUTABLES = simpleCanvas
# Packages to build with. Requires pkg-config identifiers
PACKAGES =
# Files that are part of the project, but are not compiled
EXTRA =
# Other libaries
#LDLIBS = -lsfml-graphics-1.6 -lsfml-window-1.6 -lsfml-system-1.6 -lSOIL -lGL
LDLIBS = -lsfml-graphics -lsfml-window -lGL
# assembler
AS = as
# scanner generator
LEX = flex
# parser generator
YACC = bison
# C compiler
CC = gcc
# C++ compiler
CXX = g++
# linker
LD = g++
# assembler flags
ASFLAGS =
# c preproccessor flags
CPPFLAGS = -I $(CURDIR)/$(INCLUDE) -I /usr/include/sfml-1.6
# lex flags
LFLAGS =
# yacc flags
YFLAGS = -d -y
# c flags
CFLAGS = -g
# c++ flags
CXXFLAGS = $(CFLAGS)
# linking flags
LDFLAGS =
# END OPTIONS
# assembly source files
ASSOURCE = $(subst $(SRC)/,,$(shell find $(SRC) -name "[^.]*.s"))
ASOUTPUT = $(subst .s,.o,$(ASSOURCE))
# yacc source files
YSOURCE = $(subst $(SRC)/,,$(shell find $(SRC) -name "[^.]*.y"))
YOUTPUT = $(subst .y,.c,$(YSOURCE))
# lex source files
LSOURCE = $(subst $(SRC)/,,$(shell find $(SRC) -name "[^.]*.l"))
LOUTPUT = $(subst .l,.c,$(LSOURCE))
# c source files
CSOURCE = $(subst $(SRC)/,,$(shell find $(SRC) -name "[^.]*.c"))
CHEADER = $(subst $(INCLUDE)/,,$(shell find $(INCLUDE) -name "[^.]*.h"))
COUTPUT = $(subst .c,.o,$(CSOURCE))\
$(subst .y,.o,$(YSOURCE))\
$(subst .l,.o,$(LSOURCE))
# c++ source files
CXXSOURCE = $(subst $(SRC)/,,$(shell find $(SRC) -name "[^.]*.cpp"))
CXXHEADER = $(subst $(INCLUDE)/,,$(shell find $(INCLUDE) -name "[^.]*.hpp"))
CXXOUTPUT = $(subst .cpp,.o,$(CXXSOURCE))
export SRCDIR = $(CURDIR)/$(SRC)
export INCLUDEDIR = $(CURDIR)/$(INCLUDE)
export PACKAGES
export PROJECT
export AS
export LEX
export YACC
export CC
export CXX
export LD
export ASFLAGS
export CPPFLAGS
export LFLAGS
export YFLAGS
export LFLAGS
export CFLAGS
export CXXFLAGS
export LDFLAGS
export LDLIBS
export ASSOURCE
export ASOUTPUT
export YSOURCE
export YOUTPUT
export YOBJECT
export LSOURCE
export LOUTPUT
export LOBJECT
export CSOURCE
export COUTPUT
export CXXSOURCE
export CXXOUTPUT
all : $(EXECUTABLES)
$(EXECUTABLES): yacc lex
$(MAKE) $@ -C $(BIN) "EXECUTABLE=$@"
compile: as c cxx
as:
$(MAKE) as -C $(BIN)
c: yacc lex
$(MAKE) c -C $(BIN)
cxx:
@echo $(CXXSOURCE)
$(MAKE) cxx -C $(BIN)
yacc :
$(MAKE) yacc -C $(BIN)
lex :
$(MAKE) lex -C $(BIN)
dist :
tar --transform 's,^,$(PROJECT)/,' -czf $(PROJECT).tar.gz\
Makefile $(BIN)/Makefile\
$(EXTRA)\
$(addprefix $(SRC)/,$(CSOURCE))\
$(addprefix $(SRC)/,$(YSOURCE))\
$(addprefix $(SRC)/,$(LSOURCE))\
$(addprefix $(SRC)/,$(CXXSOURCE))\
$(addprefix $(INCLUDE)/,$(CHEADER))\
$(addprefix $(INCLUDE)/,$(CXXHEADER))
clean :
$(MAKE) clean -C $(BIN)