bcastfwd/Makefile
2010-12-12 16:23:33 +01:00

46 lines
1.0 KiB
Makefile

DESTDIR =
BINARY_DIR = /usr/local/bin
CONFIG_DIR = /usr/local/etc
LOG_DIR = /var/log
PID_DIR = /var/run
# ############################
SRC := $(wildcard *.c)
TARGET := bcastfwd
CFLAGS := -O2 -Wall -Wno-unused-result -MMD -I.
LDFLAGS :=
# ############################
ifeq ($(strip $(wildcard $(DESTDIR)$(CONFIG_DIR)/$(TARGET).conf)),)
NEWCONF=$(TARGET).conf
else
NEWCONF=$(TARGET).conf.dist
endif
# ############################
all: $(TARGET)
$(TARGET): $(SRC:%.c=%.o)
@echo " Linking file: $@"
@$(CC) $(LDFLAGS) $^ -o $@
%.o: %.c
@echo " Building file: $<"
@$(CC) $(CFLAGS) -o $@ -c $<
install: all
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:
rm -rf *.d *.o $(TARGET)
include $(shell find . -name \*.d 2> /dev/null)