Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 225955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:27:52+00:00 2026-05-11T19:27:52+00:00

I want to know a parameter which is an indicator of the current OS.

  • 0

I want to know a parameter which is an indicator of the current OS. If am supporting Windows and Linux, how can I get a system parameter which differentiates the OS types. This for an OS independent makefile which runs both in Windows and Linux by checking the parameter in an ‘if’.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T19:27:52+00:00Added an answer on May 11, 2026 at 7:27 pm

    In the past I’ve checked the value of the environment variable OS. This is set on Windows. For other platforms I’ve explicitly set it in the environment. This then lets you push platform specific settings into makefiles called …

    makefile.Windows_NT
    makefile.Linux
    makefile.HPUX
    

    In my main makefile I then just do

    SUPPORTED_PLATFORMS=Windows_NT AIX AIX32 Solaris8 Linux HPUX Solaris_64
    
    ifeq (,$(findstring $(OS),$(SUPPORTED_PLATFORMS)))
    
    all %:
            @echo The OS environment variable is set to [$(OS)].
            @echo Please set the OS environment variable to one of the following:
            @echo $(SUPPORTED_PLATFORMS)
    
    else
    
    
    include makefile.$(OS)
    
    
    all:
            @$(TCLSH) makefile.tcl
            @$(MAKE) -f makefile.gen
    
    
    clean:
            @$(TCLSH) makefile.tcl
            @$(MAKE) -f makefile.gen clean
            @$(RM) makefile.gen
    
    etags:
            @$(RM) TAGS
            @etags *.cpp *.h TAGS
            @$(MAKE) -C Core etags
            @$(MAKE) -C Components etags
            @$(MAKE) -C Repository etags
    
    tags: ctags
    
    ctags:
            @ctags *.h
            @$(MAKE) -C Core ctags
            @$(MAKE) -C Components ctags
            @$(MAKE) -C Repository ctags
    
    lint:
            @$(TCLSH) makefile.tcl
            @$(MAKE) -f makefile.gen lint
    
    depends:
            @$(TCLSH) makefile.tcl
            @$(MAKE) -f makefile.gen depends
    
    endif
    

    This all works because I can pull in the platform specific settings via makefile.$(OS)

    That’s the sum total of my main makefile and it compiles for seven different platforms. You could make the detection cleverer but that would reduce comprehensability.

    In each makefile.WHATEVER I provide definitions of things like

    #*******************************************************************************
    #
    #   Platform specific tools
    #
    CC              = CL
    RM              = rm
    LINK            = LINK
    ETAGS           = c:\emacs\bin\etags
    TCLSH           = tclsh83
    
    #*******************************************************************************
    #
    #   Platform specific CC definitions
    #
    INCLUDE := $(SYS_INCDIR);$(INCLUDE);$(SOURCE_ROOT_DIR)/SivTech/cpp;$(ORACLE_INCDIR);$(DB2_INCDIR);$(ODBC_INCDIR);$(MYSQL_INCDIR);$(TCL_INCDIR);$(XML_INCDIR);$(XSLT_INCDIR);$(JNI_INCLUDE);$(ACE_INCDIR);$(TAO_INCDIR);$(TAO_SERVICES_INC);$(CPPUNIT_INCDIR);$(ICU_INCDIR);$(SAP_INCDIR);$(QAS_INCDIR);$(INFA_INCDIR);$(MELISSADATA_INCDIR);$(ADDRESSDOCTOR_INCDIR)
    
    CC_DEFS := $(CC_DEFS) -DOS_WIN_95 -D_WIN32_WINNT=0x400 -D_MBCS -DWIN32_LEAN_AND_MEAN -DWIN32 -DWIN32_EXTRA_LEAN $(CC_DEFINES)
    
    CC_FLAGS_CMN    := /c /nologo /G7  /EHsc /W3  $(CC_FLAGS$) $(CC_DEFS) $(MYFLAGS)
    CC_FLAGS_DBG    := $(CC_FLAGS_CMN) /Gi /MDd /Od /Zi /RTCu /RTCs /GZ
    

    Obviously this is quite a C/C++ focus makefile but it proves that you can abstract away all of the platform specifics.

    Chris

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to know the way by which I can send a SharedPreference file
I want to write a function that accepts a parameter which can be either
i want know how i can manage multiple twitter account on iOS in my
i want know if is possible, to get a specific element value of a
please help me. I want know about what types of flags to run an
I have a method in a webservice that has parameter with which users can
I want to know how to call a function, passing a parameter that it
I have the caption parameter set in the jqGrid definition. I want to know
There seems to be too many attributes/parameters in CSS... I want to know all
I want to run tcpdump with some parameters (still don't know what to use),

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.