summaryrefslogtreecommitdiff
path: root/Makefile
blob: 0a9ca1a98f6b06acc148b2c1ebee8e557b902f54 (plain)
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
include config.mk

-include $(DEPS)

all: $(TARGET)
debug: $(DTARGET)

options:
	@echo "$(PROJECT) build options:"
	@echo "LIBS    = $(LIBS)"
	@echo "CFLAGS  = $(CFLAGS)"
	@echo "LDFLAGS = $(LDFLAGS)"
	@echo "CC      = $(CC)"

src/hints.o: src/hints.js.h
src/hints.do: src/hints.js.h

src/hints.js.h: src/hints.js
	@echo "minify $<"
	@cat $< | src/js2h.sh > $@

$(OBJ): src/config.h config.mk
$(DOBJ): src/config.h config.mk

$(TARGET): $(OBJ)
	@echo "$(CC) $@"
	@$(CC) $(OBJ) -o $(TARGET) $(LDFLAGS)

$(DTARGET): $(DOBJ)
	@echo "$(CC) $@"
	@$(CC) $(DFLAGS) $(DOBJ) -o $(DTARGET) $(DLDFLAGS)

src/config.h:
	@echo create $@ from src/config.def.h
	@cp src/config.def.h $@

%.o: %.c %.h
	@echo "${CC} $<"
	@$(CC) -c -o $@ $< $(CFLAGS)

%.do: %.c %.h
	@echo "${CC} $<"
	@$(CC) -c -o $@ $< $(DFLAGS)

install: $(TARGET) doc/$(MAN1)
	install -d $(DESTDIR)$(BINDIR)
	install -d $(DESTDIR)$(MANDIR1)
	install -m 755 $(TARGET) $(DESTDIR)$(BINDIR)/$(TARGET)
	@echo "install -m 644 src/$(MAN1) $(DESTDIR)$(MANDIR1)/$(MAN1)"
	@sed -e "s/VERSION/$(VERSION)/g" \
		-e "s/DATE/`date +'%m %Y'`/g" \
		-e "s/PROJECT/$(PROJECT)/g" < doc/$(MAN1) > $(DESTDIR)$(MANDIR1)/$(MAN1)
	@chmod 644 $(DESTDIR)$(MANDIR1)/$(MAN1)

uninstall:
	$(RM) $(DESTDIR)$(BINDIR)/$(TARGET)
	$(RM) $(DESTDIR)$(MANDIR1)/$(MAN1)

clean:
	$(RM) src/*.o src/*.do src/hints.js.h $(TARGET) $(DTARGET)

dist: distclean
	@echo "Creating tarball."
	@git archive --format tar -o $(DIST_FILE) HEAD

distclean:
	$(RM) $(DIST_FILE)

.PHONY: clean debug all install uninstall options dist