aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPali Rohár <pali@kernel.org>2021-12-26 18:42:35 +0100
committerMartin Mareš <mj@ucw.cz>2021-12-26 22:51:59 +0100
commitec1fe05c4811a1946ab42979e714a6515aef792a (patch)
treeee4a82b0653c626b7aecc78a06de792ca75b5742
parent79978004b854ad7cf38ef87aeaeab8550ce83d26 (diff)
downloadpciutils-ec1fe05c4811a1946ab42979e714a6515aef792a.tar.gz
Makefile: Append EXEEXT variable to executable filename rules
If x86_64-w64-mingw32-gcc compiler is called with -o filename option without any file extension then compiler automatically appends suffix ".exe" to output filename. This behavior of x86_64-w64-mingw32-gcc compiler basically breaks pattern rule of type '%: %.o' as x86_64-w64-mingw32-gcc compiler cannot generate arbitrary output file via -o option just by stripping .o extension from filename. When generating executables by x86_64-w64-mingw32-gcc compiler it is really the best option to specify .exe suffix in -o option. So introduce a new makefile variable EXEEXT which will be automatically appended to any executable filename. For Windows and DOS systems set it to ".exe". For other systems set it just to empty string "". GNU automake uses same makefile variable for same purpose.
-rw-r--r--.gitignore1
-rw-r--r--Makefile18
-rwxr-xr-xlib/configure4
3 files changed, 14 insertions, 9 deletions
diff --git a/.gitignore b/.gitignore
index a797910..4a25863 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
*.a
*.o
*.so
+*.exe
*.[0-9]
lspci
setpci
diff --git a/Makefile b/Makefile
index 17a8630..0ce56f6 100644
--- a/Makefile
+++ b/Makefile
@@ -59,7 +59,7 @@ PCIINC_INS=lib/config.h lib/header.h lib/pci.h lib/types.h
export
-all: lib/$(PCILIB) lspci setpci example lspci.8 setpci.8 pcilib.7 pci.ids.5 update-pciids update-pciids.8 $(PCI_IDS)
+all: lib/$(PCILIB) lspci$(EXEEXT) setpci$(EXEEXT) example$(EXEEXT) lspci.8 setpci.8 pcilib.7 pci.ids.5 update-pciids update-pciids.8 $(PCI_IDS)
lib/$(PCILIB): $(PCIINC) force
$(MAKE) -C lib all
@@ -69,8 +69,8 @@ force:
lib/config.h lib/config.mk:
cd lib && ./configure
-lspci: lspci.o ls-vpd.o ls-caps.o ls-caps-vendor.o ls-ecaps.o ls-kernel.o ls-tree.o ls-map.o common.o lib/$(PCILIB)
-setpci: setpci.o common.o lib/$(PCILIB)
+lspci$(EXEEXT): lspci.o ls-vpd.o ls-caps.o ls-caps-vendor.o ls-ecaps.o ls-kernel.o ls-tree.o ls-map.o common.o lib/$(PCILIB)
+setpci$(EXEEXT): setpci.o common.o lib/$(PCILIB)
LSPCIINC=lspci.h pciutils.h $(PCIINC)
lspci.o: lspci.c $(LSPCIINC)
@@ -84,7 +84,7 @@ ls-map.o: ls-map.c $(LSPCIINC)
setpci.o: setpci.c pciutils.h $(PCIINC)
common.o: common.c pciutils.h $(PCIINC)
-lspci: LDLIBS+=$(LIBKMOD_LIBS)
+lspci$(EXEEXT): LDLIBS+=$(LIBKMOD_LIBS)
ls-kernel.o: CFLAGS+=$(LIBKMOD_CFLAGS)
update-pciids: update-pciids.sh
@@ -92,10 +92,10 @@ update-pciids: update-pciids.sh
chmod +x $@
# The example of use of libpci
-example: example.o lib/$(PCILIB)
+example$(EXEEXT): example.o lib/$(PCILIB)
example.o: example.c $(PCIINC)
-%: %.o
+%$(EXEEXT): %.o
$(CC) $(LDFLAGS) $(TARGET_ARCH) $^ $(LDLIBS) -o $@
%.8 %.7 %.5: %.man
@@ -111,7 +111,7 @@ TAGS:
clean:
rm -f `find . -name "*~" -o -name "*.[oa]" -o -name "\#*\#" -o -name TAGS -o -name core -o -name "*.orig"`
- rm -f update-pciids lspci setpci example lib/config.* *.[578] pci.ids.gz lib/*.pc lib/*.so lib/*.so.* tags
+ rm -f update-pciids lspci$(EXEEXT) setpci$(EXEEXT) example$(EXEEXT) lib/config.* *.[578] pci.ids.gz lib/*.pc lib/*.so lib/*.so.* tags
rm -rf maint/dist
distclean: clean
@@ -119,7 +119,7 @@ distclean: clean
install: all
# -c is ignored on Linux, but required on FreeBSD
$(DIRINSTALL) -m 755 $(DESTDIR)$(SBINDIR) $(DESTDIR)$(IDSDIR) $(DESTDIR)$(MANDIR)/man8 $(DESTDIR)$(MANDIR)/man7 $(DESTDIR)/$(MANDIR)/man5
- $(INSTALL) -c -m 755 $(STRIP) lspci setpci $(DESTDIR)$(SBINDIR)
+ $(INSTALL) -c -m 755 $(STRIP) lspci$(EXEEXT) setpci$(EXEEXT) $(DESTDIR)$(SBINDIR)
$(INSTALL) -c -m 755 update-pciids $(DESTDIR)$(SBINDIR)
$(INSTALL) -c -m 644 $(PCI_IDS) $(DESTDIR)$(IDSDIR)
$(INSTALL) -c -m 644 lspci.8 setpci.8 update-pciids.8 $(DESTDIR)$(MANDIR)/man8
@@ -156,7 +156,7 @@ endif
endif
uninstall: all
- rm -f $(DESTDIR)$(SBINDIR)/lspci $(DESTDIR)$(SBINDIR)/setpci $(DESTDIR)$(SBINDIR)/update-pciids
+ rm -f $(DESTDIR)$(SBINDIR)/lspci$(EXEEXT) $(DESTDIR)$(SBINDIR)/setpci$(EXEEXT) $(DESTDIR)$(SBINDIR)/update-pciids
rm -f $(DESTDIR)$(IDSDIR)/$(PCI_IDS)
rm -f $(DESTDIR)$(MANDIR)/man8/lspci.8 $(DESTDIR)$(MANDIR)/man8/setpci.8 $(DESTDIR)$(MANDIR)/man8/update-pciids.8
rm -f $(DESTDIR)$(MANDIR)/man7/pcilib.7
diff --git a/lib/configure b/lib/configure
index 40f9ff8..ddcad87 100755
--- a/lib/configure
+++ b/lib/configure
@@ -62,6 +62,7 @@ echo >$m 'WITH_LIBS='
echo_n "Looking for access methods..."
LIBRESOLV=-lresolv
LIBEXT=so
+EXEEXT=
SYSINCLUDE=/usr/include
case $sys in
@@ -139,11 +140,13 @@ case $sys in
djgpp)
echo_n " i386-ports"
echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
+ EXEEXT=.exe
;;
cygwin)
echo_n " i386-ports"
echo >>$c '#define PCI_HAVE_PM_INTEL_CONF'
echo >>$m 'WITH_LIBS+=-lioperm'
+ EXEEXT=.exe
;;
beos|haiku)
case $cpu in
@@ -167,6 +170,7 @@ case $sys in
esac
echo >>$m "LIBEXT="$LIBEXT
+echo >>$m "EXEEXT="$EXEEXT
echo >>$c '#define PCI_HAVE_PM_DUMP'
echo " dump"