2010-12-12 16:23:33 +01:00
|
|
|
DESTDIR =
|
|
|
|
BINARY_DIR = /usr/local/bin
|
|
|
|
CONFIG_DIR = /usr/local/etc
|
|
|
|
LOG_DIR = /var/log
|
|
|
|
PID_DIR = /var/run
|
|
|
|
|
|
|
|
# ############################
|
|
|
|
|
2011-04-17 12:37:20 +02:00
|
|
|
SRC = $(wildcard *.c)
|
|
|
|
TARGET = bcastfwd
|
|
|
|
BUILD_DIR = build
|
|
|
|
CFLAGS = -O2 -g -pipe -Wall -Wno-unused-result
|
|
|
|
CFLAGS += -MMD -MF $(BUILD_DIR)/$(*D)/$(*F).d
|
|
|
|
LDFLAGS =
|
2010-12-12 16:23:33 +01:00
|
|
|
|
|
|
|
# ############################
|
|
|
|
|
|
|
|
ifeq ($(strip $(wildcard $(DESTDIR)$(CONFIG_DIR)/$(TARGET).conf)),)
|
|
|
|
NEWCONF=$(TARGET).conf
|
|
|
|
else
|
|
|
|
NEWCONF=$(TARGET).conf.dist
|
|
|
|
endif
|
|
|
|
|
|
|
|
# ############################
|
|
|
|
|
|
|
|
all: $(TARGET)
|
|
|
|
|
2011-04-17 12:37:20 +02:00
|
|
|
$(TARGET): $(patsubst %,$(BUILD_DIR)/%, $(SRC:.c=.o))
|
2010-12-12 16:23:33 +01:00
|
|
|
@echo " Linking file: $@"
|
|
|
|
@$(CC) $(LDFLAGS) $^ -o $@
|
|
|
|
|
2011-04-17 12:37:20 +02:00
|
|
|
$(BUILD_DIR)/%.o: %.c $(MAKEFILE_LIST)
|
2010-12-12 16:23:33 +01:00
|
|
|
@echo " Building file: $<"
|
2011-04-17 12:37:20 +02:00
|
|
|
@$(shell test -d $(BUILD_DIR)/$(*D) || mkdir -p $(BUILD_DIR)/$(*D))
|
2010-12-12 16:23:33 +01:00
|
|
|
@$(CC) $(CFLAGS) -o $@ -c $<
|
|
|
|
|
2011-04-17 12:37:20 +02:00
|
|
|
install: $(TARGET)
|
2010-12-12 16:23:33 +01:00
|
|
|
install -D -m 755 -s $(TARGET) $(DESTDIR)$(BINARY_DIR)/$(TARGET)
|
|
|
|
install -D -m 644 $(TARGET).conf $(DESTDIR)$(CONFIG_DIR)/$(NEWCONF)
|
|
|
|
sed -i -e "s:^logfile .*$$:logfile $(LOG_DIR)/$(TARGET).log:" \
|
|
|
|
-e "s:^pidfile .*$$:pidfile $(PID_DIR)/$(TARGET).pid:" \
|
|
|
|
$(DESTDIR)$(CONFIG_DIR)/$(NEWCONF)
|
|
|
|
install -d -m 755 $(DESTDIR)$(LOG_DIR)
|
|
|
|
|
|
|
|
clean:
|
2011-04-17 12:37:20 +02:00
|
|
|
rm -rf $(BUILD_DIR) $(TARGET)
|
2010-12-12 16:23:33 +01:00
|
|
|
|
2011-04-17 12:37:20 +02:00
|
|
|
include $(shell find $(BUILD_DIR) -name \*.d 2> /dev/null)
|