-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
87 lines (63 loc) · 1.76 KB
/
configure
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
#!/bin/sh
OPTFLAGS:=-O3 -ffast-math
ifeq ($(RELEASE),)
OPTFLAGS+=-g
else
OPTFLAGS+=-flto
endif
WARNINGS:=-Wall -Wextra -Wno-pointer-arith -Wno-unused-parameter
CFLAGS:=-std=c17 $(OPTFLAGS) $(WARNINGS)
LDFLAGS:=$(OPTFLAGS)
PREFIX?=/usr/local
INSTALL?=install
IFLAGS:=-D
all:
define decl
SRC_$1=$(patsubst %,./src/$1/%.c,$2)
OBJ_$1=$(patsubst %,./build/$1/%.o,$2)
all: ./build/$1
./build/$1:
@mkdir -p $$@
./build/$1/%.o: ./src/$1/%.c
$$(CC) -o $$@ -c $$< $$(CFLAGS) $$(CFLAGS_$1)
endef
define exec
all: ./build/$1/$1
install-exec: ./build/$1/$1
./build/$1/$1: $(OBJ_$1) $2
$$(CC) -o $$@ $$^ $$(LDFLAGS) $$(LDFLAGS_$1)
endef
define lib
all: ./build/$1/$1.ar ./build/$1/$1.so
install-lib: ./build/$1/$1.ar ./build/$1/$1.so
./build/$1/$1.ar: $(OBJ_$1) $2
$(AR) rcs $$@ $$^ $$(LDFLAGS_$1)
./build/$1/$1.so: $(OBJ_$1) $2
$(CC) -fPIC -shared -o $$@ $$^ $$(LDFLAGS_$1)
endef
define dev
install-dev: $(patsubst %,./include/%.h,$1)
endef
clean:
rm -rf ./build/*
install-exec:
$(INSTALL) $(IFLAGS) -s $^ -t $(PREFIX)/bin
install-lib:
$(INSTALL) $(IFLAGS) $^ -t $(PREFIX)/lib
install-dev:
$(INSTALL) $(IFLAGS) $^ -t $(PREFIX)/include/$(PROJECT)
install: install-exec install-lib install-dev
PROJECT:=terra
include common.mk
CFLAGS+=-I./ -I./include
$(eval $(call decl,libterra,util loop dynstr dynarr piper path gem pget))
$(eval $(call decl,libpcgi,pcgi))
$(eval $(call decl,rover,main gui draw line rover))
$(eval $(call decl,ares,main client cfg mod))
$(eval $(call exec,rover,$(OBJ_libterra)))
$(eval $(call exec,ares,$(patsubst %,./build/libterra/%.o,util loop dynarr)))
$(eval $(call lib,libpcgi,$(patsubst %,./build/libterra/%.o,util)))
$(eval $(call lib,libterra))
$(eval $(call dev,terra pcgi))
LDFLAGS_rover:=$(shell pkg-config --libs x11) -lutil
LDFLAGS_ares:=-lrt