deadpixi / sam

An updated version of the sam text editor.
Other
430 stars 46 forks source link

Fix compiling parameters and dependencies for macOS #121

Open jacksonbenete opened 2 years ago

jacksonbenete commented 2 years ago

I hope you don't mind the pull request. This will only make it easier for compiling sam on macOS.

People on macOS don't have to change config.mk, as we'll be adding the dependencies automatically. Do you think this is a good idea?

jacksonbenete commented 2 years ago

I'm detecting Darwin but not BSD though, since I don't have the various versions of BSD to test if the changes are still needed for compilation. I removed the BSD comment, maybe we should keep it.

jacksonbenete commented 2 years ago

This will also address #120 .

On line 18 I've detected the system version:

OSVERSION := $(shell sw_vers | awk '($$1 = /ProductVersion:/){ ($$2 < 10.7) ? source = "-D_ANSI_SOURCE" : source = "-D_DARWIN_C_SOURCE"; print source }')
STANDARDS+=$(OSVERSION)

This is a bit cryptic, alternatively we can get more verbose:

OSVERSION_NEED_ANSI := $(shell sw_vers | awk '($$1 = /ProductVersion:/){ ($$2 < 10.7) ? ansi = 1 : ansi = 0; print ansi }')        

ifeq ($(OSVERSION_NEED_ANSI), 1) 
  STANDARDS+=-D_ANSI_SOURCE
else
  STANDARDS+=-D_DARWIN_C_SOURCE                                                                                          
endif