uhub/GNUmakefile

250 lines
5.7 KiB
Makefile
Raw Normal View History

2009-02-19 16:14:09 +00:00
##
## Makefile for uhub (Use GNU make)
## Copyright (C) 2007-2009, Jan Vidar Krey <janvidar@extatic.org>
2009-02-19 16:14:09 +00:00
#
CC = gcc
LD := $(CC)
MV := mv
RANLIB := ranlib
CFLAGS += -pipe -Wall
2009-08-03 21:59:19 +00:00
USE_SSL ?= NO
USE_LIBEVENT ?= NO
2009-02-19 16:14:09 +00:00
USE_BIGENDIAN ?= AUTO
BITS ?= AUTO
SILENT ?= YES
TERSE ?= NO
2009-03-16 21:49:55 +00:00
STACK_PROTECT ?= NO
2009-02-19 16:14:09 +00:00
ifeq ($(OS), Windows_NT)
WINDOWS ?= YES
endif
2009-08-06 21:15:55 +00:00
ifeq (SOLARIS,YES)
LDLIBS += -lsocket -lnsl
endif
2009-07-25 18:05:27 +00:00
CFLAGS += -I./src/
2009-02-19 16:14:09 +00:00
ifeq ($(WINDOWS),YES)
USE_BIGENDIAN := NO
LDLIBS += -lws2_32
UHUB_CONF_DIR ?= c:/uhub/
UHUB_PREFIX ?= c:/uhub/
CFLAGS += -mno-cygwin
LDFLAGS += -mno-cygwin
BIN_EXT ?= .exe
2009-06-25 15:29:50 +00:00
GIT_REVISION ?= NO
2009-02-19 16:14:09 +00:00
else
DESTDIR ?= /
UHUB_CONF_DIR ?= $(DESTDIR)/etc/uhub
UHUB_PREFIX ?= $(DESTDIR)/usr/local
2009-02-19 16:14:09 +00:00
CFLAGS += -I/usr/local/include
LDFLAGS += -L/usr/local/lib
BIN_EXT ?=
endif
ifeq ($(SILENT),YES)
MSG_CC=@echo " CC:" $(notdir $^) &&
MSG_LD=@echo " LD:" $(notdir $@) &&
MSG_AR=@echo " AR:" $(notdir $@) &&
else
MSG_CC=
MSG_LD=
MSG_AR=
endif
ifeq ($(TERSE), YES)
MSG_CC=@
MSG_LD=@
MSG_AR=@
MSG_CLEAN=-n ""
else
MSG_CLEAN="Clean as a whistle"
endif
2009-08-28 14:04:45 +00:00
# CFLAGS += -I/source/libevent
# LDFLAGS += -L/source/libevent
2009-02-19 16:14:09 +00:00
ifeq ($(RELEASE),YES)
CFLAGS += -O3 -DNDEBUG
GIT_REVISION ?= NO
2009-02-19 16:14:09 +00:00
else
CFLAGS += -ggdb -DDEBUG
GIT_REVISION ?= YES
2009-03-16 21:49:55 +00:00
endif
ifeq ($(STACK_PROTECT),YES)
CFLAGS += -fstack-protector-all
2009-02-19 16:14:09 +00:00
endif
2009-03-16 21:49:55 +00:00
2009-02-19 16:14:09 +00:00
ifeq ($(PROFILING),YES)
CFLAGS += -pg
LDFLAGS += -pg
endif
ifeq ($(FUNCTRACE),YES)
CFLAGS += -finstrument-functions
CFLAGS += -DDEBUG_FUNCTION_TRACE
endif
ifneq ($(BITS), AUTO)
ifeq ($(BITS), 64)
CFLAGS += -m64
LDFLAGS += -m64
else
ifeq ($(BITS), 32)
CFLAGS += -m32
LDFLAGS += -m32
endif
endif
endif
ifeq ($(USE_BIGENDIAN),AUTO)
ifeq ($(shell perl -e 'print pack("L", 0x554E4958)'),UNIX)
CFLAGS += -DARCH_BIGENDIAN
endif
else
ifeq ($(USE_BIGENDIAN),YES)
CFLAGS += -DARCH_BIGENDIAN
endif
endif
ifeq ($(USE_SSL),YES)
CFLAGS += -DSSL_SUPPORT
LDLIBS += -lssl
endif
ifeq ($(USE_LIBEVENT),YES)
CFLAGS += -DUSE_LIBEVENT
LDLIBS += -levent
2009-02-19 16:14:09 +00:00
ifneq ($(LIBEVENT_PATH),)
CFLAGS += -I$(LIBEVENT_PATH)
LDFLAGS += -L$(LIBEVENT_PATH)
endif
endif
2009-02-19 16:14:09 +00:00
ifeq ($(GIT_REVISION),YES)
CFLAGS += -DGIT_REVISION=\"$(shell git show --abbrev-commit | head -n 1 | cut -f 2 -d " ")\"
endif
2009-02-19 16:14:09 +00:00
# Sources
libuhub_SOURCES := \
2009-07-25 18:05:27 +00:00
src/core/auth.c \
src/core/commands.c \
src/core/config.c \
src/core/eventqueue.c \
src/core/hub.c \
src/core/hubevent.c \
src/core/hubio.c \
src/core/inf.c \
2010-01-18 14:55:40 +00:00
src/core/netevent.c \
src/core/probe.c \
2010-01-18 14:55:40 +00:00
src/core/route.c \
src/core/user.c \
src/core/usermanager.c \
2009-07-25 18:05:27 +00:00
src/util/ipcalc.c \
2010-01-18 14:55:40 +00:00
src/network/epoll.c \
src/network/libevent.c \
src/network/network.c \
2009-07-25 18:05:27 +00:00
src/util/list.c \
src/util/log.c \
src/util/memory.c \
src/util/misc.c \
src/util/rbtree.c \
2010-01-18 14:55:40 +00:00
src/util/timeout.c \
src/util/tiger.c
2009-07-25 18:05:27 +00:00
2009-08-28 14:18:18 +00:00
libadc_common_SOURCES := \
src/adc/message.c \
src/adc/sid.c
2009-02-19 16:14:09 +00:00
2009-08-28 14:18:18 +00:00
libadc_client_SOURCES := \
src/tools/adcclient.c
uhub_SOURCES := src/core/main.c
2009-08-02 19:07:16 +00:00
adcrush_SOURCES := src/tools/adcrush.c
2009-02-19 16:14:09 +00:00
admin_SOURCES := src/tools/admin.c
2009-02-19 16:14:09 +00:00
autotest_SOURCES := \
autotest/test_message.tcc \
autotest/test_list.tcc \
autotest/test_memory.tcc \
autotest/test_ipfilter.tcc \
autotest/test_inf.tcc \
autotest/test_hub.tcc \
autotest/test_misc.tcc \
autotest/test_tiger.tcc \
autotest/test_usermanager.tcc \
2009-02-19 16:14:09 +00:00
autotest/test_eventqueue.tcc
autotest_OBJECTS = autotest.o
# Source to objects
2009-08-28 14:18:18 +00:00
libuhub_OBJECTS := $(libuhub_SOURCES:.c=.o)
libadc_client_OBJECTS := $(libadc_client_SOURCES:.c=.o)
libadc_common_OBJECTS := $(libadc_common_SOURCES:.c=.o)
uhub_OBJECTS := $(uhub_SOURCES:.c=.o)
adcrush_OBJECTS := $(adcrush_SOURCES:.c=.o)
admin_OBJECTS := $(admin_SOURCES:.c=.o)
2009-02-19 16:14:09 +00:00
2009-08-28 14:18:18 +00:00
all_OBJECTS := $(libuhub_OBJECTS) $(uhub_OBJECTS) $(adcrush_OBJECTS) $(autotest_OBJECTS) $(admin_OBJECTS) $(libadc_common_OBJECTS) $(libadc_client_OBJECTS)
2009-02-19 16:14:09 +00:00
uhub_BINARY=uhub$(BIN_EXT)
adcrush_BINARY=adcrush$(BIN_EXT)
admin_BINARY=uhub-admin$(BIN_EXT)
2009-02-19 16:14:09 +00:00
autotest_BINARY=autotest/test$(BIN_EXT)
%.o: %.c
2009-06-25 15:35:59 +00:00
$(MSG_CC) $(CC) -c $(CFLAGS) -o $@ $^
2009-02-19 16:14:09 +00:00
2009-08-28 14:04:45 +00:00
all: $(uhub_BINARY)
2009-08-28 14:18:18 +00:00
$(adcrush_BINARY): $(adcrush_OBJECTS) $(libuhub_OBJECTS) $(libadc_common_OBJECTS) $(libadc_client_OBJECTS)
2009-08-28 14:04:45 +00:00
$(MSG_LD) $(CC) -o $@ $^ $(LDFLAGS) $(LDLIBS)
2009-02-19 16:14:09 +00:00
2009-08-28 14:18:18 +00:00
$(admin_BINARY): $(admin_OBJECTS) $(libuhub_OBJECTS) $(libadc_common_OBJECTS) $(libadc_client_OBJECTS)
2009-08-28 14:04:45 +00:00
$(MSG_LD) $(CC) -o $@ $^ $(LDFLAGS) $(LDLIBS)
2009-08-28 14:18:18 +00:00
$(uhub_BINARY): $(uhub_OBJECTS) $(libuhub_OBJECTS) $(libadc_common_OBJECTS)
2009-08-28 14:04:45 +00:00
$(MSG_LD) $(CC) -o $@ $^ $(LDFLAGS) $(LDLIBS)
2009-02-19 16:14:09 +00:00
autotest.c: $(autotest_SOURCES)
$(shell exotic --standalone $(autotest_SOURCES) > $@)
2009-02-19 16:14:09 +00:00
$(autotest_OBJECTS): autotest.c
2009-06-25 15:35:59 +00:00
$(MSG_CC) $(CC) -c $(CFLAGS) -Isrc -o $@ $<
2009-02-19 16:14:09 +00:00
2009-08-28 14:18:18 +00:00
$(autotest_BINARY): $(autotest_OBJECTS) $(libuhub_OBJECTS) $(libadc_common_OBJECTS) $(libadc_client_OBJECTS)
2009-06-25 15:35:59 +00:00
$(MSG_LD) $(CC) -o $@ $^ $(LDFLAGS) $(LDLIBS)
2009-02-19 16:14:09 +00:00
autotest: $(autotest_BINARY)
@./$(autotest_BINARY) -s -f
ifeq ($(WINDOWS),YES)
install:
@echo "Cannot install automatically on windows."
else
install: $(uhub_BINARY)
@echo Copying $(uhub_BINARY) to $(UHUB_PREFIX)/bin/
@cp $(uhub_BINARY) $(UHUB_PREFIX)/bin/
@if [ ! -d $(UHUB_CONF_DIR) ]; then echo Creating $(UHUB_CONF_DIR); mkdir -p $(UHUB_CONF_DIR); fi
@if [ ! -f $(UHUB_CONF_DIR)/uhub.conf ]; then cp doc/uhub.conf $(UHUB_CONF_DIR); fi
@if [ ! -f $(UHUB_CONF_DIR)/users.conf ]; then cp doc/users.conf $(UHUB_CONF_DIR); fi
@touch $(UHUB_CONF_DIR)/motd.txt
2009-02-19 16:14:09 +00:00
@echo done.
endif
dist-clean:
2009-08-28 14:04:45 +00:00
@rm -rf $(all_OBJECTS) *~ core
2009-02-19 16:14:09 +00:00
clean:
@rm -rf $(libuhub_OBJECTS) *~ core $(uhub_BINARY) $(admin_BINARY) $(autotest_BINARY) $(adcrush_BINARY) $(all_OBJECTS) autotest.c && \
echo $(MSG_CLEAN)
2009-02-19 16:14:09 +00:00