How can I determine in the Makefile under which OS the program is compiled? It is advisable to know, at least, within IOS / Android / Windows / Linux. I would like to have a common file in which libraries will be connected depending on the OS.
1 answer
The question is turned upside down. you specify it, under what platform it is necessary to compile the program. and indicate this first to the compiler , not to the make interpreter.
Of course, if you do this through environment variables, you can add some processing to the program intended for the make interpreter.
the make interpreter understands various kinds of conditional constructs:
for example, write this program in the makefile :
цель: ifeq ($(собираемся-под),супер-ось) @echo 'ура! собираемся под нашу супер-ось' else @echo 'собираемся под фигню какую-то' endif examples of output (only for gnu / make ):
$ make собираемся под фигню какую-то $ make собираемся-под=супер-ось ура! собираемся под нашу супер-ось - oneI think it's worth mentioning that
ifeqis an extension of GNU Make. Native Make some * BSD will not understand you. There it is necessary to hide the conditions in sh. - Ainar-G
|
make, such asautotools/cmake/qmake, etc. - Fat-Zer