Skip to content

Instantly share code, notes, and snippets.

@AgtLucas
Forked from sighingnow/Makefile
Created May 17, 2020 17:26

Revisions

  1. @sighingnow sighingnow renamed this gist May 29, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. @sighingnow sighingnow created this gist May 29, 2015.
    35 changes: 35 additions & 0 deletions Makefile-detect-os
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    # Detect operating system in Makefile.
    # Author: He Tao
    # Date: 2015-05-30

    OSFLAG :=
    ifeq ($(OS),Windows_NT)
    OSFLAG += -D WIN32
    ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
    OSFLAG += -D AMD64
    endif
    ifeq ($(PROCESSOR_ARCHITECTURE),x86)
    OSFLAG += -D IA32
    endif
    else
    UNAME_S := $(shell uname -s)
    ifeq ($(UNAME_S),Linux)
    OSFLAG += -D LINUX
    endif
    ifeq ($(UNAME_S),Darwin)
    OSFLAG += -D OSX
    endif
    UNAME_P := $(shell uname -p)
    ifeq ($(UNAME_P),x86_64)
    OSFLAG += -D AMD64
    endif
    ifneq ($(filter %86,$(UNAME_P)),)
    OSFLAG += -D IA32
    endif
    ifneq ($(filter arm%,$(UNAME_P)),)
    OSFLAG += -D ARM
    endif
    endif

    all:
    @echo $(OSFLAG)