-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathMakefile
More file actions
73 lines (57 loc) · 2.17 KB
/
Makefile
File metadata and controls
73 lines (57 loc) · 2.17 KB
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
CC = gcc
CFLAGS = -c -g -O2 -Wall -Wno-pointer-sign $(RPM_OPT_FLAGS)
LDFLAGS = -rdynamic -lhd -lblkid -lcurl -lreadline -lmediacheck
ARCH = $(shell /usr/bin/uname -m)
ifeq ($(ARCH),s390x)
LDFLAGS += -lqc
endif
GIT2LOG := $(shell if [ -x ./git2log ] ; then echo ./git2log --update ; else echo true ; fi)
GITDEPS := $(shell [ -d .git ] && echo .git/HEAD .git/refs/heads .git/refs/tags)
VERSION := $(shell $(GIT2LOG) --version VERSION ; cat VERSION)
BRANCH := $(shell [ -d .git ] && git branch | perl -ne 'print $$_ if s/^\*\s*//')
PREFIX := linuxrc-$(VERSION)
SRC = $(filter-out inflate.c,$(sort $(wildcard *.c)))
INC = $(wildcard *.h)
OBJ = $(SRC:.c=.o)
SUBDIRS = mkpsfu edid-write
.EXPORT_ALL_VARIABLES:
.PHONY: all clean install libs archive
%.o: %.c
$(CC) $(CFLAGS) -o $@ $<
all: changelog libs linuxrc
changelog: $(GITDEPS)
$(GIT2LOG) --changelog changelog
version.h: VERSION
@echo "#define LXRC_VERSION \"`cut -d. -f1-2 VERSION`\"" >$@
@echo "#define LXRC_FULL_VERSION \"`cat VERSION`\"" >>$@
linuxrc: $(OBJ)
$(CC) $(OBJ) $(LDFLAGS) -o $@
@cp $@ $(@)-debug
@strip -R .note -R .comment $@
@ls -l linuxrc
@mv $(@)-debug $@
install: linuxrc
install -m 755 linuxrc $(DESTDIR)/usr/sbin
install -m 755 mkpsfu/mkpsfu $(DESTDIR)/usr/bin
install -m 755 edid-write/edid-write $(DESTDIR)/usr/bin
install -d -m 755 $(DESTDIR)/usr/share/linuxrc
gzip -c9 mkpsfu/linuxrc-16.psfu >$(DESTDIR)/usr/share/linuxrc/linuxrc-16.psfu.gz
gzip -c9 mkpsfu/linuxrc2-16.psfu >$(DESTDIR)/usr/share/linuxrc/linuxrc2-16.psfu.gz
libs:
@for d in $(SUBDIRS); do $(MAKE) -C $$d $(MAKECMDGOALS); done
archive: changelog
@if [ ! -d .git ] ; then echo no git repo ; false ; fi
mkdir -p package
git archive --prefix=$(PREFIX)/ $(BRANCH) > package/$(PREFIX).tar
tar -r -f package/$(PREFIX).tar --mode=0664 --owner=root --group=root --mtime="`git show -s --format=%ci`" --transform='s:^:$(PREFIX)/:' VERSION changelog
xz -f package/$(PREFIX).tar
clean: libs
rm -f $(OBJ) *~ linuxrc linuxrc.map linuxrc-debug .depend version.h
rm -rf package
TAGS: *.c *.h */*.c
etags $^
ifeq ($(filter clean changelog VERSION, $(MAKECMDGOALS)),)
.depend: version.h $(SRC) $(INC)
@$(CC) -MM $(CFLAGS) $(SRC) >$@
-include .depend
endif