forked from amnuts/Amnuts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
151 lines (127 loc) · 5.16 KB
/
Copy pathMakefile
File metadata and controls
151 lines (127 loc) · 5.16 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#
# General setup of GCC and compiler flags, base directories, etc.
#
BINDIR = $(CURDIR)/build
INCDIR = $(CURDIR)/src/includes
PERMS = 755
CC = clang
# -std=gnu23 = Use the C23 standard with GNU extras
# -g = Add debugging information to the executable
# -Wall = Enable all compiler warnings
# -Wextra = Extra warnings not covered by the above
# -MMD = Generate dependency files
# -Wpedantic = Be pedantic about the code
C_FLAGS = -std=gnu23 -g -Wall -Wextra -MMD -Wpedantic
CC_FLAGS = -I$(INCDIR)
LD_FLAGS =
#
# TALKER_FLAGS allows you to turn off certain aspects within the talker
# as if they were never there. Don't want Netlinks function? Then just
# remove the '-DNETLINKS' - same for the others.
# Possible flags are (each starting with '-D'):
# GAMES - include games
# WIZPORT - Allow a separate port just for WIZ levels to use
# IDENTD - Ident Daemon
# MANDNS - Manual DNS lookups
# NETLINKS - The infamous Netlinks
#
TALKER_FLAGS = -DGAMES -DWIZPORT -DIDENTD -DMANDNS -DNETLINKS
#
# Locations and binary name for talker build
#
TALKER_BIN = amnutsTalker
TALKER_SRC_DIR = $(CURDIR)/src
TALKER_OBJ_DIR = $(TALKER_SRC_DIR)/objects
TALKER_SRC = $(wildcard $(TALKER_SRC_DIR)/*.c $(TALKER_SRC_DIR)/commands/*.c)
TALKER_OBJS = $(addprefix $(TALKER_OBJ_DIR)/,$(notdir $(TALKER_SRC:.c=.o)))
#
# Locations and binary name for ident server build
#
IDENTD_BIN = amnutsIdent
IDENTD_SRC_DIR = $(TALKER_SRC_DIR)/identd
IDENTD_OBJ_DIR = $(TALKER_OBJ_DIR)
IDENTD_SRC = $(wildcard $(IDENTD_SRC_DIR)/*.c)
IDENTD_OBJS = $(addprefix $(IDENTD_OBJ_DIR)/,$(notdir $(IDENTD_SRC:.c=.o)))
#
# Locations of vendors libraries
#
# SDS: https://github.com/antirez/sds
VENDOR_SDS_SRC_DIR = $(TALKER_SRC_DIR)/vendors/sds
VENDOR_SDS_OBJ_DIR = $(TALKER_OBJ_DIR)
VENDOR_SDS_SRC = $(wildcard $(VENDOR_SDS_SRC_DIR)/*.c)
VENDOR_SDS_OBJS = $(addprefix $(VENDOR_SDS_OBJ_DIR)/,$(notdir $(VENDOR_SDS_SRC:.c=.o)))
# libtelnet: https://github.com/seanmiddleditch/libtelnet
VENDOR_LIBTELNET_SRC_DIR = $(TALKER_SRC_DIR)/vendors/libtelnet
VENDOR_LIBTELNET_OBJ_DIR = $(TALKER_OBJ_DIR)
VENDOR_LIBTELNET_SRC = $(wildcard $(VENDOR_LIBTELNET_SRC_DIR)/*.c)
VENDOR_LIBTELNET_OBJS = $(addprefix $(VENDOR_LIBTELNET_OBJ_DIR)/,$(notdir $(VENDOR_LIBTELNET_SRC:.c=.o)))
#
# Platform-specific libraries that need to be included
#
UNAME = $(shell uname)
ifeq ($(UNAME), Darwin)
LD_FLAGS += -L/usr/local/opt/openssl/lib
CC_FLAGS += -I/usr/local/opt/openssl/include
TALKER_LIBS = -lcrypto
IDENTD_LIBS =
endif
ifeq ($(UNAME), SunOS)
TALKER_LIBS = -lnsl -lsocket
IDENTD_LIBS =
endif
ifeq ($(UNAME), Linux)
TALKER_LIBS = -lcrypt
IDENTD_LIBS =
endif
#
# Build rules
#
all: build
.PHONY: all compile build install clean distclean
distclean: clean
@echo "Removing binary and backup files"
rm -f $(TALKER_SRC_DIR)/*.[ch]~ $(TALKER_SRC_DIR)/*.[ch].bak
rm -f $(IDENTD_SRC_DIR)/*.[ch]~ $(IDENTD_SRC_DIR)/*.[ch].bak
rm -f $(VENDOR_SDS_SRC_DIR)/*.[ch]~ $(VENDOR_SDS_SRC_DIR)/*.[ch].bak
rm -f $(VENDOR_LIBTELNET_SRC_DIR)/*.[ch]~ $(VENDOR_LIBTELNET_SRC_DIR)/*.[ch].bak
rm -f $(TALKER_BIN) $(BINDIR)/$(TALKER_BIN)
rm -f $(IDENTD_BIN) $(BINDIR)/$(IDENTD_BIN)
rm -f $(INCDIR)/*.[ch]~ $(INCDIR)/*.[ch].bak
clean:
@echo "Removing object and dependency files"
rm -f $(TALKER_OBJS) $(TALKER_OBJS:.o=.d)
rm -f $(IDENTD_OBJS) $(IDENTD_OBJS:.o=.d)
rm -f $(VENDOR_SDS_OBJS) $(VENDOR_SDS_OBJS:.o=.d)
rm -f $(VENDOR_LIBTELNET_OBJS) $(VENDOR_LIBTELNET_OBJS:.o=.d)
install: $(BINDIR)/$(TALKER_BIN) $(BINDIR)/$(IDENTD_BIN)
build: $(TALKER_BIN) $(IDENTD_BIN)
compile: $(TALKER_OBJS) $(IDENTD_OBJS) $(VENDOR_SDS_OBJS) $(VENDOR_LIBTELNET_OBJS)
print-%: ; @echo $* = $($*)
vpath %.c $(TALKER_SRC_DIR) $(TALKER_SRC_DIR)/commands $(IDENTD_SRC_DIR) $(VENDOR_SDS_SRC_DIR) $(VENDOR_LIBTELNET_SRC_DIR)
$(BINDIR)/$(TALKER_BIN) $(BINDIR)/$(IDENTD_BIN): $(BINDIR)/%: %
@echo "Installing $< ..."
chmod $(PERMS) $<
mv $< $(BINDIR)
$(TALKER_BIN): $(TALKER_OBJS) $(VENDOR_SDS_OBJS) $(VENDOR_LIBTELNET_OBJS)
@echo "Linking $@ ..."
$(CC) $(LD_FLAGS) $^ $(TALKER_LIBS) -o $@
$(IDENTD_BIN): $(IDENTD_OBJS) $(VENDOR_SDS_OBJS) $(VENDOR_LIBTELNET_OBJS)
@echo "Linking $@ ..."
$(CC) $(LD_FLAGS) $^ $(IDENTD_LIBS) -o $@
$(TALKER_OBJS): $(TALKER_OBJ_DIR)/%.o: %.c
@echo "Compiling talker $< ... ($@)"
@test -d $(TALKER_OBJ_DIR) || mkdir $(TALKER_OBJ_DIR)
$(CC) $(C_FLAGS) $(CC_FLAGS) $(TALKER_FLAGS) -c -o $@ $<
$(IDENTD_OBJS): $(IDENTD_OBJ_DIR)/%.o: %.c
@echo "Compiling identd $< ... ($@)"
@test -d $(IDENTD_OBJ_DIR) || mkdir $(IDENTD_OBJ_DIR)
$(CC) $(C_FLAGS) $(CC_FLAGS) $(TALKER_FLAGS) -c -o $@ $<
$(VENDOR_SDS_OBJS): $(VENDOR_SDS_OBJ_DIR)/%.o: %.c
@echo "Compiling SDS library $< ... ($@)"
@test -d $(VENDOR_SDS_OBJ_DIR) || mkdir $(VENDOR_SDS_OBJ_DIR)
$(CC) $(C_FLAGS) $(CC_FLAGS) $(TALKER_FLAGS) -c -o $@ $<
$(VENDOR_LIBTELNET_OBJS): $(VENDOR_LIBTELNET_OBJ_DIR)/%.o: %.c
@echo "Compiling libtelnet library $< ... ($@)"
@test -d $(VENDOR_LIBTELNET_OBJ_DIR) || mkdir $(VENDOR_LIBTELNET_OBJ_DIR)
$(CC) $(C_FLAGS) $(CC_FLAGS) $(TALKER_FLAGS) -c -o $@ $<
-include $(TALKER_OBJS:.o=.d) $(IDENTD_OBJS:.o=.d) $(VENDOR_SDS_OBJS:.o=.d) $(VENDOR_LIBTELNET_OBJS:.o=.d)