-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmakefile
82 lines (63 loc) · 2.85 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Single-source file programs to build
progs = cable/daemon cable/mhdrop cable/hex2base32 \
$(if $(NOI2P),,cable/eeppriv.jar)
objextra_daemon = obj/server.o obj/service.o obj/process.o obj/util.o
ldextra_daemon = -lrt -lmicrohttpd
cpextra_EepPriv = /opt/i2p/lib/i2p.jar
title := $(shell grep -o 'LIBERTE CABLE [[:alnum:]._-]\+' src/daemon.h)
# Installation directories (override DESTDIR and/or PREFIX)
# (DESTDIR is temporary, (ETC)PREFIX is hard-coded into scripts)
DESTDIR=
PREFIX=/usr
ETCPREFIX=$(patsubst %/usr/etc,%/etc,$(PREFIX)/etc)
instdir=$(DESTDIR)$(PREFIX)
etcdir=$(DESTDIR)$(ETCPREFIX)
# Default compilers
CC = gcc
JAVAC = javac
# Disable I2P eepSite keypair generation functionality? (non-empty to disable)
NOI2P =
# Modifications to compiler flags
CFLAGS := -std=c99 -Wall -pedantic -MMD -D_FILE_OFFSET_BITS=64 -D_POSIX_C_SOURCE=200809L -D_BSD_SOURCE -DNDEBUG $(CFLAGS)
JFLAGS := -target 1.5 -deprecation -Werror -g:none $(JFLAGS)
JLIBS = $(subst : ,:,$(addsuffix :,$(wildcard lib/*.jar)))
# Build rules
.PHONY: all clean install
.SUFFIXES: .o
.SECONDARY:
all: $(progs)
clean:
$(RM) -r $(progs) obj/*
cable/%: obj/%.o
$(CC) -o $@ $(CFLAGS) $< $(objextra_$*) $(LDFLAGS) $(ldextra_$*)
obj/%.o: src/%.c
$(CC) -c -o $@ $(CFLAGS) $<
cable/eeppriv.jar: obj/su/dee/i2p/EepPriv.class
echo "Manifest-Version: 1.0" > $(<D)/manifest.mf
echo "Created-By: $(title)" >> $(<D)/manifest.mf
echo "Main-Class: $(subst /,.,$(subst obj/,,$(basename $<)))" >> $(<D)/manifest.mf
echo "Class-Path: $(cpextra_$(basename $(<F)))" >> $(<D)/manifest.mf
jar c0mf $(<D)/manifest.mf $@ -C obj $(patsubst obj/%,%,$^)
obj/%.class: src/%.java
$(JAVAC) -d obj $(JFLAGS) $< -classpath obj:$(JLIBS)$(cpextra_$(basename $(*F)))
install: all
install -d $(etcdir)/cable $(instdir)/bin $(instdir)/libexec/cable $(instdir)/share/applications
install -m 644 -t $(etcdir)/cable $(wildcard conf/*)
install -t $(instdir)/bin bin/*
install -t $(instdir)/libexec/cable cable/*
install -m 644 -t $(instdir)/share/applications $(wildcard share/*.desktop)
sed -i 's&/usr/libexec/cable\>&$(PREFIX)/libexec/cable&g' \
$(addprefix $(etcdir)/cable/,profile cabled) \
$(instdir)/bin/cable-send
sed -i 's&/etc/cable\>&$(ETCPREFIX)/cable&g' \
$(etcdir)/cable/profile \
$(addprefix $(instdir)/libexec/cable/,cabled send) \
$(addprefix $(instdir)/bin/,cable-id cable-ping cable-send gen-cable-username gen-tor-hostname gen-i2p-hostname)
ifeq ($(strip $(NOI2P)),)
chmod a-x $(instdir)/libexec/cable/eeppriv.jar
else
rm $(instdir)/bin/gen-i2p-hostname
endif
# File-specific dependencies
cable/daemon: $(objextra_daemon)
-include $(wildcard obj/*.d)