-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
66 lines (51 loc) · 1.41 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
PREFIX ?= /usr/local
PRG := gwfmt
CFLAGS += -O3
# Warnings
CFLAGS += -Wall -Wextra
# Includes
CFLAGS += -I../util/include
CFLAGS += -I../ast/include
CFLAGS += -I../include
CFLAGS += -Iinclude
# Libraries
LDFLAGS += -L../util
LDFLAGS += -L../ast
LDFLAGS += -L../
ifeq ($(shell uname), Darwin)
AR = /usr/bin/libtool
AR_OPT = -static $^ -o $@
LDFLAGS += -undefined dynamic_lookup
else
AR = ar
AR_OPT = rcs $@ $^
endif
ifeq (${BUILD_ON_WINDOWS}, 1)
CFLAGS += -DBUILD_ON_WINDOWS=1 -D_XOPEN_SOURCE=700
LDFLAGS += -Wl,--enable-auto-import
endif
all: ${PRG}
${PRG}: src/${PRG}.o src/unpy.o src/gwion_config.o libgwion_fmt.a
${CC} ${DEPFLAGS} ${CFLAGS} $^ -Iinclude -lgwion -lgwion_ast -lgwion_util ${LDFLAGS} -ldl -lpthread -lm -o $@
libgwion_fmt.a: src/lint.o src/casing.o
${AR} ${AR_OPT}
src/unpy.c: src/unpy.l
${LEX} src/unpy.l
clean:
rm -rf src/*.o ${PRG} libgwion_fmt.a
install: all
install ${PRG} ${PREFIX}/bin
install lib${PRG}.a ${PREFIX}/lib
install include/${PRG}.h ${PREFIX}/include/${PRG}.h
uninstall:
rm ${PREFIX}/bin/${PRG}
rm ${PREFIX}/lib/lib${PRG}.a
rm ${PREFIX}/include/${PRG}.h
.c.o:
$(info compile $(<:.c=))
@${CC} $(DEPFLAGS) ${CFLAGS} ${PACKAGE_INFO} ${INSTALL_PREFIX} -c $< -o $(<:.c=.o)
@mv -f $(DEPDIR)/$(@F:.o=.Td) $(DEPDIR)/$(@F:.o=.d) && touch $@
@echo $@: config.mk >> $(DEPDIR)/$(@F:.o=.d)
DEPDIR := .d
$(shell mkdir -p $(DEPDIR) >/dev/null)
DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$(@F:.o=.Td)