1

I'm trying to understand somethings about make command, and even if I've read the manual I still have some doubts about its usage. In particular, if I install a program (consisting in many packages) using the "classic" sequence of command on terminal, that is:

./configure -prefix /usr/bin/my_program (here I refer to a configuration file usually provided with some softwares)

make

sudo make install

what it the inverse operation to unistall that program? It's enough to erase the whole directory choose before? (for example with sudo rm -r /usr/bin/my_program).

Thanks to anyone so kind to explain it to me

4

2 Answers 2

3

Read the makefile for answers.

make is great, but it's not magical. The make application can only do what it's instructed to do (like any application). Those instructions are in the makefile.

If there are 'install' instructions in the makefile, then sudo make install will work, otherwise it will fail.

Similarly, make needs 'uninstall' instructions for sudo make uninstall to work.

2
  • 1
    sudo must be used for the make install and make uninstall.
    – heynnema
    Commented Dec 3, 2020 at 1:40
  • @heynnema good catch! edited.
    – user535733
    Commented Dec 3, 2020 at 4:19
1

For ANY Makefile, do a cat Makefile and look at the very end of the listing. There you'll find what options make will understand (for that particular Makefile).

Look at the following code snippet... and look for "option:"... and in this example, we can see "all:" and "modules:" and etc... all the way down to "uninstall:"... and even a few more after that.

This typically means (in this case example), following your initial make command, and sudo make install to build and install the code, you can use sudo make uninstall to remove the installed code.

all: modules

modules:
    $(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KSRC) M=$(shell pwd)  modules
    @echo "---------------------------------------------------------------------------"
    @echo "Visit https://github.com/aircrack-ng/rtl8812au for support/reporting issues"
    @echo "or check for newer versions (branches) of these drivers.                   "
    @echo "---------------------------------------------------------------------------"
strip:
    $(CROSS_COMPILE)strip $(MODULE_NAME).ko --strip-unneeded

install:
    install -p -m 644 $(MODULE_NAME).ko  $(MODDESTDIR)
    /sbin/depmod -a ${KVER}

uninstall:
    rm -f $(MODDESTDIR)/$(MODULE_NAME).ko
    /sbin/depmod -a ${KVER}

backup_rtlwifi:
    @echo "Making backup rtlwifi drivers"
ifneq (,$(wildcard $(STAGINGMODDIR)/rtl*))
    @tar cPf $(wildcard $(STAGINGMODDIR))/backup_rtlwifi_driver.tar $(wildcard $(STAGINGMODDIR)/rtl*)
    @rm -rf $(wildcard $(STAGINGMODDIR)/rtl*)
endif
ifneq (,$(wildcard $(MODDESTDIR)realtek))
    @tar cPf $(MODDESTDIR)backup_rtlwifi_driver.tar $(MODDESTDIR)realtek
    @rm -fr $(MODDESTDIR)realtek
endif
ifneq (,$(wildcard $(MODDESTDIR)rtl*))
    @tar cPf $(MODDESTDIR)../backup_rtlwifi_driver.tar $(wildcard $(MODDESTDIR)rtl*)
    @rm -fr $(wildcard $(MODDESTDIR)rtl*)
endif
    @/sbin/depmod -a ${KVER}
    @echo "Please reboot your system"

restore_rtlwifi:
    @echo "Restoring backups"
ifneq (,$(wildcard $(STAGINGMODDIR)/backup_rtlwifi_driver.tar))
    @tar xPf $(STAGINGMODDIR)/backup_rtlwifi_driver.tar
    @rm $(STAGINGMODDIR)/backup_rtlwifi_driver.tar
endif
ifneq (,$(wildcard $(MODDESTDIR)backup_rtlwifi_driver.tar))
    @tar xPf $(MODDESTDIR)backup_rtlwifi_driver.tar
    @rm $(MODDESTDIR)backup_rtlwifi_driver.tar
endif
ifneq (,$(wildcard $(MODDESTDIR)../backup_rtlwifi_driver.tar))
    @tar xPf $(MODDESTDIR)../backup_rtlwifi_driver.tar
    @rm $(MODDESTDIR)../backup_rtlwifi_driver.tar
endif
    @/sbin/depmod -a ${KVER}
    @echo "Please reboot your system"

config_r:
    @echo "make config"
    /bin/bash script/Configure script/config.in

DRIVER_VERSION = $(shell grep "\#define DRIVERVERSION" include/rtw_version.h | awk '{print $$3}' | tr -d v\")

dkms_install:
    mkdir -p /usr/src/8812au-$(DRIVER_VERSION)
    cp -r * /usr/src/8812au-$(DRIVER_VERSION)
    dkms add -m 8812au -v $(DRIVER_VERSION)
    dkms build -m 8812au -v $(DRIVER_VERSION)
    dkms install -m 8812au -v $(DRIVER_VERSION)
    dkms status

dkms_remove:
    dkms remove 8812au/$(DRIVER_VERSION) --all
    rm -rf /usr/src/8812au-$(DRIVER_VERSION)

.PHONY: modules clean

clean:
    #$(MAKE) -C $(KSRC) M=$(shell pwd) clean
    cd hal ; rm -fr */*/*/*.mod.c */*/*/*.mod */*/*/*.o */*/*/.*.cmd */*/*/*.ko
    cd hal ; rm -fr */*/*.mod.c */*/*.mod */*/*.o */*/.*.cmd */*/*.ko
    cd hal ; rm -fr */*.mod.c */*.mod */*.o */.*.cmd */*.ko
    cd hal ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko
    cd core ; rm -fr */*.mod.c */*.mod */*.o */.*.cmd */*.ko
    cd core ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko
    cd os_dep/linux ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko *.o.d
    cd os_dep ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko
    cd platform ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko
    rm -fr Module.symvers ; rm -fr Module.markers ; rm -fr modules.order
    rm -fr *.mod.c *.mod *.o .*.cmd *.ko *~
    rm -fr .tmp_versions
endif

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .