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 7930861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:33:15+00:00 2026-06-03T20:33:15+00:00

I am trying to make my Makefiles platform conditional with statements like: ifeq ($(UNAME),

  • 0

I am trying to make my Makefiles platform conditional with statements like:

ifeq ($(UNAME), Linux)
# LINUX version
program_NAME := lib$(TARGET).so
OBJDIR = ../build/linux
endif

ifeq ($(UNAME), MINGW32_NT-6.1)
# WINDOWS version
program_NAME := lib$(TARGET).dll
OBJDIR = ../build/windows
endif

and:

ifeq ($(UNAME), Linux)
# LINUX version
program_INCLUDE_DIRS := \
    /home/ben/projects/g2/src \
    /home/ben/projects/pulse_IO/src \
    /home/ben/projects/core/src

endif

ifeq ($(UNAME), MINGW32_NT-6.1)

# WINDOWS Virtual Machine version
program_INCLUDE_DIRS := \
    E:/g2/src \
    E:/pulse_IO/src \
    E:/core/src

endif

I then compile the src either under Linux or Windows 7 running as a VM (via virtualbox) on a Linux host OS. Problem I haven’t managed to solve is how to get the object files and resulting shared libraries or executables to be written to a platform specific directory, e.g. /build/linux or /build/windows where the source code is in /src

As you can see I’ve added an OBJDIR variable but I can’t figure out how to use that to redirect the .o, .so, .dll, .exe files to the correct dir conditional on platform. I’m sure it should be easy but my research keeps bogging down with articles on vpath usage which I don’t think is what I’m after.

The part of my Makefile I think I need to modify is as follows:

LINK.c := $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)

$(program_NAME): $(program_OBJS)
    $(LINK.c) -shared -Wl,-soname,$(program_NAME) $(program_OBJS) -o $(program_NAME)

I should probably be using something smarter like autotools or cmake but it would be great just to get this working for now.

should also add, my list of object files is created as follows:

program_C_OBJS := ${program_C_SRCS:.c=.o}

Have tried:

program_OBJS := $(addprefix $(OBJDIR)/$program_C_OBJS)

but make compains that addprefix has the wrong no. of arguments

  • 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-06-03T20:33:16+00:00Added an answer on June 3, 2026 at 8:33 pm

    For gmake, see Here:

     OBJDIR := objdir
     OBJS := $(addprefix $(OBJDIR)/,foo.o bar.o baz.o)
    
     $(OBJDIR)/%.o : %.c
             $(COMPILE.c) $(OUTPUT_OPTION) $<
    
     all: $(OBJS)
    
     $(OBJS): | $(OBJDIR)
    
     $(OBJDIR):
             mkdir $(OBJDIR)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to make a simple number clicker control for BlackBerry 6/7, like this: At
I'm trying to use cmake (on Linux with GNU make and g++) to build
I am trying to build gzip for an embedded platform on a Linux machine.
(On Linux, trying to set up SDL) I'm having a time with makefiles, I'm
I am trying to make a makefile which does the following: gets source files
I am trying to run make on a PintOS makefile but I keep getting
I'm trying make a login window where a user is prompted to enter their
I'm trying make an entity with doctrine that has three associations with other entities
I am trying make long screen to vertical direction. So, I need a screen
I am fairly new to iOS development and trying make a simple app which

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.