@@ -7,13 +7,14 @@ KERN_DEBUG_ENVVARS = CONFIG_DEBUG_INFO=1
7
7
RELEASE_CFLAGS = -O3 -march=native
8
8
KERN_RELEASE_CFLAGS = -O3
9
9
KERN_RELEASE_ENVVARS =
10
- LDFLAGS = -lhpcap -lnuma - lpcap -lpthread -lm -lmgmon
10
+ LDFLAGS = -lhpcap -lpcap -lpthread -lm -lmgmon
11
11
DEBUG_LDFLAGS = -Llib/debug
12
12
RELEASE_LDFLAGS = -Llib/release
13
13
LATEXFLAGS = -pdf -silent -synctex=1 -shell-escape
14
+ VERBOSE = 0
14
15
15
16
# Uncomment to build the driver for a specific kernel version
16
- # BUILD_KERNEL=3.2 .0-23 -generic
17
+ # BUILD_KERNEL=4.8 .0-32 -generic
17
18
18
19
# Directory variables
19
20
BINDIR = bin
@@ -78,8 +79,6 @@ all: $(ALL_TARGETS)
78
79
libs : $(LIB_NAMES )
79
80
samples : $(SAMPLES )
80
81
81
- .FORCE :
82
-
83
82
# For debugging
84
83
print-% : ; @echo $* =$($* )
85
84
@@ -102,6 +101,8 @@ help:
102
101
@echo " - uninstall: Uninstall the driver from the system."
103
102
@echo " - pack: Pack the source code in a .tar.gz file in the current directory."
104
103
@echo " - dist: Pack the source code and binaries in a ready-to-install package."
104
+ @echo " - format: Run the astyle formatter"
105
+ @echo " - check: Check the folder structure is correct and output readable errors"
105
106
@echo " "
106
107
@echo " Apart from those generic rules, you can use specific rules, such as bin/[conf]/[binary]"
107
108
@echo " or lib/[conf]/[library] to build just one file in one given configuration. Drivers are"
@@ -113,6 +114,9 @@ help:
113
114
@echo " Drivers: $( DRIV_TARGETS) "
114
115
@echo " Sample applications: $( SAMPLES) "
115
116
@echo " Libraries: $( LIB_NAMES) "
117
+ @echo " "
118
+ @echo " Note: If some target gives Makefile errors, first try to run make clean, rm -rf obj, and/or run make check"
119
+ @echo " to see if it is some common error (like not having the correct folder structure)."
116
120
117
121
# ###################################
118
122
# # Build configuration management ##
@@ -139,6 +143,14 @@ ALL_DEPS = $(SAMPLE_DEPS) $(LIB_DEPS)
139
143
config : $(ALL_CONFS )
140
144
depend : $(ALL_DEPS )
141
145
146
+ check :
147
+ @for driver in $(DRIV_NAMES ) ; do \
148
+ if [ ! -d $( DRIVDIR) /$$ driver/driver ]; then \
149
+ echo " Error: Cannot build $$ driver: folder $( DRIVDIR) /$$ driver/driver does not exist" ; \
150
+ fi ; \
151
+ done ; \
152
+
153
+
142
154
# If the kernel version is fixed, we have to add it to the kernel environment variables
143
155
ifneq (,$(BUILD_KERNEL ) )
144
156
KERN_DEBUG_ENVVARS += BUILD_KERNEL=$(BUILD_KERNEL )
@@ -189,7 +201,10 @@ generate_deps = \
189
201
done; \
190
202
mv "$(1 ) .0" $(1 )
191
203
192
- drivname = $(shell echo $(1 ) | sed -E 's/hpcap_(ixgbe) ?([a-zA-Z]*).*/hpcap\2/')
204
+ # This function is just a regex that constructs the hpcap driver name from the folder name
205
+ # E.g., hpcap_i40e-1.4.25 is converted to hpcapi, hpcap_ixgbevf-2.14.2 is converted to
206
+ # hpcapvf, etc.
207
+ drivname = $(shell echo $(1 ) | sed -E 's/hpcap_(ixgbe) ?([a-zA-Z]*)[0-9e]*(vf)?.*/hpcap\2\3/')
193
208
194
209
DRIV_TARGETS := $(foreach driver, $(DRIV_NAMES ) , $(call drivname, $(driver ) ) )
195
210
DRIV_BINARIES := $(foreach conf, $(CONFS ) , $(wildcard $(BINDIR ) /$(conf ) /* .ko) )
@@ -282,30 +297,38 @@ $(OBJDIR)/.lib-%-deps.mk: $(LIBSRCDIR)/%/*.c Makefile | $(OBJDIR)
282
297
# ###################################
283
298
SOURCES_AFFECTING_VERSION := $(filter-out $(COMMON_DIR ) /hpcap_version.h, $(ALL_SRCS ) )
284
299
285
- VERSION_FILE = .svnversion
286
- DEFAULT_BRANCH = trunk
287
- BRANCH = $(shell svn info 2> /dev/null | grep '^URL:' | egrep -o '(tags|branches) /[^/]+|trunk' || echo "$(DEFAULT_BRANCH ) ")
288
- REVISION = $(shell svnversion -n 2>/dev/null || cat $(VERSION_FILE ) 2>/dev/null || echo "no-cvs-info")
300
+ # Use "wildcard" to avoid errors due to unexisting files when not running without the .git
301
+ # directory. If the .git directory is not present, GIT_INFO_FILES will be empty.
302
+ GIT_INFO_FILES := $(wildcard .git/index) $(wildcard .git/HEAD)
303
+ VERSION_FILE = .gitversion
304
+ GIT_BRANCH = $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "master")
305
+ GIT_COMMIT = $(shell git describe --dirty --tags --always --abbrev=7 --match="v* " || cat $(VERSION_FILE ) 2>/dev/null || echo "no-git-info")
289
306
290
- VERSION_BRANCH_INFO = from $(BRANCH )
307
+ ifeq (master,$(GIT_BRANCH ) )
308
+ VERSION_BRANCH_INFO =
309
+ else
310
+ VERSION_BRANCH_INFO = , branch $(GIT_BRANCH )
311
+ endif
291
312
292
- # hpcap_version.h should be regenerated also when the SVN revision changes.
293
- # However, SVN is not like git where we have a nice file that changes when
294
- # the revision or HEAD pointer changes, so I can't do that. I can't neither
295
- # make this file depend on VERSION_FILE because it hangs the build process.
296
- $(COMMON_DIR ) /hpcap_version.h : $(SOURCES_AFFECTING_VERSION )
313
+ # Only overwrite the version file if we can extract significant info (that is, the .git directory)
314
+ # is present.
315
+ $(COMMON_DIR ) /hpcap_version.h : $(SOURCES_AFFECTING_VERSION ) $(GIT_INFO_FILES )
316
+ ifneq (,$(GIT_INFO_FILES ) )
297
317
@echo "# ifndef HPCAP_VERSION_H" > $@
298
318
@echo "# define HPCAP_VERSION_H" >> $@
299
- @echo " #define HPCAP_REVISION \" $( REVISION ) $( VERSION_BRANCH_INFO) \" " >> $@
319
+ @echo "# define HPCAP_REVISION \"$(GIT_COMMIT) $(VERSION_BRANCH_INFO)\"" >> $@
300
320
@echo "# define HPCAP_BUILD_DATE \"$(shell date +"%d %b %Y %R %Z")\"" >> $@
301
- @echo " #define HPCAP_BUILD_INFO \" rev \" HPCAP_REVISION \" built \" HPCAP_BUILD_DATE" >> $@
321
+ @echo "# define HPCAP_BUILD_INFO HPCAP_REVISION \" built \" HPCAP_BUILD_DATE" >> $@
302
322
@echo "# endif" >> $@
323
+ else
324
+ @touch $@
325
+ endif
303
326
304
- $(VERSION_FILE ) : .FORCE
305
- ifneq (,$(shell which svnversion 2>/dev/null ) )
306
- @echo $(shell svnversion 2>/dev/null || echo "no-svn-info" ) > $@
327
+ $(VERSION_FILE ) : $( GIT_INFO_FILES )
328
+ ifneq (,$(GIT_INFO_FILES ) )
329
+ @echo $(shell git describe --dirty --tags --always --abbrev=7 ) > $@
307
330
else
308
- @[ -e $@ ] || echo "no-svn-info" > $@
331
+ @touch $@
309
332
endif
310
333
311
334
version-info : $(COMMON_DIR ) /hpcap_version.h $(VERSION_FILE )
@@ -410,11 +433,22 @@ TAR_EXCLUDES_SRC = $(TAR_EXCLUDES_DIST) bin lib
410
433
TAR_EXCLUDES_DIST_ARG = $(addprefix --exclude=, $(TAR_EXCLUDES_DIST ) )
411
434
TAR_EXCLUDES_SRC_ARG = $(addprefix --exclude=, $(TAR_EXCLUDES_SRC ) )
412
435
413
- TAR_BRANCH = _$(shell echo $(BRANCH ) | tr '/' '-' | sed 's/release/pre-release/')
436
+ # Only show the git branch if we're not on master
437
+ ifeq (master,$(GIT_BRANCH ) )
438
+ TAR_GITBRANCH =
439
+ else
440
+ TAR_GITBRANCH = _$(shell echo $(GIT_BRANCH ) | tr '/' '-' | sed 's/release/pre-release/')
441
+ endif
442
+
443
+ TAR_TARGET = HPCAP$(TAR_GITBRANCH ) _$(shell date +"% F") _$(shell git describe --tags --always --match="v* ")
444
+
445
+ CHANGELOG : $(GIT_INFO_FILES )
446
+ @git tag -l -n99 " v*" > CHANGELOG
414
447
415
- TAR_TARGET = HPCAP$(TAR_BRANCH ) _$(shell date +"% F") _rev$(subst :,-,$(REVISION ) )
448
+ VERSION.txt : $(GIT_INFO_FILES )
449
+ @git tag -l $(shell git describe) -n99 > VERSION.txt
416
450
417
- changes : version-info
451
+ changes : CHANGELOG VERSION.txt version-info
418
452
419
453
pack : docs changes
420
454
@cd ..; COPYFILE_DISABLE=1 tar $(TAR_EXCLUDES_SRC_ARG ) -czf $(TAR_TARGET ) .tar.gz $(lastword $(notdir $(CURDIR ) ) )
@@ -425,3 +459,10 @@ dist: release docs changes
425
459
@cd ..; COPYFILE_DISABLE=1 tar $(TAR_EXCLUDES_DIST_ARG ) -czf $(TAR_TARGET ) _dist.tar.gz $(lastword $(notdir $(CURDIR ) ) )
426
460
@mv ../$(TAR_TARGET ) _dist.tar.gz .
427
461
@echo " Packed $( TAR_TARGET) .tar.gz."
462
+
463
+ # ###################################
464
+ # # Some misc scripts ##
465
+ # ###################################
466
+
467
+ format :
468
+ astyle --options=.astylerc --recursive " driver/*.c" " driver/*.h" " samples/*.c" " samples/*.h" " include/*.h" " srclib/*.c"
0 commit comments