-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
63 lines (47 loc) · 1.86 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
# libScricon: The Simple Graphical Console Library
# Copyright (C) 2021-2022 Jyothiraditya Nellakra
#
# 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 <https://www.gnu.org/licenses/>.
headers = $(wildcard include/*.h)
objs = $(patsubst %.c,%.o,$(wildcard src/*.c))
demos = $(patsubst demo/%.c,%,$(wildcard demo/*.c))
demo_objs = $(patsubst %.c,%.o,$(wildcard demo/*.c))
demo_shs += $(patsubst demo/%.sh,%,$(wildcard demo/*.sh))
files = $(foreach file,$(objs) $(demo_objs),$(wildcard $(file)))
files += $(foreach file,$(demos) $(demo_shs),$(wildcard $(file)))
files += $(wildcard *.a)
CLEAN = $(foreach file,$(files),rm $(file);)
CPPFLAGS += -std=gnu17 -Wall -Wextra -Wpedantic -Ofast
CPPFLAGS += -I inc/ -I libClame/inc/
CFLAGS += -std=gnu17 -Ofast -s
libs = libClame/libClame.a libScricon.a
LD_LIBS ?= -L. -lScricon -lm -L libClame -lClame
$(objs) : %.o : %.c $(headers)
$(CC) $(CPPFLAGS) -c $< -o $@
libScricon.a : $(objs)
$(AR) -r libScricon.a $(objs)
$(demo_objs) : %.o : %.c $(headers)
$(CC) $(CPPFLAGS) -c $< -o $@
$(demos) : % : demo/%.o $(libs)
$(CC) $(CFLAGS) $< -o $@ $(LD_LIBS)
$(demo_shs) : % : demo/%.sh
cp $< $@; chmod +x $@
libClame/libClame.a : libClame
+cd libClame; $(MAKE) libClame.a;
.DEFAULT_GOAL = all
.PHONY : all clean
all : libScricon.a $(demos) $(demo_shs)
clean :
$(CLEAN)
+cd libClame; $(MAKE) clean