BSD Make > GNU Make

CMake or Meson simply because homegrown configure scripts and makefiles are a pita and prone to break on various platforms when packaging but to answer if you can do with (b)make compatibility that's great.
 
For embedded, Android or anything requiring more build steps than just "compiling C and C++", then BSD Make is easily the most flexible. For example packaging assets, baking lighting, generating certificates, etc.
 
As for Embedded programming, as an example, NXP's Smart Card Composer (the SDK/IDE for develop OS on microcontrollers) uses GNU Make.

And as for cross-platforms, I use GNU Make on FreeBSD, Linux, Windows, and makefiles are (almost) the same for all these platforms.

Sorry for the grumbling old raving GNU Make zealot. ;)
 
CMake or Meson simply because homegrown configure scripts and makefiles are a pita and prone to break on various platforms when packaging but to answer if you can do with (b)make compatibility that's great.
Of those, I'll always opt for CMake. Meson has its own set of dependency hell(s).
 
As for Embedded programming, as an example, NXP's Smart Card Composer (the SDK/IDE for develop OS on microcontrollers) uses GNU Make.

And as for cross-platforms, I use GNU Make on FreeBSD, Linux, Windows, and makefiles are (almost) the same for all these platforms.
Indeed. The trick is to avoid i.e pattern rules, then your POSIX-compliant Makefile can run in most places.
 
As for Embedded programming, as an example, NXP's Smart Card Composer (the SDK/IDE for develop OS on microcontrollers) uses GNU Make.

And as for cross-platforms, I use GNU Make on FreeBSD, Linux, Windows, and makefiles are (almost) the same for all these platforms.

Sorry for the grumbling old raving GNU Make zealot. ;)
With BSD make I can get the preferred CFLAGS, LDFLAGS, etc used by the system. No need to specify rules at all for simple programs. And the BSD's don't diverge a lot in this regard when including `bsd.*.mk`, which takes me to the next point:

When you have common stuff that you want to reuse in Makefiles, the `.include`directive in BSD Make behaves just like C's `#include`. With GNU Make I have to move the `include` to the bottom I don't know why.
 
I'm a fan of both to an extent but I'd say GNU wins because I can define functions in my gnu style makefile (which helps me in out-of-source builds). However, I should add that I've used GNU make more so I could just be not as good with BSD.

I did not know about the CLFAGS thing. I'll have to look into that. I really should spend more time with BSD make.

The programs I'm building these days (that I write on my MacBook) which are for my server (BSD) I've been writing in a nondescript make style which can be read by either.
 
Indeed. The trick is to avoid i.e pattern rules, then your POSIX-compliant Makefile can run in most places.
Yes, otherwise you have to create files with pattern rules for each platform, in which you specify something like this:

win_rules.mak :

Code:
# *.c -> *.obj
$(_TMP_DIR)/%.obj: %.c $(_PCH_NAME)
    $(call _MakeDir,$@)
    @$(_ECHO_CMD) $(_COMPILER) $(C_OPT) $(_PCH_OPT) -Fo$@ $<

unix_rules.mak :

Code:
# *.c -> *.o
$(_TMP_DIR)/%.o: %.c
    $(call _MakeDir,$@)
    $(_COMPILER) $(C_OPT) -o $@ $<
 
When you have common stuff that you want to reuse in Makefiles, the `.include`directive in BSD Make behaves just like C's `#include`. With GNU Make I have to move the `include` to the bottom I don't know why.
This is not mandatory, but overall, yes, this is 'vision' and 'common practice' of writing gnu makefiles. The general logic ( and default values for variables) is defined in a single file (main.mak), and the specifics for the current project/library in the project makefile. The latter includes the former. Inclusion of main.mak in project makefile is performed after all the specifics of the project have been defined.
Example:

main.mak :
Code:
... ... ...
export PLATFORM ?= WINDOWS

ifeq ($(PLATFORM),WINDOWS)
LIB_TESTS_LOG ?= nul
else
LIB_TESTS_LOG ?= /dev/null
endif

ifeq ($(MAKELEVEL),10)
$(error Too deep recursion level)
endif

ifeq ($(PLATFORM),WINDOWS)
 _MAKEDEP_UTIL:=perl.exe $(ROOT_DIR)/env/bin/makedep_win.pl
else
 _MAKEDEP_UTIL:=$(ROOT_DIR)/env/bin/makedep_lin.pl
endif

.PHONY: all always

all: build


_MAKE_DIR := $(ROOT_DIR)/make

include $(_MAKE_DIR)/gmsl

include $(_MAKE_DIR)/Lib.mak

... ... ...

project makefile :
Code:
ROOT_DIR := ../../..

SUB_ROOT_DIR := env

ifeq ($(PLATFORM),UNIX)
TARGET := libcryptLib.a
else
TARGET := cryptlib.lib
endif

include $(ROOT_DIR)/make/openssl.mak

include $(ROOT_DIR)/make/main.mak
 
Back
Top