blob: e2d30e5133659f53142f2da0941c4e80b3391bb6 (
plain)
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
|
################################################################################
#
# NetCosm - a MUD server
# Copyright (C) 2016 Franklin Wei
#
# 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/>.
#
################################################################################
# Definitions
################################################################################
CC = cc
BUILDDIR = build
PLATFORM = unix
OUT = $(BUILDDIR)/$(PLATFORM).bin
PREFIX = /usr/local
SRC = $(shell cat SOURCES)
OBJ = $(patsubst %.c,$(BUILDDIR)/%.o,$(SRC))
INCLUDES = -I src/ -I export/include/
WARNFLAGS = -Wall -Wextra -Wshadow -fno-strict-aliasing
OPTFLAGS = -O3
DEBUGFLAGS = -g
CFLAGS = $(OPTFLAGS) $(DEBUGFLAGS) $(WARNFLAGS) -std=c99 $(INCLUDES)
LDFLAGS = -lev -lcrypto -lbsd
HEADERS = src/*.h export/include/*.h
DEPS = $(patsubst %.c,$(BUILDDIR)/%.d,$(SRC))
# Main targets
################################################################################
.PHONY: all
all: | $(OUT)
$(OUT): $(OBJ)
@echo "LD $@"
@$(CC) $(OBJ) $(CFLAGS) -o $@ $(LDFLAGS)
$(OBJ): | $(BUILDDIR)
$(BUILDDIR):
@mkdir -p $(BUILDDIR)
$(BUILDDIR)/%.o: %.c $(BUILDDIR)/%.d Makefile
@echo "CC $<"
@mkdir -p `dirname $@`
@$(CC) -c $< $(CFLAGS) -o $@
# Dependencies
################################################################################
.PRECIOUS: $(BUILDDIR)/%.d
$(BUILDDIR)/%.d: %.c
@mkdir -p `dirname $@`
@$(CC) $(CCFLAGS) -MF"$@" -MG -MM -MP -MT"$@" -MT"$(<:.c=.o)" "$<"
-include $(DEPS)
# Helper targets
################################################################################
.PHONY: setcap
setcap:
@echo "Setting CAP_NET_BIND_SERVICE on $(OUT)..."
@sudo setcap 'cap_net_bind_service=+ep' "$(OUT)"
.PHONY: clean
clean:
@echo "Cleaning build directory..."
@rm -f $(OBJ) $(OUT)
.PHONY: veryclean
veryclean:
@echo "Removing build directory..."
@rm -rf $(BUILDDIR)
.PHONY: depend
depend: $(DEPS)
@echo "Dependencies (re)generated."
.PHONY: install
install: $(OUT)
@install build/unix.bin $(PREFIX)/bin/netcosm
|