0001-friendly-makefile.patch 2.39 KB
Newer Older
Tomasz Buchert's avatar
Tomasz Buchert committed
1
From: Tomasz Buchert <tomasz@debian.org>
Tomasz Buchert's avatar
Tomasz Buchert committed
2 3
Date: Thu, 2 Aug 2018 11:43:04 +0800
Subject: friendly makefile
4 5

---
Tomasz Buchert's avatar
Tomasz Buchert committed
6 7 8 9 10
 .gitignore |  1 -
 Makefile   | 28 +++++++++-------------------
 VERSION    |  1 +
 3 files changed, 10 insertions(+), 20 deletions(-)
 create mode 100644 VERSION
11

Tomasz Buchert's avatar
Tomasz Buchert committed
12 13 14 15 16 17 18
diff --git a/.gitignore b/.gitignore
index 0b89911..6d10dce 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1 @@
 changelog
-VERSION
19
diff --git a/Makefile b/Makefile
Tomasz Buchert's avatar
Tomasz Buchert committed
20
index 6fa6fcc..b074253 100644
21 22
--- a/Makefile
+++ b/Makefile
Tomasz Buchert's avatar
Tomasz Buchert committed
23
@@ -3,20 +3,14 @@ ifneq ($(filter i386 i486 i586 i686, $(ARCH)),)
24 25 26 27 28
 ARCH	:= i386
 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)
Tomasz Buchert's avatar
Tomasz Buchert committed
29 30 31
-VERSION := $(shell $(GIT2LOG) --version VERSION ; cat VERSION)
-BRANCH  := $(shell [ -d .git ] && git branch | perl -ne 'print $$_ if s/^\*\s*//')
-PREFIX  := libx86emu-$(VERSION)
Tomasz Buchert's avatar
Tomasz Buchert committed
32 33
+CC	?= gcc
+CFLAGS	+= -g -O2 -fPIC -fvisibility=hidden -fomit-frame-pointer -Wall
34
 
Tomasz Buchert's avatar
Tomasz Buchert committed
35 36
-MAJOR_VERSION := $(shell $(GIT2LOG) --version VERSION ; cut -d . -f 1 VERSION)
-
37
-CC	= gcc
Tomasz Buchert's avatar
Tomasz Buchert committed
38 39 40 41 42
-CFLAGS	= -g -O2 -fPIC -fvisibility=hidden -fomit-frame-pointer -Wall
-
-LIBDIR = /usr/lib$(shell ldd /bin/sh | grep -q /lib64/ && echo 64)
 LIBX86	= libx86emu
 
43 44
+VERSION := $(shell cat VERSION)
+MAJOR_VERSION := $(shell cut -d . -f 1 VERSION)
Tomasz Buchert's avatar
Tomasz Buchert committed
45
+
46 47
 CFILES	= $(wildcard *.c)
 OBJS	= $(CFILES:.c=.o)
Tomasz Buchert's avatar
Tomasz Buchert committed
48 49
 
@@ -26,12 +20,9 @@ LIB_SONAME	= $(LIBX86).so.$(MAJOR_VERSION)
Tomasz Buchert's avatar
Tomasz Buchert committed
50
 .PHONY: all shared install test demo clean
51 52
 
 %.o: %.c
53
-	$(CC) -c $(CFLAGS) $<
Tomasz Buchert's avatar
Tomasz Buchert committed
54
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -c $<
55
 
Tomasz Buchert's avatar
Tomasz Buchert committed
56 57
-all: changelog shared
-
58 59 60 61 62 63
-changelog: $(GITDEPS)
-	$(GIT2LOG) --changelog changelog
+all: shared
 
 shared: $(LIB_NAME)
 
Tomasz Buchert's avatar
Tomasz Buchert committed
64
@@ -42,7 +33,7 @@ install: shared
65 66 67 68
 	install -m 644 -D include/x86emu.h $(DESTDIR)/usr/include/x86emu.h
 
 $(LIB_NAME): .depend $(OBJS)
-	$(CC) -shared -Wl,-soname,$(LIB_SONAME) $(OBJS) -o $(LIB_NAME)
Tomasz Buchert's avatar
Tomasz Buchert committed
69 70 71
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -shared -Wl,-soname,$(LIB_SONAME) $(OBJS) -o $(LIB_NAME)
 	@ln -snf $(LIB_NAME) $(LIB_SONAME)
 	@ln -snf $(LIB_SONAME) $(LIBX86).so
72
 
Tomasz Buchert's avatar
Tomasz Buchert committed
73
@@ -67,7 +58,6 @@ clean:
74 75 76
 
 ifneq "$(MAKECMDGOALS)" "clean"
 .depend: $(CFILES)
77
-	@$(CC) -MG -MM $(CFLAGS) $(CFILES) >$@
Tomasz Buchert's avatar
Tomasz Buchert committed
78
+	@$(CC) -MG -MM $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(CFILES) >$@
79 80
 -include .depend
 endif
Tomasz Buchert's avatar
Tomasz Buchert committed
81 82 83 84 85 86 87 88
-
diff --git a/VERSION b/VERSION
new file mode 100644
index 0000000..cd5ac03
--- /dev/null
+++ b/VERSION
@@ -0,0 +1 @@
+2.0