free bugs [fixed]
[coupserv.git] / Makefile
blob5ff90c8c82c4d618d9fb794d931f1c077e264e8d
1 # Makefile for HaxServ
3 # Written by: Test_User <hax@andrewyu.org>
5 # This is free and unencumbered software released into the public
6 # domain.
8 # Anyone is free to copy, modify, publish, use, compile, sell, or
9 # distribute this software, either in source code form or as a compiled
10 # binary, for any purpose, commercial or non-commercial, and by any
11 # means.
13 # In jurisdictions that recognize copyright laws, the author or authors
14 # of this software dedicate any and all copyright interest in the
15 # software to the public domain. We make this dedication for the benefit
16 # of the public at large and to the detriment of our heirs and
17 # successors. We intend this dedication to be an overt act of
18 # relinquishment in perpetuity of all present and future rights to this
19 # software under copyright law.
21 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 # IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25 # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 # OTHER DEALINGS IN THE SOFTWARE.
29 #INCLUDEFLAGS =
31 CFLAGS += $(INCLUDEFLAGS) -D_REENTRANT -ggdb3 -Wall -Wextra -Wsign-conversion -Wno-unused-parameter $(shell pkg-config gnutls --cflags) -std=gnu99
33 LDFLAGS = -lpthread $(shell pkg-config gnutls --libs)
35 .makeopts:
36 @printf '%s\n' 'LAST_VERBOSE = 1' > .makeopts
37 @printf '%s\n' 'LAST_COLORIZE = 1' >> .makeopts
38 @printf '%s\n' 'LAST_SAFE_STACK = 0' >> .makeopts
40 include .makeopts
42 rebuild = 0
44 #tabs not allowed :(
45 ifneq ($(VERBOSE),)
46 ifneq ($(VERBOSE),$(LAST_VERBOSE))
47 rebuild = 1
48 endif
49 else
50 VERBOSE = $(LAST_VERBOSE)
51 endif
53 ifneq ($(COLORIZE),)
54 ifneq ($(COLORIZE),$(LAST_COLORIZE))
55 rebuild = 1
56 endif
57 else
58 COLORIZE = $(LAST_COLORIZE)
59 endif
61 ifneq ($(SAFE_STACK),)
62 ifneq ($(SAFE_STACK),$(LAST_SAFE_STACK))
63 rebuild = 1
64 endif
65 else
66 SAFE_STACK = $(LAST_SAFE_STACK)
67 endif
69 ifeq ($(rebuild),1)
70 $(shell printf '%s%s\n' 'LAST_VERBOSE = ' $(VERBOSE) > .makeopts)
71 $(shell printf '%s%s\n' 'LAST_COLORIZE = ' $(COLORIZE) >> .makeopts)
72 $(shell printf '%s%s\n' 'LAST_SAFE_STACK = ' $(SAFE_STACK) >> .makeopts)
74 $(shell $(RM) haxserv *.o)
75 endif
77 DEPS = $(shell $(CC) $(INCLUDEFLAGS) -MM -MT $(1).o $(1).c | sed 's_\\$$__g')
79 ifeq ($(VERBOSE), 1)
80 CFLAGS += -DLOGALL=1
81 endif
83 ifeq ($(COLORIZE), 1)
84 CFLAGS += -DCOLORIZE=1
85 endif
87 ifeq ($(SAFE_STACK), 1)
88 CFLAGS += -fstack-check
89 endif
91 .PHONY: all clean
92 all: haxserv
94 haxserv: main.o server_network.o client_network.o general_network.o commands.o table.o config.o tls.o utils.o
95 $(CC) $^ -o $@ $(LDFLAGS)
97 %.o: %.c
98 $(CC) $(CFLAGS) -c $< -o $@
100 $(call DEPS,main)
102 $(call DEPS,server_network)
104 $(call DEPS,client_network)
106 $(call DEPS,general_network)
108 $(call DEPS,commands)
110 $(call DEPS,table)
112 $(call DEPS,config)
114 $(call DEPS,tls)
116 $(call DEPS,utils)
118 clean:
119 $(RM) haxserv *.o