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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
From af97e2ad643334b4c7c3d66f971ce9ebb2b596af Mon Sep 17 00:00:00 2001
From: Mingli Yu <mingli.yu@windriver.com>
Date: Thu, 21 Jul 2016 18:06:21 +0800
Subject: [PATCH] makedumpfile: replace hardcode CFLAGS
* Create alias for target such as powerpc as powerpc32
* Remove hardcode CFLAGS
* Add CFLAGS_COMMON to instead of CFLAGS so can flexibly
customize CFLAGS and not hardcode the CFLAGS as previously
* Forcibly to link dynamic library as the poky build
system doesn't build static library by default
Upstream-Status: Inappropriate[oe specific]
Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
---
Makefile | 45 +++++++++++++++++++++++----------------------
1 file changed, 23 insertions(+), 22 deletions(-)
Index: git/Makefile
===================================================================
--- git.orig/Makefile
+++ git/Makefile
@@ -8,12 +8,6 @@ ifeq ($(strip $CC),)
CC = gcc
endif
-CFLAGS_BASE := $(CFLAGS) -g -O2 -Wall -D_FILE_OFFSET_BITS=64 \
- -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
-CFLAGS := $(CFLAGS_BASE) -DVERSION='"$(VERSION)"' -DRELEASE_DATE='"$(DATE)"'
-CFLAGS_ARCH := $(CFLAGS_BASE)
-# LDFLAGS = -L/usr/local/lib -I/usr/local/include
-
HOST_ARCH := $(shell uname -m)
# Use TARGET as the target architecture if specified.
# Defaults to uname -m
@@ -21,29 +15,36 @@ ifeq ($(strip($TARGET)),)
TARGET := $(HOST_ARCH)
endif
-ARCH := $(shell echo ${TARGET} | sed -e s/i.86/x86/ -e s/sun4u/sparc64/ \
- -e s/arm.*/arm/ -e s/sa110/arm/ \
- -e s/s390x/s390/ -e s/parisc64/parisc/ \
- -e s/ppc64/powerpc64/ -e s/ppc/powerpc32/)
+ARCH := $(shell echo __${TARGET}__ | sed -e s/i.86/x86/ -e s/sun4u/sparc64/ \
+ -e s/arm.*/arm/ -e s/sa110/arm/ \
+ -e s/s390x/s390/ -e s/parisc64/parisc/ \
+ -e s/ppc64/powerpc64/ -e s/ppc/powerpc32/ \
+ -e s/_powerpc_/_powerpc32_/)
CROSS :=
ifneq ($(TARGET), $(HOST_ARCH))
CROSS := -U__$(HOST_ARCH)__
endif
-CFLAGS += -D__$(ARCH)__ $(CROSS)
-CFLAGS_ARCH += -D__$(ARCH)__ $(CROSS)
+CFLAGS_ARCH += -D$(ARCH) $(CROSS)
-ifeq ($(ARCH), powerpc64)
-CFLAGS += -m64
+ifeq ($(ARCH), __powerpc64__)
CFLAGS_ARCH += -m64
endif
-ifeq ($(ARCH), powerpc32)
-CFLAGS += -m32
+ifeq ($(ARCH), __powerpc32__)
CFLAGS_ARCH += -m32
endif
+CFLAGS_ARCH += $(CFLAGS) \
+ -D_FILE_OFFSET_BITS=64 \
+ -D_LARGEFILE_SOURCE \
+ -D_LARGEFILE64_SOURCE
+
+CFLAGS_COMMON = $(CFLAGS_ARCH) \
+ -DVERSION='"$(VERSION)"' \
+ -DRELEASE_DATE='"$(DATE)"'
+
SRC_BASE = makedumpfile.c makedumpfile.h diskdump_mod.h sadump_mod.h sadump_info.h
SRC_PART = print_info.c dwarf_info.c elf_info.c erase_info.c sadump_info.c cache.c tools.c
OBJ_PART=$(patsubst %.c,%.o,$(SRC_PART))
@@ -52,12 +53,12 @@ OBJ_ARCH=$(patsubst %.c,%.o,$(SRC_ARCH))
LIBS = -ldw -lbz2 -ldl -lelf -lz
ifneq ($(LINKTYPE), dynamic)
-LIBS := -static $(LIBS) -llzma
+LIBS := $(LIBS) -llzma
endif
ifeq ($(USELZO), on)
LIBS := -llzo2 $(LIBS)
-CFLAGS += -DUSELZO
+CFLAGS_COMMON += -DUSELZO
endif
ifeq ($(USESNAPPY), on)
@@ -65,7 +66,7 @@ LIBS := -lsnappy $(LIBS)
ifneq ($(LINKTYPE), dynamic)
LIBS := $(LIBS) -lstdc++
endif
-CFLAGS += -DUSESNAPPY
+CFLAGS_COMMON += -DUSESNAPPY
endif
LIBS := -lpthread $(LIBS)
@@ -90,14 +91,14 @@ LIBS := $(LIBS) $(call try-run,\
all: makedumpfile
$(OBJ_PART): $(SRC_PART)
- $(CC) $(CFLAGS) -c -o ./$@ $(VPATH)$(@:.o=.c)
+ $(CC) $(CFLAGS_COMMON) -c -o ./$@ $(VPATH)$(@:.o=.c)
$(OBJ_ARCH): $(SRC_ARCH)
@mkdir -p $(@D)
$(CC) $(CFLAGS_ARCH) -c -o ./$@ $(VPATH)$(@:.o=.c)
makedumpfile: $(SRC_BASE) $(OBJ_PART) $(OBJ_ARCH)
- $(CC) $(CFLAGS) $(LDFLAGS) $(OBJ_PART) $(OBJ_ARCH) -rdynamic -o $@ $< $(LIBS)
+ $(CC) $(CFLAGS_COMMON) $(LDFLAGS) $(OBJ_PART) $(OBJ_ARCH) -rdynamic -o $@ $< $(LIBS)
echo .TH MAKEDUMPFILE 8 \"$(DATE)\" \"makedumpfile v$(VERSION)\" \"Linux System Administrator\'s Manual\" > temp.8
grep -v "^.TH MAKEDUMPFILE 8" $(VPATH)makedumpfile.8 >> temp.8
mv temp.8 makedumpfile.8
@@ -108,7 +109,7 @@ makedumpfile: $(SRC_BASE) $(OBJ_PART) $(
gzip -c ./makedumpfile.conf.5 > ./makedumpfile.conf.5.gz
eppic_makedumpfile.so: extension_eppic.c
- $(CC) $(CFLAGS) $(LDFLAGS) -shared -rdynamic -o $@ extension_eppic.c -fPIC -leppic -ltinfo
+ $(CC) $(CFLAGS_COMMON) $(LDFLAGS) -shared -rdynamic -o $@ extension_eppic.c -fPIC -leppic -ltinfo
clean:
rm -f $(OBJ) $(OBJ_PART) $(OBJ_ARCH) makedumpfile makedumpfile.8.gz makedumpfile.conf.5.gz
|