forked from synapticon/siitool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
91 lines (67 loc) · 1.97 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
83
84
85
86
87
88
89
90
91
# project file for siitool
CC = gcc
LD = gcc
INSTALL = install
WARNINGS = -Wall -Wextra
OPTIMIZATION = -O2
DEBUG = 0
CFLAGS = -g $(WARNINGS) $(OPTIMIZATION) -std=gnu99 -DDEBUG=$(DEBUG)
LDFLAGS = -g $(WARNINGS)
PLATTFORM = $(shell uname -s)
ifeq (Linux, $(PLATTFORM))
INSTFLAGS = -D -b
else
ifeq (Darwin, $(PLATTFORM))
INSTFLAGS = -b
else
INSTFLAGS =
endif
endif
# add libxml specific flags
CFLAGS += `xml2-config --cflags`
LDFLAGS += `xml2-config --libs`
H2MFLAGS = --help-option "-h" --version-option "-v" --no-discard-stderr --no-info
TARGET = siitool
OBJECTS = main.o sii.o esi.o esifile.o crc8.o
PREFIX = /usr/local/bin
ifeq (Darwin, $(PLATTFORM))
MANPATH = /usr/local/share/man/man1
else
MANPATH = $(PREFIX)/../man/man1
endif
SOURCEDIR = `pwd`
VERSION = `scripts/getversion`
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $^
all: $(TARGET) $(TARGET).1
$(TARGET): $(OBJECTS)
$(LD) -o $@ $^ $(LDFLAGS)
$(TARGET).1: $(TARGET)
help2man -o $<.1 $(H2MFLAGS) -i misc/mansections.txt ./$<
.PHONY: clean install install-man install-prg uninstall lint tarball help
help:
@echo "Available make targets:"
@echo " all builds binary and man page"
@echo " install installs this software at $(PREFIX)"
@echo " uninstall removes installed software from $(PREFIX)"
@echo " clean cleans all objects"
@echo " lint static code analyzing (works best with clang v3.4+)"
@echo " tarball packages a software release tar.gz file."
install: install-man install-prg
install-prg:
strip $(TARGET)
$(INSTALL) $(INSTFLAGS) $(TARGET) $(PREFIX)
install-man:
$(INSTALL) $(INSTFLAGS) $(TARGET).1 $(MANPATH)/$(TARGET).1
ifeq (Linux, $(PLATTFORM))
@mandb -f $(MANPATH)/$(TARGET).1
endif
uninstall:
rm -f $(PREFIX)/$(TARGET)
rm -f $(MANPATH)/$(TARGET).1
clean:
rm -f $(TARGET) $(TARGET).1 $(OBJECTS)
lint:
clang --analyze `xml2-config --cflags` main.c sii.c esi.c esifile.c
tarball:
git archive --format=tar --prefix="$(TARGET)-$(VERSION)/" HEAD | gzip > $(TARGET)-$(VERSION).tar.gz