# Copyright 2007-2016 Mitchell mitchell.att.foicica.com. See LICENSE. CC = gcc CXX = g++ ifeq (win, $(findstring win, $(MAKECMDGOALS))) # Cross-compile for Win32. CROSS = i686-w64-mingw32- CFLAGS = -mms-bitfields -Os CXXFLAGS = -mms-bitfields -static-libgcc -static-libstdc++ -Os LUA_CFLAGS = -DLUA_BUILD_AS_DLL -DLUA_LIB LDFLAGS = -Wl,--retain-symbols-file -Wl,lua.sym ifeq (, $(findstring curses, $(MAKECMDGOALS))) CXXFLAGS += -mwindows LDFLAGS += -liconv endif WINDRES = windres MAKE = make ifeq (, $(findstring curses, $(MAKECMDGOALS))) plat_flag = -DGTK GTK_CFLAGS = $(shell PKG_CONFIG_PATH=`pwd`/win32gtk/lib/pkgconfig \ pkg-config --define-variable=prefix=win32gtk \ --cflags gtk+-2.0) GTK_LIBS = $(shell PKG_CONFIG_PATH=`pwd`/win32gtk/lib/pkgconfig \ pkg-config --define-variable=prefix=win32gtk \ --libs gtk+-2.0) GLIB_CFLAGS = $(shell PKG_CONFIG_PATH=`pwd`/win32gtk/lib/pkgconfig \ pkg-config --define-variable=prefix=win32gtk \ --cflags glib-2.0) else plat_flag = -DCURSES CURSES_CFLAGS = -DLIBICONV_STATIC -Iwin32curses/include CURSES_LIBS = win32curses/lib/pdcurses.a win32curses/lib/libiconv.a endif libluajit = luajit/src/lua51.dll else ifeq (osx, $(findstring osx, $(MAKECMDGOALS))) # Cross-compile for Mac OSX. CROSS = i686-apple-darwin10- CFLAGS = -m32 -arch i386 -mdynamic-no-pic -mmacosx-version-min=10.5 \ -isysroot /usr/lib/apple/SDKs/MacOSX10.5.sdk -Os CXXFLAGS = -m32 -arch i386 -mdynamic-no-pic -mmacosx-version-min=10.5 \ -isysroot /usr/lib/apple/SDKs/MacOSX10.5.sdk -Os LUA_CFLAGS = -DLUA_USE_MACOSX LDFLAGS = -liconv -rdynamic MAKE = make ifeq (, $(findstring curses, $(MAKECMDGOALS))) plat_flag = -DGTK GTK_CFLAGS = $(shell PKG_CONFIG_PATH=`pwd`/gtkosx/lib/pkgconfig \ pkg-config --define-variable=prefix=gtkosx \ --cflags gtk+-2.0) GTK_LIBS = $(shell PKG_CONFIG_PATH=`pwd`/gtkosx/lib/pkgconfig \ pkg-config --define-variable=prefix=gtkosx \ --libs gtk+-2.0 gmodule-2.0 gtk-mac-integration) \ -framework Cocoa GLIB_CFLAGS = $(shell PKG_CONFIG_PATH=`pwd`/gtkosx/lib/pkgconfig \ pkg-config --define-variable=prefix=gtkosx \ --cflags glib-2.0) else plat_flag = -DCURSES -D_XOPEN_SOURCE_EXTENDED CURSES_LIBS = -lncurses endif libluajit = luajit/src/libluajit.osx.a else # Build for Linux/BSD. CFLAGS = -Os CXXFLAGS = -Os -std=c++0x LUA_CFLAGS = -DLUA_USE_LINUX LDFLAGS = -rdynamic -Wl,--retain-symbols-file -Wl,lua.sym ifeq (Linux, $(shell uname -s)) LDFLAGS += -ldl MAKE = make else LDFLAGS += -liconv MAKE = gmake endif PREFIX ?= /usr/local bin_dir = $(DESTDIR)$(PREFIX)/bin data_dir = $(DESTDIR)$(PREFIX)/share/textadept ifeq (, $(findstring curses, $(MAKECMDGOALS))) plat_flag = -DGTK ifndef GTK3 gtk_version = 2.0 else gtk_version = 3.0 endif GTK_CFLAGS = $(shell pkg-config --cflags gtk+-$(gtk_version) gmodule-2.0) GTK_LIBS = $(shell pkg-config --libs gtk+-$(gtk_version) gmodule-2.0) GLIB_CFLAGS = $(shell pkg-config --cflags glib-2.0) install_targets = ../textadept ../textadeptjit else plat_flag = -DCURSES -D_XOPEN_SOURCE_EXTENDED CURSES_LIBS = -lncursesw install_targets = ../textadept-curses ../textadeptjit-curses endif libluajit = luajit/src/libluajit.a endif # Scintilla. sci_flags = -pedantic $(plat_flag) -DSCI_LEXER -DNDEBUG -DNO_CXX11_REGEX \ -Iscintilla/include -Iscintilla/src -Iscintilla/lexlib -Wall sci_objs = AutoComplete.o CallTip.o CaseConvert.o CaseFolder.o Catalogue.o \ CellBuffer.o CharClassify.o ContractionState.o Decoration.o \ Document.o EditModel.o Editor.o EditView.o ExternalLexer.o \ Indicator.o KeyMap.o LineMarker.o MarginView.o PerLine.o \ PositionCache.o RESearch.o RunStyles.o ScintillaBase.o Selection.o \ Style.o UniConversion.o ViewStyle.o XPM.o sci_lex_objs = Accessor.o CharacterSet.o LexerBase.o LexerModule.o \ LexerNoExceptions.o LexerSimple.o PropSetSimple.o \ StyleContext.o WordList.o sci_gtk_objs = PlatGTK.o ScintillaGTK.o lexlpeg_objs = LexLPeg.o LexLPegjit.o LexLPeg-curses.o LexLPegjit-curses.o # Textadept. ta_flags = -std=c99 -pedantic -D_POSIX_C_SOURCE=200809L -D_DARWIN_C_SOURCE \ $(plat_flag) -Iscintilla/include -Igtdialog -W -Wall -Wno-unused textadept_gtk_objs = textadept.o textadeptjit.o textadept_curses_objs = textadept-curses.o textadeptjit-curses.o textadept_objs = $(textadept_gtk_objs) $(textadept_curses_objs) lua_objs = lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o \ linit.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o \ lstring.o ltable.o ltm.o lundump.o lvm.o lzio.o \ lauxlib.o lbaselib.o lbitlib.o lcorolib.o ldblib.o liolib.o \ lmathlib.o loadlib.o loslib.o lstrlib.o ltablib.o lutf8lib.o lua_lib_objs = lpcap.o lpcode.o lpprint.o lptree.o lpvm.o lfs.o lutf8libext.o luajit_lib_objs = lpcapjit.o lpcodejit.o lpprintjit.o lptreejit.o lpvmjit.o \ lfsjit.o lutf8libjit.o lutf8libextjit.o lua_spawn_objs = lspawn.o lspawnjit.o lspawn-curses.o lspawnjit-curses.o gtdialog_objs = gtdialog.o gtdialog-curses.o termkey_unix_objs = driver-ti.o driver-csi.o termkey_win32_objs = driver-win32-pdcurses.o termkey_objs = termkey.o $(termkey_unix_objs) $(termkey_win32_objs) cdk_objs = binding.o buttonbox.o cdk.o cdk_display.o cdk_objs.o cdkscreen.o \ draw.o entry.o fselect.o itemlist.o label.o mentry.o popup_label.o \ scroll.o scroller.o select_file.o selection.o traverse.o version.o # Add debugging symbols and disable optimizations when DEBUG=1. # Note: In order to profile with gprof (-pg), do not retain symbols in LDFLAGS. ifdef DEBUG CFLAGS += -g -O0 CXXFLAGS += -g -O0 endif # Build. all: textadept textadeptjit curses: textadept-curses textadeptjit-curses win32: textadept.exe textadeptjit.exe win32-curses: textadept-curses.exe textadeptjit-curses.exe osx: textadept textadeptjit osx-curses: textadept-curses textadeptjit-curses $(sci_objs): %.o: scintilla/src/%.cxx $(CROSS)$(CXX) -c $(CXXFLAGS) $(sci_flags) $< -o $@ $(sci_lex_objs): %.o: scintilla/lexlib/%.cxx $(CROSS)$(CXX) -c $(CXXFLAGS) $(sci_flags) $< -o $@ $(sci_gtk_objs): %.o: scintilla/gtk/%.cxx $(CROSS)$(CXX) -c $(CXXFLAGS) $(sci_flags) $(GTK_CFLAGS) $< -o $@ scintilla-marshal.o: scintilla/gtk/scintilla-marshal.c $(CROSS)$(CC) -c $(CFLAGS) $(GTK_CFLAGS) $< -o $@ ScintillaTerm.o: scintilla/term/ScintillaTerm.cxx $(CROSS)$(CXX) -c $(CXXFLAGS) $(sci_flags) $(CURSES_CFLAGS) $< -o $@ $(lexlpeg_objs): LexLPeg.cxx $(CROSS)$(CXX) -c $(CXXFLAGS) $(LUA_CFLAGS) $(sci_flags) $< -o $@ $(textadept_objs): textadept.c $(CROSS)$(CC) -c $(CFLAGS) $(LUA_CFLAGS) $(ta_flags) $< -o $@ $(lua_objs): %.o: lua/src/%.c $(CROSS)$(CC) -c $(CFLAGS) $(LUA_CFLAGS) -ULUA_LIB $< -o $@ $(lua_lib_objs): %.o: lua/src/lib/%.c $(CROSS)$(CC) -c $(CFLAGS) $(LUA_CFLAGS) $< -o $@ $(luajit_lib_objs): %jit.o: lua/src/lib/%.c $(CROSS)$(CC) -c $(CFLAGS) $(LUA_CFLAGS) $< -o $@ $(lua_spawn_objs): lua/src/lib/lspawn.c $(CROSS)$(CC) -c $(CFLAGS) $(LUA_CFLAGS) -std=c99 -pedantic -D_XOPEN_SOURCE \ $(spawn_flags) $< -o $@ luajit/src/libluajit.a: ; $(MAKE) -C luajit CC="$(CC) $(CFLAGS)" luajit/src/lua51.dll: $(MAKE) -C luajit HOST_CC="$(CC) -m32" CROSS=$(CROSS) TARGET_SYS=Windows luajit/src/libluajit.osx.a: $(MAKE) -C luajit CC="$(CC) -m32" CROSS=$(CROSS) TARGET_SYS=Darwin \ LUAJIT_A=$(notdir $@) || return 0 $(gtdialog_objs): gtdialog/gtdialog.c $(CROSS)$(CC) -c $(CFLAGS) -std=c99 -pedantic -D_POSIX_C_SOURCE=200809L \ $(gtdialog_flags) $< -o $@ $(cdk_objs): %.o: cdk/%.c $(CROSS)$(CC) -c $(CFLAGS) -D_GNU_SOURCE -Itermkey -Icdk $(CURSES_CFLAGS) $< \ -o $@ $(termkey_objs): %.o: termkey/%.c $(CROSS)$(CC) -c $(CFLAGS) -std=c99 $(termkey_flags) $< -o $@ textadept_rc.o: textadept.rc ; $(CROSS)$(WINDRES) $< $@ # Target-specific variables. $(lexlpeg_objs): sci_flags += -DLPEG_LEXER -DNO_SCITE -Wno-long-long LexLPeg-curses.o LexLPegjit-curses.o: sci_flags += -DCURSES $(CURSES_CFLAGS) lua_dep_objs = LexLPeg.o LexLPeg-curses.o textadept.o textadept-curses.o \ $(lua_objs) $(lua_lib_objs) lspawn.o lspawn-curses.o luajit_dep_objs = LexLPegjit.o LexLPegjit-curses.o textadeptjit.o \ textadeptjit-curses.o $(luajit_lib_objs) lspawnjit.o \ lspawnjit-curses.o $(lua_dep_objs): LUA_CFLAGS += -Ilua/src $(luajit_dep_objs): LUA_CFLAGS += -Iluajit/src $(textadept_gtk_objs): ta_flags += $(GTK_CFLAGS) $(textadept_curses_objs): \ ta_flags += -Iscintilla/term -Itermkey -Icdk $(CURSES_CFLAGS) lspawn.o lspawnjit.o: spawn_flags = -DGTK $(GLIB_CFLAGS) $(gtdialog_objs): gtdialog_flags = $(plat_flag) -DNOHELP -DLIBRARY gtdialog.o: gtdialog_flags += $(GTK_CFLAGS) gtdialog-curses.o: gtdialog_flags += -Icdk $(CURSES_CFLAGS) $(termkey_win32_objs): termkey_flags += $(CURSES_CFLAGS) # Lua 5.3 compatibility with LuaJIT. lbitlib.o linit.o: LUA_CFLAGS += -DLUA_COMPAT_BITLIB -DLUA_COMPAT_APIINTCASTS lutf8libjit.o: LUA_CFLAGS += -Ilua/src # Executables. textadept: $(sci_objs) $(sci_lex_objs) $(sci_gtk_objs) scintilla-marshal.o \ LexLPeg.o textadept.o $(lua_objs) $(lua_lib_objs) lspawn.o gtdialog.o $(CROSS)$(CXX) $(CXXFLAGS) -o ../$@ $^ $(GTK_LIBS) $(LDFLAGS) textadeptjit: $(sci_objs) $(sci_lex_objs) $(sci_gtk_objs) scintilla-marshal.o \ LexLPegjit.o textadeptjit.o $(luajit_lib_objs) $(libluajit) \ lspawnjit.o gtdialog.o $(CROSS)$(CXX) $(CXXFLAGS) -o ../$@ $^ $(GTK_LIBS) $(LDFLAGS) textadept-curses: $(sci_objs) $(sci_lex_objs) ScintillaTerm.o LexLPeg-curses.o \ textadept-curses.o $(lua_objs) $(lua_lib_objs) \ lspawn-curses.o gtdialog-curses.o termkey.o \ $(termkey_unix_objs) $(cdk_objs) $(CROSS)$(CXX) $(CXXFLAGS) -o ../$@ $^ $(CURSES_LIBS) $(LDFLAGS) textadeptjit-curses: $(sci_objs) $(sci_lex_objs) ScintillaTerm.o \ LexLPegjit-curses.o textadeptjit-curses.o \ $(luajit_lib_objs) $(libluajit) lspawnjit-curses.o \ gtdialog-curses.o termkey.o $(termkey_unix_objs) \ $(cdk_objs) $(CROSS)$(CXX) $(CXXFLAGS) -o ../$@ $^ $(CURSES_LIBS) $(LDFLAGS) textadept.exe: $(sci_objs) $(sci_lex_objs) $(sci_gtk_objs) scintilla-marshal.o \ LexLPeg.o textadept.o textadept_rc.o $(lua_objs) \ $(lua_lib_objs) lspawn.o gtdialog.o $(CROSS)$(CXX) $(CXXFLAGS) -o ../$@ $^ $(GTK_LIBS) $(LDFLAGS) textadeptjit.exe: $(sci_objs) $(sci_lex_objs) $(sci_gtk_objs) \ scintilla-marshal.o LexLPegjit.o textadeptjit.o \ textadept_rc.o $(luajit_lib_objs) $(libluajit) lspawnjit.o \ gtdialog.o $(CROSS)$(CXX) $(CXXFLAGS) -o ../$@ $^ $(GTK_LIBS) $(LDFLAGS) textadept-curses.exe: $(sci_objs) $(sci_lex_objs) ScintillaTerm.o \ LexLPeg-curses.o textadept-curses.o textadept_rc.o \ $(lua_objs) $(lua_lib_objs) lspawn-curses.o \ gtdialog-curses.o termkey.o $(termkey_win32_objs) \ $(cdk_objs) $(CROSS)$(CXX) $(CXXFLAGS) -o ../$@ $^ $(CURSES_LIBS) $(LDFLAGS) textadeptjit-curses.exe: $(sci_objs) $(sci_lex_objs) ScintillaTerm.o \ LexLPegjit-curses.o textadeptjit-curses.o \ textadept_rc.o $(luajit_lib_objs) $(libluajit) \ lspawnjit-curses.o gtdialog-curses.o termkey.o \ $(termkey_win32_objs) $(cdk_objs) $(CROSS)$(CXX) $(CXXFLAGS) -o ../$@ $^ $(CURSES_LIBS) $(LDFLAGS) # Install/uninstall. install: $(install_targets) | ../core ../doc ../init.lua ../lexers ../LICENSE \ ../modules ../properties.lua ../themes install -d $(bin_dir) $(data_dir) install $^ $(data_dir) cp -r $| $(data_dir) ln -s $(subst .., $(subst $(DESTDIR),, $(data_dir)), $^) $(bin_dir) uninstall: ; rm -r $(bin_dir)/textadept* $(data_dir) # Clean. clean: $(MAKE) -C luajit clean rm -f *.o ../textadept* # Documentation. doc: manual luadoc manual: ../*.md ../doc/manual.md | ../doc/bombay $| -d ../doc -t ../doc --title Textadept $^ luadoc: ../modules ../core ../lexers cd ../doc && luadoc -d . -t . --doclet markdowndoc $^/lexer.lua cd ../modules && luadoc -d lua --doclet lua/tadoc $^/lexer.lua # Releases. ifndef NIGHTLY basedir = textadept_$(shell grep -m 1 _RELEASE ../core/init.lua | \ cut -d ' ' -f4- | tr ' ' '_' | tr -d '"') else basedir = textadept_NIGHTLY_$(shell date +"%F") endif osxapp = Textadept.app osxapp_bin = $(osxapp)/Contents/MacOS osxapp_res = $(osxapp)/Contents/Resources osxapp_libs = libatk-1.0.0.dylib libcairo.2.dylib libexpat.1.dylib \ libffi.5.dylib libfontconfig.1.dylib libfreetype.6.dylib \ libgdk_pixbuf-2.0.0.dylib libgdk-quartz-2.0.0.dylib \ libgio-2.0.0.dylib libglib-2.0.0.dylib libgmodule-2.0.0.dylib \ libgobject-2.0.0.dylib \ libgtkmacintegration.2.dylib libgtk-quartz-2.0.0.dylib \ libintl.8.dylib libpango-1.0.0.dylib libpangocairo-1.0.0.dylib \ libpangoft2-1.0.0.dylib libpixman-1.0.dylib libpng14.14.dylib \ charset.alias gdk-pixbuf-2.0 gtk-2.0 pango release-all: release release64 win32-release osx-release modules-release $(basedir).i386: ; hg archive $@ -X ".hg*" release: $(basedir).i386 make deps clean doc sign-deps PKG_CONFIG_PATH=/opt/gtk/lib/pkgconfig make -j4 make -j4 CURSES_CFLAGS=-I/opt/ncursesw/include/ncursesw \ CURSES_LIBS="-L/opt/ncursesw/lib -lncursesw" curses cp -r ../doc ../lexers ../textadept* $< && cp *.asc $