summaryrefslogtreecommitdiffstats
path: root/Makefile.in
blob: e374abe921825dd2d89c7b1e7be2ca0d4f2db256 (plain) (blame)
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
CC           = @CC@
CFLAGS      ?= @CFLAGS@
CFLAGS      += -I. @CPPFLAGS@
SHARED       = @SHARED@

PKG_CONFIG   = @PKG_CONFIG@
STRIP        = @STRIP@
INSTALL      = @INSTALL@
SED          = @SED@

headers      = @headers@
programs     = lem utils.so
scripts      = repl.lua lem-repl

objects      = @objects@

LIBS         = @LIBS@

prefix       = @prefix@
exec_prefix  = @exec_prefix@
bindir       = @bindir@
includedir   = @includedir@
libdir       = @libdir@
datarootdir  = @datarootdir@
pkgconfigdir = @pkgconfigdir@
lmoddir      = @lmoddir@
cmoddir      = @cmoddir@

installdirs  = $(bindir) $(includedir)/lem \
               $(lmoddir)/lem $(cmoddir)/lem $(pkgconfigdir)

ifdef V
E=@\#
Q=
else
E=@echo
Q=@
endif

.PHONY: all strip install clean $(installdirs)
.PRECIOUS: %.lo

all: $(programs) lem.pc

libev.o: CFLAGS += -w
lua.o: lua/luaconf.h

%.o: %.c
	$E '  CC    $@'
	$Q$(CC) $(CFLAGS) -c $< -o $@

lem: $(objects)
	$E '  LD    $@'
	$Q$(CC) $^ -o $@ -rdynamic $(LDFLAGS) $(LIBS)

%.so: %.c
	$E '  CCLD  $@'
	$Q$(CC) $(CFLAGS) -fPIC -nostartfiles $(SHARED) $^ -o $@ $(LDFLAGS)

lua/luaconf.h: lua/luaconf.h.in
	$E '  SED > $@'
	$Q$(SED) \
	  -e 's|@path@|$(lua_path)|' \
	  -e 's|@cpath@|$(lua_cpath)|' \
	  $< > $@

%.pc: %.pc.in
	$E '  SED > $@'
	$Q$(SED) \
	  -e 's|@lmoddir[@]|$(lmoddir)|' \
	  -e 's|@cmoddir[@]|$(cmoddir)|' \
	  -e 's|@includedir[@]|$(includedir)|' \
	  $< > $@

%-strip: %
	$E '  STRIP $<'
	$Q$(STRIP) $(STRIP_ARGS) $<

strip: $(programs:%=%-strip)

$(installdirs):
	$E '  INSTALL -d $@'
	$Q$(INSTALL) -dm755 $(DESTDIR)$@

lem-install: lem | $(bindir)
	$E '  INSTALL $<'
	$Q$(INSTALL) $< $(DESTDIR)$(bindir)/$<

lem-repl-install: lem-repl | $(bindir)
	$E '  INSTALL $<'
	$Q$(INSTALL) $< $(DESTDIR)$(bindir)/$<

%.h-install: %.h | $(includedir)/lem
	$E '  INSTALL $(notdir $<)'
	$Q$(INSTALL) -m644 $< $(DESTDIR)$(includedir)/lem/$(notdir $<)

%.lua-install: %.lua | $(lmoddir)/lem
	$E '  INSTALL $<'
	$Q$(INSTALL) -m644 $< $(DESTDIR)$(lmoddir)/lem/$<

%.so-install: %.so | $(cmoddir)/lem
	$E '  INSTALL $<'
	$Q$(INSTALL) $< $(DESTDIR)$(cmoddir)/lem/$<

%.pc-install: %.pc | $(pkgconfigdir)
	$E '  INSTALL $<'
	$Q$(INSTALL) -m644 $< $(DESTDIR)$(pkgconfigdir)

install: lem.pc-install $(headers:%=%-install) $(programs:%=%-install) $(scripts:%=%-install)

clean:
	rm -f lem lua/luaconf.h lem.pc *.o *.so