diff --git a/Makefile b/Makefile index 51b9a61e..89580472 100644 --- a/Makefile +++ b/Makefile @@ -1,41 +1,78 @@ -# INADYN Makefile +# Makefile for INADYN, a simple and small ddns client. -*-Makefile-*- + +#VERSION ?= $(shell git tag -l | tail -1) +VERSION ?= 1.96.2 +NAME = inadyn +EXEC = src/$(NAME) +PKG = $(EXEC)-$(VERSION) +ARCHIVE = $(PKG).tar.bz2 +MAN5 = inadyn.conf.5 +MAN8 = inadyn.8 + +ROOTDIR ?= $(dir $(shell pwd)) +RM ?= rm -f +CC ?= $(CROSS)gcc + +prefix ?= /usr/local +sysconfdir ?= /etc +datadir = $(prefix)/share/doc/inadyn +mandir = $(prefix)/share/man # This magic trick looks like a comment, but works on BSD PMake #include include config.mk -OUTFILE = $(OUTDIR)/$(TARGET_ARCH)/inadyn -BASE_OBJS = $(OUTDIR)/base64utils.o $(OUTDIR)/dyndns.o $(OUTDIR)/errorcode.o \ - $(OUTDIR)/get_cmd.o $(OUTDIR)/http_client.o $(OUTDIR)/ip.o $(OUTDIR)/main.o \ - $(OUTDIR)/os_unix.o $(OUTDIR)/os_windows.o $(OUTDIR)/os.o $(OUTDIR)/os_psos.o \ - $(OUTDIR)/tcp.o $(OUTDIR)/inadyn_cmd.o +BASE_OBJS = src/base64utils.o src/dyndns.o src/errorcode.o src/get_cmd.o \ + src/http_client.o src/ip.o src/main.o src/os_unix.o src/os_windows.o \ + src/os.o src/os_psos.o src/tcp.o src/inadyn_cmd.o OBJS = $(BASE_OBJS) $(CFG_OBJ) $(EXTRA_OBJS) -CFLAGS += $(CFG_INC) $(EXTRA_CFLAGS) +CFLAGS = -Iinclude $(CFG_INC) $(EXTRA_CFLAGS) +CFLAGS += -O2 -W -Wall LDLIBS += $(EXTRA_LIBS) +DISTFILES = README COPYING LICENSE # Pattern rules -$(OUTDIR)/%.o : $(SRCDIR)/%.c +.c.o: @printf " CC $@\n" @$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $< # Build rules -all: $(OUTFILE) +all: $(EXEC) -$(OUTFILE): $(OUTDIR)/$(TARGET_ARCH) $(OBJS) +$(EXEC): $(OBJS) @printf " LINK $@\n" @$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS) -$(OUTDIR)/$(TARGET_ARCH): - -@mkdir -p "$@" +install: $(EXEC) + @install -d $(DESTDIR)$(prefix)/sbin + @install -d $(DESTDIR)$(sysconfdir) + @install -d $(DESTDIR)$(datadir) + @install -d $(DESTDIR)$(mandir)/man8 + @install -d $(DESTDIR)$(mandir)/man5 + @install -m 0755 $(EXEC) $(DESTDIR)$(prefix)/sbin/ + @install -m 0644 man/MAN5 $(DESTDIR)$(mandir)/man5/MAN5 + @install -m 0644 man/MAN8 $(DESTDIR)$(mandir)/man8/MAN8 + @for file in $(DISTFILES); do \ + install -m 0644 $$file $(DESTDIR)$(datadir)/$$file; \ + done -# Rebuild this project -rebuild: cleanall all +uninstall: + -@$(RM) $(DESTDIR)$(prefix)/sbin/$(EXEC) + -@$(RM) -r $(DESTDIR)$(datadir) + -@$(RM) $(DESTDIR)$(mandir)/man5/MAN5 + -@$(RM) $(DESTDIR)$(mandir)/man8/MAN8 -# Clean this project clean: - -@rm -f $(OUTFILE) - -@rm -f $(OBJS) + -@$(RM) $(OBJS) $(EXECS) + +distclean: + -@$(RM) $(OBJS) core $(EXECS) *.o *.map .*.d *.out tags TAGS + +dist: + @echo "Building bzip2 tarball of $(PKG) in parent dir..." + git archive --format=tar --prefix=$(PKG)/ $(VERSION) | bzip2 >../$(ARCHIVE) + @(cd ..; md5sum $(ARCHIVE)) -# Clean this project and all dependencies -cleanall: clean +build-deb: + git-buildpackage --git-ignore-new --git-upstream-branch=master diff --git a/config.mk b/config.mk index 4db85e20..b4e18672 100644 --- a/config.mk +++ b/config.mk @@ -1,10 +1,3 @@ -# Make command to use for dependencies -MAKECMD = make - -INADYN_BASE = . -SRCDIR = $(INADYN_BASE)/src -OUTDIR = bin - # Oversimplified arch setup, no smart detection. # Possible values: linux, mac, solaris, yourown ifndef TARGET_ARCH diff --git a/src/base64.h b/include/base64.h similarity index 100% rename from src/base64.h rename to include/base64.h diff --git a/src/debug_if.h b/include/debug_if.h similarity index 100% rename from src/debug_if.h rename to include/debug_if.h diff --git a/src/dyndns.h b/include/dyndns.h similarity index 100% rename from src/dyndns.h rename to include/dyndns.h diff --git a/src/errorcode.h b/include/errorcode.h similarity index 100% rename from src/errorcode.h rename to include/errorcode.h diff --git a/src/get_cmd.h b/include/get_cmd.h similarity index 100% rename from src/get_cmd.h rename to include/get_cmd.h diff --git a/src/http_client.h b/include/http_client.h similarity index 100% rename from src/http_client.h rename to include/http_client.h diff --git a/src/ip.h b/include/ip.h similarity index 100% rename from src/ip.h rename to include/ip.h diff --git a/src/os.h b/include/os.h similarity index 100% rename from src/os.h rename to include/os.h diff --git a/src/psos_net.h b/include/psos_net.h similarity index 100% rename from src/psos_net.h rename to include/psos_net.h diff --git a/src/tcp.h b/include/tcp.h similarity index 100% rename from src/tcp.h rename to include/tcp.h