-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.template
62 lines (45 loc) · 1.42 KB
/
Makefile.template
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
# -*- mode: makefile -*-
# ^^^ because .template extension won't set makefile mode
# Change the target according to your project;
# everything else is generated from this value.
TARGET = ate.so
# Used to generate and install the enable_*cmd* script:
BUILTIN = $(basename $(TARGET))
ENABLER = $(addprefix enable_,$(BUILTIN))
PREFIX ?= /usr/local
# Change if source files not in base directory:
SRC = .
CFLAGS = -Wall -Werror -std=c99 -pedantic -ggdb
LFLAGS =
LDFLAGS =
# Uncomment the following if target is a Shared library
CFLAGS += -fPIC
LFLAGS += --shared
CFLAGS += -I/usr/include/bash -I/usr/include/bash/include
MODULES = $(addsuffix .o,$(basename $(wildcard $(SRC)/*.c)))
.PHONY: all install uninstall clean help
all: $(TARGET)
$(TARGET) : $(MODULES)
$(CC) $(LFLAGS) -o $@ $(MODULES) $(LDFLAGS)
$(ENABLER):
@echo "#!/usr/bin/env bash" > $(ENABLER)
@echo "echo -f $(PREFIX)/lib/$(TARGET) $(BUILTIN)" >> $(ENABLER)
%o : %c
$(CC) $(CFLAGS) -c -o $@ $<
install: $(ENABLER)
install -D --mode=775 $(ENABLER) $(PREFIX)/bin
install -D --mode=775 $(TARGET) $(PREFIX)/lib
uninstall:
rm -f $(PREFIX)/bin/$(ENABLER)
rm -f $(PREFIX)/lib/$(TARGET)
clean:
rm -f $(TARGET)
rm -f $(ENABLER)
rm -f $(MODULES)
help:
@echo "Makefile options:"
@echo
@echo " install to install project"
@echo " uninstall to uninstall project"
@echo " clean to remove generated files"
@echo " help this display"