File: Makefile

package info (click to toggle)
netstress 1.2.0-12
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 276 kB
  • sloc: ansic: 2,512; makefile: 214; sh: 6
file content (172 lines) | stat: -rw-r--r-- 4,482 bytes parent folder | download | duplicates (6)
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
##############################################################################
# Package: netstress Network Stress utility
# File: Makefile.arch
##############################################################################

CURDIR=$(shell basename $(shell pwd))

CFLAGS += -O2 -Wall ${INC}
#CFLAGS+=-g -Wall ${INC}

BIN_DIR=/usr/sbin

### Currently have pkgdir/topdir nested to facilitate creating RPM's
pkgdir=pkgdir
topdir=${pkgdir}/topdir

##############################################################################

ifeq (${ARCH},)
  ARCH:=$(shell arch)
endif

ifeq (${ARCH},i686)
  ARCH:=i386
endif

ifeq (${ARCH},x86_64)
  ARCH:=amd64
endif
ARCH:=build
##############################################################################

PKGname:=$(shell grep -e "[^[:space:]]" PKGname)
PKGversion:=$(shell grep -e "[^[:space:]]" PKGversion)
PKGarch:=${ARCH}

##############################################################################

.PHONY: all
all: ${ARCH}/netstress

##############################################################################

${ARCH}/netstress: ${ARCH}/netstress.o
	${CC} ${CFLAGS} ${LDFLAGS} ${CPPFLAGS} -o $@ $^

##############################################################################

${ARCH}/%.o: %.c
	@mkdir -v -p ${ARCH}
	${CC} ${CFLAGS} ${LDFLAGS} ${CPPFLAGS} -c -o $@ $^

##############################################################################

.PHONY: bin_install
bin_install: ${ARCH}/netstress
	@if [ -d "${pkgdir}" ]; then rm -fr ${pkgdir}; fi
	@mkdir -p --verbose ${topdir}
	@#
	@install -v -d -m 755 ${topdir}/${INSTALL_DIR}
	@install -v -d -m 755 ${topdir}/${BIN_DIR}
	@install -v -m 755 ${ARCH}/netstress ${topdir}/${BIN_DIR}/

##############################################################################

.PHONY: deb_install
deb_install:
	${MAKE} bin_install
	@# Place the debian package information/scripts in place
	@install -v -d -m 755 ${topdir}/DEBIAN
	@install -v -m 644 DEBIAN/control ${topdir}/DEBIAN/control
	@#
	@# Replace PKGname, PKGarch and PKGversion in the control file
	sed -i	-e"s/^Package:.*/Package: ${PKGname}/g" \
		-e"s/^Version:.*/Version: ${PKGversion}/g" \
		-e"s/^Architecture:.*/Architecture: ${PKGarch}/g" \
		${topdir}/DEBIAN/control
		
##############################################################################

.PHONY: rpm_install
rpm_install:
	${MAKE} bin_install
	@# Place the redhat package information/scripts in place
	@# TBD

##############################################################################

DEB_PKG:="${ARCH}/${PKGname}_${PKGversion}_${PKGarch}.deb"

.PHONY: deb debian
deb: ${DEB_PKG}
debian: ${DEB_PKG}

${DEB_PKG}:
	${MAKE} deb_install
	@# Create the ${topdir}/DEBIAN/md5sums file
	@cd ${topdir}; \
	find . ! -path \*/DEBIAN/\* -type f | xargs md5sum > DEBIAN/md5sums
	@#
	@# Create the actual .deb package
	dpkg-deb -b ${topdir} ${DEB_PKG}
	@ls -l ${DEB_PKG}

##############################################################################

RPM_PKG:="${ARCH}/${PKGname}_${PKGversion}_${PKGarch}.rpm"

.PHONY: rpm redhat
rpm: ${DEB_PKG}
redhat: ${DEB_PKG}

${RPM_PKG}:
	${MAKE} rpm_install
	@# TBD

##############################################################################

BINTAR_PKG:=${ARCH}/${PKGname}_${PKGversion}_${ARCH}.tgz

.PHONY: bintar
bintar: ${BINTAR_PKG}

${BINTAR_PKG}:
	${MAKE} bin_install
	cd ${topdir}; \
	tar -czv -f ../../$@ .

##############################################################################

SRCTAR_PKG:=${PKGname}_${PKGversion}_src.tgz

.PHONY: srctar
srctar: ${SRCTAR_PKG}

${SRCTAR_PKG}:
	cd ..; \
	tar -czv -X ${CURDIR}/tar-excludes -f ${CURDIR}/$@ ${CURDIR}

##############################################################################

.PHONY: done
done:
	echo ""
	@find . | grep -e"\.tgz$$" -e"\.deb$$" -e"\.rpm$$" | xargs ls -lh

.PHONY: package
package:
	${MAKE} debian
	${MAKE} redhat
	${MAKE} bintar
	${MAKE} srctar
	${MAKE} done

##############################################################################

.PHONY: clean
clean:
	-@if [ -d "${ARCH}" ]; then rm -fr ${ARCH}; fi
	-@find . -mindepth 1 -maxdepth 1 -name "*.tgz" | xargs rm -f
	-@find . -mindepth 1 -maxdepth 1 -name "*.rpm" | xargs rm -f
	-@find . -mindepth 1 -maxdepth 1 -name "*.deb" | xargs rm -f
	-@rm -fr pkgdir

.PHONY: cleanall
cleanall: clean
	-@for THIS_ARCH in 1386 amd64; do \
		if [ -d "$${THIS_ARCH}" ]; then rm -fr $${THIS_ARCH}; fi; \
	done

##############################################################################