Skip to content

Instantly share code, notes, and snippets.

@benzap
Created June 3, 2012 04:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benzap/2861889 to your computer and use it in GitHub Desktop.
Save benzap/2861889 to your computer and use it in GitHub Desktop.
makefile for portable code between mingw and linux builds
#Written By: Benjamin Zaporzan
UNAME := $(shell uname)
CC = g++
PROGRAM_NAME =
OBJ =
##########################
######## Linux ###########
##########################
ifeq ($(UNAME), Linux)
#include specific variables for jobs
LIBS =
LIBS_DIR = ./libs/x86_linux #assuming you have this folder
INC_DIR = ./include/x86_linux #...
FLAGS =
MACRO_FLAGS = -d__LINUX_X86__
default : $(OBJ)
$(CC) $(OBJ) -o $(PROGRAM_NAME) $(LIBS_DIR) $(LIBS) $(INC_DIR) $(FLAGS) $(MACRO_FLAGS)
#satisfy dependencies
endif #END ifeq ($(UNAME), Linux)
##########################
###### Win32-Mingw #######
##########################
#find out if it is a version of mingw
SUB_UNAME := $(findstring MINGW32, $(UNAME))
ifeq ($(SUB_UNAME), MINGW32)
LIBS = #-lopengl
LIBS_DIR = -L./libs/x86_win32 #assuming you have this folder
INC_DIR = -I./includes/x86_win32 #...
FLAGS =
MACRO_FLAGS = -d__WIN32_X86__
PROGRAM_NAME = $(PROGRAM_NAME).exe
default-w32 : $(OBJ)
$(CC) $(OBJ) -o $(PROGRAM_NAME) $(LIBS_DIR) $(LIBS) $(INC_DIR) $(FLAGS) $(MACRO_FLAGS)
endif #END ifeq ($(SUB_UNAME), MINGW32)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment