]> mj.ucw.cz Git - pciutils.git/commitdiff
Makefile: Append EXEEXT variable to executable filename rules
authorPali Rohár <pali@kernel.org>
Sun, 26 Dec 2021 17:42:35 +0000 (18:42 +0100)
committerMartin Mareš <mj@ucw.cz>
Sun, 26 Dec 2021 21:51:59 +0000 (22:51 +0100)
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.

.gitignore
Makefile
lib/configure

index a797910522f4a4b22310e243ebcd8768911f552f..4a25863a1504d2c658309ad65eb6fe979a6661f3 100644 (file)
@@ -1,6 +1,7 @@
 *.a
 *.o
 *.so
+*.exe
 *.[0-9]
 lspci
 setpci
index 17a8630933e7a3ba9dc116928cb1c6a7a8fe684e..0ce56f6ce5e1ec85072dbe2e3cd4f1a676c2cd65 100644 (file)
--- 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
index 40f9ff8d454812fabd0357143b76820fd17f6f20..ddcad874b06fc4e9f0b9371b1fbc3e864790b1d9 100755 (executable)
@@ -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"