Skip to content

Instantly share code, notes, and snippets.

@codebrainz
Created December 18, 2011 21:56
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 codebrainz/1494603 to your computer and use it in GitHub Desktop.
Save codebrainz/1494603 to your computer and use it in GitHub Desktop.
Windows Make file for Geany
########################################################################
# Geany Make file for Windows
# ===========================
#
# Simple instructions:
# --------------------
# - Download and install MinGW to C:\MinGW
# - Download and install GTK+ bundle to C:\GTK
# - Add `bin` dir of both of above to PATH environment variable
# - Change into the root of the Geany source code (this directory)
# - Execute `mingw32-make -f windows.mk`
#
# TODO:
# -----
# - Create an installation target
# - Create an uninstallation target
# - Use PREFIX for the install/uninstall
# - Get `config.h` able to be include (missing fnmatch.h here) and
# set -DHAVE_CONFIG_H so it's used
# - Support MAKE V=N to control amount of verbosity
########################################################################
#=======================================================================
# Variables
#=======================================================================
# Installation prefix (TODO)
#ifndef PREFIX
#PREFIX = "."
#endif
# Path to GTK+ bundle
ifndef GTK_BASE
GTK_BASE = C:/GTK
endif
# Path to MinGW
ifndef MINGW_BASE
MINGW_BASE = C:/MinGW
endif
# Path to C compiler
CC = $(MINGW_BASE)/bin/gcc
# Path to C++ compiler
CXX = $(MINGW_BASE)/bin/g++
# Compiler include paths for GTK+
GTK_INCLUDES = \
-I"$(GTK_BASE)/include/gtk-2.0" \
-I"$(GTK_BASE)/lib/gtk-2.0/include" \
-I"$(GTK_BASE)/include/atk-1.0" \
-I"$(GTK_BASE)/include/cairo" \
-I"$(GTK_BASE)/include/gdk-pixbuf-2.0" \
-I"$(GTK_BASE)/include/pango-1.0" \
-I"$(GTK_BASE)/include/glib-2.0" \
-I"$(GTK_BASE)/lib/glib-2.0/include" \
-I"$(GTK_BASE)/include" \
-I"$(GTK_BASE)/include/gettext"
# Compiler include paths for the C source files
C_INCLUDES = \
-I. -Isrc \
-Itagmanager \
-Itagmanager/mio \
-Itagmanager/include \
-Iscintilla/src \
-Iscintilla/lexlib \
-Iscintilla/include \
-Iscintilla/gtk \
$(GTK_INCLUDES)
# Compiler include paths for the C++ source files (Scintilla)
CXX_INCLUDES = \
-Iscintilla/src \
-Iscintilla/lexlib \
-Iscintilla/include \
-Iscintilla/gtk \
$(GTK_INCLUDES)
# C Preprocessor Macros
DEFINES = \
-DGEANY_PRIVATE \
-DGEANY_DATADIR=\"data\" \
-DGEANY_LOCALEDIR=\"\" \
-DGEANY_LIBDIR=\"\" \
-DGEANY_PREFIX=\"\" \
-DPACKAGE=\"geany\" \
-DGTK \
-DSCI_LEXER \
-DGETTEXT_PACKAGE=\"geany\" \
-DVERSION=\"1.22\" \
-DREVISION=\"-1\"
# Linker library directories for GTK+
LIBDIRS = -L"$(GTK_BASE)/lib"
# GTK+ libraries to link to
GTK_LIBS = \
-lgtk-win32-2.0 \
-lgdk-win32-2.0 \
-latk-1.0 \
-lgdk_pixbuf-2.0 \
-lpangowin32-1.0 \
-lgdi32 \
-lpango-1.0 \
-lgobject-2.0 \
-lgmodule-2.0 \
-lgthread-2.0 \
-lglib-2.0 \
-lgthread-2.0 \
-lintl \
-lcairo \
-lpangocairo-1.0 \
-lgio-2.0
# Miscellaneous libraries and linker flags
MISC_LIBS = -mwindows -lole32 -luuid -liberty -lwsock32 -lstdc++
# Miscellaneous compiler flags
MISC_CFLAGS = -pipe -mms-bitfields
# Combine various cpp and compiler flags into one variable
GEANY_CFLAGS = \
$(INCLUDES) \
$(DEFINES) \
$(MISC_CFLAGS) \
$(CFLAGS)
# Combine various linker flags into one variable
GEANY_LIBS = \
$(LIBDIRS) \
$(GTK_LIBS) \
$(MISC_LIBS) \
$(LDFLAGS)
# Object files based on all the C files
C_SOURCES = \
$(wildcard src/*.c) \
$(wildcard tagmanager/*.c) \
$(wildcard tagmanager/mio/*.c) \
$(wildcard scintilla/gtk/*.c)
C_OBJECTS = $(C_SOURCES:.c=.c.o)
# Object files bassed on all the C++ files (Scintilla)
CXX_SOURCES = \
$(wildcard scintilla/gtk/*.cxx) \
$(wildcard scintilla/lexers/*.cxx) \
$(wildcard scintilla/lexlib/*.cxx) \
$(wildcard scintilla/src/*.cxx)
CXX_OBJECTS = $(CXX_SOURCES:.cxx=.cpp.o)
#=======================================================================
# Compile & Link
#=======================================================================
# Link all of the objects together (this is the default target)
geany.exe: $(C_OBJECTS) $(CXX_OBJECTS)
@echo Linking $@... && \
$(CC) -o $@ $^ $(GEANY_LIBS)
# Setup virtual paths to find C/C++ source files
vpath %.c src
vpath %.h src
vpath %.c tagmanager/mio tagmanager
vpath %.h tagmanager/mio tagmanager/include
vpath %.c scintilla/gtk
vpath %.cxx scintilla/gtk scintilla/lexers scintilla/lexlib scintilla/src
vpath %.h scintilla/gtk scintilla/lexers scintilla/lexlib scintilla/src scintilla/include
# Compile objects for all of the C source files
%.c.o: %.c
@echo Compiling $@... && \
$(CC) $(GEANY_CFLAGS) $(C_INCLUDES) -c $< -o $@
# Compile objects for all of the C++ source files
%.cpp.o: %.cxx
@echo Compiling $@... && \
$(CXX) $(GEANY_CFLAGS) $(CXX_INCLUDES) -c $< -o $@
# TODO
# install:
# TODO
# uninstall:
# Cleanup all built files made by this make file
clean:
@echo Removing built files...
@del deps.mak 1>nul 2>nul
@del geany.exe 1>nul 2>nul
@del /S *.c.o 1>nul 2>nul
@del /S *.cpp.o 1>nul 2>nul
# Generate header dependencies so that objects get updated when the
# header files are changed (this is slooooow!)
# TODO: skip on clean using MAKECMDGOALS
deps.mk:
@echo Generating header dependencies... && \
$(CC) -MM $(CFLAGS) $(C_INCLUDES) $(C_SOURCES) > deps.mk && \
$(CXX) -MM $(CFLAGS) $(CXX_INCLUDES) $(CXX_SOURCES) >> deps.mk
-include deps.mk
.PHONY: clean
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment