Makefile linux - is it possible to restrict the compilation per machine?

Asked

Viewed 32 times

1

Hello

I have the following scenario, several machines shared in network, and with directories visible to each other. A developer called the program build on machine 1, but the program only compiles correctly on machine 2 (environment issues and SO/LIBS versions).

My question is: is there any way in Makefile to put some check to prevent compilation if it is not machine 2?

1 answer

2


You can set a variable on the correct machine, and make:

ifndef MAQUINACORRETA
$(error "Máquina errada")
endif

This way, the compilation will only work on the defined machine. This same logic can be used with variables existing in OS:

ifeq ($(CARACTERISTICADAMAQUINA), valor)
 $(error "Máquina errada")
endif

Whether by IP, station name, or anything you think is relevant to your case.

Note that you can do this here to expand something from the shell and use it in make:

$(shell echo $$OSTYPE) 

Applied to if:

ifeq ($(shell echo $$OSTYPE),ambientedesejado)

Are examples, have to adapt to the feature you consider appropriate to your case.

  • So in this case there is an environment variable that is storing the name of the machine ...and I can attach to it. Thanks @Bacco I will search for ways to get the name of the machine and assign in make this check

  • probably the case of making $(shell COMMAND)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.